HighLAND
FlatTreeConverter.cxx
1 #include "FlatTreeConverter.hxx"
2 #include "BasicUtils.hxx"
3 #include "TreeConverterUtils.hxx"
4 #include "HighlandTreeConverterUtils.hxx"
5 #include "HighlandAnalysisUtils.hxx"
6 #include "Parameters.hxx"
7 
8 // set true for avoiding error messages that might appear when using old flat trees
9 bool suppress_err_msg = true;
10 
11 //********************************************************************
13 //********************************************************************
14 
15  // If true the RooTrackerVtx tree will be read
16  _readRooTrackerVtx = readRooTrackerVtx;
17 
18  _currentFileIndex=-1;
19  _RooVtxEntryInCurrentInputFile=0;
20  _entry_roo=0;
21 
22  _firstFile=true;
23  _firstEntry=true;
24 
25  // Initialise all the variables. This is particularly important as some
26  // branches many not exist in the flat tree.
27  sBeamPOT = 0;
28  sBeamPOTCT4 = 0;
29  sBeamSpill = 0;
30  sBeamSpillNumber = 0;
31  sBeamBeamRunNumber = 0;
32 
33  sDQND280Flag = 0;
34  for(int i = 0; i < 7; i++) sDQDetFlag[i] = 0;
35 
36  sNTrueVertices = 0;
37  for (unsigned int i = 0; i < NMAXTRUEVERTICES; i++) {
38  sTrueVertexNReconTracks[i] = 0;
39  sTrueVertexNReconVertices[i] = 0;
40  sTrueVertexBunch[i] = 0;
41  sTrueVertexLeptonPDG[i] = 0;
42  sTrueVertexQ2[i] = 0;
43  sTrueVertexTargetMom[i] = 0;
44  sTrueVertexLeptonMom[i] = 0;
45  sTrueVertexProtonMom[i] = 0;
46  sTrueVertexPionMom[i] = 0;
47  sTrueVertexIsPauliBlocked[i] = 0;
48  sTrueVertexIsCohOnH[i] = 0;
49 
50  for (unsigned int j = 0; j < 3; j++) {
51  sTrueVertexTargetDir[i][j] = 0;
52  sTrueVertexLeptonDir[i][j] = 0;
53  sTrueVertexProtonDir[i][j] = 0;
54  sTrueVertexPionDir[i][j] = 0;
55  }
56 
57  for (int j = 0; j < Int_t(ParticleId::kLast)+1; j++) {
58  sTrueVertexNPrimaryParticles[i][j]=0;
59  }
60 
61  }
62 
63  for (unsigned int i = 0; i < NMAXPARTICLES; i++) {
64  trReconPDG[i] = 0;
65  trNTRACKERs[i] = 0;
66  trLength[i] = 0;
67  trRangeMomentumMuonFlip[i] = 0;
68  trRangeMomentumProtonFlip[i] = 0;
69  trTrueParticleID[i] = 0;
70 
71  trNTimeNodes[i] = 0;
72  for (unsigned int j = 0; j < NMAXTIMENODES; j++) {
73  trTimeNodeDetector[i][j] = 0;
74  trTimeNodeTimeStart[i][j] = 0;
75  trTimeNodeTimeEnd[i][j] = 0;
76  }
77 
78  for (int j = 0; j < 3; j++) {
79  trDirectionAtVertex[i][j] = 0;
80  trDirectionStartFlip[i][j] = 0; //!
81  trDirectionEndFlip[i][j] = 0; //!
82  }
83 
84  for (int j = 0; j < 3; j++) {
85  trTpcUniqueID[i][j] = 0;
86  trTpcLength[i][j] = 0;
87  trTpcPullmu[i][j] = 0;
88  trTpcPullele[i][j] = 0;
89  trTpcPullp[i][j] = 0;
90  trTpcPullpi[i][j] = 0;
91  trTpcPullk[i][j] = 0;
92  trTpcRawdEdxMeas[i][j] = 0;
93  trTpcRawdEdxExpMu[i][j] = 0;
94  trTpcRawdEdxExpEle[i][j] = 0;
95  trTpcRawdEdxExpP[i][j] = 0;
96  trTpcRawdEdxExpPi[i][j] = 0;
97  trTpcRawdEdxExpK[i][j] = 0;
98  }
99 
100  for (int j = 0; j < 2; j++) {
101  trFgdUniqueID[i][j] = 0;
102 
103  trFgdHasFgdVA[i][j] = 0;
104  trFgdHasFgdVA_fmode[i][j] = 0;
105  trFgdTypeVA[i][j] = 0;
106 
107  trFgdHasFgdEA[i][j] = 0;
108  trFgdHasFgdEA_fmode[i][j] = 0;
109  trFgdTypeEA[i][j] = 0;
110  trFgdEnd0x0[i][j] = 0;
111  trFgdEnd1x1[i][j] = 0;
112  trFgdEnd3x3[i][j] = 0;
113  trFgdEnd5x5[i][j] = 0;
114  trFgdEnd7x7[i][j] = 0;
115  }
116 
117  for (int j = 0; j < (int)NECALSUBDETS; j++) {
118  trECALUniqueID[i][j] = 0;
119  trECALPIDMipPion[i][j] = 0;
120  trECALContainment[i][j] = 0;
121  }
122 
123  for (int j = 0; j < (int)NSMRDSUBDETS; j++) {
124  trSMRDUniqueID[i][j] = 0;
125  trSMRDEDeposit[i][j] = 0;
126  }
127 
128  for (int j = 0; j < 1; j++) {
129  trP0DUniqueID[i][j] = 0;
130  }
131 
132  for (int j = 0; j < (int)NMAXTRACKERS; j++) {
133  trTRACKERDetector[i][j] = 0;
134  trTRACKERNHits[i][j] = 0;
135  trTRACKERNNodes[i][j] = 0;
136  trTRACKERUniqueID[i][j] = 0;
137  trTRACKERLength[i][j] = 0;
138  trTRACKERCharge[i][j] = 0;
139  trTRACKERMomentum[i][j] = 0;
140  trTRACKERMomentumEnd[i][j] = 0;
141 
142  for (int k = 0; k < 3; k++) {
143  trTRACKERDirectionStart[i][j][k] = 0;
144  trTRACKERDirectionEnd[i][j][k] = 0;
145  }
146 
147  for (int k = 0; k < 4; k++) {
148  trTRACKERPositionStart[i][j][k] = 0;
149  trTRACKERPositionEnd[i][j][k] = 0;
150  }
151  }
152  }
153 
154  /// AnaLocalReconBunch information
155  tecalReconCounter = 0;
156  for (unsigned int i=0; i<NMAXTECALRECONOBJECTS; i++){
157  tecalReconAverageHitTime [i] = 0;
158  tecalReconAverageZPosition [i] = 0;
159  tecalReconContainment [i] = 0;
160  tecalReconEFitResult [i] = 0;
161  tecalReconEFitUncertainty [i] = 0;
162  tecalReconFirstLayer [i] = 0;
163  tecalReconIsShowerLike [i] = 0;
164  tecalReconIsTrackLike [i] = 0;
165  tecalReconLastLayer [i] = 0;
166  tecalReconLikeMIPEM [i] = 0;
167  tecalReconLikeMIPPion [i] = 0;
168  tecalReconLikeEMHIP [i] = 0;
169  tecalReconLikeMIPEMLow [i] = 0;
170  tecalReconMatchingLike [i] = 0;
171  tecalReconMichelTagNDelayedCluster[i] = 0;
172  tecalReconModule [i] = 0;
173  tecalReconMostDownStreamLayerHit [i] = 0;
174  tecalReconMostUpStreamLayerHit [i] = 0;
175  tecalReconNHits [i] = 0;
176  tecalReconNLayersHit [i] = 0;
177  tecalReconObjectLength [i] = 0;
178  tecalReconPIDAMR [i] = 0;
179  tecalReconPIDAngle [i] = 0;
180  tecalReconPIDAsymmetry [i] = 0;
181  tecalReconPIDCircularity [i] = 0;
182  tecalReconPIDFBR [i] = 0;
183  tecalReconPIDMaxRatio [i] = 0;
184  tecalReconPIDMeanPos [i] = 0;
185  tecalReconPIDShowerAngle [i] = 0;
186  tecalReconPIDShowerWidth [i] = 0;
187  tecalReconPIDTransverseChargeRatio[i] = 0;
188  tecalReconPIDTruncatedMaxRatio [i] = 0;
189  tecalReconThrust [i] = 0;
190  tecalReconTimeBunch [i] = 0;
191  tecalReconTotalHitCharge [i] = 0;
192  tecalReconTrueID [i] = 0;
193  tecalReconTrueIDPrimary [i] = 0;
194  tecalReconTrueIDRecursive [i] = 0;
195  tecalReconTrueIDSingle [i] = 0;
196  tecalReconUniqueID [i] = 0;
197  tecalReconBunch [i] = 0;
198 
199  for (int j=0; j<3; j++){
200  tecalReconPointing [i][j] = 0;
201  tecalReconThrustAxis [i][j] = 0;
202  tecalReconThrustOrigin [i][j] = 0;
203 
204  }
205  }
206 
207 
208  // Initialise all the branches. This is particularly important as some
209  // branches many not exist in the flat tree.
210  b_sIsMC = NULL;
211  b_sBeamPOT = NULL;
212  b_sBeamPOTCT4 = NULL;
213  b_sBeamSpill = NULL;
214  b_sBeamSpillNumber = NULL;
215  b_sBeamBeamRunNumber = NULL;
216  b_sDQND280Flag = NULL;
217  b_sDQDetFlag = NULL;
218 
219 
220  b_sTrueVertexLeptonPDG = NULL;
221  b_sTrueVertexLeptonDir = NULL;
222  b_sTrueVertexProtonDir = NULL;
223  b_sTrueVertexPionDir = NULL;
224  b_sTrueVertexLeptonMom = NULL;
225  b_sTrueVertexProtonMom = NULL;
226  b_sTrueVertexPionMom = NULL;
227  b_sTrueVertexIsPauliBlocked = NULL;
228  b_sTrueVertexIsCohOnH = NULL;
229  b_sTrueVertexNPrimaryParticles = NULL;
230  b_sTrueVertexPionMom = NULL;
231  b_sTrueVertexTargetDir = NULL;
232  b_sTrueVertexTargetMom = NULL;
233 
234  b_trReconPDG = NULL;
235  b_trDirectionAtVertex = NULL;
236 
237  b_trNTRACKERs = NULL;
238 
239  b_trTpcPullmu = NULL;
240  b_trTpcPullele = NULL;
241  b_trTpcPullp = NULL;
242  b_trTpcPullpi = NULL;
243  b_trTpcPullk = NULL;
244  b_trNTimeNodes = NULL;
245  b_trTimeNodeDetector = NULL;
246  b_trTimeNodeTimeStart = NULL;
247  b_trTimeNodeTimeEnd = NULL;
248 
249  b_trTpcUniqueID = NULL;
250  b_trFgdUniqueID = NULL;
251  b_trECALUniqueID = NULL;
252  b_trSMRDUniqueID = NULL;
253  b_trP0DUniqueID = NULL;
254 
255  b_trTpcRawdEdxMeas = NULL;
256  b_trTpcRawdEdxExpMu = NULL;
257  b_trTpcRawdEdxExpEle = NULL;
258  b_trTpcRawdEdxExpP = NULL;
259  b_trTpcRawdEdxExpPi = NULL;
260  b_trTpcRawdEdxExpK = NULL;
261 
262  b_trFgdHasFgdVA = NULL;
263  b_trFgdHasFgdVA_fmode = NULL;
264  b_trFgdTypeVA = NULL;
265  b_trFgdHasFgdEA = NULL;
266  b_trFgdHasFgdEA_fmode = NULL;
267  b_trFgdTypeEA = NULL;
268  b_trFgdEnd0x0 = NULL;
269  b_trFgdEnd1x1 = NULL;
270  b_trFgdEnd3x3 = NULL;
271  b_trFgdEnd5x5 = NULL;
272  b_trFgdEnd7x7 = NULL;
273 
274  b_trP0DAvgTime = NULL;
275 
276  b_trTRACKERDetector = NULL;
277  b_trTRACKERNHits = NULL;
278  b_trTRACKERNNodes = NULL;
279  b_trTRACKERUniqueID = NULL;
280  b_trTRACKERLength = NULL;
281  b_trTRACKERDirectionStart = NULL;
282  b_trTRACKERDirectionEnd = NULL;
283  b_trTRACKERPositionStart = NULL;
284  b_trTRACKERPositionEnd = NULL;
285  b_trTRACKERCharge = NULL;
286  b_trTRACKERMomentum = NULL;
287  b_trTRACKERMomentumEnd = NULL;
288 
289  b_trDirectionStartFlip = NULL;
290  b_trDirectionEndFlip = NULL;
291  b_trRangeMomentumMuonFlip = NULL;
292  b_trRangeMomentumProtonFlip = NULL;
293  b_trMomentumAtVertex = NULL;
294  b_trLength = NULL;
295 
296  b_trECALPIDMipPion = NULL;
297  b_trECALContainment = NULL;
298 
299  // SMRD
300  b_trSMRDEDeposit = NULL;
301 
302  b_tecalReconCounter = NULL;
303  b_tecalReconAverageHitTime = NULL;
304  b_tecalReconAverageZPosition = NULL;
305  b_tecalReconContainment = NULL;
306  b_tecalReconEFitResult = NULL;
307  b_tecalReconEFitUncertainty = NULL;
308  b_tecalReconFirstLayer = NULL;
309  b_tecalReconIsShowerLike = NULL;
310  b_tecalReconIsTrackLike = NULL;
311  b_tecalReconLastLayer = NULL;
312  b_tecalReconLikeMIPEM = NULL;
313  b_tecalReconLikeMIPPion = NULL;
314  b_tecalReconLikeEMHIP = NULL;
315  b_tecalReconLikeMIPEMLow = NULL;
316  b_tecalReconMatchingLike = NULL;
317  b_tecalReconMichelTagNDelayedCluster = NULL;
318  b_tecalReconModule = NULL;
319  b_tecalReconMostDownStreamLayerHit = NULL;
320  b_tecalReconMostUpStreamLayerHit = NULL;
321  b_tecalReconNHits = NULL;
322  b_tecalReconNLayersHit = NULL;
323  b_tecalReconObjectLength = NULL;
324  b_tecalReconPIDAMR = NULL;
325  b_tecalReconPIDAngle = NULL;
326  b_tecalReconPIDAsymmetry = NULL;
327  b_tecalReconPIDCircularity = NULL;
328  b_tecalReconPIDFBR = NULL;
329  b_tecalReconPIDMaxRatio = NULL;
330  b_tecalReconPIDMeanPos = NULL;
331  b_tecalReconPIDShowerAngle = NULL;
332  b_tecalReconPIDShowerWidth = NULL;
333  b_tecalReconPIDTransverseChargeRatio = NULL;
334  b_tecalReconPIDTruncatedMaxRatio = NULL;
335  b_tecalReconPointing = NULL;
336  b_tecalReconThrust = NULL;
337  b_tecalReconThrustAxis = NULL;
338  b_tecalReconThrustOrigin = NULL;
339  b_tecalReconTimeBunch = NULL;
340  b_tecalReconTotalHitCharge = NULL;
341  b_tecalReconTrueID = NULL;
342  b_tecalReconTrueIDPrimary = NULL;
343  b_tecalReconTrueIDRecursive = NULL;
344  b_tecalReconTrueIDSingle = NULL;
345  b_tecalReconUniqueID = NULL;
346  b_tecalReconBunch = NULL;
347 
348  RunID=-1;
349  SubrunID=-1;
350  EventID=-1;
351 
352 }
353 
354 //********************************************************************
356 //********************************************************************
357 
358  // Use corrected values or raw values
359  _useCorrectedValues = ND::params().GetParameterI("highlandIO.ReadFlatTree.UseCorrectedValues");
360 
361  /// Is AnaLocalReconBunch information enabled in the parameters file?
362  _isUsingReconDirFGDOnly = ND::params().GetParameterI("highlandIO.FlatTree.UseReconDirFGDOnly" );
363  _isUsingReconDirP0D = ND::params().GetParameterI("highlandIO.FlatTree.UseReconDirP0D" );
364  _isUsingReconDirPECAL = ND::params().GetParameterI("highlandIO.FlatTree.UseReconDirP0DECal" );
365  _isUsingReconDirTECAL = ND::params().GetParameterI("highlandIO.FlatTree.UseReconDirTrackerECal");
366 
367 
369 }
370 
371 //********************************************************************
373 //********************************************************************
374 
376 
377  // The branches commented below are not read becouse they are not currently needed by any analysis.
378  // This is equivalent to setting their status to 0, as it was done in the previous version
379 
380 
381  anaUtils::ConfigureTreeBranch(fChain, "sIsMC", &sIsMC, &b_sIsMC);
382  anaUtils::ConfigureTreeBranch(fChain, "sEventTime", &sEventTime, &b_sEventTime);
383  anaUtils::ConfigureTreeBranch(fChain, "sNTotalTrueTracks", &sNTotalTrueParticles, &b_sNTotalTrueParticles);
384  anaUtils::ConfigureTreeBranch(fChain, "sNTotalTrueVertices", &sNTotalTrueVertices, &b_sNTotalTrueVertices);
385 
386  anaUtils::ConfigureTreeBranch(fChain, "sInputFileIndex", &sInputFileIndex, &b_sInputFileIndex);
387  anaUtils::ConfigureTreeBranch(fChain, "sRooVtxEntry", &sRooVtxEntry, &b_sRooVtxEntry);
388 
389  // anaUtils::ConfigureTreeBranch(fChain, "sPOTSincePreviousSpill", &sPOTSincePreviousSpill, &b_sPOTSincePreviousSpill);
390  anaUtils::ConfigureTreeBranch(fChain, "sBeamPOT", &sBeamPOT, &b_sBeamPOT);
391 #if !VERSION_HAS_OFFICIAL_POT
392  anaUtils::ConfigureTreeBranch(fChain, "sBeamPOTCT4", &sBeamPOTCT4, &b_sBeamPOTCT4);
393 #endif
394  anaUtils::ConfigureTreeBranch(fChain, "sBeamSpill", &sBeamSpill, &b_sBeamSpill);
395  anaUtils::ConfigureTreeBranch(fChain, "sBeamSpillNumber", &sBeamSpillNumber, &b_sBeamSpillNumber);
396  anaUtils::ConfigureTreeBranch(fChain, "sBeamGoodSpill", &sBeamGoodSpill, &b_sBeamGoodSpill);
397  anaUtils::ConfigureTreeBranch(fChain, "sBeamBeamRunNumber", &sBeamBeamRunNumber, &b_sBeamBeamRunNumber);
398  anaUtils::ConfigureTreeBranch(fChain, "sDQGoodDaq", &sDQGoodDaq, &b_sDQGoodDaq);
399  anaUtils::ConfigureTreeBranch(fChain, "sDQND280Flag", &sDQND280Flag, &b_sDQND280Flag);
400  anaUtils::ConfigureTreeBranch(fChain, "sDQDetFlag", sDQDetFlag, &b_sDQDetFlag);
401  anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexRooVtxIndex", sTrueVertexRooVtxIndex, &b_sTrueVertexRooVtxIndex);
402  anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexRooVtxEntry", sTrueVertexRooVtxEntry, &b_sTrueVertexRooVtxEntry);
403  anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexReacCode", sTrueVertexReacCode, &b_sTrueVertexReacCode);
404  anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexNTrueTracks", sTrueVertexNTrueParticles, &b_sTrueVertexNTrueParticles);
405  // anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexNReconTracks", sTrueVertexNReconTracks, &b_sTrueVertexNReconTracks);
406  // anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexNReconVertices", sTrueVertexNReconVertices, &b_sTrueVertexNReconVertices);
407  // anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexNBaryons", sTrueVertexNBaryons, &b_sTrueVertexNBaryons);
408  anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexDetector", sTrueVertexDetector, &b_sTrueVertexDetector);
409  anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexLeptonPDG", sTrueVertexLeptonPDG, &b_sTrueVertexLeptonPDG);
410  anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexTargetPDG", sTrueVertexTargetPDG, &b_sTrueVertexTargetPDG);
411  anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexNuEnergy", sTrueVertexNuEnergy, &b_sTrueVertexNuEnergy);
412  // anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexQ2", sTrueVertexQ2, &b_sTrueVertexQ2);
413  anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexPosition", sTrueVertexPosition, &b_sTrueVertexPosition);
414  anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexNuParentPDG", sTrueVertexNuParentPDG, &b_sTrueVertexNuParentPDG);
415  anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexNuParentDecPoint", sTrueVertexNuParentDecPoint, &b_sTrueVertexNuParentDecPoint);
416  anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexNuDir", sTrueVertexNuDir, &b_sTrueVertexNuDir);
417  anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexTargetDir", sTrueVertexTargetDir, &b_sTrueVertexTargetDir);
418  anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexLeptonDir", sTrueVertexLeptonDir, &b_sTrueVertexLeptonDir);
419  anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexProtonDir", sTrueVertexProtonDir, &b_sTrueVertexProtonDir);
420  anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexPionDir", sTrueVertexPionDir, &b_sTrueVertexPionDir);
421  anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexTargetMom", sTrueVertexTargetMom, &b_sTrueVertexTargetMom);
422  anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexLeptonMom", sTrueVertexLeptonMom, &b_sTrueVertexLeptonMom);
423  anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexProtonMom", sTrueVertexProtonMom, &b_sTrueVertexProtonMom);
424  anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexPionMom", sTrueVertexPionMom, &b_sTrueVertexPionMom);
425  anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexIsPauliBlocked", sTrueVertexIsPauliBlocked, &b_sTrueVertexIsPauliBlocked);
426  anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexIsCohOnH", sTrueVertexIsCohOnH, &b_sTrueVertexIsCohOnH);
427  anaUtils::ConfigureTreeBranch(fChain, "sTrueVertexNPrimaryParticles", sTrueVertexNPrimaryParticles, &b_sTrueVertexNPrimaryParticles);
428  // anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackBunch", sTrueParticleBunch, &b_sTrueParticleBunch);
429  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackPDG", sTrueParticlePDG, &b_sTrueParticlePDG);
430  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackParentPDG", sTrueParticleParentPDG, &b_sTrueParticleParentPDG);
431  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackGParentPDG", sTrueParticleGParentPDG, &b_sTrueParticleGParentPDG);
432  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackPrimaryID", sTrueParticlePrimaryID, &b_sTrueParticlePrimaryID);
433  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackParentID", sTrueParticleParentID, &b_sTrueParticleParentID);
434  // anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackPurity", sTrueParticlePurity, &b_sTrueParticlePurity);
435  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackMomentum", sTrueParticleMomentum, &b_sTrueParticleMomentum);
436  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackCharge", sTrueParticleCharge, &b_sTrueParticleCharge);
437  // anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackNReconTracks", sTrueParticleNReconTracks, &b_sTrueParticleNReconTracks);
438  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackPosition", sTrueParticlePosition, &b_sTrueParticlePosition);
439  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackPositionEnd", sTrueParticlePositionEnd, &b_sTrueParticlePositionEnd);
440  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackDirection", sTrueParticleDirection, &b_sTrueParticleDirection);
441  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackNDetCrossings", sTrueParticleNDetCrossings, &b_sTrueParticleNDetCrossings);
442  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackEntrancePosition", sTrueParticleEntrancePosition, &b_sTrueParticleEntrancePosition);
443  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackEntranceMomentum", sTrueParticleEntranceMomentum, &b_sTrueParticleEntranceMomentum);
444  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackExitPosition", sTrueParticleExitPosition, &b_sTrueParticleExitPosition);
445  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackExitMomentum", sTrueParticleExitMomentum, &b_sTrueParticleExitMomentum);
446  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackInActive", sTrueParticleInActive, &b_sTrueParticleInActive);
447  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackDetector", sTrueParticleDetector, &b_sTrueParticleDetector);
448  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackIsTruePrimaryPi0DecayPhoton", sTrueParticleIsTruePrimaryPi0DecayPhoton, &b_sTrueParticleIsTruePrimaryPi0DecayPhoton);
449  anaUtils::ConfigureTreeBranch(fChain, "sTrueTrackIsTruePrimaryPi0DecayPhotonChild", sTrueParticleIsTruePrimaryPi0DecayPhotonChild, &b_sTrueParticleIsTruePrimaryPi0DecayPhotonChild);
450  anaUtils::ConfigureTreeBranch(fChain, "sFgdTimeBinMinTime", sFgdTimeBinMinTime, &b_sFgdTimeBinMinTime);
451  anaUtils::ConfigureTreeBranch(fChain, "sFgdTimeBinMaxTime", sFgdTimeBinMaxTime, &b_sFgdTimeBinMaxTime);
452  anaUtils::ConfigureTreeBranch(fChain, "sFgdTimeBinRawChargeSum1", sFgdTimeBinRawChargeSum1, &b_sFgdTimeBinRawChargeSum1);
453  anaUtils::ConfigureTreeBranch(fChain, "sFgdTimeBinRawChargeSum2", sFgdTimeBinRawChargeSum2, &b_sFgdTimeBinRawChargeSum2);
454  // anaUtils::ConfigureTreeBranch(fChain, "sFgdTimeBinG4ID", sFgdTimeBinG4ID, &b_sFgdTimeBinG4ID);
455 
456  // anaUtils::ConfigureTreeBranch(fChain, "NVertices", &NVertices, &b_NVertices);
457  // anaUtils::ConfigureTreeBranch(fChain, "vPrimaryIndex", &vPrimaryIndex, &b_vPrimaryIndex);
458  // anaUtils::ConfigureTreeBranch(fChain, "vBunch", &vBunch, &b_vBunch);
459  // anaUtils::ConfigureTreeBranch(fChain, "vPosition", &vPosition, &b_vPosition);
460  // anaUtils::ConfigureTreeBranch(fChain, "vVariance", &vVariance, &b_vVariance);
461  // anaUtils::ConfigureTreeBranch(fChain, "vChi2", &vChi2, &b_vChi2);
462  // anaUtils::ConfigureTreeBranch(fChain, "vNDOF", &vNDOF, &b_vNDOF);
463  anaUtils::ConfigureTreeBranch(fChain, "vNReconTracks", &vNReconParticles, &b_vNReconParticles);
464  anaUtils::ConfigureTreeBranch(fChain, "vNTrueVerticesMatch", &vNTrueVerticesMatch, &b_vNTrueVerticesMatch);
465  anaUtils::ConfigureTreeBranch(fChain, "vTracksUniqueID", &vParticlesUniqueID, &b_vParticlesUniqueID);
466  anaUtils::ConfigureTreeBranch(fChain, "vTrueVertexIndex", &vTrueVertexIndex, &b_vTrueVertexIndex);
467  anaUtils::ConfigureTreeBranch(fChain, "vTrueVerticesClean", &vTrueVerticesClean, &b_vTrueVerticesClean);
468  anaUtils::ConfigureTreeBranch(fChain, "vTrueVerticesCompl", &vTrueVerticesCompl, &b_vTrueVerticesCompl);
469 
470  // anaUtils::ConfigureTreeBranch(fChain, "trStatus", trStatus, &b_trStatus);
471  anaUtils::ConfigureTreeBranch(fChain, "trReconPDG", trReconPDG, &b_trReconPDG);
472  // anaUtils::ConfigureTreeBranch(fChain, "trBunch", trBunch, &b_trBunch);
473  // anaUtils::ConfigureTreeBranch(fChain, "trNReconVertices", &trNReconVertices, &b_trNReconVertices);
474  anaUtils::ConfigureTreeBranch(fChain, "trDetectors", trDetectors, &b_trDetectors);
475  // anaUtils::ConfigureTreeBranch(fChain, "trNTPCs", trNTPCs, &b_trNTPCs);
476  // anaUtils::ConfigureTreeBranch(fChain, "trNFGDs", trNFGDs, &b_trNFGDs);
477  // anaUtils::ConfigureTreeBranch(fChain, "trNECALs", trNECALs, &b_trNECALs);
478  // anaUtils::ConfigureTreeBranch(fChain, "trNSMRDs", trNSMRDs, &b_trNSMRDs);
479  // anaUtils::ConfigureTreeBranch(fChain, "trNP0Ds", trNP0Ds, &b_trNP0Ds);
480  anaUtils::ConfigureTreeBranch(fChain, "trNTRACKERs", trNTRACKERs, &b_trNTRACKERs);
481  anaUtils::ConfigureTreeBranch(fChain, "trNHits", trNHits, &b_trNHits);
482  anaUtils::ConfigureTreeBranch(fChain, "trNNodes", trNNodes, &b_trNNodes);
483  anaUtils::ConfigureTreeBranch(fChain, "trNDOF", trNDOF, &b_trNDOF);
484  anaUtils::ConfigureTreeBranch(fChain, "trChi2", trChi2, &b_trChi2);
485  anaUtils::ConfigureTreeBranch(fChain, "trCharge", trCharge, &b_trCharge);
486  anaUtils::ConfigureTreeBranch(fChain, "trMomentum", trMomentum, &b_trMomentum);
487  // anaUtils::ConfigureTreeBranch(fChain, "trMomentumError", trMomentumError, &b_trMomentumError);
488  anaUtils::ConfigureTreeBranch(fChain, "trMomentumMuon", trMomentumMuon, &b_trMomentumMuon);
489  // anaUtils::ConfigureTreeBranch(fChain, "trMomentumErrorMuon", trMomentumErrorMuon, &b_trMomentumErrorMuon);
490  anaUtils::ConfigureTreeBranch(fChain, "trMomentumProton", trMomentumProton, &b_trMomentumProton);
491  // anaUtils::ConfigureTreeBranch(fChain, "trMomentumErrorProton", trMomentumErrorProton, &b_trMomentumErrorProton);
492  anaUtils::ConfigureTreeBranch(fChain, "trMomentumEle", trMomentumEle, &b_trMomentumEle);
493  // anaUtils::ConfigureTreeBranch(fChain, "trMomentumErrorEle", trMomentumErrorEle, &b_trMomentumErrorEle);
494 
495 
496  anaUtils::ConfigureTreeBranch(fChain, "trLength", trLength, &b_trLength);
497 
498 #if VERSION_HAS_REVERSED_REFITS
499  anaUtils::ConfigureTreeBranch(fChain, "trDirectionStartFlip", trDirectionStartFlip, &b_trDirectionStartFlip);
500  anaUtils::ConfigureTreeBranch(fChain, "trDirectionEndFlip", trDirectionEndFlip, &b_trDirectionEndFlip);
501 #endif
502 
503 
504 #if VERSION_HAS_PRANGE_ESTIMATES
505  // anaUtils::ConfigureTreeBranch(fChain, "trRangeMomentumEle", trRangeMomentumEle, &b_trRangeMomentumEle);
506  anaUtils::ConfigureTreeBranch(fChain, "trRangeMomentumProton", trRangeMomentumProton, &b_trRangeMomentumProton);
507  // anaUtils::ConfigureTreeBranch(fChain, "trRangeMomentumMuonFlip", trRangeMomentumMuonFlip, &b_trRangeMomentumMuonFlip);
508 // anaUtils::ConfigureTreeBranch(fChain, "trRangeMomentumProtonFlip", trRangeMomentumProtonFlip, &b_trRangeMomentumProtonFlip);
509 #endif
510 
511  anaUtils::ConfigureTreeBranch(fChain, "trMomentumAtVertex", trMomentumAtVertex, &b_trMomentumAtVertex);
512  anaUtils::ConfigureTreeBranch(fChain, "trDirectionAtVertex", trDirectionAtVertex, &b_trDirectionAtVertex);
513  anaUtils::ConfigureTreeBranch(fChain, "trDirectionStart", trDirectionStart, &b_trDirectionStart);
514  anaUtils::ConfigureTreeBranch(fChain, "trDirectionEnd", trDirectionEnd, &b_trDirectionEnd);
515  anaUtils::ConfigureTreeBranch(fChain, "trPositionStart", trPositionStart, &b_trPositionStart);
516  anaUtils::ConfigureTreeBranch(fChain, "trPositionEnd", trPositionEnd, &b_trPositionEnd);
517  anaUtils::ConfigureTreeBranch(fChain, "trTrueTrackID", trTrueParticleID, &b_trTrueParticleID);
518 
519 #if VERSION_HAS_TIME_FITS
520  // anaUtils::ConfigureTreeBranch(fChain, "trNTimeNodes", trNTimeNodes, &b_trNTimeNodes);
521  // anaUtils::ConfigureTreeBranch(fChain, "trTimeNodeDetector", trTimeNodeDetector, &b_trTimeNodeDetector);
522  // anaUtils::ConfigureTreeBranch(fChain, "trTimeNodeTimeStart", trTimeNodeTimeStart, &b_trTimeNodeTimeStart);
523  // anaUtils::ConfigureTreeBranch(fChain, "trTimeNodeTimeEnd", trTimeNodeTimeEnd, &b_trTimeNodeTimeEnd);
524 
525  anaUtils::ConfigureTreeBranch(fChain, "trToFFGD1_FGD2", trToFFGD1_FGD2, &b_trToFFGD1_FGD2);
526  anaUtils::ConfigureTreeBranch(fChain, "trToFP0D_FGD1", trToFP0D_FGD1, &b_trToFP0D_FGD1);
527  anaUtils::ConfigureTreeBranch(fChain, "trToFECal_FGD1", trToFECal_FGD1, &b_trToFECal_FGD1);
528  anaUtils::ConfigureTreeBranch(fChain, "trToFECal_FGD2", trToFECal_FGD2, &b_trToFECal_FGD2);
529  anaUtils::ConfigureTreeBranch(fChain, "trToFFlag_FGD1_FGD2", trToFFlag_FGD1_FGD2, &b_trToFFlag_FGD1_FGD2);
530  anaUtils::ConfigureTreeBranch(fChain, "trToFFlag_P0D_FGD1", trToFFlag_P0D_FGD1, &b_trToFFlag_P0D_FGD1);
531  anaUtils::ConfigureTreeBranch(fChain, "trToFFlag_ECal_FGD1", trToFFlag_ECal_FGD1, &b_trToFFlag_ECal_FGD1);
532  anaUtils::ConfigureTreeBranch(fChain, "trToFFlag_ECal_FGD2", trToFFlag_ECal_FGD2, &b_trToFFlag_ECal_FGD2);
533 
534 #endif
535 
536  anaUtils::ConfigureTreeBranch(fChain, "trTpcNHits", trTpcNHits, &b_trTpcNHits);
537  anaUtils::ConfigureTreeBranch(fChain, "trTpcUniqueID", trTpcUniqueID, &b_trTpcUniqueID);
538  anaUtils::ConfigureTreeBranch(fChain, "trTpcLength", trTpcLength, &b_trTpcLength);
539  anaUtils::ConfigureTreeBranch(fChain, "trTpcDirectionStart", trTpcDirectionStart, &b_trTpcDirectionStart);
540  anaUtils::ConfigureTreeBranch(fChain, "trTpcDirectionEnd", trTpcDirectionEnd, &b_trTpcDirectionEnd);
541  anaUtils::ConfigureTreeBranch(fChain, "trTpcPositionStart", trTpcPositionStart, &b_trTpcPositionStart);
542  anaUtils::ConfigureTreeBranch(fChain, "trTpcPositionEnd", trTpcPositionEnd, &b_trTpcPositionEnd);
543  anaUtils::ConfigureTreeBranch(fChain, "trTpcCharge", trTpcCharge, &b_trTpcCharge);
544  anaUtils::ConfigureTreeBranch(fChain, "trTpcMomentum", trTpcMomentum, &b_trTpcMomentum);
545  anaUtils::ConfigureTreeBranch(fChain, "trTpcMomentumError", trTpcMomentumError, &b_trTpcMomentumError);
546  anaUtils::ConfigureTreeBranch(fChain, "trTpcBackMomentum", trTpcBackMomentum, &b_trTpcBackMomentum);
547 #if VERSION_HAS_BFIELD_REFIT
548  anaUtils::ConfigureTreeBranch(fChain, "trTpcRefitMomentum", trTpcRefitMomentum, &b_trTpcRefitMomentum);
549 #endif
550 #if VERSION_HAS_BFIELD_REFIT_FULL
551  anaUtils::ConfigureTreeBranch(fChain, "trTpcRefitCharge", trTpcRefitCharge, &b_trTpcRefitCharge);
552  anaUtils::ConfigureTreeBranch(fChain, "trTpcRefitDirection",trTpcRefitDirection, &b_trTpcRefitDirection);
553  anaUtils::ConfigureTreeBranch(fChain, "trTpcRefitPosition", trTpcRefitPosition, &b_trTpcRefitPosition);
554 #endif
555 #if VERSION_HAS_EFIELD_REFIT
556  anaUtils::ConfigureTreeBranch(fChain, "trTpcEFieldRefitMomentum", trTpcEFieldRefitMomentum, &b_trTpcEFieldRefitMomentum);
557 #endif
558  anaUtils::ConfigureTreeBranch(fChain, "trTpcPullmu", trTpcPullmu, &b_trTpcPullmu);
559  anaUtils::ConfigureTreeBranch(fChain, "trTpcPullele", trTpcPullele, &b_trTpcPullele);
560  anaUtils::ConfigureTreeBranch(fChain, "trTpcPullp", trTpcPullp, &b_trTpcPullp);
561  anaUtils::ConfigureTreeBranch(fChain, "trTpcPullpi", trTpcPullpi, &b_trTpcPullpi);
562  anaUtils::ConfigureTreeBranch(fChain, "trTpcPullk", trTpcPullk, &b_trTpcPullk);
563  anaUtils::ConfigureTreeBranch(fChain, "trTpcdEdxMeas", trTpcdEdxMeas, &b_trTpcdEdxMeas);
564  anaUtils::ConfigureTreeBranch(fChain, "trTpcdEdxExpMu", trTpcdEdxExpMu, &b_trTpcdEdxExpMu);
565  anaUtils::ConfigureTreeBranch(fChain, "trTpcdEdxExpEle", trTpcdEdxExpEle, &b_trTpcdEdxExpEle);
566  anaUtils::ConfigureTreeBranch(fChain, "trTpcdEdxExpP", trTpcdEdxExpP, &b_trTpcdEdxExpP);
567  anaUtils::ConfigureTreeBranch(fChain, "trTpcdEdxExpPi", trTpcdEdxExpPi, &b_trTpcdEdxExpPi);
568  anaUtils::ConfigureTreeBranch(fChain, "trTpcdEdxExpK", trTpcdEdxExpK, &b_trTpcdEdxExpK);
569  anaUtils::ConfigureTreeBranch(fChain, "trTpcRawdEdxMeas", trTpcRawdEdxMeas, &b_trTpcRawdEdxMeas);
570  anaUtils::ConfigureTreeBranch(fChain, "trTpcRawdEdxExpMu", trTpcRawdEdxExpMu, &b_trTpcRawdEdxExpMu);
571  anaUtils::ConfigureTreeBranch(fChain, "trTpcRawdEdxExpEle", trTpcRawdEdxExpEle, &b_trTpcRawdEdxExpEle);
572  anaUtils::ConfigureTreeBranch(fChain, "trTpcRawdEdxExpP", trTpcRawdEdxExpP, &b_trTpcRawdEdxExpP);
573  anaUtils::ConfigureTreeBranch(fChain, "trTpcRawdEdxExpPi", trTpcRawdEdxExpPi, &b_trTpcRawdEdxExpPi);
574  anaUtils::ConfigureTreeBranch(fChain, "trTpcRawdEdxExpK", trTpcRawdEdxExpK, &b_trTpcRawdEdxExpK);
575  anaUtils::ConfigureTreeBranch(fChain, "trTpcdEdxSigmaMu", trTpcdEdxSigmaMu, &b_trTpcdEdxSigmaMu);
576  anaUtils::ConfigureTreeBranch(fChain, "trTpcdEdxSigmaEle", trTpcdEdxSigmaEle, &b_trTpcdEdxSigmaEle);
577  anaUtils::ConfigureTreeBranch(fChain, "trTpcdEdxSigmaP", trTpcdEdxSigmaP, &b_trTpcdEdxSigmaP);
578  anaUtils::ConfigureTreeBranch(fChain, "trTpcdEdxSigmaPi", trTpcdEdxSigmaPi, &b_trTpcdEdxSigmaPi);
579  anaUtils::ConfigureTreeBranch(fChain, "trTpcdEdxSigmaK", trTpcdEdxSigmaK, &b_trTpcdEdxSigmaK);
580  // anaUtils::ConfigureTreeBranch(fChain, "trTpcPurity", trTpcPurity, &b_trTpcPurity);
581  anaUtils::ConfigureTreeBranch(fChain, "trTpcTrueTrackID", trTpcTrueParticleID, &b_trTpcTrueParticleID);
582  anaUtils::ConfigureTreeBranch(fChain, "trFgdDetector", trFgdDetector, &b_trFgdDetector);
583  anaUtils::ConfigureTreeBranch(fChain, "trFgdNHits", trFgdNHits, &b_trFgdNHits);
584  anaUtils::ConfigureTreeBranch(fChain, "trFgdNNodes", trFgdNNodes, &b_trFgdNNodes);
585  anaUtils::ConfigureTreeBranch(fChain, "trFgdUniqueID", trFgdUniqueID, &b_trFgdUniqueID);
586  anaUtils::ConfigureTreeBranch(fChain, "trFgdLength", trFgdLength, &b_trFgdLength);
587  anaUtils::ConfigureTreeBranch(fChain, "trFgdDirectionStart", trFgdDirectionStart, &b_trFgdDirectionStart);
588  anaUtils::ConfigureTreeBranch(fChain, "trFgdDirectionEnd", trFgdDirectionEnd, &b_trFgdDirectionEnd);
589  anaUtils::ConfigureTreeBranch(fChain, "trFgdPositionStart", trFgdPositionStart, &b_trFgdPositionStart);
590  anaUtils::ConfigureTreeBranch(fChain, "trFgdPositionEnd", trFgdPositionEnd, &b_trFgdPositionEnd);
591  anaUtils::ConfigureTreeBranch(fChain, "trFgdX", trFgdX, &b_trFgdX);
592  anaUtils::ConfigureTreeBranch(fChain, "trFgdE", trFgdE, &b_trFgdE);
593  anaUtils::ConfigureTreeBranch(fChain, "trFgdPullmu", trFgdPullmu, &b_trFgdPullmu);
594  anaUtils::ConfigureTreeBranch(fChain, "trFgdPullp", trFgdPullp, &b_trFgdPullp);
595  anaUtils::ConfigureTreeBranch(fChain, "trFgdPullpi", trFgdPullpi, &b_trFgdPullpi);
596  anaUtils::ConfigureTreeBranch(fChain, "trFgdPullno", trFgdPullno, &b_trFgdPullno);
597  anaUtils::ConfigureTreeBranch(fChain, "trFgdContainment", trFgdContainment, &b_trFgdContainment);
598  // anaUtils::ConfigureTreeBranch(fChain, "trFgdAvgTime", trFgdAvgTime, &b_trFgdAvgTime);
599 
600 #if VERSION_HAS_FGD_VERTEX_AND_END_ACTIVITY
601  anaUtils::ConfigureTreeBranch(fChain, "trFgdHasFgdVA", trFgdHasFgdVA, &b_trFgdHasFgdVA);
602  anaUtils::ConfigureTreeBranch(fChain, "trFgdHasFgdVA_fmode", trFgdHasFgdVA_fmode, &b_trFgdHasFgdVA_fmode);
603  anaUtils::ConfigureTreeBranch(fChain, "trFgdTypeVA", trFgdTypeVA, &b_trFgdTypeVA);
604 #endif
605  anaUtils::ConfigureTreeBranch(fChain, "trFgdVertex1x1", trFgdVertex1x1, &b_trFgdVertex1x1);
606  anaUtils::ConfigureTreeBranch(fChain, "trFgdVertex3x3", trFgdVertex3x3, &b_trFgdVertex3x3);
607  anaUtils::ConfigureTreeBranch(fChain, "trFgdVertex5x5", trFgdVertex5x5, &b_trFgdVertex5x5);
608  anaUtils::ConfigureTreeBranch(fChain, "trFgdVertex7x7", trFgdVertex7x7, &b_trFgdVertex7x7);
609  anaUtils::ConfigureTreeBranch(fChain, "trFgdVertexLayer", trFgdVertexLayer, &b_trFgdVertexLayer);
610 
611 #if VERSION_HAS_FGD_VERTEX_AND_END_ACTIVITY
612  anaUtils::ConfigureTreeBranch(fChain, "trFgdHasFgdEA", trFgdHasFgdEA, &b_trFgdHasFgdEA);
613  anaUtils::ConfigureTreeBranch(fChain, "trFgdHasFgdEA_fmode", trFgdHasFgdEA_fmode, &b_trFgdHasFgdEA_fmode);
614  anaUtils::ConfigureTreeBranch(fChain, "trFgdTypeEA", trFgdTypeEA, &b_trFgdTypeEA);
615  anaUtils::ConfigureTreeBranch(fChain, "trFgdEnd0x0", trFgdEnd0x0, &b_trFgdEnd0x0);
616  anaUtils::ConfigureTreeBranch(fChain, "trFgdEnd0x0", trFgdEnd0x0, &b_trFgdEnd0x0);
617  anaUtils::ConfigureTreeBranch(fChain, "trFgdEnd1x1", trFgdEnd1x1, &b_trFgdEnd1x1);
618  anaUtils::ConfigureTreeBranch(fChain, "trFgdEnd3x3", trFgdEnd3x3, &b_trFgdEnd3x3);
619  anaUtils::ConfigureTreeBranch(fChain, "trFgdEnd5x5", trFgdEnd5x5, &b_trFgdEnd5x5);
620  anaUtils::ConfigureTreeBranch(fChain, "trFgdEnd7x7", trFgdEnd7x7, &b_trFgdEnd7x7);
621 #endif
622 
623  // anaUtils::ConfigureTreeBranch(fChain, "trECALDetector", trECALDetector, &b_trECALDetector);
624  anaUtils::ConfigureTreeBranch(fChain, "trECALNHits", trECALNHits, &b_trECALNHits);
625  // anaUtils::ConfigureTreeBranch(fChain, "trECALNNodes", trECALNNodes, &b_trECALNNodes);
626  anaUtils::ConfigureTreeBranch(fChain, "trECALUniqueID", trECALUniqueID, &b_trECALUniqueID);
627  // anaUtils::ConfigureTreeBranch(fChain, "trECALLength", trECALLength, &b_trECALLength);
628  anaUtils::ConfigureTreeBranch(fChain, "trECALDirectionStart", trECALDirectionStart, &b_trECALDirectionStart);
629  anaUtils::ConfigureTreeBranch(fChain, "trECALDirectionEnd", trECALDirectionEnd, &b_trECALDirectionEnd);
630  anaUtils::ConfigureTreeBranch(fChain, "trECALPositionStart", trECALPositionStart, &b_trECALPositionStart);
631  anaUtils::ConfigureTreeBranch(fChain, "trECALPositionEnd", trECALPositionEnd, &b_trECALPositionEnd);
632  // anaUtils::ConfigureTreeBranch(fChain, "trECALEMEnergy", trECALEMEnergy, &b_trECALEMEnergy);
633  anaUtils::ConfigureTreeBranch(fChain, "trECALEDeposit", trECALEDeposit, &b_trECALEDeposit);
634  anaUtils::ConfigureTreeBranch(fChain, "trECALIsShowerLike", trECALIsShowerLike, &b_trECALIsShowerLike);
635  anaUtils::ConfigureTreeBranch(fChain, "trECALAvgTime", trECALAvgTime, &b_trECALAvgTime);
636  //ECal PID
637  anaUtils::ConfigureTreeBranch(fChain, "trECALPIDMipPion", trECALPIDMipPion, &b_trECALPIDMipPion);
638  // anaUtils::ConfigureTreeBranch(fChain, "trECALPIDMipEm", trECALPIDMipEm, &b_trECALPIDMipEm);
639  // anaUtils::ConfigureTreeBranch(fChain, "trECALPIDEmHip", trECALPIDEmHip, &b_trECALPIDEmHip);
640  anaUtils::ConfigureTreeBranch(fChain, "trECALContainment", trECALContainment, &b_trECALContainment);
641  // anaUtils::ConfigureTreeBranch(fChain, "trECALMostUpStreamLayerHit", trECALMostUpStreamLayerHit, &b_trECALMostUpStreamLayerHit);
642 
643  // anaUtils::ConfigureTreeBranch(fChain, "trSMRDDetector", trSMRDDetector, &b_trSMRDDetector);
644  // anaUtils::ConfigureTreeBranch(fChain, "trSMRDNHits", trSMRDNHits, &b_trSMRDNHits);
645  // anaUtils::ConfigureTreeBranch(fChain, "trSMRDNNodes", trSMRDNNodes, &b_trSMRDNNodes);
646  // anaUtils::ConfigureTreeBranch(fChain, "trSMRDUniqueID", trSMRDUniqueID, &b_trSMRDUniqueID);
647  // anaUtils::ConfigureTreeBranch(fChain, "trSMRDLength", trSMRDLength, &b_trSMRDLength);
648  // anaUtils::ConfigureTreeBranch(fChain, "trSMRDDirectionStart", trSMRDDirectionStart, &b_trSMRDDirectionStart);
649  // anaUtils::ConfigureTreeBranch(fChain, "trSMRDDirectionEnd", trSMRDDirectionEnd, &b_trSMRDDirectionEnd);
650  // anaUtils::ConfigureTreeBranch(fChain, "trSMRDPositionStart", trSMRDPositionStart, &b_trSMRDPositionStart);
651  // anaUtils::ConfigureTreeBranch(fChain, "trSMRDPositionEnd", trSMRDPositionEnd, &b_trSMRDPositionEnd);
652  // anaUtils::ConfigureTreeBranch(fChain, "trSMRDAvgTime", trSMRDAvgTime, &b_trSMRDAvgTime);
653  anaUtils::ConfigureTreeBranch(fChain, "trSMRDEDeposit", trSMRDEDeposit, &b_trSMRDEDeposit);
654 
655 
656 
657  // anaUtils::ConfigureTreeBranch(fChain, "trP0DDetector", trP0DDetector, &b_trP0DDetector);
658  // anaUtils::ConfigureTreeBranch(fChain, "trP0DNHits", trP0DNHits, &b_trP0DNHits);
659  anaUtils::ConfigureTreeBranch(fChain, "trP0DNNodes", trP0DNNodes, &b_trP0DNNodes);
660  // anaUtils::ConfigureTreeBranch(fChain, "trP0DUniqueID", trP0DUniqueID, &b_trP0DUniqueID);
661  // anaUtils::ConfigureTreeBranch(fChain, "trP0DLength", trP0DLength, &b_trP0DLength);
662  // anaUtils::ConfigureTreeBranch(fChain, "trP0DDirectionStart", trP0DDirectionStart, &b_trP0DDirectionStart);
663  // anaUtils::ConfigureTreeBranch(fChain, "trP0DDirectionEnd", trP0DDirectionEnd, &b_trP0DDirectionEnd);
664  // anaUtils::ConfigureTreeBranch(fChain, "trP0DPositionStart", trP0DPositionStart, &b_trP0DPositionStart);
665  // anaUtils::ConfigureTreeBranch(fChain, "trP0DPositionEnd", trP0DPositionEnd, &b_trP0DPositionEnd);
666 
667 #if VERSION_HAS_P0D_AVERAGED_TIME
668  anaUtils::ConfigureTreeBranch(fChain, "trP0DAvgTime", trP0DAvgTime, &b_trP0DAvgTime);
669 #endif
670 
671  anaUtils::ConfigureTreeBranch(fChain, "trTRACKERDetector", trTRACKERDetector, &b_trTRACKERDetector);
672  anaUtils::ConfigureTreeBranch(fChain, "trTRACKERNHits", trTRACKERNHits, &b_trTRACKERNHits);
673  anaUtils::ConfigureTreeBranch(fChain, "trTRACKERNNodes", trTRACKERNNodes, &b_trTRACKERNNodes);
674  anaUtils::ConfigureTreeBranch(fChain, "trTRACKERUniqueID", trTRACKERUniqueID, &b_trTRACKERUniqueID);
675  anaUtils::ConfigureTreeBranch(fChain, "trTRACKERLength", trTRACKERLength, &b_trTRACKERLength);
676  anaUtils::ConfigureTreeBranch(fChain, "trTRACKERDirectionStart", trTRACKERDirectionStart, &b_trTRACKERDirectionStart);
677  anaUtils::ConfigureTreeBranch(fChain, "trTRACKERDirectionEnd", trTRACKERDirectionEnd, &b_trTRACKERDirectionEnd);
678  anaUtils::ConfigureTreeBranch(fChain, "trTRACKERPositionStart", trTRACKERPositionStart, &b_trTRACKERPositionStart);
679  anaUtils::ConfigureTreeBranch(fChain, "trTRACKERPositionEnd", trTRACKERPositionEnd, &b_trTRACKERPositionEnd);
680  anaUtils::ConfigureTreeBranch(fChain, "trTRACKERCharge", trTRACKERCharge, &b_trTRACKERCharge);
681  anaUtils::ConfigureTreeBranch(fChain, "trTRACKERMomentum", trTRACKERMomentum, &b_trTRACKERMomentum);
682  anaUtils::ConfigureTreeBranch(fChain, "trTRACKERMomentumEnd", trTRACKERMomentumEnd, &b_trTRACKERMomentumEnd);
683 
684  /// AnaLocalReconBunch information
685  if(_isUsingReconDirTECAL){
686  anaUtils::ConfigureTreeBranch(fChain, "tecalReconCounter", &tecalReconCounter, &b_tecalReconCounter );
687  anaUtils::ConfigureTreeBranch(fChain, "tecalReconAverageHitTime", tecalReconAverageHitTime, &b_tecalReconAverageHitTime );
688  anaUtils::ConfigureTreeBranch(fChain, "tecalReconAverageZPosition", tecalReconAverageZPosition, &b_tecalReconAverageZPosition );
689  anaUtils::ConfigureTreeBranch(fChain, "tecalReconContainment", tecalReconContainment, &b_tecalReconContainment );
690  anaUtils::ConfigureTreeBranch(fChain, "tecalReconEFitResult", tecalReconEFitResult, &b_tecalReconEFitResult );
691  anaUtils::ConfigureTreeBranch(fChain, "tecalReconEFitUncertainty", tecalReconEFitUncertainty, &b_tecalReconEFitUncertainty );
692  anaUtils::ConfigureTreeBranch(fChain, "tecalReconFirstLayer", tecalReconFirstLayer, &b_tecalReconFirstLayer );
693  anaUtils::ConfigureTreeBranch(fChain, "tecalReconIsShowerLike", tecalReconIsShowerLike, &b_tecalReconIsShowerLike );
694  anaUtils::ConfigureTreeBranch(fChain, "tecalReconIsTrackLike", tecalReconIsTrackLike, &b_tecalReconIsTrackLike );
695  anaUtils::ConfigureTreeBranch(fChain, "tecalReconLastLayer", tecalReconLastLayer, &b_tecalReconLastLayer );
696 #if VERSION_HAS_ECAL_LLR
697  anaUtils::ConfigureTreeBranch(fChain, "tecalReconLikeMIPEM", tecalReconLikeMIPEM, &b_tecalReconLikeMIPEM );
698  anaUtils::ConfigureTreeBranch(fChain, "tecalReconLikeMIPPion", tecalReconLikeMIPPion, &b_tecalReconLikeMIPPion );
699  anaUtils::ConfigureTreeBranch(fChain, "tecalReconLikeEMHIP", tecalReconLikeEMHIP, &b_tecalReconLikeEMHIP );
700  anaUtils::ConfigureTreeBranch(fChain, "tecalReconLikeMIPEMLow", tecalReconLikeMIPEMLow, &b_tecalReconLikeMIPEMLow );
701 #endif
702  anaUtils::ConfigureTreeBranch(fChain, "tecalReconMatchingLike", tecalReconMatchingLike, &b_tecalReconMatchingLike );
703  anaUtils::ConfigureTreeBranch(fChain, "tecalReconMichelTagNDelayedCluster",tecalReconMichelTagNDelayedCluster, &b_tecalReconMichelTagNDelayedCluster);
704  anaUtils::ConfigureTreeBranch(fChain, "tecalReconModule", tecalReconModule, &b_tecalReconModule );
705  anaUtils::ConfigureTreeBranch(fChain, "tecalReconMostDownStreamLayerHit", tecalReconMostDownStreamLayerHit, &b_tecalReconMostDownStreamLayerHit );
706  anaUtils::ConfigureTreeBranch(fChain, "tecalReconMostUpStreamLayerHit", tecalReconMostUpStreamLayerHit, &b_tecalReconMostUpStreamLayerHit );
707  anaUtils::ConfigureTreeBranch(fChain, "tecalReconNHits", tecalReconNHits, &b_tecalReconNHits );
708  anaUtils::ConfigureTreeBranch(fChain, "tecalReconNLayersHit", tecalReconNLayersHit, &b_tecalReconNLayersHit );
709  anaUtils::ConfigureTreeBranch(fChain, "tecalReconObjectLength", tecalReconObjectLength, &b_tecalReconObjectLength );
710  anaUtils::ConfigureTreeBranch(fChain, "tecalReconPIDAMR", tecalReconPIDAMR, &b_tecalReconPIDAMR );
711  anaUtils::ConfigureTreeBranch(fChain, "tecalReconPIDAngle", tecalReconPIDAngle, &b_tecalReconPIDAngle );
712  anaUtils::ConfigureTreeBranch(fChain, "tecalReconPIDAsymmetry", tecalReconPIDAsymmetry, &b_tecalReconPIDAsymmetry );
713  anaUtils::ConfigureTreeBranch(fChain, "tecalReconPIDCircularity", tecalReconPIDCircularity, &b_tecalReconPIDCircularity );
714  anaUtils::ConfigureTreeBranch(fChain, "tecalReconPIDFBR", tecalReconPIDFBR, &b_tecalReconPIDFBR );
715  anaUtils::ConfigureTreeBranch(fChain, "tecalReconPIDMaxRatio", tecalReconPIDMaxRatio, &b_tecalReconPIDMaxRatio );
716  anaUtils::ConfigureTreeBranch(fChain, "tecalReconPIDMeanPos", tecalReconPIDMeanPos, &b_tecalReconPIDMeanPos );
717  anaUtils::ConfigureTreeBranch(fChain, "tecalReconPIDShowerAngle", tecalReconPIDShowerAngle, &b_tecalReconPIDShowerAngle );
718  anaUtils::ConfigureTreeBranch(fChain, "tecalReconPIDShowerWidth", tecalReconPIDShowerWidth, &b_tecalReconPIDShowerWidth );
719  anaUtils::ConfigureTreeBranch(fChain, "tecalReconPIDTransverseChargeRatio",tecalReconPIDTransverseChargeRatio, &b_tecalReconPIDTransverseChargeRatio);
720  anaUtils::ConfigureTreeBranch(fChain, "tecalReconPIDTruncatedMaxRatio", tecalReconPIDTruncatedMaxRatio, &b_tecalReconPIDTruncatedMaxRatio );
721  anaUtils::ConfigureTreeBranch(fChain, "tecalReconPointing", tecalReconPointing, &b_tecalReconPointing );
722  anaUtils::ConfigureTreeBranch(fChain, "tecalReconThrust", tecalReconThrust, &b_tecalReconThrust );
723  anaUtils::ConfigureTreeBranch(fChain, "tecalReconThrustAxis", tecalReconThrustAxis, &b_tecalReconThrustAxis );
724  anaUtils::ConfigureTreeBranch(fChain, "tecalReconThrustOrigin", tecalReconThrustOrigin, &b_tecalReconThrustOrigin );
725  anaUtils::ConfigureTreeBranch(fChain, "tecalReconTimeBunch", tecalReconTimeBunch, &b_tecalReconTimeBunch );
726  anaUtils::ConfigureTreeBranch(fChain, "tecalReconTotalHitCharge", tecalReconTotalHitCharge, &b_tecalReconTotalHitCharge );
727  anaUtils::ConfigureTreeBranch(fChain, "tecalReconTrueID", tecalReconTrueID, &b_tecalReconTrueID );
728  anaUtils::ConfigureTreeBranch(fChain, "tecalReconTrueIDPrimary", tecalReconTrueIDPrimary, &b_tecalReconTrueIDPrimary );
729  anaUtils::ConfigureTreeBranch(fChain, "tecalReconTrueIDRecursive", tecalReconTrueIDRecursive, &b_tecalReconTrueIDRecursive );
730  anaUtils::ConfigureTreeBranch(fChain, "tecalReconTrueIDSingle", tecalReconTrueIDSingle, &b_tecalReconTrueIDSingle );
731  anaUtils::ConfigureTreeBranch(fChain, "tecalReconUniqueID", tecalReconUniqueID, &b_tecalReconUniqueID );
732  anaUtils::ConfigureTreeBranch(fChain, "tecalReconBunch", tecalReconBunch, &b_tecalReconBunch );
733  }
734 }
735 
736 //********************************************************************
737 FlatTreeConverter::~FlatTreeConverter(){
738 //********************************************************************
739 
740 }
741 
742 //****************************************************************************
743 bool FlatTreeConverter::AddFileToTChain(const std::string& inputString){
744 //****************************************************************************
745 
746  std::cout << "FlatTreeConverter::AddFileToTChain(). Adding file: " << inputString << std::endl;
747 
748  if (!RedoTreeConverter::AddFileToTChain(inputString)) return false;
749 
750  // Open the file to do few checks
751  TFile *f = TFile::Open(inputString.c_str());
752  f->cd();
753 
754  // ---------- Deal with RooTrackerVtx trees. Only for the first file
755 
756 
757  if( _firstFile ) {
758  _firstFile = false;
759 
760  if (_readRooTrackerVtx){
761  if (fNeut) {
762  NRooTrackerVTX = GetChain("NRooTrackerVtx");
763  NRooTrackerVTX->SetBranchAddress("RunID", &RunID);
764  NRooTrackerVTX->SetBranchAddress("SubrunID", &SubrunID);
765  NRooTrackerVTX->SetBranchAddress("EventID", &EventID);
766  NVtx = new TClonesArray("ND::NRooTrackerVtx",100);
767  NRooTrackerVTX->SetBranchAddress("NVtx",&NNVtx);
768  NRooTrackerVTX->SetBranchAddress("Vtx",&NVtx);
769  std::cout << "FlatTreeConverter::AddFileToTChain(). NEUT RooTrackerVtx tree found !!" << std::endl;
770  }
771  else if(fGenie) {
772  GRooTrackerVTX = GetChain("GRooTrackerVtx");
773  GRooTrackerVTX->SetBranchAddress("RunID", &RunID);
774  GRooTrackerVTX->SetBranchAddress("SubrunID", &SubrunID);
775  GRooTrackerVTX->SetBranchAddress("EventID", &EventID);
776  GVtx = new TClonesArray("ND::GRooTrackerVtx",100);
777  GRooTrackerVTX->SetBranchAddress("NVtx",&NGVtx);
778  GRooTrackerVTX->SetBranchAddress("Vtx",&GVtx);
779  std::cout << "FlatTreeConverter::AddFileToTChain(). GENIE RooTrackerVtx tree found !!" << std::endl;
780  }
781  }
782  }
783 
784  // Close the file
785  f->Close();
786 
787  // Define Data/MC status: use the first valid entry in the flat tree
788  Long64_t nentries = GetEntries();
789  for (Long64_t i = 0; i<nentries; i++){
790  Int_t entry_temp = flattree->GetEntry(i);
791  if (entry_temp<=0) continue;
792  // Set the data/MC mode and return false when mixing data and MC files
793  if (!header().SetIsMC(sIsMC)) return false;
794  break;
795  }
796 
797  return true;
798 }
799 
800 //*****************************************************************************
801 Int_t FlatTreeConverter::GetSpill(Long64_t& entry, AnaSpillC*& spill){
802 //*****************************************************************************
803 
804  // Read contents of entry.
805  if (!fChain) return 0;
806 
807  // Create an instance of AnaSpill
808  spill = MakeSpill();
809 
810  // get a new entry from the flat tree. entry_temp >0 when succesfull
811  Int_t entry_temp = flattree->GetEntry(entry);
812 
813  // If this is not one of the events to skim just go to the next entry (and don't process that event --> return <=0)
814  if (!anaUtils::CheckSkimmedEvent(sRun,sSubrun,sEvt)){
815  entry++;
816  return 0;
817  }
818 
819  if (_readRooTrackerVtx){
820  // sEvt should be positive since sEvt=-999 is used for the last flatree entry
821  if (entry_temp>0 && sIsMC && (fGenie || fNeut) && sEvt>=0) {
822  // Loop over RooTrackerVtx entries until we get the same run, subrun and event numbers
823  // In general we will get the right entry in the first iteration, but just in case
824  do{
825  if (NRooTrackerVTX) NRooTrackerVTX->GetEntry(_entry_roo);
826  else if (GRooTrackerVTX) GRooTrackerVTX->GetEntry(_entry_roo);
827  if ((RunID> sRun ) ||
828  (RunID==sRun && SubrunID> sSubrun ) ||
829  (RunID==sRun && SubrunID==sSubrun && EventID>sEvt )){
830  _entry_roo--;
831  _RooVtxEntryInCurrentInputFile--;
832  }
833  else{
834  _entry_roo++;
835  _RooVtxEntryInCurrentInputFile++;
836  }
837  }while(EventID!=sEvt || RunID!=sRun || SubrunID!=sSubrun);
838  }
839  }
840 
841 
842 
843  // Print the current file
844  TString filename(flattree->GetFile()->GetName());
845  if( filename != _currentFileName ) {
846  _RooVtxEntryInCurrentInputFile=0;
847  _currentFileIndex++;
848  std::cout << " Running on file (" << _currentFileIndex << " ): " << filename << std::endl;
849  _currentFileName = filename;
850  }
851 
852  // Caset the spill
853  _spill = static_cast<AnaSpillB*>(spill);
854  // _spill = spill;
855 
856  int evt_prev=sEvt;
857 
858  // This is needed to make sure that we read the first bunch of the spill when skiping entries
859  if (_firstEntry){
860  _firstEntry=false;
861  Long64_t requested_first_entry = entry;
862  while (sEvt==evt_prev && entry>0){
863  entry--;
864  entry_temp = flattree->GetEntry(entry);
865  }
866  if (sEvt!=evt_prev){
867  entry++;
868  entry_temp = flattree->GetEntry(entry);
869  }
870 
871  // Fill the general spill info
872  FillInfo(_spill);
873 
874  entry = requested_first_entry;
875  entry_temp = flattree->GetEntry(entry);
876  }
877  else{
878  // Fill the general spill info
879  FillInfo(_spill);
880  }
881 
882  // Fill tracks->vertices and vertices->tracks with null pointers for tracks and vertices that are not in this bunch
883  // FillNotInBunchObjWithNullPointers(_spill);
884 
885  // Always make the out of bunch
886  if (_isUsingReconDirTECAL || _isUsingReconDirPECAL || _isUsingReconDirFGDOnly || _isUsingReconDirP0D)
887  _spill->OutOfBunch = MakeLocalReconBunch();
888  else
889  _spill->OutOfBunch = MakeBunch();
890 
891  evt_prev = sEvt;
892 
893  while (sEvt==evt_prev && entry < _nentries){
894  // Create and fill a new bunch
895 
896  // First the Out of bunch stuff
897  if (Bunch==-1) {
898  FillBunchInfo(_spill->TrueParticles, _spill->OutOfBunch);
899  // Fill tracks->vertices and vertices->tracks with null pointers for tracks and vertices that are not in this bunch
900  // FillNotInBunchObjWithNullPointers(spill->OutOfBunch);
901  } else if (Bunch>-1){ // Bunch=-999 when the entry in the FlatTree is just for the Spill info,
902  // because there are no reconstructed tracks. We should skip this. Actual bunches are numbered: 0-7
903 
904  AnaBunch* bunch = NULL;
905  if (_isUsingReconDirTECAL || _isUsingReconDirPECAL || _isUsingReconDirFGDOnly || _isUsingReconDirP0D)
906  bunch = static_cast<AnaLocalReconBunch*>(MakeLocalReconBunch());
907  else
908  bunch = static_cast<AnaBunch*> (MakeBunch ());
909 
910  _spill->Bunches.push_back(bunch);
911  FillBunchInfo(_spill->TrueParticles, bunch);
912 
913  // Fill tracks->vertices and vertices->tracks with null pointers for tracks and vertices that are not in this bunch
914  // FillNotInBunchObjWithNullPointers(bunch);
915  }
916 
917  // Check that null pointers are still filled properly
918  // CheckNotInBunchObjWithNullPointers(_spill);
919 
920  // increment the entry number
921  entry++;
922 
923  // break if we have reach the maximum entry number
924  if (entry>=_nentries) break;
925 
926  // save the previous event number
927  evt_prev=sEvt;
928 
929  // get a new entry from the input tree
930  entry_temp = flattree->GetEntry(entry);
931  }
932 
933  return entry_temp;
934 }
935 
936 //*****************************************************************************
937 void FlatTreeConverter::FillInfo(AnaSpillB* spillB){
938 //*****************************************************************************
939 
940  RedoTreeConverter::FillInfo(spillB);
941 
942  AnaSpill* spill = static_cast<AnaSpill*>(spillB);
943 
944  AnaEventInfo& info = *static_cast<AnaEventInfo*>(spill->EventInfo);
945 
946  info.IsMC = sIsMC;
947  info.SubRun = sSubrun;
948  info.EventTime = sEventTime;
949 
950  if ( fNeut || fGenie) {
951  spill->InputFileIndex = _currentFileIndex;
952  spill->RooVtxEntry = _RooVtxEntryInCurrentInputFile;
953  }
954  else{
955  spill->InputFileIndex = sInputFileIndex;
956  spill->RooVtxEntry = sRooVtxEntry;
957  }
958 
959 
960  // Give the proper size to the TrueParticles vector for each TrueVertex.
961  // This can be done only after filling the general True Track vector (above) since is in this process
962  // when the TrueVertex <---> TrueParticle association is done
963  for (UInt_t i=0;i<spill->TrueVertices.size();i++){
964  anaUtils::ResizeArray(spill->TrueVertices[i]->TrueParticles, spill->TrueVertices[i]->nTrueParticles);
965  }
966 
967  // if RooTrackerVtx is not available fill the new NPrimaryParticles (used in Categories.cxx) using TrueParticles
968  if ( ! fNeut && ! fGenie) {
969  for (UInt_t i=0;i<spill->TrueVertices.size();i++){
970  AnaTrueVertex* vertex = static_cast<AnaTrueVertex*>(spill->TrueVertices[i]);
971  FillNPrimaryParticles(vertex);
972  }
973  }
974 
975 
976  FillTriggerInfo(&spill->Trigger);
977 
978 }
979 
980 //*****************************************************************************
981 void FlatTreeConverter::FillBunchInfo(std::vector<AnaTrueParticleB*>& trueParticles, AnaBunchB* bunchB){
982 //*****************************************************************************
983 
984  RedoTreeConverter::FillBunchInfo(trueParticles, bunchB);
985 
986  AnaBunch* bunch = static_cast<AnaBunch*>(bunchB);
987 
988  /// Is there AnaLocalReconBunch information to be filled?
989  if(_isUsingReconDirTECAL){
990  for (int i=0; i<tecalReconCounter; i++){
991  AnaTECALReconObject* anaTECAL = static_cast<AnaTECALReconObject*>(MakeTECALReconObject());
992  FillTECALReconObjectInfo(i,anaTECAL,bunch);
993  static_cast<AnaLocalReconBunch*>(bunchB)->TECALReconObjects.push_back(anaTECAL);
994  }
995  }
996 }
997 
998 //*****************************************************************************
999 void FlatTreeConverter::FillNotInBunchObjWithNullPointers(AnaBunch* bunch){
1000 //*****************************************************************************
1001 
1002  // Fill ReconParticles->ReconVertices (that should be already sorted) with NULL pointers for vertices not in this bunch
1003  for (int i=0; i<NParticles; i++) {
1004  AnaTrack* track = static_cast<AnaTrack*>(bunch->Particles.at(i));
1005  for (int j = track->ReconVertices.size(); j < trNReconVertices[i]; j++){
1006  track->ReconVertices.push_back(NULL);
1007  }
1008  if ( ! suppress_err_msg)
1009  if ((int)track->ReconVertices.size() != trNReconVertices[i])
1010  std::cout << "minor error 01011" << std::endl;
1011  }
1012 
1013  for (int i=0; i<NVertices; i++) {
1014 
1015  //Fill ReconVertices->ReconParticles (that should be already sorted as stored) with NULL pointers for vertices not in this bunch
1016  for (int j = bunch->Vertices.at(i)->nParticles; j < vNReconParticles[i]; j++)
1017  bunch->Vertices.at(i)->Particles[j] = NULL;
1018  if ( ! suppress_err_msg)
1019  if ((int)bunch->Vertices.at(i)->nParticles != vNReconParticles[i])
1020  std::cout << "minor error 01012" << std::endl;
1021 
1022  //Fill ReconVertices->TrueVertices (that should be already sorted as stored) with NULL pointers for vertices not in this bunch
1023  std::pair<AnaTrueVertex*, AnaRecTrueMatch> myMatch;
1024  myMatch.first = NULL;
1025  myMatch.second.Cleanliness = -999;
1026  myMatch.second.Completeness = -999;
1027  for (int j = bunch->Vertices.at(i)->TrueVerticesMatch.size(); j < vNTrueVerticesMatch[i]; j++)
1028  bunch->Vertices.at(i)->TrueVerticesMatch.push_back(myMatch);
1029  if ( ! suppress_err_msg)
1030  if ((int)bunch->Vertices.at(i)->TrueVerticesMatch.size() != vNTrueVerticesMatch[i])
1031  std::cout<<"minor error 01013"<<std::endl;
1032 
1033  }
1034 }
1035 
1036 //*****************************************************************************
1037 void FlatTreeConverter::FillNotInBunchObjWithNullPointers(AnaSpill* spill){
1038 //*****************************************************************************
1039 
1040  // Fill TrueParticles->ReconTracks with NULL pointers for tracks not in this bunch
1041  for (int i=0; i<(int) spill->TrueParticles.size(); i++) {
1042  for (int j = 0; j < sTrueParticleNReconTracks[i] ; j++) static_cast<AnaTrueParticle*>(spill->TrueParticles.at(i))->ReconParticles.push_back(NULL);
1043  }
1044 
1045  // Fill TrueVertices->ReconTracks and TrueVertices->ReconVertex with NULL pointers for tracks/vertices not in this bunch
1046  for (int i=0; i<(int) spill->TrueVertices.size(); i++) {
1047  AnaTrueVertex* vertex = static_cast<AnaTrueVertex*>(spill->TrueVertices.at(i));
1048  for (int j = 0; j < sTrueVertexNReconVertices[i] ; j++) vertex->ReconVertices.push_back(NULL);
1049  for (int j = 0; j < sTrueVertexNReconTracks[i] ; j++) vertex->ReconParticles.push_back(NULL);
1050  }
1051 }
1052 
1053 //*****************************************************************************
1054 void FlatTreeConverter::CheckNotInBunchObjWithNullPointers(AnaSpill* spill){
1055 //*****************************************************************************
1056 
1057  // Check TrueParticles->ReconTracks NULL pointers for tracks not in this bunch
1058  for (int i=0; i<(int) spill->TrueParticles.size(); i++) {
1059  AnaTrueParticle* thistrueobj = static_cast<AnaTrueParticle*>(spill->TrueParticles.at(i));
1060  if ( ! suppress_err_msg)
1061  if ((int)thistrueobj->ReconParticles.size() != sTrueParticleNReconTracks[i])
1062  std::cout << "minor error 0102" << std::endl;
1063  }
1064 
1065  // Check TrueVertices->ReconParticles and TrueVertices->ReconVertex NULL pointers for tracks/vertices not in this bunch
1066  for (int i=0; i<(int) spill->TrueVertices.size(); i++) {
1067  AnaTrueVertex* thistrueobj = static_cast<AnaTrueVertex*>(spill->TrueVertices.at(i));
1068  if ( ! suppress_err_msg){
1069  if ((int)thistrueobj->ReconVertices.size() != sTrueVertexNReconVertices[i])
1070  std::cout << "minor error 0103" << std::endl;
1071  if ((int)thistrueobj->ReconParticles.size() != sTrueVertexNReconTracks[i])
1072  std::cout << "minor error 0104" << std::endl;
1073  }
1074  }
1075 }
1076 
1077 //*****************************************************************************
1078 void FlatTreeConverter::FillFgdTimeBinInfo(std::vector<AnaFgdTimeBinB*>& FgdTimeBins){
1079 //*****************************************************************************
1080 
1081  RedoTreeConverter::FillFgdTimeBinInfo(FgdTimeBins);
1082 
1083  //loop over fgd time bins
1084  for(UInt_t ibin=0; ibin<FgdTimeBins.size(); ibin++) {
1085 
1086  AnaFgdTimeBin* abin = static_cast<AnaFgdTimeBin*>(FgdTimeBins[ibin]);
1087 
1088  abin->MaxTime = sFgdTimeBinMaxTime[ibin];
1089  abin->G4ID = sFgdTimeBinG4ID[ibin];
1090  }
1091 }
1092 
1093 //*****************************************************************************
1094 void FlatTreeConverter::FillDQInfo(AnaDataQualityB* dqB){
1095 //*****************************************************************************
1096 
1097  RedoTreeConverter::FillDQInfo(dqB);
1098 
1099  AnaDataQuality* dq = static_cast<AnaDataQuality*>(dqB);
1100 
1101  dq->GoodDaq = sDQGoodDaq;
1102  dq->ND280Flag = sDQND280Flag;
1103 
1104  for (int i=0;i<7;i++)
1105  dq->DetFlag[i] = sDQDetFlag[i];
1106 }
1107 
1108 //*****************************************************************************
1109 void FlatTreeConverter::FillBeamInfo(AnaBeamB* beamB){
1110 //*****************************************************************************
1111 
1112  RedoTreeConverter::FillBeamInfo(beamB);
1113 
1114  AnaBeam* beam = static_cast<AnaBeam*>(beamB);
1115 
1116  beam->SpillNumber = sBeamSpillNumber;
1117  beam->Spill = sBeamSpill;
1118  beam->GoodSpill = sBeamGoodSpill;
1119  beam->POT = sBeamPOT;
1120 #if !VERSION_HAS_OFFICIAL_POT
1121  beam->POTCT4 = sBeamPOTCT4;
1122 #endif
1123  beam->BeamRunNumber = sBeamBeamRunNumber;
1124 }
1125 
1126 //*****************************************************************************
1127 void FlatTreeConverter::FillTriggerInfo(AnaTrigger* trigger){
1128 //*****************************************************************************
1129 
1130  trigger->FGDCosmic = sTriggerFGDCosmic;
1131  trigger->TripTCosmic = sTriggerTripTCosmic;
1132 }
1133 
1134 //*****************************************************************************
1135 void FlatTreeConverter::FillTrackInfo(std::vector<AnaTrueParticleB*>& trueParticles, int itrk, AnaTrackB* trackB){
1136 //*****************************************************************************
1137 
1138  RedoTreeConverter::FillTrackInfo(trueParticles,itrk,trackB);
1139 
1140  AnaTrack* track = static_cast<AnaTrack*>(trackB);
1141 
1142  track->Status = (trStatus)[itrk];
1143  track->ReconPDG = (trReconPDG)[itrk];
1144  track->Bunch = (trBunch)[itrk];
1145  track->Detectors = (trDetectors)[itrk];
1146  track->NDOF = (trNDOF)[itrk];
1147  track->Chi2 = (trChi2)[itrk];
1148  track->Charge = (trCharge)[itrk];
1149  track->MomentumError = (trMomentumError)[itrk];
1150  track->MomentumMuon = (trMomentumMuon)[itrk];
1151  track->MomentumErrorMuon = (trMomentumErrorMuon)[itrk];
1152  track->MomentumProton = (trMomentumProton)[itrk];
1153  track->MomentumErrorProton = (trMomentumErrorProton)[itrk];
1154  track->MomentumEle = (trMomentumEle)[itrk];
1155  track->MomentumErrorEle = (trMomentumErrorEle)[itrk];
1156  track->Length = (trLength)[itrk];
1157 
1158 #if VERSION_HAS_REVERSED_REFITS
1159  anaUtils::CopyArray(trDirectionStartFlip[itrk], track->DirectionStartFlip, 3);
1160  anaUtils::CopyArray(trDirectionEndFlip[itrk], track->DirectionEndFlip, 3);
1161 #endif
1162 
1163 #if VERSION_HAS_PRANGE_ESTIMATES
1164  track->RangeMomentumEle = (trRangeMomentumEle)[itrk];
1165  track->RangeMomentumProton = (trRangeMomentumProton)[itrk];
1166  track->RangeMomentumMuonFlip = (trRangeMomentumMuonFlip)[itrk];
1167  track->RangeMomentumProtonFlip = (trRangeMomentumProtonFlip)[itrk];
1168 #endif
1169 
1170  track->MomentumAtVertex = (trMomentumAtVertex)[itrk];
1171  anaUtils::CopyArray(trDirectionAtVertex[itrk], track->DirectionAtVertex, 3);
1172 
1173 
1174 #if VERSION_HAS_TIME_FITS
1175  if(trNTimeNodes[itrk]>0){
1176  for (Int_t i=0;i<trNTimeNodes[itrk];i++){
1177 
1178  AnaTimeNode* node = new AnaTimeNode();
1179 
1180  node->Detector = trTimeNodeDetector[itrk][i];
1181  node->TimeStart = trTimeNodeTimeStart[itrk][i];
1182  node->TimeEnd = trTimeNodeTimeEnd[itrk][i];
1183 
1184  track->TimeNodes.push_back(node);
1185  }
1186  }
1187 
1188 #endif
1189 
1190  // Save all recon tracks associated to this true track
1191  if (track->TrueObject){
1192  AnaTrueParticle* thistrueobj = static_cast<AnaTrueParticle*>(track->TrueObject);
1193 
1194  // Vectors are already filled with null pointers --> fill, remove last one (that should be null) and sort
1195  thistrueobj->ReconParticles.insert(thistrueobj->ReconParticles.begin(),track);
1196 
1197  if ( ! suppress_err_msg)
1198  if (thistrueobj->ReconParticles.back())
1199  std::cout << "minor error 73731" << std::endl;
1200  if ( ! thistrueobj->ReconParticles.back()) thistrueobj->ReconParticles.pop_back();
1201  // sort here to keep handle associations from different bunches
1202 // std::sort(thistrueobj->ReconParticles.begin(), thistrueobj->ReconParticles.end(), AnaTrack::CompareMomentum);
1203 
1204  // Save all recon tracks associated to this true vertex
1205  if (track->GetTrueParticle()->TrueVertex){
1206  AnaTrueVertex* thistrueobj = static_cast<AnaTrueVertex*>(track->GetTrueParticle()->TrueVertex);
1207 
1208  // Vectors are already filled with null pointers --> fill, remove last one (that should be null) and sort
1209  thistrueobj->ReconParticles.insert(thistrueobj->ReconParticles.begin(),track);
1210  if ( ! suppress_err_msg)
1211  if (thistrueobj->ReconParticles.back())
1212  std::cout << "minor error 73741" << std::endl;
1213  if ( ! thistrueobj->ReconParticles.back()) thistrueobj->ReconParticles.pop_back();
1214  // sort here to keep handle associations from different bunches
1215 // std::sort(thistrueobj->ReconParticles.begin(), thistrueobj->ReconParticles.end(), AnaTrack::CompareMomentum);
1216  }
1217  }
1218 }
1219 //*****************************************************************************
1220 void FlatTreeConverter::FillSubdetectorInfo(std::vector<AnaTrueParticleB*>& trueParticles, int itrk, AnaTrackB* trackB){
1221 //*****************************************************************************
1222 
1223  RedoTreeConverter::FillSubdetectorInfo(trueParticles,itrk,trackB);
1224 
1225  AnaTrack* track = static_cast<AnaTrack*>(trackB);
1226 
1227  track->nSMRDSegments = 0;
1228  track->nP0DSegments = 0;
1229 
1230  for (int i = 0; i < SubDetId::kInvalidSubdetector; ++i){
1231  SubDetId::SubDetEnum idet = static_cast<SubDetId::SubDetEnum>(i);
1232  if(!SubDetId::GetDetectorUsed(track->Detector, idet)) continue;
1233  if(SubDetId::IsP0DDetector(idet)){
1234  if (track->nP0DSegments==(int)NMAXP0DS)
1235  continue;
1236  AnaP0DParticle* seg = static_cast<AnaP0DParticle*>(MakeP0dTrack());
1237  int p0d = 0;
1238  FillP0dInfo(itrk, p0d, seg);
1239  track->P0DSegments[track->nP0DSegments++] = seg;
1240  }
1241  else if(SubDetId::IsSMRDDetector(idet)){
1242  if (track->nSMRDSegments==(int)NMAXSMRDS)
1243  continue;
1244  AnaSMRDParticle* seg = static_cast<AnaSMRDParticle*>(MakeSmrdTrack());
1245  int smrd = convUtils::GetLocalDetEnum(SubDetId::kSMRD, idet);
1246  FillSmrdInfo(itrk, smrd, seg);
1247  track->SMRDSegments[track->nSMRDSegments++] = seg;
1248  }
1249  }
1250 
1251  int nTracker = std::min(trNTRACKERs[itrk], (int)NMAXTRACKERS);
1252  for (int j=0;j<nTracker;j++){
1253  AnaTrackerTrack* seg = static_cast<AnaTrackerTrack*>(MakeTrackerTrack());
1254  FillTrackerInfo(itrk, j, seg);
1255  track->TRACKERSegments.push_back(seg);
1256  }
1257 
1258 
1259 }
1260 
1261 //*****************************************************************************
1262 void FlatTreeConverter::FillTpcInfo(std::vector<AnaTrueParticleB*>& trueParticles, int itrk, int tpc, AnaTPCParticleB* segB){
1263 //*****************************************************************************
1264 
1265  RedoTreeConverter::FillTpcInfo(trueParticles,itrk, tpc, segB);
1266 
1267  AnaTPCParticle* seg = static_cast<AnaTPCParticle*>(segB);
1268 
1269  seg->NHits = (int)(trTpcNHits)[itrk][tpc];
1270  seg->UniqueID = (int)(trTpcUniqueID)[itrk][tpc];
1271  seg->MomentumEnd = (trTpcBackMomentum)[itrk][tpc];
1272  seg->Length = (trTpcLength)[itrk][tpc];
1273 
1274 #if VERSION_HAS_BFIELD_REFIT
1275  seg->RefitMomentum = (trTpcRefitMomentum)[itrk][tpc];
1276 #endif
1277 #if VERSION_HAS_BFIELD_REFIT_FULL
1278  seg->RefitCharge = (trTpcRefitCharge)[itrk][tpc];
1279  anaUtils::VectorToArray(TLorentzVector((trTpcRefitPosition)[itrk][tpc][0],
1280  (trTpcRefitPosition)[itrk][tpc][1],
1281  (trTpcRefitPosition)[itrk][tpc][2],
1282  (trTpcRefitPosition)[itrk][tpc][3]), seg->RefitPosition);
1283  anaUtils::VectorToArray(TVector3((trTpcRefitDirection)[itrk][tpc][0],
1284  (trTpcRefitDirection)[itrk][tpc][1],
1285  (trTpcRefitDirection)[itrk][tpc][2]), seg->RefitDirection);
1286 #endif
1287 #if VERSION_HAS_EFIELD_REFIT
1288  seg->EFieldRefitMomentum = (trTpcEFieldRefitMomentum)[itrk][tpc];
1289 #endif
1290 
1291  seg->Pullmu = (trTpcPullmu)[itrk][tpc];
1292  seg->Pullele = (trTpcPullele)[itrk][tpc];
1293  seg->Pullp = (trTpcPullp)[itrk][tpc];
1294  seg->Pullpi = (trTpcPullpi)[itrk][tpc];
1295  seg->Pullk = (trTpcPullk)[itrk][tpc];
1296 
1297  if(_useCorrectedValues){
1298  seg->dEdxMeas = (trTpcdEdxMeas)[itrk][tpc];
1299  seg->dEdxexpMuon = (trTpcdEdxExpMu)[itrk][tpc];
1300  seg->dEdxexpEle = (trTpcdEdxExpEle)[itrk][tpc];
1301  seg->dEdxexpProton = (trTpcdEdxExpP)[itrk][tpc];
1302  seg->dEdxexpPion = (trTpcdEdxExpPi)[itrk][tpc];
1303  seg->dEdxexpKaon = (trTpcdEdxExpK)[itrk][tpc];
1304  }
1305  else{
1306  seg->dEdxMeas = (trTpcRawdEdxMeas)[itrk][tpc];
1307  seg->dEdxexpMuon = (trTpcRawdEdxExpMu)[itrk][tpc];
1308  seg->dEdxexpEle = (trTpcRawdEdxExpEle)[itrk][tpc];
1309  seg->dEdxexpProton = (trTpcRawdEdxExpP)[itrk][tpc];
1310  seg->dEdxexpPion = (trTpcRawdEdxExpPi)[itrk][tpc];
1311  seg->dEdxexpKaon = (trTpcRawdEdxExpK)[itrk][tpc];
1312  }
1313 
1314  seg->dEdxSigmaKaon = (trTpcdEdxSigmaK)[itrk][tpc];
1315 
1316  seg->Purity = (trTpcPurity)[itrk][tpc];
1317 
1318 
1319  for (int i=0;i<3;i++){
1320  seg->DirectionEnd[i] = (trTpcDirectionEnd)[itrk][tpc][i];
1321  }
1322 }
1323 
1324 //*****************************************************************************
1325 void FlatTreeConverter::FillFgdInfo(int itrk, int fgd, AnaFGDParticleB* segB){
1326 //*****************************************************************************
1327 
1328  RedoTreeConverter::FillFgdInfo(itrk, fgd, segB);
1329 
1330  AnaFGDParticle* seg = static_cast<AnaFGDParticle*>(segB);
1331 
1332  seg->NHits = (int)(trFgdNHits)[itrk][fgd];
1333  seg->UniqueID = (int)(trFgdUniqueID)[itrk][fgd];
1334  seg->Length = (trFgdLength)[itrk][fgd];
1335 
1336  seg->E = (trFgdE)[itrk][fgd];
1337 
1338  seg->AvgTime = (trFgdAvgTime)[itrk][fgd];
1339 
1340 #if VERSION_HAS_FGD_VERTEX_AND_END_ACTIVITY
1341  seg->HasFgdVA = (trFgdHasFgdVA)[itrk][fgd];
1342  seg->HasFgdVA_fmode = (trFgdHasFgdVA_fmode)[itrk][fgd];
1343  seg->TypeVA = (trFgdTypeVA)[itrk][fgd];
1344 #endif
1345 
1346  seg->Vertex1x1 = (trFgdVertex1x1)[itrk][fgd];
1347  seg->Vertex3x3 = (trFgdVertex3x3)[itrk][fgd];
1348  seg->Vertex5x5 = (trFgdVertex5x5)[itrk][fgd];
1349  seg->Vertex7x7 = (trFgdVertex7x7)[itrk][fgd];
1350  seg->VertexLayer = (trFgdVertexLayer)[itrk][fgd];
1351 
1352 #if VERSION_HAS_FGD_VERTEX_AND_END_ACTIVITY
1353  seg->HasFgdEA = (trFgdHasFgdEA)[itrk][fgd];
1354  seg->HasFgdEA_fmode = (trFgdHasFgdEA_fmode)[itrk][fgd];
1355  seg->TypeEA = (trFgdTypeEA)[itrk][fgd];
1356 
1357  seg->End0x0 = (trFgdEnd0x0)[itrk][fgd];
1358  seg->End1x1 = (trFgdEnd1x1)[itrk][fgd];
1359  seg->End3x3 = (trFgdEnd3x3)[itrk][fgd];
1360  seg->End5x5 = (trFgdEnd5x5)[itrk][fgd];
1361  seg->End7x7 = (trFgdEnd7x7)[itrk][fgd];
1362 #endif
1363 
1364  for (int i=0;i<3;i++){
1365  seg->DirectionEnd[i] = (trFgdDirectionEnd)[itrk][fgd][i];
1366  }
1367 }
1368 
1369 //*****************************************************************************
1370 void FlatTreeConverter::FillEcalInfo(int itrk, int ecal, AnaECALParticleB* segB){
1371 //*****************************************************************************
1372 
1373  RedoTreeConverter::FillEcalInfo(itrk, ecal, segB);
1374 
1375  AnaECALParticle* seg = static_cast<AnaECALParticle*>(segB);
1376 
1377  seg->NHits = (int)(trECALNHits)[itrk][ecal];
1378  seg->UniqueID = (int)(trECALUniqueID)[itrk][ecal];
1379  seg->PIDMipPion = trECALPIDMipPion[itrk][ecal];
1380  seg->Containment = trECALContainment[itrk][ecal];
1381  seg->EDeposit = (trECALEDeposit)[itrk][ecal];
1382  seg->IsShowerLike = (int)(trECALIsShowerLike)[itrk][ecal];
1383  seg->AvgTime = (int)(trECALAvgTime)[itrk][ecal];
1384 
1385  for (int i = 0; i < 4; i++){
1386  seg->PositionStart[i] = (trECALPositionStart)[itrk][ecal][i];
1387  seg->PositionEnd[i] = (trECALPositionEnd)[itrk][ecal][i];
1388  }
1389 
1390  for (int i = 0; i < 3; i++){
1391  seg->DirectionStart[i] = (trECALDirectionStart)[itrk][ecal][i];
1392  seg->DirectionEnd[i] = (trECALDirectionEnd)[itrk][ecal][i];
1393  }
1394 
1395 }
1396 
1397 //*****************************************************************************
1398 void FlatTreeConverter::FillSmrdInfo(int itrk, int smrd, AnaSMRDParticleB* segB){
1399 //*****************************************************************************
1400 
1401  RedoTreeConverter::FillSmrdInfo(itrk, smrd, segB);
1402 
1403  AnaSMRDParticle* seg = static_cast<AnaSMRDParticle*>(segB);
1404 
1405  seg->NHits = (int)(trSMRDNHits)[itrk][smrd];
1406  seg->NNodes = (int)(trSMRDNNodes)[itrk][smrd];
1407  seg->UniqueID = (int)(trSMRDUniqueID)[itrk][smrd];
1408  seg->Length = (trSMRDLength)[itrk][smrd];
1409 
1410  seg->EDeposit = (trSMRDEDeposit)[itrk][smrd];
1411 
1412  for (int i=0;i<3;i++){
1413  seg->DirectionEnd[i] = (trSMRDDirectionEnd)[itrk][smrd][i];
1414  }
1415 }
1416 
1417 //*****************************************************************************
1418 void FlatTreeConverter::FillP0dInfo(int itrk, int p0d, AnaP0DParticleB* segB){
1419 //*****************************************************************************
1420 
1421  RedoTreeConverter::FillP0dInfo(itrk, p0d, segB);
1422 
1423  AnaP0DParticle* seg = static_cast<AnaP0DParticle*>(segB);
1424 
1425  seg->NHits = (int)(trP0DNHits)[itrk][p0d];
1426  seg->NNodes = (int)(trP0DNNodes)[itrk][p0d];
1427  seg->UniqueID = (int)(trP0DUniqueID)[itrk][p0d];
1428  seg->Length = (trP0DLength)[itrk][p0d];
1429 
1430  for (int i=0;i<3;i++){
1431  seg->DirectionEnd[i] = (trP0DDirectionEnd)[itrk][p0d][i];
1432  }
1433 
1434 
1435 #if VERSION_HAS_P0D_AVERAGED_TIME
1436  seg->AvgTime = (trP0DAvgTime)[itrk][p0d];
1437 #endif
1438 
1439 }
1440 
1441 //*****************************************************************************
1442 void FlatTreeConverter::FillTrackerInfo(int itrk, int tracker, AnaTrackerTrack* seg){
1443 //*****************************************************************************
1444 
1445  convUtils::ConvertTrackerDetEnumToBitField(seg->Detector, (trTRACKERDetector)[itrk][tracker]);
1446 
1447  seg->NHits = (int)(trTRACKERNHits)[itrk][tracker];
1448  seg->NNodes = (int)(trTRACKERNNodes)[itrk][tracker];
1449  seg->UniqueID = (int)(trTRACKERUniqueID)[itrk][tracker];
1450  seg->Length = (trTRACKERLength)[itrk][tracker];
1451  seg->Charge = (trTRACKERCharge)[itrk][tracker];
1452  seg->Momentum = (trTRACKERMomentum)[itrk][tracker];
1453  seg->MomentumEnd = (trTRACKERMomentumEnd)[itrk][tracker];
1454 
1455  for (int i=0;i<4;i++){
1456  seg->PositionStart[i] = (trTRACKERPositionStart)[itrk][tracker][i];
1457  seg->PositionEnd[i] = (trTRACKERPositionEnd)[itrk][tracker][i];
1458  }
1459 
1460  for (int i=0;i<3;i++){
1461  seg->DirectionStart[i] = (trTRACKERDirectionStart)[itrk][tracker][i];
1462  seg->DirectionEnd[i] = (trTRACKERDirectionEnd)[itrk][tracker][i];
1463  }
1464 }
1465 
1466 //*****************************************************************************
1467 void FlatTreeConverter::FillTrueParticleInfo(std::vector<AnaTrueVertexB*>& trueVertices, int itrk, AnaTrueParticleB* partB){
1468 //*****************************************************************************
1469 
1470  RedoTreeConverter::FillTrueParticleInfo(trueVertices,itrk,partB);
1471 
1472  AnaTrueParticle* part = static_cast<AnaTrueParticle*>(partB);
1473 
1474  part->Purity = (sTrueParticlePurity)[itrk];
1475  part->Bunch = (sTrueParticleBunch)[itrk];
1476  part->PrimaryID = (sTrueParticlePrimaryID)[itrk];
1477  part->ParentID = (sTrueParticleParentID)[itrk];
1478 
1479  part->IsTruePrimaryPi0DecayPhoton = (sTrueParticleIsTruePrimaryPi0DecayPhoton)[itrk];
1480  part->IsTruePrimaryPi0DecayPhotonChild = (sTrueParticleIsTruePrimaryPi0DecayPhotonChild)[itrk];
1481 
1482  for(Int_t i=0;i<part->nDetCrossings;i++){
1483  AnaDetCrossingB* cross = part->DetCrossings[i];
1484  anaUtils::CopyArray(sTrueParticleEntranceMomentum[itrk][i], cross->EntranceMomentum, 3);
1485  anaUtils::CopyArray(sTrueParticleExitMomentum[itrk][i], cross->ExitMomentum, 3);
1486  }
1487 
1488  part->VertexIndex = (sTrueParticleVertexIndex)[itrk];
1489 
1490 
1491  // TODO: Use the same code as in psyche for the moment. This is however not optimised since we loop over all vertices again
1492  // this was already done in oaAnalysisTreeConverter to create the FlatTree
1493  // The code below is supposed to be warking
1494 
1495  /*
1496  int nMaxTrueParticles = (int)(anaUtils::size_array(part->TrueVertex->TrueParticles));
1497 
1498  if (part->VertexIndex>-1 && part->VertexIndex<(int)(_spill->TrueVertices.size())){
1499 
1500  if(_spill->TrueVertices[part->VertexIndex]){
1501  // Get the true vertex associated to this part
1502  part->TrueVertex = _spill->TrueVertices[part->VertexIndex];
1503 
1504  if(part->TrueVertex->nTrueParticles<nMaxTrueParticles)
1505  // add this part to the list of true parts in the true vertex
1506  part->TrueVertex->TrueParticles[part->TrueVertex->nTrueParticles++] = part;
1507  }
1508 
1509  } else if (part->VertexIndex!=-1)
1510  if ( ! suppress_err_msg) std::cout << "minor error 6543" << std::endl;
1511  */
1512 
1513 }
1514 
1515 //*****************************************************************************
1516 void FlatTreeConverter::FillTrueVertexInfo(int ivtx, AnaTrueVertexB* vertexB){
1517 //*****************************************************************************
1518 
1519  RedoTreeConverter::FillTrueVertexInfo(ivtx,vertexB);
1520 
1521  AnaTrueVertex* vertex = static_cast<AnaTrueVertex*>(vertexB);
1522 
1523  vertex->RooVtxEntry = _RooVtxEntryInCurrentInputFile;
1524 
1525  vertex->ReacCode = (sTrueVertexReacCode)[ivtx];
1526 
1527  anaUtils::CopyArray(sTrueVertexPosition[ivtx], vertex->Position, 4);
1528 
1529  vertex->Q2 = (sTrueVertexQ2)[ivtx];
1530  vertex->NuEnergy = (sTrueVertexNuEnergy)[ivtx];
1531 
1532  anaUtils::CopyArray(sTrueVertexNuDir[ivtx], vertex->NuDir, 3);
1533  anaUtils::CopyArray(sTrueVertexLeptonDir[ivtx], vertex->LeptonDir, 3);
1534  anaUtils::CopyArray(sTrueVertexPionDir[ivtx], vertex->PionDir, 3);
1535  anaUtils::CopyArray(sTrueVertexTargetDir[ivtx], vertex->TargetDir, 3);
1536  anaUtils::CopyArray(sTrueVertexProtonDir[ivtx], vertex->ProtonDir, 3);
1537 
1538  vertex->NuParentPDG = sTrueVertexNuParentPDG[ivtx];
1539 
1540  anaUtils::CopyArray(sTrueVertexNuParentDecPoint[ivtx], vertex->NuParentDecPoint, 3);
1541 
1542  vertex->NuPDG = (sTrueVertexNuPDG)[ivtx];
1543  vertex->TargetPDG = (sTrueVertexTargetPDG)[ivtx];
1544  vertex->LeptonPDG = (sTrueVertexLeptonPDG)[ivtx];
1545  vertex->LeptonMom = sTrueVertexLeptonMom[ivtx];
1546  vertex->ProtonMom = sTrueVertexProtonMom[ivtx];
1547  vertex->PionMom = sTrueVertexPionMom[ivtx];
1548  vertex->TargetMom = sTrueVertexTargetMom[ivtx];
1549 
1550 
1551  vertex->Detector = (sTrueVertexDetector)[ivtx];
1552  vertex->NBaryons = sTrueVertexNBaryons[ivtx];
1553  vertex->Bunch = sTrueVertexBunch[ivtx];
1554 
1555  vertex->RooVtxIndex = sTrueVertexRooVtxIndex[ivtx];
1556  vertex->RooVtxEntry = sTrueVertexRooVtxEntry[ivtx];
1557  vertex->ID = sTrueVertexID[ivtx];
1558 
1559  // will be updated in FillTrueParticleInfo
1560  anaUtils::CreateArray(vertex->TrueParticles, sNTrueParticles);
1561  vertex->nTrueParticles = 0;
1562 
1563  vertex->IsPauliBlocked = sTrueVertexIsPauliBlocked[ivtx];
1564  vertex->IsCohOnH = sTrueVertexIsCohOnH[ivtx];
1565 
1566  for (int j = 0; j < Int_t(ParticleId::kLast)+1; j++) {
1567  vertex->NPrimaryParticles[j] = sTrueVertexNPrimaryParticles[ivtx][j];
1568  }
1569 }
1570 
1571 //*****************************************************************************
1572 bool FlatTreeConverter::FillTrueVertexRooInfo(AnaTrueVertexB* vertexB) {
1573 //*****************************************************************************
1574 
1575  // Don't recompute RooTrackerVtx derived variables, when:
1576  // 1. We don't read the input RooTrackerVtx,
1577  // 2. When all variables are already available in the FlatTree and we don't want to recompute them from the input RooTrackerVtx
1578  // Note that with flattrees produced with highland2 v0 these vars were slighty wrong and should be recomputed
1579 
1580  if (!_readRooTrackerVtx || (fChain->FindLeaf("sTrueVertexIsPauliBlocked"))) return true;
1581 
1582  bool foundCohOnH,foundPauliBlocked;
1583  return anaUtils::FillTrueVertexRooInfo(vertexB,RunID,fNeut,fGenie,NNVtx,NVtx,NGVtx,GVtx,foundCohOnH,foundPauliBlocked);
1584 }
1585 
1586 //*****************************************************************************
1587 void FlatTreeConverter::FillNPrimaryParticles(AnaTrueVertex* vertex){
1588 //*****************************************************************************
1589 
1590  // if RooTrackerVtx is not available fill the new NPrimaryParticles (used in Categories.cxx) using TrueParticles
1591 
1592  for (int i = 0; i<vertex->nTrueParticles; i++) {
1593  AnaTrueParticleB* trueTrack = vertex->TrueParticles[i];
1594 
1595  if(!trueTrack) continue;
1596 
1597  if(trueTrack->ParentPDG != 0) continue; //should correspond to the primary vertex
1598 
1599  int index = ParticleId::GetParticle(trueTrack->PDG,false);
1600  vertex->NPrimaryParticles[index]++;
1601  if (abs(trueTrack->PDG) > 1000 && abs(trueTrack->PDG) < 10000) vertex->NPrimaryParticles[ParticleId::kBaryons]++;
1602  if (abs(trueTrack->PDG) > 100 && abs(trueTrack->PDG) < 1000) vertex->NPrimaryParticles[ParticleId::kMesons]++;
1603  if (abs(trueTrack->PDG) > 10 && abs(trueTrack->PDG) < 19) vertex->NPrimaryParticles[ParticleId::kLeptons]++;
1604  if (trueTrack->PDG == +12 || trueTrack->PDG == +14 || trueTrack->PDG == +16) vertex->NPrimaryParticles[ParticleId::kNeutrinos]++;
1605  if (trueTrack->PDG == -12 || trueTrack->PDG == -14 || trueTrack->PDG == -16) vertex->NPrimaryParticles[ParticleId::kAntiNeutrinos]++;
1606 
1607  } // end loop over vertex->TrueParticles
1608 
1609  // Fill NPrimaryParticles for kPions and Kaons
1610  vertex->NPrimaryParticles[ParticleId::kPions] = vertex->NPrimaryParticles[ParticleId::kPi0] +
1611  vertex->NPrimaryParticles[ParticleId::kPiPos] +
1612  vertex->NPrimaryParticles[ParticleId::kPiNeg] ;
1613  vertex->NPrimaryParticles[ParticleId::kKaons] = vertex->NPrimaryParticles[ParticleId::kK0] +
1614  vertex->NPrimaryParticles[ParticleId::kAntiK0] +
1615  vertex->NPrimaryParticles[ParticleId::kK0L] +
1616  vertex->NPrimaryParticles[ParticleId::kK0S] +
1617  vertex->NPrimaryParticles[ParticleId::kKPos] +
1618  vertex->NPrimaryParticles[ParticleId::kKNeg] ;
1619 
1620 }
1621 
1622 
1623 // // NOT USED
1624 // //*****************************************************************************
1625 // int FlatTreeConverter::FindTrueVertex(int ID, AnaTrueVertex*& trueVertex){
1626 // //*****************************************************************************
1627 
1628 // // Compare the IDs to find the AnaTrueVertex associated with this recon particle.
1629 
1630 // trueVertex = NULL;
1631 // int index=0;
1632 // std::vector<AnaTrueVertex*>::iterator it;
1633 // for (it = _spill->TrueVertices.begin(); it!=_spill->TrueVertices.end();it++){
1634 // AnaTrueVertex* trueVertex2 = *it;
1635 // if (ID == trueVertex2->ID){
1636 // trueVertex = trueVertex2;
1637 // return index;
1638 // }
1639 // index++;
1640 // }
1641 // return -1;
1642 // }
1643 
1644 
1645 //*****************************************************************************
1646 void FlatTreeConverter::FillVertexInfo(int ivtx, AnaVertexB* vertexB, AnaBunchB* bunch){
1647 //*****************************************************************************
1648 
1649  RedoTreeConverter::FillVertexInfo(ivtx, vertexB, bunch);
1650 
1651  AnaVertex* vertex = static_cast<AnaVertex*>(vertexB);
1652 
1653  anaUtils::CopyArray(vVariance[ivtx], vertex->Variance, 4);
1654 
1655  vertex->Chi2 = (vChi2)[ivtx];
1656  vertex->NDOF = (vNDOF)[ivtx];
1657 
1658  // Find AnaTrack associated with this global vertex
1659  vertex->nParticles=0;
1660 
1661  anaUtils::CreateArray(vertex->Particles, vNReconParticles[ivtx]);
1662 
1663  for (int d = 0; d < vNReconParticles[ivtx]; d++) {
1664  AnaParticle* part = static_cast<AnaParticle*>(FindParticle(vParticlesUniqueID[ivtx][d], bunch));
1665  if ( ! part) continue;
1666 
1667  // fill only if in this bunch, should be already sorted in flat tree, then null pointers will be added at the end
1668  if (part->Bunch != Bunch) continue;
1669  vertex->Particles[vertex->nParticles] = part;
1670  vertex->nParticles++;
1671 
1672  // Save vertices info in AnaTrack
1673  part->ReconVertices.push_back(vertex);
1674 
1675  // choose the vertex more primary (in this bunch)
1676  if ( ! part->ReconVertex || part->ReconVertex->PrimaryIndex > vertex->PrimaryIndex)
1677  part->ReconVertex = vertex;
1678  }
1679 
1680  // Find true vertices associated with this global vertex (by index)
1681  for (int d = 0; d < vNTrueVerticesMatch[ivtx]; d++) {
1682  std::pair<AnaTrueVertex*, AnaRecTrueMatch> myMatch;
1683  int thisTrueVertexIndex = vTrueVertexIndex[ivtx][d];
1684  if (thisTrueVertexIndex == -1) continue;
1685  if (thisTrueVertexIndex < -1) {
1686  if(_spill->TrueVertices.size() == NMAXTRUEVERTICES)
1687  std::cout << "The true vertex associated to this global vertex was not saved because NTrueVertices > NMAXTRUEVERTICES" << std::endl;
1688  else
1689  std::cout << "global vertex error 6789" << std::endl;
1690  continue;
1691  }
1692 
1693  myMatch.first = static_cast<AnaTrueVertex*>(_spill->TrueVertices.at(thisTrueVertexIndex));
1694  myMatch.second.Cleanliness = (vTrueVerticesClean)[ivtx][d];
1695  myMatch.second.Completeness = (vTrueVerticesCompl)[ivtx][d];
1696  vertex->TrueVerticesMatch.push_back(myMatch);
1697 
1698  // Vectors are already filled with null pointers --> fill, remove last one (that should be null) and sort
1699  myMatch.first->ReconVertices.insert(myMatch.first->ReconVertices.begin(),vertex);
1700  if ( ! suppress_err_msg)
1701  if (myMatch.first->ReconVertices.back())
1702  std::cout << "minor error 73751" << std::endl;
1703  if ( ! myMatch.first->ReconVertices.back()) myMatch.first->ReconVertices.pop_back();
1704  // sort here to keep handle associations from different bunches
1705  std::sort(myMatch.first->ReconVertices.begin(), myMatch.first->ReconVertices.end(), AnaVertex::ComparePrimaryIndex);
1706  }
1707 
1708  // Let's keep also vertex->TrueVertex by now (the user could just called GetMainTrueVertex instead)
1709  vertex->TrueVertex = vertex->GetMainTrueVertex(false); // argument false to suppress warnings
1710 }
1711 
1712 //*****************************************************************************
1713 AnaParticleB* FlatTreeConverter::FindParticle(int ID, AnaBunchB* bunch){
1714 //*****************************************************************************
1715 
1716  // Compare the UniqueID to find the corresponding AnaTrack
1717  // AnaTrack already exists because it is saved for first
1718 
1719  AnaParticleB* part = RedoTreeConverter::FindParticle(ID,bunch);
1720  if (!part) return part;
1721 
1722  // If not found, look into all bunches
1723  // in prod 5 this could happens only when the vertex is OutOfBunch
1724 #if ! VERSION_HAS_TIME_FITS
1725  if (bunch->Bunch != -1) {
1726  if ((int)bunch->Particles.size() == (int)NMAXPARTICLES) std::cout << "minor error: vertex constituent not found (UniqueID " << ID << "), likely because this event has too many tracks!" << std::endl;
1727  else if ( ! suppress_err_msg) std::cout << "minor error in oaAnalysisConverter (ref 6056)" << std::endl;
1728  return NULL;
1729  }
1730 #endif
1731 
1732  // Look into all bunches
1733  std::vector<AnaBunchC*>::iterator itbunch;
1734  std::vector<AnaParticleB*>::iterator ittrack;
1735  for (itbunch = _spill->Bunches.begin(); itbunch != _spill->Bunches.end(); itbunch++) {
1736  AnaBunchB* bunch0 = static_cast<AnaBunchB*>(*itbunch);
1737  for (ittrack = bunch0->Particles.begin(); ittrack != bunch0->Particles.end(); ittrack++) {
1738  if (ID == (*ittrack)->UniqueID) {
1739  if (bunch->Bunch != -1) { // often a global vertex out of bunch has constituents in the near bunch
1740  std::cout << "INFO: this global vertex (in bunch " << bunch->Bunch << ") has a constituent stored in another bunch!" << std::endl;
1741  }
1742  return static_cast<AnaTrack*>(*ittrack);
1743  }
1744  }
1745  }
1746 
1747  if ( ! suppress_err_msg) {
1748  if ((int)bunch->Particles.size() == (int)NMAXPARTICLES) std::cout << "minor error: vertex constituent not found (UniqueID " << ID << "), likely because this event has too many tracks!" << std::endl;
1749  else std::cout << "minor error: vertex constituent not found in bunch " << bunch->Bunch << ": in prod6 it should be a flipped track with start position in a bunch not yet loaded!" << std::endl;
1750  }
1751  return NULL;
1752 }
1753 
1754 
1755 //*****************************************************************************
1756 void FlatTreeConverter::FillTECALReconObjectInfo(int iObj, AnaTECALReconObject* anaTECAL, AnaBunch* bunch){
1757 //*****************************************************************************
1758 
1759  (void)bunch;
1760 
1761  anaTECAL->AverageHitTime = tecalReconAverageHitTime [iObj];
1762  anaTECAL->AverageZPos = tecalReconAverageZPosition [iObj];
1763  anaTECAL->Containment = tecalReconContainment [iObj];
1764  anaTECAL->EFitResult = tecalReconEFitResult [iObj];
1765  anaTECAL->EFitUncertainty = tecalReconEFitUncertainty [iObj];
1766  anaTECAL->FirstLayer = tecalReconFirstLayer [iObj];
1767  anaTECAL->IsShowerLike = tecalReconIsShowerLike [iObj];
1768  anaTECAL->IsTrackLike = tecalReconIsTrackLike [iObj];
1769  anaTECAL->LastLayer = tecalReconLastLayer [iObj];
1770 
1771 #if VERSION_HAS_ECAL_LLR
1772  anaTECAL->LikeMIPEM = tecalReconLikeMIPEM [iObj];
1773  anaTECAL->LikeMIPPion = tecalReconLikeMIPPion [iObj];
1774  anaTECAL->LikeEMHIP = tecalReconLikeEMHIP [iObj];
1775  anaTECAL->LikeMIPEMLow = tecalReconLikeMIPEMLow [iObj];
1776 #endif
1777 
1778  anaTECAL->MatchingLike = tecalReconMatchingLike [iObj];
1779  anaTECAL->MichelTagNDelayedCluster = tecalReconMichelTagNDelayedCluster[iObj];
1780  anaTECAL->Module = tecalReconModule [iObj];
1781  anaTECAL->MostDownStreamLayerHit = tecalReconMostDownStreamLayerHit [iObj];
1782  anaTECAL->MostUpStreamLayerHit = tecalReconMostUpStreamLayerHit [iObj];
1783  anaTECAL->NHits = tecalReconNHits [iObj];
1784  anaTECAL->NLayersHit = tecalReconNLayersHit [iObj];
1785  anaTECAL->ObjectLength = tecalReconObjectLength [iObj];
1786  anaTECAL->PIDAMR = tecalReconPIDAMR [iObj];
1787  anaTECAL->PIDAngle = tecalReconPIDAngle [iObj];
1788  anaTECAL->PIDAsymmetry = tecalReconPIDAsymmetry [iObj];
1789  anaTECAL->PIDCircularity = tecalReconPIDCircularity [iObj];
1790  anaTECAL->PIDFBR = tecalReconPIDFBR [iObj];
1791  anaTECAL->PIDMaxRatio = tecalReconPIDMaxRatio [iObj];
1792  anaTECAL->PIDMeanPos = tecalReconPIDMeanPos [iObj];
1793  anaTECAL->PIDShowerAngle = tecalReconPIDShowerAngle [iObj];
1794  anaTECAL->PIDShowerWidth = tecalReconPIDShowerWidth [iObj];
1795  anaTECAL->PIDTransverseChargeRatio = tecalReconPIDTransverseChargeRatio[iObj];
1796  anaTECAL->PIDTruncatedMaxRatio = tecalReconPIDTruncatedMaxRatio [iObj];
1797  anaTECAL->Thrust = tecalReconThrust [iObj];
1798  anaTECAL->TimeBunch = tecalReconTimeBunch [iObj];
1799  anaTECAL->TotalHitCharge = tecalReconTotalHitCharge [iObj];
1800  anaTECAL->TrueID = tecalReconTrueID [iObj];
1801  anaTECAL->TrueIDPrimary = tecalReconTrueIDPrimary [iObj];
1802  anaTECAL->TrueIDRecursive = tecalReconTrueIDRecursive [iObj];
1803  anaTECAL->TrueIDSingle = tecalReconTrueIDSingle [iObj];
1804  anaTECAL->UniqueID = tecalReconUniqueID [iObj];
1805  anaTECAL->Bunch = tecalReconBunch [iObj];
1806 
1807  anaUtils::CopyArray(tecalReconPointing [iObj], anaTECAL->Pointing, 3);
1808  anaUtils::CopyArray(tecalReconThrustAxis [iObj], anaTECAL->ThrustAxis, 3);
1809  anaUtils::CopyArray(tecalReconThrustOrigin[iObj], anaTECAL->ThrustOrigin, 3);
1810  return;
1811 }
Float_t dEdxexpMuon
Expected dE/dx for a muon, based on the reconstructed momentum.
Float_t Pullmu
Muon pull of the segment: (dEdxMeas-dEdxexpMuon)/dEdxSigmaMuon.
AnaTrueVertexB * TrueVertex
Pointer to the AnaTrueVertexB of the interaction that created this AnaTrueParticleB.
Float_t DirectionStartFlip[3]
Direction at the start for the main PID hypothesis and reverse sense.
int nP0DSegments
How many P0D tracks are associated with this track.
Float_t PositionStart[4]
The reconstructed start position of the particle.
Float_t MomentumAtVertex
The reconstructed momentum of the track, at the most primary global vertex (if exists).
Representation of the beam quality and perhaps other beam information as needed.
Representation of a global track.
Float_t AvgTime
Average Time: using results from time vs distance fit.
AnaTrueVertexB * TrueVertex
Representation of the ND280 data quality flags.
AnaP0DParticleB * P0DSegments[NMAXP0DS]
The P0D segments that contributed to this global track.
unsigned long Detector
Int_t InputFileIndex
Index of the input file producing this spill.
Int_t NuPDG
The PDG code of the incoming neutrino.
Int_t LeptonPDG
The PDG code of the primary outgoing electron/muon.
int nDetCrossings
The number of DetCrossing objects.
int GetParameterI(std::string)
Get parameter. Value is returned as integer.
Definition: Parameters.cxx:217
Float_t MomentumEle
Momentum from refitting the track assuming the electron hypothesis.
bool IsTruePrimaryPi0DecayPhoton
Is this a true primary pi0 decay photon or the child of one?
int nTrueParticles
How many true particles are associated with this vertex.
Int_t NDOF
The number of degrees of freedom of the fit using a Kalman filter.
FlatTreeConverter(bool readRooTrackerVtx=false)
Int_t Detector
Definition: DataClasses.hxx:40
bool FGDCosmic
FGD cosmic trigger flag.
Int_t DetFlag[7]
Float_t dEdxexpProton
Expected dE/dx for a proton, based on the reconstructed momentum.
Int_t NuParentPDG
Neutrino parent PDG code.
Definition: DataClasses.hxx:88
std::vector< std::pair< AnaTrueVertexB *, AnaRecTrueMatchB > > TrueVerticesMatch
The true vertices that are associated with this global vertex, with the related cleanliness and compl...
Int_t Status
The Status of the fit of this reconstructed object.
int _nentries
The number of entries in the chain. To be set by the implementation.
Float_t LeptonDir[3]
The direction of the primary outgoing electron/muon.
Representation of the ND280 trigger bits.
Int_t NDOF
The number of degrees of freedom when the track was fitted with a Kalman filter.
AnaSMRDParticleB * SMRDSegments[NMAXSMRDS]
The SMRD segments that contributed to this global track.
Float_t Variance[4]
The variance values of the fit using a Kalman filter.
Float_t NuParentDecPoint[4]
Decay point of the neutrino parent.
Definition: DataClasses.hxx:91
Int_t RooVtxIndex
The index of the associated RooTrackerVtx vertex from its position in the TClonesArray.
Definition: DataClasses.hxx:75
Representation of a true Monte Carlo vertex.
Float_t DirectionEnd[3]
The reconstructed end direction of the particle.
Float_t E
Input to the pull calculations. Needs to be documented properly in oaAnalysis.
Float_t Pullpi
Pion pull of the segment: (dEdxMeas-dEdxexpPion)/dEdxSigmaPion.
std::vector< AnaTrueVertexB * > TrueVertices
The true MC vertices used in this spill.
std::vector< AnaBunchC * > Bunches
The reconstructed objects, split into timing bunches.
static bool IsP0DDetector(SubDetId::SubDetEnum det)
Check if a detector enumeration refers to a SMRDP0D or not.
Definition: SubDetId.cxx:146
Int_t NBaryons
The total number of primary baryons that were ejected.
Int_t NNodes
The number of nodes in the reconstructed object.
Float_t ProtonDir[3]
The direction of the primary outgoing protons listed first (likely the interacted one)...
Float_t TargetDir[3]
The direction of the target nucleus.
Representation of an ECAL segment of a global track.
Representation of the ND280 data quality flags.
Float_t Vertex1x1
Vertex activity variables.
Float_t AvgTime
Time charged averaged over hits.
Int_t Bunch
The bunch of the track, based on the PositionStart.T()
AnaTrueObjectC * TrueObject
The link to the true oject that most likely generated this reconstructed object.
Float_t Length
The number of hits in the reconstructed object.
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()
bool _isUsingReconDirFGDOnly
Store whether AnaLocalReconBunch information is enabled in the parameters file.
AnaTrueParticleB ** TrueParticles
The true particles associated with this vertex.
This Ana* object is used to flatten TECALReconObjects from ReconDir/TrackerECal.
Float_t MomentumErrorProton
Error on momentum from refitting the track assuming the proton hypothesis.
Int_t GetSpill(Long64_t &entry, AnaSpillC *&spill)
Float_t AvgTime
Average Time for the iso FGD hits.
AnaBunchB * OutOfBunch
Reconstructed objects that didn&#39;t fit into one of the timing bunches.
Long64_t GetEntries()
Return the total number of entries in the chain.
Int_t TargetPDG
The PDG code of the target nucleus.
Definition: DataClasses.hxx:85
std::vector< AnaParticleB * > ReconParticles
Vector of pointers to AnaParticle&#39;s associated with this true particle.
Float_t Chi2
The chi2 value of the fit using a Kalman filter.
Float_t dEdxexpPion
Expected dE/dx for a pion, based on the reconstructed momentum.
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 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...
Int_t SubRun
The subrun number.
std::vector< AnaVertexB * > Vertices
Int_t Spill
Spill number from BeamSummaryDataModule::ND280Spill.
Float_t Chi2
The chi2 value when the track was fitted using a Kalman filter.
int nSMRDSegments
How many SMRD tracks are associated with this track.
Representation of detector time info.
Definition: DataClasses.hxx:11
Float_t POTCT4
The POT from CT4 for this spill. This is only needed for P5 files.
Float_t ProtonMom
The momentum of the primary outgoing protons listed first (likely the interacted one).
Float_t LeptonMom
The momentum of the primary outgoing electron/muon.
Float_t Momentum
The reconstructed momentum of the particle, at the start position.
Representation of a true Monte Carlo vertex.
Definition: DataClasses.hxx:50
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 dEdxSigmaKaon
Expected error on the dE/dx measurement, for the proton hypothesis.
std::vector< AnaVertexB * > ReconVertices
Vector of pointers to AnaVertexB (global vertices) associated with this true vertex.
AnaDetCrossingB ** DetCrossings
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 DirectionAtVertex[3]
The reconstructed direction of the track at the most primary global vertex (if exists).
Float_t EFieldRefitMomentum
Reconstructed momentum with the E-field distortion corrections.
Int_t PDG
The PDG code of this particle.
Int_t SpillNumber
Spill number from BeamSummaryDataModule::BeamSummaryData::SpillNumber.
Float_t MomentumErrorMuon
Error on momentum from refitting the track assuming the muon hypothesis.
unsigned long Detector
Int_t Detectors
Int_t NHits
The number of hits in the particle.
Int_t ParentPDG
The PDG code of this particle&#39;s immediate parent, or 0 if there is no parent.
Int_t BeamRunNumber
Float_t MomentumErrorEle
Error on momentum from refitting the track assuming the electron hypothesis.
Float_t dEdxMeas
dE/dx as measured by the TPC.
Float_t TimeEnd
End time.
Definition: DataClasses.hxx:46
Representation of a global track.
bool TripTCosmic
TripT cosmic trigger flag.
AnaTrueVertexB * GetMainTrueVertex(bool warning=true)
The main true vertex that is associated with this global vertex.
Float_t MomentumEnd
The reconstructed momentum of the particle, at the end position.
Int_t EventTime
The ND280 subrun number.
Representation of a TPC segment of a global track.
int GetLocalDetEnum(SubDetId::SubDetEnum det, SubDetId::SubDetEnum idet)
Get old local detector enumeration to find array index of Flat tree.
AnaParticleB ** Particles
Float_t ExitMomentum[3]
for each subdetector tell the exit momentum
Float_t Pullk
Kaon pull of the segment: (dEdxMeas-dEdxexpPion)/dEdxSigmaKaon.
std::vector< AnaTrackerTrackB * > TRACKERSegments
The TRACKER segments that contributed to this global track.
Float_t Pullp
Proton pull of the segment: (dEdxMeas-dEdxexpProton)/dEdxSigmaProton.
std::vector< AnaTrueParticleB * > TrueParticles
The true MC particles used in this spill.
Representation of a global vertex.
AnaVertexB * ReconVertex
The pointer to the most primary AnaVertexB (global vertex) associated with this track.
virtual void DefineBranches()
Define the branches to be read from the input tree.
Int_t RooVtxEntry
Not in the MiniTree for the Moment since it produces a seg fault.
virtual bool AddFileToTChain(const std::string &inputString)
Add the file specified to fChain, and any friend chains that were set up.
Float_t Length
The length of this global track.
Float_t MomentumError
The error on the reconstructed momentum.
Float_t DirectionStart[3]
The reconstructed start direction of the particle.
Representation of a FGD segment of a global track.
Int_t Bunch
The index of this bunch (0-7).
std::vector< AnaVertexB * > ReconVertices
Vector of pointers to AnaVertexB (global vertices) associated with this track.
Int_t tecalReconCounter
AnaLocalReconBunch information.
Int_t PrimaryIndex
Index of the global vertex.
Int_t GoodSpill
Good spill flag, as defined in Beam Summary Data. 0 is bad.
Float_t Pullele
Electron pull of the segment: (dEdxMeas-dEdxexpEle)/dEdxSigmaEle.
Float_t PionDir[3]
The direction of the primary outgoing pions listed first (likely the interacted one).
Float_t Q2
The Q2 of the true interaction.
Definition: DataClasses.hxx:97
AnaTrigger Trigger
Not in the MiniTree for the Moment since it produces a seg fault.
Int_t RooVtxEntry
Entry in the RooTrackerVtx tree (not set directly)
Definition: DataClasses.hxx:72
Int_t ParentID
The ID of this particle&#39;s immediate parent, or 0 if there is no parent.
virtual bool Initialize()
Float_t Purity
The purity with which this particle was matched to a reconstructed object.
std::vector< AnaParticleB * > Particles
Representation of a TPC segment of a global track.
void ConvertTrackerDetEnumToBitField(unsigned long &det, int DetUsed)
Convert the detector used array to the bit field used by psyche for tracker tracks.
Float_t TimeStart
Start time.
Definition: DataClasses.hxx:43
virtual void DefineBranches()
Define the branches to be read from the input tree.
Header & header()
Returns the Header manager.
TChain * fChain
The main TChain used to read events from the input file.
Float_t NuDir[3]
The true (unit) direction of the incoming neutrino.
Definition: DataClasses.hxx:82
Representation of a P0D segment of a global track.
AnaTrueParticleB * GetTrueParticle() const
Return a casted version of the AnaTrueObject associated.
AnaParticle.
Representation of a reconstructed particle (track or shower).
Int_t ReconPDG
PDG of the most probable particle hypothesis used at reconstruction level.
bool IsMC
Says if the event is MC or data.
virtual void FillBunchInfo(std::vector< AnaTrueParticleB *> &trueParticles, AnaBunchB *bunch)
static bool ComparePrimaryIndex(const AnaVertexB *t1, const AnaVertexB *t2)
Function used to sort PrimaryIndex in increasing order.
Representation of a true Monte Carlo trajectory/particle.
Float_t MomentumMuon
Momentum from refitting the track assuming the muon hypothesis.
Representation of the beam information, including POT and quality.
Float_t POT
The POT for this spill. For data, this comes from the Beam Summary Data.
Float_t dEdxexpKaon
Expected dE/dx for a proton, based on the reconstructed momentum.
Float_t EntranceMomentum[3]
for each subdetector tell the entrance momentum
Float_t TargetMom
The momentum of the target nucleus.
virtual bool AddFileToTChain(const std::string &inputString)
Add the file specified to fChain, and any friend chains that were set up.
Float_t PionMom
The momentum of the primary outgoing pions listed first (likely the interacted one).
static bool IsSMRDDetector(SubDetId::SubDetEnum det)
Check if a detector enumeration refers to a SMRD or not.
Definition: SubDetId.cxx:142
Int_t NPrimaryParticles[Int_t(ParticleId::kLast)+1]
Array to count the outgoing primary particles of each type (.
std::vector< AnaParticleB * > ReconParticles
Float_t PositionEnd[4]
The reconstructed end position of the particle.
Float_t RefitMomentum
Reconstructed momentum with the empirical distortion corrections.
Float_t MomentumProton
Momentum from refitting the track assuming the proton hypothesis.