HighLAND
RedoTreeConverter.cxx
1 #include "RedoTreeConverter.hxx"
2 #include "BasicUtils.hxx"
3 #include "ND280AnalysisUtils.hxx"
4 #include "TreeConverterUtils.hxx"
5 #include "TDataType.h"
6 #include "TLeaf.h"
7 #include "TROOT.h"
8 
9 // set true for avoiding error messages that might appear when using old flat trees
10 bool suppress_err_msg = true;
11 
12 //********************************************************************
13 RedoTreeConverter::RedoTreeConverter():InputConverter("flattree"){
14  //********************************************************************
15 
16  _firstFile = true;
17  _entry_roo=0;
18  _currentfilename="";
19 
20 
22 
23  flattree = GetChain(_treeName);
24  NRooTrackerVTX = NULL;
25  GRooTrackerVTX = NULL;
26  _spill = NULL;
27  _prevEvent=NULL;
28 
29 
30  fChain = flattree;
31 
32 
33  // initialize to 0 the number of entries
34  _nentries =0;
35 
36  // Initialise all the variables. This is particularly important as some
37  // branches many not exist in the flat tree.
38  sPOTSincePreviousSpill = 0;
39  sRun = 0;
40  sSubrun = 0;
41  sEvt = 0;
42  sEventTime = 0;
43  sNTotalTrueParticles = 0;
44  sNTotalTrueVertices = 0;
45 
46  sBeamGoodSpill = 0;
47  sDQGoodDaq = 0;
48 
49  sTriggerFGDCosmic = 0;
50  sTriggerTripTCosmic = 0;
51 
52  sNTrueVertices = 0;
53  for (UInt_t i = 0; i < NMAXTRUEVERTICES; i++) {
54  sTrueVertexID[i] = 0;
55  sTrueVertexRooVtxIndex[i] = 0;
56  sTrueVertexRooVtxEntry[i] = 0;
57  sTrueVertexReacCode[i] = 0;
58  sTrueVertexNTrueParticles[i] = 0;
59  sTrueVertexNBaryons[i] = 0;
60  sTrueVertexBunch[i] = 0;
61  sTrueVertexDetector[i] = 0;
62  sTrueVertexNuPDG[i] = 0;
63  sTrueVertexTargetPDG[i] = 0;
64  sTrueVertexNuEnergy[i] = 0;
65  sTrueVertexQ2[i] = 0;
66  sTrueVertexNuParentPDG[i] = 0;
67 
68  for (UInt_t j = 0; j < 4; j++) {
69  sTrueVertexPosition[i][j] = 0;
70  sTrueVertexNuParentDecPoint[i][j] = 0;
71  }
72 
73  for (UInt_t j = 0; j < 3; j++) {
74  sTrueVertexNuDir[i][j] = 0;
75  }
76  }
77 
78  sNTrueParticles = 0;
79  for (UInt_t i = 0; i < NMAXTRUEPARTICLES; i++) {
80  sTrueParticleID [i] = 0;
81  sTrueParticleBunch [i] = 0;
82  sTrueParticlePDG [i] = 0;
83  sTrueParticleParentPDG [i] = 0;
84  sTrueParticleGParentPDG [i] = 0;
85  sTrueParticlePrimaryID [i] = 0;
86  sTrueParticleParentID [i] = 0;
87  sTrueParticlePurity [i] = 0;
88  sTrueParticleMomentum [i] = 0;
89  sTrueParticleCharge [i] = 0;
90  sTrueParticleVertexIndex [i] = 0;
91  sTrueParticleTruthVertexID [i] = 0;
92  sTrueParticleNReconTracks [i] = 0;
93  sTrueParticleIsTruePrimaryPi0DecayPhoton [i] = 0;
94  sTrueParticleIsTruePrimaryPi0DecayPhotonChild[i] = 0;
95 
96  for (int j = 0; j < 4; j++) {
97  sTrueParticlePosition[i][j] = 0;
98  sTrueParticlePositionEnd[i][j] = 0;
99  }
100  for (int j = 0; j < 3; j++) {
101  sTrueParticleDirection[i][j] = 0;
102  }
103  sTrueParticleNDetCrossings[i] = 0;
104  for (UInt_t j = 0; j < NMAXCROSSEDDET; j++) {
105  for (int k = 0; k < 4; k++) {
106  sTrueParticleEntrancePosition[i][j][k] = 0;
107  sTrueParticleExitPosition[i][j][k] = 0;
108  }
109  for (int k = 0; k < 3; k++) {
110  sTrueParticleEntranceMomentum[i][j][k] = 0;
111  sTrueParticleExitMomentum[i][j][k] = 0;
112  }
113  sTrueParticleDetector[i][j] = 0;
114  sTrueParticleInActive[i][j] = 0;
115  }
116  }
117 
118  sNFgdTimeBins = 0;
119  for (UInt_t i = 0; i < NMAXFGDTIMEBINS; i++) {
120  sFgdTimeBinMinTime[i] = 0;
121  sFgdTimeBinMaxTime[i] = 0;
122  sFgdTimeBinNHits1[i] = 0;
123  sFgdTimeBinNHits2[i] = 0;
124  sFgdTimeBinRawChargeSum1[i] = 0;
125  sFgdTimeBinRawChargeSum2[i] = 0;
126  sFgdTimeBinG4ID[i] = 0;
127  }
128 
129  Bunch = 0;
130  Weight = 1;
131  NVertices = 0;
132 
133  for (UInt_t i = 0; i < NMAXVERTICES; i++) {
134  vPrimaryIndex[i] = 0;
135  vBunch[i] = 0;
136  vChi2[i] = 0;
137  vNDOF[i] = 0;
138  vNReconParticles[i] = 0;
139  vNTrueVerticesMatch[i] = 0;
140 
141  for (int j = 0; j < 4; j++) {
142  vPosition[i][j] = 0;
143  vVariance[i][j] = 0;
144  }
145 
146  for (UInt_t j = 0; j < NMAXPARTICLESINVERTEX; j++) {
147  vParticlesUniqueID[i][j] = 0;
148  }
149 
150  for (UInt_t j = 0; j < NMAXTRUEVERTICESMATCH; j++) {
151  vTrueVertexIndex[i][j] = 0;
152  vTrueVerticesClean[i][j] = 0;
153  vTrueVerticesCompl[i][j] = 0;
154  }
155  }
156 
157  NParticles = 0;
158  for (UInt_t i = 0; i < NMAXPARTICLES; i++) {
159  trUniqueID[i] = 0;
160  trStatus[i] = 0;
161  trBunch[i] = 0;
162  trNReconVertices[i] = 0;
163  trDetectors[i] = 0;
164  trNTPCs[i] = 0;
165  trNFGDs[i] = 0;
166  trNECALs[i] = 0;
167  trNSMRDs[i] = 0;
168  trNP0Ds[i] = 0;
169  trNHits[i] = 0;
170  trNNodes[i] = 0;
171  trNDOF[i] = 0;
172  trChi2[i] = 0;
173  trCharge[i] = 0;
174  trMomentum[i] = 0;
175  trMomentumFlip[i] = 0;
176  trToFFGD1_FGD2[i] = 0;
177  trToFP0D_FGD1[i] = 0;
178  trToFECal_FGD1[i] = 0;
179  trToFECal_FGD2[i] = 0;
180  trToFFlag_FGD1_FGD2[i] = 0;
181  trToFFlag_P0D_FGD1[i] = 0;
182  trToFFlag_ECal_FGD1[i] = 0;
183  trToFFlag_ECal_FGD2[i] = 0;
184  trMomentumError[i] = 0;
185  trMomentumMuon[i] = 0;
186  trMomentumErrorMuon[i] = 0;
187  trMomentumProton[i] = 0;
188  trMomentumErrorProton[i] = 0;
189  trMomentumEle[i] = 0;
190  trMomentumErrorEle[i] = 0;
191  trRangeMomentumEle[i] = 0;
192  trRangeMomentumMuon[i] = 0;
193  trRangeMomentumProton[i] = 0;
194  trTrueParticleID[i] = 0;
195 
196  for (UInt_t j = 0; j < NDETECTORS; j++) {
197  trDetUsed[i][j] = 0;
198  }
199 
200  for (int j = 0; j < 3; j++) {
201  trDirectionStart[i][j] = 0;
202  trDirectionEnd[i][j] = 0;
203  }
204 
205  for (int j = 0; j < 4; j++) {
206  trPositionStart[i][j] = 0;
207  trPositionEnd[i][j] = 0;
208  }
209 
210  for (int j = 0; j < 3; j++) {
211  trTpcDetector[i][j] = 0;
212  trTpcNHits[i][j] = 0;
213  trTpcNNodes[i][j] = 0;
214  trTpcLength[i][j] = 0;
215  trTpcCharge[i][j] = 0;
216  trTpcMomentum[i][j] = 0;
217  trTpcMomentumError[i][j] = 0;
218  trTpcBackMomentum[i][j] = 0;
219  trTpcRefitCharge[i][j] = 0;
220  trTpcRefitMomentum[i][j] = 0;
221  trTpcEFieldRefitMomentum[i][j] = 0;
222  trTpcdEdxMeas[i][j] = 0;
223  trTpcdEdxExpMu[i][j] = 0;
224  trTpcdEdxExpEle[i][j] = 0;
225  trTpcdEdxExpP[i][j] = 0;
226  trTpcdEdxExpPi[i][j] = 0;
227  trTpcdEdxExpK[i][j] = 0;
228  trTpcdEdxSigmaMu[i][j] = 0;
229  trTpcdEdxSigmaEle[i][j] = 0;
230  trTpcdEdxSigmaP[i][j] = 0;
231  trTpcdEdxSigmaPi[i][j] = 0;
232  trTpcdEdxSigmaK[i][j] = 0;
233  trTpcPurity[i][j] = 0;
234  trTpcTrueParticleID[i][j] = 0;
235 
236  for (int k = 0; k < 3; k++) {
237  trTpcRefitDirection[i][j][k] = 0;
238  trTpcDirectionStart[i][j][k] = 0;
239  trTpcDirectionEnd[i][j][k] = 0;
240  }
241 
242  for (int k = 0; k < 4; k++) {
243  trTpcRefitPosition[i][j][k] = 0;
244  trTpcPositionStart[i][j][k] = 0;
245  trTpcPositionEnd[i][j][k] = 0;
246  }
247  }
248 
249  for (int j = 0; j < 2; j++) {
250  trFgdDetector[i][j] = 0;
251  trFgdNHits[i][j] = 0;
252  trFgdNNodes[i][j] = 0;
253  trFgdLength[i][j] = 0;
254  trFgdX[i][j] = 0;
255  trFgdE[i][j] = 0;
256  trFgdPullmu[i][j] = 0;
257  trFgdPullp[i][j] = 0;
258  trFgdPullpi[i][j] = 0;
259  trFgdPullno[i][j] = 0;
260  trFgdContainment[i][j] = 0;
261  trFgdAvgTime[i][j] = 0;
262  trFgdVertex1x1[i][j] = 0;
263  trFgdVertex3x3[i][j] = 0;
264  trFgdVertex5x5[i][j] = 0;
265  trFgdVertex7x7[i][j] = 0;
266  trFgdVertexLayer[i][j] = 0;
267 
268  for (int k = 0; k < 3; k++) {
269  trFgdDirectionStart[i][j][k] = 0;
270  trFgdDirectionEnd[i][j][k] = 0;
271  }
272 
273  for (int k = 0; k < 4; k++) {
274  trFgdPositionStart[i][j][k] = 0;
275  trFgdPositionEnd[i][j][k] = 0;
276  }
277  }
278 
279 
280  for (UInt_t j = 0; j < NECALSUBDETS; j++) {
281  trECALDetector[i][j] = 0;
282  trECALNHits[i][j] = 0;
283  trECALNNodes[i][j] = 0;
284  trECALLength[i][j] = 0;
285  trECALEMEnergy[i][j] = 0;
286  trECALEDeposit[i][j] = 0;
287  trECALIsShowerLike[i][j] = 0;
288  trECALAvgTime[i][j] = 0;
289  trECALPIDMipEm[i][j] = 0;
290  trECALPIDEmHip[i][j] = 0;
291  trECALMostUpStreamLayerHit[i][j] = 0;
292 
293 
294  for (int k = 0; k < 3; k++) {
295  trECALDirectionStart[i][j][k] = 0;
296  trECALDirectionEnd[i][j][k] = 0;
297  trECALShowerPosition[i][j][k] = 0;
298  }
299 
300  for (int k = 0; k < 4; k++) {
301  trECALPositionStart[i][j][k] = 0;
302  trECALPositionEnd[i][j][k] = 0;
303  }
304  }
305 
306  for (UInt_t j = 0; j < NSMRDSUBDETS; j++) {
307  trSMRDDetector[i][j] = 0;
308  trSMRDNHits[i][j] = 0;
309  trSMRDNNodes[i][j] = 0;
310  trSMRDLength[i][j] = 0;
311  trSMRDAvgTime[i][j] = 0;
312 
313  for (int k = 0; k < 3; k++) {
314  trSMRDDirectionStart[i][j][k] = 0;
315  trSMRDDirectionEnd[i][j][k] = 0;
316  }
317 
318  for (int k = 0; k < 4; k++) {
319  trSMRDPositionStart[i][j][k] = 0;
320  trSMRDPositionEnd[i][j][k] = 0;
321  }
322  }
323 
324  for (int j = 0; j < 1; j++) {
325  trP0DDetector[i][j] = 0;
326  trP0DNHits[i][j] = 0;
327  trP0DNNodes[i][j] = 0;
328  trP0DLength[i][j] = 0;
329  trP0DELoss[i][j] = 0;
330 
331  for (int k = 0; k < 3; k++) {
332  trP0DDirectionStart[i][j][k] = 0;
333  trP0DDirectionEnd[i][j][k] = 0;
334  }
335 
336  for (int k = 0; k < 4; k++) {
337  trP0DPositionStart[i][j][k] = 0;
338  trP0DPositionEnd[i][j][k] = 0;
339  }
340  }
341  }
342 
343 
344  // Initialise all the branches. This is particularly important as some
345  // branches many not exist in the flat tree.
346  b_sPOTSincePreviousSpill = NULL;
347  b_sRun = NULL;
348  b_sSubrun = NULL;
349  b_sEvt = NULL;
350  b_sEventTime = NULL;
351  b_sNTotalTrueParticles = NULL;
352  b_sNTotalTrueVertices = NULL;
353  b_sBeamGoodSpill = NULL;
354  b_sDQGoodDaq = NULL;
355  b_sTriggerFGDCosmic = NULL;
356  b_sTriggerTripTCosmic = NULL;
357 
358  b_sNTrueVertices = NULL;
359 
360  b_sTrueVertexID = NULL;
361  b_sTrueVertexRooVtxIndex = NULL;
362  b_sTrueVertexRooVtxEntry = NULL;
363  b_sTrueVertexReacCode = NULL;
364  b_sTrueVertexNTrueParticles = NULL;
365  b_sTrueVertexNBaryons = NULL;
366  b_sTrueVertexBunch = NULL;
367  b_sTrueVertexDetector = NULL;
368  b_sTrueVertexNuPDG = NULL;
369  b_sTrueVertexTargetPDG = NULL;
370  b_sTrueVertexNuEnergy = NULL;
371  b_sTrueVertexQ2 = NULL;
372  b_sTrueVertexPosition = NULL;
373  b_sTrueVertexNuParentPDG = NULL;
374  b_sTrueVertexNuParentDecPoint = NULL;
375  b_sTrueVertexNuDir = NULL;
376 
377  b_sNTrueParticles = NULL;
378 
379  b_sTrueParticleID = NULL;
380  b_sTrueParticleBunch = NULL;
381  b_sTrueParticlePDG = NULL;
382  b_sTrueParticleParentPDG = NULL;
383  b_sTrueParticleGParentPDG = NULL;
384  b_sTrueParticlePrimaryID = NULL;
385  b_sTrueParticleParentID = NULL;
386  b_sTrueParticlePurity = NULL;
387  b_sTrueParticleMomentum = NULL;
388  b_sTrueParticleCharge = NULL;
389  b_sTrueParticleVertexIndex = NULL;
390  b_sTrueParticleTruthVertexID = NULL;
391  b_sTrueParticleNReconTracks = NULL;
392  b_sTrueParticlePosition = NULL;
393  b_sTrueParticlePositionEnd = NULL;
394  b_sTrueParticleDirection = NULL;
395  b_sTrueParticleNDetCrossings = NULL;
396  b_sTrueParticleEntrancePosition = NULL;
397  b_sTrueParticleExitPosition = NULL;
398  b_sTrueParticleEntranceMomentum = NULL;
399  b_sTrueParticleExitMomentum = NULL;
400  b_sTrueParticleDetector = NULL;
401  b_sTrueParticleInActive = NULL;
402  b_sTrueParticleIsTruePrimaryPi0DecayPhoton = NULL;
403  b_sTrueParticleIsTruePrimaryPi0DecayPhotonChild = NULL;
404 
405  b_sNFgdTimeBins = NULL;
406 
407  b_sFgdTimeBinMinTime = NULL;
408  b_sFgdTimeBinMaxTime = NULL;
409  b_sFgdTimeBinNHits1 = NULL;
410  b_sFgdTimeBinNHits2 = NULL;
411  b_sFgdTimeBinRawChargeSum1 = NULL;
412  b_sFgdTimeBinRawChargeSum2 = NULL;
413  b_sFgdTimeBinG4ID = NULL;
414 
415  b_Bunch = NULL;
416  b_Weight = NULL;
417 
418  b_NVertices = NULL;
419 
420  b_vPrimaryIndex = NULL;
421  b_vBunch = NULL;
422  b_vPosition = NULL;
423  b_vVariance = NULL;
424  b_vChi2 = NULL;
425  b_vNDOF = NULL;
426  b_vNReconParticles = NULL;
427  b_vNTrueVerticesMatch = NULL;
428  b_vParticlesUniqueID = NULL;
429  b_vTrueVertexIndex = NULL;
430  b_vTrueVerticesClean = NULL;
431  b_vTrueVerticesCompl = NULL;
432 
433  b_NParticles = NULL;
434 
435  b_trUniqueID = NULL;
436  b_trStatus = NULL;
437  b_trBunch = NULL;
438  b_trNReconVertices = NULL;
439  b_trDetectors = NULL;
440  b_trDetUsed = NULL;
441  b_trNTPCs = NULL;
442  b_trNFGDs = NULL;
443  b_trNECALs = NULL;
444  b_trNSMRDs = NULL;
445  b_trNP0Ds = NULL;
446  b_trNHits = NULL;
447  b_trNNodes = NULL;
448  b_trNDOF = NULL;
449  b_trChi2 = NULL;
450  b_trCharge = NULL;
451  b_trMomentum = NULL;
452  b_trMomentumFlip = NULL;
453  b_trToFFGD1_FGD2 = NULL;
454  b_trToFP0D_FGD1 = NULL;
455  b_trToFECal_FGD1 = NULL;
456  b_trToFECal_FGD2 = NULL;
457  b_trToFFlag_FGD1_FGD2 = NULL;
458  b_trToFFlag_P0D_FGD1 = NULL;
459  b_trToFFlag_ECal_FGD1 = NULL;
460  b_trToFFlag_ECal_FGD2 = NULL;
461  b_trMomentumError = NULL;
462  b_trMomentumMuon = NULL;
463  b_trMomentumErrorMuon = NULL;
464  b_trMomentumProton = NULL;
465  b_trMomentumErrorProton = NULL;
466  b_trMomentumEle = NULL;
467  b_trMomentumErrorEle = NULL;
468  b_trRangeMomentumEle = NULL;
469  b_trRangeMomentumMuon = NULL;
470  b_trRangeMomentumProton = NULL;
471  b_trDirectionStart = NULL;
472  b_trDirectionEnd = NULL;
473  b_trPositionStart = NULL;
474  b_trPositionEnd = NULL;
475 
476  b_trTpcDetector = NULL;
477  b_trTpcNHits = NULL;
478  b_trTpcNNodes = NULL;
479  b_trTpcLength = NULL;
480  b_trTpcDirectionStart = NULL;
481  b_trTpcDirectionEnd = NULL;
482  b_trTpcPositionStart = NULL;
483  b_trTpcPositionEnd = NULL;
484  b_trTpcCharge = NULL;
485  b_trTpcMomentum = NULL;
486  b_trTpcMomentumError = NULL;
487  b_trTpcBackMomentum = NULL;
488  b_trTpcRefitCharge = NULL;
489  b_trTpcRefitMomentum = NULL;
490  b_trTpcRefitPosition = NULL;
491  b_trTpcRefitDirection = NULL;
492  b_trTpcEFieldRefitMomentum = NULL;
493  b_trTpcdEdxMeas = NULL;
494  b_trTpcdEdxExpMu = NULL;
495  b_trTpcdEdxExpEle = NULL;
496  b_trTpcdEdxExpP = NULL;
497  b_trTpcdEdxExpPi = NULL;
498  b_trTpcdEdxExpK = NULL;
499  b_trTpcdEdxSigmaMu = NULL;
500  b_trTpcdEdxSigmaEle = NULL;
501  b_trTpcdEdxSigmaP = NULL;
502  b_trTpcdEdxSigmaPi = NULL;
503  b_trTpcdEdxSigmaK = NULL;
504  b_trTpcPurity = NULL;
505 
506  b_trFgdDetector = NULL;
507  b_trFgdNHits = NULL;
508  b_trFgdNNodes = NULL;
509  b_trFgdLength = NULL;
510  b_trFgdDirectionStart = NULL;
511  b_trFgdDirectionEnd = NULL;
512  b_trFgdPositionStart = NULL;
513  b_trFgdPositionEnd = NULL;
514  b_trFgdX = NULL;
515  b_trFgdE = NULL;
516  b_trFgdPullmu = NULL;
517  b_trFgdPullp = NULL;
518  b_trFgdPullpi = NULL;
519  b_trFgdPullno = NULL;
520  b_trFgdContainment = NULL;
521  b_trFgdAvgTime = NULL;
522  b_trFgdVertex1x1 = NULL;
523  b_trFgdVertex3x3 = NULL;
524  b_trFgdVertex5x5 = NULL;
525  b_trFgdVertex7x7 = NULL;
526  b_trFgdVertexLayer = NULL;
527 
528  b_trECALDetector = NULL;
529  b_trECALNHits = NULL;
530  b_trECALNNodes = NULL;
531  b_trECALLength = NULL;
532  b_trECALDirectionStart = NULL;
533  b_trECALDirectionEnd = NULL;
534  b_trECALPositionStart = NULL;
535  b_trECALPositionEnd = NULL;
536  b_trECALEMEnergy = NULL;
537  b_trECALEDeposit = NULL;
538  b_trECALIsShowerLike = NULL;
539  b_trECALAvgTime = NULL;
540  b_trECALMostUpStreamLayerHit = NULL;
541  b_trECALPIDMipEm = NULL;
542  b_trECALPIDEmHip = NULL;
543  b_trECALShowerPosition = NULL;
544 
545 
546  b_trSMRDDetector = NULL;
547  b_trSMRDNHits = NULL;
548  b_trSMRDNNodes = NULL;
549  b_trSMRDLength = NULL;
550  b_trSMRDDirectionStart = NULL;
551  b_trSMRDDirectionEnd = NULL;
552  b_trSMRDPositionStart = NULL;
553  b_trSMRDPositionEnd = NULL;
554  b_trSMRDAvgTime = NULL;
555 
556  b_trP0DDetector = NULL;
557  b_trP0DNHits = NULL;
558  b_trP0DNNodes = NULL;
559  b_trP0DLength = NULL;
560  b_trP0DELoss = NULL;
561  b_trP0DDirectionStart = NULL;
562  b_trP0DDirectionEnd = NULL;
563  b_trP0DPositionStart = NULL;
564  b_trP0DPositionEnd = NULL;
565 
566  b_trTrueParticleID = NULL;
567  b_trTpcTrueParticleID = NULL;
568 }
569 
570 //********************************************************************
572  //********************************************************************
573 
574  // Set branch addresses and branch pointers
575  if (!fChain) return false;
576 
577  // Check the existence of the _treeName tree
578  if (!gDirectory->FindObjectAny(_treeName.c_str())) return false;
579 
580  fCurrent = -1;
581  fChain->SetMakeClass(1);
582 
583  return true;
584 }
585 
586 //********************************************************************
588  //********************************************************************
589 
590 
591 
592  // The branches commented below are not read becouse they are not currently needed by any analysis.
593  // This is equivalent to setting their status to 0, as it was done in the previous version
594 
595  // Now set branch addresses for integer variables
596  anaUtils::ConfigureTreeBranch(fChain, "sRun", &sRun, &b_sRun);
597 
598  anaUtils::ConfigureTreeBranch(fChain, "sSubRun", &sSubrun, &b_sSubrun);
599 
600  anaUtils::ConfigureTreeBranch(fChain, "sEvt", &sEvt, &b_sEvt);
601  // anaUtils::ConfigureTreeBranch(fChain, "sEventTime", &sEventTime, &b_sEventTime);
602  // anaUtils::ConfigureTreeBranch(fChain, "sNTotalTrueTracks", &sNTotalTrueParticles, &b_sNTotalTrueParticles);
603  // anaUtils::ConfigureTreeBranch(fChain, "sNTotalTrueVertices", &sNTotalTrueVertices, &b_sNTotalTrueVertices);
604  anaUtils::ConfigureTreeBranch(fChain, "sBeamGoodSpill", &sBeamGoodSpill, &b_sBeamGoodSpill);
605  anaUtils::ConfigureTreeBranch(fChain, "sDQGoodDaq", &sDQGoodDaq, &b_sDQGoodDaq);
606 
607  anaUtils::ConfigureTreeBranch(fChain, "sNTrueVertices", &sNTrueVertices, &b_sNTrueVertices);
608  anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexID", sTrueVertexID, &b_sTrueVertexID);
609  // anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexRooVtxIndex", sTrueVertexRooVtxIndex, &b_sTrueVertexRooVtxIndex);
610  // anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexRooVtxEntry", sTrueVertexRooVtxEntry, &b_sTrueVertexRooVtxEntry);
611  // anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexReacCode", sTrueVertexReacCode, &b_sTrueVertexReacCode);
612  // anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexNTrueParticles", sTrueVertexNTrueParticles, &b_sTrueVertexNTrueParticles);
613  // anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexNBaryons", sTrueVertexNBaryons, &b_sTrueVertexNBaryons);
614  anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexBunch", sTrueVertexBunch, &b_sTrueVertexBunch);
615  anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexNuPDG", sTrueVertexNuPDG, &b_sTrueVertexNuPDG);
616  // anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexTargetPDG", sTrueVertexTargetPDG, &b_sTrueVertexTargetPDG);
617  // anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexNuParentPDG", sTrueVertexNuParentPDG, &b_sTrueVertexNuParentPDG);
618 
619  anaUtils::ConfigureTreeBranch(fChain, "sNTrueTracks", &sNTrueParticles, &b_sNTrueParticles);
620  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackID", sTrueParticleID, &b_sTrueParticleID);
621  // anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackBunch", sTrueParticleBunch, &b_sTrueParticleBunch);
622  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackPDG", sTrueParticlePDG, &b_sTrueParticlePDG);
623  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackParentPDG", sTrueParticleParentPDG, &b_sTrueParticleParentPDG);
624  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackGParentPDG", sTrueParticleGParentPDG, &b_sTrueParticleGParentPDG);
625  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackPrimaryID", sTrueParticlePrimaryID, &b_sTrueParticlePrimaryID);
626  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackParentID", sTrueParticleParentID, &b_sTrueParticleParentID);
627  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackVertexIndex", sTrueParticleVertexIndex, &b_sTrueParticleVertexIndex);
628  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackTruthVertexID", sTrueParticleTruthVertexID, &b_sTrueParticleTruthVertexID);
629  // anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackNReconTracks", sTrueParticleNReconTracks, &b_sTrueParticleNReconTracks);
630  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackInActive", sTrueParticleInActive, &b_sTrueParticleInActive);
631  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackDetector", sTrueParticleDetector, &b_sTrueParticleDetector);
632  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackNDetCrossings", sTrueParticleNDetCrossings, &b_sTrueParticleNDetCrossings);
633  anaUtils::ConfigureTreeBranch(fChain, "sNFgdTimeBins", &sNFgdTimeBins, &b_sNFgdTimeBins);
634  anaUtils::ConfigureTreeBranch(fChain, "sFgdTimeBinNHits1", sFgdTimeBinNHits1, &b_sFgdTimeBinNHits1);
635  anaUtils::ConfigureTreeBranch(fChain, "sFgdTimeBinNHits2", sFgdTimeBinNHits2, &b_sFgdTimeBinNHits2);
636  // anaUtils::ConfigureTreeBranch(fChain, "sFgdTimeBinG4ID", sFgdTimeBinG4ID, &b_sFgdTimeBinG4ID);
637 
638  anaUtils::ConfigureTreeBranch(fChain, "Bunch", &Bunch, &b_Bunch);
639  anaUtils::ConfigureTreeBranch(fChain, "Weight", &Weight, &b_Weight);
640  // anaUtils::ConfigureTreeBranch(fChain, "NVertices", &NVertices, &b_NVertices);
641  // anaUtils::ConfigureTreeBranch(fChain, "vPrimaryIndex", &vPrimaryIndex, &b_vPrimaryIndex);
642  // anaUtils::ConfigureTreeBranch(fChain, "vBunch", &vBunch, &b_vBunch);
643  // anaUtils::ConfigureTreeBranch(fChain, "vNDOF", &vNDOF, &b_vNDOF);
644  anaUtils::ConfigureTreeBranch(fChain, "vNReconParticles", &vNReconParticles, &b_vNReconParticles);
645  anaUtils::ConfigureTreeBranch(fChain, "vNTrueVerticesMatch", &vNTrueVerticesMatch, &b_vNTrueVerticesMatch);
646  anaUtils::ConfigureTreeBranch(fChain, "vParticlesUniqueID", &vParticlesUniqueID, &b_vParticlesUniqueID);
647  anaUtils::ConfigureTreeBranch(fChain, "vTrueVertexIndex", &vTrueVertexIndex, &b_vTrueVertexIndex);
648 
649  anaUtils::ConfigureTreeBranch(fChain, "NTracks", &NParticles, &b_NParticles);
650  anaUtils::ConfigureTreeBranch(fChain, "trUniqueID", trUniqueID, &b_trUniqueID);
651  // anaUtils::ConfigureTreeBranch(fChain, "trStatus", trStatus, &b_trStatus);
652  // anaUtils::ConfigureTreeBranch(fChain, "trBunch", trBunch, &b_trBunch);
653  // anaUtils::ConfigureTreeBranch(fChain, "trNReconVertices", &trNReconVertices, &b_trNReconVertices);
654  // anaUtils::ConfigureTreeBranch(fChain, "trDetectors", trDetectors, &b_trDetectors);
655  anaUtils::ConfigureTreeBranch(fChain, "trDetUsed", trDetUsed, &b_trDetUsed);
656  // anaUtils::ConfigureTreeBranch(fChain, "trNTPCs", trNTPCs, &b_trNTPCs);
657  // anaUtils::ConfigureTreeBranch(fChain, "trNFGDs", trNFGDs, &b_trNFGDs);
658  // anaUtils::ConfigureTreeBranch(fChain, "trNECALs", trNECALs, &b_trNECALs);
659  // anaUtils::ConfigureTreeBranch(fChain, "trNSMRDs", trNSMRDs, &b_trNSMRDs);
660  // anaUtils::ConfigureTreeBranch(fChain, "trNP0Ds", trNP0Ds, &b_trNP0Ds);
661  anaUtils::ConfigureTreeBranch(fChain, "trNHits", trNHits, &b_trNHits);
662  // anaUtils::ConfigureTreeBranch(fChain, "trNNodes", trNNodes, &b_trNNodes);
663  // anaUtils::ConfigureTreeBranch(fChain, "trNDOF", trNDOF, &b_trNDOF);
664  anaUtils::ConfigureTreeBranch(fChain, "trTrueTrackID", trTrueParticleID, &b_trTrueParticleID);
665  anaUtils::ConfigureTreeBranch(fChain, "trTpcDetector", trTpcDetector, &b_trTpcDetector);
666  anaUtils::ConfigureTreeBranch(fChain, "trTpcNNodes", trTpcNNodes, &b_trTpcNNodes);
667  anaUtils::ConfigureTreeBranch(fChain, "trTpcTrueTrackID", trTpcTrueParticleID, &b_trTpcTrueParticleID);
668  anaUtils::ConfigureTreeBranch(fChain, "trFgdDetector", trFgdDetector, &b_trFgdDetector);
669  anaUtils::ConfigureTreeBranch(fChain, "trFgdNNodes", trFgdNNodes, &b_trFgdNNodes);
670  anaUtils::ConfigureTreeBranch(fChain, "trFgdContainment", trFgdContainment, &b_trFgdContainment);
671 
672  // anaUtils::ConfigureTreeBranch(fChain, "trSMRDDetector", trSMRDDetector, &b_trSMRDDetector);
673  // anaUtils::ConfigureTreeBranch(fChain, "trSMRDNNodes", trSMRDNNodes, &b_trSMRDNNodes);
674  // anaUtils::ConfigureTreeBranch(fChain, "trP0DDetector", trP0DDetector, &b_trP0DDetector);
675  // anaUtils::ConfigureTreeBranch(fChain, "trP0DNNodes", trP0DNNodes, &b_trP0DNNodes);
676 
677  // anaUtils::ConfigureTreeBranch(fChain, "sPOTSincePreviousSpill", &sPOTSincePreviousSpill, &b_sPOTSincePreviousSpill);
678  anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexNuEnergy", sTrueVertexNuEnergy, &b_sTrueVertexNuEnergy);
679  // anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexQ2", sTrueVertexQ2, &b_sTrueVertexQ2);
680  anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexPosition", sTrueVertexPosition, &b_sTrueVertexPosition);
681  // anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexNuParentDecPoint", sTrueVertexNuParentDecPoint, &b_sTrueVertexNuParentDecPoint);
682  // anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexNuDir", sTrueVertexNuDir, &b_sTrueVertexNuDir);
683 
684  // anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackPurity", sTrueParticlePurity, &b_sTrueParticlePurity);
685  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackMomentum", sTrueParticleMomentum, &b_sTrueParticleMomentum);
686  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackCharge", sTrueParticleCharge, &b_sTrueParticleCharge);
687  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackPosition", sTrueParticlePosition, &b_sTrueParticlePosition);
688  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackPositionEnd", sTrueParticlePositionEnd, &b_sTrueParticlePositionEnd);
689  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackDirection", sTrueParticleDirection, &b_sTrueParticleDirection);
690  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackEntrancePosition", sTrueParticleEntrancePosition, &b_sTrueParticleEntrancePosition);
691  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackExitPosition", sTrueParticleExitPosition, &b_sTrueParticleExitPosition);
692 
693  anaUtils::ConfigureTreeBranch(fChain, "sFgdTimeBinMinTime", sFgdTimeBinMinTime, &b_sFgdTimeBinMinTime);
694  anaUtils::ConfigureTreeBranch(fChain, "sFgdTimeBinMaxTime", sFgdTimeBinMaxTime, &b_sFgdTimeBinMaxTime);
695  anaUtils::ConfigureTreeBranch(fChain, "sFgdTimeBinRawChargeSum1", sFgdTimeBinRawChargeSum1, &b_sFgdTimeBinRawChargeSum1);
696  anaUtils::ConfigureTreeBranch(fChain, "sFgdTimeBinRawChargeSum2", sFgdTimeBinRawChargeSum2, &b_sFgdTimeBinRawChargeSum2);
697 
698  anaUtils::ConfigureTreeBranch(fChain, "vPosition", &vPosition, &b_vPosition);
699  // anaUtils::ConfigureTreeBranch(fChain, "vVariance", &vVariance, &b_vVariance);
700  // anaUtils::ConfigureTreeBranch(fChain, "vChi2", &vChi2, &b_vChi2);
701  anaUtils::ConfigureTreeBranch(fChain, "vTrueVerticesClean", &vTrueVerticesClean, &b_vTrueVerticesClean);
702  anaUtils::ConfigureTreeBranch(fChain, "vTrueVerticesCompl", &vTrueVerticesCompl, &b_vTrueVerticesCompl);
703 
704  // anaUtils::ConfigureTreeBranch(fChain, "trChi2", trChi2, &b_trChi2);
705  anaUtils::ConfigureTreeBranch(fChain, "trCharge", trCharge, &b_trCharge);
706  anaUtils::ConfigureTreeBranch(fChain, "trToFFGD1_FGD2", trToFFGD1_FGD2, &b_trToFFGD1_FGD2);
707  anaUtils::ConfigureTreeBranch(fChain, "trToFP0D_FGD1", trToFP0D_FGD1, &b_trToFP0D_FGD1);
708  anaUtils::ConfigureTreeBranch(fChain, "trToFECal_FGD1", trToFECal_FGD1, &b_trToFECal_FGD1);
709  anaUtils::ConfigureTreeBranch(fChain, "trToFECal_FGD2", trToFECal_FGD2, &b_trToFECal_FGD2);
710  anaUtils::ConfigureTreeBranch(fChain, "trToFFlag_FGD1_FGD2", trToFFlag_FGD1_FGD2, &b_trToFFlag_FGD1_FGD2);
711  anaUtils::ConfigureTreeBranch(fChain, "trToFFlag_P0D_FGD1", trToFFlag_P0D_FGD1, &b_trToFFlag_P0D_FGD1);
712  anaUtils::ConfigureTreeBranch(fChain, "trToFFlag_ECal_FGD1", trToFFlag_ECal_FGD1, &b_trToFFlag_ECal_FGD1);
713  anaUtils::ConfigureTreeBranch(fChain, "trToFFlag_ECal_FGD2", trToFFlag_ECal_FGD2, &b_trToFFlag_ECal_FGD2);
714  anaUtils::ConfigureTreeBranch(fChain, "trMomentum", trMomentum, &b_trMomentum);
715  anaUtils::ConfigureTreeBranch(fChain, "trMomentumFlip", trMomentumFlip, &b_trMomentumFlip);
716 
717  // anaUtils::ConfigureTreeBranch(fChain, "trMomentumError", trMomentumError, &b_trMomentumError);
718  // anaUtils::ConfigureTreeBranch(fChain, "trMomentumMuon", trMomentumMuon, &b_trMomentumMuon);
719  // anaUtils::ConfigureTreeBranch(fChain, "trMomentumErrorMuon", trMomentumErrorMuon, &b_trMomentumErrorMuon);
720  // anaUtils::ConfigureTreeBranch(fChain, "trMomentumProton", trMomentumProton, &b_trMomentumProton);
721  // anaUtils::ConfigureTreeBranch(fChain, "trMomentumErrorProton", trMomentumErrorProton, &b_trMomentumErrorProton);
722  // anaUtils::ConfigureTreeBranch(fChain, "trMomentumEle", trMomentumEle, &b_trMomentumEle);
723  // anaUtils::ConfigureTreeBranch(fChain, "trMomentumErrorEle", trMomentumErrorEle, &b_trMomentumErrorEle);
724  // anaUtils::ConfigureTreeBranch(fChain, "trRangeMomentumEle", trRangeMomentumEle, &b_trRangeMomentumEle);
725  anaUtils::ConfigureTreeBranch(fChain, "trRangeMomentumMuon", trRangeMomentumMuon, &b_trRangeMomentumMuon);
726  // anaUtils::ConfigureTreeBranch(fChain, "trRangeMomentumProton", trRangeMomentumProton, &b_trRangeMomentumProton);
727 
728  anaUtils::ConfigureTreeBranch(fChain, "trDirectionStart", trDirectionStart, &b_trDirectionStart);
729  anaUtils::ConfigureTreeBranch(fChain, "trDirectionEnd", trDirectionEnd, &b_trDirectionEnd);
730  anaUtils::ConfigureTreeBranch(fChain, "trPositionStart", trPositionStart, &b_trPositionStart);
731  anaUtils::ConfigureTreeBranch(fChain, "trPositionEnd", trPositionEnd, &b_trPositionEnd);
732  anaUtils::ConfigureTreeBranch(fChain, "trTpcDirectionStart", trTpcDirectionStart, &b_trTpcDirectionStart);
733  anaUtils::ConfigureTreeBranch(fChain, "trTpcPositionStart", trTpcPositionStart, &b_trTpcPositionStart);
734  anaUtils::ConfigureTreeBranch(fChain, "trTpcPositionEnd", trTpcPositionEnd, &b_trTpcPositionEnd);
735  anaUtils::ConfigureTreeBranch(fChain, "trTpcCharge", trTpcCharge, &b_trTpcCharge);
736  anaUtils::ConfigureTreeBranch(fChain, "trTpcMomentum", trTpcMomentum, &b_trTpcMomentum);
737  anaUtils::ConfigureTreeBranch(fChain, "trTpcMomentumError", trTpcMomentumError, &b_trTpcMomentumError);
738  anaUtils::ConfigureTreeBranch(fChain, "trTpcBackMomentum", trTpcBackMomentum, &b_trTpcBackMomentum);
739  anaUtils::ConfigureTreeBranch(fChain, "trTpcRefitMomentum", trTpcRefitMomentum, &b_trTpcRefitMomentum);
740  anaUtils::ConfigureTreeBranch(fChain, "trTpcRefitCharge", trTpcRefitCharge, &b_trTpcRefitCharge);
741  anaUtils::ConfigureTreeBranch(fChain, "trTpcRefitDirection", trTpcRefitDirection, &b_trTpcRefitDirection);
742  anaUtils::ConfigureTreeBranch(fChain, "trTpcRefitPosition", trTpcRefitPosition, &b_trTpcRefitPosition);
743  anaUtils::ConfigureTreeBranch(fChain, "trTpcEFieldRefitMomentum", trTpcEFieldRefitMomentum, &b_trTpcEFieldRefitMomentum);
744  anaUtils::ConfigureTreeBranch(fChain, "trTpcdEdxMeas", trTpcdEdxMeas, &b_trTpcdEdxMeas);
745  anaUtils::ConfigureTreeBranch(fChain, "trTpcdEdxExpMu", trTpcdEdxExpMu, &b_trTpcdEdxExpMu);
746  anaUtils::ConfigureTreeBranch(fChain, "trTpcdEdxExpEle", trTpcdEdxExpEle, &b_trTpcdEdxExpEle);
747  anaUtils::ConfigureTreeBranch(fChain, "trTpcdEdxExpP", trTpcdEdxExpP, &b_trTpcdEdxExpP);
748  anaUtils::ConfigureTreeBranch(fChain, "trTpcdEdxExpPi", trTpcdEdxExpPi, &b_trTpcdEdxExpPi);
749  // anaUtils::ConfigureTreeBranch(fChain, "trTpcdEdxExpK", trTpcdEdxExpK, &b_trTpcdEdxExpK);
750  anaUtils::ConfigureTreeBranch(fChain, "trTpcdEdxSigmaMu", trTpcdEdxSigmaMu, &b_trTpcdEdxSigmaMu);
751  anaUtils::ConfigureTreeBranch(fChain, "trTpcdEdxSigmaEle", trTpcdEdxSigmaEle, &b_trTpcdEdxSigmaEle);
752  anaUtils::ConfigureTreeBranch(fChain, "trTpcdEdxSigmaP", trTpcdEdxSigmaP, &b_trTpcdEdxSigmaP);
753  anaUtils::ConfigureTreeBranch(fChain, "trTpcdEdxSigmaPi", trTpcdEdxSigmaPi, &b_trTpcdEdxSigmaPi);
754  // anaUtils::ConfigureTreeBranch(fChain, "trTpcdEdxSigmaK", trTpcdEdxSigmaK, &b_trTpcdEdxSigmaK);
755  // anaUtils::ConfigureTreeBranch(fChain, "trTpcPurity", trTpcPurity, &b_trTpcPurity);
756 
757  anaUtils::ConfigureTreeBranch(fChain, "trFgdDirectionStart", trFgdDirectionStart, &b_trFgdDirectionStart);
758  anaUtils::ConfigureTreeBranch(fChain, "trFgdPositionStart", trFgdPositionStart, &b_trFgdPositionStart);
759  anaUtils::ConfigureTreeBranch(fChain, "trFgdPositionEnd", trFgdPositionEnd, &b_trFgdPositionEnd);
760  anaUtils::ConfigureTreeBranch(fChain, "trFgdX", trFgdX, &b_trFgdX);
761  anaUtils::ConfigureTreeBranch(fChain, "trFgdE", trFgdE, &b_trFgdE);
762  anaUtils::ConfigureTreeBranch(fChain, "trFgdPullmu", trFgdPullmu, &b_trFgdPullmu);
763  anaUtils::ConfigureTreeBranch(fChain, "trFgdPullp", trFgdPullp, &b_trFgdPullp);
764  anaUtils::ConfigureTreeBranch(fChain, "trFgdPullpi", trFgdPullpi, &b_trFgdPullpi);
765  anaUtils::ConfigureTreeBranch(fChain, "trFgdPullno", trFgdPullno, &b_trFgdPullno);
766  // anaUtils::ConfigureTreeBranch(fChain, "trFgdAvgTime", trFgdAvgTime, &b_trFgdAvgTime);
767  // anaUtils::ConfigureTreeBranch(fChain, "trFgdVertex1x1", trFgdVertex1x1, &b_trFgdVertex1x1);
768  // anaUtils::ConfigureTreeBranch(fChain, "trFgdVertex3x3", trFgdVertex3x3, &b_trFgdVertex3x3);
769  // anaUtils::ConfigureTreeBranch(fChain, "trFgdVertex5x5", trFgdVertex5x5, &b_trFgdVertex5x5);
770  // anaUtils::ConfigureTreeBranch(fChain, "trFgdVertex7x7", trFgdVertex7x7, &b_trFgdVertex7x7);
771  // anaUtils::ConfigureTreeBranch(fChain, "trFgdVertexLayer", trFgdVertexLayer, &b_trFgdVertexLayer);
772 
773 
774  // ECal variables
775  // anaUtils::ConfigureTreeBranch(fChain, "trECALDetector", trECALDetector, &b_trECALDetector);
776  anaUtils::ConfigureTreeBranch(fChain, "trECALNNodes", trECALNNodes, &b_trECALNNodes);
777 // anaUtils::ConfigureTreeBranch(fChain, "trECALIsShowerLike", trECALIsShowerLike, &b_trECALIsShowerLike);
778  anaUtils::ConfigureTreeBranch(fChain, "trECALDirectionStart", trECALDirectionStart, &b_trECALDirectionStart);
779 // anaUtils::ConfigureTreeBranch(fChain, "trECALDirectionEnd", trECALDirectionEnd, &b_trECALDirectionEnd);
780  anaUtils::ConfigureTreeBranch(fChain, "trECALPositionStart", trECALPositionStart, &b_trECALPositionStart);
781 // anaUtils::ConfigureTreeBranch(fChain, "trECALPositionEnd", trECALPositionEnd, &b_trECALPositionEnd);
782 // anaUtils::ConfigureTreeBranch(fChain, "trECALEDeposit", trECALEDeposit, &b_trECALEDeposit);
783  anaUtils::ConfigureTreeBranch(fChain, "trECALAvgTime", trECALAvgTime, &b_trECALAvgTime);
784 
785  anaUtils::ConfigureTreeBranch(fChain, "trECALEMEnergy", trECALEMEnergy, &b_trECALEMEnergy);
786  anaUtils::ConfigureTreeBranch(fChain, "trECALLength", trECALLength, &b_trECALLength);
787  anaUtils::ConfigureTreeBranch(fChain, "trECALPIDMipEm", trECALPIDMipEm, &b_trECALPIDMipEm);
788  anaUtils::ConfigureTreeBranch(fChain, "trECALPIDEmHip", trECALPIDEmHip, &b_trECALPIDEmHip);
789  anaUtils::ConfigureTreeBranch(fChain, "trECALNNodes", trECALNNodes, &b_trECALNNodes);
790  anaUtils::ConfigureTreeBranch(fChain, "trECALMostUpStreamLayerHit", trECALMostUpStreamLayerHit, &b_trECALMostUpStreamLayerHit);
791  anaUtils::ConfigureTreeBranch(fChain, "trECALShowerPosition", trECALShowerPosition, &b_trECALShowerPosition);
792 
793 
794 
795 
796  // anaUtils::ConfigureTreeBranch(fChain, "trSMRDDirectionStart", trSMRDDirectionStart, &b_trSMRDDirectionStart);
797  // anaUtils::ConfigureTreeBranch(fChain, "trSMRDPositionStart", trSMRDPositionStart, &b_trSMRDPositionStart);
798  // anaUtils::ConfigureTreeBranch(fChain, "trSMRDPositionEnd", trSMRDPositionEnd, &b_trSMRDPositionEnd);
799  // anaUtils::ConfigureTreeBranch(fChain, "trSMRDAvgTime", trSMRDAvgTime, &b_trSMRDAvgTime);
800 
801  anaUtils::ConfigureTreeBranch(fChain, "trP0DLength", trP0DLength, &b_trP0DLength);
802  anaUtils::ConfigureTreeBranch(fChain, "trP0DELoss", trP0DELoss, &b_trP0DELoss);
803  // anaUtils::ConfigureTreeBranch(fChain, "trP0DDirectionStart", trP0DDirectionStart, &b_trP0DDirectionStart);
804  // anaUtils::ConfigureTreeBranch(fChain, "trP0DPositionStart", trP0DPositionStart, &b_trP0DPositionStart);
805  // anaUtils::ConfigureTreeBranch(fChain, "trP0DPositionEnd", trP0DPositionEnd, &b_trP0DPositionEnd);
806 
807  fChain->SetBranchStatus("*",1);
808  /*
809  fChain->SetBranchStatus("*",0);
810 
811  fChain->SetBranchStatus("sPOTSincePreviousSpill",0); //!
812  fChain->SetBranchStatus("sRun",1); //!
813  fChain->SetBranchStatus("sEvt",1); //!
814  fChain->SetBranchStatus("sEventTime",0); //!
815  fChain->SetBranchStatus("sNTotalTrueParticles",0); //!
816  fChain->SetBranchStatus("sNTotalTrueVertices",0); //!
817  fChain->SetBranchStatus("sBeamGoodSpill",1); //!
818  fChain->SetBranchStatus("sDQGoodDaq",1); //!
819  fChain->SetBranchStatus("sTriggerFGDCosmic",0);//!
820  fChain->SetBranchStatus("sTriggerTripTCosmic",0);//!
821  fChain->SetBranchStatus("sNTrueVertices",1); //!
822  fChain->SetBranchStatus("sTrueVertexID",1); //!
823  fChain->SetBranchStatus("sTrueVertexRooVtxIndex",0); //!
824  fChain->SetBranchStatus("sTrueVertexRooVtxEntry",0); //!
825  fChain->SetBranchStatus("sTrueVertexReacCode",0); //!
826  fChain->SetBranchStatus("sTrueVertexNTrueParticles",0); //!
827  fChain->SetBranchStatus("sTrueVertexNReconTracks",0); //!
828  fChain->SetBranchStatus("sTrueVertexNReconVertices",0); //!
829  fChain->SetBranchStatus("sTrueVertexNBaryons",0); //!
830  fChain->SetBranchStatus("sTrueVertexBunch",1); //!
831  fChain->SetBranchStatus("sTrueVertexNuPDG",1); //!
832  fChain->SetBranchStatus("sTrueVertexTargetPDG",0); //!
833  fChain->SetBranchStatus("sTrueVertexNuEnergy",1); //!
834  fChain->SetBranchStatus("sTrueVertexQ2",0); //!
835  fChain->SetBranchStatus("sTrueVertexPosition",1); //!
836  fChain->SetBranchStatus("sTrueVertexNuParentPDG",0); //!
837  fChain->SetBranchStatus("sTrueVertexNuParentDecPoint",0); //!
838  fChain->SetBranchStatus("sTrueVertexNuDir",0); //!
839  fChain->SetBranchStatus("sNTrueParticles",1); //!
840  fChain->SetBranchStatus("sTrueTrackID",1); //!
841  fChain->SetBranchStatus("sTrueTrackBunch",0); //!
842  fChain->SetBranchStatus("sTrueTrackPDG",1); //!
843  fChain->SetBranchStatus("sTrueTrackParentPDG",1); //!
844  fChain->SetBranchStatus("sTrueTrackGParentPDG",1); //!
845  fChain->SetBranchStatus("sTrueTrackPrimaryID",1); //!
846  fChain->SetBranchStatus("sTrueTrackParentID",1); //!
847  fChain->SetBranchStatus("sTrueTrackPurity",0); //!
848  fChain->SetBranchStatus("sTrueTrackMomentum",1); //!
849  fChain->SetBranchStatus("sTrueTrackCharge",1); //!
850  fChain->SetBranchStatus("sTrueTrackVertexIndex",1); //!
851  fChain->SetBranchStatus("sTrueTrackTruthVertexID",1); //!
852  fChain->SetBranchStatus("sTrueTrackNReconTracks",0); //!
853  fChain->SetBranchStatus("sTrueTrackPosition",1); //!
854  fChain->SetBranchStatus("sTrueTrackPositionEnd",1); //!
855  fChain->SetBranchStatus("sTrueTrackDirection",1); //!
856  fChain->SetBranchStatus("sTrueTrackNDetCrossings",1);
857  fChain->SetBranchStatus("sTrueTrackEntrancePosition",1);
858  fChain->SetBranchStatus("sTrueTrackExitPosition",1);
859  fChain->SetBranchStatus("sTrueTrackDetector",1);
860  fChain->SetBranchStatus("sTrueTrackInActive",1);
861  fChain->SetBranchStatus("sNFgdTimeBins",1); //!
862  fChain->SetBranchStatus("sFgdTimeBinMinTime",1); //!
863  fChain->SetBranchStatus("sFgdTimeBinMaxTime",1); //!
864  fChain->SetBranchStatus("sFgdTimeBinNHits1",1); //!
865  fChain->SetBranchStatus("sFgdTimeBinNHits2",1); //!
866  fChain->SetBranchStatus("sFgdTimeBinRawChargeSum1",1); //!
867  fChain->SetBranchStatus("sFgdTimeBinRawChargeSum2",1); //!
868  fChain->SetBranchStatus("sFgdTimeBinG4ID",0); //!
869  fChain->SetBranchStatus("Bunch",1); //!
870  fChain->SetBranchStatus("Weight",1); //!
871  fChain->SetBranchStatus("NVertices",1); //!
872  fChain->SetBranchStatus("vPrimaryIndex",1); //!
873  fChain->SetBranchStatus("vBunch",0); //!
874  fChain->SetBranchStatus("vPosition",1); //!
875  fChain->SetBranchStatus("vVariance",0); //!
876  fChain->SetBranchStatus("vChi2",0); //!
877  fChain->SetBranchStatus("vNDOF",0); //!
878  fChain->SetBranchStatus("vNReconParticles",1); //!
879  fChain->SetBranchStatus("vNTrueVerticesMatch",1); //!
880  fChain->SetBranchStatus("vParticlesUniqueID",1); //!
881  fChain->SetBranchStatus("vTrueVertexIndex",1); //!
882  fChain->SetBranchStatus("vTrueVerticesClean",1); //!
883  fChain->SetBranchStatus("vTrueVerticesCompl",1); //!
884  fChain->SetBranchStatus("NTracks",1); //!
885  fChain->SetBranchStatus("trUniqueID",1); //!
886  fChain->SetBranchStatus("trStatus",0); //!
887  fChain->SetBranchStatus("trBunch",0); //!
888  fChain->SetBranchStatus("trNReconVertices",0); //!
889  fChain->SetBranchStatus("trDetectors",0); //!
890  fChain->SetBranchStatus("trDetUsed",1); //!
891  fChain->SetBranchStatus("trNTPCs",0); //!
892  fChain->SetBranchStatus("trNFGDs",0); //!
893  fChain->SetBranchStatus("trNECALs",0); //!
894  fChain->SetBranchStatus("trNSMRDs",0); //!
895  fChain->SetBranchStatus("trNP0Ds",0); //!
896  fChain->SetBranchStatus("trNHits",1); //!
897  fChain->SetBranchStatus("trNNodes",0); //!
898  fChain->SetBranchStatus("trNDOF",0); //!
899  fChain->SetBranchStatus("trChi2",0); //!
900  fChain->SetBranchStatus("trCharge",1); //!
901  fChain->SetBranchStatus("trToFFGD1_FGD2", 1); //!
902  fChain->SetBranchStatus("trToFP0D_FGD1", 1); //!
903  fChain->SetBranchStatus("trToFECal_FGD1", 1); //!
904  fChain->SetBranchStatus("trToFECal_FGD2", 1); //!
905  fChain->SetBranchStatus("trToFFlag_FGD1_FGD2", 1); //!
906  fChain->SetBranchStatus("trToFFlag_P0D_FGD1", 1); //!
907  fChain->SetBranchStatus("trToFFlag_ECal_FGD1", 1); //!
908  fChain->SetBranchStatus("trToFFlag_ECal_FGD2", 1); //!
909  fChain->SetBranchStatus("trMomentum",1); //!
910  fChain->SetBranchStatus("trMomentumError",0); //!
911  fChain->SetBranchStatus("trMomentumMuon",0); //!
912  fChain->SetBranchStatus("trMomentumErrorMuon",0); //!
913  fChain->SetBranchStatus("trMomentumProton",0); //!
914  fChain->SetBranchStatus("trMomentumErrorProton",0); //!
915  fChain->SetBranchStatus("trMomentumEle",0); //!
916  fChain->SetBranchStatus("trMomentumErrorEle",0); //!
917  fChain->SetBranchStatus("trRangeMomentumEle",0); //!
918  fChain->SetBranchStatus("trRangeMomentumMuon",0); //!
919  fChain->SetBranchStatus("trRangeMomentumProton",0); //!
920  fChain->SetBranchStatus("trDirectionStart",1); //!
921  fChain->SetBranchStatus("trDirectionEnd",0); //!
922  fChain->SetBranchStatus("trPositionStart",1); //!
923  fChain->SetBranchStatus("trPositionEnd",1); //!
924  fChain->SetBranchStatus("trTpcDetector",1); //!
925  fChain->SetBranchStatus("trTpcNNodes",1); //!
926  fChain->SetBranchStatus("trTpcDirectionStart",1); //!
927  fChain->SetBranchStatus("trTpcPositionStart",1); //!
928  fChain->SetBranchStatus("trTpcPositionEnd",1); //!
929  fChain->SetBranchStatus("trTpcCharge",1); //!
930  fChain->SetBranchStatus("trTpcMomentum",1); //!
931  fChain->SetBranchStatus("trTpcMomentumError",1); //!
932  fChain->SetBranchStatus("trTpcRefitMomentum",1);
933  fChain->SetBranchStatus("trTpcBackMomentum",1); //!
934  fChain->SetBranchStatus("trTpcdEdxMeas",1); //!
935  fChain->SetBranchStatus("trTpcdEdxExpMu",1); //!
936  fChain->SetBranchStatus("trTpcdEdxExpEle",1); //!
937  fChain->SetBranchStatus("trTpcdEdxExpP",1); //!
938  fChain->SetBranchStatus("trTpcdEdxExpPi",1); //!
939  fChain->SetBranchStatus("trTpcdEdxExpK",0); //!
940  fChain->SetBranchStatus("trTpcdEdxSigmaMu",1); //!
941  fChain->SetBranchStatus("trTpcdEdxSigmaEle",1); //!
942  fChain->SetBranchStatus("trTpcdEdxSigmaP",1); //!
943  fChain->SetBranchStatus("trTpcdEdxSigmaPi",1); //!
944  fChain->SetBranchStatus("trTpcdEdxSigmaK",0); //!
945  fChain->SetBranchStatus("trTpcPurity",0); //!
946  fChain->SetBranchStatus("trFgdDetector",1); //!
947  fChain->SetBranchStatus("trFgdNNodes",1); //!
948  fChain->SetBranchStatus("trFgdDirectionStart",1); //!
949  fChain->SetBranchStatus("trFgdPositionStart",1); //!
950  fChain->SetBranchStatus("trFgdPositionEnd",1); //!
951  fChain->SetBranchStatus("trFgdX",1); //!
952  fChain->SetBranchStatus("trFgdE",1); //!
953  fChain->SetBranchStatus("trFgdPullmu",1); //!
954  fChain->SetBranchStatus("trFgdPullp",1); //!
955  fChain->SetBranchStatus("trFgdPullpi",1); //!
956  fChain->SetBranchStatus("trFgdPullno",1); //!
957  fChain->SetBranchStatus("trFgdContainment",1); //!
958  fChain->SetBranchStatus("trFgdAvgTime",0); //!
959  fChain->SetBranchStatus("trFgdVertex1x1",0); //!
960  fChain->SetBranchStatus("trFgdVertex3x3",0); //!
961  fChain->SetBranchStatus("trFgdVertex5x5",0); //!
962  fChain->SetBranchStatus("trFgdVertex7x7",0); //!
963  fChain->SetBranchStatus("trFgdVertexLayer",0); //!
964  fChain->SetBranchStatus("trECALDetector",0); //!
965  fChain->SetBranchStatus("trECALNNodes",0); //!
966  fChain->SetBranchStatus("trECALDirectionStart",0); //!
967  fChain->SetBranchStatus("trECALPositionStart",0); //!
968  fChain->SetBranchStatus("trECALPositionEnd",0); //!
969  fChain->SetBranchStatus("trECALEMEnergy",0); //!
970  fChain->SetBranchStatus("trECALEDeposit",0); //!
971  fChain->SetBranchStatus("trECALIsShowerLike",0); //!
972  fChain->SetBranchStatus("trECALAvgTime",0); //!
973  fChain->SetBranchStatus("trSMRDDetector",0); //!
974  fChain->SetBranchStatus("trSMRDNNodes",0); //!
975  fChain->SetBranchStatus("trSMRDDirectionStart",0); //!
976  fChain->SetBranchStatus("trSMRDPositionStart",0); //!
977  fChain->SetBranchStatus("trSMRDPositionEnd",0); //!
978  fChain->SetBranchStatus("trSMRDAvgTime",0); //!
979  fChain->SetBranchStatus("trP0DDetector",0); //!
980  fChain->SetBranchStatus("trP0DNNodes",0); //!
981  fChain->SetBranchStatus("trP0DDirectionStart",0); //!
982  fChain->SetBranchStatus("trP0DPositionStart",0); //!
983  fChain->SetBranchStatus("trP0DPositionEnd",0); //!
984  fChain->SetBranchStatus("trTrueParticleID",1); //!
985  fChain->SetBranchStatus("trTpcTrueParticleID",1); //!
986  */
987 }
988 
989 //********************************************************************
990 RedoTreeConverter::~RedoTreeConverter(){
991  //********************************************************************
992 
993  if (!fChain) return;
994 
995  if (flattree) delete flattree->GetCurrentFile();
996  if (GRooTrackerVTX) delete GRooTrackerVTX->GetCurrentFile();
997  if (NRooTrackerVTX) delete NRooTrackerVTX->GetCurrentFile();
998  if (flattree) delete flattree;
999  if (GRooTrackerVTX) delete GRooTrackerVTX;
1000  if (NRooTrackerVTX) delete NRooTrackerVTX;
1001 }
1002 
1003 
1004 //****************************************************************************
1005 bool RedoTreeConverter::AddFileToTChain(const std::string& inputString){
1006  //****************************************************************************
1007 
1008  std::cout << "RedoTreeConverter::AddFileToTChain(). Adding file: " << inputString << std::endl;
1009 
1010  // ------------- Check that the file has some entries. Otherwise ignore it -----------------
1011  TChain dummy(_treeName.c_str());
1012  dummy.AddFile(inputString.c_str());
1013  if (dummy.GetEntries("sEvt>=0") == 0){
1014  std::cout << " ----> This file does not contain any entries. IGNORED !!!!" << std::endl;
1015  return true;
1016  }
1017 
1018 
1019  // Open the file to do few checks
1020  TFile *f = TFile::Open(inputString.c_str());
1021  f->cd();
1022 
1023  // ------------- Check that the header tree exists (needed for POT counting). If it doesn't ignore the file -----------------
1024 
1025  if (!gDirectory->FindObjectAny("header")){
1026  std::cout << " ----> This file does not contain a header tree. IGNORED !!!!" << std::endl;
1027  return true;
1028  }
1029 
1030 
1031  // ---------- Deal with RooTrackerVtx trees. Only for the first file
1032 
1033  if( _firstFile ) {
1034  fGenie=fNeut=false;
1035 
1036  if( gDirectory->FindObjectAny("NRooTrackerVtx")) {
1037  fNeut = true;
1038  AddChain("NRooTrackerVtx");
1039  NRooTrackerVTX = GetChain("NRooTrackerVtx");
1040  /*
1041  NRooTrackerVTX->SetBranchAddress("RunID", &RunID);
1042  NRooTrackerVTX->SetBranchAddress("SubrunID", &SubrunID);
1043  NRooTrackerVTX->SetBranchAddress("EventID", &EventID);
1044  NVtx = new TClonesArray("ND::NRooTrackerVtx",100);
1045  NRooTrackerVTX->SetBranchAddress("NVtx",&NNVtx);
1046  NRooTrackerVTX->SetBranchAddress("Vtx",&NVtx);
1047  */
1048  std::cout << "RedoTreeConverter::AddFileToTChain(). NEUT RooTrackerVtx tree found !!" << std::endl;
1049  }
1050  else if(gDirectory->FindObjectAny("GRooTrackerVtx")) {
1051  fGenie = true;
1052  AddChain("GRooTrackerVtx");
1053  GRooTrackerVTX = GetChain("GRooTrackerVtx");
1054  /*
1055  GRooTrackerVTX->SetBranchAddress("RunID", &RunID);
1056  GRooTrackerVTX->SetBranchAddress("SubrunID", &SubrunID);
1057  GRooTrackerVTX->SetBranchAddress("EventID", &EventID);
1058  GVtx = new TClonesArray("ND::GRooTrackerVtx",100);
1059  GRooTrackerVTX->SetBranchAddress("NVtx",&NGVtx);
1060  GRooTrackerVTX->SetBranchAddress("Vtx",&GVtx);
1061  */
1062  std::cout << "redoTreeConverter::AddFileToTChain(). GENIE RooTrackerVtx tree found !!" << std::endl;
1063  }
1064  }
1065 
1066  f->Close();
1067 
1068  // ------------- Add the file to the RooTrackerVtx chain
1069 
1070  if( fGenie && GRooTrackerVTX) {
1071  GRooTrackerVTX->AddFile(inputString.c_str());
1072  }
1073  else if( fNeut && NRooTrackerVTX) {
1074  NRooTrackerVTX->AddFile(inputString.c_str());
1075  }
1076 
1077  // ------------- Add the file to the FlatTree chain
1078  flattree->AddFile(inputString.c_str());
1079 
1080 
1081  // Define the branches to be read from the input tree only once after reading the first file
1082  // Need to re-initialize now we know which type of highland tree we are dealing with
1083  if( _firstFile ) {
1084  _firstFile = false;
1085  DefineBranches();
1086  }
1087  /*
1088  // Define Data/MC status: use the first valid entry in the flat tree
1089  Long64_t nentries = GetEntries();
1090  for (Long64_t i = 0; i<nentries; i++){
1091  Int_t entry_temp = flattree->GetEntry(i);
1092  if (entry_temp<=0) continue;
1093 // Set the data/MC mode and return false when mixing data and MC files
1094 if (!header().SetIsMC(sIsMC)) return false;
1095 break;
1096 }
1097 */
1098 // Read the header tree for POT counting (when running over a file list POT is incremented), IsMC and SoftwareVersion
1099 return header().AddHeader(inputString);
1100 }
1101 
1102 
1103 //*****************************************************************************
1104 Int_t RedoTreeConverter::GetSpill(Long64_t& entry, AnaSpillC*& spill){
1105  //*****************************************************************************
1106 
1107  // Read contents of entry.
1108  if (!fChain) return 0;
1109 
1110  // Create an instance of AnaSpill
1111  spill = MakeSpill();
1112 
1113  Int_t entry_temp;
1114 
1115  // Get a new entry from the flat tree
1116  entry_temp = flattree->GetEntry(entry);
1117 
1118 
1119  if (entry_temp>0 && sRun > 1000000) {
1120  if (fGenie && GRooTrackerVTX) GRooTrackerVTX->GetEntry(entry);
1121  if (fNeut && NRooTrackerVTX){
1122  NRooTrackerVTX->GetEntry(_entry_roo);
1123  _entry_roo++;
1124  }
1125  }
1126 
1127  // Print the current file
1128  TString filename(flattree->GetFile()->GetName());
1129  if( filename != _currentfilename ) {
1130  std::cout << " Running on file : " << filename << std::endl;
1131  _currentfilename = filename;
1132  }
1133 
1134  // Fill the general spill info
1135  _spill = static_cast<AnaSpillB*>(spill);
1136  FillInfo(_spill);
1137 
1138  // Always make the out of bunch
1139  _spill->OutOfBunch = MakeBunch();
1140 
1141  int evt_prev=sEvt;
1142 
1143  while (sEvt==evt_prev && entry < _nentries){
1144 
1145  // Create and fill a new bunch
1146  if (Bunch==-1) {
1147  FillBunchInfo(_spill->TrueParticles, _spill->OutOfBunch);
1148  } else {
1149  AnaBunchB* bunch = MakeBunch();
1150  _spill->Bunches.push_back(bunch);
1151  FillBunchInfo(_spill->TrueParticles, bunch);
1152  }
1153 
1154  // increment the entry number
1155  entry++;
1156 
1157  // break if we have reach the maximum entry number
1158  if (entry>=_nentries) break;
1159 
1160  // save the previous event number
1161  evt_prev=sEvt;
1162 
1163  // get a new entry from the input tree
1164  entry_temp = flattree->GetEntry(entry);
1165  }
1166 
1167  return entry_temp;
1168 }
1169 
1170 //*****************************************************************************
1171 Int_t RedoTreeConverter::GetEvent(Long64_t& entry, AnaEventC*& event){
1172  //*****************************************************************************
1173 
1174  // Read contents of entry.
1175  if (!fChain) return 0;
1176  Int_t entry_temp;
1177 
1178  // get a new entry from the input tree
1179  entry_temp = flattree->GetEntry(entry);
1180 
1181  // Reed the RooTrackerVtx when exists
1182  if (entry_temp>0 && sRun > 1000000) {
1183  if (fGenie && GRooTrackerVTX) GRooTrackerVTX->GetEntry(entry);
1184  if (fNeut && NRooTrackerVTX){
1185  NRooTrackerVTX->GetEntry(_entry_roo);
1186  _entry_roo++;
1187  }
1188  }
1189 
1190  // Print the current file
1191  TString filename(flattree->GetFile()->GetName());
1192  if( filename != _currentfilename ) {
1193  std::cout << " Running on file : " << filename << std::endl;
1194  _currentfilename = filename;
1195  }
1196 
1197  // Create a new event
1198  event = new AnaEventB();
1199 
1200  // Fill the event info;
1201  FillEventInfo(static_cast<AnaEventB*>(event));
1202 
1203  // Increment entry number
1204  entry++;
1205 
1206  _prevEvent=static_cast<AnaEventB*>(event);
1207  return entry_temp;
1208 }
1209 
1210 //********************************************************************
1212  //********************************************************************
1213 
1214  // ND::header().IncrementPOTBySpill(*_spill);
1215 }
1216 
1217 //*****************************************************************************
1219  //*****************************************************************************
1220 
1221  // if this is the first time this function is called get the number of entries
1222  // Comment out for now, since Asher needs to call GetEntries for every tree when not using preloading
1223  //if (_nentries==0)
1224  _nentries = GetChain()->GetEntries("sEvt>=0");
1225 
1226  // just returns the number of entries otherwise
1227  return _nentries;
1228 }
1229 
1230 //*****************************************************************************
1231 void RedoTreeConverter::FillEventInfo(AnaEventB* event){
1232  //*****************************************************************************
1233 
1234  // When the previous event has the same event number it means that we are in the same Spill.
1235  // In this case we can copy all common spill info from the previous event
1236  bool filled = false;
1237  if (_prevEvent){
1238  if (sEvt == _prevEvent->EventInfo.Event){
1239  // Don't copy bunch info but clone truth
1240  event->Copy(*_prevEvent, false);
1241  filled = true;
1242  }
1243  }
1244  // otherwise this is a new spill and everything should be filled
1245  if (!filled)
1246  FillEventSpillInfo(event);
1247 
1248  // Now we fill the Bunch info
1249  event->Bunch = Bunch;
1250  event->Weight = Weight;
1251 
1252 
1253  event->nParticles = 0;
1254  event->nVertices = 0;
1255  anaUtils::CreateArray(event->Particles, NParticles);
1256  anaUtils::CreateArray(event->Vertices, NVertices);
1257  for (int i=0;i<NParticles;i++){
1258  AnaTrackB* track = MakeTrack();
1259  FillTrackInfo(event, i, track);
1260  event->Particles[event->nParticles] = track;
1261  event->nParticles++;
1262  }
1263  for (int i=0;i<NVertices;i++){
1264  AnaVertexB* vertex = MakeVertex();
1265  FillVertexInfo(i, vertex, event);
1266  event->Vertices[event->nVertices] = vertex;
1267  event->nVertices++;
1268  }
1269 
1270 }
1271 
1272 //*****************************************************************************
1273 void RedoTreeConverter::FillEventSpillInfo(AnaEventB* event){
1274  //*****************************************************************************
1275 
1276  if (sRun==0 || sRun>1000000)
1277  event->EventInfo.IsMC = true;
1278  else
1279  event->EventInfo.IsMC = false;
1280 
1281  event->EventInfo.Run = sRun;
1282  event->EventInfo.Event = sEvt;
1283  event->EventInfo.SetIsSandMC();
1284  // Fill the true vertices vector. This should be called before filling the true particles vector
1285  event->nTrueVertices = 0;
1286  anaUtils::CreateArray(event->TrueVertices, sNTrueVertices);
1287  for (int i=0;i<sNTrueVertices;i++){
1288  AnaTrueVertexB* vertex = MakeTrueVertex();
1289  FillTrueVertexInfo(i, vertex);
1290  event->TrueVertices[event->nTrueVertices] = vertex;
1291  event->nTrueVertices++;
1292  }
1293 
1294  // Fill the true particles vector
1295  event->nTrueParticles = 0;
1296  anaUtils::CreateArray(event->TrueParticles, sNTrueParticles);
1297  for (int i=0;i<sNTrueParticles;i++){
1298  AnaTrueParticleB* particle = MakeTrueParticle();
1299  FillTrueParticleInfo(event, i, particle);
1300  // if(!particle->TrueVertex){
1301  // delete particle;
1302  // continue;
1303  // }
1304  event->TrueParticles[event->nTrueParticles] = particle;
1305  event->nTrueParticles++;
1306  }
1307 
1308  // Give the proper size to the TrueParticles vector for each TrueVertex.
1309  // This can be done only after filling the general True Particle vector (above) since is in this process
1310  // when the TrueVertex <---> TrueParticle association is done
1311  for (int i=0;i<event->nTrueVertices;i++){
1312  anaUtils::ResizeArray(event->TrueVertices[i]->TrueParticles, event->TrueVertices[i]->nTrueParticles);
1313  }
1314 
1315  event->DataQuality = MakeDataQuality();
1316  event->Beam = MakeBeam();
1317  FillDQInfo(event->DataQuality);
1318  FillBeamInfo(event->Beam);
1319 
1320  // FGD time bin info
1321  FillFgdTimeBinInfo(event);
1322 }
1323 
1324 //*****************************************************************************
1325 void RedoTreeConverter::FillInfo(AnaSpillB* spill){
1326  //*****************************************************************************
1327  spill->EventInfo = MakeEventInfo();
1328 
1329  if (sRun==0 || sRun>1000000)
1330  spill->EventInfo->IsMC = true;
1331  else
1332  spill->EventInfo->IsMC = false;
1333 
1334  spill->EventInfo->Run = sRun;
1335  spill->EventInfo->Event = sEvt;
1336  spill->EventInfo->SetIsSandMC();
1337 
1338  spill->NTotalTrueParticles = sNTotalTrueParticles;
1339  spill->NTotalTrueVertices = sNTotalTrueVertices;
1340 
1341  // Fill the true vertices vector. This should be called before filling the true particles vector
1342  spill->TrueVertices.clear();
1343  int nVertices = std::min((int)NMAXTRUEVERTICES, sNTrueVertices);
1344  for (int i=0;i<nVertices;i++){
1345  AnaTrueVertexB* vertex = MakeTrueVertex();
1346  FillTrueVertexInfo(i, vertex);
1347  FillTrueVertexRooInfo(vertex);
1348  spill->TrueVertices.push_back(vertex);
1349  }
1350 
1351  // Fill the true particles vector
1352  spill->TrueParticles.clear();
1353  int nParts = std::min((int)NMAXTRUEPARTICLES, sNTrueParticles);
1354  for (int i=0;i<nParts;i++){
1355  AnaTrueParticleB* particle = MakeTrueParticle();
1356  FillTrueParticleInfo(spill->TrueVertices, i, particle);
1357  spill->TrueParticles.push_back(particle);
1358  }
1359 
1360  spill->DataQuality = MakeDataQuality();
1361  spill->Beam = MakeBeam();
1362  FillDQInfo(spill->DataQuality);
1363  FillBeamInfo(spill->Beam);
1364  // FillTriggerInfo(&spill->Trigger);
1365 
1366  // FGD time bin info
1367  FillFgdTimeBinInfo(spill->FgdTimeBins);
1368 }
1369 
1370 //*****************************************************************************
1371 void RedoTreeConverter::FillBunchInfo(std::vector<AnaTrueParticleB*>& trueParticles, AnaBunchB* bunch){
1372  //*****************************************************************************
1373 
1374  bunch->Bunch = Bunch;
1375  bunch->Weight = Weight;
1376  bunch->Particles.clear();
1377  bunch->Vertices.clear();
1378 
1379  for (int i=0;i<NParticles;i++){
1380  AnaTrackB* track = MakeTrack();
1381  FillTrackInfo(trueParticles, i, track);
1382  bunch->Particles.push_back(track);
1383  }
1384 
1385  for (int i=0;i<NVertices;i++){
1386  AnaVertexB* vertex = MakeVertex();
1387  FillVertexInfo(i, vertex, bunch);
1388  bunch->Vertices.push_back(vertex);
1389  }
1390 }
1391 
1392 //*****************************************************************************
1393 void RedoTreeConverter::FillFgdTimeBinInfo(std::vector<AnaFgdTimeBinB*>& FgdTimeBins){
1394  //*****************************************************************************
1395 
1396  //loop over fgd time bins
1397  for(int ibin=0; ibin<sNFgdTimeBins; ibin++) {
1398 
1399  AnaFgdTimeBinB* abin = MakeFgdTimeBin();
1400  FgdTimeBins.push_back(abin);
1401 
1402  abin->MinTime = sFgdTimeBinMinTime[ibin];
1403  abin->NHits[0] = sFgdTimeBinNHits1[ibin];
1404  abin->NHits[1] = sFgdTimeBinNHits2[ibin];
1405  abin->RawChargeSum[0] = sFgdTimeBinRawChargeSum1[ibin];
1406  abin->RawChargeSum[1] = sFgdTimeBinRawChargeSum2[ibin];
1407  // abin->G4ID = sFgdTimeBinG4ID[ibin];
1408  }
1409 }
1410 
1411 //*****************************************************************************
1412 void RedoTreeConverter::FillFgdTimeBinInfo(AnaEventB* event){
1413  //*****************************************************************************
1414 
1415  //loop over fgd time bins
1416  event->nFgdTimeBins = 0;
1417  anaUtils::CreateArray(event->FgdTimeBins, sNFgdTimeBins);
1418  for(int ibin=0; ibin<sNFgdTimeBins; ibin++) {
1419 
1420  AnaFgdTimeBinB* abin = MakeFgdTimeBin();
1421  event->FgdTimeBins[event->nFgdTimeBins] = abin;
1422  event->nFgdTimeBins++;
1423 
1424  abin->MinTime = sFgdTimeBinMinTime[ibin];
1425  abin->NHits[0] = sFgdTimeBinNHits1[ibin];
1426  abin->NHits[1] = sFgdTimeBinNHits2[ibin];
1427  abin->RawChargeSum[0] = sFgdTimeBinRawChargeSum1[ibin];
1428  abin->RawChargeSum[1] = sFgdTimeBinRawChargeSum2[ibin];
1429  // abin->G4ID = sFgdTimeBinG4ID[ibin];
1430  }
1431 }
1432 
1433 //*****************************************************************************
1434 void RedoTreeConverter::FillDQInfo(AnaDataQualityB* dq){
1435  //*****************************************************************************
1436 
1437  dq->GoodDaq = sDQGoodDaq;
1438 }
1439 
1440 //*****************************************************************************
1441 void RedoTreeConverter::FillBeamInfo(AnaBeamB* beam){
1442  //*****************************************************************************
1443 
1444  beam->GoodSpill = sBeamGoodSpill;
1445 }
1446 
1447 //*****************************************************************************
1448 //void RedoTreeConverter::FillTriggerInfo(AnaTrigger* trigger){
1449 //*****************************************************************************
1450 /*
1451  trigger->FGDCosmic = sTriggerFGDCosmic;
1452  trigger->TripTCosmic = sTriggerTripTCosmic;
1453  }
1454  */
1455 //*****************************************************************************
1456 void RedoTreeConverter::FillTrackInfo(AnaEventB* event, int itrk, AnaTrackB* track){
1457  //*****************************************************************************
1458 
1459  track->Index = itrk;
1460  track->UniqueID = (trUniqueID)[itrk];
1461  // track->Status = (trStatus)[itrk];
1462  // track->Detectors = (trDetectors)[itrk];
1463  track->Charge = (trCharge)[itrk];
1464  track->NHits = (trNHits)[itrk];
1465  track->NNodes = (trNNodes)[itrk];
1466  track->Momentum = (trMomentum)[itrk];
1467  track->MomentumFlip = (trMomentumFlip)[itrk];
1468  track->ToF.FGD1_FGD2 = (trToFFGD1_FGD2)[itrk];
1469  track->ToF.P0D_FGD1 = (trToFP0D_FGD1)[itrk];
1470  track->ToF.ECal_FGD1 = (trToFECal_FGD1)[itrk];
1471  track->ToF.ECal_FGD2 = (trToFECal_FGD2)[itrk];
1472  track->ToF.Flag_FGD1_FGD2 = (trToFFlag_FGD1_FGD2)[itrk];
1473  track->ToF.Flag_P0D_FGD1 = (trToFFlag_P0D_FGD1)[itrk];
1474  track->ToF.Flag_ECal_FGD1 = (trToFFlag_ECal_FGD1)[itrk];
1475  track->ToF.Flag_ECal_FGD2 = (trToFFlag_ECal_FGD2)[itrk];
1476  // track->MomentumError = (trMomentumError)[itrk];
1477 
1478  track->RangeMomentumMuon = (trRangeMomentumMuon)[itrk];
1479 
1480 
1481  anaUtils::CopyArray(trPositionStart[itrk], track->PositionStart, 4);
1482  anaUtils::CopyArray(trPositionEnd[itrk], track->PositionEnd, 4);
1483  anaUtils::CopyArray(trDirectionStart[itrk], track->DirectionStart, 3);
1484  anaUtils::CopyArray(trDirectionEnd[itrk], track->DirectionEnd, 3);
1485 
1486  convUtils::ConvertTrackDetEnumToBitField(track->Detector, (trDetUsed)[itrk]);
1487 
1488  FillSubdetectorInfo(event, itrk, track);
1489 
1490  // Find the true particle associated with this recon track
1491  FindTrueParticle(event, trTrueParticleID[itrk], track->TrueObject);
1492 
1493  // Save all recon tracks associated to this true particle
1494  /*
1495  if (track->TrueObject){
1496  AnaTrueObjectC* thistrueobj = track->TrueObject;
1497 
1498  // Vectors are already filled with null pointers --> fill, remove last one (that should be null) and sort
1499  thistrueobj->ReconParticles.insert(thistrueobj->ReconParticles.begin(),track);
1500  if (thistrueobj->ReconParticles.back())
1501  if ( ! suppress_err_msg) std::cout << "minor error 73731" << std::endl;
1502  if ( ! thistrueobj->ReconParticles.back()) thistrueobj->ReconParticles.pop_back();
1503  // sort here to keep handle associations from different bunches
1504  std::sort(thistrueobj->ReconParticles.begin(), thistrueobj->ReconParticles.end(), AnaTrackB::CompareMomentum);
1505 
1506  }
1507  */
1508 }
1509 
1510 //*****************************************************************************
1511 void RedoTreeConverter::FillTrackInfo(std::vector<AnaTrueParticleB*>& trueParticles, int itrk, AnaTrackB* track){
1512  //*****************************************************************************
1513 
1514  track->Index = itrk;
1515  track->UniqueID = (trUniqueID)[itrk];
1516  // track->Status = (trStatus)[itrk];
1517  // track->Detectors = (trDetectors)[itrk];
1518  track->Charge = (trCharge)[itrk];
1519  track->NHits = (trNHits)[itrk];
1520  track->NNodes = (trNNodes)[itrk];
1521  track->Momentum = (trMomentum)[itrk];
1522  track->MomentumFlip = (trMomentumFlip)[itrk];
1523  track->ToF.FGD1_FGD2 = (trToFFGD1_FGD2)[itrk];
1524  track->ToF.P0D_FGD1 = (trToFP0D_FGD1)[itrk];
1525  track->ToF.ECal_FGD1 = (trToFECal_FGD1)[itrk];
1526  track->ToF.ECal_FGD2 = (trToFECal_FGD2)[itrk];
1527  track->ToF.Flag_FGD1_FGD2 = (trToFFlag_FGD1_FGD2)[itrk];
1528  track->ToF.Flag_P0D_FGD1 = (trToFFlag_P0D_FGD1)[itrk];
1529  track->ToF.Flag_ECal_FGD1 = (trToFFlag_ECal_FGD1)[itrk];
1530  track->ToF.Flag_ECal_FGD2 = (trToFFlag_ECal_FGD2)[itrk];
1531  // track->MomentumError = (trMomentumError)[itrk];
1532 
1533  track->RangeMomentumMuon = (trRangeMomentumMuon)[itrk];
1534 
1535 
1536  anaUtils::CopyArray(trPositionStart[itrk], track->PositionStart, 4);
1537  anaUtils::CopyArray(trPositionEnd[itrk], track->PositionEnd, 4);
1538  anaUtils::CopyArray(trDirectionStart[itrk], track->DirectionStart, 3);
1539  anaUtils::CopyArray(trDirectionEnd[itrk], track->DirectionEnd, 3);
1540 
1541  convUtils::ConvertTrackDetEnumToBitField(track->Detector, (trDetUsed)[itrk]);
1542 
1543  FillSubdetectorInfo(trueParticles, itrk, track);
1544 
1545  // Find the true track associated with this recon track
1546  FindTrueParticle(trueParticles, trTrueParticleID[itrk], track->TrueObject);
1547 
1548  // Save all recon tracks associated to this true particle
1549  /*
1550  if (track->TrueObject){
1551  AnaTrueObjectC* thistrueobj = track->TrueObject;
1552 
1553  // Vectors are already filled with null pointers --> fill, remove last one (that should be null) and sort
1554  thistrueobj->ReconParticles.insert(thistrueobj->ReconParticles.begin(),track);
1555  if (thistrueobj->ReconParticles.back())
1556  if ( ! suppress_err_msg) std::cout << "minor error 73731" << std::endl;
1557  if ( ! thistrueobj->ReconParticles.back()) thistrueobj->ReconParticles.pop_back();
1558  // sort here to keep handle associations from different bunches
1559  std::sort(thistrueobj->ReconParticles.begin(), thistrueobj->ReconParticles.end(), AnaTrackB::CompareMomentum);
1560 
1561  }
1562  */
1563 }
1564 
1565 //*****************************************************************************
1566 void RedoTreeConverter::FillSubdetectorInfo(std::vector<AnaTrueParticleB*>& trueParticles, int itrk, AnaTrackB* track){
1567  //*****************************************************************************
1568 
1569  track->nTPCSegments = 0;
1570  track->nFGDSegments = 0;
1571  track->nECALSegments = 0;
1572  for (int i = 0; i < SubDetId::kInvalidSubdetector; ++i){
1573  SubDetId::SubDetEnum idet = static_cast<SubDetId::SubDetEnum>(i);
1574  if(!SubDetId::GetDetectorUsed(track->Detector, idet)) continue;
1575  if(SubDetId::IsTPCDetector(idet)){
1576  if (track->nTPCSegments==(int)NMAXTPCS)
1577  continue;
1578  AnaTPCParticleB* seg = MakeTpcTrack();
1579  int tpc = convUtils::GetLocalDetEnum(SubDetId::kTPC, idet);
1580  FillTpcInfo(trueParticles, itrk, tpc, seg);
1581  track->TPCSegments[track->nTPCSegments] = seg;
1582  track->nTPCSegments++;
1583  }
1584  else if(SubDetId::IsFGDDetector(idet)){
1585  if (track->nFGDSegments==(int)NMAXFGDS)
1586  continue;
1587  AnaFGDParticleB* seg = MakeFgdTrack();
1588  int fgd = convUtils::GetLocalDetEnum(SubDetId::kFGD, idet);
1589  FillFgdInfo(itrk, fgd, seg);
1590  track->FGDSegments[track->nFGDSegments] = seg;
1591  track->nFGDSegments++;
1592  }
1593 
1594  else if(SubDetId::IsECALDetector(idet)){
1595  if (track->nECALSegments==(int)NMAXECALS)
1596  continue;
1597 
1598  AnaECALParticleB* seg = MakeEcalTrack();
1599  int ecal = convUtils::GetLocalDetEnum(SubDetId::kECAL, idet);
1600  FillEcalInfo(itrk, ecal, seg);
1601  track->ECALSegments[track->nECALSegments++] = seg;
1602  }
1603 
1604  }
1605 
1606 }
1607 
1608 //*****************************************************************************
1609 void RedoTreeConverter::FillSubdetectorInfo(AnaEventB* event, int itrk, AnaTrackB* track){
1610  //*****************************************************************************
1611 
1612  track->nTPCSegments = 0;
1613  track->nFGDSegments = 0;
1614  track->nECALSegments = 0;
1615  for (int i = 0; i < SubDetId::kInvalidSubdetector; ++i){
1616  SubDetId::SubDetEnum idet = static_cast<SubDetId::SubDetEnum>(i);
1617  if(!SubDetId::GetDetectorUsed(track->Detector, idet)) continue;
1618  if(SubDetId::IsTPCDetector(idet)){
1619  AnaTPCParticleB* seg = MakeTpcTrack();
1620  int tpc = convUtils::GetLocalDetEnum(SubDetId::kTPC, idet);
1621  FillTpcInfo(event, itrk, tpc, seg);
1622  track->TPCSegments[track->nTPCSegments] = seg;
1623  track->nTPCSegments++;
1624  }
1625  else if(SubDetId::IsFGDDetector(idet)){
1626  AnaFGDParticleB* seg = MakeFgdTrack();
1627  int fgd = convUtils::GetLocalDetEnum(SubDetId::kFGD, idet);
1628  FillFgdInfo(itrk, fgd, seg);
1629  track->FGDSegments[track->nFGDSegments] = seg;
1630  track->nFGDSegments++;
1631  }
1632 
1633  else if(SubDetId::IsECALDetector(idet)){
1634  if (track->nECALSegments==(int)NMAXECALS)
1635  continue;
1636  AnaECALParticleB* seg = MakeEcalTrack();
1637  int ecal = convUtils::GetLocalDetEnum(SubDetId::kECAL, idet);
1638  FillEcalInfo(itrk, ecal, seg);
1639  track->ECALSegments[track->nECALSegments++] = seg;
1640  }
1641  }
1642 
1643 
1644 
1645 }
1646 
1647 //*****************************************************************************
1648 void RedoTreeConverter::FillTpcInfo(std::vector<AnaTrueParticleB*>& trueParticles, int itrk, int tpc, AnaTPCParticleB* seg){
1649  //*****************************************************************************
1650 
1652 
1653  seg->Charge = (trTpcCharge)[itrk][tpc];
1654  seg->NNodes = (int)(trTpcNNodes)[itrk][tpc];
1655  seg->Momentum = (trTpcMomentum)[itrk][tpc];
1656  seg->MomentumError = (trTpcMomentumError)[itrk][tpc];
1657  // seg->Length = (trTpcLength)[itrk][tpc];
1658 
1659  seg->RefitMomentum = (trTpcRefitMomentum)[itrk][tpc];
1660  seg->EFieldRefitMomentum = (trTpcEFieldRefitMomentum)[itrk][tpc];
1661 
1662  seg->dEdxMeas = (trTpcdEdxMeas)[itrk][tpc];
1663 
1664  seg->dEdxexpMuon = (trTpcdEdxExpMu)[itrk][tpc];
1665  seg->dEdxexpEle = (trTpcdEdxExpEle)[itrk][tpc];
1666  seg->dEdxexpProton = (trTpcdEdxExpP)[itrk][tpc];
1667  seg->dEdxexpPion = (trTpcdEdxExpPi)[itrk][tpc];
1668 
1669  seg->dEdxSigmaMuon = (trTpcdEdxSigmaMu)[itrk][tpc];
1670  seg->dEdxSigmaEle = (trTpcdEdxSigmaEle)[itrk][tpc];
1671  seg->dEdxSigmaProton = (trTpcdEdxSigmaP)[itrk][tpc];
1672  seg->dEdxSigmaPion = (trTpcdEdxSigmaPi)[itrk][tpc];
1673 
1674  // seg->Purity = (trTpcPurity)[itrk][tpc];
1675 
1676 
1677  for (int i=0;i<4;i++){
1678  seg->PositionStart[i] = (trTpcPositionStart)[itrk][tpc][i];
1679  seg->PositionEnd[i] = (trTpcPositionEnd)[itrk][tpc][i];
1680  }
1681 
1682  for (int i=0;i<3;i++){
1683  seg->DirectionStart[i] = (trTpcDirectionStart)[itrk][tpc][i];
1684  // seg->DirectionEnd[i] = (trTpcDirectionEnd)[itrk][tpc][i];
1685  }
1686 
1687  // Find the true particle assiciated with this recon particle
1688  FindTrueParticle(trueParticles, (trTpcTrueParticleID)[itrk][tpc], seg->TrueObject);
1689 }
1690 
1691 //*****************************************************************************
1692 void RedoTreeConverter::FillTpcInfo(AnaEventB* event, int itrk, int tpc, AnaTPCParticleB* seg){
1693  //*****************************************************************************
1694 
1696 
1697  seg->Charge = (trTpcCharge)[itrk][tpc];
1698  seg->NNodes = (int)(trTpcNNodes)[itrk][tpc];
1699  seg->Momentum = (trTpcMomentum)[itrk][tpc];
1700  seg->MomentumError = (trTpcMomentumError)[itrk][tpc];
1701  // seg->Length = (trTpcLength)[itrk][tpc];
1702 
1703 
1704  seg->RefitMomentum = (trTpcRefitMomentum)[itrk][tpc];
1705  seg->EFieldRefitMomentum = (trTpcEFieldRefitMomentum)[itrk][tpc];
1706 
1707  seg->dEdxMeas = (trTpcdEdxMeas)[itrk][tpc];
1708 
1709  seg->dEdxexpMuon = (trTpcdEdxExpMu)[itrk][tpc];
1710  seg->dEdxexpEle = (trTpcdEdxExpEle)[itrk][tpc];
1711  seg->dEdxexpProton = (trTpcdEdxExpP)[itrk][tpc];
1712  seg->dEdxexpPion = (trTpcdEdxExpPi)[itrk][tpc];
1713 
1714  seg->dEdxSigmaMuon = (trTpcdEdxSigmaMu)[itrk][tpc];
1715  seg->dEdxSigmaEle = (trTpcdEdxSigmaEle)[itrk][tpc];
1716  seg->dEdxSigmaProton = (trTpcdEdxSigmaP)[itrk][tpc];
1717  seg->dEdxSigmaPion = (trTpcdEdxSigmaPi)[itrk][tpc];
1718 
1719  // seg->Purity = (trTpcPurity)[itrk][tpc];
1720 
1721 
1722  for (int i=0;i<4;i++){
1723  seg->PositionStart[i] = (trTpcPositionStart)[itrk][tpc][i];
1724  seg->PositionEnd[i] = (trTpcPositionEnd)[itrk][tpc][i];
1725  }
1726 
1727  for (int i=0;i<3;i++){
1728  seg->DirectionStart[i] = (trTpcDirectionStart)[itrk][tpc][i];
1729  // seg->DirectionEnd[i] = (trTpcDirectionEnd)[itrk][tpc][i];
1730  }
1731 
1732  // Find the true track assiciated with this recon particle
1733  FindTrueParticle(event, (trTpcTrueParticleID)[itrk][tpc], seg->TrueObject);
1734 }
1735 
1736 //*****************************************************************************
1737 void RedoTreeConverter::FillFgdInfo(int itrk, int fgd, AnaFGDParticleB* seg){
1738  //*****************************************************************************
1739 
1741 
1742  seg->NNodes = (int)(trFgdNNodes)[itrk][fgd];
1743  // seg->Length = (trFgdLength)[itrk][fgd];
1744 
1745  seg->Pullmu = (trFgdPullmu)[itrk][fgd];
1746  seg->Pullp = (trFgdPullp)[itrk][fgd];
1747  seg->Pullpi = (trFgdPullpi)[itrk][fgd];
1748  seg->Pullno = (trFgdPullno)[itrk][fgd];
1749  seg->Containment = (trFgdContainment)[itrk][fgd];
1750  seg->X = (trFgdX)[itrk][fgd];
1751 
1752  /*
1753  seg->AvgTime = (trFgdAvgTime)[itrk][fgd];
1754 
1755 
1756  seg->Vertex1x1 = (trFgdVertex1x1)[itrk][fgd];
1757  seg->Vertex3x3 = (trFgdVertex3x3)[itrk][fgd];
1758  seg->Vertex5x5 = (trFgdVertex5x5)[itrk][fgd];
1759  seg->Vertex7x7 = (trFgdVertex7x7)[itrk][fgd];
1760  seg->VertexLayer = (trFgdVertexLayer)[itrk][fgd];
1761  */
1762  for (int i=0;i<4;i++){
1763  seg->PositionStart[i] = (trFgdPositionStart)[itrk][fgd][i];
1764  seg->PositionEnd[i] = (trFgdPositionEnd)[itrk][fgd][i];
1765  }
1766 
1767  for (int i=0;i<3;i++){
1768  seg->DirectionStart[i] = (trFgdDirectionStart)[itrk][fgd][i];
1769  // seg->DirectionEnd[i] = (trFgdDirectionEnd)[itrk][fgd][i];
1770  }
1771 
1772 }
1773 
1774 //*****************************************************************************
1775 void RedoTreeConverter::FillEcalInfo(int itrk, int ecal, AnaECALParticleB* seg){
1776  //*****************************************************************************
1777 
1779 
1780  seg->NNodes = (int)(trECALNNodes)[itrk][ecal];
1781  seg->Length = (trECALLength)[itrk][ecal];
1782  seg->EMEnergy = (trECALEMEnergy)[itrk][ecal];
1783  seg->PIDMipEm = trECALPIDMipEm[itrk][ecal];
1784  seg->PIDEmHip = trECALPIDEmHip[itrk][ecal];
1785 
1786  //seg->IsShowerLike = trECALIsShowerLike[itrk][ecal];
1787  //seg->AvgTime = trECALAvgTime[itrk][ecal];
1788  //seg->EDeposit = trECALEDeposit[itrk][ecal];
1789 
1790 
1791  seg->MostUpStreamLayerHit = (int)trECALMostUpStreamLayerHit[itrk][ecal];
1792 
1793  for (int i = 0; i < 3; i++){
1794  seg->ShowerPosition[i] = (trECALShowerPosition)[itrk][ecal][i];
1795  seg->DirectionStart[i] = (trECALDirectionStart)[itrk][ecal][i];
1796  //seg->DirectionEnd[i] = (trECALDirectionStart)[itrk][ecal][i];
1797  }
1798 
1799  for (int i = 0; i < 4; i++){
1800  seg->PositionStart[i] = (trECALPositionStart)[itrk][ecal][i];
1801  // seg->PositionEnd[i] = (trECALPositionEnd)[itrk][ecal][i];
1802  }
1803 
1804 }
1805 
1806 //*****************************************************************************
1807 void RedoTreeConverter::FillSmrdInfo(int itrk, int smrd, AnaSMRDParticleB* seg){
1808  //*****************************************************************************
1809 
1811 
1812  for (int i=0;i<4;i++){
1813  seg->PositionStart[i] = (trSMRDPositionStart)[itrk][smrd][i];
1814  seg->PositionEnd[i] = (trSMRDPositionEnd)[itrk][smrd][i];
1815  }
1816 
1817  for (int i=0;i<3;i++){
1818  seg->DirectionStart[i] = (trSMRDDirectionStart)[itrk][smrd][i];
1819  }
1820 }
1821 
1822 //*****************************************************************************
1823 void RedoTreeConverter::FillP0dInfo(int itrk, int p0d, AnaP0DParticleB* seg){
1824  //*****************************************************************************
1825 
1826  SubDetId::SetDetectorUsed(seg->Detector, SubDetId::kP0D);
1827 
1828  seg->Length = (trP0DLength)[itrk][p0d];
1829  seg->ELoss = (trP0DELoss)[itrk][p0d];
1830 
1831  for (int i=0;i<4;i++){
1832  seg->PositionStart[i] = (trP0DPositionStart)[itrk][p0d][i];
1833  seg->PositionEnd[i] = (trP0DPositionEnd)[itrk][p0d][i];
1834  }
1835 
1836  for (int i=0;i<3;i++){
1837  seg->DirectionStart[i] = (trP0DDirectionStart)[itrk][p0d][i];
1838  }
1839 }
1840 
1841 //*****************************************************************************
1842 void RedoTreeConverter::FillTrueParticleInfo(std::vector<AnaTrueVertexB*>& trueVertices, int itrk, AnaTrueParticleB* particle){
1843  //*****************************************************************************
1844  particle->ID = (sTrueParticleID)[itrk];
1845  particle->ParentID = (sTrueParticleParentID)[itrk];
1846  particle->PDG = (sTrueParticlePDG)[itrk];
1847  particle->ParentPDG = (sTrueParticleParentPDG)[itrk];
1848  particle->GParentPDG = (sTrueParticleGParentPDG)[itrk];
1849 
1850  particle->Charge = (sTrueParticleCharge)[itrk];
1851  particle->Momentum = (sTrueParticleMomentum)[itrk];
1852 
1853  anaUtils::CopyArray(sTrueParticlePosition[itrk], particle->Position, 4);
1854  anaUtils::CopyArray(sTrueParticlePositionEnd[itrk], particle->PositionEnd, 4);
1855  anaUtils::CopyArray(sTrueParticleDirection[itrk], particle->Direction, 3);
1856 
1857  particle->nDetCrossings = 0;
1858  UInt_t nCrossings = sTrueParticleNDetCrossings[itrk];
1859  // for backward compatibility since sTrueParticleNDetCrossings have been just introduced in FlatTree
1860  if( nCrossings==0 || nCrossings > NMAXCROSSEDDET ) nCrossings = NMAXCROSSEDDET;
1861  anaUtils::CreateArray(particle->DetCrossings, nCrossings);
1862  for(UInt_t i=0;i<nCrossings;i++){
1863  if (sTrueParticleDetector[itrk][i]<0) continue;
1864  AnaDetCrossingB* cross = new AnaDetCrossingB();
1865  convUtils::ConvertTrueParticleDetEnumToBitField(cross->Detector, sTrueParticleDetector[itrk][i]);
1866 
1867  cross->InActive = (bool) sTrueParticleInActive[itrk][i];
1868 
1869  anaUtils::CopyArray(sTrueParticleEntrancePosition[itrk][i], cross->EntrancePosition, 4);
1870  anaUtils::CopyArray(sTrueParticleExitPosition[itrk][i], cross->ExitPosition, 4);
1871 
1872  particle->DetCrossings[particle->nDetCrossings] = cross;
1873  particle->nDetCrossings++;
1874  }
1875 
1876  particle->TrueVertex = NULL;
1877  particle->VertexID = (sTrueParticleTruthVertexID)[itrk];
1878 
1879  for(UInt_t i = 0; i < trueVertices.size(); ++i){
1880  if(particle->VertexID == trueVertices[i]->ID){
1881  // Associate the vertex to this track
1882  particle->TrueVertex = trueVertices[i];
1883  // add this track to the list of true tracks in the true vertex
1884  if((UInt_t)particle->TrueVertex->nTrueParticles >=NMAXTRUEPARTICLES) break;
1885  particle->TrueVertex->TrueParticles[particle->TrueVertex->nTrueParticles] = particle;
1886  particle->TrueVertex->nTrueParticles++;
1887  break;
1888  }
1889  }
1890 }
1891 
1892 //*****************************************************************************
1893 void RedoTreeConverter::FillTrueParticleInfo(AnaEventB* event, int itrk, AnaTrueParticleB* particle){
1894  //*****************************************************************************
1895  particle->ID = (sTrueParticleID)[itrk];
1896  particle->ParentID = (sTrueParticleParentID)[itrk];
1897  particle->PDG = (sTrueParticlePDG)[itrk];
1898  particle->ParentPDG = (sTrueParticleParentPDG)[itrk];
1899  particle->GParentPDG = (sTrueParticleGParentPDG)[itrk];
1900 
1901  particle->Charge = (sTrueParticleCharge)[itrk];
1902  particle->Momentum = (sTrueParticleMomentum)[itrk];
1903 
1904  anaUtils::CopyArray(sTrueParticlePosition[itrk], particle->Position, 4);
1905  anaUtils::CopyArray(sTrueParticlePositionEnd[itrk], particle->PositionEnd, 4);
1906  anaUtils::CopyArray(sTrueParticleDirection[itrk], particle->Direction, 3);
1907 
1908  particle->nDetCrossings = 0;
1909  UInt_t nCrossings = sTrueParticleNDetCrossings[itrk];
1910  // for backward compatibility since sTrueParticleNDetCrossings have been just introduced in FlatTree
1911  if( nCrossings==0 || nCrossings > NMAXCROSSEDDET ) nCrossings = NMAXCROSSEDDET;
1912  anaUtils::CreateArray(particle->DetCrossings, nCrossings);
1913  for(UInt_t i=0;i<nCrossings;i++){
1914  if (sTrueParticleDetector[itrk][i]<0) continue;
1915  AnaDetCrossingB* cross = new AnaDetCrossingB();
1916  convUtils::ConvertTrueParticleDetEnumToBitField(cross->Detector, sTrueParticleDetector[itrk][i]);
1917 
1918  cross->InActive = (bool) sTrueParticleInActive[itrk][i];
1919 
1920  anaUtils::CopyArray(sTrueParticleEntrancePosition[itrk][i], cross->EntrancePosition, 4);
1921  anaUtils::CopyArray(sTrueParticleExitPosition[itrk][i], cross->ExitPosition, 4);
1922 
1923  particle->DetCrossings[particle->nDetCrossings] = cross;
1924  particle->nDetCrossings++;
1925  }
1926 
1927  particle->TrueVertex = NULL;
1928  particle->VertexID = (sTrueParticleTruthVertexID)[itrk];
1929  for(int i = 0; i < event->nTrueVertices; ++i){
1930  if(particle->VertexID == event->TrueVertices[i]->ID){
1931  // Associate the vertex to this track
1932  particle->TrueVertex = event->TrueVertices[i];
1933  // add this track to the list of true tracks in the true vertex
1934  if((UInt_t)particle->TrueVertex->nTrueParticles >=NMAXTRUEPARTICLES) break;
1935  particle->TrueVertex->TrueParticles[particle->TrueVertex->nTrueParticles] = particle;
1936  particle->TrueVertex->nTrueParticles++;
1937  break;
1938  }
1939  }
1940 }
1941 
1942 //*****************************************************************************
1943 void RedoTreeConverter::FillTrueVertexInfo(int ivtx, AnaTrueVertexB* vertex){
1944  //*****************************************************************************
1945 
1946  vertex->ID = sTrueVertexID[ivtx];
1947  vertex->NuPDG = sTrueVertexNuPDG[ivtx];
1948  vertex->NuEnergy = sTrueVertexNuEnergy[ivtx];
1949 
1950  anaUtils::CopyArray(sTrueVertexPosition[ivtx], vertex->Position, 4);
1951 
1952  vertex->Bunch = sTrueVertexBunch[ivtx];
1953 
1954  // will be updated in FillTrueParticleInfo
1955  anaUtils::CreateArray(vertex->TrueParticles, sNTrueParticles);
1956  vertex->nTrueParticles = 0;
1957 }
1958 
1959 //*****************************************************************************
1960 void RedoTreeConverter::FindTrueParticle(std::vector<AnaTrueParticleB*>& trueParticles, int ID, AnaTrueObjectC*& trueTrack){
1961  //*****************************************************************************
1962 
1963  // Compare the IDs to find the AnaTrueObjectC associated with this recon particle.
1964  trueTrack = NULL;
1965 
1966  if (ID==-999) return; // there's no true track association
1967 
1968  for (UInt_t it = 0; it < trueParticles.size(); it++){
1969  AnaTrueObjectC* trueTrack2 = trueParticles[it];
1970  if (ID == trueTrack2->ID){
1971  trueTrack = trueTrack2;
1972  break; // Stop when association is found.
1973  }
1974  }
1975 }
1976 
1977 //*****************************************************************************
1978 void RedoTreeConverter::FindTrueParticle(AnaEventB* event, int ID, AnaTrueObjectC*& trueTrack){
1979  //*****************************************************************************
1980 
1981  // Compare the IDs to find the AnaTrueObjectC associated with this recon particle.
1982  trueTrack = NULL;
1983  if (ID==-999) return; // there's no true track association
1984 
1985  for (int it = 0; it < event->nTrueParticles; it++){
1986  AnaTrueObjectC* trueTrack2 = event->TrueParticles[it];
1987  if (ID == trueTrack2->ID){
1988  trueTrack = trueTrack2;
1989  break; // Stop when association is found.
1990  }
1991  }
1992 }
1993 
1994 //*****************************************************************************
1995 void RedoTreeConverter::FillVertexInfo(int ivtx, AnaVertexB* vertex, AnaEventB* event){
1996  //*****************************************************************************
1997 
1998  vertex->PrimaryIndex = (vPrimaryIndex)[ivtx];
1999  anaUtils::CopyArray(vPosition[ivtx], vertex->Position, 4);
2000 
2001  // Find AnaParticleB associated with this global vertex
2002  for (int d = 0; d < vNReconParticles[ivtx]; d++) {
2003  AnaParticleB* matchedParticle = FindParticle(vParticlesUniqueID[ivtx][d], event);
2004  if ( ! matchedParticle) continue;
2005 
2006  // fill only if in this bunch, should be already sorted in flat tree, then null pointers will be added at the end
2007  // if (matchedParticle->Bunch != Bunch) continue;
2008  // vertex->Particles.push_back(matchedParticle);
2009 
2010  // Save vertices info in AnaParticleB
2011  // matchedParticle->ReconVertices.push_back(vertex);
2012 
2013  // choose the vertex more primary (in this bunch)
2014  // if ( ! matchedParticle->Vertex || matchedParticle->Vertex->PrimaryIndex > vertex->PrimaryIndex)
2015  // matchedParticle->Vertex = vertex;
2016  }
2017 
2018  // Find true vertices associated with this global vertex (by index)
2019  for (int d = 0; d < vNTrueVerticesMatch[ivtx]; d++) {
2020  std::pair<AnaTrueVertexB*, AnaRecTrueMatchB> myMatch;
2021  int thisTrueVertexIndex = vTrueVertexIndex[ivtx][d];
2022  if (thisTrueVertexIndex == -1) continue;
2023  if (thisTrueVertexIndex < -1 || thisTrueVertexIndex >= event->nTrueVertices)
2024  std::cout << "minor error 6789" << std::endl;
2025 
2026  myMatch.first = event->TrueVertices[thisTrueVertexIndex];
2027  myMatch.second.Cleanliness = (vTrueVerticesClean)[ivtx][d];
2028  myMatch.second.Completeness = (vTrueVerticesCompl)[ivtx][d];
2029  vertex->TrueVerticesMatch.push_back(myMatch);
2030  }
2031 
2032  // Let's keep also vertex->TrueVertex by now (the user could just called GetMainTrueVertex instead)
2033  vertex->TrueVertex = vertex->GetMainTrueVertex(false); // vertex->GetMainTrueVertex() could replace this info
2034 }
2035 
2036 
2037 //*****************************************************************************
2038 void RedoTreeConverter::FillVertexInfo(int ivtx, AnaVertexB* vertex, AnaBunchB* bunch){
2039  //*****************************************************************************
2040 
2041  vertex->PrimaryIndex = (vPrimaryIndex)[ivtx];
2042  vertex->Bunch = (vBunch)[ivtx];
2043  anaUtils::CopyArray(vPosition[ivtx], vertex->Position, 4);
2044 
2045  // Find AnaParticleB associated with this global vertex
2046  for (int d = 0; d < vNReconParticles[ivtx]; d++) {
2047  AnaParticleB* matchedParticle = FindParticle(vParticlesUniqueID[ivtx][d], bunch);
2048  if ( ! matchedParticle) continue;
2049 
2050  // fill only if in this bunch, should be already sorted in flat tree, then null pointers will be added at the end
2051  // if (matchedParticle->Bunch != Bunch) continue;
2052  // vertex->Particles.push_back(matchedParticle);
2053 
2054  // Save vertices info in AnaParticleB
2055  // matchedParticle->ReconVertices.push_back(vertex);
2056 
2057  // choose the vertex more primary (in this bunch)
2058  // if ( ! matchedParticle->Vertex || matchedParticle->Vertex->PrimaryIndex > vertex->PrimaryIndex)
2059  // matchedParticle->Vertex = vertex;
2060  }
2061 
2062  // Find true vertices associated with this global vertex (by index)
2063  for (int d = 0; d < vNTrueVerticesMatch[ivtx]; d++) {
2064  std::pair<AnaTrueVertexB*, AnaRecTrueMatchB> myMatch;
2065  int thisTrueVertexIndex = vTrueVertexIndex[ivtx][d];
2066  if (thisTrueVertexIndex == -1) continue;
2067  if (thisTrueVertexIndex < -1 || thisTrueVertexIndex >= (int)_spill->TrueVertices.size())
2068  std::cout << "minor error 6789" << std::endl;
2069 
2070  myMatch.first = _spill->TrueVertices[thisTrueVertexIndex];
2071  myMatch.second.Cleanliness = (vTrueVerticesClean)[ivtx][d];
2072  myMatch.second.Completeness = (vTrueVerticesCompl)[ivtx][d];
2073  vertex->TrueVerticesMatch.push_back(myMatch);
2074  }
2075 
2076  // Let's keep also vertex->TrueVertex, by now
2077  vertex->TrueVertex = vertex->GetMainTrueVertex(); // vertex->GetMainTrueVertex() could replace this info
2078 }
2079 
2080 //*****************************************************************************
2081 AnaParticleB* RedoTreeConverter::FindParticle(int ID, AnaEventB* event){
2082  //*****************************************************************************
2083 
2084  // Compare the UniqueID to find the corresponding AnaParticleB
2085  // AnaParticleB already exists because it is saved for first
2086  // Look first in the same event bunch as the vertex
2087  for (int ittrack = 0; ittrack < event->nParticles; ittrack++) {
2088 
2089  if (ID == event->Particles[ittrack]->UniqueID) return event->Particles[ittrack];
2090  }
2091 
2092  //We are not using out of bunch tracks in the BANFF fit, so cannot do these checks.
2093 
2094  // // If not found, look into OutOfBunch (saved for first in the Flat Tree, if parameters enabled)
2095  // if (_spill->OutOfBunch) {
2096  // for (ittrack = _spill->OutOfBunch->Particles.begin(); ittrack != _spill->OutOfBunch->Particles.end(); ittrack++) {
2097  // if (ID == (*ittrack)->UniqueID) return *ittrack;
2098  // }
2099  // }
2100 
2101  if (event->Bunch != -1) //&& _spill->OutOfBunch->Bunch != -999)
2102  if ( ! suppress_err_msg) std::cout << "minor error 0999" << std::endl;
2103 
2104  return NULL;
2105 }
2106 
2107 //*****************************************************************************
2108 AnaParticleB* RedoTreeConverter::FindParticle(int ID, AnaBunchB* bunch){
2109  //*****************************************************************************
2110 
2111  // Compare the UniqueID to find the corresponding AnaParticleB
2112  // AnaParticleB already exists because it is saved for first
2113  std::vector<AnaParticleB*>::iterator ittrack;
2114 
2115  // Look first in the same bunch of the vertex
2116  for (ittrack = bunch->Particles.begin(); ittrack != bunch->Particles.end(); ittrack++) {
2117  if (ID == (*ittrack)->UniqueID) return *ittrack;
2118  }
2119 
2120  // If not found, look into OutOfBunch (saved for first in the Flat Tree, if parameters enabled)
2121  if (_spill->OutOfBunch) {
2122  for (ittrack = _spill->OutOfBunch->Particles.begin(); ittrack != _spill->OutOfBunch->Particles.end(); ittrack++) {
2123  if (ID == (*ittrack)->UniqueID) return *ittrack;
2124  }
2125  }
2126 
2127  if (bunch->Bunch != -1 && _spill->OutOfBunch->Bunch != -999)
2128  if ( ! suppress_err_msg) std::cout << "minor error 0999" << std::endl;
2129 
2130  return NULL;
2131 }
2132 
2133 
Float_t dEdxexpMuon
Expected dE/dx for a muon, based on the reconstructed momentum.
bool InActive
If the particle passes through an active part of the subdetector.
AnaTrueVertexB * TrueVertex
Pointer to the AnaTrueVertexB of the interaction that created this AnaTrueParticleB.
Float_t PositionStart[4]
The reconstructed start position of the particle.
Representation of the beam quality and perhaps other beam information as needed.
AnaTrueVertexB * TrueVertex
Representation of the ND280 data quality flags.
unsigned long Detector
Int_t NuPDG
The PDG code of the incoming neutrino.
unsigned long Detector
int nDetCrossings
The number of DetCrossing objects.
int nTrueParticles
How many true particles are associated with this vertex.
Float_t ExitPosition[4]
for each subdetector tell the exit position
AnaFgdTimeBinB ** FgdTimeBins
The FGD time bins.
static bool IsFGDDetector(SubDetId::SubDetEnum det)
Check if a detector enumeration refers to a FGD or not.
Definition: SubDetId.cxx:126
Int_t GetEvent(Long64_t &entry, AnaEventC *&event)
Float_t dEdxexpProton
Expected dE/dx for a proton, based on the reconstructed momentum.
AnaECALParticleB * ECALSegments[NMAXECALS]
The ECAL segments that contributed to this global track.
int nECALSegments
How many ECAL tracks are associated with this track.
std::vector< std::pair< AnaTrueVertexB *, AnaRecTrueMatchB > > TrueVerticesMatch
The true vertices that are associated with this global vertex, with the related cleanliness and compl...
int _nentries
The number of entries in the chain. To be set by the implementation.
void SetIsSandMC()
Set whether this event is from Sand MC.
Float_t Pullp
Proton pull, according to FGD information.
void ConvertTPCDetEnumToBitField(unsigned long &det, int tpc)
Convert the detector used array to the bit field used by psyche for TPC track segments.
AnaVertexB ** Vertices
The reconstructed objects in this bunch.
Representation of a true Monte Carlo vertex.
Float_t DirectionEnd[3]
The reconstructed end direction of the particle.
Float_t Position[4]
The identified position of the global vertex.
std::vector< AnaTrueVertexB * > TrueVertices
The true MC vertices used in this spill.
std::vector< AnaBunchC * > Bunches
The reconstructed objects, split into timing bunches.
AnaBeamB * Beam
The beam quality flags for this event.
Float_t Pullno
Dummy pull. If the FGD pulls weren&#39;t set, this is set to 1.
Int_t NNodes
The number of nodes in the reconstructed object.
std::string _treeName
The name of the tree to convert.
Int_t GParentPDG
The PDG code of this particle&#39;s grandparent, or 0 if there is no grandparent.
Representation of an ECAL segment of a global track.
Float_t Pullpi
Pion pull, according to FGD information.
AnaTPCParticleB * TPCSegments[NMAXTPCS]
The TPC segments that contributed to this global track.
Float_t dEdxSigmaProton
Expected error on the dE/dx measurement, for the proton hypothesis.
AnaTrueObjectC * TrueObject
The link to the true oject that most likely generated this reconstructed object.
AnaToF ToF
Times of flight between pairs of detectors.
AnaEventInfoB * EventInfo
Run, sunrun, event, time stamp, etc.
static bool GetDetectorUsed(unsigned long BitField, SubDetId::SubDetEnum det)
Method to see if a certain subdetector or subdetector system is used.
Definition: SubDetId.cxx:40
virtual bool Initialize()
Float_t Momentum
The initial momentum of the true particle.
AnaParticleB ** Particles
The reconstructed objects in this bunch.
AnaTrueParticleB ** TrueParticles
The true particles associated with this vertex.
AnaBunchB * OutOfBunch
Reconstructed objects that didn&#39;t fit into one of the timing bunches.
Int_t Bunch
The bunch of the global vertex, based on the Position.T()
Long64_t GetEntries()
Return the total number of entries in the chain.
Float_t RangeMomentumMuon
Momentum by range calculated with muon hypothesis.
void AddChain(const std::string &name, const std::string &name_path="")
Float_t dEdxexpPion
Expected dE/dx for a pion, based on the reconstructed momentum.
Int_t VertexID
The TruthVertexID of the AnaTrueVertexB of the interaction that created this AnaTrueParticleB.
Int_t UniqueID
The UniqueID of this reconstructed object.
Float_t dEdxexpEle
Expected dE/dx for an electron, based on the reconstructed momentum.
Float_t Pullmu
Muon pull, according to FGD information.
Float_t Charge
The reconstructed charge of the particle.
Int_t ID
The ID of the trueObj, which corresponds to the ID of the TTruthParticle that created it...
std::vector< AnaVertexB * > Vertices
Int_t fCurrent
current Tree number in a TChain
Float_t MomentumError
Error of the momentum at the start of the segment.
Float_t MomentumFlip
Momentum for the main PID hypothesis and reverse sense.
Float_t ShowerPosition[3]
The position of the shower-fit to this object by ecalRecon.
static void SetDetectorUsed(unsigned long &BitField, SubDetId::SubDetEnum det)
Method to set a certain subdetector or subdetector system to used used.
Definition: SubDetId.cxx:36
Float_t Momentum
The reconstructed momentum of the particle, at the start position.
Int_t Index
The index of this particle track in the vector of particles. TODO: Not sure it is needed (only use in...
int nTPCSegments
How many TPC tracks are associated with this track.
Representation of a true Monte Carlo trajectory/particle.
Float_t NuEnergy
The true energy of the incoming neutrino.
Representation of an SMRD segment of a global track.
TChain * GetChain(const std::string &name="")
Float_t Position[4]
The position the true interaction happened at.
Float_t dEdxSigmaEle
Expected error on the dE/dx measurement, for the electron hypothesis.
void ConvertECALDetEnumToBitField(unsigned long &det, int ecal)
Convert the detector used array to the bit field used by psyche for ECAL track segments.
Float_t EntrancePosition[4]
for each subdetector tell the entrance position
AnaBeamB * Beam
The beam quality flags for this spill.
static bool IsTPCDetector(SubDetId::SubDetEnum det)
Check if a detector enumeration refers to a TPC or not.
Definition: SubDetId.cxx:122
AnaDetCrossingB ** DetCrossings
static bool IsECALDetector(SubDetId::SubDetEnum det)
Check if a detector enumeration refers to a ECAL or not.
Definition: SubDetId.cxx:130
Representation of a detector crossing info for a true particle (G4 trajectory).
SubDetEnum
Enumeration of all detector systems and subdetectors.
Definition: SubDetId.hxx:25
Float_t EFieldRefitMomentum
Reconstructed momentum with the E-field distortion corrections.
Int_t PDG
The PDG code of this particle.
Int_t NHits
The number of hits in the particle.
void ConvertSMRDDetEnumToBitField(unsigned long &det, int smrd)
Convert the detector used array to the bit field used by psyche for SMRD track segments.
Int_t ParentPDG
The PDG code of this particle&#39;s immediate parent, or 0 if there is no parent.
void ConvertFGDDetEnumToBitField(unsigned long &det, int fgd)
Convert the detector used array to the bit field used by psyche for FGD track segments.
std::vector< AnaFgdTimeBinB * > FgdTimeBins
The FGD time bins.
Float_t dEdxMeas
dE/dx as measured by the TPC.
Representation of a global track.
Int_t Bunch
The index of this bunch (0-7).
AnaTrueVertexB * GetMainTrueVertex(bool warning=true)
The main true vertex that is associated with this global vertex.
Representation of a TPC segment of a global track.
Float_t Weight
The weight to apply to this bunch (nominally 1). An example is the beam flux weight.
int GetLocalDetEnum(SubDetId::SubDetEnum det, SubDetId::SubDetEnum idet)
Get old local detector enumeration to find array index of Flat tree.
UInt_t NTotalTrueVertices
std::vector< AnaTrueParticleB * > TrueParticles
The true MC particles used in this spill.
Representation of a global vertex.
Float_t Length
The length of the ECal segment.
virtual void DefineBranches()
Define the branches to be read from the input tree.
Float_t DirectionStart[3]
The reconstructed start direction of the particle.
Representation of a FGD segment of a global track.
void ConvertTrueParticleDetEnumToBitField(unsigned long &det, int DetUsed)
Convert the detector used array to the bit field used by psyche for truth trueParts.
Int_t Bunch
The index of this bunch (0-7).
Int_t PrimaryIndex
Index of the global vertex.
Int_t GoodSpill
Good spill flag, as defined in Beam Summary Data. 0 is bad.
Int_t Event
The ND280 event number.
int nFGDSegments
How many FGD tracks are associated with this track.
AnaTrueParticleB ** TrueParticles
The true MC particles used in this spill.
Float_t dEdxSigmaMuon
Expected error on the dE/dx measurement, for the muon hypothesis.
bool AddHeader(const std::string &file, bool bySpillPOT=false)
Read the "header" tree from the given file and increment the existing POT counting.
Definition: Header.cxx:132
Int_t ParentID
The ID of this particle&#39;s immediate parent, or 0 if there is no parent.
Float_t PositionEnd[4]
The end position of the true particle.
Float_t Position[4]
The initial position of the true particle.
Int_t Containment
Containment flag required for proper PID analysis.
AnaTrueVertexB ** TrueVertices
The true MC vertices used in this spill.
std::vector< AnaParticleB * > Particles
Int_t MostUpStreamLayerHit
Innermost layer hit of the ecal object (used in ecal pi0 veto)
void ConvertTrackDetEnumToBitField(unsigned long &det, int DetUsed[])
Convert the detector used array to the bit field used by psyche for ana tracks.
Header & header()
Returns the Header manager.
TChain * fChain
The main TChain used to read events from the input file.
Representation of a P0D segment of a global track.
Float_t dEdxSigmaPion
Expected error on the dE/dx measurement, for the pion hypothesis.
Float_t Charge
The true charge of the particle.
Int_t GetSpill(Long64_t &entry, AnaSpillC *&spill)
AnaDataQualityB * DataQuality
The ND280 data quality flags for this event.
Representation of a reconstructed particle (track or shower).
AnaDataQualityB * DataQuality
The ND280 data quality flags for this spill.
bool IsMC
Says if the event is MC or data.
Float_t Direction[3]
The initial direction of the true particle.
UInt_t NTotalTrueParticles
AnaFGDParticleB * FGDSegments[NMAXFGDS]
The FGD segments that contributed to this global track.
virtual bool AddFileToTChain(const std::string &inputString)
Add the file specified to fChain, and any friend chains that were set up.
Float_t PositionEnd[4]
The reconstructed end position of the particle.
Float_t RefitMomentum
Reconstructed momentum with the empirical distortion corrections.
Int_t Run
The ND280 run number.