HighLAND
P0DDataClasses.cxx
1 #define DataClasses_C
2 
3 #include "P0DDataClasses.hxx"
4 #include "BasicUtils.hxx"
5 #include "TMath.h"
6 
7 // define a constant value for uninitialised parameters
8 const Float_t kFloatUnassigned = -999.;
9 const UInt_t kUnassigned = 0xDEADBEEF;
10 const short kShortUnassigned = 0xFF;
11 
12 //********************************************************************
13 AnaP0DHit::AnaP0DHit(){
14 //********************************************************************
15 
16  GeomID = kUnassigned;
17  Time = kFloatUnassigned;
18  // ChanID = kUnassigned;
19  // Type = kUnassigned;
20  Charge = kFloatUnassigned;
21  // anaUtils::VectorToArray (TLorentzVector(0,0,0,0), Position );
22 }
23 
24 //********************************************************************
25 AnaP0DHit::AnaP0DHit(const AnaP0DHit& p0dHit){
26 //********************************************************************
27 
28  GeomID = p0dHit.GeomID;
29  // ChanID = p0dHit.ChanID;
30  Time = p0dHit.Time;
31  // Type = p0dHit.Type;
32  Charge = p0dHit.Charge;
33  // anaUtils::CopyArray(p0dHit.Position, Position, 4);
34 }
35 
36 //********************************************************************
37 AnaP0DCluster::AnaP0DCluster(){
38 //********************************************************************
39  AlgorithmName = "";
40  ValidDimensions = kShortUnassigned;
41  UniqueID = kUnassigned;
42  EDeposit = kFloatUnassigned;
43 
44  anaUtils::VectorToArray (TLorentzVector(0,0,0,0), Position );
45  anaUtils::VectorToArray (TLorentzVector(0,0,0,0), PosVariance);
46 
47  for (UInt_t i=0;i<9;i++) Moments[i]=0;
48 
49  TrueParticle = NULL;
50 
51  Hits = NULL;
52  nHits = 0;
53 }
54 
55 //********************************************************************
56 AnaP0DCluster::AnaP0DCluster(const AnaP0DCluster& p0dCluster){
57 //********************************************************************
58 
59  AlgorithmName = p0dCluster.AlgorithmName;
60  ValidDimensions = p0dCluster.ValidDimensions;
61  UniqueID = p0dCluster.UniqueID;
62  EDeposit = p0dCluster.EDeposit;
63 
64  anaUtils::CopyArray (p0dCluster.Moments, Moments, 9);
65 
66  anaUtils::CopyArray (p0dCluster.Position, Position, 4);
67  anaUtils::CopyArray (p0dCluster.PosVariance, PosVariance, 4);
68 
69  TrueParticle = p0dCluster.TrueParticle;
70 
71  anaUtils::CreateArray(Hits, p0dCluster.nHits);
72  anaUtils::CopyArray(p0dCluster.Hits, Hits, p0dCluster.nHits);
73  nHits = p0dCluster.nHits;
74 }
75 
76 //********************************************************************
77 AnaP0DCluster::~AnaP0DCluster(){
78 //********************************************************************
79 
80  // Must delete array of pointers, since we re-create this every time we apply a selection
81  if(Hits != NULL) delete [] Hits;
82  Hits = NULL;
83 }
84 
85 //********************************************************************
86 AnaP0DParticle::AnaP0DParticle():AnaP0DParticleB(),AnaParticleMomE(){
87 //********************************************************************
88 
89 #if VERSION_HAS_P0D_AVERAGED_TIME
90  AvgTime = -999.;
91 #endif
92 
93 
94  Type = kUnknown;
95  AlgorithmName = "";
96  // Status = kUnassigned;
97  ValidDimensions = kShortUnassigned;
98  SideDeposit = kFloatUnassigned;
99  EndDeposit = kFloatUnassigned;
100  EDeposit = kFloatUnassigned;
101 
102  realPIDNames .clear();
103  realPIDValues .clear();
104  integerPIDNames .clear();
105  integerPIDValues .clear();
106  PID .clear();
107  PID_weight .clear();
108 
109  Clusters = NULL;
110  nClusters = 0;
111 }
112 
113 //********************************************************************
114 AnaP0DParticle::AnaP0DParticle(const AnaP0DParticle& p0dParticle):AnaP0DParticleB(p0dParticle),AnaParticleMomE(p0dParticle){
115 //********************************************************************
116 
117 #if VERSION_HAS_P0D_AVERAGED_TIME
118  AvgTime = p0dParticle.AvgTime;
119 #endif
120 
121 
122  Type = p0dParticle.Type;
123  AlgorithmName = p0dParticle.AlgorithmName;
124  // Status = p0dParticle.Status;
125  ValidDimensions = p0dParticle.ValidDimensions;
126  SideDeposit = p0dParticle.SideDeposit;
127  EndDeposit = p0dParticle.EndDeposit;
128  EDeposit = p0dParticle.EDeposit;
129  realPIDNames = p0dParticle.realPIDNames;
130  realPIDValues = p0dParticle.realPIDValues;
131  integerPIDNames = p0dParticle.integerPIDNames;
132  integerPIDValues = p0dParticle.integerPIDValues;
133  PID = p0dParticle.PID;
134  PID_weight = p0dParticle.PID_weight;
135 
136  anaUtils::CreateArray(Clusters, p0dParticle.nClusters);
137  anaUtils::CopyArray(p0dParticle.Clusters, Clusters, p0dParticle.nClusters);
138 
139  nClusters = p0dParticle.nClusters;
140 }
141 
142 //********************************************************************
143 AnaP0DParticle::~AnaP0DParticle(){
144 //********************************************************************
145 
146  // Must delete array of pointers, since we re-create this every time we apply a selection
147  if(Clusters != NULL) delete [] Clusters;
148  Clusters = NULL;
149 }
150 
151 //********************************************************************
153 //********************************************************************
154 
155  std::cout << "-------- AnaP0DParticle --------- " << std::endl;
156 
158 
159  std::cout << "Type: " << Type << std::endl;
160  std::cout << "#Clusters: " << nClusters << std::endl;
161 }
162 
163 //********************************************************************
164 AnaP0DVertex::AnaP0DVertex():AnaVertexB(){
165 //********************************************************************
166 
167  ValidDimensions = kShortUnassigned;
168  AlgorithmName = "";
169  NHits = kShortUnassigned;
170  Fiducial = kFloatUnassigned;
171  // UniqueID = kUnassigned;
172 
173  anaUtils::VectorToArray (TLorentzVector(0,0,0,0), PosVariance);
174 
175  Clusters = NULL;
176  nClusters = 0;
177 }
178 
179 //********************************************************************
180 AnaP0DVertex::AnaP0DVertex(const AnaP0DVertex& p0dVertex):AnaVertexB(p0dVertex){
181 //********************************************************************
182 
183  AlgorithmName = p0dVertex.AlgorithmName;
184  ValidDimensions = p0dVertex.ValidDimensions;
185  NHits = p0dVertex.NHits;
186  // UniqueID = p0dVertex.UniqueID;
187  Fiducial = p0dVertex.Fiducial;
188 
189  anaUtils::CopyArray (p0dVertex.PosVariance, PosVariance, 4);
190 
191  anaUtils::CreateArray(Clusters, p0dVertex.nClusters);
192  anaUtils::CopyArray(p0dVertex.Clusters, Clusters, p0dVertex.nClusters);
193 
194  nClusters = p0dVertex.nClusters;
195 }
196 
197 //********************************************************************
198 AnaP0DVertex::~AnaP0DVertex(){
199 //********************************************************************
200 
201  // Must delete array of pointers, since we re-create this every time we apply a selection
202  if(Clusters != NULL) delete [] Clusters;
203  Clusters = NULL;
204 }
205 
206 //********************************************************************
207 AnaP0DBunch::AnaP0DBunch():AnaBunch(){
208 //********************************************************************
209  Clusters = NULL;
210  nClusters = 0;
211 
212  AlternateBunches.clear();
213 
214  FullName="";
215  P0DWaterStatus = false;
216 }
217 
218 //********************************************************************
219 AnaP0DBunch::AnaP0DBunch(const AnaP0DBunch& p0dBunch):AnaBunch(p0dBunch){
220 //********************************************************************
221 
222  anaUtils::CreateArray(Clusters, p0dBunch.nClusters);
223  anaUtils::CopyArray(p0dBunch.Clusters, Clusters, p0dBunch.nClusters);
224 
225  P0DWaterStatus = p0dBunch.P0DWaterStatus;
226  nClusters = p0dBunch.nClusters;
227 
228  for (std::vector<AnaP0DBunch*>::const_iterator it=p0dBunch.AlternateBunches.begin();it!=p0dBunch.AlternateBunches.end();it++)
229  AlternateBunches.push_back((*it)->Clone());
230 
231  FullName=p0dBunch.FullName;
232 }
233 
234 //********************************************************************
235 AnaP0DBunch::~AnaP0DBunch(){
236 //********************************************************************
237 
238  // Must delete array of pointers, since we re-create this every time we apply a selection
239  if(Clusters != NULL) delete [] Clusters;
240  Clusters = NULL;
241 
242  for (std::vector<AnaP0DBunch*>::iterator it=AlternateBunches.begin();it!=AlternateBunches.end();it++)
243  delete *it;
244 
245  AlternateBunches.clear();
246 }
247 
248 //********************************************************************
249 AnaP0DEvent::AnaP0DEvent():AnaEventB(){
250 //********************************************************************
251  Clusters = NULL;
252  nClusters = 0;
253 
254  AlternateEvents.clear();
255 
256  FullName="";
257 
258  P0DWaterStatus = false;
259 }
260 
261 //********************************************************************
262 AnaP0DEvent::AnaP0DEvent(const AnaP0DEvent& p0dEvent):AnaEventB(p0dEvent){
263 //********************************************************************
264 
265  anaUtils::CreateArray(Clusters, p0dEvent.nClusters);
266  anaUtils::CopyArray(p0dEvent.Clusters, Clusters, p0dEvent.nClusters);
267 
268  P0DWaterStatus = p0dEvent.P0DWaterStatus;
269  nClusters = p0dEvent.nClusters;
270 
271 
272  for (std::vector<AnaP0DEvent*>::const_iterator it=p0dEvent.AlternateEvents.begin();it!=p0dEvent.AlternateEvents.end();it++)
273  AlternateEvents.push_back((*it)->Clone());
274 
275  FullName=p0dEvent.FullName;
276 }
277 
278 //*****************************************************************************
279 AnaP0DEvent::AnaP0DEvent(const AnaSpillB& spill, const AnaP0DBunch& p0dBunch):AnaEventB(spill,p0dBunch) {
280 //*****************************************************************************
281 
282  anaUtils::CreateArray(Clusters, p0dBunch.nClusters);
283  anaUtils::CopyArray(p0dBunch.Clusters, Clusters, p0dBunch.nClusters);
284 
285  P0DWaterStatus = p0dBunch.P0DWaterStatus;
286  nClusters = p0dBunch.nClusters;
287 
288  FullName=p0dBunch.FullName;
289 
290  for (std::vector<AnaP0DBunch*>::const_iterator it=p0dBunch.AlternateBunches.begin();it!=p0dBunch.AlternateBunches.end();it++){
291  AnaP0DEvent* alt = new AnaP0DEvent(spill, **it);
292  AlternateEvents.push_back(alt);
293  }
294 
295 }
296 
297 //********************************************************************
298 AnaP0DEvent::~AnaP0DEvent(){
299 //********************************************************************
300 
301  // Must delete array of pointers, since we re-create this every time we apply a selection
302  if(Clusters != NULL) delete [] Clusters;
303  Clusters = NULL;
304 
305 
306  for (std::vector<AnaP0DEvent*>::iterator it=AlternateEvents.begin();it!=AlternateEvents.end();it++)
307  delete *it;
308 
309  AlternateEvents.clear();
310 }
311 
312 //********************************************************************
313 void anaUtils::CopyArray(AnaP0DCluster** const &src, AnaP0DCluster** &dest, int n){
314 //********************************************************************
315 
316  for(int i = 0; i < n; ++i){
317  dest[i] = src[i];
318  }
319  return;
320 }
321 
322 //********************************************************************
323 void anaUtils::CreateArray(AnaP0DCluster** &tgtArr, int nObj){
324 //********************************************************************
325 
326  tgtArr = new AnaP0DCluster*[nObj];
327  for(int i = 0; i < nObj; ++i){
328  tgtArr[i] = NULL;
329  }
330 }
331 
332 //********************************************************************
333 void anaUtils::CopyArray(AnaP0DHit** const &src, AnaP0DHit** &dest, int n){
334 //********************************************************************
335 
336  for(int i = 0; i < n; ++i){
337  dest[i] = src[i];
338  }
339  return;
340 }
341 
342 //********************************************************************
343 void anaUtils::CreateArray(AnaP0DHit** &tgtArr, int nObj){
344 //********************************************************************
345 
346  tgtArr = new AnaP0DHit*[nObj];
347  for(int i = 0; i < nObj; ++i){
348  tgtArr[i] = NULL;
349  }
350 }
351 
352 //********************************************************************
353 EventBoxP0D2::EventBoxP0D2():EventBoxB(){
354 //********************************************************************
355 
356  for (UInt_t i=0;i<NMAXVERTEXGROUPS;i++){
357  nVerticesInGroup[i]=0;
358  VerticesInGroup[i]=NULL;
359  }
360 }
361 
362 //********************************************************************
363 EventBoxP0D2::~EventBoxP0D2(){
364 //********************************************************************
365  for (UInt_t i=0;i<NMAXVERTEXGROUPS;i++){
366  if (VerticesInGroup[i])
367  delete [] VerticesInGroup[i];
368  VerticesInGroup[i] = NULL;
369  }
370 }
371 
Float_t AvgTime
Average Time: using results from time vs distance fit.
Extension to AnaParticleB containing momentum and charge info, to be used by aggregation.
void Print() const
Dump the object to screen.
Float_t Moments[9]
Moments of the Cluster.
Int_t NHits
The number of hits in the particle.
virtual void Print() const
Dump the object to screen.
Representation of a global vertex.
Representation of a P0D segment of a global track.