HighLAND
baseP0DAnalysis.cxx
1 #include "baseP0DAnalysis.hxx"
2 
3 //********************************************************************
5 //********************************************************************
6 
7  // Add the package version
8  ND::versioning().AddPackage("baseP0DAnalysis", anaUtils::GetSoftwareVersionFromPath((std::string)getenv("BASEP0DANALYSISROOT")));
9 }
10 
11 //********************************************************************
12 void baseP0DAnalysis::DefineSystematics(){
13 //********************************************************************
14 
15  baseAnalysis::DefineSystematics();
16 }
17 
18 //********************************************************************
19 void baseP0DAnalysis::DefineCorrections(){
20 //********************************************************************
21 
22  baseAnalysis::DefineCorrections();
23 }
24 
25 //********************************************************************
26 void baseP0DAnalysis::DefineConfigurations(){
27 //********************************************************************
28 
29  baseAnalysis::DefineConfigurations();
30 }
31 
32 //********************************************************************
33 void baseP0DAnalysis::DefineMicroTrees(bool addBase){
34 //********************************************************************
35 
36  if (addBase) baseAnalysis::DefineMicroTrees(addBase);
37 
38  // -------- Add variables to the analysis tree ----------------------
39 
40  AddVarI(output(), np0dtracks, "number of tracks containing P0D segment");
41  AddVarI(output(), np0donlytracks, "number of tracks with only P0D");
42 
43  int isUsingReconDirP0D = ND::params().GetParameterI("highlandIO.FlatTree.UseReconDirP0D");
44 
45  if (isUsingReconDirP0D){
46  AddVarI(output(), np0dreconvertices, "number of P0DRecon vertices in bunch");
47  AddVarI(output(), np0drecontracks, "number of P0DRecon tracks in bunch");
48  AddVarI(output(), np0dreconclusters, "number of P0DRecon clusters in bunch");
49  }
50 }
51 
52 //********************************************************************
53 void baseP0DAnalysis::DefineTruthTree(){
54 //********************************************************************
55 
56  baseAnalysis::DefineTruthTree();
57 }
58 
59 //********************************************************************
60 void baseP0DAnalysis::FillMicroTrees(bool addBase){
61 //********************************************************************
62 
63  if (addBase) baseAnalysis::FillMicroTreesBase(addBase);
64 
65  // Track counters
66  AnaTrackB* dummy[NMAXPARTICLES];
67  int nP0D = anaUtils::GetAllTracksUsingDet(GetBunch(), SubDetId::kP0D, dummy);
68  int nP0DOnly = anaUtils::GetAllTracksUsingOnlyDet(GetBunch(), SubDetId::kP0D, dummy);
69 
70 
71  output().FillVar(np0dtracks, nP0D);
72  output().FillVar(np0donlytracks,nP0DOnly);
73 
74 
75  //Local Recon counters
76 
77  //P0D local recon parameter must be enabled in highlandIO
78 
79  int isUsingReconDirP0D = ND::params().GetParameterI("highlandIO.FlatTree.UseReconDirP0D");
80 
81 
82  if (isUsingReconDirP0D == 1){
83 
84  AnaSpill* spill = static_cast<AnaSpill*>(&(input().GetSpill()));
85 
86  AnaLocalReconBunch* localBunch = NULL;
87 
88  int nP0DReconTracks = -1;
89  int nP0DReconClusters = -1;
90  int nP0DReconVertices = -1;
91 
92  // Loop over all bunches
93  for (unsigned int iBunch=0; iBunch<spill->Bunches.size(); iBunch++){
94 
95  // Cast this bunch to the local variety
96  localBunch = dynamic_cast<AnaLocalReconBunch*>(spill->Bunches[iBunch]);
97 
98  // Pointer will be NULL if dynamic_cast fails
99  if(localBunch){
100  nP0DReconTracks = localBunch->P0DReconParticles.size();
101  nP0DReconClusters = localBunch->P0DReconClusters.size();
102  nP0DReconVertices = localBunch->P0DReconVertices.size();
103 
104  }
105  else {
106  std::cerr<<"Invalid local bunch, did you enable UseReconDirP0D = 1 in highlandIO.parameters.dat?\n";
107  }
108 
109  } // End of loop over Bunches
110 
111  output().FillVar(np0drecontracks, nP0DReconTracks);
112  output().FillVar(np0dreconvertices, nP0DReconVertices);
113  output().FillVar(np0dreconclusters, nP0DReconClusters);
114  } // End of local recon
115 
116 
117 }
118 
119 //********************************************************************
120 void baseP0DAnalysis::FillToyVarsInMicroTrees(bool addBase){
121 //********************************************************************
122 
123  if (addBase) baseAnalysis::FillToyVarsInMicroTreesBase(addBase);
124 }
125 
126 //********************************************************************
127 void baseP0DAnalysis::FillTruthTreeBase(const AnaTrueVertex& vtx, const SubDetId::SubDetEnum det, bool IsAntinu){
128 //********************************************************************
129 
130  // Fill the common variables
131  baseAnalysis::FillTruthTreeBase(vtx, det, IsAntinu);
132 }
int GetAllTracksUsingOnlyDet(const AnaBunchB &bunch, SubDetId::SubDetEnum det, AnaTrackB *selTracks[])
int GetParameterI(std::string)
Get parameter. Value is returned as integer.
Definition: Parameters.cxx:217
AnaP0DBunch & GetBunch()
Get a casted AnaBunchBB to AnaBunch from the InputManager.
void AddPackage(const std::string &name, const std::string &version)
Add a package.
std::vector< AnaBunchC * > Bunches
The reconstructed objects, split into timing bunches.
std::string GetSoftwareVersionFromPath(const std::string &path)
Get The software version from the path of the package.
Representation of a true Monte Carlo vertex.
Definition: DataClasses.hxx:50
SubDetEnum
Enumeration of all detector systems and subdetectors.
Definition: SubDetId.hxx:25
AnaSpillC & GetSpill()
Get the current spill (to have corrections and systematics applied to it).
Representation of a global track.
void FillVar(Int_t index, Float_t var)
Fill a single variable.
baseP0DAnalysis(AnalysisAlgorithm *ana=NULL)
int GetAllTracksUsingDet(const AnaBunchB &bunch, SubDetId::SubDetEnum det, AnaTrackB *selTracks[])