DataStructs.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 //
4 // TCAlg data structs
5 //
6 // Bruce Baller
7 //
8 ///////////////////////////////////////////////////////////////////////
9 #ifndef TRAJCLUSTERALGDATASTRUCT_H
10 #define TRAJCLUSTERALGDATASTRUCT_H
11 
12 // C/C++ standard libraries
13 #include <array>
14 #include <bitset>
15 #include <vector>
16 
17 // LArSoft libraries
19 
20 namespace TMVA {
21  class Reader;
22 }
23 namespace calo {
24  class CalorimetryAlg;
25 }
26 namespace geo {
27  class GeometryCore;
28 }
29 namespace recob {
30  class Hit;
31  class SpacePoint;
32 }
33 namespace simb {
34  class MCParticle;
35 }
36 struct SortEntry {
37  unsigned int index;
38  float val;
39 };
40 
41 namespace tca {
42 
43  using Point3_t = std::array<double, 3>;
44  using Vector3_t = std::array<double, 3>;
45  using Point2_t = std::array<float, 2>;
46  using Vector2_t = std::array<double, 2>;
47 
48  // some functions to handle the CTP_t type
49  typedef unsigned int CTP_t;
50  constexpr unsigned int Tpad = 10; // alignment for CTP sub-items - TPC
51  constexpr unsigned int Cpad = 10000; // alignment for CTP sub-items - Cryostat
52 
53  inline CTP_t
54  EncodeCTP(unsigned int cryo, unsigned int tpc, unsigned int plane)
55  {
56  return cryo * Cpad + tpc * Tpad + plane;
57  }
58  inline CTP_t
59  EncodeCTP(const geo::PlaneID& planeID)
60  {
61  return EncodeCTP(planeID.Cryostat, planeID.TPC, planeID.Plane);
62  }
63  inline CTP_t
64  EncodeCTP(const geo::WireID& wireID)
65  {
66  return EncodeCTP(wireID.Cryostat, wireID.TPC, wireID.Plane);
67  }
68  geo::PlaneID DecodeCTP(CTP_t CTP);
69 
70  /// @{
71  /// @name Data structures for the reconstruction results
72 
73  /// struct of temporary 2D vertices (end points)
74  struct VtxStore {
75  Point2_t Pos{{0, 0}};
76  Point2_t PosErr{{2, 1}};
77  unsigned short NTraj{0};
78  unsigned short Pass{0}; // Pass in which this vertex was created
79  float ChiDOF{0};
80  // Topo: 0 = end0-end0, 1 = end0(1)-end1(0), 2 = end1-end1, 3 = CI3DV,
81  // 4 = C3DIVIG, 5 = FHV, 6 = FHV2, 7 = SHCH, 8 = CTBC, 9 = Junk, 10 = HamBragg, 11 = neutral decay (pizero)
82  // 12 = BraggSplit, 13 = Not Used, 14 = Reconcile2VTs
83  short Topo{0};
84  CTP_t CTP{0};
85  int ID{0}; ///< set to 0 if killed
86  int UID{0}; ///< unique global ID
87  int Vx3ID{0};
88  float Score{0};
89  float TjChgFrac{0}; ///< Fraction of charge near the vertex that is from hits on the vertex Tjs
90  std::bitset<16> Stat{0}; ///< Vertex status bits using kVtxBit_t
91  };
92 
93  typedef enum {
94  kVtxTrjTried, ///< FindVtxTraj algorithm tried
95  kFixed, ///< vertex position fixed manually - no fitting done
97  kHiVx3Score, ///< matched to a high-score 3D vertex
98  kVxTruMatch, ///< tagged as a vertex between Tjs that are matched to MC truth neutrino interaction particles
100  kVxIndPlnNoChg, ///< vertex quality is suspect - No requirement made on chg btw it and the Tj
101  kVxEnvOK, ///< the environment near the vertex was checked - See UpdateVxEnvironment
102  kVxBitSize ///< don't mess with this line
103  } VtxBit_t;
104 
105  /// struct of temporary 3D vertices
106  struct Vtx3Store {
107  float X{0}; // x position
108  float XErr{0.5}; // x position error
109  float Y{0}; // y position
110  float YErr{0.5}; // y position error
111  float Z{0}; // z position
112  float ZErr{0.5}; // z position error
113  float Score{0};
114  int Wire{-1}; // wire number for an incomplete 3D vertex
116  std::vector<int> Vx2ID; // List of 2D vertex IDs in each plane
117  int ID{0}; // 0 = obsolete vertex
118  int UID{0}; ///< unique global ID
119  bool Primary{false};
120  bool Neutrino{false};
121  };
122 
123  // The (y,z) position of a valid wire intersection of two wires on two planes +
124  // + the (y,z) position variation for a one wire change in pln1 and pln2
126  unsigned short pln1;
127  unsigned short pln2;
128  float wir1;
129  float wir2;
130  double y;
131  double z;
132  double dydw1;
133  double dzdw1;
134  double dydw2;
135  double dzdw2;
136  unsigned int tpc;
137  };
138 
139  // A temporary struct for matching trajectory points; 1 struct for each TP for
140  // each trajectory. These are put into mallTraj which is then sorted by increasing xlo
141  struct Tj2Pt {
142  unsigned int wire;
143  // x range spanned by hits on the TP
144  float xlo;
145  float xhi;
146  unsigned short plane;
147  // the Trajectory ID
148  unsigned short id;
149  unsigned short ipt; // The trajectory point
150  // the number of points in the Tj so that the minimum Tj length cut (MatchCuts[2]) can be made
151  unsigned short npts;
152  };
153 
154  struct TrajPoint {
155  CTP_t CTP{0}; ///< Cryostat, TPC, Plane code
156  Point2_t HitPos{{0, 0}}; // Charge weighted position of hits in wire equivalent units
157  Point2_t Pos{{0, 0}}; // Trajectory position in wire equivalent units
158  Vector2_t Dir{{0, 0}}; // Direction cosines in the StepDir direction
159  double HitPosErr2{0}; // Uncertainty^2 of the hit position perpendiclar to the direction
160  // HitPosErr2 < 0 = HitPos not defined because no hits used
161  double Ang{0}; // Trajectory angle (-pi, +pi)
162  double AngErr{0.1}; // Trajectory angle error
163  float KinkSig{-1}; // kink significance = delta angle / angle error
164  float Chg{0}; // Chargetj2pt
165  float AveChg{-1}; // Average charge of last ~20 TPs
166  float ChgPull{0.1}; // = (Chg - AveChg) / ChgRMS
167  float Delta{0}; // Deviation between trajectory and hits (WSE)
168  float DeltaRMS{0.02}; // RMS of Deviation between trajectory and hits (WSE)
169  float FitChi{0}; // Chi/DOF of the fit
170  int InPFP{0}; // ID of the PFParticle that owns this TP
171  unsigned short NTPsFit{2}; // Number of trajectory points fitted to make this point
172  unsigned short Step{0}; // Step number at which this TP was created
173  unsigned short AngleCode{0}; // 0 = small angle, 1 = large angle, 2 = very large angle
174  std::vector<unsigned int> Hits; // vector of fHits indices
175  std::bitset<16> UseHit{0}; // set true if the hit is used in the fit
176  std::bitset<8> Environment{0}; // TPEnvironment_t bitset that describes the environment
177  };
178 
179  // struct filled by FitPar which fits TP Chg, Delta, etc
180  struct ParFit {
181  Point2_t Pos{{0, 0}}; // position origin of the fit
182  float Par0;
183  float AvePar;
184  float ParErr;
185  float ParSlp; // slope relative to the origin
186  float ParSlpErr;
187  float ChiDOF;
188  unsigned short nPtsFit;
189  };
190 
191  // Global information for the trajectory
192  struct Trajectory {
193  std::vector<TrajPoint> Pts; ///< Trajectory points
194  CTP_t CTP{0}; ///< Cryostat, TPC, Plane code
195  std::bitset<128> AlgMod; ///< Bit set if algorithm AlgBit_t modifed the trajectory
196  int WorkID{0};
197  int ParentID{
198  -1}; ///< ID of the parent, or the ID of the Tj this one was merged with if it is killed
199  float AveChg{0}; ///< Calculated using ALL hits
200  float TotChg{0}; ///< Total including an estimate for dead wires
201  float ChgRMS{0.5}; /// Normalized RMS using ALL hits. Assume it is 50% to start
202  short MCSMom{0}; //< Crude 2D estimate to use for shower-like vs track-like discrimination
203  Point2_t dEdx{{0, 0}}; ///< dE/dx for 3D matched trajectories
204  std::array<unsigned short, 2> VtxID{{0, 0}}; ///< ID of 2D vertex
205  std::array<unsigned short, 2> EndPt{
206  {0, 0}}; ///< First and last point in the trajectory that has charge
207  int ID; ///< ID that is local to one slice
208  int UID; ///< a unique ID for all slices
209  int SSID{0}; ///< ID of a 2D shower struct that this tj is in
210  unsigned short PDGCode{0}; ///< shower-like or track-like {default is track-like}
211  unsigned short Pass{0}; ///< the pass on which it was created
212  short StepDir{0}; ///< -1 = going US (-> small wire#), 1 = going DS (-> large wire#)
213  short StartEnd{-1}; ///< The starting end (-1 = don't know)
214  std::array<std::bitset<8>, 2> EndFlag{}; // Bitset that encodes the reason for stopping
215  std::bitset<8> Strategy{}; ///
216  bool NeedsUpdate{false}; ///< Set true when the Tj needs to be updated
217  bool IsGood{true}; ///< set false if there is a failure or the Tj fails quality cuts
218  bool MaskedLastTP{false};
219  };
220 
221  struct TjForecast {
222  unsigned short nextForecastUpdate{
223  0}; ///< Revise the forecast when NumPtsWithCharge == nextForecastUpdate
224  float showerLikeFraction{
225  0}; ///< fraction of points in the forecast envelope that are shower-like
226  float outlook{-1}; ///< tracklike ~< 2, showerlike > 2
227  float chgSlope{0};
228  float chgSlopeErr{0};
229  float chgFitChiDOF{0};
230  float chgRMS{0};
231  short MCSMom{0};
232  bool leavesBeforeEnd{false}; ///< leaves the forecast envelope before the end
233  bool foundShower{false};
234  bool endBraggPeak{false};
235  };
236 
237  // Temporary 3D trajectory points composed of triplet or doublet wire intersections
238  struct TrajPoint3 {
239  Point3_t Pos{{0.0, 0.0, 0.0}};
240  Vector3_t Dir{{0.0, 0.0, 0.0}};
241  std::vector<Tj2Pt> Tj2Pts; // list of trajectory points
242  };
243 
244  struct SectionFit {
245  Point3_t Pos{{-10.0, 0.0, 0.0}}; ///< center position of this section
246  Vector3_t Dir{{0.0, 0.0, 0.0}}; ///< and direction
247  Vector3_t DirErr{{0.0, 0.0, 0.0}}; ///< and direction error
248  float ChiDOF{-1};
249  unsigned short NPts{0};
250  bool NeedsUpdate{true}; ///< set true if the section needs to be updated
251  };
252 
253  // a 3D trajectory point composed of a 3D point & direction and a single TP
254  struct TP3D {
255  Point3_t Pos{{-10.0, -10.0, -10.0}}; ///< position of the trajectory
256  Vector3_t Dir{{0.0, 0.0, 0.0}};
257  double TPX{-10}; ///< X position of the TP or the single hit
258  double TPXErr2{1}; ///< (X position error)^2
259  float Wire{-1};
260  float along{1E6}; ///< distance from the start Pos of the section
261  int TjID{0}; ///< ID of the trajectory -> TP3D assn
262  CTP_t CTP;
263  unsigned short TPIndex{USHRT_MAX}; ///< and the TP index
264  unsigned short SFIndex{USHRT_MAX}; ///< and the section fit index
265  std::bitset<8> Flags; //< see TP3DFlags_t
266  };
267 
268  typedef enum {
269  kTP3DGood, // Is good for fitting and calorimetry
270  kTP3DBad, // Should be removed from the trajectory
271  kTP3DHiDEdx // Has high dE/dx
272  } TP3DFlags_t;
273 
274  // Struct for 3D trajectory matching
275  struct MatchStruct {
276  // IDs of Trajectories that match in all planes
277  std::vector<int> TjIDs;
278  // Count of the number of X-matched hits and de-weight by angle
279  float Count{0}; // Set to 0 if matching failed
280  };
281 
282  constexpr unsigned int pAlgModSize = 6; // alignment for CTP sub-items - TPC
283 
284  struct PFPStruct {
285  std::vector<int> TjIDs; // used to reference Tjs within a slice
286  std::vector<int> TjUIDs; // used to reference Tjs in any slice
287  std::vector<TP3D> TP3Ds; // vector of 3D trajectory points
288  std::vector<SectionFit> SectionFits;
289  // Start is 0, End is 1
290  std::array<std::vector<float>, 2> dEdx;
291  std::array<std::vector<float>, 2> dEdxErr;
292  std::array<int, 2> Vx3ID{{0, 0}};
293  int BestPlane{-1};
294  int PDGCode{-1};
295  std::vector<int> DtrUIDs;
296  size_t ParentUID{0}; // Parent PFP UID (or 0 if no parent exists)
298  float CosmicScore{0};
299  int ID{0};
300  int UID{0}; // unique global ID
301  unsigned short MVI; // matVec index for detailed debugging
302  std::bitset<8> Flags; //< see PFPFlags_t
303  std::array<std::bitset<8>, 2> EndFlag{}; // Uses the same enum as Trajectory EndFlag
304  std::bitset<pAlgModSize> AlgMod; //< Allocate the first set of bits in AlgBit_t for 3D algs
305  };
306 
307  typedef enum {
311  } PFPFlags_t;
312 
313  struct ShowerPoint {
314  Point2_t Pos; // Hit Position in the normal coordinate system
315  Point2_t
316  RotPos; // Position rotated into the shower coordinate system (0 = along, 1 = transverse)
317  float Chg{0}; // Charge of this point
318  unsigned int HitIndex; // the hit index
319  unsigned short
320  TID; // The ID of the tj the point (hit) is in. TODO eliminate this redundant variable
321  };
322 
323  // A temporary structure that defines a 2D shower-like cluster of trajectories
324  struct ShowerStruct {
325  CTP_t CTP;
326  int ShowerTjID{0}; // ID of the shower Trajectory composed of many InShower Tjs
327  std::vector<int> TjIDs; // list of InShower Tjs
328  std::vector<int> NearTjIDs; // list of Tjs that are not InShower but satisfy the maxSep cut
329  std::vector<ShowerPoint> ShPts; // Trajectory points inside the shower
330  float Angle{0}; // Angle of the shower axis
331  float AngleErr{3}; // Error
332  float AspectRatio{1}; // The ratio of charge weighted transverse/longitudinal positions
333  float DirectionFOM{1};
334  std::vector<Point2_t> Envelope; // Vertices of a polygon that encompasses the shower
335  float EnvelopeArea{0};
336  float ChgDensity{0}; // Charge density inside the Envelope
337  float Energy{0};
338  float ParentFOM{10};
339  int ID{0};
340  int UID{0}; ///< unique global ID
341  int ParentID{0}; // The ID of a parent Tj - the one at the start of the shower
342  int TruParentID{0};
343  int SS3ID{0}; // ID of a ShowerStruct3D to which this 2D shower is matched
344  bool NeedsUpdate{true}; // Needs to be updated (e.g. after adding a tj, defining a parent, etc)
345  };
346 
347  // Shower variables filled in MakeShowers. These are in cm and radians
348  struct ShowerStruct3D {
350  Vector3_t
351  DirErr; // DirErr is hijacked to store the shower rms at the start, center and end sections
353  Point3_t StartErr; // PosErr is hijacked to temporarily store the charge in the three sections
354  Point3_t ChgPos; // position of the center of charge
355  Point3_t End; // end position
356  double Len{1};
357  double OpenAngle{0.12};
358  std::vector<double> Energy;
359  std::vector<double> EnergyErr;
360  std::vector<double> MIPEnergy;
361  std::vector<double> MIPEnergyErr;
362  std::vector<double> dEdx;
363  std::vector<double> dEdxErr;
365  std::vector<int> CotIDs; // list of indices of 2D showers in tjs.cots
366  std::vector<unsigned int> Hits;
368  int ID;
369  int UID{0}; ///< unique global ID
370  int ParentID{0}; // The ID of a track-like pfp at the start of the shower, e.g. an electron
371  float MatchFOM;
372  unsigned short PFPIndex{USHRT_MAX}; // The index of the pfp for this shower
373  int Vx3ID{0};
374  bool NeedsUpdate{true}; // This is set true whenever the shower needs to be updated
375  bool Cheat{false};
376  };
377 
379  std::array<int, 2>
380  TjIDs; // pairs of Tjs that shouldn't be clustered in shower reconstruction because...
381  int Vx2ID; // they share a 2D vertex that may be matched to...
382  int Vx3ID; // a high-score 3D vertex
383  };
384 
385  struct ShowerTreeVars {
386  // run, subrun, and event are also saved to this tree
387 
388  std::vector<float> BeginWir; // begin wire
389  std::vector<float> BeginTim; // begin tick
390  std::vector<float> BeginAng; // begin angle
391  std::vector<float> BeginChg; // beginning average charge
392  std::vector<short> BeginVtx; // ID of begin vertex
393  std::vector<float> EndWir; // end wire
394  std::vector<float> EndTim; // end tick
395  std::vector<float> EndAng; // end angle
396  std::vector<float> EndChg; // ending average charge
397  std::vector<short> EndVtx; //ID of end vertex
398 
399  std::vector<short> MCSMom;
400 
401  std::vector<short> PlaneNum;
402 
403  std::vector<int> TjID;
404  std::vector<int> IsShowerTj; // indicates tj is an shower trajectory
405  std::vector<int> ShowerID; // shower ID associated w/ trajectory. -1 = no shower
406  std::vector<int> IsShowerParent; // this tj was chosen as a parent tj
407  std::vector<int> StageNum; // stage of reconstruction
408  std::vector<std::string> StageName; // stage name
409 
410  // envelope information
411  std::vector<float> Envelope;
412  std::vector<int> EnvPlane;
413  std::vector<int> EnvStage;
414  std::vector<int> EnvShowerID;
415 
416  int nStages{0};
417  unsigned short nPlanes{0};
418  };
419 
420  struct CRTreeVars {
421  std::vector<int> cr_origin;
422  std::vector<float> cr_pfpxmin;
423  std::vector<float> cr_pfpxmax;
424  std::vector<float> cr_pfpyzmindis;
425  };
426 
427  // Algorithm modification bits
428  typedef enum {
429  kFillGaps3D, // 3D algorithms for PFPs (bitset size limited to 8 bits)
434  kMat3D, // 2D algorithms for Tjs here and below
498  kAlgBitSize ///< don't mess with this line
499  } AlgBit_t;
500 
501  typedef enum {
503  kStiffEl, ///< use the stiff electron strategy
504  kStiffMu, ///< use the stiff muon strategy
505  kSlowing ///< use the slowing-down strategy
506  } Strategy_t;
507 
508  // Stop flag bits
509  typedef enum {
517  kFlagBitSize ///< don't mess with this line
518  } EndFlag_t;
519 
520  // Environment near a trajectory point
521  typedef enum {
527  kEnvNearSrcHit, ///< TP is near a hit in the srcHit collection but no allHit hit exists (DUNE disambiguation error)
528  kEnvFlag ///< a general purpose flag bit used in 3D matching
529  } TPEnvironment_t;
530 
531  // TrajClusterAlg configuration bits
532  typedef enum {
533  kStepDir, ///< step from US -> DS (true) or DS -> US (false)
534  kTestBeam, ///< Expect tracks entering from the front face. Don't create neutrino PFParticles
535  kDebug, ///< master switch for turning on debug mode
536  kStudy1, ///< call study functions to develop cuts, etc (see TCTruth.cxx)
537  kStudy2, ///< call study functions to develop cuts, etc
538  kStudy3, ///< call study functions to develop cuts, etc
539  kStudy4, ///< call study functions to develop cuts, etc
540  kSaveCRTree, ///< save cosmic ray tree
541  kTagCosmics, ///< tag cosmic rays
542  kSaveShowerTree ///< save shower tree
543  } TCModes_t;
544 
545  extern const std::vector<std::string> AlgBitNames;
546  extern const std::vector<std::string> EndFlagNames;
547  extern const std::vector<std::string> VtxBitNames;
548  extern const std::vector<std::string> StrategyBitNames;
549 
550  // struct for configuration - used in all slices
551  struct TCConfig {
552  std::vector<float> vtx2DCuts; ///< Max position pull, max Position error rms
553  std::vector<float> vtx3DCuts; ///< 2D vtx -> 3D vtx matching cuts
554  std::vector<float> vtxScoreWeights;
555  std::vector<float> neutralVxCuts;
556  std::vector<short> deltaRayTag;
557  std::vector<short> muonTag;
558  std::vector<float> electronTag;
559  std::vector<float> chkStopCuts; ///< Bragg peak finder configuration
560  std::vector<float> showerTag; ///< shower-like trajectory tagging + shower reconstruction
561  std::vector<float> kinkCuts; ///< kink finder algorithm
562  std::vector<float> match3DCuts; ///< 3D matching cuts
563  // std::vector<float> matchTruth; ///< Match to MC truth
564  std::vector<float> chargeCuts;
565  std::vector<float> qualityCuts; ///< Min points/wire, min consecutive pts after a gap
566  std::vector<float> pfpStitchCuts; ///< cuts for stitching between TPCs
567  std::vector<unsigned short> minPtsFit; ///< Reconstruct in several passes
568  std::vector<unsigned short> minPts; ///< min number of Pts required to make a trajectory
569  std::vector<unsigned short> maxAngleCode; ///< max allowed angle code for each pass
570  std::vector<short> minMCSMom; ///< Min MCSMom for each pass
571  std::vector<float> angleRanges; ///< list of max angles for each angle range
572  float wirePitch;
573  float unitsPerTick; ///< scale factor from Tick to WSE equivalent units
574  std::vector<float> maxPos0;
575  std::vector<float> maxPos1;
576  float multHitSep; ///< preferentially "merge" hits with < this separation
577  float maxChi;
580  TMVA::Reader* showerParentReader;
581  std::vector<float> showerParentVars;
582  float hitErrFac;
583  float maxWireSkipNoSignal; ///< max number of wires to skip w/o a signal on them
584  float maxWireSkipWithSignal; ///< max number of wires to skip with a signal on them
586  float VLAStepSize;
587  float JTMaxHitSep2; /// Max hit separation for making junk trajectories. < 0 to turn off
588  std::bitset<128> useAlg; ///< Allow user to mask off specific algorithms
589  std::bitset<128> dbgAlg; ///< Allow user to turn on debug printing in algorithms (that print...)
590  short recoSlice{0}; ///< only reconstruct the slice with ID (0 = all)
591  short recoTPC{-1}; ///< only reconstruct in the seleted TPC
592  bool dbgSlc{true}; ///< debug only in the user-defined slice? default is all slices
593  bool dbgStp{false}; ///< debug stepping using debug.Cryostat, debug.TPC, etc
594  bool dbgMrg{false};
595  bool dbg2V{false}; ///< debug 2D vertex finding
596  bool dbgVxNeutral{false};
597  bool dbgVxMerge{false};
598  bool dbgVxJunk{false};
599  bool dbg3V{false}; ///< debug 3D vertex finding
600  bool dbgPFP{false};
601  bool dbgDeltaRayTag{false};
602  bool dbgMuonTag{false};
603  bool dbg2S{false};
604  bool dbg3S{false};
605  bool dbgStitch{false}; ///< debug PFParticle stitching
606  bool dbgSummary{false}; ///< print a summary report
607  bool dbgDump{false}; /// dump trajectory points
608  short nPtsAve; /// number of points to find AveChg
609  std::bitset<16> modes; /// See TCMode_t above
610  bool doForecast{true};
611  bool useChannelStatus{true};
612  };
613 
614  struct TCHit {
615  unsigned int allHitsIndex; // index into fHits
616  int InTraj{
617  0}; // ID of the trajectory this hit is used in, 0 = none, < 0 = Tj under construction
618  };
619 
620  // hit collection for all slices, TPCs and cryostats + event information
621  // Note: Ideally this hit collection would be the FULL hit collection before cosmic removal
622  struct TCEvent {
624  std::vector<recob::Hit> const* allHits = nullptr;
625  std::vector<recob::Hit> const* srcHits = nullptr;
626  // hit Range for the allHits collection in the current TPCID
627  // plane wire firstHit, lastHit
628  std::vector<std::vector<std::pair<unsigned int, unsigned int>>> wireHitRange;
629  // hit range for the srcHits collection
630  std::vector<std::pair<unsigned int, unsigned int>> tpcSrcHitRange;
631  // list of good wires in the current TPCID
632  std::vector<std::vector<bool>> goodWire;
633  std::vector<recob::SpacePoint> const* sptHandle =
634  nullptr; ///< handle to SpacePoints in the event
635  std::vector<std::array<unsigned int, 3>> sptHits; ///< SpacePoint -> Hits assns by plane
636  unsigned int event;
637  unsigned int run;
638  unsigned int subRun;
639  unsigned int eventsProcessed;
640  std::vector<float> aveHitRMS; ///< average RMS of an isolated hit
641  std::vector<TCWireIntersection> wireIntersections;
642  int WorkID;
649  bool aveHitRMSValid{false}; ///< set true when the average hit RMS is well-known
650  bool expectSlicedHits{
651  false}; ///< info passed from the module - used to (not) define wireHitRange
652  };
653 
654  struct TCSlice {
655  std::vector<unsigned int> nWires;
656  std::vector<unsigned int> firstWire; ///< the first wire with a hit
657  std::vector<unsigned int> lastWire; ///< the last wire with a hit
658  float xLo; // fiducial volume of the current tpc
659  float xHi;
660  float yLo;
661  float yHi;
662  float zLo;
663  float zHi;
665  unsigned short nPlanes;
666  int ID; ///< ID of the recob::Slice (not the sub-slice)
667  // The variables below do change in size from event to event
668 
669  // Save histograms to develop cosmic removal tools
671  std::vector<TCHit> slHits;
672  std::vector<Trajectory> tjs; ///< vector of all trajectories in each plane
673  std::vector<Tj2Pt> mallTraj; ///< vector of trajectory points ordered by increasing X
674  // vector of pairs of first (.first) and last+1 (.second) hit on each wire
675  // in the range fFirstWire to fLastWire. A value of UINT_MAX indicates that there
676  // are no hits on the wire.
677  std::vector<std::vector<std::pair<unsigned int, unsigned int>>> wireHitRange;
678  std::vector<VtxStore> vtxs; ///< 2D vertices
679  std::vector<Vtx3Store> vtx3s; ///< 3D vertices
680  std::vector<PFPStruct> pfps;
681  std::vector<ShowerStruct> cots; // Clusters of Trajectories that define 2D showers
682  std::vector<DontClusterStruct>
683  dontCluster; // pairs of Tjs that shouldn't clustered in one shower
684  std::vector<ShowerStruct3D> showers; // 3D showers
685  bool isValid{false}; // set false if this slice failed reconstruction
686  };
687 
688  extern TCEvent evt;
689  extern TCConfig tcc;
690  extern ShowerTreeVars stv;
691  extern std::vector<TjForecast> tjfs;
692 
693  // vector of hits, tjs, etc in each slice
694  extern std::vector<TCSlice> slices;
695  // vector of seed TPs
696  extern std::vector<TrajPoint> seeds;
697 
698 } // namespace tca
699 
700 #endif // ifndef TRAJCLUSTERALGDATASTRUCT_H
Expect tracks entering from the front face. Don&#39;t create neutrino PFParticles.
Definition: DataStructs.h:534
calo::CalorimetryAlg * caloAlg
Definition: DataStructs.h:579
std::vector< int > EnvStage
Definition: DataStructs.h:413
short MCSMom(const TCSlice &slc, const std::vector< int > &tjIDs)
Definition: Utils.cxx:3466
std::vector< int > IsShowerParent
Definition: DataStructs.h:406
std::vector< Trajectory > tjs
vector of all trajectories in each plane
Definition: DataStructs.h:672
std::vector< float > cr_pfpyzmindis
Definition: DataStructs.h:424
std::array< std::vector< float >, 2 > dEdxErr
Definition: DataStructs.h:291
std::vector< float > kinkCuts
kink finder algorithm
Definition: DataStructs.h:561
unsigned int event
Definition: DataStructs.h:636
geo::TPCID TPCID
Definition: DataStructs.h:623
float ParSlpErr
Definition: DataStructs.h:186
std::vector< float > EndWir
Definition: DataStructs.h:393
Reconstruction base classes.
struct of temporary 2D vertices (end points)
Definition: DataStructs.h:74
FindVtxTraj algorithm tried.
Definition: DataStructs.h:94
std::vector< float > EndAng
Definition: DataStructs.h:395
const std::vector< std::string > AlgBitNames
Definition: DataStructs.cxx:15
std::vector< ShowerStruct > cots
Definition: DataStructs.h:681
unsigned int run
Definition: DataStructs.h:637
std::vector< double > dEdxErr
Definition: DataStructs.h:363
std::vector< float > maxPos0
Definition: DataStructs.h:574
std::vector< unsigned short > minPtsFit
Reconstruct in several passes.
Definition: DataStructs.h:567
std::vector< float > cr_pfpxmax
Definition: DataStructs.h:423
std::vector< int > NearTjIDs
Definition: DataStructs.h:328
std::array< double, 3 > Point3_t
Definition: DataStructs.h:43
std::vector< ShowerStruct3D > showers
Definition: DataStructs.h:684
std::vector< float > vtx3DCuts
2D vtx -> 3D vtx matching cuts
Definition: DataStructs.h:553
std::vector< float > qualityCuts
Min points/wire, min consecutive pts after a gap.
Definition: DataStructs.h:565
unsigned int index
Definition: DataStructs.h:37
std::vector< float > BeginTim
Definition: DataStructs.h:389
std::array< int, 2 > TjIDs
Definition: DataStructs.h:380
std::vector< Point2_t > Envelope
Definition: DataStructs.h:334
unsigned int ID
tagged as a vertex between Tjs that are matched to MC truth neutrino interaction particles ...
Definition: DataStructs.h:98
TCConfig tcc
Definition: DataStructs.cxx:8
unsigned short id
Definition: DataStructs.h:148
vertex position fixed manually - no fitting done
Definition: DataStructs.h:95
std::vector< int > TjIDs
Definition: DataStructs.h:277
std::vector< float > BeginAng
Definition: DataStructs.h:390
std::bitset< pAlgModSize > AlgMod
Definition: DataStructs.h:304
std::vector< std::vector< std::pair< unsigned int, unsigned int > > > wireHitRange
Definition: DataStructs.h:677
std::vector< int > Vx2ID
Definition: DataStructs.h:116
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
matched to a high-score 3D vertex
Definition: DataStructs.h:97
std::vector< unsigned int > Hits
Definition: DataStructs.h:174
std::vector< double > MIPEnergy
Definition: DataStructs.h:360
step from US -> DS (true) or DS -> US (false)
Definition: DataStructs.h:533
std::vector< int > TjIDs
Definition: DataStructs.h:327
VtxBit_t
Definition: DataStructs.h:93
TP3DFlags_t
Definition: DataStructs.h:268
float maxWireSkipWithSignal
max number of wires to skip with a signal on them
Definition: DataStructs.h:584
call study functions to develop cuts, etc
Definition: DataStructs.h:538
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:212
std::vector< std::pair< unsigned int, unsigned int > > tpcSrcHitRange
Definition: DataStructs.h:630
std::vector< Tj2Pt > Tj2Pts
Definition: DataStructs.h:241
std::vector< float > electronTag
Definition: DataStructs.h:558
a general purpose flag bit used in 3D matching
Definition: DataStructs.h:528
float ParentFOM(std::string inFcnLabel, TCSlice &slc, PFPStruct &pfp, unsigned short pend, ShowerStruct3D &ss3, bool prt)
Definition: TCShower.cxx:2075
std::vector< unsigned int > lastWire
the last wire with a hit
Definition: DataStructs.h:657
float AvePar
Definition: DataStructs.h:183
unsigned int eventsProcessed
Definition: DataStructs.h:639
std::vector< int > CotIDs
Definition: DataStructs.h:365
std::vector< std::array< unsigned int, 3 > > sptHits
SpacePoint -> Hits assns by plane.
Definition: DataStructs.h:635
std::vector< ShowerPoint > ShPts
Definition: DataStructs.h:329
Strategy_t
Definition: DataStructs.h:501
AlgBit_t
Definition: DataStructs.h:428
CRTreeVars crt
Definition: DataStructs.h:670
std::vector< float > angleRanges
list of max angles for each angle range
Definition: DataStructs.h:571
const std::vector< std::string > EndFlagNames
Definition: DataStructs.cxx:87
std::vector< float > showerTag
shower-like trajectory tagging + shower reconstruction
Definition: DataStructs.h:560
don&#39;t mess with this line
Definition: DataStructs.h:102
std::vector< float > EndTim
Definition: DataStructs.h:394
unsigned short plane
Definition: DataStructs.h:146
std::vector< int > ShowerID
Definition: DataStructs.h:405
ShowerTreeVars stv
Definition: DataStructs.cxx:10
unsigned short npts
Definition: DataStructs.h:151
unsigned short TID
Definition: DataStructs.h:320
std::vector< unsigned short > maxAngleCode
max allowed angle code for each pass
Definition: DataStructs.h:569
std::bitset< 8 > Flags
Definition: DataStructs.h:302
float projectionErrFactor
Definition: DataStructs.h:585
std::vector< int > TjUIDs
Definition: DataStructs.h:286
save shower tree
Definition: DataStructs.h:542
constexpr unsigned int Tpad
Definition: DataStructs.h:50
unsigned short ipt
Definition: DataStructs.h:149
std::vector< DontClusterStruct > dontCluster
Definition: DataStructs.h:683
const std::vector< std::string > StrategyBitNames
std::vector< std::string > StageName
Definition: DataStructs.h:408
CTP_t CTP
Definition: DataStructs.h:262
double dEdx(float dqdx, float Efield)
Definition: doAna.cpp:21
struct of temporary 3D vertices
Definition: DataStructs.h:106
geo::TPCID TPCID
Definition: DataStructs.h:297
short nPtsAve
dump trajectory points
Definition: DataStructs.h:608
std::vector< int > TjID
Definition: DataStructs.h:403
std::vector< Tj2Pt > mallTraj
vector of trajectory points ordered by increasing X
Definition: DataStructs.h:673
std::array< float, 2 > Point2_t
Definition: DataStructs.h:45
std::vector< float > maxPos1
Definition: DataStructs.h:575
don&#39;t mess with this line
Definition: DataStructs.h:517
float unitsPerTick
scale factor from Tick to WSE equivalent units
Definition: DataStructs.h:573
use the slowing-down strategy
Definition: DataStructs.h:505
std::vector< short > minMCSMom
Min MCSMom for each pass.
Definition: DataStructs.h:570
std::vector< short > BeginVtx
Definition: DataStructs.h:392
geo::TPCID TPCID
Definition: DataStructs.h:115
TP is near a hit in the srcHit collection but no allHit hit exists (DUNE disambiguation error) ...
Definition: DataStructs.h:527
unsigned int wire
Definition: DataStructs.h:142
the environment near the vertex was checked - See UpdateVxEnvironment
Definition: DataStructs.h:101
std::vector< float > aveHitRMS
average RMS of an isolated hit
Definition: DataStructs.h:640
std::vector< TrajPoint > Pts
Trajectory points.
Definition: DataStructs.h:193
TMVA::Reader * showerParentReader
Definition: DataStructs.h:580
std::vector< std::vector< bool > > goodWire
Definition: DataStructs.h:632
std::vector< float > showerParentVars
Definition: DataStructs.h:581
std::vector< float > neutralVxCuts
Definition: DataStructs.h:555
std::vector< short > EndVtx
Definition: DataStructs.h:397
unsigned short pln2
Definition: DataStructs.h:127
std::bitset< 8 > Flags
Definition: DataStructs.h:265
std::vector< VtxStore > vtxs
2D vertices
Definition: DataStructs.h:678
std::vector< int > cr_origin
Definition: DataStructs.h:421
std::vector< float > match3DCuts
3D matching cuts
Definition: DataStructs.h:562
std::vector< SectionFit > SectionFits
Definition: DataStructs.h:288
AdcSimulator::Count Count
std::vector< float > Envelope
Definition: DataStructs.h:411
call study functions to develop cuts, etc
Definition: DataStructs.h:539
const geo::GeometryCore * geom
Definition: DataStructs.h:578
std::vector< unsigned short > minPts
min number of Pts required to make a trajectory
Definition: DataStructs.h:568
int UID
a unique ID for all slices
Definition: DataStructs.h:208
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:493
Description of geometry of one entire detector.
constexpr unsigned int pAlgModSize
Definition: DataStructs.h:282
std::array< double, 2 > Vector2_t
Definition: DataStructs.h:46
Definition of data types for geometry description.
std::vector< unsigned int > Hits
Definition: DataStructs.h:366
std::vector< unsigned int > firstWire
the first wire with a hit
Definition: DataStructs.h:656
Base utilities and modules for event generation and detector simulation.
float ChiDOF
Definition: DataStructs.h:187
std::vector< float > BeginChg
Definition: DataStructs.h:391
int ID
ID that is local to one slice.
Definition: DataStructs.h:207
std::vector< TCSlice > slices
Definition: DataStructs.cxx:12
vertex quality is suspect - No requirement made on chg btw it and the Tj
Definition: DataStructs.h:100
std::bitset< 16 > modes
number of points to find AveChg
Definition: DataStructs.h:609
std::vector< TCHit > slHits
Definition: DataStructs.h:671
std::vector< float > chargeCuts
Definition: DataStructs.h:564
EndFlag_t
Definition: DataStructs.h:509
std::vector< int > EnvPlane
Definition: DataStructs.h:412
std::vector< TrajPoint > seeds
Definition: DataStructs.cxx:13
float ParSlp
Definition: DataStructs.h:185
float maxWireSkipNoSignal
max number of wires to skip w/o a signal on them
Definition: DataStructs.h:583
std::vector< short > MCSMom
Definition: DataStructs.h:399
float val
Definition: DataStructs.h:38
const std::vector< std::string > VtxBitNames
Definition: DataStructs.cxx:97
std::vector< double > EnergyErr
Definition: DataStructs.h:359
std::vector< double > MIPEnergyErr
Definition: DataStructs.h:361
std::vector< float > vtxScoreWeights
Definition: DataStructs.h:554
unsigned int CTP_t
Definition: DataStructs.h:49
std::vector< Vtx3Store > vtx3s
3D vertices
Definition: DataStructs.h:679
geo::TPCID TPCID
Definition: DataStructs.h:664
TCModes_t
Definition: DataStructs.h:532
std::vector< int > StageNum
Definition: DataStructs.h:407
std::vector< TjForecast > tjfs
Definition: DataStructs.cxx:9
std::bitset< 128 > useAlg
Max hit separation for making junk trajectories. < 0 to turn off.
Definition: DataStructs.h:588
CTP_t EncodeCTP(const geo::WireID &wireID)
Definition: DataStructs.h:64
std::vector< float > pfpStitchCuts
cuts for stitching between TPCs
Definition: DataStructs.h:566
std::vector< short > deltaRayTag
Definition: DataStructs.h:556
save cosmic ray tree
Definition: DataStructs.h:540
float ParErr
Definition: DataStructs.h:184
float VLAStepSize
Definition: DataStructs.h:586
std::bitset< 128 > AlgMod
Bit set if algorithm AlgBit_t modifed the trajectory.
Definition: DataStructs.h:195
call study functions to develop cuts, etc
Definition: DataStructs.h:537
std::vector< double > Energy
Definition: DataStructs.h:358
std::vector< short > muonTag
Definition: DataStructs.h:557
std::vector< float > BeginWir
Definition: DataStructs.h:388
geo::PlaneID DecodeCTP(CTP_t CTP)
std::vector< float > EndChg
Definition: DataStructs.h:396
std::vector< int > TjIDs
Definition: DataStructs.h:285
PFPFlags_t
Definition: DataStructs.h:307
std::bitset< 128 > dbgAlg
Allow user to turn on debug printing in algorithms (that print...)
Definition: DataStructs.h:589
std::vector< TCWireIntersection > wireIntersections
Definition: DataStructs.h:641
unsigned int HitIndex
Definition: DataStructs.h:318
std::vector< unsigned int > nWires
Definition: DataStructs.h:655
use the stiff electron strategy
Definition: DataStructs.h:503
std::array< double, 3 > Vector3_t
Definition: DataStructs.h:44
std::vector< float > chkStopCuts
Bragg peak finder configuration.
Definition: DataStructs.h:559
std::vector< TP3D > TP3Ds
Definition: DataStructs.h:287
int ID
ID of the recob::Slice (not the sub-slice)
Definition: DataStructs.h:666
std::array< std::vector< float >, 2 > dEdx
Definition: DataStructs.h:290
std::vector< float > cr_pfpxmin
Definition: DataStructs.h:422
unsigned int subRun
Definition: DataStructs.h:638
std::vector< float > vtx2DCuts
Max position pull, max Position error rms.
Definition: DataStructs.h:552
unsigned short pln1
Definition: DataStructs.h:126
unsigned short nPlanes
Definition: DataStructs.h:665
std::vector< PFPStruct > pfps
Definition: DataStructs.h:680
float multHitSep
preferentially "merge" hits with < this separation
Definition: DataStructs.h:576
float JTMaxHitSep2
Definition: DataStructs.h:587
std::vector< int > EnvShowerID
Definition: DataStructs.h:414
TPEnvironment_t
Definition: DataStructs.h:521
TCEvent evt
Definition: DataStructs.cxx:7
call study functions to develop cuts, etc (see TCTruth.cxx)
Definition: DataStructs.h:536
unsigned int allHitsIndex
Definition: DataStructs.h:615
unsigned short MVI
Definition: DataStructs.h:301
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:406
std::vector< int > IsShowerTj
Definition: DataStructs.h:404
constexpr unsigned int Cpad
Definition: DataStructs.h:51
unsigned short nPtsFit
Definition: DataStructs.h:188
std::vector< double > dEdx
Definition: DataStructs.h:362
std::vector< short > PlaneNum
Definition: DataStructs.h:401
std::vector< std::vector< std::pair< unsigned int, unsigned int > > > wireHitRange
Definition: DataStructs.h:628
LArSoft geometry interface.
Definition: ChannelGeo.h:16
master switch for turning on debug mode
Definition: DataStructs.h:535
tag cosmic rays
Definition: DataStructs.h:541
don&#39;t mess with this line
Definition: DataStructs.h:498
std::vector< int > DtrUIDs
Definition: DataStructs.h:295
calorimetry
use the stiff muon strategy
Definition: DataStructs.h:504