HighLAND
CreateFlatTree.cxx
1 #include "CreateFlatTree.hxx"
2 #include "InputManager.hxx"
3 #include "FlatTreeConverter.hxx"
4 #include "oaAnalysisTreeConverter.hxx"
5 #include "HighlandMiniTreeConverter.hxx"
6 #include "Parameters.hxx"
7 #include "Versioning.hxx"
8 #include "HighlandAnalysisUtils.hxx"
9 
10 #include "CorrId.hxx"
11 
12 // Corrections
13 #include "CT4POTCorrection.hxx"
14 #include "DataQualityCorrection.hxx"
15 #include "PileUpCorrection.hxx"
16 #include "TPCdEdxDataCorrection.hxx"
17 #include "TPCdEdxMCCorrection.hxx"
18 #include "TPCExpecteddEdxCorrection.hxx"
19 #include "IgnoreRightECalRuns3and4Correction.hxx"
20 #include "UseGlobalAltMomCorrection.hxx"
21 #include "FlipKinematicsCorrection.hxx"
22 #include "ToFCorrection.hxx"
23 #include "MomResolMCCorrection.hxx"
24 #include "MomRangeCorrection.hxx"
25 #include "TPCPIDPullMCCorrection.hxx"
26 
27 
28 
29 
30 //********************************************************************
31 CreateFlatTree::CreateFlatTree(int argc, char *argv[]):SimpleLoopBase(argc, argv){
32 //********************************************************************
33 
34  // Add the different productions
35  ND::versioning().AddProduction(ProdId::PROD5E, "PROD5E", "v10r11p17", "v10r11p18");
36  ND::versioning().AddProduction(ProdId::PROD5F, "PROD5F", "v10r11p19", "v10r11p24");
37  ND::versioning().AddProduction(ProdId::PROD5G, "PROD5G", "v10r11p27", "v10r11p28");
38  ND::versioning().AddProduction(ProdId::PROD6PRE, "PROD6PRE", "v11r17", "v11r28");
39  ND::versioning().AddProduction(ProdId::PROD6A, "PROD6A", "v11r29", "v11r30");
40  ND::versioning().AddProduction(ProdId::PROD6BC, "PROD6B/6C", "v11r31", "v11r32");
41  //May change when production evolves
42  ND::versioning().AddProduction(ProdId::PROD7DEVEL, "PROD7DEVEL", "v12", "v13");
43 
44  // Add package versions to be saved in config tree
45  ND::versioning().AddPackage("psycheCore", anaUtils::GetSoftwareVersionFromPath((std::string)getenv("PSYCHECOREROOT")));
46  ND::versioning().AddPackage("psycheUtils", anaUtils::GetSoftwareVersionFromPath((std::string)getenv("PSYCHEUTILSROOT")));
47  ND::versioning().AddPackage("highlandCore", anaUtils::GetSoftwareVersionFromPath((std::string)getenv("HIGHLANDCOREROOT")));
48  ND::versioning().AddPackage("highlandCorrections", anaUtils::GetSoftwareVersionFromPath((std::string)getenv("HIGHLANDCORRECTIONSROOT")));
49  ND::versioning().AddPackage("highlandIO", anaUtils::GetSoftwareVersionFromPath((std::string)getenv("HIGHLANDIOROOT")));
50 
51 
52  // add the different converters
53  input().AddConverter("FlatTree", new FlatTreeConverter(true));
54  input().AddConverter("MiniTree", new HighlandMiniTreeConverter(true));
55  input().AddConverter("oaAnalysisTree", new oaAnalysisTreeConverter());
56 
57 }
58 //********************************************************************
60 //********************************************************************
61  // save only true tracks and vertices with recon association
62  _saveTruthWithRecon = (bool)ND::params().GetParameterI("highlandIO.FlatTree.SaveTruthWithReconAssociation");
63  _saveRoo = (bool)ND::params().GetParameterI("highlandIO.FlatTree.SaveRooTracker");
64 
65  _saveTPCInfo = (bool)ND::params().GetParameterI("highlandIO.FlatTree.SaveTPCInfo");
66  _saveFGDInfo = (bool)ND::params().GetParameterI("highlandIO.FlatTree.SaveFGDInfo");
67  _saveECALInfo = (bool)ND::params().GetParameterI("highlandIO.FlatTree.SaveECALInfo");
68  _saveP0DInfo = (bool)ND::params().GetParameterI("highlandIO.FlatTree.SaveP0DInfo");
69  _saveSMRDInfo = (bool)ND::params().GetParameterI("highlandIO.FlatTree.SaveSMRDInfo");
70  _saveTrackerInfo = (bool)ND::params().GetParameterI("highlandIO.FlatTree.SaveTrackerInfo");
71 
72  // save info from the local reconstruction to the flat tree?
73  _saveReconDirFGDOnlyInfo = (bool)ND::params().GetParameterI("highlandIO.FlatTree.UseReconDirFGDOnly" );
74  _saveReconDirP0DInfo = (bool)ND::params().GetParameterI("highlandIO.FlatTree.UseReconDirP0D" );
75  _saveReconDirPECALInfo = (bool)ND::params().GetParameterI("highlandIO.FlatTree.UseReconDirP0DECal" );
76  _saveReconDirTECALInfo = (bool)ND::params().GetParameterI("highlandIO.FlatTree.UseReconDirTrackerECal");
77 
78  _useTPC1 = (bool)ND::params().GetParameterI("highlandIO.FlatTree.UseTPC1");
79  _useTPC2 = (bool)ND::params().GetParameterI("highlandIO.FlatTree.UseTPC2");
80  _useTPC3 = (bool)ND::params().GetParameterI("highlandIO.FlatTree.UseTPC3");
81  _useFGD1 = (bool)ND::params().GetParameterI("highlandIO.FlatTree.UseFGD1");
82  _useFGD2 = (bool)ND::params().GetParameterI("highlandIO.FlatTree.UseFGD2");
83  _useP0D = (bool)ND::params().GetParameterI("highlandIO.FlatTree.UseP0D");
84  _useDsECal = (bool)ND::params().GetParameterI("highlandIO.FlatTree.UseDsECal");
85  _useTrECal = (bool)ND::params().GetParameterI("highlandIO.FlatTree.UseTrECal");
86  _useP0DECal = (bool)ND::params().GetParameterI("highlandIO.FlatTree.UseP0DECal");
87  _useSMRD = (bool)ND::params().GetParameterI("highlandIO.FlatTree.UseSMRD");
88 
89  _useTPC1outOfBunch = (bool)ND::params().GetParameterI("highlandIO.FlatTree.UseTPC1outOfBunch");
90  _useTPC2outOfBunch = (bool)ND::params().GetParameterI("highlandIO.FlatTree.UseTPC2outOfBunch");
91  _useTPC3outOfBunch = (bool)ND::params().GetParameterI("highlandIO.FlatTree.UseTPC3outOfBunch");
92  _useFGD1outOfBunch = (bool)ND::params().GetParameterI("highlandIO.FlatTree.UseFGD1outOfBunch");
93  _useFGD2outOfBunch = (bool)ND::params().GetParameterI("highlandIO.FlatTree.UseFGD2outOfBunch");
94  _useP0DoutOfBunch = (bool)ND::params().GetParameterI("highlandIO.FlatTree.UseP0DoutOfBunch");
95  _useDsECaloutOfBunch = (bool)ND::params().GetParameterI("highlandIO.FlatTree.UseDsECaloutOfBunch");
96  _useTrECaloutOfBunch = (bool)ND::params().GetParameterI("highlandIO.FlatTree.UseTrECaloutOfBunch");
97  _useP0DECaloutOfBunch = (bool)ND::params().GetParameterI("highlandIO.FlatTree.UseP0DECaloutOfBunch");
98  _useSMRDoutOfBunch = (bool)ND::params().GetParameterI("highlandIO.FlatTree.UseSMRDoutOfBunch");
99 
100  _saveTrueNuNC = (bool)ND::params().GetParameterI("highlandIO.FlatTree.TrueVertex.NuNC");
101  _saveTrueAntiNuNC = (bool)ND::params().GetParameterI("highlandIO.FlatTree.TrueVertex.AntiNuNC");
102  _saveTrueNumuCC = (bool)ND::params().GetParameterI("highlandIO.FlatTree.TrueVertex.NumuCC");
103  _saveTrueAntiNumuCC = (bool)ND::params().GetParameterI("highlandIO.FlatTree.TrueVertex.AntiNumuCC");
104  _saveTrueNueCC = (bool)ND::params().GetParameterI("highlandIO.FlatTree.TrueVertex.NueCC");
105  _saveTrueAntiNueCC = (bool)ND::params().GetParameterI("highlandIO.FlatTree.TrueVertex.AntiNueCC");
106 
107 
108  if (ND::params().GetParameterI("highlandIO.FlatTree.TrueVertex.TPC1")) _saveTrueVertexInDet.push_back(SubDetId::kTPC1);
109  if (ND::params().GetParameterI("highlandIO.FlatTree.TrueVertex.TPC2")) _saveTrueVertexInDet.push_back(SubDetId::kTPC2);
110  if (ND::params().GetParameterI("highlandIO.FlatTree.TrueVertex.TPC3")) _saveTrueVertexInDet.push_back(SubDetId::kTPC3);
111  if (ND::params().GetParameterI("highlandIO.FlatTree.TrueVertex.FGD1")) _saveTrueVertexInDet.push_back(SubDetId::kFGD1);
112  if (ND::params().GetParameterI("highlandIO.FlatTree.TrueVertex.FGD2")) _saveTrueVertexInDet.push_back(SubDetId::kFGD2);
113  if (ND::params().GetParameterI("highlandIO.FlatTree.TrueVertex.P0D")) _saveTrueVertexInDet.push_back(SubDetId::kP0D);
114  if (ND::params().GetParameterI("highlandIO.FlatTree.TrueVertex.DsECal")) _saveTrueVertexInDet.push_back(SubDetId::kDSECAL);
115  if (ND::params().GetParameterI("highlandIO.FlatTree.TrueVertex.TrECal")) _saveTrueVertexInDet.push_back(SubDetId::kTECAL);
116  if (ND::params().GetParameterI("highlandIO.FlatTree.TrueVertex.P0DECal")) _saveTrueVertexInDet.push_back(SubDetId::kPECAL);
117  if (ND::params().GetParameterI("highlandIO.FlatTree.TrueVertex.SMRD")) _saveTrueVertexInDet.push_back(SubDetId::kSMRD);
118 
119 
120  // Check software version compatibility between nd280AnalysisTools and current file
121  if (_versionCheck){
122  if(!ND::versioning().CheckVersionCompatibility(input().GetSoftwareVersion(),anaUtils::GetProductionIdFromND280AnalysisTools())) return false;
123  }
124 
125  // Select the production based on the software version of the input file. This will be used to select the appropriate corrections,
126  // bunching, systematics, etc. Assume production 5 when no software version exists
127  versionUtils::prod6_bunching = false;
128  versionUtils::prod6_corrections = false;
129  versionUtils::prod6_systematics = false;
130  if (_versionCheck){
131  if (ND::versioning().GetProduction(input().GetSoftwareVersion()) >= ProdId::PROD6PRE){
132  versionUtils::prod6_bunching = true;
133  versionUtils::prod6_corrections = true;
134  versionUtils::prod6_systematics = true;
135  }
136  }
137 
138  // Dump the production used for corrections, bunching, systematics, etc
139  versionUtils::DumpProductions();
140 
141  _POTSincePreviousSpill = 0;
142  _spill_filled = false;
143 
144 
145  // Enable any corrections that have to be done while the flat tree is being created.
146  // Ignore right ECal for runs 3 and 4 as part of it is broken.
147  if (ND::params().GetParameterI("highlandIO.FlatTree.EnableIgnoreRightECalCorrection")){
148  _corrections.AddCorrection(CorrId::kRightECalRun3And4Corr, "ignorerightecal_corr", new IgnoreRightECalRuns3and4Correction());
149  }
150 
151  if (ND::params().GetParameterI("highlandIO.FlatTree.EnableDQCorrection")) {
152  // Correct the data quality in periods when a FGD FEB wasn't working.
153  _corrections.AddCorrection(CorrId::kDQCorr, "dq_corr", new DataQualityCorrection());
154  }
155 
156 
157 #if !VERSION_HAS_OFFICIAL_POT
158  // Only need this correction for P5 files.
159 
160  if (ND::params().GetParameterI("highlandIO.FlatTree.EnablePOTCorrection")) {
161  // Use CT4 for MR44 POT accounting, as CT5 wasn't working properly.
162  _corrections.AddCorrection(CorrId::kCT4POTCorr, "ct4pot_corr", new CT4POTCorrection());
163  }
164 #endif
165 
166  // Change the main fit momentum by the muon alternate momentum, but only for P5
167 #if !VERSION_HAS_EQUIVALENT_MAIN_AND_ALT_FITS
168  if (ND::params().GetParameterI("highlandIO.FlatTree.EnableUseMuonAltMomCorrection")) {
169  _corrections.AddCorrection(CorrId:: kGlobalAltMomCorr, "altmom_corr", new UseGlobalAltMomCorrection(UseGlobalAltMomCorrection::kMuon));
170  }
171 #endif
172 
173 
174  if (ND::params().GetParameterI("highlandIO.FlatTree.EnablePileUpCorrection")){
175  _corrections.AddCorrection(CorrId::kPileUpCorr, "pileup_corr", new PileUpCorrection());
176  }
177  // Apply the TPC dE/dx correction in all configurations
178  if (ND::params().GetParameterI("highlandIO.FlatTree.EnableTPCdEdxDataCorrection")){
179  _corrections.AddCorrection(CorrId::kTPCdEdxDataCorr, "tpcdedx_data_corr", new TPCdEdxDataCorrection());
180  }
181  // Apply the TPC dE/dx correction in all configurations
182  if (ND::params().GetParameterI("highlandIO.FlatTree.EnableTPCdEdxMCCorrection")){
183  _corrections.AddCorrection(CorrId::kTPCdEdxMCCorr, "tpcdedx_mc_corr", new TPCdEdxMCCorrection());
184  }
185  // Apply the TPC expected dE/dx correction in all configurations
186  if (ND::params().GetParameterI("highlandIO.FlatTree.EnableTPCExpecteddEdxCorrection")){
187  _corrections.AddCorrection(CorrId::kTPCdEdxExpCorr, "tpcexpecteddedx_corr", new TPCExpecteddEdxCorrection());
188  }
189 
190  // Apply the TPC PID correction based on pull params smearing
191  if (ND::params().GetParameterI("highlandIO.FlatTree.EnableTPCPIDPullMCCorrection")){
192  _corrections.AddCorrection(CorrId::kTPCPIDPullMCCorr, "tpc_pid_pull_mc_corr", new TPCPIDPullMCCorrection());
193  }
194 
195  if (ND::params().GetParameterI("highlandIO.FlatTree.EnableMomResolMCCorrection")){
196  _corrections.AddCorrection(CorrId::kMomResolMCCorr, "mom_resol_mc_corr", new MomResolMCCorrection());
197  }
198 
199  // Need to be called before the ToF in order to correctly flip a track if required
200  if (ND::params().GetParameterI("highlandIO.FlatTree.EnableFlipKinematicsCorrection")){
201  _corrections.AddCorrection(CorrId::kFlipKinCorr, "flipkinematics_corr", new FlipKinematicsCorrection());
202  }
203 
204  if (ND::params().GetParameterI("highlandIO.FlatTree.EnableToFCorrection")){
205  _corrections.AddCorrection(CorrId::kToFCorr, "tof_corr", new ToFCorrection());
206  }
207 
208 
209  if (ND::params().GetParameterI("highlandIO.FlatTree.EnableMomRangeCorrection")){
210  _corrections.AddCorrection(CorrId::kMomRangeCorr, "momrange_corr", new MomRangeCorrection());
211  }
212 
213 
214  return true;
215 }
216 
217 //********************************************************************
219 //********************************************************************
220 
221  // Add a new tree called "flattree"
222  AddTreeWithName(flattree,"flattree");
223 
224  // Add a tree to save the truth info as a clone of the TruthDir/NRooTrackerVtx tree.
225  // oaAnalysis tree converter has already dealt with the NRooTrackerVtx bit for us.
226  if (input().GetChain("NRooTrackerVtx") && _saveRoo)
227  AddTreeWithName(RooTrackerVtx, "RooTrackerVtx", input().GetChain("NRooTrackerVtx"));
228 
229  if (input().GetChain("GRooTrackerVtx") && _saveRoo)
230  AddTreeWithName(RooTrackerVtx, "RooTrackerVtx", input().GetChain("GRooTrackerVtx"));
231 
232 
233  SetCurrentTree(flattree);
234  SetFillSingleTree(GetCurrentTree());
235 
236 
237  // -------- Define variables to be put to the flat tree ----------------------
238  AnaBunchIO *bunch = new AnaBunchIO ();
239  AnaECALParticleIO *ecal = new AnaECALParticleIO ();
240  AnaFgdTimeBinIO *fgdTimeBin = new AnaFgdTimeBinIO ();
241  AnaFGDParticleIO *fgd = new AnaFGDParticleIO ();
242  AnaP0DParticleIO *p0d = new AnaP0DParticleIO ();
243  AnaSMRDParticleIO *smrd = new AnaSMRDParticleIO ();
244  AnaSpillIO *spill = new AnaSpillIO ();
245  AnaTECALReconObjectIO *tecalRecon = new AnaTECALReconObjectIO ();
246  AnaTECALUnmatchedObjectIO *tecalUnmatched = new AnaTECALUnmatchedObjectIO ();
247  AnaP0DReconVertexIO *p0dVertex = new AnaP0DReconVertexIO ();
248  AnaP0DReconParticleIO *p0dParticle = new AnaP0DReconParticleIO ();
249  AnaTPCParticleIO *tpc = new AnaTPCParticleIO ();
250  AnaTrackIO *track = new AnaTrackIO ();
251  AnaTrackerTrackIO *tracker = new AnaTrackerTrackIO ();
252  AnaTrueParticleIO *trueParticle = new AnaTrueParticleIO ();
253  AnaTrueVertexIO *trueVertex = new AnaTrueVertexIO ();
254  AnaVertexIO *vertex = new AnaVertexIO ();
255 
256  //------------ spill variables -------
257  // evt, run, spill, etc Includes Beam and Data quality
258  DefineSpill(spill);
259 
260  AddVar(sPOTSincePreviousSpill,"sPOTSincePreviousSpill","D","");
261 
262  // All true vertices
263  DefineTrueVertex(trueVertex);
264 
265  // All true tracks
266  DefineTrueParticle(trueParticle);
267 
268  // FGD time bins
269  DefineFgdTimeBin(fgdTimeBin);
270 
271  // Summary info about bunch
272  DefineBunch(bunch);
273 
274  if (_saveTPCInfo) DefineTPCParticle (tpc ); // TPC constituents
275  if (_saveFGDInfo) DefineFGDParticle (fgd ); // FGD constituents
276  if (_saveECALInfo) DefineECALParticle (ecal ); // ECAL constituents
277  if (_saveSMRDInfo) DefineSMRDParticle (smrd ); // SMRD constituents
278  if (_saveP0DInfo) DefineP0DParticle (p0d ); // P0D constituents
279  if (_saveTrackerInfo) DefineTrackerTrack(tracker); // Tracker constiruents
280 
281  // Global track info
282  DefineTrack(track);
283 
284  // Info from local reconstruction
285  if (_saveReconDirTECALInfo){
286  DefineTECALReconObject (tecalRecon ); // ReconDir/TrackerECal
287  DefineTECALUnmatchedObject(tecalUnmatched); // ReconDir/TrackerECal
288  }
289  if (_saveReconDirP0DInfo){
290  DefineP0DReconVertex (p0dVertex ); // ReconDir/P0D
291  DefineP0DReconParticle(p0dParticle); // ReconDir/P0D
292  }
293 
294  //------------ Vertices
295  DefineVertex(vertex);
296  _POTSincePreviousSpill=0;
297 
298  delete fgdTimeBin;
299  delete bunch;
300  delete ecal;
301  delete fgd;
302  delete p0d;
303  delete p0dVertex;
304  delete p0dParticle;
305  delete smrd;
306  delete spill;
307  delete tecalRecon;
308  delete tecalUnmatched;
309  delete tpc;
310  delete track;
311  delete tracker;
312  delete trueParticle;
313  delete trueVertex;
314  delete vertex;
315 }
316 
317 
318 //********************************************************************
320 //********************************************************************
321 
322  _spill_filled=false;
323 
324  // Set the tree to fill
325  SetFillSingleTree(flattree);
326  SetCurrentTree(flattree);
327 
328  AnaSpill& spill = *static_cast<AnaSpill*>(&input().GetCorrectedSpill());
329 
330  // Accumulate POT since previous spill saved
331  _POTSincePreviousSpill += static_cast<const AnaBeam*>(spill.Beam)->POT;
332 
333  // Analyse OutOfBunch for first for having AnaTrack when associating vertex constituents
334  std::vector<AnaBunchC*> outplusbunches;
335  outplusbunches.push_back(spill.OutOfBunch);
336  for (unsigned int b = 0; b < spill.Bunches.size(); b++){
337  outplusbunches.push_back(spill.Bunches[b]);
338  }
339 
340  //------ Loop over outofbunch+bunches --------------
341  for (unsigned int b=0; b < outplusbunches.size(); b++){
342 
343  AnaBunch* bunch = static_cast<AnaBunch*>(outplusbunches[b]);
344 
345  if (!bunch) continue;
346 
347  // Check whether there are FGD or TPC reconstructed tracks in the bunch
348  bool ok_recon = CheckReconFillFlatTree(*bunch);
349 
350  // Stop if there is no interesting recon info
351  if (!ok_recon) continue;
352 
353  // Put all variables to their default value
354  InitializeTree(GetCurrentTree());
355 
356  // Summary info for the spill + Beam + DQ + trigger
357  AnaSpill* spill = static_cast<AnaSpill*>(&input().GetSpill());
358  AnaSpillIO spill_io(*spill);
359 
360  // When the RooTrackerVtx tree is saved in the output file the entry must be recomputed (is not the one in the input file)
361  if (HasTree(RooTrackerVtx))
362  spill_io.RooVtxEntry = _rooVtxManager.GetRooVtxEntry();
363 
364  // Summary info for the spill + Beam + DQ
365  spill_io.Write(*this, "s");
366 
367 
368  AnaBunchIO bunch_io(*bunch);
369 
370  // Fill Bunch variables
371  WriteBunch(&bunch_io);
372 
373  // Fill spill first for having AnaTrueParticle and AnaTrueVertex to point to
374  // Fill spill && truth info only for the first bunch saved
375  if (!_spill_filled) {
376  // TrueVertices and FgdTimeBins
377  FillSpillVariables();
378 
379  // Fill the RooTrackerVtx tree
380  if (HasTree(RooTrackerVtx)){
381  OutputManager::FillTree(RooTrackerVtx);
382  _rooVtxManager.IncrementRooVtxEntry();
383  }
384 
385  _spill_filled = true;
386  }
387 
388  //------ Particles ----------
389  for (UInt_t i = 0; i < bunch->Particles.size(); i++){
390  AnaTrack* track = static_cast<AnaTrack*>(bunch->Particles[i]);
391 
392  if (!track) continue;
393 
394 
395  // TPC constituent variables
396  if (_saveTPCInfo) {
397  ResetCheckWriteSegment();
398  for (int j = 0; j < track->nTPCSegments; j++){
399  AnaTPCParticle* particle = static_cast<AnaTPCParticle*>(track->TPCSegments[j]);
400  AnaTPCParticleIO particle_io(*particle);
401  if (CheckWriteSegment(SubDetId::kTPC, *track->TPCSegments[j])) WriteTPCParticle(&particle_io);
402  }
403  }
404 
405  // FGD constituent variables
406  if (_saveFGDInfo) {
407  ResetCheckWriteSegment();
408  for (int j = 0; j < track->nFGDSegments; j++){
409  AnaFGDParticle* particle = static_cast<AnaFGDParticle*>(track->FGDSegments[j]);
410  AnaFGDParticleIO particle_io(*particle);
411  if (CheckWriteSegment(SubDetId::kFGD, *track->FGDSegments[j])) WriteFGDParticle(&particle_io);
412  }
413  }
414 
415  // ECAL constituent variables
416  if (_saveECALInfo) {
417  ResetCheckWriteSegment();
418  for (int j = 0; j < track->nECALSegments; j++){
419  AnaECALParticle* particle = static_cast<AnaECALParticle*>(track->ECALSegments[j]);
420  AnaECALParticleIO particle_io(*particle);
421  if (CheckWriteSegment(SubDetId::kECAL, *track->ECALSegments[j])) WriteECALParticle(&particle_io);
422  }
423  }
424 
425  // SMRD constituent variables
426  if (_saveSMRDInfo) {
427  ResetCheckWriteSegment();
428  for (int j = 0; j < track->nSMRDSegments; j++){
429  AnaSMRDParticle* particle = static_cast<AnaSMRDParticle*>(track->SMRDSegments[j]);
430  AnaSMRDParticleIO particle_io(*particle);
431 
432  if (CheckWriteSegment(SubDetId::kSMRD, *track->SMRDSegments[j])) WriteSMRDParticle(&particle_io);
433  }
434  }
435 
436  // P0D constituent variables
437  if (_saveP0DInfo) {
438  ResetCheckWriteSegment();
439  for (int j = 0; j < track->nP0DSegments; j++){
440  AnaP0DParticle* particle = static_cast<AnaP0DParticle*>(track->P0DSegments[j]);
441  AnaP0DParticleIO particle_io(*particle);
442 
443  if (CheckWriteSegment(SubDetId::kP0D, *track->P0DSegments[j])) WriteP0DParticle(&particle_io);
444  }
445  }
446 
447  // TRACKER constituent variables
448  if (_saveTrackerInfo) {
449  std::vector<AnaTrackerTrackB*> trackers = track->TRACKERSegments;
450  for (unsigned int j = 0; j < trackers.size(); j++){
451  AnaTrackerTrack* tracker = static_cast<AnaTrackerTrack*>(trackers[j]);
452 
453  AnaTrackerTrackIO tracker_io(*tracker);
454 
455  WriteTrackerTrack(&tracker_io, j);
456  }
457  }
458 
459  AnaTrackIO track_io(*track);
460 
461  // Summary info for the track (adds a new track to the vector)
462  WriteTrack(&track_io);
463  }
464 
465  // Write TECALReconObjects to the bunch ?
466  if (_saveReconDirTECALInfo){
467 
468  // Cast the AnaBunch pointer to an AnaLocalReconBunch
469  AnaLocalReconBunch* localBunch = static_cast<AnaLocalReconBunch*>(bunch);
470 
471  // Iterate over the vector of AnaTECALReconObjects belonging to the bunch and write them
472  // to the flat tree.
473  for (std::vector<AnaTECALReconObject*>::const_iterator it = localBunch->TECALReconObjects.begin(); it != localBunch->TECALReconObjects.end(); it++){
474 
475  AnaTECALReconObject* object = static_cast<AnaTECALReconObject*>(*it);
476  AnaTECALReconObjectIO object_ecal(*object);
477 
478  WriteTECALReconObject(&object_ecal);
479  }
480 
481  // Iterate over the vector of AnaTECALUnmatchedObjects belonging to the bunch and write them
482  // to the flat tree.
483  for (std::vector<AnaTECALUnmatchedObject*>::const_iterator it=localBunch->TECALUnmatchedObjects.begin(); it!=localBunch->TECALUnmatchedObjects.end(); it++){
484 
485  AnaTECALUnmatchedObject* object = static_cast<AnaTECALUnmatchedObject*>(*it);
486  AnaTECALUnmatchedObjectIO object_ecal(*object);
487 
488 
489  WriteTECALUnmatchedObject(&object_ecal);
490  }
491  }
492 
493  // Write P0DReconObjects to the bunch?
494  if (_saveReconDirP0DInfo){
495 
496  // Cast the AnaBunch pointer to an AnaLocalReconBunch
497  AnaLocalReconBunch* localBunch = static_cast<AnaLocalReconBunch*>(bunch);
498 
499 
500  // Iterate over the vector of AnaP0DReconVertex objects belonging to the bunch and write them
501  for (std::vector<AnaP0DReconVertex*>::const_iterator it = localBunch->P0DReconVertices.begin(); it != localBunch->P0DReconVertices.end(); it++){
502 
503  AnaP0DReconVertex* object = static_cast<AnaP0DReconVertex*>(*it);
504  AnaP0DReconVertexIO object_p0d(*object);
505 
506  WriteP0DReconVertex(&object_p0d);
507  }
508 
509  // Iterate over the vector of AnaP0DReconParticle objects belonging to the bunch and write them
510  for (std::vector<AnaP0DReconParticle*>::const_iterator it = localBunch->P0DReconParticles.begin(); it!=localBunch->P0DReconParticles.end(); it++){
511 
512  AnaP0DReconParticle* object = static_cast<AnaP0DReconParticle*>(*it);
513  AnaP0DReconParticleIO object_p0d(*object);
514 
515  WriteP0DReconParticle(&object_p0d);
516  }
517  }
518 
519 
520  //------ Vertices ----------
521  std::vector<int> trueVertexIndices;
522  for (unsigned int i = 0; i < bunch->Vertices.size(); i++) {
523  //Save the trueVertexIndex instead of ID to speed up associations in FlatTreeConverter
524  AnaTrueVertexB* MatchedTrueVertices[100];
525  int nMatchedTrueVertices = bunch->Vertices[i]->GetTrueVertices(MatchedTrueVertices);
526  trueVertexIndices.clear();
527  for (int j = 0; j < nMatchedTrueVertices; j++) {
528  int trueVertexIndex = FindTrueVertexIndex(MatchedTrueVertices[j]);
529  trueVertexIndices.push_back(trueVertexIndex);
530  }
531 
532  AnaVertex* vertex_tmp = static_cast<AnaVertex*>(bunch->Vertices[i]);
533  AnaVertexIO vertex(*vertex_tmp);
534 
535  // Summary info for the vertex (adds a new vertex to the vector)
536  WriteVertex(&vertex, trueVertexIndices);
537  }
538 
539  // fill the flat tree
540  FillFlatTree();
541  }
542 
543  // Fill spill and truth info when there are no bunches
544  if (!_spill_filled){
545 
546  // Check whether this event is true signal (for eff calculation)
547  bool ok_truth = CheckTruthFillFlatTree(spill);
548  if (ok_truth){
549 
550  InitializeTree(GetCurrentTree());
551 
552  AnaSpill* spill_tmp = static_cast<AnaSpill*>(&input().GetSpill());
553  AnaSpillIO spill(*spill_tmp);
554 
555  // When the RooTrackerVtx tree is saved in the output file the entry must be recomputed (is not the one in the input file)
556  if (HasTree(RooTrackerVtx))
557  spill.RooVtxEntry = _rooVtxManager.GetRooVtxEntry();
558 
559  // Summary info for the spill + Beam + DQ
560  spill.Write(*this, "s");
561 
562  // TrueVertices and FgdTimeBins
563  FillSpillVariables();
564 
565  // Fill the flattree
566  FillFlatTree();
567 
568  // Fill the RooTrackerVtx tree
569  if (HasTree(RooTrackerVtx)){
570  OutputManager::FillTree(RooTrackerVtx);
571  _rooVtxManager.IncrementRooVtxEntry();
572  }
573 
574  _spill_filled = true;
575  }
576  }
577 
578  return true;
579 }
580 
581 //********************************************************************
583 //********************************************************************
584 
585  if (_spill_filled) return;
586 
587  // Fill the info for th last processed spill such that we keep track of the total POT since the last saved entry.
588 
589  InitializeTree(GetCurrentTree());
590 
591  // Summary info for the spill + Beam + DQ
592  // input().GetSpill().Write(*this, "s");
593 
594  // Fill the flattree
595  FillFlatTree();
596 }
597 
598 //********************************************************************
599 void CreateFlatTree::FillSpillVariables(){
600 //********************************************************************
601 
602  // True vertex variables
603  _savedTrueVertices.clear();
604 
605  AnaSpill& spill = *static_cast<AnaSpill*>(&input().GetCorrectedSpill());
606 
607  for (unsigned int i=0; i<spill.TrueVertices.size(); i++){
608 
609  AnaTrueVertex* vertex_tmp = static_cast<AnaTrueVertex*>(spill.TrueVertices[i]);
610  AnaTrueVertexIO vertex(*vertex_tmp);
611 
612  // if (vertex->ReconParticles.size()>0 || !_saveTruthWithRecon) { // scanta: now this should work
613  WriteTrueVertex(&vertex);
614  // Save vertices in a temporary vector for getting their index for WriteTrueTrack and WriteVertex
615  // (so it is correct even if we don't save all vertices)
616  _savedTrueVertices.push_back(vertex_tmp);
617  }
618 
619  if (_saveTruthWithRecon) CreateListOfTrueParticlesToSave();
620 
621  // True track variables
622  for (unsigned int i=0;i<spill.TrueParticles.size();i++){
623  if (!_saveTruthWithRecon || _trueParticleIDs.find(spill.TrueParticles[i]->ID) != _trueParticleIDs.end()) {
624  //Save the trueVertexIndex instead of ID to speed up associations in FlatTreeConverter
625  int trueVertexIndex = -2; // this will put the default value (for a true track without a true vertex).
626  if (spill.TrueParticles[i]->TrueVertex)
627  trueVertexIndex = FindTrueVertexIndex(spill.TrueParticles[i]->TrueVertex);
628 
629  AnaTrueParticle* particle_tmp = static_cast<AnaTrueParticle*>(spill.TrueParticles[i]);
630  AnaTrueParticleIO particle(*particle_tmp);
631 
632  WriteTrueParticle(&particle, trueVertexIndex);
633  }
634  }
635 
636  // FGD time bin variables
637  for (unsigned int i=0;i<spill.FgdTimeBins.size();i++){
638 
639  AnaFgdTimeBin* bin_tmp = static_cast<AnaFgdTimeBin*>(spill.FgdTimeBins[i]);
640  AnaFgdTimeBinIO bin(*bin_tmp);
641 
642  WriteFgdTimeBin(&bin);
643  }
644 
645 
646 }
647 
648 //********************************************************************
649 int CreateFlatTree::FindTrueVertexIndex(AnaTrueVertexB* vertex) {
650 //********************************************************************
651  if (!vertex) {
652  AnaSpill& spill = *static_cast<AnaSpill*>(&input().GetCorrectedSpill());
653  if (_savedTrueVertices.size() == spill.TrueVertices.size())
654  std::cout << "debug error 1234 TrueVertex not associated." << std::endl;
655  return -1;
656  }
657  for (unsigned int i = 0; i < _savedTrueVertices.size(); i++) {
658  if (vertex == _savedTrueVertices[i]) return i;
659  }
660  std::cout << "debug error 1235: TrueVertexIndex not found" << std::endl;
661  return -1;
662 }
663 
664 //********************************************************************
665 void CreateFlatTree::CreateListOfTrueParticlesToSave() {
666 //********************************************************************
667  _trueParticleIDs.clear();
668 
669  // First find all the true tracks that are matched to recon objects.
670  // These are obviosuly important.
671  std::set<AnaTrueObjectC*> matched;
672 
673  AnaSpill& spill = *static_cast<AnaSpill*>(&input().GetCorrectedSpill());
674 
675  std::vector<AnaBunch*> outplusbunches;
676  outplusbunches.push_back(static_cast<AnaBunch*>(spill.OutOfBunch));
677  for (unsigned int b = 0; b < spill.Bunches.size(); b++) {
678  outplusbunches.push_back(static_cast<AnaBunch*>(spill.Bunches[b]));
679  }
680  //------ Loop over outofbunch+bunches --------------
681  for (unsigned int b = 0; b < outplusbunches.size(); b++) {
682 
683  AnaBunch* bunch = static_cast<AnaBunch*>(outplusbunches[b]);
684 
685  for (unsigned int i = 0; i < bunch->Particles.size(); i++) {
686  AnaTrackB* track = static_cast<AnaTrackB*>(bunch->Particles[i]);
687  if (track->TrueObject) {
688  matched.insert(track->TrueObject);
689  }
690  for (int k = 0; k < track->nTPCSegments; k++) {
691  AnaTPCParticleB* tpcTrack = track->TPCSegments[k];
692  if (tpcTrack->TrueObject) {
693  matched.insert(tpcTrack->TrueObject);
694  }
695  }
696  }
697  }
698 
699  // Recursively work upwards adding all the parents of the tracks we already selected.
700  // We need these so the "parent", "gparent" categories work, among other things.
701  for (std::set<AnaTrueObjectC*>::iterator it = matched.begin(); it != matched.end(); it++){
702  AnaTrueParticleB* parent = static_cast<AnaTrueParticleB*>(*it);
703  if(!parent)
704  continue;
705  _trueParticleIDs.insert(parent->ID);
706 
707  while (parent && _trueParticleIDs.find(parent->ParentID) == _trueParticleIDs.end()) {
708  parent = GetTrueParticleByID(parent->ParentID);
709  if(parent)
710  _trueParticleIDs.insert(parent->ID);
711 
712  }
713  }
714 
715  // Finally add all the primary tracks for each vertex. We need these so the "topology"
716  // category works, for example.
717  for (unsigned int i=0;i<spill.TrueVertices.size();i++){
718  AnaTrueVertexB* vtx = spill.TrueVertices[i];
719  for (int j = 0; j < vtx->nTrueParticles; j++) {
720  if (vtx->TrueParticles[j]->ParentID == 0) {
721  _trueParticleIDs.insert(vtx->TrueParticles[j]->ID);
722  }
723  }
724  }
725 }
726 
727 //********************************************************************
728 AnaTrueParticleB* CreateFlatTree::GetTrueParticleByID(int ID) {
729 //********************************************************************
730 
731  AnaSpill& spill = *static_cast<AnaSpill*>(&input().GetCorrectedSpill());
732  std::vector<AnaTrueParticleB*> all = spill.TrueParticles;
733 
734  for (unsigned int i = 0; i < all.size(); i++) {
735  if (all[i]->ID == ID) {
736  return all[i];
737  }
738  }
739 
740  return NULL;
741 }
742 
743 //********************************************************************
744 bool CreateFlatTree::CheckTruthFillFlatTree(const AnaSpill& spill){
745 //********************************************************************
746 
747  bool ok_det = false;
748  bool ok_reac = false;
749 
750  const std::vector<AnaTrueVertexB*>& vertices = spill.TrueVertices;
751  for (std::vector<AnaTrueVertexB*>::const_iterator it = vertices.begin(); it!=vertices.end(); it++) {
752  AnaTrueVertex& vtx = *static_cast<AnaTrueVertex*>(*it);
753 
754  // Check the reaction code
755  ok_reac = CheckTrueVertexReaction(vtx);
756 
757  // Check the detector only if the reaction is OK
758  if (ok_reac)
759  ok_det = CheckTrueVertexDetector(vtx.Detector);
760 
761  // return true when it finds a tru vertex fulfilling both conditions
762  if (ok_reac && ok_det) return true;
763  }
764 
765  return false;
766 }
767 
768 //********************************************************************
769 bool CreateFlatTree::CheckTrueVertexReaction(const AnaTrueVertex& vtx){
770 //********************************************************************
771 
772  // NuWro prod5 uses 70 for 2p2h code (Neut does not have 70 at all, and uses 2 instead)
773  // NuWro prod6 uses 2 as NEUT
774  if (_saveTrueNuNC && vtx.ReacCode>=+30 && abs(vtx.ReacCode)!=70) return true;
775  if (_saveTrueAntiNuNC && vtx.ReacCode<=-30 && abs(vtx.ReacCode)!=70) return true;
776  if (_saveTrueNumuCC && vtx.NuPDG==+14 && ((vtx.ReacCode>0 && vtx.ReacCode<+30) || vtx.ReacCode==+70)) return true;
777  if (_saveTrueAntiNumuCC && vtx.NuPDG==-14 && ((vtx.ReacCode<0 && vtx.ReacCode>-30) || vtx.ReacCode==-70)) return true;
778  if (_saveTrueNueCC && vtx.NuPDG==+12 && ((vtx.ReacCode>0 && vtx.ReacCode<+30) || vtx.ReacCode==+70)) return true;
779  if (_saveTrueAntiNueCC && vtx.NuPDG==-12 && ((vtx.ReacCode<0 && vtx.ReacCode>-30) || vtx.ReacCode==-70)) return true;
780  return false;
781 }
782 
783 //********************************************************************
784 bool CreateFlatTree::CheckTrueVertexDetector(unsigned long det){
785 //********************************************************************
786 
787  for (unsigned int i = 0;i<_saveTrueVertexInDet.size();i++)
788  if (SubDetId::GetDetectorUsed(det,_saveTrueVertexInDet[i])) return true;
789 
790  return false;
791 }
792 
793 //********************************************************************
794 bool CreateFlatTree::CheckReconFillFlatTreeOutOfBunch(const AnaBunch& bunch){
795 //********************************************************************
796 
797  for (std::vector<AnaParticleB*>::const_iterator it = bunch.Particles.begin(); it!=bunch.Particles.end(); it++) {
798 
799  unsigned long bitfield = (*it)->Detector;
800 
801  if (_useTPC1outOfBunch)
802  if (SubDetId::GetDetectorUsed(bitfield, SubDetId::kTPC1)) return true;
803  if (_useTPC2outOfBunch)
804  if (SubDetId::GetDetectorUsed(bitfield, SubDetId::kTPC2)) return true;
805  if (_useTPC3outOfBunch)
806  if (SubDetId::GetDetectorUsed(bitfield, SubDetId::kTPC3)) return true;
807  if (_useFGD1outOfBunch)
808  if (SubDetId::GetDetectorUsed(bitfield, SubDetId::kFGD1)) return true;
809  if (_useFGD2outOfBunch)
810  if (SubDetId::GetDetectorUsed(bitfield, SubDetId::kFGD2)) return true;
811  if (_useP0DoutOfBunch)
812  if (SubDetId::GetDetectorUsed(bitfield, SubDetId::kP0D)) return true;
813  if (_useDsECaloutOfBunch)
814  if (SubDetId::GetDetectorUsed(bitfield, SubDetId::kDSECAL)) return true;
815  if (_useTrECaloutOfBunch)
816  if (SubDetId::HasTECALDetector(bitfield)) return true;
817  if (_useP0DECaloutOfBunch)
818  if (SubDetId::HasPECALDetector(bitfield)) return true;
819  if (_useSMRDoutOfBunch)
820  if (SubDetId::HasSMRDDetector(bitfield)) return true;
821  }
822 
823  return false;
824 }
825 
826 //********************************************************************
827 bool CreateFlatTree::CheckReconFillFlatTree(const AnaBunch& bunch){
828 //********************************************************************
829 
830  if (bunch.Bunch == -1) return CheckReconFillFlatTreeOutOfBunch(bunch);
831 
832  for (std::vector<AnaParticleB*>::const_iterator it = bunch.Particles.begin(); it!=bunch.Particles.end(); it++) {
833 
834  unsigned long bitfield = (*it)->Detector;
835 
836  if (_useTPC1)
837  if (SubDetId::GetDetectorUsed(bitfield, SubDetId::kTPC1)) return true;
838  if (_useTPC2)
839  if (SubDetId::GetDetectorUsed(bitfield, SubDetId::kTPC2)) return true;
840  if (_useTPC3)
841  if (SubDetId::GetDetectorUsed(bitfield, SubDetId::kTPC3)) return true;
842  if (_useFGD1)
843  if (SubDetId::GetDetectorUsed(bitfield, SubDetId::kFGD1)) return true;
844  if (_useFGD2)
845  if (SubDetId::GetDetectorUsed(bitfield, SubDetId::kFGD2)) return true;
846  if (_useP0D)
847  if (SubDetId::GetDetectorUsed(bitfield, SubDetId::kP0D)) return true;
848  if (_useDsECal)
849  if (SubDetId::GetDetectorUsed(bitfield, SubDetId::kDSECAL)) return true;
850  if (_useTrECal)
851  if (SubDetId::HasTECALDetector(bitfield)) return true;
852  if (_useP0DECal)
853  if (SubDetId::HasPECALDetector(bitfield)) return true;
854  if (_useSMRD)
855  if (SubDetId::HasSMRDDetector(bitfield)) return true;
856 
857 
858  }
859 
860  return false;
861 }
862 
863 
864 //********************************************************************
865 void CreateFlatTree::FillFlatTree(){
866 //********************************************************************
867 
868  // Save the accumulated POT since the last spill saved
869  FillVar(sPOTSincePreviousSpill, _POTSincePreviousSpill);
870 
871  // Reset it to 0
872  _POTSincePreviousSpill = 0;
873 
874  FillTree(flattree);
875 }
876 
877 
878 //********************************************************************
879 void CreateFlatTree::ResetCheckWriteSegment(){
880 //********************************************************************
881 
882  for (Int_t i=0;i<10;i++){
883  _max_nodes[i] = 0;
884  }
885 }
886 
887 //********************************************************************
888 bool CreateFlatTree::CheckWriteSegment(SubDetId::SubDetEnum det, const AnaParticleB& seg){
889 //********************************************************************
890 
891  // Only save the longest segment in a given sub-detector. This is mainly to deal with tracks with more than one TPC segment in the same TPC
892 
893  // Get the subtetector number
895 
896  if (seg.NNodes>_max_nodes[idet]){
897  _max_nodes[idet] = seg.NNodes;
898  return true;
899  }
900  else
901  return false;
902 }
Representation of a true Monte Carlo trajectory/particle.
int nP0DSegments
How many P0D tracks are associated with this track.
Representation of a global track.
Representation of an ECAL segment of a global track.
AnaP0DParticleB * P0DSegments[NMAXP0DS]
The P0D segments that contributed to this global track.
unsigned long Detector
Int_t NuPDG
The PDG code of the incoming neutrino.
int GetParameterI(std::string)
Get parameter. Value is returned as integer.
Definition: Parameters.cxx:217
int nTrueParticles
How many true particles are associated with this vertex.
static bool HasPECALDetector(unsigned long BitField)
Check if a detector bit field has a P0D ECAL or not.
Definition: SubDetId.cxx:155
P0DRecon Vertex.
AnaECALParticleB * ECALSegments[NMAXECALS]
The ECAL segments that contributed to this global track.
int nECALSegments
How many ECAL tracks are associated with this track.
AnaSMRDParticleB * SMRDSegments[NMAXSMRDS]
The SMRD segments that contributed to this global track.
Representation of a true Monte Carlo vertex.
Representation of a true Monte Carlo vertex.
void AddPackage(const std::string &name, const std::string &version)
Add a package.
std::vector< AnaTrueVertexB * > TrueVertices
The true MC vertices used in this spill.
std::vector< AnaBunchC * > Bunches
The reconstructed objects, split into timing bunches.
Int_t NNodes
The number of nodes in the reconstructed object.
Representation of an SMRD segment of a global track.
AnaTPCParticleB * TPCSegments[NMAXTPCS]
The TPC segments that contributed to this global track.
P0DRecon Particle.
AnaTrueObjectC * TrueObject
The link to the true oject that most likely generated this reconstructed object.
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
AnaTrueParticleB ** TrueParticles
The true particles associated with this vertex.
This Ana* object is used to flatten TECALReconObjects from ReconDir/TrackerECal.
AnaBunchB * OutOfBunch
Reconstructed objects that didn&#39;t fit into one of the timing bunches.
Int_t ID
The ID of the trueObj, which corresponds to the ID of the TTruthParticle that created it...
std::vector< AnaVertexB * > Vertices
std::string GetSoftwareVersionFromPath(const std::string &path)
Get The software version from the path of the package.
void FillTree()
Fill the current tree.
virtual bool Process()
int nSMRDSegments
How many SMRD tracks are associated with this track.
static bool HasSMRDDetector(unsigned long BitField)
Check if a detector bit field has a SMRD or not.
Definition: SubDetId.cxx:160
Representation of a true Monte Carlo vertex.
Definition: DataClasses.hxx:50
int nTPCSegments
How many TPC tracks are associated with this track.
Representation of a true Monte Carlo trajectory/particle.
This class defines a correction that affects the reconstructed TPC Momentum of an.
AnaBeamB * Beam
The beam quality flags for this spill.
SubDetEnum
Enumeration of all detector systems and subdetectors.
Definition: SubDetId.hxx:25
Creates the appropriate AnaSpillB type. The rest of the work is done by the base converter.
unsigned long Detector
Representation of a Tracker segment of a global track.
std::vector< AnaFgdTimeBinB * > FgdTimeBins
The FGD time bins.
Representation of a global track.
static SubDetId::SubDetEnum GetSubdetectorEnum(unsigned long BitField)
Get the single subdetector that this track is from.
Definition: SubDetId.cxx:165
Representation of a TPC segment of a global track.
static bool HasTECALDetector(unsigned long BitField)
Check if a detector bit field has a Tracker ECAL or not.
Definition: SubDetId.cxx:150
int GetLocalDetEnum(SubDetId::SubDetEnum det, SubDetId::SubDetEnum idet)
Get old local detector enumeration to find array index of Flat tree.
Representation of a FGD segment of a global track.
std::vector< AnaTrackerTrackB * > TRACKERSegments
The TRACKER segments that contributed to this global track.
std::vector< AnaTrueParticleB * > TrueParticles
The true MC particles used in this spill.
Representation of a P0D segment of a global track.
Int_t RooVtxEntry
Not in the MiniTree for the Moment since it produces a seg fault.
virtual bool Initialize()
Int_t Bunch
The index of this bunch (0-7).
This Ana* object is used to flatten TECALUnmatchedObjects from ReconDir/TrackerECal.
int nFGDSegments
How many FGD tracks are associated with this track.
Int_t ParentID
The ID of this particle&#39;s immediate parent, or 0 if there is no parent.
ProdId_h GetProductionIdFromND280AnalysisTools()
Get Production Id from nd280AnalysisTools.
Representation of a global track.
std::vector< AnaParticleB * > Particles
void AddProduction(ProdId_h prodId, const std::string &prodName, const std::string &prodLowVersion, const std::string &prodHighVersion)
Add a production.
Representation of a TPC segment of a global track.
Representation of a reconstructed particle (track or shower).
virtual void DefineOutputTree()
Define the tree that should be written to the output file.
Representation of a TPC segment of a global particle.
Representation of a true Monte Carlo trajectory/particle.
Representation of the beam information, including POT and quality.
AnaFGDParticleB * FGDSegments[NMAXFGDS]
The FGD segments that contributed to this global track.
virtual void Finalize()
Representation of a global vertex.