1 #include "oaAnalysisTreeConverter.hxx" 2 #include "InputManager.hxx" 3 #include "Versioning.hxx" 4 #include "BasicUtils.hxx" 5 #include "HighlandAnalysisUtils.hxx" 6 #include "TreeConverterUtils.hxx" 7 #include "HighlandTreeConverterUtils.hxx" 8 #include "Parameters.hxx" 11 const Float_t SANDFACTOR=2.5e17;
15 bool _discardPauliBlocked =
true;
18 bool _discardCohOnH =
true;
23 bool CompareNNodes(ND::TSubBaseObject *obj1, ND::TSubBaseObject *obj2){
28 return (obj1->NNodes > obj2->NNodes);
35 oaAnalysisTreeConverter::oaAnalysisTreeConverter():
InputConverter(
"ReconDir/Global"){
42 _RooVtxEntryInCurrentInputFile=0;
45 TrECalUnmatched = NULL;
46 P0DReconVertices = NULL;
47 P0DReconParticles = NULL;
48 P0DReconClusters = NULL;
49 P0DReconTracks = NULL;
50 P0DReconShowers = NULL;
55 DelayedClusters = NULL;
62 XZTracks_Radon2 = NULL;
63 YZTracks_Radon2 = NULL;
64 XYZTracks_Radon2 = NULL;
65 XZTracksAllFGD_Radon2 = NULL;
66 YZTracksAllFGD_Radon2 = NULL;
67 XYZTracksAllFGD_Radon2 = NULL;
70 beamSummaryDataStatus = -1;
81 NeutFirstFile =
false;
82 GenieFirstFile =
false;
113 FGDCosmicEvent =
false;
114 TripTCosmicEvent =
false;
115 P0DWaterStatus =
false;
117 NTrECalObjects = -999;
118 NP0DReconVertices = -999;
119 NP0DReconParticles = -999;
120 NP0DReconClusters = -999;
121 NP0DReconTracks = -999;
122 NP0DReconShowers = -999;
123 NP0DReconNodes = -999;
124 NP0DReconHits = -999;
131 NDelayedClusters = -999;
136 NTruthVertices = -999;
140 NXZTracks_Radon2 = -999;
141 NYZTracks_Radon2 = -999;
142 NXYZTracks_Radon2 = -999;
143 NXZTracksAllFGD_Radon2 = -999;
144 NYZTracksAllFGD_Radon2 = -999;
145 NXYZTracksAllFGD_Radon2 = -999;
155 fND280OffFlag = -999;
164 for (
int i = 0; i < 7; i++) {
165 TruthTrajsName[i] =
"";
167 for (
int i = 0; i < 9; i++) {
168 TruthVerticesName[i] =
"";
174 _previousSubrunID = -1;
175 _previousRefEventID = -1;
184 _isUsingReconDirFGDOnly = ND::params().
GetParameterI(
"highlandIO.FlatTree.UseReconDirFGDOnly");
185 _isUsingReconDirP0D = ND::params().
GetParameterI(
"highlandIO.FlatTree.UseReconDirP0D");
186 _isUsingReconDirPECAL = ND::params().
GetParameterI(
"highlandIO.FlatTree.UseReconDirP0DECal");
187 _isUsingReconDirTECAL = ND::params().
GetParameterI(
"highlandIO.FlatTree.UseReconDirTrackerECal");
190 _isUsingReconDirP0DNew = ND::params().
GetParameterI(
"highlandIO.P0DDataClasses.UseReconDirP0DNew");
191 _p0dAlgoResName = ND::params().
GetParameterS(
"highlandIO.P0DDataClasses.UseReconDirP0DAlgoResult");
192 _addGlobalTracksToP0DVertices = (bool)ND::params().
GetParameterI(
"highlandIO.P0DDataClasses.AddGlobalTracksToP0DVertices");
194 if (_isUsingReconDirP0D && _isUsingReconDirP0DNew){
195 std::cerr <<
"ERROR. oaAnalysisTreeConverter::Initialize(). 'highlandIO.FlatTree.UseReconDirP0D' and 'highlandIO.P0DRecon.UseReconDirP0DNew' are both set to 1 " 196 <<
"highlandIO.parameters.dat. Please switch off one of two !!!!" << std::endl;
202 _ignoreSMRDContainedTrueObjects = ND::params().
GetParameterI(
"highlandIO.oaAnalysis.IgnoreSMRDContainedTrueObjects");
203 _ignoreP0DECalContainedTrueObjects = ND::params().
GetParameterI(
"highlandIO.oaAnalysis.IgnoreP0DECalContainedTrueObjects");
204 _ignoreDsECalContainedTrueObjects = ND::params().
GetParameterI(
"highlandIO.oaAnalysis.IgnoreDsECalContainedTrueObjects");
205 _ignoreBrECalContainedTrueObjects = ND::params().
GetParameterI(
"highlandIO.oaAnalysis.IgnoreBrECalContainedTrueObjects");
206 _ignoreINGRIDContainedTrueObjects = ND::params().
GetParameterI(
"highlandIO.oaAnalysis.IgnoreINGRIDContainedTrueObjects");
209 _removeTrueVerticesWithNoTrueParticles = ND::params().
GetParameterI(
"highlandIO.oaAnalysis.RemoveTrueVerticesWithNoTrueParticles");
214 AddChain(
"HeaderDir/BeamSummaryData");
215 AddChain(
"HeaderDir/BasicDataQuality");
218 if(_isUsingReconDirFGDOnly)
AddChain(
"ReconDir/FGDOnly");
219 if(_isUsingReconDirTECAL)
AddChain(
"ReconDir/TrackerECal");
220 if(_isUsingReconDirP0D || _isUsingReconDirP0DNew)
AddChain(
"ReconDir/P0D");
222 reconGlobal =
GetChain(
"ReconDir/Global");
223 mcTruthVertices =
GetChain(
"TruthDir/Vertices");
224 mcTruthTrajectories =
GetChain(
"TruthDir/Trajectories");
225 beamInfo =
GetChain(
"HeaderDir/BeamSummaryData");
226 DQInfo =
GetChain(
"HeaderDir/BasicDataQuality");
227 BasicHeader =
GetChain(
"HeaderDir/BasicHeader");
229 GRooTrackerVTX = NULL;
230 NRooTrackerVTX = NULL;
232 if(_isUsingReconDirFGDOnly) fgdOnly =
GetChain(
"ReconDir/FGDOnly");
234 if(_isUsingReconDirTECAL) trackerECAL =
GetChain(
"ReconDir/TrackerECal");
235 else trackerECAL = NULL;
236 if(_isUsingReconDirP0D || _isUsingReconDirP0DNew) p0d =
GetChain(
"ReconDir/P0D");
243 if (!
fChain)
return false;
247 PIDs =
new TClonesArray(
"ND::TGlobalReconModule::TGlobalPID",20);
248 reconGlobal->SetBranchAddress(
"NPIDs", &NPIDs);
249 reconGlobal->SetBranchAddress(
"PIDs", &PIDs);
251 FgdTimeBins =
new TClonesArray(
"ND::TGlobalReconModule::TFgdTimeBin");
252 reconGlobal->SetBranchAddress(
"NFgdTimeBins", &NFgdTimeBins);
253 reconGlobal->SetBranchAddress(
"FgdTimeBins", &FgdTimeBins);
255 Vertices =
new TClonesArray(
"ND::TGlobalReconModule::TGlobalVertex",20);
256 reconGlobal->SetBranchAddress(
"NVertices",&NVertices);
257 reconGlobal->SetBranchAddress(
"Vertices",&Vertices);
276 TrECalObjects =
new TClonesArray(
"ND::TTrackerECALReconModule::TECALReconObject",20);
277 trackerECAL->SetBranchAddress(
"NReconObject",&NTrECalObjects);
278 trackerECAL->SetBranchAddress(
"ReconObject", &TrECalObjects);
280 TrECalUnmatched =
new TClonesArray(
"ND::TTrackerECALReconModule::TECALReconUnmatchedObject",20);
281 trackerECAL->SetBranchAddress(
"NUnmatchedObject",&NTrECalUnmatched);
282 trackerECAL->SetBranchAddress(
"UnmatchedObject", &TrECalUnmatched);
287 P0DAlgoResults =
new TClonesArray(
"ND::TP0DReconModule::TP0DAlgoRes",20);
288 p0d->SetBranchAddress(
"NAlgoResults",&NP0DAlgoResults);
289 p0d->SetBranchAddress(
"AlgoResults", &P0DAlgoResults);
291 P0DReconVertices =
new TClonesArray(
"ND::TP0DReconModule::TP0DVertex",100);
292 p0d->SetBranchAddress(
"NVertices",&NP0DReconVertices);
293 p0d->SetBranchAddress(
"Vertices", &P0DReconVertices);
295 P0DReconParticles =
new TClonesArray(
"ND::TP0DReconModule::TP0DParticle",100);
296 p0d->SetBranchAddress(
"NParticles",&NP0DReconParticles);
297 p0d->SetBranchAddress(
"Particles", &P0DReconParticles);
299 P0DReconTracks =
new TClonesArray(
"ND::TP0DReconModule::TP0DTrack",100);
300 p0d->SetBranchAddress(
"NTracks",&NP0DReconTracks);
301 p0d->SetBranchAddress(
"Tracks", &P0DReconTracks);
303 P0DReconShowers =
new TClonesArray(
"ND::TP0DReconModule::TP0DShower",100);
304 p0d->SetBranchAddress(
"NShowers",&NP0DReconShowers);
305 p0d->SetBranchAddress(
"Showers", &P0DReconShowers);
307 P0DReconClusters =
new TClonesArray(
"ND::TP0DReconModule::TP0DCluster",100);
308 p0d->SetBranchAddress(
"NClusters",&NP0DReconClusters);
309 p0d->SetBranchAddress(
"Clusters", &P0DReconClusters);
311 P0DReconNodes =
new TClonesArray(
"ND::TP0DReconModule::TP0DNode",100);
312 p0d->SetBranchAddress(
"NNodes",&NP0DReconNodes);
313 p0d->SetBranchAddress(
"Nodes", &P0DReconNodes);
315 P0DReconHits =
new TClonesArray(
"ND::TP0DReconModule::TP0DHit",100);
316 p0d->SetBranchAddress(
"NHits",&NP0DReconHits);
317 p0d->SetBranchAddress(
"Hits", &P0DReconHits);
322 if (mcTruthVertices){
323 TruthVertices =
new TClonesArray(
"ND::TTruthVerticesModule::TTruthVertex", 100);
324 mcTruthVertices->SetBranchAddress(
"NVtx", &NTruthVertices);
325 mcTruthVertices->SetBranchAddress(
"NVtxFGD1", &NVtxFGD1);
326 mcTruthVertices->SetBranchAddress(
"NVtxFGD2", &NVtxFGD2);
327 mcTruthVertices->SetBranchAddress(
"Vertices", &TruthVertices);
331 if (mcTruthTrajectories){
332 TruthTrajs =
new TClonesArray(
"ND::TTruthTrajectoriesModule::TTruthTrajectory", 100);
333 mcTruthTrajectories->SetBranchAddress(
"NTraj", &NTruthTrajs);
334 mcTruthTrajectories->SetBranchAddress(
"Trajectories", &TruthTrajs);
339 XZTracks_Radon2 =
new TClonesArray(
"ND::TFgdOnlyModule::TFgd2DIsoTrack",200);
340 fgdOnly->SetBranchAddress(
"NXZTracks_Radon2", &NXZTracks_Radon2);
341 fgdOnly->SetBranchAddress(
"XZTracks_Radon2", &XZTracks_Radon2);
343 YZTracks_Radon2 =
new TClonesArray(
"ND::TFgdOnlyModule::TFgd2DIsoTrack",200);
344 fgdOnly->SetBranchAddress(
"NYZTracks_Radon2", &NYZTracks_Radon2);
345 fgdOnly->SetBranchAddress(
"YZTracks_Radon2", &YZTracks_Radon2);
347 XYZTracks_Radon2 =
new TClonesArray(
"ND::TFgdOnlyModule::TFgd3DIsoTrack",200);
348 fgdOnly->SetBranchAddress(
"NXYZTracks_Radon2", &NXYZTracks_Radon2);
349 fgdOnly->SetBranchAddress(
"XYZTracks_Radon2", &XYZTracks_Radon2);
351 XZTracksAllFGD_Radon2 =
new TClonesArray(
"ND::TFgdOnlyModule::TFgd2DIsoTrack",200);
352 fgdOnly->SetBranchAddress(
"NXZTracksAllFGD_Radon2", &NXZTracksAllFGD_Radon2);
353 fgdOnly->SetBranchAddress(
"XZTracksAllFGD_Radon2", &XZTracksAllFGD_Radon2);
355 YZTracksAllFGD_Radon2 =
new TClonesArray(
"ND::TFgdOnlyModule::TFgd2DIsoTrack",200);
356 fgdOnly->SetBranchAddress(
"NYZTracksAllFGD_Radon2", &NYZTracksAllFGD_Radon2);
357 fgdOnly->SetBranchAddress(
"YZTracksAllFGD_Radon2", &YZTracksAllFGD_Radon2);
359 XYZTracksAllFGD_Radon2 =
new TClonesArray(
"ND::TFgdOnlyModule::TFgd3DIsoTrack",200);
360 fgdOnly->SetBranchAddress(
"NXYZTracksAllFGD_Radon2", &NXYZTracksAllFGD_Radon2);
361 fgdOnly->SetBranchAddress(
"XYZTracksAllFGD_Radon2", &XYZTracksAllFGD_Radon2);
366 beamSummary =
new TClonesArray(
"ND::TBeamSummaryDataModule::TBeamSummaryData",200);
367 beamInfo->SetBranchAddress(
"BeamSummaryData", &beamSummary);
368 beamInfo->SetBranchAddress(
"BeamSummaryDataStatus", &beamSummaryDataStatus);
369 beamInfo->SetBranchAddress(
"ND280Spill", &ND280Spill);
380 BasicHeader->SetBranchAddress(
"EventID", &EventID);
381 BasicHeader->SetBranchAddress(
"RunID", &RunID);
382 BasicHeader->SetBranchAddress(
"SubrunID", &SubrunID);
383 BasicHeader->SetBranchAddress(
"IsMC", &IsMC);
384 BasicHeader->SetBranchAddress(
"EventTime", &EventTime);
385 BasicHeader->SetBranchAddress(
"Preselected", &Preselected);
386 BasicHeader->SetBranchAddress(
"TriggerWord", &TriggerWord);
387 BasicHeader->SetBranchAddress(
"FGDCosmicEvent", &FGDCosmicEvent);
388 BasicHeader->SetBranchAddress(
"TripTCosmicEvent", &TripTCosmicEvent);
389 BasicHeader->SetBranchAddress(
"SoftwareVersion", &SoftwareVersion);
390 BasicHeader->SetBranchAddress(
"P0DWaterStatus", &P0DWaterStatus);
391 #if VERSION_HAS_OFFICIAL_POT 392 BasicHeader->SetBranchAddress(
"POTPerSpill", &POTPerSpill);
398 DQInfo->SetBranchAddress(
"ND280OffFlag", &fND280OffFlag);
399 DQInfo->SetBranchAddress(
"TPCFlag", &fTPCFlag);
400 DQInfo->SetBranchAddress(
"TPC1Flag", &fTPC1Flag);
401 DQInfo->SetBranchAddress(
"TPC2Flag", &fTPC2Flag);
402 DQInfo->SetBranchAddress(
"TPC3Flag", &fTPC3Flag);
403 DQInfo->SetBranchAddress(
"FGDFlag", &fFGDFlag);
404 DQInfo->SetBranchAddress(
"FGD1Flag", &fFGD1Flag);
405 DQInfo->SetBranchAddress(
"FGD2Flag", &fFGD2Flag);
406 DQInfo->SetBranchAddress(
"ECALFlag", &fECALFlag);
407 DQInfo->SetBranchAddress(
"DSECALFlag", &fDSECALFlag);
408 DQInfo->SetBranchAddress(
"BarECALFlag", &fBarECALFlag);
409 DQInfo->SetBranchAddress(
"P0DECALFlag", &fP0DECALFlag);
410 DQInfo->SetBranchAddress(
"P0DFlag", &fP0DFlag);
411 DQInfo->SetBranchAddress(
"SMRDFlag", &fSMRDFlag);
412 DQInfo->SetBranchAddress(
"MAGNETFlag", &fMAGNETFlag);
413 DQInfo->SetBranchAddress(
"INGRIDFlag", &fINGRIDFlag);
417 _truthUtils.SetTrajectoriesArray (TruthTrajs);
418 _truthUtils.SetVerticesArray (TruthVertices);
419 _truthUtils.SetTrajectoriesNumber(&NTruthTrajs);
420 _truthUtils.SetVerticesNumber (&NTruthVertices);
426 oaAnalysisTreeConverter::~oaAnalysisTreeConverter(){
431 if (reconGlobal )
delete reconGlobal ->GetCurrentFile();
432 if (trackerECAL )
delete trackerECAL ->GetCurrentFile();
433 if (p0d )
delete p0d ->GetCurrentFile();
434 if (fgdOnly )
delete fgdOnly ->GetCurrentFile();
435 if (mcTruthVertices )
delete mcTruthVertices ->GetCurrentFile();
436 if (beamInfo )
delete beamInfo ->GetCurrentFile();
437 if (DQInfo )
delete DQInfo ->GetCurrentFile();
438 if (BasicHeader )
delete BasicHeader ->GetCurrentFile();
439 if (mcTruthTrajectories )
delete mcTruthTrajectories ->GetCurrentFile();
440 if (GRooTrackerVTX )
delete GRooTrackerVTX ->GetCurrentFile();
441 if (NRooTrackerVTX )
delete NRooTrackerVTX ->GetCurrentFile();
442 if (accPOTInfo )
delete accPOTInfo ->GetCurrentFile();
446 delete DelayedClusters;
449 delete TruthVertices;
453 delete TrECalObjects;
454 delete TrECalUnmatched;
455 delete P0DReconVertices;
456 delete P0DReconParticles;
457 delete P0DReconTracks;
458 delete P0DReconShowers;
459 delete P0DReconClusters;
460 delete P0DReconNodes;
462 delete XZTracks_Radon2;
463 delete YZTracks_Radon2;
464 delete XYZTracks_Radon2;
465 delete XZTracksAllFGD_Radon2;
466 delete YZTracksAllFGD_Radon2;
467 delete XYZTracksAllFGD_Radon2;
476 std::cout <<
"oaAnalysisTreeConverter::AddFileToTChain(). Adding file: " << inputString << std::endl;
479 TChain BasicHeaderForFile(
"HeaderDir/BasicHeader");
480 BasicHeaderForFile.AddFile(inputString.c_str());
481 if (BasicHeaderForFile.GetEntries() == 0){
482 std::cout <<
" ----> This file does not contain any entries. IGNORED !!!!" << std::endl;
487 BasicHeaderForFile.SetBranchAddress(
"IsMC", &IsMC);
488 BasicHeaderForFile.GetEntry(0);
492 Genie = Neut =
false;
494 TFile *f = TFile::Open(inputString.c_str());
497 gDirectory->cd(
"/TruthDir");
498 if ( gDirectory->FindObjectAny(
"NRooTrackerVtx") ) Neut =
true;
499 else if( gDirectory->FindObjectAny(
"GRooTrackerVtx") ) Genie =
true;
505 NeutFirstFile = Neut;
506 GenieFirstFile = Genie;
514 AddChain(
"NRooTrackerVtx",
"TruthDir/NRooTrackerVtx");
515 NRooTrackerVTX =
GetChain(
"NRooTrackerVtx");
516 NVtx =
new TClonesArray(
"ND::NRooTrackerVtx",100);
517 NRooTrackerVTX->SetBranchAddress(
"NVtx",&NNVtx);
518 NRooTrackerVTX->SetBranchAddress(
"Vtx",&NVtx);
521 AddChain(
"GRooTrackerVtx",
"TruthDir/GRooTrackerVtx");
522 GRooTrackerVTX =
GetChain(
"GRooTrackerVtx");
523 GVtx =
new TClonesArray(
"ND::GRooTrackerVtx",100);
524 GRooTrackerVTX->SetBranchAddress(
"NVtx",&NGVtx);
525 GRooTrackerVTX->SetBranchAddress(
"Vtx",&GVtx);
531 if ( Neut ) std::cout <<
" Neut Branch " << std::endl;
532 else if ( Genie ) std::cout <<
" Genie Branch " << std::endl;
535 if ((!Genie && !Neut) && (GenieFirstFile || NeutFirstFile) ){
536 std::cout <<
"ERROR (see https://bugzilla.nd280.org/show_bug.cgi?id=1372): This file does not contain RooTrackerVtx Tree. IGNORED !!!!" << std::endl;
541 if ((Genie || Neut) && (!GenieFirstFile && !NeutFirstFile) ){
542 std::cout <<
"ERROR (see https://bugzilla.nd280.org/show_bug.cgi?id=1372): The first file didn't contain RooTrackerVtx tree, while this does. Please remove first file from list !!!!" << std::endl;
547 if ((Genie && NeutFirstFile)){
548 std::cout <<
"ERROR (see https://bugzilla.nd280.org/show_bug.cgi?id=1372): This is a Genie file. Neut and Genie files cannot be mixed !!!!" << std::endl;
552 if ((Neut && GenieFirstFile)){
553 std::cout <<
"ERROR (see https://bugzilla.nd280.org/show_bug.cgi?id=1372): This is a Neut file. Neut and Genie files cannot be mixed !!!!" << std::endl;
563 if (reconGlobal ) reconGlobal->AddFile(inputString.c_str());
564 if (trackerECAL ) trackerECAL->AddFile(inputString.c_str());
565 if (fgdOnly ) fgdOnly->AddFile(inputString.c_str());
566 if (p0d ) p0d->AddFile(inputString.c_str());
567 if (mcTruthVertices ) mcTruthVertices->AddFile(inputString.c_str());
568 if (mcTruthTrajectories ) mcTruthTrajectories->AddFile(inputString.c_str());
569 if (beamInfo ) beamInfo->AddFile(inputString.c_str());
570 if (DQInfo ) DQInfo->AddFile(inputString.c_str());
571 if (BasicHeader ) BasicHeader->AddFile(inputString.c_str());
572 if( AccPOTflg && accPOTInfo) accPOTInfo->AddFile(inputString.c_str());
573 if( Neut && NRooTrackerVTX ) NRooTrackerVTX->AddFile(inputString.c_str());
574 if( Genie && GRooTrackerVTX) GRooTrackerVTX->AddFile(inputString.c_str());
577 BasicHeader->GetEntry(BasicHeader->GetEntries() - 1);
580 if (_previousRunID==RunID && _previousSubrunID==SubrunID && _previousRefEventID>= EventID){
581 std::cout <<
"-------------------------------------------------------------------------------------------------------" << std::endl;
582 std::cout <<
"oaAnalysisTreeConverter::AddFileToTChain(). Current file has the same run and subrun as the previous" << std::endl;
583 std::cout <<
" and no higher event number !!!" << std::endl;
584 std::cout <<
" - this file: " << inputString << std::endl;
585 std::cout <<
" - previous file: " << _previousFile << std::endl;
586 std::cout <<
"Please verify the input file list !!!" << std::endl;
587 std::cout <<
"-------------------------------------------------------------------------------------------------------" << std::endl;
592 _previousFile = inputString;
593 _previousRunID = RunID;
594 _previousSubrunID = SubrunID;
595 _previousRefEventID = EventID;
600 std::stringstream sRun; sRun << RunID;
601 issand = ((sRun.str())[4]==
'7');
605 Double_t NPOT = GetPOTFromRooTrackerVtx();
606 bool bySpillInMC =
false;
607 #if VERSION_HAS_OFFICIAL_POT 618 if (!
header().SetIsMC(IsMC))
return false;
625 Double_t oaAnalysisTreeConverter::GetPOTFromRooTrackerVtx() {
631 Int_t ientry,ilastentry;
632 if( GRooTrackerVTX) {
635 ilastentry = GRooTrackerVTX->GetEntries() - 2;
638 GRooTrackerVTX->GetEntry(ientry--);
639 ND::GRooTrackerVtx *gvtx = (ND::GRooTrackerVtx*) (*GVtx)[0];
640 NPOT = gvtx->OrigTreePOT;
641 }
while(NPOT==0 && ientry>=0);
643 else if(NRooTrackerVTX) {
646 ilastentry = NRooTrackerVTX->GetEntries() - 2;
649 NRooTrackerVTX->GetEntry(ientry--);
650 ND::NRooTrackerVtx *gvtx = (ND::NRooTrackerVtx*) (*NVtx)[0];
651 NPOT = gvtx->OrigTreePOT;
652 }
while(NPOT==0 && ientry>=0);
658 std::cout <<
"WARNING: This file has 0 POT but it has some entries !!!!" << std::endl;
659 }
else if (ientry+1 != ilastentry) {
660 std::cout <<
"INFO: OrigTreePOT is 0 in the usual second last entry of RooTrackerVtx (" 661 << ilastentry <<
"), POT taken from entry " << ientry+1 << std::endl;
668 Int_t oaAnalysisTreeConverter::ReadEntries(Long64_t& entry) {
671 Int_t entry_temp = reconGlobal->GetEntry(entry);
673 if (entry_temp > 0) {
674 if (trackerECAL) trackerECAL->GetEntry(entry);
675 if (p0d ) p0d ->GetEntry(entry);
676 if (fgdOnly ) fgdOnly ->GetEntry(entry);
677 if (BasicHeader) BasicHeader->GetEntry(entry);
679 if (mcTruthVertices ) mcTruthVertices ->GetEntry(entry);
680 if (mcTruthTrajectories) mcTruthTrajectories->GetEntry(entry);
682 if (Genie && GRooTrackerVTX) GRooTrackerVTX->GetEntry(entry);
683 if (Neut && NRooTrackerVTX ) NRooTrackerVTX->GetEntry(entry);
685 if (beamInfo ) beamInfo ->GetEntry(entry);
686 if (DQInfo ) DQInfo ->GetEntry(entry);
687 if (AccPOTflg && accPOTInfo) accPOTInfo->GetEntry(entry);
694 reconGlobal->SetCacheSize(200000000);
695 reconGlobal->AddBranchToCache(
"*",kTRUE);
697 if( mcTruthTrajectories && IsMC) {
698 mcTruthTrajectories->SetCacheSize(200000000);
699 mcTruthTrajectories->AddBranchToCache(
"*",kTRUE);
701 if( mcTruthVertices && IsMC) {
702 mcTruthVertices->SetCacheSize(200000000);
703 mcTruthVertices->AddBranchToCache(
"*",kTRUE);
705 if( Neut && NRooTrackerVTX ) {
706 NRooTrackerVTX->SetCacheSize(200000000);
707 NRooTrackerVTX->AddBranchToCache(
"*",kTRUE);
709 if( Genie && GRooTrackerVTX ) {
710 GRooTrackerVTX->SetCacheSize(200000000);
711 GRooTrackerVTX->AddBranchToCache(
"*",kTRUE);
726 std::string filename(reconGlobal->GetFile()->GetName());
728 if( filename != _currentFileName ) {
730 _RooVtxEntryInCurrentInputFile=0;
731 std::cout <<
" Running on file (" << _currentFileIndex <<
"): " << filename << std::endl;
732 _currentFileName = filename;
733 _alreadyWarned=
false;
739 Int_t entry_temp = ReadEntries(entry);
742 if (!anaUtils::CheckSkimmedEvent(RunID,SubrunID,EventID)){
748 if (((Neut && NNVtx==0) || (Genie && NGVtx==0) || EventID<0) && !FGDCosmicEvent && !TripTCosmicEvent){
755 if (entry_temp > 0) {
761 _spill =
static_cast<AnaSpill*
>(spill);
766 std::cout <<
"Failed in reading entry " << entry << std::endl;
771 _RooVtxEntryInCurrentInputFile++;
781 bool bySpillInMC =
false;
782 #if VERSION_HAS_OFFICIAL_POT 786 if (!IsMC || bySpillInMC)
788 anaUtils::IncrementPOTBySpill(*_spill,
header());
792 void oaAnalysisTreeConverter::FillInfo(
AnaSpill* spill){
799 info.
Event = EventID;
805 spill->
RooVtxEntry = _RooVtxEntryInCurrentInputFile;
808 spill->
Beam = MakeBeam();
813 FillBeamInfo(IsMC, static_cast<AnaBeam*>(spill->
Beam));
816 FillDQInfo(static_cast<AnaDataQuality*>(spill->
DataQuality));
818 FillTriggerInfo(&(spill->
Trigger));
824 FillBunchInfo(spill);
827 if (!_isUsingReconDirP0DNew)
828 DeleteBadObjects(spill);
838 FillDelayedClustersInfo(*spill);
850 std::vector<AnaTrueVertexB*>::iterator itvtx;
859 void oaAnalysisTreeConverter::FillBeamInfo(
bool isMC,
AnaBeam* beam){
862 #if !VERSION_HAS_OFFICIAL_POT 865 beam->
Spill = ND280Spill;
872 if (beamSummaryDataStatus == 1) {
873 ND::TBeamSummaryDataModule::TBeamSummaryData *beamS = (ND::TBeamSummaryDataModule::TBeamSummaryData*) (*beamSummary)[0];
876 #if VERSION_HAS_OFFICIAL_POT 877 beam->
POT = beamS->OfficialProtonsPerSpill;
879 beam->
POT = beamS->CT5ProtonsPerSpill;
880 beam->
POTCT4 = beamS->OtherData.ProtonsPerSpill[3];
885 std::cout <<
"WARNING: run " << RunID <<
", subrun " << SubrunID <<
", event " << EventID
886 <<
" claims to have beam summary data, but it isn't there! Event will be ignored." << std::endl;
888 }
else if (EventID != -559038737 && ! cosmic_mode && ! _alreadyWarned) {
892 _alreadyWarned =
true;
893 std::cout <<
"INFO: at least one event in this file has no beam summary data." 894 <<
" These events will be ignored if you are using the event_quality cut." << std::endl;
897 #if VERSION_HAS_OFFICIAL_POT 899 beam->
POT = POTPerSpill;
915 void oaAnalysisTreeConverter::FillTriggerInfo(
AnaTrigger* tr){
923 void oaAnalysisTreeConverter::FillBunchInfo(
AnaSpill* spill){
926 if(_isUsingReconDirTECAL || _isUsingReconDirPECAL || _isUsingReconDirFGDOnly || _isUsingReconDirP0D)
928 else if (_isUsingReconDirP0DNew)
942 GetBunchLocalObjects();
945 for (
unsigned int ibunch=0; ibunch<NBUNCHES+1; ibunch++) {
947 if ( _bunchPIDs[ibunch].size() == 0 &&
948 _bunchVertices[ibunch].size() == 0 &&
949 _bunchTECALObjects[ibunch].size() == 0 &&
950 _bunchTECALUnmatchedObjects[ibunch].size() == 0 &&
951 _bunchP0DVertices[ibunch].size() == 0 &&
952 _bunchP0DParticles[ibunch].size() == 0 &&
953 _bunchP0DClusters[ibunch].size() == 0)
continue;
956 if ((
unsigned int)_bunchPIDs[ibunch].size() > NMAXPARTICLES) {
957 std::cout <<
"INFO: event " << EventID <<
" has " << (
unsigned int)_bunchPIDs[ibunch].size() <<
" recon tracks (too many), " 958 <<
"only the first " << NMAXPARTICLES <<
" will be stored (=> some warnings might appear)" << std::endl;
960 if ((
unsigned int)_bunchVertices[ibunch].size() > NMAXVERTICES) {
961 std::cout <<
"INFO: event " << EventID <<
" has " << (
unsigned int)_bunchVertices[ibunch].size() <<
" recon vertices (too many), " 962 <<
"only the first " << NMAXVERTICES <<
" will be stored (=> some warnings might appear)" << std::endl;
967 if (ibunch < NBUNCHES) {
971 if(_isUsingReconDirTECAL || _isUsingReconDirPECAL || _isUsingReconDirFGDOnly || _isUsingReconDirP0D)
973 else if (_isUsingReconDirP0DNew)
976 bunch =
static_cast<AnaBunch*
>(MakeBunch());
978 spill->
Bunches.push_back(bunch);
979 bunch->
Bunch = ibunch;
981 if(_isUsingReconDirTECAL || _isUsingReconDirPECAL || _isUsingReconDirFGDOnly || _isUsingReconDirP0D)
983 else if (_isUsingReconDirP0DNew)
990 if(_bunchPIDs[ibunch].size()>0)
991 FillPIDs(bunch, ibunch);
995 if(_isUsingReconDirTECAL && _bunchTECALObjects[ibunch].size()>0)
996 FillTECALReconObjects(bunch, ibunch);
1000 if(_isUsingReconDirTECAL && _bunchTECALUnmatchedObjects[ibunch].size()>0)
1001 FillTECALReconUnmatchedObjects(bunch, ibunch);
1004 if(_isUsingReconDirP0D && _bunchP0DVertices[ibunch].size()>0)
1005 FillP0DReconVertices(bunch, ibunch);
1008 if(_isUsingReconDirP0D && _bunchP0DParticles[ibunch].size()>0)
1009 FillP0DReconParticles(bunch, ibunch);
1012 if(_isUsingReconDirP0D && _bunchP0DClusters[ibunch].size()>0)
1013 FillP0DReconClusters(bunch, ibunch);
1017 if(_isUsingReconDirP0DNew)
1018 FillP0DBunch(bunch, ibunch,_topP0DAlgoRes);
1025 FillGlobalVertices(spill);
1030 void oaAnalysisTreeConverter::FillPIDs(
AnaBunch* bunch,
int ibunch){
1034 unsigned int nTracks = std::min((
unsigned int)_bunchPIDs[ibunch].size(), NMAXPARTICLES);
1035 for (
unsigned int j=0; j<nTracks; j++) {
1036 ND::TGlobalReconModule::TGlobalPID *globalTrack = _bunchPIDs[ibunch][j];
1042 if (_isUsingReconDirP0DNew && globalTrack->Detectors==6) {
1043 part = MakeP0DParticle();
1045 ND::TGlobalReconModule::TP0DObject* p0dObjectInGlobal = (ND::TGlobalReconModule::TP0DObject*)(*(globalTrack->P0D))[0];
1047 ND::TP0DReconModule::TP0DParticle *p0dParticle = GetP0DReconParticleWithUniqueID(p0dObjectInGlobal->UniqueID);
1049 FillP0DParticleInfo(*p0dParticle,static_cast<AnaP0DParticle*>(part));
1054 FillTrackInfo(*globalTrack,static_cast<AnaTrack*>(part));
1069 void oaAnalysisTreeConverter::FillTECALReconObjects(
AnaBunch* bunch,
int ibunch){
1076 localBunch->TECALReconObjects .clear();
1079 for (UInt_t iTECAL=0; iTECAL<_bunchTECALObjects[ibunch].size(); ++iTECAL){
1080 ND::TTrackerECALReconModule::TECALReconObject *tecalObj = _bunchTECALObjects[ibunch][iTECAL];
1086 FillTECALReconObjectInfo(*tecalObj,anaTECAL,localBunch);
1090 if(anaTECAL) localBunch->TECALReconObjects.push_back(anaTECAL);
1097 void oaAnalysisTreeConverter::FillTECALReconUnmatchedObjects(
AnaBunch* bunch,
int ibunch){
1104 localBunch->TECALUnmatchedObjects.clear();
1107 for (UInt_t iTECAL=0; iTECAL<_bunchTECALUnmatchedObjects[ibunch].size(); ++iTECAL){
1108 ND::TTrackerECALReconModule::TECALReconUnmatchedObject *tecalObj = _bunchTECALUnmatchedObjects[ibunch][iTECAL];
1114 FillTECALUnmatchedObjectInfo(*tecalObj,anaTECAL,localBunch);
1118 if(anaTECAL) localBunch->TECALUnmatchedObjects.push_back(anaTECAL);
1125 void oaAnalysisTreeConverter::FillP0DReconVertices(
AnaBunch* bunch,
int ibunch){
1132 localBunch->P0DReconVertices.clear();
1135 for (UInt_t iP0D=0; iP0D<_bunchP0DVertices[ibunch].size(); ++iP0D){
1136 ND::TP0DReconModule::TP0DVertex *p0dVertex = _bunchP0DVertices[ibunch][iP0D];
1142 FillP0DReconVertexInfo(*p0dVertex,anaP0DRecon,localBunch);
1146 if(anaP0DRecon) localBunch->P0DReconVertices.push_back(anaP0DRecon);
1153 void oaAnalysisTreeConverter::FillP0DReconParticles(
AnaBunch* bunch,
int ibunch){
1160 localBunch->P0DReconParticles.clear();
1163 for (UInt_t iP0D=0; iP0D<_bunchP0DParticles[ibunch].size(); ++iP0D){
1164 ND::TP0DReconModule::TP0DParticle *p0dParticle = _bunchP0DParticles[ibunch][iP0D];
1169 FillP0DReconParticleInfo(*p0dParticle,anaP0DRecon,localBunch);
1173 if(anaP0DRecon) localBunch->P0DReconParticles.push_back(anaP0DRecon);
1180 void oaAnalysisTreeConverter::FillP0DReconClusters(
AnaBunch* bunch,
int ibunch){
1187 localBunch->P0DReconClusters.clear();
1190 for (UInt_t iP0D=0; iP0D<_bunchP0DClusters[ibunch].size(); ++iP0D){
1191 ND::TP0DReconModule::TP0DCluster *p0dCluster = _bunchP0DClusters[ibunch][iP0D];
1197 FillP0DReconClusterInfo(*p0dCluster,anaP0D,localBunch);
1201 if(anaP0D) localBunch->P0DReconClusters.push_back(anaP0D);
1208 void oaAnalysisTreeConverter::FillP0DReconVertexInfo(ND::TP0DReconModule::TP0DVertex& p0dVertex,
AnaP0DReconVertex* anaP0DReconVertex,
AnaLocalReconBunch* anaLocalBunch){
1211 FillP0DReconVertexLinks(p0dVertex, anaP0DReconVertex);
1213 anaP0DReconVertex->Vertices = p0dVertex.Vertices;
1214 anaP0DReconVertex->Particles = p0dVertex.Particles;
1215 anaP0DReconVertex->Tracks = p0dVertex.Tracks;
1216 anaP0DReconVertex->Showers = p0dVertex.Showers;
1217 anaP0DReconVertex->Clusters = p0dVertex.Clusters;
1218 anaP0DReconVertex->Nodes = p0dVertex.Nodes;
1219 anaP0DReconVertex->Hits = p0dVertex.Hits;
1220 anaP0DReconVertex->AlgorithmName = p0dVertex.AlgorithmName;
1221 anaP0DReconVertex->Cycle = p0dVertex.Cycle;
1222 anaP0DReconVertex->NHits = p0dVertex.NHits;
1223 anaP0DReconVertex->UniqueID = p0dVertex.UniqueID;
1224 anaP0DReconVertex->Status = p0dVertex.Status;
1225 anaP0DReconVertex->Quality = p0dVertex.Quality;
1226 anaP0DReconVertex->NDOF = p0dVertex.NDOF;
1227 anaP0DReconVertex->Truth_PrimaryTrajIDs = p0dVertex.Truth_PrimaryTrajIDs;
1228 anaP0DReconVertex->Truth_TrajIDs = p0dVertex.Truth_TrajIDs;
1229 anaP0DReconVertex->Truth_HitCount = p0dVertex.Truth_HitCount;
1230 anaP0DReconVertex->Truth_ChargeShare = p0dVertex.Truth_ChargeShare;
1231 anaUtils::VectorToArray (p0dVertex.Position, anaP0DReconVertex->Position );
1232 anaUtils::VectorToArray (p0dVertex.PosVariance, anaP0DReconVertex->PosVariance);
1233 anaP0DReconVertex->ValidDimensions = p0dVertex.ValidDimensions;
1234 anaP0DReconVertex->Fiducial = p0dVertex.Fiducial;
1236 anaP0DReconVertex->Bunch = anaLocalBunch->
Bunch;
1241 void oaAnalysisTreeConverter::FillP0DReconParticleInfo(ND::TP0DReconModule::TP0DParticle& p0dParticle,
AnaP0DReconParticle* anaP0DReconParticle,
AnaLocalReconBunch* anaLocalBunch){
1244 FillP0DReconParticleLinks(p0dParticle, anaP0DReconParticle);
1246 anaP0DReconParticle->Vertices = p0dParticle.Vertices;
1247 anaP0DReconParticle->Particles = p0dParticle.Particles;
1248 anaP0DReconParticle->Tracks = p0dParticle.Tracks;
1249 anaP0DReconParticle->Showers = p0dParticle.Showers;
1250 anaP0DReconParticle->Clusters = p0dParticle.Clusters;
1251 anaP0DReconParticle->Nodes = p0dParticle.Nodes;
1252 anaP0DReconParticle->Hits = p0dParticle.Hits;
1253 anaP0DReconParticle->AlgorithmName = p0dParticle.AlgorithmName;
1254 anaP0DReconParticle->Cycle = p0dParticle.Cycle;
1255 anaP0DReconParticle->NHits = p0dParticle.NHits;
1256 anaP0DReconParticle->UniqueID = p0dParticle.UniqueID;
1257 anaP0DReconParticle->Status = p0dParticle.Status;
1258 anaP0DReconParticle->Quality = p0dParticle.Quality;
1259 anaP0DReconParticle->NDOF = p0dParticle.NDOF;
1260 anaP0DReconParticle->SideDeposit = p0dParticle.SideDeposit;
1261 anaP0DReconParticle->EndDeposit = p0dParticle.EndDeposit;
1262 anaP0DReconParticle->Truth_PrimaryTrajIDs = p0dParticle.Truth_PrimaryTrajIDs;
1263 anaP0DReconParticle->Truth_TrajIDs = p0dParticle.Truth_TrajIDs;
1264 anaP0DReconParticle->Truth_HitCount = p0dParticle.Truth_HitCount;
1265 anaP0DReconParticle->Truth_ChargeShare = p0dParticle.Truth_ChargeShare;
1266 anaUtils::VectorToArray (p0dParticle.Position, anaP0DReconParticle->Position );
1267 anaUtils::VectorToArray (p0dParticle.PosVariance, anaP0DReconParticle->PosVariance);
1268 anaP0DReconParticle->ValidDimensions = p0dParticle.ValidDimensions;
1269 anaUtils::VectorToArray (p0dParticle.Direction, anaP0DReconParticle->Direction );
1270 anaUtils::VectorToArray (p0dParticle.DirVariance, anaP0DReconParticle->DirVariance );
1271 anaP0DReconParticle->Momentum = p0dParticle.Momentum;
1272 anaP0DReconParticle->Charge = p0dParticle.Charge;
1273 anaP0DReconParticle->realPIDNames = p0dParticle.realPIDNames;
1274 anaP0DReconParticle->realPIDValues = p0dParticle.realPIDValues;
1275 anaP0DReconParticle->integerPIDNames = p0dParticle.integerPIDNames;
1276 anaP0DReconParticle->integerPIDValues = p0dParticle.integerPIDValues;
1277 anaP0DReconParticle->PID = p0dParticle.PID;
1278 anaP0DReconParticle->PID_weight = p0dParticle.PID_weight;
1280 anaP0DReconParticle->Bunch = anaLocalBunch->
Bunch;
1282 if (p0dParticle.Tracks.size()==1){
1283 ND::TP0DReconModule::TP0DTrack *p0dTrack = (ND::TP0DReconModule::TP0DTrack*) (*P0DReconTracks)[p0dParticle.Tracks[0]];
1284 anaP0DReconParticle->Length = p0dTrack->Length;
1285 anaP0DReconParticle->Clusters = p0dTrack->Clusters;
1288 else if (p0dParticle.Tracks.size()>1){
1289 std::cout <<
"more than 1 track in particle" << std::endl;
1291 if (p0dParticle.Showers.size()==1){
1292 ND::TP0DReconModule::TP0DShower *p0dShower = (ND::TP0DReconModule::TP0DShower*) (*P0DReconShowers)[p0dParticle.Showers[0]];
1293 anaP0DReconParticle->EDeposit = p0dShower->EDeposit;
1294 anaP0DReconParticle->Clusters = p0dShower->Clusters;
1297 else if (p0dParticle.Showers.size()>1){
1298 std::cout <<
"more than 1 shower in particle" << std::endl;
1302 Float_t max_charge=0;
1304 Float_t total_charge=0;
1305 for (UInt_t i = 0; i<p0dParticle.Truth_PrimaryTrajIDs.size();i++){
1306 if (p0dParticle.Truth_ChargeShare[i] > max_charge){
1307 max_charge = p0dParticle.Truth_ChargeShare[i];
1310 total_charge += p0dParticle.Truth_ChargeShare[i];
1318 anaP0DReconParticle->TrueParticle=NULL;
1360 void oaAnalysisTreeConverter::FillP0DReconClusterInfo(ND::TP0DReconModule::TP0DCluster& p0dCluster,
AnaP0DReconCluster* anaP0DReconCluster,
AnaLocalReconBunch* anaLocalBunch){
1363 FillP0DReconClusterLinks(p0dCluster, anaP0DReconCluster);
1365 anaP0DReconCluster->Vertices = p0dCluster.Vertices;
1366 anaP0DReconCluster->Particles = p0dCluster.Particles;
1367 anaP0DReconCluster->Tracks = p0dCluster.Tracks;
1368 anaP0DReconCluster->Showers = p0dCluster.Showers;
1369 anaP0DReconCluster->Clusters = p0dCluster.Clusters;
1370 anaP0DReconCluster->Nodes = p0dCluster.Nodes;
1371 anaP0DReconCluster->Hits = p0dCluster.Hits;
1372 anaP0DReconCluster->AlgorithmName = p0dCluster.AlgorithmName;
1373 anaP0DReconCluster->Cycle = p0dCluster.Cycle;
1374 anaP0DReconCluster->NHits = p0dCluster.NHits;
1375 anaP0DReconCluster->UniqueID = p0dCluster.UniqueID;
1376 anaP0DReconCluster->Truth_PrimaryTrajIDs = p0dCluster.Truth_PrimaryTrajIDs;
1377 anaP0DReconCluster->Truth_TrajIDs = p0dCluster.Truth_TrajIDs;
1378 anaP0DReconCluster->Truth_HitCount = p0dCluster.Truth_HitCount;
1379 anaP0DReconCluster->Truth_ChargeShare = p0dCluster.Truth_ChargeShare;
1380 anaUtils::VectorToArray (p0dCluster.Position, anaP0DReconCluster->Position );
1381 anaUtils::VectorToArray (p0dCluster.PosVariance, anaP0DReconCluster->PosVariance);
1382 anaP0DReconCluster->ValidDimensions = p0dCluster.ValidDimensions;
1383 anaP0DReconCluster->NFiducialHits = p0dCluster.NFiducialHits;
1384 anaP0DReconCluster->EDeposit = p0dCluster.EDeposit;
1387 anaP0DReconCluster->Bunch = anaLocalBunch->
Bunch;
1392 void oaAnalysisTreeConverter::FillP0DReconVertexLinks(ND::TP0DReconModule::TP0DVertex& p0dVertex,
AnaP0DReconVertex* anaP0DReconVertex){
1396 for (UInt_t i=0;i<p0dVertex.Vertices.size();i++){
1397 ND::TP0DReconModule::TP0DVertex *p0dVertex2 = (ND::TP0DReconModule::TP0DVertex*) (*P0DReconVertices)[p0dVertex.Vertices[i]];
1398 anaP0DReconVertex->VerticesP.push_back(_P0DReconVerticesMap[p0dVertex2]);
1401 for (UInt_t i=0;i<p0dVertex.Particles.size();i++){
1402 ND::TP0DReconModule::TP0DParticle *p0dParticle2 = (ND::TP0DReconModule::TP0DParticle*) (*P0DReconParticles)[p0dVertex.Particles[i]];
1403 anaP0DReconVertex->ParticlesP.push_back(_P0DReconParticlesMap[p0dParticle2]);
1406 for (UInt_t i=0;i<p0dVertex.Clusters.size();i++){
1407 ND::TP0DReconModule::TP0DCluster *p0dCluster2 = (ND::TP0DReconModule::TP0DCluster*) (*P0DReconClusters)[p0dVertex.Clusters[i]];
1408 anaP0DReconVertex->ClustersP.push_back(_P0DReconClustersMap[p0dCluster2]);
1414 void oaAnalysisTreeConverter::FillP0DReconParticleLinks(ND::TP0DReconModule::TP0DParticle& p0dParticle,
AnaP0DReconParticle* anaP0DReconParticle){
1417 for (UInt_t i=0;i<p0dParticle.Vertices.size();i++){
1418 ND::TP0DReconModule::TP0DVertex *p0dVertex2 = (ND::TP0DReconModule::TP0DVertex*) (*P0DReconVertices)[p0dParticle.Vertices[i]];
1419 anaP0DReconParticle->VerticesP.push_back(_P0DReconVerticesMap[p0dVertex2]);
1422 for (UInt_t i=0;i<p0dParticle.Particles.size();i++){
1423 ND::TP0DReconModule::TP0DParticle *p0dParticle2 = (ND::TP0DReconModule::TP0DParticle*) (*P0DReconParticles)[p0dParticle.Particles[i]];
1424 anaP0DReconParticle->ParticlesP.push_back(_P0DReconParticlesMap[p0dParticle2]);
1427 for (UInt_t i=0;i<p0dParticle.Clusters.size();i++){
1428 ND::TP0DReconModule::TP0DCluster *p0dCluster2 = (ND::TP0DReconModule::TP0DCluster*) (*P0DReconClusters)[p0dParticle.Clusters[i]];
1429 anaP0DReconParticle->ClustersP.push_back(_P0DReconClustersMap[p0dCluster2]);
1435 void oaAnalysisTreeConverter::FillP0DReconClusterLinks(ND::TP0DReconModule::TP0DCluster& p0dCluster,
AnaP0DReconCluster* anaP0DReconCluster){
1438 for (UInt_t i=0;i<p0dCluster.Vertices.size();i++){
1439 ND::TP0DReconModule::TP0DVertex *p0dVertex2 = (ND::TP0DReconModule::TP0DVertex*) (*P0DReconVertices)[p0dCluster.Vertices[i]];
1440 anaP0DReconCluster->VerticesP.push_back(_P0DReconVerticesMap[p0dVertex2]);
1443 for (UInt_t i=0;i<p0dCluster.Particles.size();i++){
1444 ND::TP0DReconModule::TP0DParticle *p0dParticle2 = (ND::TP0DReconModule::TP0DParticle*) (*P0DReconParticles)[p0dCluster.Particles[i]];
1445 anaP0DReconCluster->ParticlesP.push_back(_P0DReconParticlesMap[p0dParticle2]);
1448 for (UInt_t i=0;i<p0dCluster.Clusters.size();i++){
1449 ND::TP0DReconModule::TP0DCluster *p0dCluster2 = (ND::TP0DReconModule::TP0DCluster*) (*P0DReconClusters)[p0dCluster.Clusters[i]];
1450 anaP0DReconCluster->ClustersP.push_back(_P0DReconClustersMap[p0dCluster2]);
1456 void oaAnalysisTreeConverter::FillGlobalVertices(
AnaSpill* spill){
1461 for (
unsigned int ibunch=0; ibunch<NBUNCHES+1; ibunch++) {
1463 if (_bunchVertices[ibunch].size() == 0)
continue;
1469 std::vector<AnaBunchC*>::iterator itbunch;
1470 for (itbunch = spill->
Bunches.begin(); itbunch != spill->
Bunches.end(); itbunch++) {
1471 if (ibunch == (
unsigned int)(*itbunch)->Bunch) {
1472 bunch =
static_cast<AnaBunch*
>(*itbunch);
1478 std::cout <<
"ERROR 1102 in oaAnalysisConverter: looking for a bunch not created!" << std::endl;
1481 unsigned int nVertices = std::min((
unsigned int)_bunchVertices[ibunch].size(), NMAXVERTICES);
1482 for (
unsigned int j=0; j<nVertices; j++) {
1483 ND::TGlobalReconModule::TGlobalVertex *globalVertex = _bunchVertices[ibunch][j];
1485 FillVertexInfo(*globalVertex, vertex, bunch, spill);
1497 void oaAnalysisTreeConverter::FillFgdTimeBinInfo(std::vector<AnaFgdTimeBinB*>* AnaFgdTimeBins){
1501 for(Int_t ibin=0; ibin<NFgdTimeBins; ibin++) {
1503 ND::TGlobalReconModule::TFgdTimeBin *bin=(ND::TGlobalReconModule::TFgdTimeBin*)(*(FgdTimeBins))[ibin];
1506 if (AnaFgdTimeBins->size()>=NMAXFGDTIMEBINS)
1511 AnaFgdTimeBins->push_back(abin);
1514 abin->MinTime = bin->minTime;
1515 abin->MaxTime = bin->maxTime;
1516 abin->G4ID = bin->g4ID;
1518 for (
int i=0;i<2;i++){
1519 abin->NHits[i] = bin->nHits[i];
1520 abin->RawChargeSum[i] = bin->rawChargeSum[i];
1526 void oaAnalysisTreeConverter::FillTECALReconObjectInfo(ND::TTrackerECALReconModule::TECALReconObject& tecalReconObject,
AnaTECALReconObject *anaTECALReconObject,
AnaLocalReconBunch *anaLocalBunch){
1529 anaTECALReconObject->AverageHitTime = tecalReconObject.AverageHitTime;
1530 anaTECALReconObject->AverageZPos = tecalReconObject.AverageZPosition;
1531 anaTECALReconObject->Containment = tecalReconObject.Containment;
1532 anaTECALReconObject->EFitResult = tecalReconObject.EMEnergyFit_Result;
1533 anaTECALReconObject->EFitUncertainty = tecalReconObject.EMEnergyFit_Uncertainty;
1535 #if !VERSION_PROD7_DEVEL 1536 anaTECALReconObject->FirstLayer = tecalReconObject.FirstLayer;
1537 anaTECALReconObject->IsShowerLike = tecalReconObject.IsShowerLike;
1538 anaTECALReconObject->IsTrackLike = tecalReconObject.IsTrackLike;
1539 anaTECALReconObject->LastLayer = tecalReconObject.LastLayer;
1540 anaTECALReconObject->MichelTagNDelayedCluster = tecalReconObject.MElectronTag_NDelayedCluster;
1541 anaTECALReconObject->PIDAMR = tecalReconObject.PID_AMR;
1542 anaTECALReconObject->PIDMaxRatio = tecalReconObject.PID_Max_Ratio;
1543 anaTECALReconObject->PIDMeanPos = tecalReconObject.PID_MeanPosition;
1544 anaTECALReconObject->PIDShowerWidth = tecalReconObject.PID_ShowerWidth;
1545 anaTECALReconObject->TimeBunch = tecalReconObject.TimeBunch;
1548 #if VERSION_HAS_ECAL_LLR 1549 anaTECALReconObject->LikeEMHIP = tecalReconObject.PID_LLR_EM_HIP;
1550 anaTECALReconObject->LikeMIPEM = tecalReconObject.PID_LLR_MIP_EM;
1551 anaTECALReconObject->LikeMIPEMLow = tecalReconObject.PID_LLR_MIP_EM_LowMomentum;
1552 anaTECALReconObject->LikeMIPPion = tecalReconObject.PID_LLR_MIP_Pion;
1555 anaTECALReconObject->MatchingLike = tecalReconObject.MatchingLikelihood;
1556 anaTECALReconObject->Module = tecalReconObject.Module;
1557 anaTECALReconObject->MostDownStreamLayerHit = tecalReconObject.mostDownStreamLayerHit;
1558 anaTECALReconObject->MostUpStreamLayerHit = tecalReconObject.mostUpStreamLayerHit;
1559 anaTECALReconObject->NHits = tecalReconObject.NHits;
1560 anaTECALReconObject->NLayersHit = tecalReconObject.NLayersHit;
1561 anaTECALReconObject->ObjectLength = tecalReconObject.ObjectLength;
1562 anaTECALReconObject->PIDAngle = tecalReconObject.PID_Angle;
1563 anaTECALReconObject->PIDAsymmetry = tecalReconObject.PID_Asymmetry;
1564 anaTECALReconObject->PIDCircularity = tecalReconObject.PID_Circularity;
1565 anaTECALReconObject->PIDFBR = tecalReconObject.PID_FrontBackRatio;
1566 anaTECALReconObject->PIDShowerAngle = tecalReconObject.PID_ShowerAngle;
1567 anaTECALReconObject->PIDTransverseChargeRatio = tecalReconObject.PID_TransverseChargeRatio;
1568 anaTECALReconObject->PIDTruncatedMaxRatio = tecalReconObject.PID_TruncatedMaxRatio;
1569 anaUtils::VectorToArray (tecalReconObject.Pointing, anaTECALReconObject->Pointing );
1570 anaTECALReconObject->Thrust = tecalReconObject.Thrust;
1571 anaUtils::VectorToArray (tecalReconObject.ThrustAxis, anaTECALReconObject->ThrustAxis );
1572 anaUtils::VectorToArray (tecalReconObject.ThrustOrigin, anaTECALReconObject->ThrustOrigin);
1573 anaTECALReconObject->TotalHitCharge = tecalReconObject.TotalHitCharge;
1574 anaTECALReconObject->TrueID = tecalReconObject.G4ID;
1575 anaTECALReconObject->TrueIDPrimary = tecalReconObject.G4ID_Primary;
1576 anaTECALReconObject->TrueIDRecursive = tecalReconObject.G4ID_Recursive;
1577 anaTECALReconObject->TrueIDSingle = tecalReconObject.G4ID_Single;
1578 anaTECALReconObject->UniqueID = tecalReconObject.UniqueID;
1580 anaTECALReconObject->Bunch = anaLocalBunch->
Bunch;
1585 void oaAnalysisTreeConverter::FillTECALUnmatchedObjectInfo(ND::TTrackerECALReconModule::TECALReconUnmatchedObject& tecalUnmatchedObject,
AnaTECALUnmatchedObject* anaTECALUnmatchedObject,
AnaLocalReconBunch* anaLocalBunch){
1588 anaTECALUnmatchedObject->AverageHitTime = tecalUnmatchedObject.AverageHitTime;
1589 anaUtils::VectorToArray (tecalUnmatchedObject.BackPosition, anaTECALUnmatchedObject->BackPos );
1590 anaUtils::VectorToArray (tecalUnmatchedObject.FrontPosition, anaTECALUnmatchedObject->FrontPos);
1591 anaTECALUnmatchedObject->MostDownStreamLayerHit = tecalUnmatchedObject.mostDownStreamLayerHit;
1592 anaTECALUnmatchedObject->MostUpStreamLayerHit = tecalUnmatchedObject.mostUpStreamLayerHit;
1593 anaTECALUnmatchedObject->NHits = tecalUnmatchedObject.NHits;
1594 anaTECALUnmatchedObject->TotalHitCharge = tecalUnmatchedObject.TotalHitCharge;
1595 anaTECALUnmatchedObject->TrueID = tecalUnmatchedObject.G4ID;
1596 anaTECALUnmatchedObject->TrueIDPrimary = tecalUnmatchedObject.G4ID_Primary;
1597 anaTECALUnmatchedObject->TrueIDRecursive = tecalUnmatchedObject.G4ID_Recursive;
1598 anaTECALUnmatchedObject->TrueIDSingle = tecalUnmatchedObject.G4ID_Single;
1599 anaTECALUnmatchedObject->View = tecalUnmatchedObject.View;
1601 anaTECALUnmatchedObject->Bunch = anaLocalBunch->
Bunch;
1629 void oaAnalysisTreeConverter::FillTrackInfo(ND::TGlobalReconModule::TGlobalPID& globalTrack,
AnaTrack* track){
1633 track->
UniqueID = globalTrack.UniqueID;
1634 track->
Status = globalTrack.Status;
1635 track->
NNodes = globalTrack.NNodes;
1636 track->
NHits = globalTrack.NHits;
1637 track->
NNodes = globalTrack.NNodes;
1638 track->
NDOF = globalTrack.NDOF;
1639 track->
Chi2 = globalTrack.Chi2;
1640 track->
Detectors = globalTrack.Detectors;
1641 track->
Length = globalTrack.Length;
1642 track->
Momentum = globalTrack.FrontMomentum;
1644 track->
Charge = globalTrack.Charge;
1645 anaUtils::VectorToArray(globalTrack.FrontDirection, track->
DirectionStart);
1646 anaUtils::VectorToArray(globalTrack.BackDirection, track->
DirectionEnd);
1647 anaUtils::VectorToArray(globalTrack.FrontPosition, track->
PositionStart);
1648 anaUtils::VectorToArray(globalTrack.BackPosition, track->
PositionEnd);
1650 FillTrackHits(globalTrack, track);
1659 #if VERSION_HAS_PRANGE_ESTIMATES 1660 track->RangeMomentumEle = -10000;
1662 track->RangeMomentumProton = -10000;
1664 track->RangeMomentumMuonFlip = -10000;
1665 track->RangeMomentumProtonFlip = -10000;
1669 std::map<double, int, std::greater<double> > map_pid;
1671 for (
int i=0; i < (int)globalTrack.PIDWeights.size(); i++)
1672 map_pid[globalTrack.PIDWeights[i]] = globalTrack.ParticleIds[i];
1674 if (map_pid.size() > 0 )
1675 track->
ReconPDG = map_pid.begin()->second;
1680 for (
int jj = 0; jj < globalTrack.NAlternates; jj++) {
1681 ND::TGlobalReconModule::TGlobalPIDAlternate *alt = (ND::TGlobalReconModule::TGlobalPIDAlternate*)(*(globalTrack.Alternates))[jj];
1684 bool samedir =
true;
1686 #if VERSION_HAS_REVERSED_REFITS 1691 samedir = ((alt->FrontDirection[2] < 0 && track->
DirectionStart[2] < 0) || (alt->FrontDirection[2] >= 0 && track->
DirectionStart[2] >= 0));
1693 if (!samedir && map_pid.size() > 0){
1696 if (alt->ParticleId == map_pid.begin()->second){
1699 anaUtils::VectorToArray( alt->FrontDirection, track->DirectionEndFlip);
1706 if (alt->ParticleId == 11 && samedir) {
1709 }
else if (alt->ParticleId == 13 && samedir) {
1712 }
else if (alt->ParticleId == 2212 && samedir) {
1719 #if VERSION_HAS_PRANGE_ESTIMATES 1723 track->RangeMomentumEle = globalTrack.RangeMomentumElectron;
1725 track->RangeMomentumProton = globalTrack.RangeMomentumProton;
1727 track->RangeMomentumMuonFlip = globalTrack.RangeMomentumMuonFlip;
1728 track->RangeMomentumProtonFlip = globalTrack.RangeMomentumProtonFlip;
1731 #if VERSION_HAS_TIME_FITS 1732 for (
unsigned int i=0;i<globalTrack.NodeTimes.size();i++){
1736 node->
Detector = globalTrack.NodeTimes[i].first;
1737 node->
TimeStart = globalTrack.NodeTimes[i].second.X();
1738 node->
TimeEnd = globalTrack.NodeTimes[i].second.Y();
1740 track->TimeNodes.push_back(node);
1743 track->
ToF.Flag_FGD1_FGD2 =
false;
1744 track->
ToF.Flag_P0D_FGD1 =
false;
1745 track->
ToF.Flag_ECal_FGD1 =
false;
1746 track->
ToF.Flag_ECal_FGD2 =
false;
1747 track->
ToF.Flag_DSECal_FGD2 =
false;
1749 bool fgd1 =
false, fgd2 =
false, p0d =
false, ecal =
false, dsecal =
false;
1750 float tfgd1 = 0, tfgd2 = 0, tp0d = 0, tecal = 0, tdsecal = 0;
1752 for (
unsigned int i=0;i<globalTrack.NodeTimes.size();i++){
1753 double t = ( globalTrack.NodeTimes[i].second.X()+globalTrack.NodeTimes[i].second.Y() )/2.0;
1754 switch( globalTrack.NodeTimes[i].first ){
1756 if(!fgd1){tfgd1 = t;}
1760 if(!fgd2){tfgd2 = t;}
1768 if(!dsecal){tdsecal = t;}
1772 if(!ecal){tecal = t;}
1779 track->
ToF.Flag_FGD1_FGD2 =
true;
1780 track->
ToF.FGD1_FGD2 = tfgd1-tfgd2;
1781 }
else{track->
ToF.Flag_FGD1_FGD2 =
false;}
1783 track->
ToF.Flag_P0D_FGD1 =
true;
1784 track->
ToF.P0D_FGD1 = tp0d-tfgd1;
1785 }
else{track->
ToF.Flag_P0D_FGD1 =
false;}
1787 track->
ToF.Flag_ECal_FGD1 =
true;
1788 track->
ToF.ECal_FGD1 = tecal-tfgd1;
1789 }
else{track->
ToF.Flag_ECal_FGD1 =
false;}
1791 track->
ToF.Flag_DSECal_FGD2 =
true;
1792 track->
ToF.DSECal_FGD2 = tdsecal-tfgd2;
1793 }
else{track->
ToF.Flag_DSECal_FGD2 =
false;}
1795 track->
ToF.Flag_ECal_FGD2 =
true;
1796 track->
ToF.ECal_FGD2 = tecal-tfgd2;
1797 }
else{track->
ToF.Flag_ECal_FGD2 =
false;}
1806 FillTpcInfo(globalTrack, track);
1807 FillFgdInfo(globalTrack, track);
1808 FillEcalInfo(globalTrack, track);
1809 FillSmrdInfo(globalTrack, track);
1810 FillP0dInfo(globalTrack, track);
1811 FillTrackerInfo(globalTrack, track);
1814 FillTrueParticleRecoInfo(globalTrack.TrueParticle, track->
TrueObject,
true);
1823 std::cout<<
"oaAnalysisTreeConverter::FillTrackInfo() found a track from globalPID with UniqueID:"<<globalTrack.UniqueID
1824 <<
" and appended it to ReconParticles for true pi0 decay photon with ID:"<<trueParticle->
ID 1838 void oaAnalysisTreeConverter::FillTrackHits(ND::TGlobalReconModule::TGlobalPID& globalTrack,
AnaTrack* track){
1843 if (globalTrack.NHitsSaved == 0)
return;
1846 int prevtype, thistype;
1847 ND::TGlobalReconModule::TGlobalHit* hit;
1849 hit = (ND::TGlobalReconModule::TGlobalHit*)(*(globalTrack.HitsSaved))[ihit];
1851 track->UpstreamHits_Charge[0] = hit->Charge;
1852 prevtype = hit->Type % 100;
1853 if (globalTrack.NHitsSaved == 4 && prevtype==11) std::cout <<
"Minor error in oaAnalysisConverter::FillTrackHits (ref. 4833)\n";
1858 bool anotherupstream =
false;
1859 if (globalTrack.NHitsSaved == 3 && prevtype != 11) {
1860 ND::TGlobalReconModule::TGlobalHit* hit1 = (ND::TGlobalReconModule::TGlobalHit*)(*(globalTrack.HitsSaved))[1];
1861 ND::TGlobalReconModule::TGlobalHit* hit2 = (ND::TGlobalReconModule::TGlobalHit*)(*(globalTrack.HitsSaved))[2];
1862 if (hit1->Position.Z() < hit2->Position.Z()) anotherupstream =
true;
1864 if (hit1->Position.Z() == hit2->Position.Z() && (hit1->Type % 100) == 11) anotherupstream =
true;
1871 if (globalTrack.NHitsSaved == 4 || anotherupstream) {
1872 hit = (ND::TGlobalReconModule::TGlobalHit*)(*(globalTrack.HitsSaved))[++ihit];
1874 track->UpstreamHits_Charge[1] = hit->Charge;
1875 thistype = hit->Type % 100;
1876 if (prevtype == thistype) std::cout <<
"Minor error in oaAnalysisConverter::FillTrackHits (ref. 4835) " << prevtype <<
" vs " << thistype <<
"\n";
1880 hit = (ND::TGlobalReconModule::TGlobalHit*)(*(globalTrack.HitsSaved))[++ihit];
1881 track->DownstreamHits_Position[0] = hit->Position;
1882 track->DownstreamHits_Charge[0] = hit->Charge;
1883 prevtype = hit->Type % 100;
1886 if (ihit == globalTrack.NHitsSaved-1)
return;
1887 if (prevtype==11) std::cout <<
"Minor error in oaAnalysisConverter::FillTrackHits (ref. 4836) " << ihit <<
" vs " << globalTrack.NHitsSaved <<
" and " << anotherupstream <<
"\n";
1888 hit = (ND::TGlobalReconModule::TGlobalHit*)(*(globalTrack.HitsSaved))[++ihit];
1889 track->DownstreamHits_Position[1] = hit->Position;
1890 track->DownstreamHits_Charge[1] = hit->Charge;
1891 thistype = hit->Type % 100;
1892 if (prevtype == thistype) std::cout <<
"Minor error in oaAnalysisConverter::FillTrackHits (ref. 4837) \n";
1894 if (ihit != globalTrack.NHitsSaved-1) std::cout <<
"Minor error in oaAnalysisConverter::FillTrackHits (ref. 4838) \n";
1898 void oaAnalysisTreeConverter::FillTpcInfo(ND::TGlobalReconModule::TGlobalPID& globalTrack,
AnaTrack* track){
1902 std::vector<ND::TGlobalReconModule::TTPCObject*> tpcObjects;
1904 tpcObjects.reserve((
unsigned int)globalTrack.NTPCs);
1907 for(
int jj = 0; jj < globalTrack.NTPCs; jj++){
1908 ND::TGlobalReconModule::TTPCObject *tpcTrack=(ND::TGlobalReconModule::TTPCObject*)(*(globalTrack.TPC))[jj];
1909 if(!tpcTrack)
continue;
1910 tpcObjects.push_back(tpcTrack);
1914 std::sort(tpcObjects.begin(), tpcObjects.end(), CompareNNodes);
1916 int nObjects = std::min((
unsigned int)tpcObjects.size(), NMAXTPCS);
1917 for(
int jj = 0; jj < nObjects; jj++){
1918 ND::TGlobalReconModule::TTPCObject *tpcTrack=tpcObjects[jj];
1921 FillTpcTrackInfo( *tpcTrack, seg);
1927 void oaAnalysisTreeConverter::FillFgdInfo(ND::TGlobalReconModule::TGlobalPID& globalTrack,
AnaTrack* track){
1930 for(
int jj = 0; jj < globalTrack.NFGDs; jj++){
1934 ND::TGlobalReconModule::TFGDObject *fgdTrack=(ND::TGlobalReconModule::TFGDObject*)(*(globalTrack.FGD))[jj];
1935 if(!fgdTrack)
continue;
1938 FillFgdTrackInfo( *fgdTrack, seg);
1944 void oaAnalysisTreeConverter::FillEcalInfo(ND::TGlobalReconModule::TGlobalPID& globalTrack,
AnaTrack* track){
1949 for(
int jj = 0; jj < globalTrack.NECALs; jj++){
1953 ND::TGlobalReconModule::TECALObject *ecalTrack=(ND::TGlobalReconModule::TECALObject*)(*(globalTrack.ECAL))[jj];
1954 if(!ecalTrack)
continue;
1957 FillEcalTrackInfo( *ecalTrack, seg);
1962 for(
int jj = 0; jj < globalTrack.NP0DECALs; jj++){
1966 ND::TGlobalReconModule::TECALObject *ecalTrack=(ND::TGlobalReconModule::TECALObject*)(*(globalTrack.P0DECAL))[jj];
1967 if(!ecalTrack)
continue;
1970 FillEcalTrackInfo( *ecalTrack, seg);
1977 void oaAnalysisTreeConverter::FillSmrdInfo(ND::TGlobalReconModule::TGlobalPID& globalTrack,
AnaTrack* track){
1980 for(
int jj = 0; jj < globalTrack.NSMRDs; jj++){
1984 ND::TGlobalReconModule::TSMRDObject *smrdTrack=(ND::TGlobalReconModule::TSMRDObject*)(*(globalTrack.SMRD))[jj];
1985 if(!smrdTrack)
continue;
1988 FillSmrdTrackInfo( *smrdTrack, seg);
1994 void oaAnalysisTreeConverter::FillP0dInfo(ND::TGlobalReconModule::TGlobalPID& globalTrack,
AnaTrack* track){
1997 for(
int jj = 0; jj < globalTrack.NP0Ds; jj++){
2002 ND::TGlobalReconModule::TP0DObject *p0dTrack=(ND::TGlobalReconModule::TP0DObject*)(*(globalTrack.P0D))[jj];
2003 if(!p0dTrack)
continue;
2007 FillP0dTrackInfo( *p0dTrack, seg);
2009 Float_t entrance[4] = {globalTrack.EntrancePosition[0].X(),globalTrack.EntrancePosition[0].Y(),globalTrack.EntrancePosition[0].Z(),globalTrack.EntrancePosition[0].T()};
2012 seg->ELoss = track->
Momentum - globalTrack.EntranceMomentum[0];
2013 else seg->ELoss = -99999;
2021 if (_isUsingReconDirP0DNew){
2023 ND::TP0DReconModule::TP0DParticle *p0dParticle = GetP0DReconParticleWithUniqueID(p0dTrack->UniqueID);
2028 FillP0DParticleInfo(*p0dParticle,part);
2036 void oaAnalysisTreeConverter::FillTrackerInfo(ND::TGlobalReconModule::TGlobalPID& globalTrack,
AnaTrack* track){
2040 for(
int jj = 0; jj < globalTrack.NTRACKERs; jj++){
2045 ND::TGlobalReconModule::TTrackerObject *trTrack=(ND::TGlobalReconModule::TTrackerObject*)(*(globalTrack.TRACKER))[jj];
2046 if(!trTrack)
continue;
2049 FillTrackerTrackInfo( *trTrack, seg);
2055 void oaAnalysisTreeConverter::FillSubdetectorTrackInfo(ND::TSubBaseObject& subTrack,
AnaParticleB* seg){
2058 seg->
NHits = subTrack.NHits;
2063 seg2->
Length = subTrack.Length;
2065 seg->
NNodes = subTrack.NNodes;
2066 anaUtils::VectorToArray(subTrack.FrontDirection,seg->
DirectionStart);
2067 anaUtils::VectorToArray(subTrack.BackDirection, seg->
DirectionEnd);
2068 anaUtils::VectorToArray(subTrack.FrontPosition, seg->
PositionStart);
2069 anaUtils::VectorToArray(subTrack.BackPosition, seg->
PositionEnd);
2074 void oaAnalysisTreeConverter::FillTpcTrackInfo(ND::TGlobalReconModule::TTPCObject& tpcTrack,
AnaTPCParticle* seg){
2077 FillSubdetectorTrackInfo(tpcTrack, seg);
2081 seg->
Charge = tpcTrack.Charge;
2082 seg->
Momentum = tpcTrack.FrontMomentum;
2086 #if VERSION_HAS_BFIELD_REFIT_FULL 2087 seg->RefitCharge = tpcTrack.RefitCharge;
2089 anaUtils::VectorToArray(tpcTrack.RefitDirection, seg->RefitDirection);
2090 anaUtils::VectorToArray(tpcTrack.RefitPosition, seg->RefitPosition);
2093 #if VERSION_HAS_BFIELD_REFIT_BASIC 2097 #if VERSION_HAS_EFIELD_REFIT 2101 seg->
Pullmu = tpcTrack.PullMuon;
2102 seg->
Pullele = tpcTrack.PullEle;
2103 seg->
Pullp = tpcTrack.PullProton;
2104 seg->
Pullpi = tpcTrack.PullPion;
2105 seg->
Pullk = tpcTrack.PullKaon;
2124 FillTrueParticleRecoInfo(tpcTrack.TrueParticle, seg->
TrueObject,
false);
2126 seg->
Purity = tpcTrack.TrueParticle.Pur;
2131 #if VERSION_PROD7_DEVEL 2132 seg->
NNodes = tpcTrack.NbFittedVerticalClusters +
2133 tpcTrack.NbFittedHorizontalClusters;
2139 void oaAnalysisTreeConverter::FillFgdTrackInfo(ND::TGlobalReconModule::TFGDObject& fgdTrack,
AnaFGDParticle* seg){
2142 FillSubdetectorTrackInfo(fgdTrack, seg);
2145 seg->
E = fgdTrack.E;
2146 seg->
X = fgdTrack.x;
2148 seg->
AvgTime = fgdTrack.avgtime;
2150 seg->
Pullmu = fgdTrack.PullMuon;
2151 seg->
Pullp = fgdTrack.PullProton;
2152 seg->
Pullpi = fgdTrack.PullPion;
2153 seg->
Pullno = fgdTrack.PullNotSet;
2156 seg->Vertex3x3 = fgdTrack.fgdVA_verNearQ;
2157 seg->Vertex5x5 = fgdTrack.fgdVA_verNextNearQ;
2158 seg->Vertex7x7 = fgdTrack.fgdVA_verNextNextNearQ;
2166 seg->VertexLayer = fgdTrack.fgdVA_verLayQ;
2170 void oaAnalysisTreeConverter::FillTrackerTrackInfo(ND::TGlobalReconModule::TTrackerObject& trackerTrack,
AnaTrackerTrack* seg){
2173 FillSubdetectorTrackInfo(trackerTrack, seg);
2179 seg->
Charge = trackerTrack.Charge;
2180 seg->
Momentum = trackerTrack.FrontMomentum;
2187 void oaAnalysisTreeConverter::FillEcalTrackInfo(ND::TGlobalReconModule::TECALObject& ecalTrack,
AnaECALParticle* seg){
2190 FillSubdetectorTrackInfo(ecalTrack, seg);
2194 seg->
EMEnergy = ecalTrack.EMEnergy;
2195 seg->
EDeposit = ecalTrack.EDeposit;
2197 seg->
AvgTime = ecalTrack.AverageHitTime;
2198 seg->
Length = ecalTrack.Length;
2199 #if VERSION_HAS_ECAL_LLR 2201 seg->
PIDMipEm = ecalTrack.LLR_MIP_EM;
2202 seg->PIDMipPion = ecalTrack.LLR_MIP_Pion;
2203 seg->PIDEmHip = ecalTrack.LLR_EM_HIP;
2206 for (
int i = 0; i < NTrECalObjects; i++) {
2207 ND::TTrackerECALReconModule::TECALReconObject *ecalObject = (ND::TTrackerECALReconModule::TECALReconObject*) (*TrECalObjects)[i];
2209 if (ecalTrack.UniqueID == ecalObject->UniqueID) {
2211 #if !VERSION_HAS_ECAL_LLR 2213 _ecalPidCalc->CalculateLikelihoodValues(*ecalObject);
2214 seg->
PIDMipEm = _ecalPidCalc->GetLikelihoodValue(
"MipEm");
2215 seg->PIDMipPion = _ecalPidCalc->GetLikelihoodValue(
"MipPion");
2216 seg->PIDEmHip = _ecalPidCalc->GetLikelihoodValue(
"EmHip");
2218 seg->Containment = ecalObject->Containment;
2220 #if !VERSION_PROD7_DEVEL 2221 seg->
TrShVal = ecalObject->PID_TrShval;
2225 anaUtils::VectorToArray(ecalObject->Shower.Position.Vect(),seg->
ShowerPosition);
2232 void oaAnalysisTreeConverter::FillSmrdTrackInfo(ND::TGlobalReconModule::TSMRDObject& smrdTrack,
AnaSMRDParticle* seg){
2235 FillSubdetectorTrackInfo(smrdTrack, seg);
2239 seg->
AvgTime = smrdTrack.avgtime;
2240 seg->EDeposit = smrdTrack.EDeposit;
2245 void oaAnalysisTreeConverter::FillP0dTrackInfo(ND::TGlobalReconModule::TP0DObject& p0dTrack,
AnaP0DParticle* seg){
2248 FillSubdetectorTrackInfo(p0dTrack, seg);
2249 seg->Length = p0dTrack.Length;
2254 void oaAnalysisTreeConverter::FillTrueParticleRecoInfo(ND::TTrueParticle& trueParticle,
AnaTrueObjectC*& trueObj,
bool setpurity){
2261 if (trueParticle.ID == -1)
return;
2263 std::vector<AnaTrueParticleB*>::iterator it;
2267 if (trueParticle.ID == truePart->
ID){
2283 void oaAnalysisTreeConverter::FillTrueParticleInfo(ND::TTruthTrajectoriesModule::TTruthTrajectory* truthTraj,
AnaTrueParticle* truePart,
AnaSpill* spill){
2290 if(truthTraj==NULL ){
2295 anaUtils::VectorToArray(TLorentzVector(0,0,0,0),truePart->
Position);
2297 anaUtils::VectorToArray(TVector3(0,0,0), truePart->
Direction);
2299 truePart->
Bunch = -1;
2305 truePart->
ID = truthTraj->ID;
2306 truePart->
PDG = truthTraj->PDG;
2307 truePart->
PrimaryID = truthTraj->PrimaryID;
2308 truePart->
ParentID = truthTraj->ParentID;
2309 anaUtils::VectorToArray(truthTraj->InitPosition, truePart->
Position);
2310 anaUtils::VectorToArray(truthTraj->FinalPosition,truePart->
PositionEnd);
2311 truePart->
Momentum = truthTraj->InitMomentum.Vect().Mag();
2312 anaUtils::VectorToArray((1/truePart->
Momentum)*truthTraj->InitMomentum.Vect(), truePart->
Direction);
2313 truePart->
Charge = truthTraj->Charge;
2317 truePart->
Bunch = _bunching.GetBunch(truthTraj->InitPosition.T() + _trueBunchShift, spill->
EventInfo->
Run, IsMC, cosmic_mode);
2321 unsigned int nCrossers = std::min((
unsigned int)truthTraj->TraceSubdetectors.size(), NMAXCROSSEDDET);
2324 anaUtils::CreateArray(truePart->
DetCrossings, nCrossers);
2325 for(
unsigned int i=0;i<nCrossers;i++){
2330 cross->
InActive = truthTraj->TraceInActive[i];
2331 anaUtils::VectorToArray(truthTraj->TraceEntrancePosition[i], cross->
EntrancePosition);
2332 anaUtils::VectorToArray(truthTraj->TraceExitPosition[i], cross->
ExitPosition);
2333 anaUtils::VectorToArray(truthTraj->TraceEntranceMomentum[i], cross->
EntranceMomentum);
2334 anaUtils::VectorToArray(truthTraj->TraceExitMomentum[i], cross->
ExitMomentum);
2344 ND::TTruthVerticesModule::TTruthVertex* vtx = _truthUtils.GetVertexOfTrajectory(truthTraj);
2350 ND::TTruthTrajectoriesModule::TTruthTrajectory* parentTraj = _truthUtils.GetParentTrajectory(truthTraj->ID);
2351 ND::TTruthTrajectoriesModule::TTruthTrajectory* grandparentTraj = NULL;
2353 if(parentTraj!=NULL){
2356 grandparentTraj = _truthUtils.GetParentTrajectory(parentTraj->ID);
2358 if(grandparentTraj!=NULL){
2364 if (parentTraj==NULL)
return;
2365 if (truePart->
PDG == ParticleId::kPhotonPDG and
2366 truePart->
ParentPDG == ParticleId::kPi0PDG and
2368 parentTraj->ParentID == 0 and
2369 parentTraj->TraceSubdetectors[0] < 3){
2374 std::cout<<
"oaAnalysisTreeConverter::FillTrueParticleInfo() truePart with ID:"<<setw(6)<<truePart->
ID 2375 <<
" and ParentID:"<<setw(6)<<parentTraj->ID
2376 <<
" is a true subdet:"<<parentTraj->TraceSubdetectors[0]<<
" pi0 decay photon"<<std::endl;
2385 if (not static_cast<AnaTrueParticle*>(*it)->IsTruePrimaryPi0DecayPhoton)
2389 if (truePart->
ParentID == (*it)->ID or
2392 truePart->IsTruePrimaryPi0DecayPhotonChild =
true;
2395 std::cout<<
"oaAnalysisTreeConverter::FillTrueParticleInfo() truePart with ID:"<<setw(6)<<truePart->
ID 2396 <<
" and ParentID:"<<setw(6)<<parentTraj->ID
2397 <<
" is a true subdet:"<<parentTraj->TraceSubdetectors[0]<<
" pi0 decay photon child"<<std::endl;
2408 void oaAnalysisTreeConverter::FillTrueInfo(
AnaSpill* spill){
2411 _containedTrueParticles.clear();
2413 if (!spill->
GetIsMC())
return;
2416 for (
int i = 0; i < NTruthTrajs; i++) {
2419 std::cout <<
"INFO: event " << EventID <<
" has " << NTruthTrajs <<
" true trajectories (too many), ";
2420 std::cout <<
"only the first " << NMAXTRUEPARTICLES <<
" will be stored (=> some warnings might appear)" << std::endl;
2424 ND::TTruthTrajectoriesModule::TTruthTrajectory* traj = (ND::TTruthTrajectoriesModule::TTruthTrajectory*) (*TruthTrajs)[i];
2432 FillTrueParticleInfo(traj, trueParticle, spill);
2433 if (trueParticle->
PDG == 0) {
2434 delete trueParticle;
2437 int InitSubdetector = (traj->TraceSubdetectors.empty()) ? -1 : traj->TraceSubdetectors.front();
2438 if (_ignoreDsECalContainedTrueObjects && InitSubdetector==3 && traj->TraceSubdetectors.size()==1) _containedTrueParticles.push_back(trueParticle);
2439 if (_ignoreBrECalContainedTrueObjects && InitSubdetector==4 && traj->TraceSubdetectors.size()==1) _containedTrueParticles.push_back(trueParticle);
2440 if (_ignoreP0DECalContainedTrueObjects && InitSubdetector==5 && traj->TraceSubdetectors.size()==1) _containedTrueParticles.push_back(trueParticle);
2441 if (_ignoreSMRDContainedTrueObjects && InitSubdetector==9 && traj->TraceSubdetectors.size()==1) _containedTrueParticles.push_back(trueParticle);
2442 if (_ignoreINGRIDContainedTrueObjects && InitSubdetector==10 && traj->TraceSubdetectors.size()==1) _containedTrueParticles.push_back(trueParticle);
2449 if (Neut && NNVtx != NTruthVertices)
2450 std::cout<<
"ERROR: NNVtx (in TTruthVerticesModule) = " << NNVtx
2451 <<
" vs NTruthVertices (in rooTrackerVtx) = " << NTruthVertices
2452 <<
" in EventID " << EventID << std::endl;
2453 if (Genie && NGVtx != NTruthVertices)
2454 std::cout<<
"ERROR: NGVtx (in TTruthVerticesModule) = " << NGVtx
2455 <<
" vs NTruthVertices (in rooTrackerVtx) " << NTruthVertices
2456 <<
" in EventID " << EventID << std::endl;
2459 _foundPauliBlocked =
false;
2460 _foundCohOnH =
false;
2461 std::vector<AnaTrueVertexB*>& vertices = spill->
TrueVertices;
2462 ND::TTruthVerticesModule::TTruthVertex *true_vertex = NULL;
2463 for(
int v = 0; v < NTruthVertices; v++){
2465 if(vertices.size() == NMAXTRUEVERTICES) {
2466 std::cout <<
"INFO: event " << EventID <<
" has " << NTruthVertices <<
" true vertices (too many), ";
2467 std::cout <<
"only the first " << NMAXTRUEVERTICES <<
" will be stored (=> some warnings might appear)" << std::endl;
2472 true_vertex = (ND::TTruthVerticesModule::TTruthVertex*) TruthVertices->UncheckedAt(v);
2474 if( ! true_vertex)
continue;
2479 bool goodVtx = FillTrueVertexInfo(true_vertex, vertex, v, spill);
2484 vertices.push_back(vertex);
2493 bool oaAnalysisTreeConverter::FillTrueVertexInfo(ND::TTruthVerticesModule::TTruthVertex* true_vertex,
AnaTrueVertex* vertex,
int v,
AnaSpill* spill) {
2496 vertex->
RooVtxEntry = _RooVtxEntryInCurrentInputFile;
2498 if((true_vertex->ReactionCode).find(
":") != std::string::npos) {
2500 vertex->
ReacCode = GetGenieReactionCode(true_vertex->ReactionCode);
2503 vertex->
ReacCode = atoi((true_vertex->ReactionCode).c_str());
2506 vertex->
ID = true_vertex->ID;
2513 vertex->
NuPDG = true_vertex->NeutrinoPDG;
2514 vertex->
NuEnergy = true_vertex->NeutrinoMomentum.E();
2519 bool goodRooVtx = anaUtils::FillTrueVertexRooInfo(vertex,RunID,Neut,Genie,NNVtx,NVtx,NGVtx,GVtx,_foundCohOnH,_foundPauliBlocked);
2520 if ( ! goodRooVtx)
return false;
2522 vertex->
TargetMom = true_vertex->TargetMomentum.Vect().Mag();
2523 vertex->
TargetPDG = true_vertex->TargetPDG;
2524 anaUtils::VectorToArray(true_vertex->Position, vertex->
Position);
2525 vertex->
Bunch = _bunching.GetBunch(true_vertex->Position.T() + _trueBunchShift, spill->
EventInfo->
Run, IsMC, cosmic_mode);
2530 if(true_vertex->NeutrinoMomentum.Vect().Mag() > 0)
2531 anaUtils::VectorToArray((1/true_vertex->NeutrinoMomentum.Vect().Mag())*true_vertex->NeutrinoMomentum.Vect(),vertex->
NuDir);
2533 if(true_vertex->TargetMomentum.Vect().Mag() > 0)
2534 anaUtils::VectorToArray((1/true_vertex->TargetMomentum.Vect().Mag())*true_vertex->TargetMomentum.Vect(),vertex->
TargetDir);
2539 if (fabs(vertex->
NuEnergy - true_vertex->NeutrinoMomentum[3] > 0.001))
2540 std::cout <<
"Error: the neutrino energy differs between TruthTrajectoryModule and RooTrackerVtx!!! ID " << true_vertex->ID << std::endl;
2542 std::stringstream ssRun; ssRun << RunID;
2543 bool issand = ((ssRun.str())[4]==
'7');
2547 for (
int i = 0; i < true_vertex->NPrimaryTraj; i++) {
2548 ND::TTruthTrajectoriesModule::TTruthTrajectory* truthTraj = _truthUtils.GetTrajectoryById(true_vertex->PrimaryTrajIDs[i]);
2549 if (truthTraj == NULL)
continue;
2552 if ( (vertex->
NuPDG == 14 && truthTraj->PDG == 13) ||
2553 (vertex->
NuPDG == 12 && truthTraj->PDG == 11) ||
2554 (vertex->
NuPDG == -14 && truthTraj->PDG == -13) ||
2555 (vertex->
NuPDG == -12 && truthTraj->PDG == -11) ) {
2561 if ( ! Neut && ! Genie) {
2563 vertex->
Q2 = - (truthTraj->InitMomentum - true_vertex->NeutrinoMomentum).Mag2();
2564 vertex->
LeptonMom = truthTraj->InitMomentum.Vect().Mag();
2566 anaUtils::VectorToArray((1 / vertex->
LeptonMom) * truthTraj->InitMomentum.Vect(), vertex->
LeptonDir);
2571 else if (truthTraj->InitMomentum.Vect().Mag() > 0) {
2573 if (fabs(vertex->
LeptonMom - truthTraj->InitMomentum.Vect().Mag()) > 0.005) {
2575 std::cout <<
"INFO: LeptonMom differs between TruthTrajectoryModule and RooTrackerVtx: there is a lepton pair produced by FSI and probably the lepton coming from the neutrino is not saved in TruthTrajectoryModule because it didn't have G4 points (we use RooTrackerVtx info anyway): Nmuon " << vertex->
NPrimaryParticles[ParticleId::kMuon] <<
", Nantimuon " << vertex->
NPrimaryParticles[ParticleId::kAntiMuon] <<
", NuPDG " << vertex->
NuPDG << std::endl;
2578 std::cout <<
"ERROR: LeptonMom is -999 (something wrong in RooTrackerVtx ?), setting it from TruthTrajectoryModule (" << truthTraj->InitMomentum.Vect().Mag() <<
"), for vertex ID " << true_vertex->ID << std::endl;
2579 vertex->
LeptonMom = truthTraj->InitMomentum.Vect().Mag();
2581 vertex->
Q2 = - (truthTraj->InitMomentum - true_vertex->NeutrinoMomentum).Mag2();
2582 vertex->
LeptonMom = truthTraj->InitMomentum.Vect().Mag();
2584 anaUtils::VectorToArray((1 / vertex->
LeptonMom) * truthTraj->InitMomentum.Vect(), vertex->
LeptonDir);
2587 std::cout <<
"ERROR: LeptonMom differs between RooTrackerVtx and TruthTrajectoryModule! " << vertex->
LeptonMom <<
" - " << truthTraj->InitMomentum.Vect().Mag() <<
" = " << vertex->
LeptonMom - truthTraj->InitMomentum.Vect().Mag() <<
", for vertex ID " << true_vertex->ID << std::endl;
2604 else if ( ! Neut && ! Genie && truthTraj->PDG == 2212 && truthTraj->ParentID == 0) {
2607 vertex->
ProtonMom = truthTraj->InitMomentum.Vect().Mag();
2609 anaUtils::VectorToArray((1. / vertex->
ProtonMom) * truthTraj->InitMomentum.Vect(), vertex->
ProtonDir);
2614 else if ( ! Neut && ! Genie && truthTraj->PDG == 211 && truthTraj->ParentID == 0) {
2616 if (vertex->
PionMom < truthTraj->InitMomentum.Vect().Mag()) {
2617 vertex->
PionMom = truthTraj->InitMomentum.Vect().Mag();
2619 anaUtils::VectorToArray((1. / vertex->
PionMom) * truthTraj->InitMomentum.Vect(), vertex->
PionDir);
2629 std::cout <<
"INFO: true lepton not found in TruthTrajectoryModule (probably no G4 points, but we use RooTrackerVtx info), ";
2630 std::cout <<
"ReacCode " << vertex->
ReacCode <<
", in FV FGD" << true_vertex->Subdetector+1 <<
", NuPDG " << vertex->
NuPDG <<
"" << std::endl;
2638 anaUtils::CreateArray(vertex->
TrueParticles, NMAXTRUEPARTICLES);
2639 for (
unsigned int jj=0; jj<spill->
TrueParticles.size(); jj++) {
2641 if((
unsigned int)vertex->
nTrueParticles==NMAXTRUEPARTICLES)
break;
2644 if (particle->
VertexID == true_vertex->ID) {
2648 particle->
VertexID = true_vertex->ID;
2665 if (_removeTrueVerticesWithNoTrueParticles && vertex->
nTrueParticles==0){
2673 double oaAnalysisTreeConverter::GetVertexTime(ND::TGlobalReconModule::TGlobalPID& globalTrack){
2676 return globalTrack.FrontPosition.T();
2680 void oaAnalysisTreeConverter::GetBunchPIDs(){
2683 for (
unsigned int i=0;i<NBUNCHES+1;i++)
2684 _bunchPIDs[i].clear();
2686 for(
int j=0; j<NPIDs; j++) {
2688 ND::TGlobalReconModule::TGlobalPID *globalTrack = (ND::TGlobalReconModule::TGlobalPID*)PIDs->UncheckedAt(j);
2689 if(!globalTrack) std::cout <<
"debug error 1100 in oaAnalysisConverter" << std::endl;
2690 if(!globalTrack)
continue;
2696 double tTrack = GetVertexTime(*globalTrack);
2697 int ibunch = _bunching.GetBunch(tTrack,RunID,IsMC, cosmic_mode);
2703 _bunchPIDs[ibunch].push_back(globalTrack);
2708 void oaAnalysisTreeConverter::GetBunchLocalObjects(){
2712 for (
unsigned int i=0;i<NBUNCHES+1;i++){
2713 _bunchTECALObjects[i].clear();
2714 _bunchTECALUnmatchedObjects[i].clear();
2715 _bunchP0DVertices[i].clear();
2716 _bunchP0DParticles[i].clear();
2717 _bunchP0DClusters[i].clear();
2720 if(_isUsingReconDirTECAL) {
2723 for (
int iTECAL=0; iTECAL<NTrECalUnmatched; ++iTECAL){
2724 ND::TTrackerECALReconModule::TECALReconUnmatchedObject *tecalObj = (ND::TTrackerECALReconModule::TECALReconUnmatchedObject*) (*TrECalUnmatched)[iTECAL];
2727 Int_t ibunch = _bunching.GetBunch(tecalObj->AverageHitTime, RunID, IsMC, cosmic_mode);
2733 _bunchTECALUnmatchedObjects[ibunch].push_back(tecalObj);
2738 for (
int iTECAL=0; iTECAL<NTrECalObjects; ++iTECAL){
2739 ND::TTrackerECALReconModule::TECALReconObject *tecalObj = (ND::TTrackerECALReconModule::TECALReconObject*) (*TrECalObjects)[iTECAL];
2741 Int_t ibunch = _bunching.GetBunch(tecalObj->AverageHitTime, RunID, IsMC, cosmic_mode);
2747 _bunchTECALObjects[ibunch].push_back(tecalObj);
2752 if(_isUsingReconDirP0D) {
2755 _P0DReconVerticesMap.clear();
2756 _P0DReconParticlesMap.clear();
2757 _P0DReconClustersMap.clear();
2760 for (
int iP0D=0; iP0D<NP0DReconVertices; ++iP0D){
2761 ND::TP0DReconModule::TP0DVertex *p0dVertex = (ND::TP0DReconModule::TP0DVertex*) (*P0DReconVertices)[iP0D];
2763 Int_t ibunch = _bunching.GetBunch(p0dVertex->Position.T(), RunID, IsMC, cosmic_mode);
2768 _bunchP0DVertices[ibunch].push_back(p0dVertex);
2772 _P0DReconVerticesMap[p0dVertex] = anaP0DRecon;
2777 for (Int_t iP0D=0; iP0D<NP0DReconParticles; ++iP0D){
2778 ND::TP0DReconModule::TP0DParticle *p0dParticle = (ND::TP0DReconModule::TP0DParticle*) (*P0DReconParticles)[iP0D];
2781 Int_t ibunch = _bunching.GetBunch(p0dParticle->Position.T(), RunID, IsMC, cosmic_mode);
2787 _bunchP0DParticles[ibunch].push_back(p0dParticle);
2791 _P0DReconParticlesMap[p0dParticle] = anaP0DRecon;
2796 for (Int_t iP0D=0; iP0D<NP0DReconClusters; ++iP0D){
2797 ND::TP0DReconModule::TP0DCluster *p0dCluster = (ND::TP0DReconModule::TP0DCluster*) (*P0DReconClusters)[iP0D];
2800 Int_t ibunch = _bunching.GetBunch(p0dCluster->Position.T(), RunID, IsMC, cosmic_mode);
2806 _bunchP0DClusters[ibunch].push_back(p0dCluster);
2810 _P0DReconClustersMap[p0dCluster] = anaP0DRecon;
2815 if(_isUsingReconDirP0DNew) {
2816 GetBunchLocalP0DObjects();
2822 int oaAnalysisTreeConverter::GetGenieReactionCode(
const std::string& reactionCode){
2828 if(reactionCode.find(
"charm") == string::npos && reactionCode.find(
"Weak[CC],QES") != string::npos){
2831 else if(reactionCode.find(
"Weak[CC],RES") != string::npos){
2834 else if(reactionCode.find(
"charm") == string::npos && reactionCode.find(
"Weak[CC],DIS") != string::npos){
2837 else if(reactionCode.find(
"Weak[CC],COH") != string::npos){
2840 else if(reactionCode.find(
"Weak[NC],RES") != string::npos){
2843 else if(reactionCode.find(
"Weak[NC],QES") != string::npos){
2846 else if(reactionCode.find(
"Weak[NC],COH") != string::npos){
2849 else if(reactionCode.find(
"Weak[NC],DIS") != string::npos){
2857 void oaAnalysisTreeConverter::GetBunchVertices(){
2860 for (
unsigned int i=0;i<NBUNCHES+1;i++) _bunchVertices[i].clear();
2862 for(
int j=0; j<NVertices; j++) {
2863 ND::TGlobalReconModule::TGlobalVertex *globalVertex = (ND::TGlobalReconModule::TGlobalVertex*)Vertices->UncheckedAt(j);
2864 if(!globalVertex) std::cout <<
"debug error 1101 in oaAnalysisConverter" << std::endl;
2865 if(!globalVertex)
continue;
2871 double tVertex = (*globalVertex).Position.T();
2872 int ibunch = _bunching.GetBunch(tVertex,RunID,IsMC, cosmic_mode);
2878 _bunchVertices[ibunch].push_back(globalVertex);
2883 void oaAnalysisTreeConverter::FillVertexInfo(ND::TGlobalReconModule::TGlobalVertex& globalVertex,
AnaVertex* vertex,
AnaBunch* bunch,
AnaSpill* spill) {
2887 anaUtils::VectorToArray(globalVertex.Position,vertex->
Position);
2889 anaUtils::VectorToArray(globalVertex.Variance,vertex->
Variance);
2890 vertex->
Chi2 = globalVertex.Quality;
2891 vertex->
NDOF = globalVertex.NDOF;
2895 vertex->nParticles = 0;
2896 anaUtils::CreateArray(vertex->
Particles, globalVertex.NConstituents);
2897 for (
int i=0; i<globalVertex.NConstituents; i++) {
2898 ND::TGlobalReconModule::TVertexConstituent* vConst = (ND::TGlobalReconModule::TVertexConstituent*)(*(globalVertex.Constituents))[i];
2902 std::cout <<
"WARNING: a reconstructed global vertex (position " 2903 << globalVertex.Position.X() <<
"," << globalVertex.Position.Y() <<
"," << globalVertex.Position.Z() <<
")" 2904 <<
" is supposed to have an associated particle (PID = " << vConst->PID <<
") which cannot be found (see bug 1161)" << std::endl;
2905 if (vConst->PID<0)
continue;
2907 ND::TGlobalReconModule::TGlobalPID* globalTrack = (ND::TGlobalReconModule::TGlobalPID*)(*PIDs)[vConst->PID];
2910 AnaTrack* track = FindTrack(globalTrack->UniqueID, bunch, spill);
2913 vertex->
Particles[vertex->nParticles++] = track;
2934 for (
int i=0; i<globalVertex.NTrueVertices; i++) {
2935 ND::TTrueVertex* matchedTrueVertex = (ND::TTrueVertex*)((*(globalVertex.TrueVertices))[i]);
2936 FillTrueVerticesMatchInfo(matchedTrueVertex, vertex, bunch);
2952 std::vector<AnaParticleB*>::iterator ittrack;
2955 for (ittrack = bunch->
Particles.begin(); ittrack != bunch->
Particles.end(); ittrack++) {
2956 if (ID == (*ittrack)->UniqueID)
return static_cast<AnaTrack*
>(*ittrack);
2961 if (ID == (*ittrack)->UniqueID)
return static_cast<AnaTrack*
>(*ittrack);
2966 #if ! VERSION_HAS_TIME_FITS 2967 if (bunch->
Bunch != -1) {
2968 if ((
int)NPIDs > (int)NMAXPARTICLES) std::cout <<
"minor error: track to be associated to a global vertex not found (UniqueID " << ID <<
"), likely because this event has too many tracks (" << NPIDs <<
") and highland saves maximum " << NMAXPARTICLES <<
" tracks." << std::endl;
2969 else std::cout <<
"minor error in oaAnalysisConverter (ref 6056)" << std::endl;
2975 std::vector<AnaBunchC*>::iterator itbunch;
2976 for (itbunch = spill->
Bunches.begin(); itbunch != spill->
Bunches.end(); itbunch++) {
2978 for (ittrack = bunch0->
Particles.begin(); ittrack != bunch0->
Particles.end(); ittrack++) {
2979 if (ID == (*ittrack)->UniqueID) {
2980 if (bunch->
Bunch != -1) {
2981 int bunchStart = _bunching.GetBunch((*ittrack)->PositionStart[3],RunID,IsMC, cosmic_mode);
2982 int bunchEnd = _bunching.GetBunch((*ittrack)->PositionEnd[3],RunID,IsMC, cosmic_mode);
2983 std::cout <<
"INFO: this global vertex (in bunch " << bunch->
Bunch <<
") has an associated track stored in another bunch, which starts in bunch " << bunchStart <<
" and ends in bunch " << bunchEnd << std::endl;
2985 return static_cast<AnaTrack*
>(*ittrack);
2990 if ((
int)NPIDs > (
int)NMAXPARTICLES) std::cout <<
"minor error: track to be associated to a global vertex not found (UniqueID " << ID <<
"), likely because this event has too many tracks (" << NPIDs <<
") and highland saves maximum " << NMAXPARTICLES <<
" tracks." << std::endl;
2991 else std::cout <<
"minor error: track to be associated to a global vertex not found in bunch " << bunch->
Bunch <<
": in prod6 it should be a flipped track with start position in a bunch not yet loaded!" << std::endl;
2997 void oaAnalysisTreeConverter::FillTrueVerticesMatchInfo(ND::TTrueVertex* matchedTrueVertex,
AnaVertex* vertex,
AnaBunch* bunch){
3004 std::vector<AnaTrueVertexB*>::iterator it;
3006 if (matchedTrueVertex->ID != (*it)->ID)
continue;
3013 AnaRecTrueMatch* thisRecTrueMatch = FillCompletenessCleanliness(vertex, bunch, *it);
3016 pair<AnaTrueVertexB*, AnaRecTrueMatch> myPair(tvertex, *thisRecTrueMatch);
3022 std::cout <<
"minor error: matchedTrueVertex not found, ID:" << matchedTrueVertex->ID << std::endl;
3034 std::vector<AnaTrackB*> trueVconst;
3035 std::set<AnaTrueObjectC*> trueVconst_true;
3039 for (
int i = 0; i < ntracks; i++) {
3045 if (track->
NNodes > 0) ;
else continue;
3046 if (track->
Status != 1)
continue;
3054 int nTrueVconst = (int)trueVconst.size();
3055 int nTrueVconst_true = (int)trueVconst_true.size();
3056 int nRecoVconst = 0;
3057 int nCommonConst = 0;
3058 int nRecoVconst_true = 0;
3059 int nCommonConst_true = 0;
3062 std::set<AnaTrueObjectC*> recoVconst_true;
3063 std::vector<AnaTrackB*>::iterator itrecoVconst;
3064 for (
int i = 0; i < vertex->nParticles; i++) {
3066 if ( ! itrecoVconst)
continue;
3068 if (itrecoVconst->
Bunch != bunch->
Bunch)
continue;
3073 std::vector<AnaTrackB*>::iterator ittrueVconst;
3074 for (ittrueVconst = trueVconst.begin(); ittrueVconst != trueVconst.end(); ittrueVconst++) {
3075 if (itrecoVconst->
UniqueID == (*ittrueVconst)->UniqueID) {
3087 double checkBroken=recoVconst_true.size();
3088 recoVconst_true.insert(itrecoVconst->
TrueObject);
3089 if (checkBroken == recoVconst_true.size())
continue;
3091 std::set<AnaTrueObjectC*>::iterator ittrueVconst_true;
3092 for (ittrueVconst_true = trueVconst_true.begin(); ittrueVconst_true != trueVconst_true.end(); ittrueVconst_true++) {
3093 if (itrecoVconst->
TrueObject->
ID == (*ittrueVconst_true)->ID) {
3094 nCommonConst_true++;
3100 nRecoVconst_true += (int)recoVconst_true.size();
3103 if (nRecoVconst==0) thisRecTrueMatch->
Cleanliness = 0;
3105 else thisRecTrueMatch->
Cleanliness = (double)nCommonConst_true/nRecoVconst_true;
3106 if (nTrueVconst==0) thisRecTrueMatch->
Completeness = 0;
3108 else thisRecTrueMatch->
Completeness = (double)nCommonConst_true/nTrueVconst_true;
3110 return thisRecTrueMatch;
3114 void oaAnalysisTreeConverter::DeleteBadObjects(
AnaSpill* spill){
3126 if ( ! _foundCohOnH && ! _foundPauliBlocked && _containedTrueParticles.size() == 0)
return;
3128 if ( ! _discardPauliBlocked && _foundPauliBlocked)
3129 std::cout <<
"There is a Pauli blocked vertices but their deletion is not enabled, why?!? (see bugzilla 1011)" << std::endl;
3130 if ( ! _discardCohOnH && _foundCohOnH)
3131 std::cout <<
"There is a coherent interaction on hydrogen but their deletion is not enabled, why?!? (see bugzilla 1056)" << std::endl;
3132 if ( ! _discardPauliBlocked && ! _discardCohOnH && _containedTrueParticles.size() == 0)
return;
3135 std::vector<AnaTrueVertexB*>::iterator truevertexB;
3140 if ( ! IsFullyContained(*truevertex)){
3141 if ( ( ! truevertex->IsCohOnH && ! truevertex->
IsPauliBlocked) ||
3143 (truevertex->IsCohOnH && ! _discardCohOnH) ) {
3152 std::vector<AnaVertexB*>::iterator vertexB;
3155 for (
int i=0; i < (*vertexB)->nParticles; i++) {
3157 if (!track)
continue;
3158 if ( ! track) std::cout << std::endl <<
"ERROR: this track has to exist otherwise something is wrong somewhere else!" 3159 <<
" The process will now crash (see bug 1172)." << std::endl << std::endl;
3162 int size_orig = (int)track->
ReconVertices.size(); (void)size_orig;
3163 std::vector<AnaVertexB*>::iterator vertexB2;
3165 if (*vertexB2 == *vertexB) {
3184 size_orig = (int)anothertrueV->
ReconVertices.size(); (void)size_orig;
3186 if (*vertexB2 == *vertexB) {
3197 DeleteRecoVertex(spill,*vertexB);
3202 std::vector<AnaParticleB*>::iterator part;
3204 DeleteRecoParticle(spill,*part);
3211 DeleteTrueParticle(spill,truePartB);
3215 if ((*truevertexB)->Bunch != -1) {
3217 std::vector<AnaBunchC*>::iterator bunchC;
3218 for (bunchC = spill->
Bunches.begin(); bunchC != spill->
Bunches.end();) {
3221 if ((*bunchC)->Bunch != (*truevertexB)->Bunch) {
3228 int size_orig = (int)spill->
Bunches.size(); (void)size_orig;
3230 bunchC = spill->
Bunches.erase(bunchC);
3242 delete *truevertexB;
3258 std::vector<AnaBunchC*> outplusbunches;
3259 for (
int b = 0; b < (int)spill->
Bunches.size(); b++) {
3260 outplusbunches.push_back(spill->
Bunches[b]);
3266 for (
int b = 0; b < (int)outplusbunches.size(); b++) {
3270 int size_orig = (int)bunch->
Particles.size(); (void) size_orig;
3273 std::vector<AnaParticleB*>::iterator it;
3276 if (!track)
continue;
3281 std::cout <<
"INFO: found a TPCsegment associated to a trueTrack to be deleted (see bug 1011 and 1056) and to a reconTrack not to be deleted (which is associated to a different trueTrack)! Keep the segment but set to NULL the link to its trueTrack." << std::endl;
3290 std::cout <<
"INFO: found a P0Dsegment2 associated to a trueTrack to be deleted (see bug 1011 and 1056) and to a reconTrack not to be deleted (which is associated to a different trueTrack)! Keep the segment but set to NULL the link to its trueTrack." << std::endl;
3302 int size_orig = (int)spill->
TrueParticles.size(); (void)size_orig;
3305 std::vector<AnaTrueParticleB*>::iterator part;
3308 if (*part != trackToDelete) {
3321 if ( ! found) std::cout <<
"error in oaAnalysisTreeConverter::DeleteTrueParticle: track to delete not found!!!" << std::endl;
3326 void oaAnalysisTreeConverter::DeleteRecoParticle(
AnaSpill* spill,
AnaParticleB* particleToDelete){
3333 std::cout <<
"ERROR in DeleteRecoParticle (ref. 9884): particleToDelete->ReconVertices.size = " 3338 std::vector<AnaBunchC*> outplusbunches;
3339 for (
int b = 0; b < (int)spill->
Bunches.size(); b++) {
3340 outplusbunches.push_back(spill->
Bunches[b]);
3347 for (
int b = 0; b < (int)outplusbunches.size(); b++) {
3351 int size_orig = (int)bunch->
Particles.size(); (void) size_orig;
3354 std::vector<AnaParticleB*>::iterator part;
3357 if (*part != particleToDelete) {
3377 if ( ! found) std::cout <<
"error in oaAnalysisTreeConverter::DeleteRecoParticle: particle to delete not found!!!" << std::endl;
3382 void oaAnalysisTreeConverter::DeleteRecoVertex(
AnaSpill* spill,
AnaVertexB* vertexToDelete){
3386 std::vector<AnaBunchC*> outplusbunches;
3387 for (
int b = 0; b < (int)spill->
Bunches.size(); b++) {
3388 outplusbunches.push_back(spill->
Bunches[b]);
3395 for (
int b = 0; b < (int)outplusbunches.size(); b++) {
3399 int size_orig = (int)bunch->
Vertices.size(); (void) size_orig;
3402 std::vector<AnaVertexB*>::iterator vertexB;
3403 for (vertexB = bunch->
Vertices.begin(); vertexB != bunch->
Vertices.end();) {
3405 if (*vertexB != vertexToDelete) {
3412 vertexB = bunch->
Vertices.erase(vertexB);
3425 if ( ! found) std::cout <<
"error in oaAnalysisTreeConverter::DeleteRecoVertex: vertex to delete not found!!!" << std::endl;
3429 bool oaAnalysisTreeConverter::HasNonContainedReconParticles(
AnaTrueParticleB* trueParticleB){
3461 bool oaAnalysisTreeConverter::IsFullyContained(
const AnaTrueVertexB& trueVertex){
3466 bool contained=
true;
3471 for (
size_t j2=0;j2<_containedTrueParticles.size();j2++){
3472 if (trueVertex.
TrueParticles[j1] == _containedTrueParticles[j2] && !HasNonContainedReconParticles(_containedTrueParticles[j2])){
Float_t dEdxexpMuon
Expected dE/dx for a muon, based on the reconstructed momentum.
Float_t Pullmu
Muon pull of the segment: (dEdxMeas-dEdxexpMuon)/dEdxSigmaMuon.
Float_t Completeness
The completeness of the true-reco matching.
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 DirectionStartFlip[3]
Direction at the start for the main PID hypothesis and reverse sense.
int nP0DSegments
How many P0D tracks are associated with this track.
Float_t PositionStart[4]
The reconstructed start position of the particle.
Float_t MomentumAtVertex
The reconstructed momentum of the track, at the most primary global vertex (if exists).
Representation of a global track.
AnaTrueVertexB * TrueVertex
AnaP0DParticleB * P0DSegments[NMAXP0DS]
The P0D segments that contributed to this global track.
Int_t InputFileIndex
Index of the input file producing this spill.
Int_t NuPDG
The PDG code of the incoming neutrino.
Int_t LeptonPDG
The PDG code of the primary outgoing electron/muon.
int nDetCrossings
The number of DetCrossing objects.
int GetParameterI(std::string)
Get parameter. Value is returned as integer.
Float_t MomentumEle
Momentum from refitting the track assuming the electron hypothesis.
bool IsTruePrimaryPi0DecayPhoton
Is this a true primary pi0 decay photon or the child of one?
int nTrueParticles
How many true particles are associated with this vertex.
Int_t NDOF
The number of degrees of freedom of the fit using a Kalman filter.
Float_t ExitPosition[4]
for each subdetector tell the exit position
Float_t Cleanliness
The cleanliness of the true-reco matching.
void IncrementPOTBySpill()
bool FGDCosmic
FGD cosmic trigger flag.
Float_t dEdxexpProton
Expected dE/dx for a proton, based on the reconstructed momentum.
AnaECALParticleB * ECALSegments[NMAXECALS]
The ECAL segments that contributed to this global track.
int nECALSegments
How many ECAL tracks are associated with this track.
std::vector< std::pair< AnaTrueVertexB *, AnaRecTrueMatchB > > TrueVerticesMatch
The true vertices that are associated with this global vertex, with the related cleanliness and compl...
Int_t Status
The Status of the fit of this reconstructed object.
Float_t LeptonDir[3]
The direction of the primary outgoing electron/muon.
void SetIsSandMC()
Set whether this event is from Sand MC.
Representation of the ND280 trigger bits.
Int_t NDOF
The number of degrees of freedom when the track was fitted with a Kalman filter.
Float_t Pullp
Proton pull, according to FGD information.
AnaSMRDParticleB * SMRDSegments[NMAXSMRDS]
The SMRD segments that contributed to this global track.
Float_t Variance[4]
The variance values of the fit using a Kalman filter.
void ConvertLocalDetEnumToBitField(unsigned long &det, int index, SubDetId::SubDetEnum subdet_enum)
Convert the detector used array to the bit field used by psyche given a SubDetEnum.
Representation of a true Monte Carlo vertex.
Float_t DirectionEnd[3]
The reconstructed end direction of the particle.
Float_t E
Input to the pull calculations. Needs to be documented properly in oaAnalysis.
Float_t Position[4]
The identified position of the global vertex.
Float_t Pullpi
Pion pull of the segment: (dEdxMeas-dEdxexpPion)/dEdxSigmaPion.
std::vector< AnaTrueVertexB * > TrueVertices
The true MC vertices used in this spill.
std::vector< AnaBunchC * > Bunches
The reconstructed objects, split into timing bunches.
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.
virtual Int_t GetSpill(Long64_t &entry, AnaSpillC *&spill)
Float_t ProtonDir[3]
The direction of the primary outgoing protons listed first (likely the interacted one)...
Int_t GParentPDG
The PDG code of this particle's grandparent, or 0 if there is no grandparent.
Float_t TargetDir[3]
The direction of the target nucleus.
Float_t Pullpi
Pion pull, according to FGD information.
AnaTPCParticleB * TPCSegments[NMAXTPCS]
The TPC segments that contributed to this global track.
Representation of the ND280 data quality flags.
Float_t Vertex1x1
Vertex activity variables.
Float_t AvgTime
Time charged averaged over hits.
Int_t SpillsSincePreviousSavedSpill
Int_t Bunch
The bunch of the track, based on the PositionStart.T()
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.
Float_t Length
The number of hits in the reconstructed object.
AnaToF ToF
Times of flight between pairs of detectors.
Int_t GetCurrentGeomID() const
Retrieve current geometry ID.
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.
Float_t Momentum
The initial momentum of the true particle.
virtual bool AddFileToTChain(const std::string &inputString)
Add the file specified to fChain, and any friend chains that were set up.
AnaTrueParticleB ** TrueParticles
The true particles associated with this vertex.
This Ana* object is used to flatten TECALReconObjects from ReconDir/TrackerECal.
Float_t MomentumErrorProton
Error on momentum from refitting the track assuming the proton hypothesis.
Float_t AvgTime
Average Time for the iso FGD hits.
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()
Int_t TargetPDG
The PDG code of the target nucleus.
Float_t RangeMomentumMuon
Momentum by range calculated with muon hypothesis.
std::vector< AnaParticleB * > ReconParticles
Vector of pointers to AnaParticle's associated with this true particle.
Float_t Chi2
The chi2 value of the fit using a Kalman filter.
std::string GetParameterS(std::string)
Get parameter. Value is returned as string.
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 GetAllTracksUsingFGDorTPC(const AnaBunchB &bunch, AnaTrackB *selTracks[])
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...
Int_t SubRun
The subrun number.
std::vector< AnaVertexB * > Vertices
Int_t Spill
Spill number from BeamSummaryDataModule::ND280Spill.
Float_t Chi2
The chi2 value when the track was fitted using a Kalman filter.
int nSMRDSegments
How many SMRD tracks are associated with this track.
Representation of detector time info.
Float_t POTCT4
The POT from CT4 for this spill. This is only needed for P5 files.
Float_t MomentumError
Error of the momentum at the start of the segment.
Float_t ProtonMom
The momentum of the primary outgoing protons listed first (likely the interacted one).
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.
Float_t LeptonMom
The momentum of the primary outgoing electron/muon.
Float_t Momentum
The reconstructed momentum of the particle, at the start position.
Representation of a true Monte Carlo vertex.
int nTPCSegments
How many TPC tracks are associated with this track.
Representation of a true Monte Carlo trajectory/particle.
TVector3 UpstreamHits_Position[2]
Float_t NuEnergy
The true energy of the incoming neutrino.
virtual bool IsEmpty() const
Returns true if the bunch is completely empty.
UInt_t GeomID
Is this the original Spill or a clone.
Float_t Position[4]
The position the true interaction happened at.
Float_t dEdxSigmaKaon
Expected error on the dE/dx measurement, for the proton hypothesis.
Float_t dEdxSigmaEle
Expected error on the dE/dx measurement, for the electron hypothesis.
Float_t EntrancePosition[4]
for each subdetector tell the entrance position
AnaBeamB * Beam
The beam quality flags for this spill.
std::vector< AnaVertexB * > ReconVertices
Vector of pointers to AnaVertexB (global vertices) associated with this true vertex.
AnaDetCrossingB ** DetCrossings
Representation of a detector crossing info for a true particle (G4 trajectory).
SubDetEnum
Enumeration of all detector systems and subdetectors.
Float_t DirectionAtVertex[3]
The reconstructed direction of the track at the most primary global vertex (if exists).
Float_t EFieldRefitMomentum
Reconstructed momentum with the E-field distortion corrections.
Int_t PDG
The PDG code of this particle.
Int_t SpillNumber
Spill number from BeamSummaryDataModule::BeamSummaryData::SpillNumber.
Float_t MomentumErrorMuon
Error on momentum from refitting the track assuming the muon hypothesis.
Int_t NHits
The number of hits in the particle.
Int_t ParentPDG
The PDG code of this particle's immediate parent, or 0 if there is no parent.
bool GetIsMC() const
Return whether this spill is from Monte Carlo or not.
std::vector< AnaFgdTimeBinB * > FgdTimeBins
The FGD time bins.
Float_t MomentumErrorEle
Error on momentum from refitting the track assuming the electron hypothesis.
Float_t dEdxMeas
dE/dx as measured by the TPC.
Representation of a global track.
bool TripTCosmic
TripT cosmic trigger flag.
AnaTrueVertexB * GetMainTrueVertex(bool warning=true)
The main true vertex that is associated with this global vertex.
Float_t MomentumEnd
The reconstructed momentum of the particle, at the end position.
Int_t EventTime
The ND280 subrun number.
AnaParticleB ** Particles
Float_t ExitMomentum[3]
for each subdetector tell the exit momentum
UInt_t NTotalTrueVertices
Float_t Pullk
Kaon pull of the segment: (dEdxMeas-dEdxexpPion)/dEdxSigmaKaon.
std::vector< AnaTrackerTrackB * > TRACKERSegments
The TRACKER segments that contributed to this global track.
Float_t Pullp
Proton pull of the segment: (dEdxMeas-dEdxexpProton)/dEdxSigmaProton.
std::vector< AnaTrueParticleB * > TrueParticles
The true MC particles used in this spill.
Representation of a global vertex.
AnaVertexB * ReconVertex
The pointer to the most primary AnaVertexB (global vertex) associated with this track.
Double_t POTSincePreviousSavedSpill
bool InDetVolume(SubDetId::SubDetEnum det, const Float_t *pos)
Float_t Length
The length of the ECal segment.
Int_t RooVtxEntry
Not in the MiniTree for the Moment since it produces a seg fault.
Float_t Length
The length of this global track.
Float_t MomentumError
The error on the reconstructed momentum.
Float_t DirectionStart[3]
The reconstructed start direction of the particle.
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).
std::vector< AnaVertexB * > ReconVertices
Vector of pointers to AnaVertexB (global vertices) associated with this track.
void ConvertTrackerDetFieldToBitField(unsigned long &det, int Detectors)
Convert tracker detector field to bit field.
This Ana* object is used to flatten TECALUnmatchedObjects from ReconDir/TrackerECal.
virtual bool Initialize()
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.
Float_t Pullele
Electron pull of the segment: (dEdxMeas-dEdxexpEle)/dEdxSigmaEle.
int nFGDSegments
How many FGD tracks are associated with this track.
Float_t PionDir[3]
The direction of the primary outgoing pions listed first (likely the interacted one).
Float_t Q2
The Q2 of the true interaction.
AnaTrigger Trigger
Not in the MiniTree for the Moment since it produces a seg fault.
Float_t dEdxSigmaMuon
Expected error on the dE/dx measurement, for the muon hypothesis.
Int_t RooVtxEntry
Entry in the RooTrackerVtx tree (not set directly)
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 Purity
The purity with which this particle was matched to a reconstructed object.
Float_t Position[4]
The initial position of the true particle.
Int_t Containment
Containment flag required for proper PID analysis.
std::vector< AnaParticleB * > Particles
Int_t MostUpStreamLayerHit
Innermost layer hit of the ecal object (used in ecal pi0 veto)
Representation of a TPC segment of a global track.
Float_t TimeStart
Start time.
void ConvertTrackDetEnumToBitField(unsigned long &det, int DetUsed[])
Convert the detector used array to the bit field used by psyche for ana tracks.
Float_t NuDir[3]
The true (unit) direction of the incoming neutrino.
Float_t dEdxSigmaPion
Expected error on the dE/dx measurement, for the pion hypothesis.
AnaTrueParticleB * GetTrueParticle() const
Return a casted version of the AnaTrueObject associated.
Float_t Charge
The true charge of the particle.
bool InFiducialVolume(SubDetId::SubDetEnum det, const Float_t *pos, const Float_t *FVdefmin, const Float_t *FVdefmax)
Representation of a reconstructed particle (track or shower).
AnaDataQualityB * DataQuality
The ND280 data quality flags for this spill.
Int_t ReconPDG
PDG of the most probable particle hypothesis used at reconstruction level.
bool IsMC
Says if the event is MC or data.
Float_t Direction[3]
The initial direction of the true particle.
static bool ComparePrimaryIndex(const AnaVertexB *t1, const AnaVertexB *t2)
Function used to sort PrimaryIndex in increasing order.
UInt_t NTotalTrueParticles
Representation of a true Monte Carlo trajectory/particle.
Float_t MomentumMuon
Momentum from refitting the track assuming the muon hypothesis.
bool TrackUsesOnlyDet(const AnaTrackB &track, SubDetId::SubDetEnum det)
Representation of the beam information, including POT and quality.
AnaFGDParticleB * FGDSegments[NMAXFGDS]
The FGD segments that contributed to this global track.
Float_t POT
The POT for this spill. For data, this comes from the Beam Summary Data.
Float_t dEdxexpKaon
Expected dE/dx for a proton, based on the reconstructed momentum.
Float_t EntranceMomentum[3]
for each subdetector tell the entrance momentum
Float_t TargetMom
The momentum of the target nucleus.
Float_t PionMom
The momentum of the primary outgoing pions listed first (likely the interacted one).
Int_t NPrimaryParticles[Int_t(ParticleId::kLast)+1]
Array to count the outgoing primary particles of each type (.
std::vector< AnaParticleB * > ReconParticles
Float_t PositionEnd[4]
The reconstructed end position of the particle.
Float_t RefitMomentum
Reconstructed momentum with the empirical distortion corrections.
Float_t MomentumProton
Momentum from refitting the track assuming the proton hypothesis.
bool LoadGeometry(const std::string &file="", Int_t geomID=-1, const std::string &geomDir="")
Load the TGeoManager from the input root file. Returns true when the new geometry was loaded...
Int_t Run
The ND280 run number.