1 #include "RedoTreeConverter.hxx" 2 #include "BasicUtils.hxx" 3 #include "ND280AnalysisUtils.hxx" 4 #include "TreeConverterUtils.hxx" 10 bool suppress_err_msg =
true;
24 NRooTrackerVTX = NULL;
25 GRooTrackerVTX = NULL;
38 sPOTSincePreviousSpill = 0;
43 sNTotalTrueParticles = 0;
44 sNTotalTrueVertices = 0;
49 sTriggerFGDCosmic = 0;
50 sTriggerTripTCosmic = 0;
53 for (UInt_t i = 0; i < NMAXTRUEVERTICES; i++) {
55 sTrueVertexRooVtxIndex[i] = 0;
56 sTrueVertexRooVtxEntry[i] = 0;
57 sTrueVertexReacCode[i] = 0;
58 sTrueVertexNTrueParticles[i] = 0;
59 sTrueVertexNBaryons[i] = 0;
60 sTrueVertexBunch[i] = 0;
61 sTrueVertexDetector[i] = 0;
62 sTrueVertexNuPDG[i] = 0;
63 sTrueVertexTargetPDG[i] = 0;
64 sTrueVertexNuEnergy[i] = 0;
66 sTrueVertexNuParentPDG[i] = 0;
68 for (UInt_t j = 0; j < 4; j++) {
69 sTrueVertexPosition[i][j] = 0;
70 sTrueVertexNuParentDecPoint[i][j] = 0;
73 for (UInt_t j = 0; j < 3; j++) {
74 sTrueVertexNuDir[i][j] = 0;
79 for (UInt_t i = 0; i < NMAXTRUEPARTICLES; i++) {
80 sTrueParticleID [i] = 0;
81 sTrueParticleBunch [i] = 0;
82 sTrueParticlePDG [i] = 0;
83 sTrueParticleParentPDG [i] = 0;
84 sTrueParticleGParentPDG [i] = 0;
85 sTrueParticlePrimaryID [i] = 0;
86 sTrueParticleParentID [i] = 0;
87 sTrueParticlePurity [i] = 0;
88 sTrueParticleMomentum [i] = 0;
89 sTrueParticleCharge [i] = 0;
90 sTrueParticleVertexIndex [i] = 0;
91 sTrueParticleTruthVertexID [i] = 0;
92 sTrueParticleNReconTracks [i] = 0;
93 sTrueParticleIsTruePrimaryPi0DecayPhoton [i] = 0;
94 sTrueParticleIsTruePrimaryPi0DecayPhotonChild[i] = 0;
96 for (
int j = 0; j < 4; j++) {
97 sTrueParticlePosition[i][j] = 0;
98 sTrueParticlePositionEnd[i][j] = 0;
100 for (
int j = 0; j < 3; j++) {
101 sTrueParticleDirection[i][j] = 0;
103 sTrueParticleNDetCrossings[i] = 0;
104 for (UInt_t j = 0; j < NMAXCROSSEDDET; j++) {
105 for (
int k = 0; k < 4; k++) {
106 sTrueParticleEntrancePosition[i][j][k] = 0;
107 sTrueParticleExitPosition[i][j][k] = 0;
109 for (
int k = 0; k < 3; k++) {
110 sTrueParticleEntranceMomentum[i][j][k] = 0;
111 sTrueParticleExitMomentum[i][j][k] = 0;
113 sTrueParticleDetector[i][j] = 0;
114 sTrueParticleInActive[i][j] = 0;
119 for (UInt_t i = 0; i < NMAXFGDTIMEBINS; i++) {
120 sFgdTimeBinMinTime[i] = 0;
121 sFgdTimeBinMaxTime[i] = 0;
122 sFgdTimeBinNHits1[i] = 0;
123 sFgdTimeBinNHits2[i] = 0;
124 sFgdTimeBinRawChargeSum1[i] = 0;
125 sFgdTimeBinRawChargeSum2[i] = 0;
126 sFgdTimeBinG4ID[i] = 0;
133 for (UInt_t i = 0; i < NMAXVERTICES; i++) {
134 vPrimaryIndex[i] = 0;
138 vNReconParticles[i] = 0;
139 vNTrueVerticesMatch[i] = 0;
141 for (
int j = 0; j < 4; j++) {
146 for (UInt_t j = 0; j < NMAXPARTICLESINVERTEX; j++) {
147 vParticlesUniqueID[i][j] = 0;
150 for (UInt_t j = 0; j < NMAXTRUEVERTICESMATCH; j++) {
151 vTrueVertexIndex[i][j] = 0;
152 vTrueVerticesClean[i][j] = 0;
153 vTrueVerticesCompl[i][j] = 0;
158 for (UInt_t i = 0; i < NMAXPARTICLES; i++) {
162 trNReconVertices[i] = 0;
175 trMomentumFlip[i] = 0;
176 trToFFGD1_FGD2[i] = 0;
177 trToFP0D_FGD1[i] = 0;
178 trToFECal_FGD1[i] = 0;
179 trToFECal_FGD2[i] = 0;
180 trToFFlag_FGD1_FGD2[i] = 0;
181 trToFFlag_P0D_FGD1[i] = 0;
182 trToFFlag_ECal_FGD1[i] = 0;
183 trToFFlag_ECal_FGD2[i] = 0;
184 trMomentumError[i] = 0;
185 trMomentumMuon[i] = 0;
186 trMomentumErrorMuon[i] = 0;
187 trMomentumProton[i] = 0;
188 trMomentumErrorProton[i] = 0;
189 trMomentumEle[i] = 0;
190 trMomentumErrorEle[i] = 0;
191 trRangeMomentumEle[i] = 0;
192 trRangeMomentumMuon[i] = 0;
193 trRangeMomentumProton[i] = 0;
194 trTrueParticleID[i] = 0;
196 for (UInt_t j = 0; j < NDETECTORS; j++) {
200 for (
int j = 0; j < 3; j++) {
201 trDirectionStart[i][j] = 0;
202 trDirectionEnd[i][j] = 0;
205 for (
int j = 0; j < 4; j++) {
206 trPositionStart[i][j] = 0;
207 trPositionEnd[i][j] = 0;
210 for (
int j = 0; j < 3; j++) {
211 trTpcDetector[i][j] = 0;
212 trTpcNHits[i][j] = 0;
213 trTpcNNodes[i][j] = 0;
214 trTpcLength[i][j] = 0;
215 trTpcCharge[i][j] = 0;
216 trTpcMomentum[i][j] = 0;
217 trTpcMomentumError[i][j] = 0;
218 trTpcBackMomentum[i][j] = 0;
219 trTpcRefitCharge[i][j] = 0;
220 trTpcRefitMomentum[i][j] = 0;
221 trTpcEFieldRefitMomentum[i][j] = 0;
222 trTpcdEdxMeas[i][j] = 0;
223 trTpcdEdxExpMu[i][j] = 0;
224 trTpcdEdxExpEle[i][j] = 0;
225 trTpcdEdxExpP[i][j] = 0;
226 trTpcdEdxExpPi[i][j] = 0;
227 trTpcdEdxExpK[i][j] = 0;
228 trTpcdEdxSigmaMu[i][j] = 0;
229 trTpcdEdxSigmaEle[i][j] = 0;
230 trTpcdEdxSigmaP[i][j] = 0;
231 trTpcdEdxSigmaPi[i][j] = 0;
232 trTpcdEdxSigmaK[i][j] = 0;
233 trTpcPurity[i][j] = 0;
234 trTpcTrueParticleID[i][j] = 0;
236 for (
int k = 0; k < 3; k++) {
237 trTpcRefitDirection[i][j][k] = 0;
238 trTpcDirectionStart[i][j][k] = 0;
239 trTpcDirectionEnd[i][j][k] = 0;
242 for (
int k = 0; k < 4; k++) {
243 trTpcRefitPosition[i][j][k] = 0;
244 trTpcPositionStart[i][j][k] = 0;
245 trTpcPositionEnd[i][j][k] = 0;
249 for (
int j = 0; j < 2; j++) {
250 trFgdDetector[i][j] = 0;
251 trFgdNHits[i][j] = 0;
252 trFgdNNodes[i][j] = 0;
253 trFgdLength[i][j] = 0;
256 trFgdPullmu[i][j] = 0;
257 trFgdPullp[i][j] = 0;
258 trFgdPullpi[i][j] = 0;
259 trFgdPullno[i][j] = 0;
260 trFgdContainment[i][j] = 0;
261 trFgdAvgTime[i][j] = 0;
262 trFgdVertex1x1[i][j] = 0;
263 trFgdVertex3x3[i][j] = 0;
264 trFgdVertex5x5[i][j] = 0;
265 trFgdVertex7x7[i][j] = 0;
266 trFgdVertexLayer[i][j] = 0;
268 for (
int k = 0; k < 3; k++) {
269 trFgdDirectionStart[i][j][k] = 0;
270 trFgdDirectionEnd[i][j][k] = 0;
273 for (
int k = 0; k < 4; k++) {
274 trFgdPositionStart[i][j][k] = 0;
275 trFgdPositionEnd[i][j][k] = 0;
280 for (UInt_t j = 0; j < NECALSUBDETS; j++) {
281 trECALDetector[i][j] = 0;
282 trECALNHits[i][j] = 0;
283 trECALNNodes[i][j] = 0;
284 trECALLength[i][j] = 0;
285 trECALEMEnergy[i][j] = 0;
286 trECALEDeposit[i][j] = 0;
287 trECALIsShowerLike[i][j] = 0;
288 trECALAvgTime[i][j] = 0;
289 trECALPIDMipEm[i][j] = 0;
290 trECALPIDEmHip[i][j] = 0;
291 trECALMostUpStreamLayerHit[i][j] = 0;
294 for (
int k = 0; k < 3; k++) {
295 trECALDirectionStart[i][j][k] = 0;
296 trECALDirectionEnd[i][j][k] = 0;
297 trECALShowerPosition[i][j][k] = 0;
300 for (
int k = 0; k < 4; k++) {
301 trECALPositionStart[i][j][k] = 0;
302 trECALPositionEnd[i][j][k] = 0;
306 for (UInt_t j = 0; j < NSMRDSUBDETS; j++) {
307 trSMRDDetector[i][j] = 0;
308 trSMRDNHits[i][j] = 0;
309 trSMRDNNodes[i][j] = 0;
310 trSMRDLength[i][j] = 0;
311 trSMRDAvgTime[i][j] = 0;
313 for (
int k = 0; k < 3; k++) {
314 trSMRDDirectionStart[i][j][k] = 0;
315 trSMRDDirectionEnd[i][j][k] = 0;
318 for (
int k = 0; k < 4; k++) {
319 trSMRDPositionStart[i][j][k] = 0;
320 trSMRDPositionEnd[i][j][k] = 0;
324 for (
int j = 0; j < 1; j++) {
325 trP0DDetector[i][j] = 0;
326 trP0DNHits[i][j] = 0;
327 trP0DNNodes[i][j] = 0;
328 trP0DLength[i][j] = 0;
329 trP0DELoss[i][j] = 0;
331 for (
int k = 0; k < 3; k++) {
332 trP0DDirectionStart[i][j][k] = 0;
333 trP0DDirectionEnd[i][j][k] = 0;
336 for (
int k = 0; k < 4; k++) {
337 trP0DPositionStart[i][j][k] = 0;
338 trP0DPositionEnd[i][j][k] = 0;
346 b_sPOTSincePreviousSpill = NULL;
351 b_sNTotalTrueParticles = NULL;
352 b_sNTotalTrueVertices = NULL;
353 b_sBeamGoodSpill = NULL;
355 b_sTriggerFGDCosmic = NULL;
356 b_sTriggerTripTCosmic = NULL;
358 b_sNTrueVertices = NULL;
360 b_sTrueVertexID = NULL;
361 b_sTrueVertexRooVtxIndex = NULL;
362 b_sTrueVertexRooVtxEntry = NULL;
363 b_sTrueVertexReacCode = NULL;
364 b_sTrueVertexNTrueParticles = NULL;
365 b_sTrueVertexNBaryons = NULL;
366 b_sTrueVertexBunch = NULL;
367 b_sTrueVertexDetector = NULL;
368 b_sTrueVertexNuPDG = NULL;
369 b_sTrueVertexTargetPDG = NULL;
370 b_sTrueVertexNuEnergy = NULL;
371 b_sTrueVertexQ2 = NULL;
372 b_sTrueVertexPosition = NULL;
373 b_sTrueVertexNuParentPDG = NULL;
374 b_sTrueVertexNuParentDecPoint = NULL;
375 b_sTrueVertexNuDir = NULL;
377 b_sNTrueParticles = NULL;
379 b_sTrueParticleID = NULL;
380 b_sTrueParticleBunch = NULL;
381 b_sTrueParticlePDG = NULL;
382 b_sTrueParticleParentPDG = NULL;
383 b_sTrueParticleGParentPDG = NULL;
384 b_sTrueParticlePrimaryID = NULL;
385 b_sTrueParticleParentID = NULL;
386 b_sTrueParticlePurity = NULL;
387 b_sTrueParticleMomentum = NULL;
388 b_sTrueParticleCharge = NULL;
389 b_sTrueParticleVertexIndex = NULL;
390 b_sTrueParticleTruthVertexID = NULL;
391 b_sTrueParticleNReconTracks = NULL;
392 b_sTrueParticlePosition = NULL;
393 b_sTrueParticlePositionEnd = NULL;
394 b_sTrueParticleDirection = NULL;
395 b_sTrueParticleNDetCrossings = NULL;
396 b_sTrueParticleEntrancePosition = NULL;
397 b_sTrueParticleExitPosition = NULL;
398 b_sTrueParticleEntranceMomentum = NULL;
399 b_sTrueParticleExitMomentum = NULL;
400 b_sTrueParticleDetector = NULL;
401 b_sTrueParticleInActive = NULL;
402 b_sTrueParticleIsTruePrimaryPi0DecayPhoton = NULL;
403 b_sTrueParticleIsTruePrimaryPi0DecayPhotonChild = NULL;
405 b_sNFgdTimeBins = NULL;
407 b_sFgdTimeBinMinTime = NULL;
408 b_sFgdTimeBinMaxTime = NULL;
409 b_sFgdTimeBinNHits1 = NULL;
410 b_sFgdTimeBinNHits2 = NULL;
411 b_sFgdTimeBinRawChargeSum1 = NULL;
412 b_sFgdTimeBinRawChargeSum2 = NULL;
413 b_sFgdTimeBinG4ID = NULL;
420 b_vPrimaryIndex = NULL;
426 b_vNReconParticles = NULL;
427 b_vNTrueVerticesMatch = NULL;
428 b_vParticlesUniqueID = NULL;
429 b_vTrueVertexIndex = NULL;
430 b_vTrueVerticesClean = NULL;
431 b_vTrueVerticesCompl = NULL;
438 b_trNReconVertices = NULL;
439 b_trDetectors = NULL;
452 b_trMomentumFlip = NULL;
453 b_trToFFGD1_FGD2 = NULL;
454 b_trToFP0D_FGD1 = NULL;
455 b_trToFECal_FGD1 = NULL;
456 b_trToFECal_FGD2 = NULL;
457 b_trToFFlag_FGD1_FGD2 = NULL;
458 b_trToFFlag_P0D_FGD1 = NULL;
459 b_trToFFlag_ECal_FGD1 = NULL;
460 b_trToFFlag_ECal_FGD2 = NULL;
461 b_trMomentumError = NULL;
462 b_trMomentumMuon = NULL;
463 b_trMomentumErrorMuon = NULL;
464 b_trMomentumProton = NULL;
465 b_trMomentumErrorProton = NULL;
466 b_trMomentumEle = NULL;
467 b_trMomentumErrorEle = NULL;
468 b_trRangeMomentumEle = NULL;
469 b_trRangeMomentumMuon = NULL;
470 b_trRangeMomentumProton = NULL;
471 b_trDirectionStart = NULL;
472 b_trDirectionEnd = NULL;
473 b_trPositionStart = NULL;
474 b_trPositionEnd = NULL;
476 b_trTpcDetector = NULL;
478 b_trTpcNNodes = NULL;
479 b_trTpcLength = NULL;
480 b_trTpcDirectionStart = NULL;
481 b_trTpcDirectionEnd = NULL;
482 b_trTpcPositionStart = NULL;
483 b_trTpcPositionEnd = NULL;
484 b_trTpcCharge = NULL;
485 b_trTpcMomentum = NULL;
486 b_trTpcMomentumError = NULL;
487 b_trTpcBackMomentum = NULL;
488 b_trTpcRefitCharge = NULL;
489 b_trTpcRefitMomentum = NULL;
490 b_trTpcRefitPosition = NULL;
491 b_trTpcRefitDirection = NULL;
492 b_trTpcEFieldRefitMomentum = NULL;
493 b_trTpcdEdxMeas = NULL;
494 b_trTpcdEdxExpMu = NULL;
495 b_trTpcdEdxExpEle = NULL;
496 b_trTpcdEdxExpP = NULL;
497 b_trTpcdEdxExpPi = NULL;
498 b_trTpcdEdxExpK = NULL;
499 b_trTpcdEdxSigmaMu = NULL;
500 b_trTpcdEdxSigmaEle = NULL;
501 b_trTpcdEdxSigmaP = NULL;
502 b_trTpcdEdxSigmaPi = NULL;
503 b_trTpcdEdxSigmaK = NULL;
504 b_trTpcPurity = NULL;
506 b_trFgdDetector = NULL;
508 b_trFgdNNodes = NULL;
509 b_trFgdLength = NULL;
510 b_trFgdDirectionStart = NULL;
511 b_trFgdDirectionEnd = NULL;
512 b_trFgdPositionStart = NULL;
513 b_trFgdPositionEnd = NULL;
516 b_trFgdPullmu = NULL;
518 b_trFgdPullpi = NULL;
519 b_trFgdPullno = NULL;
520 b_trFgdContainment = NULL;
521 b_trFgdAvgTime = NULL;
522 b_trFgdVertex1x1 = NULL;
523 b_trFgdVertex3x3 = NULL;
524 b_trFgdVertex5x5 = NULL;
525 b_trFgdVertex7x7 = NULL;
526 b_trFgdVertexLayer = NULL;
528 b_trECALDetector = NULL;
529 b_trECALNHits = NULL;
530 b_trECALNNodes = NULL;
531 b_trECALLength = NULL;
532 b_trECALDirectionStart = NULL;
533 b_trECALDirectionEnd = NULL;
534 b_trECALPositionStart = NULL;
535 b_trECALPositionEnd = NULL;
536 b_trECALEMEnergy = NULL;
537 b_trECALEDeposit = NULL;
538 b_trECALIsShowerLike = NULL;
539 b_trECALAvgTime = NULL;
540 b_trECALMostUpStreamLayerHit = NULL;
541 b_trECALPIDMipEm = NULL;
542 b_trECALPIDEmHip = NULL;
543 b_trECALShowerPosition = NULL;
546 b_trSMRDDetector = NULL;
547 b_trSMRDNHits = NULL;
548 b_trSMRDNNodes = NULL;
549 b_trSMRDLength = NULL;
550 b_trSMRDDirectionStart = NULL;
551 b_trSMRDDirectionEnd = NULL;
552 b_trSMRDPositionStart = NULL;
553 b_trSMRDPositionEnd = NULL;
554 b_trSMRDAvgTime = NULL;
556 b_trP0DDetector = NULL;
558 b_trP0DNNodes = NULL;
559 b_trP0DLength = NULL;
561 b_trP0DDirectionStart = NULL;
562 b_trP0DDirectionEnd = NULL;
563 b_trP0DPositionStart = NULL;
564 b_trP0DPositionEnd = NULL;
566 b_trTrueParticleID = NULL;
567 b_trTpcTrueParticleID = NULL;
575 if (!
fChain)
return false;
578 if (!gDirectory->FindObjectAny(
_treeName.c_str()))
return false;
596 anaUtils::ConfigureTreeBranch(
fChain,
"sRun", &sRun, &b_sRun);
598 anaUtils::ConfigureTreeBranch(
fChain,
"sSubRun", &sSubrun, &b_sSubrun);
600 anaUtils::ConfigureTreeBranch(
fChain,
"sEvt", &sEvt, &b_sEvt);
604 anaUtils::ConfigureTreeBranch(
fChain,
"sBeamGoodSpill", &sBeamGoodSpill, &b_sBeamGoodSpill);
605 anaUtils::ConfigureTreeBranch(
fChain,
"sDQGoodDaq", &sDQGoodDaq, &b_sDQGoodDaq);
607 anaUtils::ConfigureTreeBranch(
fChain,
"sNTrueVertices", &sNTrueVertices, &b_sNTrueVertices);
608 anaUtils::ConfigureTreeBranch(
fChain,
"sTrueVertexID", sTrueVertexID, &b_sTrueVertexID);
614 anaUtils::ConfigureTreeBranch(
fChain,
"sTrueVertexBunch", sTrueVertexBunch, &b_sTrueVertexBunch);
615 anaUtils::ConfigureTreeBranch(
fChain,
"sTrueVertexNuPDG", sTrueVertexNuPDG, &b_sTrueVertexNuPDG);
619 anaUtils::ConfigureTreeBranch(
fChain,
"sNTrueTracks", &sNTrueParticles, &b_sNTrueParticles);
620 anaUtils::ConfigureTreeBranch(
fChain,
"sTrueTrackID", sTrueParticleID, &b_sTrueParticleID);
622 anaUtils::ConfigureTreeBranch(
fChain,
"sTrueTrackPDG", sTrueParticlePDG, &b_sTrueParticlePDG);
623 anaUtils::ConfigureTreeBranch(
fChain,
"sTrueTrackParentPDG", sTrueParticleParentPDG, &b_sTrueParticleParentPDG);
624 anaUtils::ConfigureTreeBranch(
fChain,
"sTrueTrackGParentPDG", sTrueParticleGParentPDG, &b_sTrueParticleGParentPDG);
625 anaUtils::ConfigureTreeBranch(
fChain,
"sTrueTrackPrimaryID", sTrueParticlePrimaryID, &b_sTrueParticlePrimaryID);
626 anaUtils::ConfigureTreeBranch(
fChain,
"sTrueTrackParentID", sTrueParticleParentID, &b_sTrueParticleParentID);
627 anaUtils::ConfigureTreeBranch(
fChain,
"sTrueTrackVertexIndex", sTrueParticleVertexIndex, &b_sTrueParticleVertexIndex);
628 anaUtils::ConfigureTreeBranch(
fChain,
"sTrueTrackTruthVertexID", sTrueParticleTruthVertexID, &b_sTrueParticleTruthVertexID);
630 anaUtils::ConfigureTreeBranch(
fChain,
"sTrueTrackInActive", sTrueParticleInActive, &b_sTrueParticleInActive);
631 anaUtils::ConfigureTreeBranch(
fChain,
"sTrueTrackDetector", sTrueParticleDetector, &b_sTrueParticleDetector);
632 anaUtils::ConfigureTreeBranch(
fChain,
"sTrueTrackNDetCrossings", sTrueParticleNDetCrossings, &b_sTrueParticleNDetCrossings);
633 anaUtils::ConfigureTreeBranch(
fChain,
"sNFgdTimeBins", &sNFgdTimeBins, &b_sNFgdTimeBins);
634 anaUtils::ConfigureTreeBranch(
fChain,
"sFgdTimeBinNHits1", sFgdTimeBinNHits1, &b_sFgdTimeBinNHits1);
635 anaUtils::ConfigureTreeBranch(
fChain,
"sFgdTimeBinNHits2", sFgdTimeBinNHits2, &b_sFgdTimeBinNHits2);
638 anaUtils::ConfigureTreeBranch(
fChain,
"Bunch", &Bunch, &b_Bunch);
639 anaUtils::ConfigureTreeBranch(
fChain,
"Weight", &Weight, &b_Weight);
644 anaUtils::ConfigureTreeBranch(
fChain,
"vNReconParticles", &vNReconParticles, &b_vNReconParticles);
645 anaUtils::ConfigureTreeBranch(
fChain,
"vNTrueVerticesMatch", &vNTrueVerticesMatch, &b_vNTrueVerticesMatch);
646 anaUtils::ConfigureTreeBranch(
fChain,
"vParticlesUniqueID", &vParticlesUniqueID, &b_vParticlesUniqueID);
647 anaUtils::ConfigureTreeBranch(
fChain,
"vTrueVertexIndex", &vTrueVertexIndex, &b_vTrueVertexIndex);
649 anaUtils::ConfigureTreeBranch(
fChain,
"NTracks", &NParticles, &b_NParticles);
650 anaUtils::ConfigureTreeBranch(
fChain,
"trUniqueID", trUniqueID, &b_trUniqueID);
655 anaUtils::ConfigureTreeBranch(
fChain,
"trDetUsed", trDetUsed, &b_trDetUsed);
661 anaUtils::ConfigureTreeBranch(
fChain,
"trNHits", trNHits, &b_trNHits);
664 anaUtils::ConfigureTreeBranch(
fChain,
"trTrueTrackID", trTrueParticleID, &b_trTrueParticleID);
665 anaUtils::ConfigureTreeBranch(
fChain,
"trTpcDetector", trTpcDetector, &b_trTpcDetector);
666 anaUtils::ConfigureTreeBranch(
fChain,
"trTpcNNodes", trTpcNNodes, &b_trTpcNNodes);
667 anaUtils::ConfigureTreeBranch(
fChain,
"trTpcTrueTrackID", trTpcTrueParticleID, &b_trTpcTrueParticleID);
668 anaUtils::ConfigureTreeBranch(
fChain,
"trFgdDetector", trFgdDetector, &b_trFgdDetector);
669 anaUtils::ConfigureTreeBranch(
fChain,
"trFgdNNodes", trFgdNNodes, &b_trFgdNNodes);
670 anaUtils::ConfigureTreeBranch(
fChain,
"trFgdContainment", trFgdContainment, &b_trFgdContainment);
678 anaUtils::ConfigureTreeBranch(
fChain,
"sTrueVertexNuEnergy", sTrueVertexNuEnergy, &b_sTrueVertexNuEnergy);
680 anaUtils::ConfigureTreeBranch(
fChain,
"sTrueVertexPosition", sTrueVertexPosition, &b_sTrueVertexPosition);
685 anaUtils::ConfigureTreeBranch(
fChain,
"sTrueTrackMomentum", sTrueParticleMomentum, &b_sTrueParticleMomentum);
686 anaUtils::ConfigureTreeBranch(
fChain,
"sTrueTrackCharge", sTrueParticleCharge, &b_sTrueParticleCharge);
687 anaUtils::ConfigureTreeBranch(
fChain,
"sTrueTrackPosition", sTrueParticlePosition, &b_sTrueParticlePosition);
688 anaUtils::ConfigureTreeBranch(
fChain,
"sTrueTrackPositionEnd", sTrueParticlePositionEnd, &b_sTrueParticlePositionEnd);
689 anaUtils::ConfigureTreeBranch(
fChain,
"sTrueTrackDirection", sTrueParticleDirection, &b_sTrueParticleDirection);
690 anaUtils::ConfigureTreeBranch(
fChain,
"sTrueTrackEntrancePosition", sTrueParticleEntrancePosition, &b_sTrueParticleEntrancePosition);
691 anaUtils::ConfigureTreeBranch(
fChain,
"sTrueTrackExitPosition", sTrueParticleExitPosition, &b_sTrueParticleExitPosition);
693 anaUtils::ConfigureTreeBranch(
fChain,
"sFgdTimeBinMinTime", sFgdTimeBinMinTime, &b_sFgdTimeBinMinTime);
694 anaUtils::ConfigureTreeBranch(
fChain,
"sFgdTimeBinMaxTime", sFgdTimeBinMaxTime, &b_sFgdTimeBinMaxTime);
695 anaUtils::ConfigureTreeBranch(
fChain,
"sFgdTimeBinRawChargeSum1", sFgdTimeBinRawChargeSum1, &b_sFgdTimeBinRawChargeSum1);
696 anaUtils::ConfigureTreeBranch(
fChain,
"sFgdTimeBinRawChargeSum2", sFgdTimeBinRawChargeSum2, &b_sFgdTimeBinRawChargeSum2);
698 anaUtils::ConfigureTreeBranch(
fChain,
"vPosition", &vPosition, &b_vPosition);
701 anaUtils::ConfigureTreeBranch(
fChain,
"vTrueVerticesClean", &vTrueVerticesClean, &b_vTrueVerticesClean);
702 anaUtils::ConfigureTreeBranch(
fChain,
"vTrueVerticesCompl", &vTrueVerticesCompl, &b_vTrueVerticesCompl);
705 anaUtils::ConfigureTreeBranch(
fChain,
"trCharge", trCharge, &b_trCharge);
706 anaUtils::ConfigureTreeBranch(
fChain,
"trToFFGD1_FGD2", trToFFGD1_FGD2, &b_trToFFGD1_FGD2);
707 anaUtils::ConfigureTreeBranch(
fChain,
"trToFP0D_FGD1", trToFP0D_FGD1, &b_trToFP0D_FGD1);
708 anaUtils::ConfigureTreeBranch(
fChain,
"trToFECal_FGD1", trToFECal_FGD1, &b_trToFECal_FGD1);
709 anaUtils::ConfigureTreeBranch(
fChain,
"trToFECal_FGD2", trToFECal_FGD2, &b_trToFECal_FGD2);
710 anaUtils::ConfigureTreeBranch(
fChain,
"trToFFlag_FGD1_FGD2", trToFFlag_FGD1_FGD2, &b_trToFFlag_FGD1_FGD2);
711 anaUtils::ConfigureTreeBranch(
fChain,
"trToFFlag_P0D_FGD1", trToFFlag_P0D_FGD1, &b_trToFFlag_P0D_FGD1);
712 anaUtils::ConfigureTreeBranch(
fChain,
"trToFFlag_ECal_FGD1", trToFFlag_ECal_FGD1, &b_trToFFlag_ECal_FGD1);
713 anaUtils::ConfigureTreeBranch(
fChain,
"trToFFlag_ECal_FGD2", trToFFlag_ECal_FGD2, &b_trToFFlag_ECal_FGD2);
714 anaUtils::ConfigureTreeBranch(
fChain,
"trMomentum", trMomentum, &b_trMomentum);
715 anaUtils::ConfigureTreeBranch(
fChain,
"trMomentumFlip", trMomentumFlip, &b_trMomentumFlip);
725 anaUtils::ConfigureTreeBranch(
fChain,
"trRangeMomentumMuon", trRangeMomentumMuon, &b_trRangeMomentumMuon);
728 anaUtils::ConfigureTreeBranch(
fChain,
"trDirectionStart", trDirectionStart, &b_trDirectionStart);
729 anaUtils::ConfigureTreeBranch(
fChain,
"trDirectionEnd", trDirectionEnd, &b_trDirectionEnd);
730 anaUtils::ConfigureTreeBranch(
fChain,
"trPositionStart", trPositionStart, &b_trPositionStart);
731 anaUtils::ConfigureTreeBranch(
fChain,
"trPositionEnd", trPositionEnd, &b_trPositionEnd);
732 anaUtils::ConfigureTreeBranch(
fChain,
"trTpcDirectionStart", trTpcDirectionStart, &b_trTpcDirectionStart);
733 anaUtils::ConfigureTreeBranch(
fChain,
"trTpcPositionStart", trTpcPositionStart, &b_trTpcPositionStart);
734 anaUtils::ConfigureTreeBranch(
fChain,
"trTpcPositionEnd", trTpcPositionEnd, &b_trTpcPositionEnd);
735 anaUtils::ConfigureTreeBranch(
fChain,
"trTpcCharge", trTpcCharge, &b_trTpcCharge);
736 anaUtils::ConfigureTreeBranch(
fChain,
"trTpcMomentum", trTpcMomentum, &b_trTpcMomentum);
737 anaUtils::ConfigureTreeBranch(
fChain,
"trTpcMomentumError", trTpcMomentumError, &b_trTpcMomentumError);
738 anaUtils::ConfigureTreeBranch(
fChain,
"trTpcBackMomentum", trTpcBackMomentum, &b_trTpcBackMomentum);
739 anaUtils::ConfigureTreeBranch(
fChain,
"trTpcRefitMomentum", trTpcRefitMomentum, &b_trTpcRefitMomentum);
740 anaUtils::ConfigureTreeBranch(
fChain,
"trTpcRefitCharge", trTpcRefitCharge, &b_trTpcRefitCharge);
741 anaUtils::ConfigureTreeBranch(
fChain,
"trTpcRefitDirection", trTpcRefitDirection, &b_trTpcRefitDirection);
742 anaUtils::ConfigureTreeBranch(
fChain,
"trTpcRefitPosition", trTpcRefitPosition, &b_trTpcRefitPosition);
743 anaUtils::ConfigureTreeBranch(
fChain,
"trTpcEFieldRefitMomentum", trTpcEFieldRefitMomentum, &b_trTpcEFieldRefitMomentum);
744 anaUtils::ConfigureTreeBranch(
fChain,
"trTpcdEdxMeas", trTpcdEdxMeas, &b_trTpcdEdxMeas);
745 anaUtils::ConfigureTreeBranch(
fChain,
"trTpcdEdxExpMu", trTpcdEdxExpMu, &b_trTpcdEdxExpMu);
746 anaUtils::ConfigureTreeBranch(
fChain,
"trTpcdEdxExpEle", trTpcdEdxExpEle, &b_trTpcdEdxExpEle);
747 anaUtils::ConfigureTreeBranch(
fChain,
"trTpcdEdxExpP", trTpcdEdxExpP, &b_trTpcdEdxExpP);
748 anaUtils::ConfigureTreeBranch(
fChain,
"trTpcdEdxExpPi", trTpcdEdxExpPi, &b_trTpcdEdxExpPi);
750 anaUtils::ConfigureTreeBranch(
fChain,
"trTpcdEdxSigmaMu", trTpcdEdxSigmaMu, &b_trTpcdEdxSigmaMu);
751 anaUtils::ConfigureTreeBranch(
fChain,
"trTpcdEdxSigmaEle", trTpcdEdxSigmaEle, &b_trTpcdEdxSigmaEle);
752 anaUtils::ConfigureTreeBranch(
fChain,
"trTpcdEdxSigmaP", trTpcdEdxSigmaP, &b_trTpcdEdxSigmaP);
753 anaUtils::ConfigureTreeBranch(
fChain,
"trTpcdEdxSigmaPi", trTpcdEdxSigmaPi, &b_trTpcdEdxSigmaPi);
757 anaUtils::ConfigureTreeBranch(
fChain,
"trFgdDirectionStart", trFgdDirectionStart, &b_trFgdDirectionStart);
758 anaUtils::ConfigureTreeBranch(
fChain,
"trFgdPositionStart", trFgdPositionStart, &b_trFgdPositionStart);
759 anaUtils::ConfigureTreeBranch(
fChain,
"trFgdPositionEnd", trFgdPositionEnd, &b_trFgdPositionEnd);
760 anaUtils::ConfigureTreeBranch(
fChain,
"trFgdX", trFgdX, &b_trFgdX);
761 anaUtils::ConfigureTreeBranch(
fChain,
"trFgdE", trFgdE, &b_trFgdE);
762 anaUtils::ConfigureTreeBranch(
fChain,
"trFgdPullmu", trFgdPullmu, &b_trFgdPullmu);
763 anaUtils::ConfigureTreeBranch(
fChain,
"trFgdPullp", trFgdPullp, &b_trFgdPullp);
764 anaUtils::ConfigureTreeBranch(
fChain,
"trFgdPullpi", trFgdPullpi, &b_trFgdPullpi);
765 anaUtils::ConfigureTreeBranch(
fChain,
"trFgdPullno", trFgdPullno, &b_trFgdPullno);
776 anaUtils::ConfigureTreeBranch(
fChain,
"trECALNNodes", trECALNNodes, &b_trECALNNodes);
778 anaUtils::ConfigureTreeBranch(
fChain,
"trECALDirectionStart", trECALDirectionStart, &b_trECALDirectionStart);
780 anaUtils::ConfigureTreeBranch(
fChain,
"trECALPositionStart", trECALPositionStart, &b_trECALPositionStart);
783 anaUtils::ConfigureTreeBranch(
fChain,
"trECALAvgTime", trECALAvgTime, &b_trECALAvgTime);
785 anaUtils::ConfigureTreeBranch(
fChain,
"trECALEMEnergy", trECALEMEnergy, &b_trECALEMEnergy);
786 anaUtils::ConfigureTreeBranch(
fChain,
"trECALLength", trECALLength, &b_trECALLength);
787 anaUtils::ConfigureTreeBranch(
fChain,
"trECALPIDMipEm", trECALPIDMipEm, &b_trECALPIDMipEm);
788 anaUtils::ConfigureTreeBranch(
fChain,
"trECALPIDEmHip", trECALPIDEmHip, &b_trECALPIDEmHip);
789 anaUtils::ConfigureTreeBranch(
fChain,
"trECALNNodes", trECALNNodes, &b_trECALNNodes);
790 anaUtils::ConfigureTreeBranch(
fChain,
"trECALMostUpStreamLayerHit", trECALMostUpStreamLayerHit, &b_trECALMostUpStreamLayerHit);
791 anaUtils::ConfigureTreeBranch(
fChain,
"trECALShowerPosition", trECALShowerPosition, &b_trECALShowerPosition);
801 anaUtils::ConfigureTreeBranch(
fChain,
"trP0DLength", trP0DLength, &b_trP0DLength);
802 anaUtils::ConfigureTreeBranch(
fChain,
"trP0DELoss", trP0DELoss, &b_trP0DELoss);
807 fChain->SetBranchStatus(
"*",1);
990 RedoTreeConverter::~RedoTreeConverter(){
995 if (flattree)
delete flattree->GetCurrentFile();
996 if (GRooTrackerVTX)
delete GRooTrackerVTX->GetCurrentFile();
997 if (NRooTrackerVTX)
delete NRooTrackerVTX->GetCurrentFile();
998 if (flattree)
delete flattree;
999 if (GRooTrackerVTX)
delete GRooTrackerVTX;
1000 if (NRooTrackerVTX)
delete NRooTrackerVTX;
1008 std::cout <<
"RedoTreeConverter::AddFileToTChain(). Adding file: " << inputString << std::endl;
1012 dummy.AddFile(inputString.c_str());
1013 if (dummy.GetEntries(
"sEvt>=0") == 0){
1014 std::cout <<
" ----> This file does not contain any entries. IGNORED !!!!" << std::endl;
1020 TFile *f = TFile::Open(inputString.c_str());
1025 if (!gDirectory->FindObjectAny(
"header")){
1026 std::cout <<
" ----> This file does not contain a header tree. IGNORED !!!!" << std::endl;
1036 if( gDirectory->FindObjectAny(
"NRooTrackerVtx")) {
1039 NRooTrackerVTX =
GetChain(
"NRooTrackerVtx");
1048 std::cout <<
"RedoTreeConverter::AddFileToTChain(). NEUT RooTrackerVtx tree found !!" << std::endl;
1050 else if(gDirectory->FindObjectAny(
"GRooTrackerVtx")) {
1053 GRooTrackerVTX =
GetChain(
"GRooTrackerVtx");
1062 std::cout <<
"redoTreeConverter::AddFileToTChain(). GENIE RooTrackerVtx tree found !!" << std::endl;
1070 if( fGenie && GRooTrackerVTX) {
1071 GRooTrackerVTX->AddFile(inputString.c_str());
1073 else if( fNeut && NRooTrackerVTX) {
1074 NRooTrackerVTX->AddFile(inputString.c_str());
1078 flattree->AddFile(inputString.c_str());
1111 spill = MakeSpill();
1116 entry_temp = flattree->GetEntry(entry);
1119 if (entry_temp>0 && sRun > 1000000) {
1120 if (fGenie && GRooTrackerVTX) GRooTrackerVTX->GetEntry(entry);
1121 if (fNeut && NRooTrackerVTX){
1122 NRooTrackerVTX->GetEntry(_entry_roo);
1128 TString filename(flattree->GetFile()->GetName());
1129 if( filename != _currentfilename ) {
1130 std::cout <<
" Running on file : " << filename << std::endl;
1131 _currentfilename = filename;
1135 _spill =
static_cast<AnaSpillB*
>(spill);
1143 while (sEvt==evt_prev && entry <
_nentries){
1150 _spill->
Bunches.push_back(bunch);
1164 entry_temp = flattree->GetEntry(entry);
1179 entry_temp = flattree->GetEntry(entry);
1182 if (entry_temp>0 && sRun > 1000000) {
1183 if (fGenie && GRooTrackerVTX) GRooTrackerVTX->GetEntry(entry);
1184 if (fNeut && NRooTrackerVTX){
1185 NRooTrackerVTX->GetEntry(_entry_roo);
1191 TString filename(flattree->GetFile()->GetName());
1192 if( filename != _currentfilename ) {
1193 std::cout <<
" Running on file : " << filename << std::endl;
1194 _currentfilename = filename;
1201 FillEventInfo(static_cast<AnaEventB*>(event));
1206 _prevEvent=
static_cast<AnaEventB*
>(event);
1231 void RedoTreeConverter::FillEventInfo(
AnaEventB* event){
1236 bool filled =
false;
1238 if (sEvt == _prevEvent->EventInfo.Event){
1240 event->Copy(*_prevEvent,
false);
1246 FillEventSpillInfo(event);
1249 event->Bunch = Bunch;
1250 event->Weight = Weight;
1253 event->nParticles = 0;
1254 event->nVertices = 0;
1255 anaUtils::CreateArray(event->
Particles, NParticles);
1256 anaUtils::CreateArray(event->
Vertices, NVertices);
1257 for (
int i=0;i<NParticles;i++){
1259 FillTrackInfo(event, i, track);
1260 event->Particles[
event->nParticles] = track;
1261 event->nParticles++;
1263 for (
int i=0;i<NVertices;i++){
1265 FillVertexInfo(i, vertex, event);
1266 event->Vertices[
event->nVertices] = vertex;
1273 void RedoTreeConverter::FillEventSpillInfo(
AnaEventB* event){
1276 if (sRun==0 || sRun>1000000)
1277 event->EventInfo.IsMC =
true;
1279 event->EventInfo.IsMC =
false;
1281 event->EventInfo.Run = sRun;
1282 event->EventInfo.Event = sEvt;
1283 event->EventInfo.SetIsSandMC();
1285 event->nTrueVertices = 0;
1286 anaUtils::CreateArray(event->
TrueVertices, sNTrueVertices);
1287 for (
int i=0;i<sNTrueVertices;i++){
1289 FillTrueVertexInfo(i, vertex);
1290 event->TrueVertices[
event->nTrueVertices] = vertex;
1291 event->nTrueVertices++;
1296 anaUtils::CreateArray(event->
TrueParticles, sNTrueParticles);
1297 for (
int i=0;i<sNTrueParticles;i++){
1299 FillTrueParticleInfo(event, i, particle);
1304 event->TrueParticles[
event->nTrueParticles] = particle;
1305 event->nTrueParticles++;
1311 for (
int i=0;i<
event->nTrueVertices;i++){
1315 event->DataQuality = MakeDataQuality();
1316 event->Beam = MakeBeam();
1318 FillBeamInfo(event->
Beam);
1321 FillFgdTimeBinInfo(event);
1325 void RedoTreeConverter::FillInfo(
AnaSpillB* spill){
1329 if (sRun==0 || sRun>1000000)
1343 int nVertices = std::min((
int)NMAXTRUEVERTICES, sNTrueVertices);
1344 for (
int i=0;i<nVertices;i++){
1346 FillTrueVertexInfo(i, vertex);
1347 FillTrueVertexRooInfo(vertex);
1353 int nParts = std::min((
int)NMAXTRUEPARTICLES, sNTrueParticles);
1354 for (
int i=0;i<nParts;i++){
1356 FillTrueParticleInfo(spill->
TrueVertices, i, particle);
1361 spill->
Beam = MakeBeam();
1363 FillBeamInfo(spill->
Beam);
1371 void RedoTreeConverter::FillBunchInfo(std::vector<AnaTrueParticleB*>& trueParticles,
AnaBunchB* bunch){
1374 bunch->
Bunch = Bunch;
1379 for (
int i=0;i<NParticles;i++){
1381 FillTrackInfo(trueParticles, i, track);
1385 for (
int i=0;i<NVertices;i++){
1387 FillVertexInfo(i, vertex, bunch);
1393 void RedoTreeConverter::FillFgdTimeBinInfo(std::vector<AnaFgdTimeBinB*>& FgdTimeBins){
1397 for(
int ibin=0; ibin<sNFgdTimeBins; ibin++) {
1400 FgdTimeBins.push_back(abin);
1402 abin->MinTime = sFgdTimeBinMinTime[ibin];
1403 abin->NHits[0] = sFgdTimeBinNHits1[ibin];
1404 abin->NHits[1] = sFgdTimeBinNHits2[ibin];
1405 abin->RawChargeSum[0] = sFgdTimeBinRawChargeSum1[ibin];
1406 abin->RawChargeSum[1] = sFgdTimeBinRawChargeSum2[ibin];
1412 void RedoTreeConverter::FillFgdTimeBinInfo(
AnaEventB* event){
1416 event->nFgdTimeBins = 0;
1417 anaUtils::CreateArray(event->
FgdTimeBins, sNFgdTimeBins);
1418 for(
int ibin=0; ibin<sNFgdTimeBins; ibin++) {
1421 event->FgdTimeBins[
event->nFgdTimeBins] = abin;
1422 event->nFgdTimeBins++;
1424 abin->MinTime = sFgdTimeBinMinTime[ibin];
1425 abin->NHits[0] = sFgdTimeBinNHits1[ibin];
1426 abin->NHits[1] = sFgdTimeBinNHits2[ibin];
1427 abin->RawChargeSum[0] = sFgdTimeBinRawChargeSum1[ibin];
1428 abin->RawChargeSum[1] = sFgdTimeBinRawChargeSum2[ibin];
1441 void RedoTreeConverter::FillBeamInfo(
AnaBeamB* beam){
1459 track->
Index = itrk;
1460 track->
UniqueID = (trUniqueID)[itrk];
1463 track->
Charge = (trCharge)[itrk];
1464 track->
NHits = (trNHits)[itrk];
1465 track->
NNodes = (trNNodes)[itrk];
1466 track->
Momentum = (trMomentum)[itrk];
1468 track->
ToF.FGD1_FGD2 = (trToFFGD1_FGD2)[itrk];
1469 track->
ToF.P0D_FGD1 = (trToFP0D_FGD1)[itrk];
1470 track->
ToF.ECal_FGD1 = (trToFECal_FGD1)[itrk];
1471 track->
ToF.ECal_FGD2 = (trToFECal_FGD2)[itrk];
1472 track->
ToF.Flag_FGD1_FGD2 = (trToFFlag_FGD1_FGD2)[itrk];
1473 track->
ToF.Flag_P0D_FGD1 = (trToFFlag_P0D_FGD1)[itrk];
1474 track->
ToF.Flag_ECal_FGD1 = (trToFFlag_ECal_FGD1)[itrk];
1475 track->
ToF.Flag_ECal_FGD2 = (trToFFlag_ECal_FGD2)[itrk];
1481 anaUtils::CopyArray(trPositionStart[itrk], track->
PositionStart, 4);
1482 anaUtils::CopyArray(trPositionEnd[itrk], track->
PositionEnd, 4);
1483 anaUtils::CopyArray(trDirectionStart[itrk], track->
DirectionStart, 3);
1484 anaUtils::CopyArray(trDirectionEnd[itrk], track->
DirectionEnd, 3);
1488 FillSubdetectorInfo(event, itrk, track);
1491 FindTrueParticle(event, trTrueParticleID[itrk], track->
TrueObject);
1511 void RedoTreeConverter::FillTrackInfo(std::vector<AnaTrueParticleB*>& trueParticles,
int itrk,
AnaTrackB* track){
1514 track->
Index = itrk;
1515 track->
UniqueID = (trUniqueID)[itrk];
1518 track->
Charge = (trCharge)[itrk];
1519 track->
NHits = (trNHits)[itrk];
1520 track->
NNodes = (trNNodes)[itrk];
1521 track->
Momentum = (trMomentum)[itrk];
1523 track->
ToF.FGD1_FGD2 = (trToFFGD1_FGD2)[itrk];
1524 track->
ToF.P0D_FGD1 = (trToFP0D_FGD1)[itrk];
1525 track->
ToF.ECal_FGD1 = (trToFECal_FGD1)[itrk];
1526 track->
ToF.ECal_FGD2 = (trToFECal_FGD2)[itrk];
1527 track->
ToF.Flag_FGD1_FGD2 = (trToFFlag_FGD1_FGD2)[itrk];
1528 track->
ToF.Flag_P0D_FGD1 = (trToFFlag_P0D_FGD1)[itrk];
1529 track->
ToF.Flag_ECal_FGD1 = (trToFFlag_ECal_FGD1)[itrk];
1530 track->
ToF.Flag_ECal_FGD2 = (trToFFlag_ECal_FGD2)[itrk];
1536 anaUtils::CopyArray(trPositionStart[itrk], track->
PositionStart, 4);
1537 anaUtils::CopyArray(trPositionEnd[itrk], track->
PositionEnd, 4);
1538 anaUtils::CopyArray(trDirectionStart[itrk], track->
DirectionStart, 3);
1539 anaUtils::CopyArray(trDirectionEnd[itrk], track->
DirectionEnd, 3);
1543 FillSubdetectorInfo(trueParticles, itrk, track);
1546 FindTrueParticle(trueParticles, trTrueParticleID[itrk], track->
TrueObject);
1566 void RedoTreeConverter::FillSubdetectorInfo(std::vector<AnaTrueParticleB*>& trueParticles,
int itrk,
AnaTrackB* track){
1572 for (
int i = 0; i < SubDetId::kInvalidSubdetector; ++i){
1580 FillTpcInfo(trueParticles, itrk, tpc, seg);
1589 FillFgdInfo(itrk, fgd, seg);
1600 FillEcalInfo(itrk, ecal, seg);
1609 void RedoTreeConverter::FillSubdetectorInfo(
AnaEventB* event,
int itrk,
AnaTrackB* track){
1615 for (
int i = 0; i < SubDetId::kInvalidSubdetector; ++i){
1621 FillTpcInfo(event, itrk, tpc, seg);
1628 FillFgdInfo(itrk, fgd, seg);
1638 FillEcalInfo(itrk, ecal, seg);
1648 void RedoTreeConverter::FillTpcInfo(std::vector<AnaTrueParticleB*>& trueParticles,
int itrk,
int tpc,
AnaTPCParticleB* seg){
1653 seg->
Charge = (trTpcCharge)[itrk][tpc];
1654 seg->
NNodes = (int)(trTpcNNodes)[itrk][tpc];
1655 seg->
Momentum = (trTpcMomentum)[itrk][tpc];
1662 seg->
dEdxMeas = (trTpcdEdxMeas)[itrk][tpc];
1665 seg->
dEdxexpEle = (trTpcdEdxExpEle)[itrk][tpc];
1677 for (
int i=0;i<4;i++){
1679 seg->
PositionEnd[i] = (trTpcPositionEnd)[itrk][tpc][i];
1682 for (
int i=0;i<3;i++){
1688 FindTrueParticle(trueParticles, (trTpcTrueParticleID)[itrk][tpc], seg->
TrueObject);
1697 seg->
Charge = (trTpcCharge)[itrk][tpc];
1698 seg->
NNodes = (int)(trTpcNNodes)[itrk][tpc];
1699 seg->
Momentum = (trTpcMomentum)[itrk][tpc];
1707 seg->
dEdxMeas = (trTpcdEdxMeas)[itrk][tpc];
1710 seg->
dEdxexpEle = (trTpcdEdxExpEle)[itrk][tpc];
1722 for (
int i=0;i<4;i++){
1724 seg->
PositionEnd[i] = (trTpcPositionEnd)[itrk][tpc][i];
1727 for (
int i=0;i<3;i++){
1733 FindTrueParticle(event, (trTpcTrueParticleID)[itrk][tpc], seg->
TrueObject);
1737 void RedoTreeConverter::FillFgdInfo(
int itrk,
int fgd,
AnaFGDParticleB* seg){
1742 seg->
NNodes = (int)(trFgdNNodes)[itrk][fgd];
1745 seg->
Pullmu = (trFgdPullmu)[itrk][fgd];
1746 seg->
Pullp = (trFgdPullp)[itrk][fgd];
1747 seg->
Pullpi = (trFgdPullpi)[itrk][fgd];
1748 seg->
Pullno = (trFgdPullno)[itrk][fgd];
1750 seg->
X = (trFgdX)[itrk][fgd];
1762 for (
int i=0;i<4;i++){
1764 seg->
PositionEnd[i] = (trFgdPositionEnd)[itrk][fgd][i];
1767 for (
int i=0;i<3;i++){
1775 void RedoTreeConverter::FillEcalInfo(
int itrk,
int ecal,
AnaECALParticleB* seg){
1780 seg->
NNodes = (int)(trECALNNodes)[itrk][ecal];
1781 seg->
Length = (trECALLength)[itrk][ecal];
1782 seg->
EMEnergy = (trECALEMEnergy)[itrk][ecal];
1783 seg->
PIDMipEm = trECALPIDMipEm[itrk][ecal];
1784 seg->PIDEmHip = trECALPIDEmHip[itrk][ecal];
1793 for (
int i = 0; i < 3; i++){
1799 for (
int i = 0; i < 4; i++){
1800 seg->
PositionStart[i] = (trECALPositionStart)[itrk][ecal][i];
1807 void RedoTreeConverter::FillSmrdInfo(
int itrk,
int smrd,
AnaSMRDParticleB* seg){
1812 for (
int i=0;i<4;i++){
1813 seg->
PositionStart[i] = (trSMRDPositionStart)[itrk][smrd][i];
1814 seg->
PositionEnd[i] = (trSMRDPositionEnd)[itrk][smrd][i];
1817 for (
int i=0;i<3;i++){
1823 void RedoTreeConverter::FillP0dInfo(
int itrk,
int p0d,
AnaP0DParticleB* seg){
1828 seg->Length = (trP0DLength)[itrk][p0d];
1829 seg->ELoss = (trP0DELoss)[itrk][p0d];
1831 for (
int i=0;i<4;i++){
1833 seg->
PositionEnd[i] = (trP0DPositionEnd)[itrk][p0d][i];
1836 for (
int i=0;i<3;i++){
1842 void RedoTreeConverter::FillTrueParticleInfo(std::vector<AnaTrueVertexB*>& trueVertices,
int itrk,
AnaTrueParticleB* particle){
1844 particle->
ID = (sTrueParticleID)[itrk];
1845 particle->
ParentID = (sTrueParticleParentID)[itrk];
1846 particle->
PDG = (sTrueParticlePDG)[itrk];
1847 particle->
ParentPDG = (sTrueParticleParentPDG)[itrk];
1848 particle->
GParentPDG = (sTrueParticleGParentPDG)[itrk];
1850 particle->
Charge = (sTrueParticleCharge)[itrk];
1851 particle->
Momentum = (sTrueParticleMomentum)[itrk];
1853 anaUtils::CopyArray(sTrueParticlePosition[itrk], particle->
Position, 4);
1854 anaUtils::CopyArray(sTrueParticlePositionEnd[itrk], particle->
PositionEnd, 4);
1855 anaUtils::CopyArray(sTrueParticleDirection[itrk], particle->
Direction, 3);
1858 UInt_t nCrossings = sTrueParticleNDetCrossings[itrk];
1860 if( nCrossings==0 || nCrossings > NMAXCROSSEDDET ) nCrossings = NMAXCROSSEDDET;
1861 anaUtils::CreateArray(particle->
DetCrossings, nCrossings);
1862 for(UInt_t i=0;i<nCrossings;i++){
1863 if (sTrueParticleDetector[itrk][i]<0)
continue;
1867 cross->
InActive = (bool) sTrueParticleInActive[itrk][i];
1869 anaUtils::CopyArray(sTrueParticleEntrancePosition[itrk][i], cross->
EntrancePosition, 4);
1870 anaUtils::CopyArray(sTrueParticleExitPosition[itrk][i], cross->
ExitPosition, 4);
1877 particle->
VertexID = (sTrueParticleTruthVertexID)[itrk];
1879 for(UInt_t i = 0; i < trueVertices.size(); ++i){
1880 if(particle->
VertexID == trueVertices[i]->ID){
1895 particle->
ID = (sTrueParticleID)[itrk];
1896 particle->
ParentID = (sTrueParticleParentID)[itrk];
1897 particle->
PDG = (sTrueParticlePDG)[itrk];
1898 particle->
ParentPDG = (sTrueParticleParentPDG)[itrk];
1899 particle->
GParentPDG = (sTrueParticleGParentPDG)[itrk];
1901 particle->
Charge = (sTrueParticleCharge)[itrk];
1902 particle->
Momentum = (sTrueParticleMomentum)[itrk];
1904 anaUtils::CopyArray(sTrueParticlePosition[itrk], particle->
Position, 4);
1905 anaUtils::CopyArray(sTrueParticlePositionEnd[itrk], particle->
PositionEnd, 4);
1906 anaUtils::CopyArray(sTrueParticleDirection[itrk], particle->
Direction, 3);
1909 UInt_t nCrossings = sTrueParticleNDetCrossings[itrk];
1911 if( nCrossings==0 || nCrossings > NMAXCROSSEDDET ) nCrossings = NMAXCROSSEDDET;
1912 anaUtils::CreateArray(particle->
DetCrossings, nCrossings);
1913 for(UInt_t i=0;i<nCrossings;i++){
1914 if (sTrueParticleDetector[itrk][i]<0)
continue;
1918 cross->
InActive = (bool) sTrueParticleInActive[itrk][i];
1920 anaUtils::CopyArray(sTrueParticleEntrancePosition[itrk][i], cross->
EntrancePosition, 4);
1921 anaUtils::CopyArray(sTrueParticleExitPosition[itrk][i], cross->
ExitPosition, 4);
1928 particle->
VertexID = (sTrueParticleTruthVertexID)[itrk];
1929 for(
int i = 0; i <
event->nTrueVertices; ++i){
1932 particle->
TrueVertex =
event->TrueVertices[i];
1943 void RedoTreeConverter::FillTrueVertexInfo(
int ivtx,
AnaTrueVertexB* vertex){
1946 vertex->
ID = sTrueVertexID[ivtx];
1947 vertex->
NuPDG = sTrueVertexNuPDG[ivtx];
1948 vertex->
NuEnergy = sTrueVertexNuEnergy[ivtx];
1950 anaUtils::CopyArray(sTrueVertexPosition[ivtx], vertex->
Position, 4);
1952 vertex->
Bunch = sTrueVertexBunch[ivtx];
1955 anaUtils::CreateArray(vertex->
TrueParticles, sNTrueParticles);
1960 void RedoTreeConverter::FindTrueParticle(std::vector<AnaTrueParticleB*>& trueParticles,
int ID,
AnaTrueObjectC*& trueTrack){
1966 if (ID==-999)
return;
1968 for (UInt_t it = 0; it < trueParticles.size(); it++){
1970 if (ID == trueTrack2->
ID){
1971 trueTrack = trueTrack2;
1983 if (ID==-999)
return;
1985 for (
int it = 0; it <
event->nTrueParticles; it++){
1987 if (ID == trueTrack2->
ID){
1988 trueTrack = trueTrack2;
1999 anaUtils::CopyArray(vPosition[ivtx], vertex->
Position, 4);
2002 for (
int d = 0; d < vNReconParticles[ivtx]; d++) {
2003 AnaParticleB* matchedParticle = FindParticle(vParticlesUniqueID[ivtx][d], event);
2004 if ( ! matchedParticle)
continue;
2019 for (
int d = 0; d < vNTrueVerticesMatch[ivtx]; d++) {
2020 std::pair<AnaTrueVertexB*, AnaRecTrueMatchB> myMatch;
2021 int thisTrueVertexIndex = vTrueVertexIndex[ivtx][d];
2022 if (thisTrueVertexIndex == -1)
continue;
2023 if (thisTrueVertexIndex < -1 || thisTrueVertexIndex >= event->nTrueVertices)
2024 std::cout <<
"minor error 6789" << std::endl;
2026 myMatch.first =
event->TrueVertices[thisTrueVertexIndex];
2027 myMatch.second.Cleanliness = (vTrueVerticesClean)[ivtx][d];
2028 myMatch.second.Completeness = (vTrueVerticesCompl)[ivtx][d];
2042 vertex->
Bunch = (vBunch)[ivtx];
2043 anaUtils::CopyArray(vPosition[ivtx], vertex->
Position, 4);
2046 for (
int d = 0; d < vNReconParticles[ivtx]; d++) {
2047 AnaParticleB* matchedParticle = FindParticle(vParticlesUniqueID[ivtx][d], bunch);
2048 if ( ! matchedParticle)
continue;
2063 for (
int d = 0; d < vNTrueVerticesMatch[ivtx]; d++) {
2064 std::pair<AnaTrueVertexB*, AnaRecTrueMatchB> myMatch;
2065 int thisTrueVertexIndex = vTrueVertexIndex[ivtx][d];
2066 if (thisTrueVertexIndex == -1)
continue;
2067 if (thisTrueVertexIndex < -1 || thisTrueVertexIndex >= (
int)_spill->
TrueVertices.size())
2068 std::cout <<
"minor error 6789" << std::endl;
2070 myMatch.first = _spill->
TrueVertices[thisTrueVertexIndex];
2071 myMatch.second.Cleanliness = (vTrueVerticesClean)[ivtx][d];
2072 myMatch.second.Completeness = (vTrueVerticesCompl)[ivtx][d];
2087 for (
int ittrack = 0; ittrack <
event->nParticles; ittrack++) {
2089 if (ID == event->
Particles[ittrack]->
UniqueID)
return event->Particles[ittrack];
2101 if (event->
Bunch != -1)
2102 if ( ! suppress_err_msg) std::cout <<
"minor error 0999" << std::endl;
2113 std::vector<AnaParticleB*>::iterator ittrack;
2116 for (ittrack = bunch->
Particles.begin(); ittrack != bunch->
Particles.end(); ittrack++) {
2117 if (ID == (*ittrack)->UniqueID)
return *ittrack;
2123 if (ID == (*ittrack)->UniqueID)
return *ittrack;
2128 if ( ! suppress_err_msg) std::cout <<
"minor error 0999" << std::endl;
Float_t dEdxexpMuon
Expected dE/dx for a muon, based on the reconstructed momentum.
bool InActive
If the particle passes through an active part of the subdetector.
AnaTrueVertexB * TrueVertex
Pointer to the AnaTrueVertexB of the interaction that created this AnaTrueParticleB.
Float_t PositionStart[4]
The reconstructed start position of the particle.
Representation of the beam quality and perhaps other beam information as needed.
AnaTrueVertexB * TrueVertex
Representation of the ND280 data quality flags.
Int_t NuPDG
The PDG code of the incoming neutrino.
int nDetCrossings
The number of DetCrossing objects.
int nTrueParticles
How many true particles are associated with this vertex.
Float_t ExitPosition[4]
for each subdetector tell the exit position
AnaFgdTimeBinB ** FgdTimeBins
The FGD time bins.
static bool IsFGDDetector(SubDetId::SubDetEnum det)
Check if a detector enumeration refers to a FGD or not.
Int_t GetEvent(Long64_t &entry, AnaEventC *&event)
Float_t dEdxexpProton
Expected dE/dx for a proton, based on the reconstructed momentum.
AnaECALParticleB * ECALSegments[NMAXECALS]
The ECAL segments that contributed to this global track.
int nECALSegments
How many ECAL tracks are associated with this track.
std::vector< std::pair< AnaTrueVertexB *, AnaRecTrueMatchB > > TrueVerticesMatch
The true vertices that are associated with this global vertex, with the related cleanliness and compl...
void SetIsSandMC()
Set whether this event is from Sand MC.
Float_t Pullp
Proton pull, according to FGD information.
void ConvertTPCDetEnumToBitField(unsigned long &det, int tpc)
Convert the detector used array to the bit field used by psyche for TPC track segments.
AnaVertexB ** Vertices
The reconstructed objects in this bunch.
Representation of a true Monte Carlo vertex.
Float_t DirectionEnd[3]
The reconstructed end direction of the particle.
Float_t Position[4]
The identified position of the global vertex.
std::vector< AnaTrueVertexB * > TrueVertices
The true MC vertices used in this spill.
std::vector< AnaBunchC * > Bunches
The reconstructed objects, split into timing bunches.
AnaBeamB * Beam
The beam quality flags for this event.
Float_t Pullno
Dummy pull. If the FGD pulls weren't set, this is set to 1.
Int_t NNodes
The number of nodes in the reconstructed object.
Int_t GParentPDG
The PDG code of this particle's grandparent, or 0 if there is no grandparent.
Representation of an ECAL segment of a global track.
Float_t Pullpi
Pion pull, according to FGD information.
AnaTPCParticleB * TPCSegments[NMAXTPCS]
The TPC segments that contributed to this global track.
Float_t dEdxSigmaProton
Expected error on the dE/dx measurement, for the proton hypothesis.
AnaTrueObjectC * TrueObject
The link to the true oject that most likely generated this reconstructed object.
AnaToF ToF
Times of flight between pairs of detectors.
AnaEventInfoB * EventInfo
Run, sunrun, event, time stamp, etc.
static bool GetDetectorUsed(unsigned long BitField, SubDetId::SubDetEnum det)
Method to see if a certain subdetector or subdetector system is used.
virtual bool Initialize()
Float_t Momentum
The initial momentum of the true particle.
AnaParticleB ** Particles
The reconstructed objects in this bunch.
AnaTrueParticleB ** TrueParticles
The true particles associated with this vertex.
AnaBunchB * OutOfBunch
Reconstructed objects that didn't fit into one of the timing bunches.
Int_t Bunch
The bunch of the global vertex, based on the Position.T()
Long64_t GetEntries()
Return the total number of entries in the chain.
Float_t RangeMomentumMuon
Momentum by range calculated with muon hypothesis.
Float_t dEdxexpPion
Expected dE/dx for a pion, based on the reconstructed momentum.
Int_t VertexID
The TruthVertexID of the AnaTrueVertexB of the interaction that created this AnaTrueParticleB.
Int_t UniqueID
The UniqueID of this reconstructed object.
Float_t dEdxexpEle
Expected dE/dx for an electron, based on the reconstructed momentum.
Float_t Pullmu
Muon pull, according to FGD information.
Float_t Charge
The reconstructed charge of the particle.
Int_t ID
The ID of the trueObj, which corresponds to the ID of the TTruthParticle that created it...
std::vector< AnaVertexB * > Vertices
Float_t MomentumError
Error of the momentum at the start of the segment.
Float_t MomentumFlip
Momentum for the main PID hypothesis and reverse sense.
Float_t ShowerPosition[3]
The position of the shower-fit to this object by ecalRecon.
static void SetDetectorUsed(unsigned long &BitField, SubDetId::SubDetEnum det)
Method to set a certain subdetector or subdetector system to used used.
Float_t Momentum
The reconstructed momentum of the particle, at the start position.
Int_t Index
The index of this particle track in the vector of particles. TODO: Not sure it is needed (only use in...
int nTPCSegments
How many TPC tracks are associated with this track.
Representation of a true Monte Carlo trajectory/particle.
Float_t NuEnergy
The true energy of the incoming neutrino.
Representation of an SMRD segment of a global track.
Float_t Position[4]
The position the true interaction happened at.
Float_t dEdxSigmaEle
Expected error on the dE/dx measurement, for the electron hypothesis.
void ConvertECALDetEnumToBitField(unsigned long &det, int ecal)
Convert the detector used array to the bit field used by psyche for ECAL track segments.
Float_t EntrancePosition[4]
for each subdetector tell the entrance position
AnaBeamB * Beam
The beam quality flags for this spill.
static bool IsTPCDetector(SubDetId::SubDetEnum det)
Check if a detector enumeration refers to a TPC or not.
AnaDetCrossingB ** DetCrossings
static bool IsECALDetector(SubDetId::SubDetEnum det)
Check if a detector enumeration refers to a ECAL or not.
Representation of a detector crossing info for a true particle (G4 trajectory).
SubDetEnum
Enumeration of all detector systems and subdetectors.
Float_t EFieldRefitMomentum
Reconstructed momentum with the E-field distortion corrections.
Int_t PDG
The PDG code of this particle.
Int_t NHits
The number of hits in the particle.
void ConvertSMRDDetEnumToBitField(unsigned long &det, int smrd)
Convert the detector used array to the bit field used by psyche for SMRD track segments.
Int_t ParentPDG
The PDG code of this particle's immediate parent, or 0 if there is no parent.
void ConvertFGDDetEnumToBitField(unsigned long &det, int fgd)
Convert the detector used array to the bit field used by psyche for FGD track segments.
std::vector< AnaFgdTimeBinB * > FgdTimeBins
The FGD time bins.
Float_t dEdxMeas
dE/dx as measured by the TPC.
Representation of a global track.
Int_t Bunch
The index of this bunch (0-7).
AnaTrueVertexB * GetMainTrueVertex(bool warning=true)
The main true vertex that is associated with this global vertex.
Representation of a TPC segment of a global track.
Float_t Weight
The weight to apply to this bunch (nominally 1). An example is the beam flux weight.
int GetLocalDetEnum(SubDetId::SubDetEnum det, SubDetId::SubDetEnum idet)
Get old local detector enumeration to find array index of Flat tree.
UInt_t NTotalTrueVertices
std::vector< AnaTrueParticleB * > TrueParticles
The true MC particles used in this spill.
Representation of a global vertex.
void IncrementPOTBySpill()
Float_t Length
The length of the ECal segment.
virtual void DefineBranches()
Define the branches to be read from the input tree.
Float_t DirectionStart[3]
The reconstructed start direction of the particle.
Representation of a FGD segment of a global track.
void ConvertTrueParticleDetEnumToBitField(unsigned long &det, int DetUsed)
Convert the detector used array to the bit field used by psyche for truth trueParts.
Int_t Bunch
The index of this bunch (0-7).
Int_t PrimaryIndex
Index of the global vertex.
Int_t GoodSpill
Good spill flag, as defined in Beam Summary Data. 0 is bad.
Int_t Event
The ND280 event number.
int nFGDSegments
How many FGD tracks are associated with this track.
AnaTrueParticleB ** TrueParticles
The true MC particles used in this spill.
Float_t dEdxSigmaMuon
Expected error on the dE/dx measurement, for the muon hypothesis.
Int_t ParentID
The ID of this particle's immediate parent, or 0 if there is no parent.
Float_t PositionEnd[4]
The end position of the true particle.
Float_t Position[4]
The initial position of the true particle.
Int_t Containment
Containment flag required for proper PID analysis.
AnaTrueVertexB ** TrueVertices
The true MC vertices used in this spill.
std::vector< AnaParticleB * > Particles
Int_t MostUpStreamLayerHit
Innermost layer hit of the ecal object (used in ecal pi0 veto)
void ConvertTrackDetEnumToBitField(unsigned long &det, int DetUsed[])
Convert the detector used array to the bit field used by psyche for ana tracks.
Representation of a P0D segment of a global track.
Float_t dEdxSigmaPion
Expected error on the dE/dx measurement, for the pion hypothesis.
Float_t Charge
The true charge of the particle.
Int_t GetSpill(Long64_t &entry, AnaSpillC *&spill)
AnaDataQualityB * DataQuality
The ND280 data quality flags for this event.
Representation of a reconstructed particle (track or shower).
AnaDataQualityB * DataQuality
The ND280 data quality flags for this spill.
bool IsMC
Says if the event is MC or data.
Float_t Direction[3]
The initial direction of the true particle.
UInt_t NTotalTrueParticles
AnaFGDParticleB * FGDSegments[NMAXFGDS]
The FGD segments that contributed to this global track.
virtual bool AddFileToTChain(const std::string &inputString)
Add the file specified to fChain, and any friend chains that were set up.
Float_t PositionEnd[4]
The reconstructed end position of the particle.
Float_t RefitMomentum
Reconstructed momentum with the empirical distortion corrections.
Int_t Run
The ND280 run number.