LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
TCShTree.cxx
Go to the documentation of this file.
2 
3 namespace tca {
4 
5  void SaveTjInfo(TCSlice& slc, std::vector<std::vector<int>>& tjList,
6  std::string stageName) {
7  if(!tcc.modes[kSaveShowerTree]) return;
8  if(tjList.empty()) return;
9  int stageNum = GetStageNum(stv, stageName);
10 
11  // get the CTP from the first tj
12  CTP_t inCTP = slc.tjs[tjList[0][0] - 1].CTP;
13  for(unsigned short it1 = 0; it1 < slc.tjs.size(); ++it1) {
14  Trajectory& tj1 = slc.tjs[it1];
15  if(tj1.CTP != inCTP) continue;
16  if(tj1.AlgMod[kKilled]) continue;
17 
18  SaveTjInfoStuff(slc, tj1, stageNum, stageName);
19 
20  int trajID = tj1.ID;
21  bool inShower = false;
22 
23  for (size_t l1 = 0; l1 < tjList.size(); ++l1) {
24  if (inShower) break;
25  for (size_t l2 = 0; l2 < tjList[l1].size(); ++l2) {
26 
27  if (trajID == tjList[l1][l2]) {
28  stv.ShowerID.back() = l1;
29  inShower = true;
30  break;
31  }
32  } // end list loop 2
33  } // end list loop 1
34  } // end tjs loop
35  // add meaningless envelope to list for counting purposes
36  // envelopes are defined once DefineShower is called
37  // fill four times, one for each side of polygon
38  for (int i = 0; i < 8; i++) {
39  stv.Envelope.push_back(-999);
40  stv.EnvStage.push_back(stageNum);
41  stv.EnvPlane.push_back(-1);
42  stv.EnvShowerID.push_back(-1);
43  }
44 
45  } // SaveTjInfo (tjlist)
46 
47  void SaveTjInfo(TCSlice& slc, const ShowerStruct& ss, std::string stageName) {
48  if(!tcc.modes[kSaveShowerTree]) return;
49  int stageNum = GetStageNum(stv, stageName);
50 
51  // killed shower?
52  if(ss.ID == 0) return;
53 
54  bool noMatch = true;
55 
56  for(unsigned short it1 = 0; it1 < slc.tjs.size(); ++it1) {
57 
58  Trajectory& tj1 = slc.tjs[it1];
59 
60  if(tj1.AlgMod[kKilled]) continue;
61 
62  int trajID = tj1.ID;
63 
64  // check if this tj has already been added to the list
65  // for this particular stage and plane
66  int tjIndex = -1;
67  bool isShowerTj = false;
68  for (size_t i = 0; i < stv.TjID.size(); ++i) {
69  if (stv.StageNum.at(i) != (int)stageNum) continue;
70  if (stv.PlaneNum.at(i) != (short)DecodeCTP(ss.CTP).Plane) continue;
71 
72  if (stv.TjID.at(i) == trajID) {
73  tjIndex = i;
74  if (stv.IsShowerTj.at(tjIndex) == 1) isShowerTj = true;
75  //beenDoneBefore = true;
76  break;
77  }
78  }
79 
80  if (isShowerTj) continue;
81  if (tjIndex == -1) SaveTjInfoStuff(slc, tj1, stageNum, stageName);
82 
83  for (size_t i = 0; i < ss.TjIDs.size(); ++i) {
84  if (trajID == ss.TjIDs[i]) {
85  noMatch = false;
86  if (tjIndex == -1) stv.ShowerID.back() = ss.ID;
87  else stv.ShowerID.at(tjIndex) = ss.ID;
88  }
89 
90  if (it1 == (ss.ShowerTjID - 1)) stv.IsShowerTj.back() = 1;
91  else if (tj1.AlgMod[kShowerTj]) stv.IsShowerTj.back() = 1; // this is a better check
92  // check if tj is shower parent. if so, add to ttree
93  // and mark parent flag
94  if (trajID == ss.ParentID) {
95  if (tjIndex == -1) {
96  stv.ShowerID.back() = ss.ID;
97  stv.IsShowerParent.back() = 1;
98  }
99  else {
100  stv.ShowerID.at(tjIndex) = ss.ID;
101  stv.IsShowerParent.at(tjIndex) = 1;
102  }
103  break;
104 
105  }
106  } // ss TjID loop
107  } // end tjs loop
108 
109  if (noMatch) return;
110 
111  // add envelope information to showertreevars
112  geo::PlaneID iPlnID = DecodeCTP(ss.CTP);
113 
114  for (int i = 0; i < 8; i++) {
115  stv.EnvStage.push_back(stageNum);
116  stv.EnvPlane.push_back(iPlnID.Plane);
117  stv.EnvShowerID.push_back(ss.ID);
118  }
119 
120  stv.Envelope.push_back(ss.Envelope[0][0]);
121  stv.Envelope.push_back(ss.Envelope[0][1]/tcc.unitsPerTick);
122  stv.Envelope.push_back(ss.Envelope[1][0]);
123  stv.Envelope.push_back(ss.Envelope[1][1]/tcc.unitsPerTick);
124  stv.Envelope.push_back(ss.Envelope[2][0]);
125  stv.Envelope.push_back(ss.Envelope[2][1]/tcc.unitsPerTick);
126  stv.Envelope.push_back(ss.Envelope[3][0]);
127  stv.Envelope.push_back(ss.Envelope[3][1]/tcc.unitsPerTick);
128 
129  } // SaveTjInfo (cots)
130 
131  void SaveTjInfoStuff(TCSlice& slc, Trajectory& tj, int stageNum, std::string stageName) {
132  if(!tcc.modes[kSaveShowerTree]) return;
133 
134  TrajPoint& beginPoint = tj.Pts[tj.EndPt[0]];
135  TrajPoint& endPoint = tj.Pts[tj.EndPt[1]];
136 
137  stv.BeginWir.push_back(std::nearbyint(beginPoint.Pos[0]));
138  stv.BeginTim.push_back(std::nearbyint(beginPoint.Pos[1]/tcc.unitsPerTick));
139  stv.BeginAng.push_back(beginPoint.Ang);
140  stv.BeginChg.push_back(beginPoint.Chg);
141  stv.BeginVtx.push_back(tj.VtxID[0]);
142 
143  stv.EndWir.push_back(std::nearbyint(endPoint.Pos[0]));
144  stv.EndTim.push_back(std::nearbyint(endPoint.Pos[1]/tcc.unitsPerTick));
145  stv.EndAng.push_back(endPoint.Ang);
146  stv.EndChg.push_back(endPoint.Chg);
147  stv.EndVtx.push_back(tj.VtxID[1]);
148 
149  stv.MCSMom.push_back(tj.MCSMom);
150  stv.TjID.push_back(tj.ID);
151  stv.IsShowerTj.push_back(-1);
152 
153  stv.ShowerID.push_back(-1);
154  stv.IsShowerParent.push_back(-1);
155  stv.StageNum.push_back(stageNum);
156  stv.nStages = stageNum;
157  geo::PlaneID iPlnID = DecodeCTP(tj.CTP);
158  stv.PlaneNum.push_back(iPlnID.Plane);
159 
160  stv.nPlanes = slc.nPlanes;
161 
162  } // SaveTjInfoStuff
163 
165  void SaveAllCots(TCSlice& slc, const CTP_t& inCTP, std::string someText) {
166  if(!tcc.modes[kSaveShowerTree]) return;
167  for(unsigned short cotIndex = 0; cotIndex < slc.cots.size(); ++cotIndex) {
168  auto& ss = slc.cots[cotIndex];
169  if (ss.CTP != inCTP) continue;
170  if(ss.ID == 0) continue;
171  SaveTjInfo(slc, ss, someText);
172  } // cotIndex
173  } // SaveAllCots
174 
175 
176  void SaveAllCots(TCSlice& slc, std::string someText) {
177  if(!tcc.modes[kSaveShowerTree]) return;
178  for(unsigned short cotIndex = 0; cotIndex < slc.cots.size(); ++cotIndex) {
179  auto& ss = slc.cots[cotIndex];
180  if(ss.ID == 0) continue;
181  SaveTjInfo(slc, ss, someText);
182  } // cotIndex
183  }
184 
185  int GetStageNum(ShowerTreeVars& stv, std::string stageName) {
186  int stageNum;
187  bool existingStage = false;
188  for (unsigned short i = 0; i < stv.StageName.size(); ++i) {
189  if (stv.StageName.at(i) == stageName) {
190  existingStage = true;
191  stageNum = i+1;
192  }
193  }
194 
195  if (!existingStage) {
196  stv.StageName.push_back(stageName);
197  stageNum = stv.StageName.size();
198  }
199 
200  return stageNum;
201  }
202 
204  stv.BeginWir.clear();
205  stv.BeginTim.clear();
206  stv.BeginAng.clear();
207  stv.BeginChg.clear();
208  stv.BeginVtx.clear();
209  stv.EndWir.clear();
210  stv.EndTim.clear();
211  stv.EndAng.clear();
212  stv.EndChg.clear();
213  stv.EndVtx.clear();
214  stv.MCSMom.clear();
215  stv.PlaneNum.clear();
216  stv.TjID.clear();
217  stv.IsShowerTj.clear();
218  stv.ShowerID.clear();
219  stv.IsShowerParent.clear();
220  stv.StageNum.clear();
221  stv.Envelope.clear();
222  stv.EnvPlane.clear();
223  stv.EnvStage.clear();
224  stv.EnvShowerID.clear();
225 
226  return;
227 
228  } // ClearShowerTree
229 
230 } // namespace tca
std::vector< int > EnvStage
Definition: DataStructs.h:330
Point2_t Pos
Definition: DataStructs.h:121
void SaveTjInfoStuff(TCSlice &slc, Trajectory &tj, int stageNum, std::string stageName)
Definition: TCShTree.cxx:131
std::vector< int > IsShowerParent
Definition: DataStructs.h:323
std::vector< Trajectory > tjs
vector of all trajectories in each plane
Definition: DataStructs.h:570
std::vector< float > EndWir
Definition: DataStructs.h:310
std::vector< float > EndAng
Definition: DataStructs.h:312
std::vector< ShowerStruct > cots
Definition: DataStructs.h:580
std::vector< float > BeginTim
Definition: DataStructs.h:306
std::vector< Point2_t > Envelope
Definition: DataStructs.h:253
TCConfig tcc
Definition: DataStructs.cxx:6
std::vector< float > BeginAng
Definition: DataStructs.h:307
The data type to uniquely identify a Plane.
Definition: geo_types.h:250
std::vector< int > TjIDs
Definition: DataStructs.h:246
void ClearShowerTree(ShowerTreeVars &stv)
Definition: TCShTree.cxx:203
Float_t ss
Definition: plot.C:23
void SaveAllCots(TCSlice &slc, const CTP_t &inCTP, std::string someText)
Definition: TCShTree.cxx:165
std::vector< float > EndTim
Definition: DataStructs.h:311
std::vector< int > ShowerID
Definition: DataStructs.h:322
ShowerTreeVars stv
Definition: DataStructs.cxx:8
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
save shower tree
Definition: DataStructs.h:456
std::vector< std::string > StageName
Definition: DataStructs.h:325
std::vector< int > TjID
Definition: DataStructs.h:320
float unitsPerTick
scale factor from Tick to WSE equivalent units
Definition: DataStructs.h:488
std::vector< short > BeginVtx
Definition: DataStructs.h:309
CTP_t CTP
Cryostat, TPC, Plane code.
Definition: DataStructs.h:144
std::vector< TrajPoint > Pts
Trajectory points.
Definition: DataStructs.h:143
std::vector< short > EndVtx
Definition: DataStructs.h:314
void SaveTjInfo(TCSlice &slc, std::vector< std::vector< int >> &tjList, std::string stageName)
Definition: TCShTree.cxx:5
std::array< unsigned short, 2 > EndPt
First and last point in the trajectory that has charge.
Definition: DataStructs.h:156
std::vector< float > Envelope
Definition: DataStructs.h:328
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:258
std::vector< float > BeginChg
Definition: DataStructs.h:308
int ID
ID that is local to one slice.
Definition: DataStructs.h:157
std::array< unsigned short, 2 > VtxID
ID of 2D vertex.
Definition: DataStructs.h:155
std::bitset< 16 > modes
number of points to find AveChg
Definition: DataStructs.h:524
std::vector< int > EnvPlane
Definition: DataStructs.h:329
std::vector< short > MCSMom
Definition: DataStructs.h:316
unsigned int CTP_t
Definition: DataStructs.h:41
std::vector< int > StageNum
Definition: DataStructs.h:324
unsigned short nPlanes
Definition: DataStructs.h:334
std::bitset< 128 > AlgMod
Bit set if algorithm AlgBit_t modifed the trajectory.
Definition: DataStructs.h:145
std::vector< float > BeginWir
Definition: DataStructs.h:305
geo::PlaneID DecodeCTP(CTP_t CTP)
std::vector< float > EndChg
Definition: DataStructs.h:313
int GetStageNum(ShowerTreeVars &stv, std::string stageName)
Definition: TCShTree.cxx:185
unsigned short nPlanes
Definition: DataStructs.h:563
std::vector< int > EnvShowerID
Definition: DataStructs.h:331
std::vector< int > IsShowerTj
Definition: DataStructs.h:321
std::vector< short > PlaneNum
Definition: DataStructs.h:318