EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PndPidCandidate.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PndPidCandidate.cxx
1 
2 // //
3 // PndPidCandidate //
4 // //
5 // Definition of the Panda pid candidate. //
6 // //
7 // Author: Klaus Goetzen, GSI, 12.06.08 //
8 // Copyright (C) 2008, GSI Darmstadt. //
9 // //
11 
12 #include "PndPidCandidate.h"
13 
14 //class VAbsPidInfo;
15 
16 // ========================================================================
17 // ===== PndPidCandidate - Class definig the AOD interface ====
18 // ========================================================================
19 
21  fLocked(kFALSE),
22  fCharge(0),
23  fXposition(0.),
24  fYposition(0.),
25  fZposition(0.),
26  fXmomentum(0.),
27  fYmomentum(0.),
28  fZmomentum(0.),
29  fEnergy(0.),
30  fFirstHitX(0.),
31  fFirstHitY(0.),
32  fFirstHitZ(0.),
33  fLastHitX(0.),
34  fLastHitY(0.),
35  fLastHitZ(0.),
36  fMcIndex(-1),
37  fTrackIndex(-1),
38  fTrackBranch(-1),
39 #if _OLD_
40  fMvdDEDX(0.),
41  fMvdHits(0),
42  fSttMeanDEDX(0.),
43  fSttHits(0),
44  fGemHits(0),
45  fTofStopTime(0.),
46  fTofM2(0.),
47  fTofTrackLength(0.),
48  fTofQuality(-1.),
49  fTofIndex(-1),
50  fDrcThetaC(0.),
51  fDrcThetaCErr(0.),
52  fDrcQuality(-1.),
53  fDrcNumberOfPhotons(0),
54  fDrcIndex(-1),
55  fDiscThetaC(0.),
56  fDiscThetaCErr(0.),
57  fDiscQuality(-1.),
58  fDiscNumberOfPhotons(0),
59  fDiscIndex(-1),
60  fRichThetaC(0.),
61  fRichThetaCErr(0.),
62  fRichQuality(-1.),
63  fRichNumberOfPhotons(0),
64  fRichIndex(-1),
65  fEmcRawEnergy(0.),
66  fEmcCalEnergy(0.),
67  fEmcQuality(-1.),
68  fEmcNumberOfCrystals(0),
69  fEmcNumberOfBumps(0),
70  fEmcModule(-1),
71  fEmcIndex(-1),
72  fEmcZ20(0.),
73  fEmcZ53(0.),
74  fEmcLat(0.),
75  fEmcE1 (0.),
76  fEmcE9 (0.),
77  fEmcE25(0.),
78  fMuoNumberOfLayers(0),
79  fMuoProbability(0.),
80  fMuoQuality(-1.),
81  fMuoIron(0.),
82  fMuoMomentumIn(0.),
83  fMuoModule(0),
84  fMuoHits(0),
85  fMuoIndex(-1),
86 #endif
87  fDegreesOfFreedom(0),
88  fFitStatus(-1),
89  fChiSquared(0.)
90 {
91  SetDefault();
92 }
93 
94 PndPidCandidate::PndPidCandidate(Int_t charge, TVector3 &pos, TLorentzVector &p4, TMatrixD &cov7 ) :
95  fLocked(kFALSE),
96  fCharge(0),
97  fXposition(0.),
98  fYposition(0.),
99  fZposition(0.),
100  fXmomentum(0.),
101  fYmomentum(0.),
102  fZmomentum(0.),
103  fEnergy(0.),
104  fFirstHitX(0.),
105  fFirstHitY(0.),
106  fFirstHitZ(0.),
107  fLastHitX(0.),
108  fLastHitY(0.),
109  fLastHitZ(0.),
110  fMcIndex(-1),
111  fTrackIndex(-1),
112  fTrackBranch(-1),
113 #if _OLD_
114  fMvdDEDX(0.),
115  fMvdHits(0),
116  fSttMeanDEDX(0.),
117  fSttHits(0),
118  fGemHits(0),
119  fTofStopTime(0.),
120  fTofM2(0.),
121  fTofTrackLength(0.),
122  fTofQuality(-1.),
123  fTofIndex(-1),
124  fDrcThetaC(0.),
125  fDrcThetaCErr(0.),
126  fDrcQuality(-1.),
127  fDrcNumberOfPhotons(0),
128  fDrcIndex(-1),
129  fDiscThetaC(0.),
130  fDiscThetaCErr(0.),
131  fDiscQuality(-1.),
132  fDiscNumberOfPhotons(0),
133  fDiscIndex(-1),
134  fRichThetaC(0.),
135  fRichThetaCErr(0.),
136  fRichQuality(-1.),
137  fRichNumberOfPhotons(0),
138  fRichIndex(-1),
139  fEmcRawEnergy(0.),
140  fEmcCalEnergy(0.),
141  fEmcQuality(-1.),
142  fEmcNumberOfCrystals(0),
143  fEmcNumberOfBumps(0),
144  fEmcModule(-1),
145  fEmcIndex(-1),
146  fEmcZ20(0.),
147  fEmcZ53(0.),
148  fEmcLat(0.),
149  fEmcE1 (0.),
150  fEmcE9 (0.),
151  fEmcE25(0.),
152  fMuoNumberOfLayers(0),
153  fMuoProbability(0.),
154  fMuoQuality(-1.),
155  fMuoIron(0.),
156  fMuoMomentumIn(0.),
157  fMuoModule(0),
158  fMuoHits(0),
159  fMuoIndex(-1),
160 #endif
161  fDegreesOfFreedom(0),
162  fFitStatus(-1),
163  fChiSquared(0.)
164 {
165  SetDefault();
166  SetPosition(pos);
167  SetLorentzVector(p4);
168  SetCov7(cov7);
169  SetCharge(charge);
170 }
171 
172 PndPidCandidate::PndPidCandidate(Int_t charge, TVector3 &pos, TLorentzVector &p4) :
173  fLocked(kFALSE),
174  fCharge(0),
175  fXposition(0.),
176  fYposition(0.),
177  fZposition(0.),
178  fXmomentum(0.),
179  fYmomentum(0.),
180  fZmomentum(0.),
181  fEnergy(0.),
182  fFirstHitX(0.),
183  fFirstHitY(0.),
184  fFirstHitZ(0.),
185  fLastHitX(0.),
186  fLastHitY(0.),
187  fLastHitZ(0.),
188  fMcIndex(-1),
189  fTrackIndex(-1),
190  fTrackBranch(-1),
191 #if _OLD_
192  fMvdDEDX(0.),
193  fMvdHits(0),
194  fSttMeanDEDX(0.),
195  fSttHits(0),
196  fGemHits(0),
197  fTofStopTime(0.),
198  fTofM2(0.),
199  fTofTrackLength(0.),
200  fTofQuality(-1.),
201  fTofIndex(-1),
202  fDrcThetaC(0.),
203  fDrcThetaCErr(0.),
204  fDrcQuality(-1.),
205  fDrcNumberOfPhotons(0),
206  fDrcIndex(-1),
207  fDiscThetaC(0.),
208  fDiscThetaCErr(0.),
209  fDiscQuality(-1.),
210  fDiscNumberOfPhotons(0),
211  fDiscIndex(-1),
212  fRichThetaC(0.),
213  fRichThetaCErr(0.),
214  fRichQuality(-1.),
215  fRichNumberOfPhotons(0),
216  fRichIndex(-1),
217  fEmcRawEnergy(0.),
218  fEmcCalEnergy(0.),
219  fEmcQuality(-1.),
220  fEmcNumberOfCrystals(0),
221  fEmcNumberOfBumps(0),
222  fEmcModule(-1),
223  fEmcIndex(-1),
224  fEmcZ20(0.),
225  fEmcZ53(0.),
226  fEmcLat(0.),
227  fEmcE1 (0.),
228  fEmcE9 (0.),
229  fEmcE25(0.),
230  fMuoNumberOfLayers(0),
231  fMuoProbability(0.),
232  fMuoQuality(-1.),
233  fMuoIron(0.),
234  fMuoMomentumIn(0.),
235  fMuoModule(0),
236  fMuoHits(0),
237  fMuoIndex(-1),
238 #endif
239  fDegreesOfFreedom(0),
240  fFitStatus(-1),
241  fChiSquared(0.)
242 {
243  SetDefault();
244  SetPosition(pos);
245  SetLorentzVector(p4);
246  SetCharge(charge);
247 }
248 
249 
251 {
252 }
253 
254 TMatrixD& PndPidCandidate::Cov7() const
255 {
256  static TMatrixD cov(7,7);
257 
258  // position error
259 
260  cov(0,0) = fErrP7[0]; cov(1,0) = fErrP7[1]; cov(1,1) = fErrP7[2];
261  cov(2,0) = fErrP7[3]; cov(2,1) = fErrP7[4]; cov(2,2) = fErrP7[5];
262 
263  // position-momentum covariance
264 
265  cov(3,0) = fErrP7[6]; cov(3,1) = fErrP7[7]; cov(3,2) = fErrP7[8];
266  cov(4,0) = fErrP7[9]; cov(4,1) = fErrP7[10]; cov(4,2) = fErrP7[11];
267  cov(5,0) = fErrP7[12]; cov(5,1) = fErrP7[13]; cov(5,2) = fErrP7[14];
268  cov(6,0) = fErrP7[15]; cov(6,1) = fErrP7[16]; cov(6,2) = fErrP7[17];
269 
270  // momentum error
271  cov(3,3) = fErrP7[18]; cov(4,3) = fErrP7[19]; cov(4,4) = fErrP7[20];
272  cov(5,3) = fErrP7[21]; cov(5,4) = fErrP7[22]; cov(5,5) = fErrP7[23];
273  cov(6,3) = fErrP7[24]; cov(6,4) = fErrP7[25]; cov(6,5) = fErrP7[26];
274  cov(6,6) = fErrP7[27];
275 
276  for (int i=0; i<6; i++)
277  for (int j=i+1; j<7; j++)
278  cov(i,j)=cov(j,i);
279 
280  return cov;
281 }
282 
283 TMatrixD& PndPidCandidate::P4Cov() const
284 {
285  static TMatrixD covP4(4,4);
286 
287  covP4(0,0) = fErrP7[18]; covP4(1,0) = fErrP7[19]; covP4(1,1) = fErrP7[20];
288  covP4(2,0) = fErrP7[21]; covP4(2,1) = fErrP7[22]; covP4(2,2) = fErrP7[23];
289  covP4(3,0) = fErrP7[24]; covP4(3,1) = fErrP7[25]; covP4(3,2) = fErrP7[26];
290  covP4(3,3) = fErrP7[27];
291 
292  for (int i=0; i<3; i++)
293  for (int j=i+1; j<4; j++)
294  covP4(i,j)=covP4(j,i);
295 
296  return covP4;
297 }
298 
299 void PndPidCandidate::SetLorentzVector(TLorentzVector &p4)
300 {
301  fXmomentum = p4.X();
302  fYmomentum = p4.Y();
303  fZmomentum = p4.Z();
304  fEnergy = p4.T();
305 }
306 
307 void PndPidCandidate::SetCov7(const TMatrixD &cov7 )
308 {
309  // position error
310 
311  fErrP7[0] = cov7(0,0); fErrP7[1] = cov7(1,0); fErrP7[2] = cov7(1,1);
312  fErrP7[3] = cov7(2,0); fErrP7[4] = cov7(2,1); fErrP7[5] = cov7(2,2);
313 
314  // position-momentum covariance
315 
316  fErrP7[6] = cov7(3,0); fErrP7[7] = cov7(3,1); fErrP7[8] = cov7(3,2);
317  fErrP7[9] = cov7(4,0); fErrP7[10] = cov7(4,1); fErrP7[11] = cov7(4,2);
318  fErrP7[12] = cov7(5,0); fErrP7[13] = cov7(5,1); fErrP7[14] = cov7(5,2);
319  fErrP7[15] = cov7(6,0); fErrP7[16] = cov7(6,1); fErrP7[17] = cov7(6,2);
320 
321  // momentum error
322  fErrP7[18] = cov7(3,3); fErrP7[19] = cov7(4,3); fErrP7[20] = cov7(4,4);
323  fErrP7[21] = cov7(5,3); fErrP7[22] = cov7(5,4); fErrP7[23] = cov7(5,5);
324  fErrP7[24] = cov7(6,3); fErrP7[25] = cov7(6,4); fErrP7[26] = cov7(6,5);
325  fErrP7[27] = cov7(6,6);
326 }
327 
328 void PndPidCandidate::SetP4Cov(const TMatrixD &covP4 )
329 {
330  // position error
331 
332  fErrP7[0] = 0; fErrP7[1] = 0; fErrP7[2] = 0;
333  fErrP7[3] = 0; fErrP7[4] = 0; fErrP7[5] = 0;
334 
335  // position-momentum covariance
336 
337  fErrP7[6] = 0; fErrP7[7] = 0; fErrP7[8] = 0;
338  fErrP7[9] = 0; fErrP7[10] = 0; fErrP7[11] = 0;
339  fErrP7[12] = 0; fErrP7[13] = 0; fErrP7[14] = 0;
340  fErrP7[15] = 0; fErrP7[16] = 0; fErrP7[17] = 0;
341 
342  // momentum error
343  fErrP7[18] = covP4(0,0); fErrP7[19] = covP4(1,0); fErrP7[20] = covP4(1,1);
344  fErrP7[21] = covP4(2,0); fErrP7[22] = covP4(2,1); fErrP7[23] = covP4(2,2);
345  fErrP7[24] = covP4(3,0); fErrP7[25] = covP4(3,1); fErrP7[26] = covP4(3,2);
346  fErrP7[27] = covP4(3,3);
347 }
348 
350 {
351  fLocked = kFALSE;
352  fCharge = 0;
353  fXposition = 0.;
354  fYposition = 0.;
355  fZposition = 0.;
356  fXmomentum = 0.;
357  fYmomentum = 0.;
358  fZmomentum = 0.;
359  fEnergy = 0.;
360  fFirstHitX = 0.;
361  fFirstHitY = 0.;
362  fFirstHitZ = 0.;
363  fLastHitX = 0.;
364  fLastHitY = 0.;
365  fLastHitZ = 0.;
366  fMcIndex = -1;
367  fTrackIndex = -1;
368  fTrackBranch = -1;
369 #if _OLD_
370  fMvdDEDX = 0.;
371  fMvdHits = 0;
372  fSttMeanDEDX = 0.;
373  fSttHits = 0;
374  fGemHits = 0;
375  fTofStopTime = 0.;
376  fTofM2 = 0.;
377  fTofTrackLength = 0.;
378  fTofQuality = -1.;
379  fTofIndex = -1;
380  fDrcThetaC = 0.;
381  fDrcThetaCErr = 0.;
382  fDrcQuality = -1.;
383  fDrcNumberOfPhotons = 0;
384  fDrcIndex = -1;
385  fDiscThetaC = 0.;
386  fDiscThetaCErr = 0.;
387  fDiscQuality = -1.;
388  fDiscNumberOfPhotons = 0;
389  fDiscIndex = -1;
390  fRichThetaC = 0.;
391  fRichThetaCErr = 0.;
392  fRichQuality = -1.;
393  fRichNumberOfPhotons = 0;
394  fRichIndex = -1;
395  fEmcRawEnergy = 0.;
396  fEmcCalEnergy = 0.;
397  fEmcQuality = -1.;
398  fEmcNumberOfCrystals = 0;
399  fEmcNumberOfBumps = 0;
400  fEmcModule = -1;
401  fEmcIndex = -1;
402  fEmcZ20 = 0.;
403  fEmcZ53 = 0.;
404  fEmcLat = 0.;
405  fEmcE1 = 0.;
406  fEmcE9 = 0.;
407  fEmcE25 = 0.;
408  fMuoNumberOfLayers = 0;
409  fMuoProbability = 0.;
410  fMuoQuality = -1.;
411  fMuoIron = 0.;
412  fMuoMomentumIn = 0.;
413  fMuoModule = 0;
414  fMuoHits = 0;
415  fMuoIndex = -1;
416 #endif
417  fDegreesOfFreedom = 0;
418  fFitStatus = 0;
419  fChiSquared = 0.;
420 
421  Int_t i;
422  for (i=0; i<28;i++) fErrP7[i] = 0;
423  for (i=0; i<5;i++) fParams[i] = 0;
424  for (i=0; i<15;i++) fCov[i] = 0;
425 }
426 
427 
428 const NaiveTrackParameterization *PndPidCandidate::GetNearestParameterization(const TVector3 &x0, const TVector3 &n0)
429 {
430  int best_hit = -1;
431  double best_dist = 0.0;
432 
433  for(unsigned iq=0; iq<mParameterizations.size(); iq++) {
435  double dist = param.DistanceToPlane(x0, n0);
436  if (best_hit == -1 || dist < best_dist) {
437  best_hit = iq;
438  best_dist = dist;
439  } //if
440  } //for iq
441 
442  return (best_hit == -1 ? 0 : &mParameterizations[best_hit]);
443 } // PndPidCandidate::GetNearestParameterization()
444 
445 // FIXME: unify these two calls;
447 {
448  int best_hit = -1;
449  double best_dist = 0.0;
450 
451  for(unsigned iq=0; iq<mParameterizations.size(); iq++) {
453  const TVector3 &pos = param.GetMoCaPosition();
454  double x = pos.X(), y = pos.Y(), dist = fabs(sqrt(x*x+y*y) - r);
455  if (best_hit == -1 || dist < best_dist) {
456  best_hit = iq;
457  best_dist = dist;
458  } //if
459  } //for iq
460 
461  return (best_hit == -1 ? 0 : &mParameterizations[best_hit]);
462 } // PndPidCandidate::GetNearestParameterization()