4 #include "TG4PrimaryParticle.hxx"
5 #include "TG4PrimaryVertex.hxx"
7 #include "TGeomInfo.hxx"
9 #include "TND280Log.hxx"
10 #include "TOADatabase.hxx"
11 #include "TP0DGeom.hxx"
15 fVtx =
new TClonesArray(
"ND::GRooTrackerVtx", 100);
19 fDescription =
"Genie specific module which fills mc-truth vertex info";
27 std::string name2compare(name);
28 bool is_genie1 = (name2compare.find(
"genie") != name2compare.npos);
29 bool is_genie2 = (name2compare.find(
"gRooTracker") != name2compare.npos);
30 bool is_genie = (is_genie1 || is_genie2);
31 ND280Debug(
"Returning is generator = " << is_genie
32 <<
" for generator name = " << name);
37 if (fCurrGenieVtx == NULL) {
38 ND280Debug(
"Could not compare pass-through to G4 primary vertex as"
39 <<
" there is no passed through vertex to compare to!");
45 (fCurrGenieVtx->EvtCode->GetString().CompareTo(vtx.GetReaction()) == 0);
46 ND280Debug(
"Comparing " << fCurrGenieVtx->EvtCode->GetString().Data()
47 <<
" and " << vtx.GetReaction());
49 double smallnum = 0.000001;
51 (std::abs(fCurrGenieVtx->EvtVtx[0] - vtx.GetPosition().X()) < smallnum) &&
52 (std::abs(fCurrGenieVtx->EvtVtx[1] - vtx.GetPosition().Y()) < smallnum) &&
53 (std::abs(fCurrGenieVtx->EvtVtx[2] - vtx.GetPosition().Z()) < smallnum);
54 ND280Debug(
"Pass through vertex position check bool passed = " << position);
57 if (position && evtcode) {
58 ND280Debug(
"Passed through vertex passed mismatch test!");
62 ND280Error(
"SEVERE ERROR! Mismatch between G4Vertex and pass-through info!");
67 if (vtx.GetPrimaryParticles().size() == 1 &&
68 vtx.GetInteractionNumber() == 0 && vtx.GetProbability() == 0 &&
69 vtx.GetCrossSection() == 0 && vtx.GetDiffCrossSection() == 0 &&
70 vtx.GetPrimaryParticles().begin()->GetPDGCode() == 0)
78 "Filling fCurrGenieVtx with OrigEvtNum = " << fOrigTreeEntryNumber);
80 fCurrGenieVtx->Reset();
81 fRooTrackerTree->GetEntry(entry);
84 fCurrGenieVtx->OrigFileName->SetString(fOrigInputFileName.c_str());
85 fCurrGenieVtx->OrigTreeName->SetString(fInputTreeName.c_str());
86 fCurrGenieVtx->OrigEvtNum = fOrigTreeEntryNumber;
87 fCurrGenieVtx->OrigTreePOT = fOrigInputTreePOT;
88 fCurrGenieVtx->OrigTreeEntries = fOrigInputTreeEntries;
89 fCurrGenieVtx->TimeInSpill = fTimeInSpill;
90 fCurrGenieVtx->TruthVertexID = fTruthVertexID;
93 fCurrGenieVtx->EvtVtx[0] *= 1000.0;
94 fCurrGenieVtx->EvtVtx[1] *= 1000.0;
95 fCurrGenieVtx->EvtVtx[2] *= 1000.0;
98 gGeoManager->FindNode(fCurrGenieVtx->EvtVtx[0], fCurrGenieVtx->EvtVtx[1],
99 fCurrGenieVtx->EvtVtx[2]);
102 fCurrGenieVtx->GeneratorName->SetString(fGeneratorName.c_str());
105 fCurrGenieVtx->GeomPath->SetString(gGeoManager->GetPath());
114 fGRooTrackerVtx->
Copy(fCurrGenieVtx);
123 fRooTrackerTree->SetBranchAddress(
"G2NeutEvtCode",
124 &(fCurrGenieVtx->G2NeutEvtCode));
125 fRooTrackerTree->SetBranchAddress(
"EvtCode", &(fCurrGenieVtx->EvtCode));
126 fRooTrackerTree->SetBranchAddress(
"EvtNum", &(fCurrGenieVtx->EvtNum));
127 fRooTrackerTree->SetBranchAddress(
"EvtXSec", &(fCurrGenieVtx->EvtXSec));
128 fRooTrackerTree->SetBranchAddress(
"EvtDXSec", &(fCurrGenieVtx->EvtDXSec));
129 fRooTrackerTree->SetBranchAddress(
"EvtWght", &(fCurrGenieVtx->EvtWght));
130 fRooTrackerTree->SetBranchAddress(
"EvtProb", &(fCurrGenieVtx->EvtProb));
131 fRooTrackerTree->SetBranchAddress(
"EvtVtx", (fCurrGenieVtx->EvtVtx));
132 fRooTrackerTree->SetBranchAddress(
"StdHepN", &(fCurrGenieVtx->StdHepN));
133 fRooTrackerTree->SetBranchAddress(
"StdHepPdg",
134 &(fCurrGenieVtx->StdHepPdgTemp));
135 fRooTrackerTree->SetBranchAddress(
"StdHepRescat",
136 &(fCurrGenieVtx->StdHepRescatTemp));
137 fRooTrackerTree->SetBranchAddress(
"StdHepStatus",
138 &(fCurrGenieVtx->StdHepStatusTemp));
139 fRooTrackerTree->SetBranchAddress(
"StdHepX4", (fCurrGenieVtx->StdHepX4));
140 fRooTrackerTree->SetBranchAddress(
"StdHepP4", (fCurrGenieVtx->StdHepP4));
141 fRooTrackerTree->SetBranchAddress(
"StdHepPolz", (fCurrGenieVtx->StdHepPolz));
142 fRooTrackerTree->SetBranchAddress(
"StdHepFd", (fCurrGenieVtx->StdHepFdTemp));
143 fRooTrackerTree->SetBranchAddress(
"StdHepLd", (fCurrGenieVtx->StdHepLdTemp));
144 fRooTrackerTree->SetBranchAddress(
"StdHepFm", (fCurrGenieVtx->StdHepFmTemp));
145 fRooTrackerTree->SetBranchAddress(
"StdHepLm", (fCurrGenieVtx->StdHepLmTemp));
151 if(fFilledConfigTree){
152 ND280NamedWarn(
"TGRooTrackerVtxModule",
"Module: " << this->GetName()
153 <<
" has already written the config tree this run.");
166 configTree->Branch(
"kGStdHepNPmax", &kGStdHepNPmax_hldr,
"kGStdHepNPmax/I");
167 configTree->Branch(
"kGStdHepIdxPx", &kGStdHepIdxPx_hldr,
"kGStdHepIdxPx/I");
168 configTree->Branch(
"kGStdHepIdxPy", &kGStdHepIdxPy_hldr,
"kGStdHepIdxPy/I");
169 configTree->Branch(
"kGStdHepIdxPz", &kGStdHepIdxPz_hldr,
"kGStdHepIdxPz/I");
170 configTree->Branch(
"kGStdHepIdxE", &kGStdHepIdxE_hldr,
"kGStdHepIdxE/I");
171 configTree->Branch(
"kGStdHepIdxX", &kGStdHepIdxX_hldr,
"kGStdHepIdxX/I");
172 configTree->Branch(
"kGStdHepIdxY", &kGStdHepIdxY_hldr,
"kGStdHepIdxY/I");
173 configTree->Branch(
"kGStdHepIdxZ", &kGStdHepIdxZ_hldr,
"kGStdHepIdxZ/I");
174 configTree->Branch(
"kGStdHepIdxT", &kGStdHepIdxT_hldr,
"kGStdHepIdxT/I");
void SetFluxTreeAddresses(ND::JNuBeamFlux *flux)
std::string fDescription
A longish descrition of the analysis.
TClonesArray * fVtx
TClonesArray of vertex objects.
void SetGeneratorTreeAddresses()
void FillConfigTree(TTree *configTree)
GRooTrackerVtx * fCurrGenieVtx
void FillConfigTree(TTree *configTree)
Bool_t CheckMismatch(ND::TG4PrimaryVertex vtx)
void SetNameTitle(char const *name, char const *title)
void Copy(const GRooTrackerVtx *event)
virtual ~TGRooTrackerVtxModule()
Bool_t IsGeantinoVtx(ND::TG4PrimaryVertex vtx)
Bool_t IsKnownGenerator(const char *)
TGRooTrackerVtxModule(const char *name="GRooTrackerVtx", const char *title="Complete truth info for GENIE primary vertices ""from the gRooTracker pass-through tree")