19 #include "CAFAna/Core/Binning.h" 25 #include "CAFAna/Core/Var.h" 34 #include "TLorentzVector.h" 62 const std::string fGENIE =
"defname: prod_caf_R17-03-01-prod3reco.d_nd_genie_nonswap_fhc_nova_v08_full_v1";
66 TFile outputFile(
"BdtTree9VarsOptimizedVolumes.root",
"RECREATE");
68 TTree *fPreSelectionTree =
new TTree(
"fPreSelectionTree",
"Storing some useful variables for MVA training");
100 float cvnncid, cvnnumu, cvnnue, cvnnutau, cvnphoton ;
101 float prong1MissingPl;
124 float distPngStartPos;
125 float png1dirx, png2dirx;
126 float png1diry, png2diry;
127 float png1dirz, png2dirz;
128 float Png1Pur, Png1Eff, Png1Pdg, Png1MotherPdg;
129 float Png2Pur, Png2Eff, Png2Pdg, Png2MotherPdg;
133 fPreSelectionTree->Branch(
"IsCC",&IsCC,
"IsCC/I");
134 fPreSelectionTree->Branch(
"IsNumuNC",&IsNumuNC,
"IsNumuNC/I");
135 fPreSelectionTree->Branch(
"IsNC",&IsNC,
"IsNC/I");
136 fPreSelectionTree->Branch(
"IsPi0all",&IsPi0all,
"IsPi0all/I");
137 fPreSelectionTree->Branch(
"IsPi0020",&IsPi0020,
"IsPi0020/I");
138 fPreSelectionTree->Branch(
"IsPi0025",&IsPi0025,
"IsPi0025/I");
139 fPreSelectionTree->Branch(
"IsPi0030",&IsPi0030,
"IsPi0030/I");
140 fPreSelectionTree->Branch(
"IsPi0035",&IsPi0035,
"IsPi0035/I");
141 fPreSelectionTree->Branch(
"IsPi0040",&IsPi0040,
"IsPi0040/I");
142 fPreSelectionTree->Branch(
"IsPi0045",&IsPi0045,
"IsPi0045/I");
143 fPreSelectionTree->Branch(
"IsPi0050",&IsPi0050,
"IsPi0050/I");
144 fPreSelectionTree->Branch(
"remid",&remid,
"remid/F");
145 fPreSelectionTree->Branch(
"michel",&michel,
"michel/F");
148 fPreSelectionTree->Branch(
"nhit",&nhit,
"nhit/I");
149 fPreSelectionTree->Branch(
"prong1Length",&prong1Length,
"prong1Length/F");
150 fPreSelectionTree->Branch(
"prong2Energy",&prong2Energy,
"prong2Energy/F");
151 fPreSelectionTree->Branch(
"png2diry",&png2diry,
"png2diry/F");
152 fPreSelectionTree->Branch(
"png1dirx",&png1dirx,
"png1dirx/F");
153 fPreSelectionTree->Branch(
"png1diry",&png1diry,
"png1diry/F");
154 fPreSelectionTree->Branch(
"prong1VtxGev",&prong1VtxGev,
"prong1VtxGev/F");
155 fPreSelectionTree->Branch(
"prong1Width",&prong1Width,
"prong1Width/F");
156 fPreSelectionTree->Branch(
"recopimass",&recopimass,
"recopimass/F");
157 fPreSelectionTree->Branch(
"shwlidpimass",&shwlidpimass,
"shwlidpimass/F");
158 fPreSelectionTree->Branch(
"prong2dedx",&prong2dedx,
"prong2dedx/F");
159 fPreSelectionTree->Branch(
"png2dirx",&png2dirx,
"png2dirx/F");
160 fPreSelectionTree->Branch(
"prong1Energy",&prong1Energy,
"prong1Energy/F");
161 fPreSelectionTree->Branch(
"png2dirz",&png2dirz,
"png2dirz/F");
162 fPreSelectionTree->Branch(
"png1dirz",&png1dirz,
"png1dirz/F");
163 fPreSelectionTree->Branch(
"remid",&remid,
"remid/F");
164 fPreSelectionTree->Branch(
"prong1MissingPl",&prong1MissingPl,
"prong1MissingPl/F");
165 fPreSelectionTree->Branch(
"prong1ContPl",&prong1ContPl,
"prong1ContPl/F");
166 fPreSelectionTree->Branch(
"prong1dedx",&prong1dedx,
"prong1dedx/F");
167 fPreSelectionTree->Branch(
"prong1epLLL",&prong1epLLL,
"prong1epLLL/F");
168 fPreSelectionTree->Branch(
"prong1epLLT",&prong1epLLT,
"prong1epLLT/F");
169 fPreSelectionTree->Branch(
"prong1epiLLL",&prong1epiLLL,
"prong1epiLLL/F");
170 fPreSelectionTree->Branch(
"prong1epiLLT",&prong1epiLLT,
"prong1epiLLT/F");
171 fPreSelectionTree->Branch(
"prong1epi0LLL",&prong1epi0LLL,
"prong1epi0LLL/F");
172 fPreSelectionTree->Branch(
"prong1epi0LLT",&prong1epi0LLT,
"prong1epi0LLT/F");
173 fPreSelectionTree->Branch(
"cvnncid",&cvnncid,
"cvnncid/F");
174 fPreSelectionTree->Branch(
"cvnnumu",&cvnnumu,
"cvnnumu/F");
175 fPreSelectionTree->Branch(
"cvnnue",&cvnnue,
"cvnnue/F");
176 fPreSelectionTree->Branch(
"cvnnutau",&cvnnutau,
"cvnnutau/F");
177 fPreSelectionTree->Branch(
"cvnphoton",&cvnphoton,
"cvnphoton/F");
178 fPreSelectionTree->Branch(
"slcCalE",&slcCalE,
"slcCalE/F");
179 fPreSelectionTree->Branch(
"distPngStartPos",&distPngStartPos,
"distPngStartPos/F");
182 fPreSelectionTree->Branch(
"Png1Pdg",&Png1Pdg,
"Png1Pdg/F");
183 fPreSelectionTree->Branch(
"Png1MotherPdg",&Png1MotherPdg,
"Png1MotherPdg/F");
184 fPreSelectionTree->Branch(
"Png1Eff",&Png1Eff,
"Png1Eff/F");
185 fPreSelectionTree->Branch(
"Png1Pur",&Png1Pur,
"Png1Pur/F");
186 fPreSelectionTree->Branch(
"Png2Pdg",&Png2Pdg,
"Png2Pdg/F");
187 fPreSelectionTree->Branch(
"Png2MotherPdg",&Png2MotherPdg,
"Png2MotherPdg/F");
188 fPreSelectionTree->Branch(
"Png2Eff",&Png2Eff,
"Png2Eff/F");
189 fPreSelectionTree->Branch(
"Png2Pur",&Png2Pur,
"Png2Pur/F");
193 SAMQueryStatus *filesrc=
new SAMQueryStatus(fGENIE);
195 int Nfiles = filesrc->NFiles();
201 while(TFile* file1 =(TFile*)filesrc->GetNextFile())
208 loader.
HandleFile(file1, Nfiles == 1 ? prog : 0);
210 if(Nfiles > 1 && prog) prog->
SetProgress((fileIdx+1.)/Nfiles);
214 TTree *
recTree = (TTree*)file1->Get(
"recTree");
218 recTree->SetBranchAddress(
"rec", &recTreeObject);
221 recTree->SetBranchStatus(
"*",0);
227 recTree->SetBranchStatus(
"hdr.run",1);
228 recTree->SetBranchStatus(
"hdr.subrun",1);
229 recTree->SetBranchStatus(
"hdr.evt",1);
230 recTree->SetBranchStatus(
"hdr.subevt",1);
233 recTree->SetBranchStatus(
"mc.nnu",1);
234 recTree->SetBranchStatus(
"mc.nu",1);
235 recTree->SetBranchStatus(
"mc.nu.iscc",1);
236 recTree->SetBranchStatus(
"mc.nu.mode",1);
237 recTree->SetBranchStatus(
"mc.nu.pdg",1);
238 recTree->SetBranchStatus(
"mc.nu.prim",1);
239 recTree->SetBranchStatus(
"mc.nu.prim.pdg",1);
240 recTree->SetBranchStatus(
"mc.nu.prim.p",1);
241 recTree->SetBranchStatus(
"mc.nu.prim.p.E",1);
242 recTree->SetBranchStatus(
"mc.nu.vtx.x",1);
243 recTree->SetBranchStatus(
"mc.nu.vtx.y",1);
244 recTree->SetBranchStatus(
"mc.nu.vtx.z",1);
247 recTree->SetBranchStatus(
"vtx.elastic",1);
248 recTree->SetBranchStatus(
"vtx.nelastic",1);
249 recTree->SetBranchStatus(
"vtx.elastic.vtx",1);
250 recTree->SetBranchStatus(
"vtx.elastic.vtx.x",1);
251 recTree->SetBranchStatus(
"vtx.elastic.vtx.y",1);
252 recTree->SetBranchStatus(
"vtx.elastic.vtx.z",1);
255 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.nshwlid",1);
256 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.npng",1);
257 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png",1);
258 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.shwlid",1);
259 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.shwlid.stop",1);
260 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.shwlid.stop.x",1);
261 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.shwlid.stop.y",1);
262 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.shwlid.stop.z",1);
263 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.shwlid.start",1);
264 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.shwlid.start.x",1);
265 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.shwlid.start.y",1);
266 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.shwlid.start.z",1);
267 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.shwlid.calE",1);
268 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.shwlid.width",1);
269 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.shwlid.len",1);
270 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.shwlid.maxplanecont",1);
271 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.shwlid.maxplanegap",1);
272 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.shwlid.dir",1);
273 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.shwlid.dir.x",1);
274 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.shwlid.dir.y",1);
275 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.shwlid.dir.z",1);
278 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.shwlid.lid",1);
279 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.shwlid.lid.eplll",1);
280 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.shwlid.lid.epllt",1);
281 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.shwlid.lid.epilll",1);
282 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.shwlid.lid.epillt",1);
283 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.shwlid.lid.epi0lll",1);
284 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.shwlid.lid.epi0llt",1);
285 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.shwlid.lid.vtxgev",1);
287 recTree->SetBranchStatus(
"sand.nue.dedxpng1",1);
288 recTree->SetBranchStatus(
"sand.nue.dedxpng2",1);
291 recTree->SetBranchStatus(
"slc.calE",1);
292 recTree->SetBranchStatus(
"slc.nhit",1);
295 recTree->SetBranchStatus(
"sel.remid.pid",1);
296 recTree->SetBranchStatus(
"sel.cvn.ncid",1);
297 recTree->SetBranchStatus(
"sel.cvn.numuid",1);
298 recTree->SetBranchStatus(
"sel.cvn.nueid",1);
299 recTree->SetBranchStatus(
"sel.cvn.nutauid",1);
300 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.cvnpart.photonid",1);
303 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.truth",1);
304 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.truth.pdg",1);
305 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.truth.motherpdg",1);
306 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.truth.eff",1);
307 recTree->SetBranchStatus(
"vtx.elastic.fuzzyk.png.truth.pur",1);
310 recTree->SetBranchStatus(
"me.nslc",1);
311 recTree->SetBranchStatus(
"me.slc.mid",1);
312 recTree->SetBranchStatus(
"me.slc.deltat",1);
313 recTree->SetBranchStatus(
"me.nkalman",1);
314 recTree->SetBranchStatus(
"me.trkkalman.mid",1);
315 recTree->SetBranchStatus(
"me.trkkalman.deltat",1);
319 Int_t numberOfEntries = recTree->GetEntriesFast();
322 for (Int_t event = 0;
event < numberOfEntries; ++event)
324 recTree->GetEntry(event);
326 if(recTreeObject->
mc.
nnu == 0)
continue;
327 if(recTreeObject->
vtx.nelastic == 0)
continue;
332 nbOfVtx = recTreeObject->
vtx.nelastic;
333 if(nbOfPng==0)
continue;
334 if(nbOfShw<=0)
continue;
335 if(nbOfVtx<=0)
continue;
338 Bool_t contained =
true;
340 Bool_t truefid =
false;
343 if((recTreeObject->
mc.
nu[0].vtx.x) < 170.0
344 && (recTreeObject->
mc.
nu[0].vtx.x) > -170.0
345 && (recTreeObject->
mc.
nu[0].vtx.y) < 170.0
346 && (recTreeObject->
mc.
nu[0].vtx.y) > -160.0
347 && (recTreeObject->
mc.
nu[0].vtx.z) < 1100.0
348 && (recTreeObject->
mc.
nu[0].vtx.z) > 50.0) truefid=
true;
352 && (recTreeObject->
mc.
nu[0].vtx.x) > -170.0
354 && (recTreeObject->
mc.
nu[0].vtx.y) > -160.0
359 for(
int i=0;
i<nbOfShw;
i++)
369 IsContained = contained;
373 if(!TrueFid)
continue;
374 if(!IsContained)
continue;
379 if(nbOfPng !=1)
continue;
380 if(nbOfVtx !=1)
continue;
401 if(!recTreeObject->
mc.
nu[0].iscc)
408 Bool_t ispi0all =
false;
409 Bool_t ispi0020 =
false;
410 Bool_t ispi0025 =
false;
411 Bool_t ispi0030 =
false;
412 Bool_t ispi0035 =
false;
413 Bool_t ispi0040 =
false;
414 Bool_t ispi0045 =
false;
415 Bool_t ispi0050 =
false;
428 int nprim=recTreeObject->
mc.
nu[0].prim.size();
430 for(
int i=0;
i<nprim;
i++)
434 if(recTreeObject->
mc.
nu[0].prim[
i].pdg==111)
436 e=recTreeObject->
mc.
nu[0].prim[
i].p.E;
440 if(t>0.0) nbOfPiall++;
441 if(t>0.20) nbOfPi020++;
442 if(t>0.25) nbOfPi025++;
443 if(t>0.30) nbOfPi030++;
444 if(t>0.35) nbOfPi035++;
445 if(t>0.40) nbOfPi040++;
446 if(t>0.45) nbOfPi045++;
447 if(t>0.50) nbOfPi050++;
451 if(nbOfPiall>0) ispi0all=
true;
452 if(nbOfPi020>0) ispi0020=
true;
453 if(nbOfPi025>0) ispi0025=
true;
454 if(nbOfPi030>0) ispi0030=
true;
455 if(nbOfPi035>0) ispi0035=
true;
456 if(nbOfPi040>0) ispi0040=
true;
457 if(nbOfPi045>0) ispi0045=
true;
458 if(nbOfPi050>0) ispi0050=
true;
500 Short_t mc_nnu = recTreeObject->
mc.
nnu;
501 Bool_t mc_nu_iscc = recTreeObject->
mc.
nu[0].iscc;
502 Short_t mc_nu_pdg = recTreeObject->
mc.
nu[0].pdg;
516 prong1dedx=recTreeObject->sand.nue.dedxpng1;
517 prong2dedx=recTreeObject->sand.nue.dedxpng2;
534 slcCalE=recTreeObject->
slc.
calE;
537 int nslc = recTreeObject->
me.
nslc;
538 int ntrkklmn = recTreeObject->
me.
nkalman;
541 for (
int i = 0;
i < nslc;
i++)
542 if (recTreeObject->
me.
slc[
i].mid > 2. && recTreeObject->
me.
slc[
i].deltat > 800.)
546 for (
int i = 0;
i < ntrkklmn;
i++)
553 if (n_me > 2.0) n_me = 2.0;
567 recopimass=thispi0mass1;
570 float thispi0mass[2];
574 for(
int i=0;
i<nbOfShw;
i++)
577 diff=
fabs(thispi0mass[
i]-pi0mass);
606 float distanceProngStart=(z2-z1)*(z2-z1)+(x2-
x1)*(x2-x1) +(y2-
y1)*(y2-y1);
607 distPngStartPos=
sqrt(distanceProngStart);
611 fPreSelectionTree->Fill();
float ncid
Likelihood Neutral Current.
Cuts and Vars for the 2020 FD DiF Study.
fvar< T > fabs(const fvar< T > &x)
Float_t y1[n_points_granero]
Float_t x1[n_points_granero]
std::vector< SRFuzzyKProng > png
Vector of 3D prong objects.
SRMichelE me
Michel electron branch.
std::vector< SRTrkME > trkkalman
float nutauid
Likelihood Charge Current NuTau.
float nueid
Likelihood Charge Current NuE.
float pid
PID value output by kNN.
unsigned int nshwlid
number of shwlid showers - either 0 or number of 3d prongs
SRCVNResult cvn
Horrible hack to appease CAFAna.
SRRemid remid
Output from RecoMuonID (ReMId) package.
float calE
Calorimetric energy of the cluster [GeV].
std::vector< SRSlcME > slc
SRVector3D vtx
Vertex position in detector coordinates. [cm].
short nnu
Number of neutrinos in nu vector (0 or 1)
unsigned int nhit
number of hits
The StandardRecord is the primary top-level object in the Common Analysis File trees.
void SetProgress(double frac)
Update the progress fraction between zero and one.
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
SRIDBranch sel
Selector (PID) branch.
SRElastic elastic
Single vertex found by Elastic Arms.
float numuid
Likelihood Charge Current NuMu.
A simple ascii-art progress bar.
SRSlice slc
Slice branch: nhit, extents, time, etc.
SRTruthBranch mc
Truth branch for MC: energy, flavor, etc.
virtual void HandleFile(TFile *f, Progress *prog=0)
SRFuzzyK fuzzyk
Primary 3D prong object.
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
void Done()
Call this when action is completed.
std::vector< SRNeutrino > nu
implemented as a vector to maintain mc.nu structure, i.e. not a pointer, but with 0 or 1 entries...
TCut fiducial(x1cut &&y1cut &&z1cut)
SRVertexBranch vtx
Vertex branch: location, time, etc.