numu_data_mc_validation.C
Go to the documentation of this file.
1 // Make Data and MC Spectra for validation
2 
4 #include "CAFAna/Core/Progress.h"
5 #include "CAFAna/Core/MultiVar.h"
7 #include "CAFAna/Core/Spectrum.h"
9 #include "CAFAna/Cuts/NueCutsSecondAna.h"
10 #include "CAFAna/Vars/Vars.h"
11 #include "CAFAna/Vars/TruthVars.h"
13 #include "OscLib/IOscCalc.h"
16 #include "CAFAna/Cuts/Cuts.h"
19 #include "CAFAna/Core/Binning.h"
23 
24 
25 using namespace ana;
26 
27 #include "TFile.h"
29 
30 #include <iostream>
31 #include <vector>
32 
33 
34 
35 
36 void AddNumuHistDefMoreTruth(std::vector< ana::HistDef > & hd){
37  const Var kTrueMuE([](const caf::SRProxy* sr){
38  if (sr->mc.nnu == 0) return -5.f;
39  return (sr->mc.nu[0].prim.size()==0) ? 0.f :
40  float(sr->mc.nu[0].prim[0].p.E);});
41 
42  const Var kTrueHadE = kTrueE - kTrueMuE;
43  hd.push_back({"true_hadE",{"True hadronic energy (GeV)",
44  Binning::Simple(20,0,5),kTrueHadE}});
45  hd.push_back({"true_muE",{"True muon energy (GeV)",
46  Binning::Simple(100,0,10),kTrueMuonE}});
47  // hd.push_back({"true_energyRes",{"(SA Reco-True)/True neutrino energy",
48 // Binning::Simple(100,-2,2),(kCCE-kTrueE)/kTrueE}});
49  // hd.push_back({"true_muonRes",{"(SA Reco-True)/True muon energy",
50 // Binning::Simple(100,-2,2),(kSAMuonE-kTrueMuonE)/kTrueMuonE}});
51  //hd.push_back({"true_hadERes",{"(SA Reco-True)/True hadronic energy",
52 // Binning::Simple(100,-2,2),(kSAHadE - kTrueHadE)/kTrueHadE}});
53  hd.push_back({"true_W",{"True W (GeV)",
54  Binning::Simple(50,0,2.5),kTrueW}});
55 }
56 
57 void AddNumuHistDef(std::vector< ana::HistDef > & hd){
58  const Binning kXYBins = Binning::Simple(55,-2.20,2.20);
59  const Binning kZBins = Binning::Simple(40, 0,20.00);
60  const Binning kEnergyBinning = Binning::Simple(200,0,20);
62 
63  hd.push_back({"ene_numuE_SA",{"SA Reconstructed Neutrino Energy [GeV]",
64  kEnergyBinning, kCCE}});
65 
66  hd.push_back({"ene_numuE_ND2017",{"2017 ND Reconstructed Neutrino Energy [GeV]",
68 
69  hd.push_back({"ene_muE_ND2017",{"2017 ND Muon Energy [GeV]",
71 
72  hd.push_back({"ene_hadE_ND2017",{"2017 ND Hadronic Energy [GeV]",
74 
75  hd.push_back({"slcNHit",{"Slice N_{Hit}",
76  Binning::Simple(50, 0, 500), kNHit}});
77 
78  hd.push_back({ "ene_calE",{"Slice Calorimetric Energy [GeV]",
80 
81  hd.push_back({ "ene_hadE",{"Reconstructed Hadronic Energy [GeV]",
83 
84  hd.push_back({"numuTrackE",{"Muon Track Energy [GeV]",
85  Binning::Simple(50, 0, 5), kMuE}});
86 
87  hd.push_back({ "hadEPerNHit",{"Average Hadronic Energy Per Hit [GeV]",
88  Binning::Simple(40, 0, 0.04), kHadEPerNHit}});
89 
90  hd.push_back({"trkEPerNHit",{"Average Track Energy Per Hit [GeV]",
91  Binning::Simple(40, 0, 0.04), kTrkEPerNHit}});
92 
93  hd.push_back({ "hadNHit",{"Hadronic N_{Hit}",
94  Binning::Simple(50, 0, 100), kHadNHit}});
95 
96  hd.push_back({"hadcalE",{"Off-track Calorimetric Hadronic Energy [GeV]",
98 
99  hd.push_back({"hadTrkE",{"On-track Hadronic Energy [GeV]",
100  Binning::Simple(50, 0, 0.5), kNumuHadTrkE}});
101 
102  hd.push_back({"hadVisE",{"Visible On-track Hadronic Energy [GeV]",
104 
105  hd.push_back({"maxy",{"Slice Maximum Y [m]",
106  kXYBins, kSlcMaxY}});
107 
108  hd.push_back({"nkal",{"Number of Tracks in Slice",
109  Binning::Simple(14, 1, 15), kNKalman}});
110 
111  hd.push_back({"nhit",{"Number of Hits in Slice",
112  Binning::Simple(50, 0, 500), kNHit}});
113 
114  hd.push_back({"trkStartX",{"Track Start X Position [m]",
115  kXYBins, kTrkStartX}});
116 
117  hd.push_back({"trkStartY",{"Track Start Y Position [m]",
118  kXYBins, kTrkStartY}});
119 
120  hd.push_back({ "trkStartZ",{"Track Start Z Position [m]",
121  kZBins, kTrkStartZ}});
122 
123  hd.push_back({ "trkEndX",{"Track End X Position [m]",
124  kXYBins, kTrkEndX}});
125 
126  hd.push_back({ "trkEndY",{"Track End Y Position [m]",
127  kXYBins, kTrkEndY}});
128 
129  hd.push_back({"trkEndZ",{"Track End Z Position [m]",
130  kZBins, kTrkEndZ}});
131 
132  hd.push_back({ "sliceDuration",{"Slice Duration [ns]",
133  Binning::Simple(50,0,500), kSliceDuration}});
134 
135  hd.push_back({"trkNhits",{"Number of Hits in Primary Track",
136  Binning::Simple(50,0,500), kTrkNhits}});
137 
138  hd.push_back({ "trkLength",{"Muon Track Length [m]",
139  Binning::Simple(50,0,16), kTrkLength}});
140 
141  hd.push_back({ "scatLL",{"ReMId Input: Scattering Log-likelihood",
142  Binning::Simple(50,-0.5,0.5), kReMIdScatLLH}});
143 
144  hd.push_back({"dedxLL",{"ReMId Input: dE/dx Log-likelihood",
145  Binning::Simple(50,-3,1), kReMIdDEDxLLH}});
146 
147  hd.push_back({"nonHadPlaneFrac",{"ReMId Input: Non-hadronic Plane Fract.",
148  Binning::Simple(50,0,1), kReMIdMeasFrac}});
149 
150  hd.push_back({ "ReMId",{"ReMId",
151  kRemidBinning, kRemID}});
152 
153  hd.push_back({"slcUnCalibNHit",{"Number of Uncalibrated Hits in Slice",
154  Binning::Simple(50, 0, 50), kSlcUnCalibNHit}});
155 
156  hd.push_back({"slcMeanTime",{"Slice Mean Time [#mus]",
157  Binning::Simple(60, -50, 550), kSlcMeanTime}});
158 
159  hd.push_back({"slcStartTime",{"Slice Start Time [#mus]",
160  Binning::Simple(60, -50, 550), kSlcStartTime}});
161 
162  hd.push_back({ "slcEndTime",{"Slice End Time [#mus]",
163  Binning::Simple(60, -50, 550), kSlcEndTime}});
164 
165  hd.push_back({"slcMinX",{"Slice Minimum X [m]",
166  kXYBins, kSlcMinX}});
167 
168  hd.push_back({"slcMinY",{"Slice Minimum Y [m]",
169  kXYBins, kSlcMinY}});
170 
171  hd.push_back({ "slcMinZ",{"Slice Minimum Z [m]",
172  kZBins, kSlcMinZ}});
173 
174  hd.push_back({"slcMaxX",{"Slice Maximum X [m]",
175  kXYBins, kSlcMaxX}});
176 
177  hd.push_back({"slcMaxY",{"Slice Maximum Y [m]",
178  kXYBins, kSlcMaxY}});
179 
180  hd.push_back({"slcMaxZ",{"Slice Maximum Z [m]",
181  kZBins, kSlcMaxZ}});
182 
183  hd.push_back({"slcExtentX",{"Slice Extent X [m]",
184  Binning::Simple(55, 0, 4.4), kSlcExtentX}});
185 
186  hd.push_back({"slcExtentY",{"Slice Extent Y [m]",
187  Binning::Simple(55, 0, 4.4), kSlcExtentY}});
188 
189  hd.push_back({ "slcExtentZ",{"Slice Extent Z [m]",
190  Binning::Simple(18, 0, 16), kSlcExtentZ}});
191 
192  hd.push_back({ "dirX",{"Kalman Track Cos #theta_{X}",
193  Binning::Simple(100, -1, 1), kDirX}});
194 
195  hd.push_back({"dirY",{"Kalman Track Cos #theta_{Y}",
196  Binning::Simple(100, -1, 1), kDirY}});
197 
198  hd.push_back({ "dirZ",{"Kalman Track Cos #theta_{Z}",
199  Binning::Simple(50, 0, 1), kDirZ}});
200 
201  hd.push_back({"cosNumi",{"Kalman Track Cos #theta_{NuMI}",
202  Binning::Simple(50, -0.02, 1.02), kCosNumi}});
203 
204  hd.push_back({"trkNPlaneGap",{"Number of Missing Planes in Kalman Track",
205  Binning::Simple(50, 0, 50), kTrkNPlaneGap}});
206 
207  hd.push_back({"slcCalEPerNHit",{"Visible Slice Energy Per Hit [GeV]",
208  Binning::Simple(40, 0, 0.04),
209  kSlcCalEPerNHit}});
210 
211  hd.push_back({"ncellsedge",{"Number of cells from the edge",
212  Binning::Simple(100,0,100),kNcellsFromEdge}}) ;
213 }
214 
215 void AddNumuHistDefWeight(std::vector< ana::HistDef > & hd){
216  hd.push_back({"wgt_ppfx",{"PPFX weights", Binning::Simple(100,0,4), kPPFXFluxCVWgt}});
217  hd.push_back({"wgt_xsec",{"XSec weights", Binning::Simple(100,0,4), kXSecCVWgt2017}});
218 }
219 
220 
221 void numu_data_mc_validation(const std::string predFileName,
222  const bool makeFile=false,
223  const std::string ldrData="",
224  const std::string ldrMC="")
225 {
226  // Variable groups from NueVarsExtra
227  // Variables from NueVars.h are used here or in the cuts
228 
229  std::vector <HistDef> defs;
230 
231  AddNumuHistDef(defs);
232  AddNueHistDefTruth(defs);
234  AddNueHistDefVertexND(defs); //ok
235  AddNueHistDefShowerND(defs); //ok
236  AddNueHistDefShower(defs); //ok
237  AddNueHistDefForCvn(defs); //ok
239 
240 // const int kIdUnweight = -1;
241  const int kIdUnweight = defs.size();
242  AddNueHistDefWeight(defs);
243  const Var kkWeight = kPPFXFluxCVWgt * kXSecCVWgt2017;
244 
245  // Cut flow. Change the names/cuts here only if new spectra are going to be saved
246  struct CutDef
247  {
249  Cut cut;
250  };
251 
252  const Cut kBENKaContainedPres = kNumuBasicQuality && kBENKaNumuFiducial
254  const Cut kBENKaUncontainPres = kNumuBasicQuality && kBENKaNumuFiducial
255  && !kBENKaNumuContain;
256 
257  std::vector <CutDef > sels = {
258  {"0_SAContain_remid", kNumuBasicQuality && kNumuContainND && kNumuNCRej},
259  {"1_2017Contain_remid", kNumuBasicQuality && kNumuContainND2017 && kNumuNCRej},
260  {"2_BENContain_remid", kBENKaContainedPres && kNumuNCRej},
261  {"3_BENUncontain_remid", kBENKaUncontainPres && kNumuNCRej},
262  };
263 
264  //Vars for a quick visual comparison of cutflow
265  MultiVar kCutFlowVar ([sels](const caf::SRProxy* sr){
266  std::vector<double> passes;
267  for (unsigned int i=0;i<sels.size();++i){
268  if(sels[i].cut(sr)) passes.push_back(i);
269  }
270  return passes;
271  });
272  const Binning flowBins = Binning::Simple(10,0,10);
273  const Var kDummy ( [] (const caf::SRProxy *sr){return 1;});
274  defs.insert(defs.begin(),{"_dummy", {"Dummy", Binning::Simple(3, -0.5,2.5), kDummy}});
275 
276  //Save Data and MC spectra
277 
278  if(makeFile){
279  SpectrumLoader loaderData(ldrData.c_str());
280  SpectrumLoader loaderMC(ldrMC.c_str());
281 
282  loaderData.SetSpillCut(kStandardSpillCuts);
283  loaderMC.SetSpillCut(kStandardDQCuts);
284 
285  std::vector < std::vector<Spectrum*> > spects;
286  std::vector < std::vector<Spectrum*> > specMC; //useful when truth info is missing
287  std::vector < std::vector<IDecomp*> > preds;
288 
289  for(int selIdx = 0; selIdx<(int)sels.size(); ++selIdx){
290  std::vector<Spectrum *> temp_spec;
291  std::vector<Spectrum *> temp_spMC;
292  std::vector<IDecomp *> temp_pred;
293  for(int varIdx = 0; varIdx < (int)defs.size(); ++varIdx){
294  const HistAxis& axis = defs[varIdx].axis;
295  Var weight = (varIdx < kIdUnweight) ? kkWeight:kUnweighted;
296 
297  temp_spec.emplace_back(new Spectrum (loaderData, axis, sels[selIdx].cut, kNoShift));
298  temp_spMC.emplace_back(new Spectrum (loaderMC, axis, sels[selIdx].cut, kNoShift, weight));
299  temp_pred.emplace_back(new CheatDecomp(loaderMC, axis, sels[selIdx].cut, kNoShift, weight));
300  }
301  spects.push_back(temp_spec);
302  specMC.push_back(temp_spMC);
303  preds.push_back(temp_pred);
304  }
305 
306  auto spfl_data = new Spectrum ("Cut Flow",flowBins,loaderData, kCutFlowVar, kNoCut);
307  auto spfl_ndmc = new Spectrum ("Cut Flow",flowBins,loaderMC, kCutFlowVar, kNoCut);
308 
309  loaderMC.Go();
310  loaderData.Go();
311 
312  TFile* fout = new TFile(predFileName.c_str(), "RECREATE");
313  Progress prog("Saving...");
314  int nsteps=0;
315  for(int selIdx = 0; selIdx < (int)sels.size(); ++selIdx){
316  const char* cut = sels[selIdx].name.c_str();
317  for(int varIdx = 0; varIdx < (int)defs.size(); ++varIdx){
318  const char* name = defs[varIdx].name.c_str();
319  spects[selIdx][varIdx]->SaveTo(fout, TString::Format("spect_%s_%s", name, cut));
320  specMC[selIdx][varIdx]->SaveTo(fout, TString::Format("speMC_%s_%s", name, cut));
321  preds[selIdx][varIdx]->SaveTo(fout, TString::Format("pred_%s_%s", name, cut));
322  nsteps ++;
323  prog.SetProgress((double)nsteps/(sels.size()*defs.size()+1));
324  }
325  }
326  spfl_data->SaveTo(fout, "spect_data_cutflow");
327  spfl_ndmc->SaveTo(fout, "spect_mc_cutflow");
328  prog.Done();
329 
330  delete fout;
331  std::cout << "Saved prediction to " << predFileName << "\n";
332  return;
333  } //end makeFile
334  else{
335  // Play with the format for the generic validation scripts
336  // Here I'm taking the one file and splitting data and MC
337  // Data and MC will be treated as "datasets" = separate files
338  // Alternatively, you could treat them as folders, or categories in a group
339  // Your mileage may vary
340 
341  TFile * predFile = new TFile (predFileName.c_str(), "READ");
342  TString validFileName1 (predFileName); validFileName1.ReplaceAll(".root","_mc_validation.root");
343  TString validFileName2 (predFileName); validFileName2.ReplaceAll(".root","_data_validation.root");
344 
345  TFile * validFile1 = new TFile(validFileName1,"RECREATE");
346  TFile * validFile2 = new TFile(validFileName2,"RECREATE");
347 
348  int kNumSels = sels.size();
349  int kNumVars = defs.size();
350 
351  // Don't make all the canvases and .json right now
352  //kNumSels = 6;
353  //kNumVars = 10;
354  bool components = 0;
355 
356  Progress prog ("Arranging spectra...");
357  int nsteps = 0;
358 
359  for(int selIdx = 0; selIdx < kNumSels; ++selIdx){
360  const char* cut = sels[selIdx].name.c_str();
361 
362  for(int varIdx = 0; varIdx < kNumVars; ++varIdx){
363  const char* name = defs[varIdx].name.c_str();
364  auto spec = Spectrum::LoadFrom(predFile, TString::Format("spect_%s_%s", name, cut).Data());
365  auto spMC = Spectrum::LoadFrom(predFile, TString::Format("speMC_%s_%s", name, cut).Data());
366  auto pred = CheatDecomp::LoadFrom (predFile, TString::Format("pred_%s_%s", name, cut).Data());
367 
368  // Data and MC for variable "name" will be plotted together
369  // Plots will have selector for cut level {group=Cut,cat=%s}
370  // Optional MCComponents folder will have extra selector; total MC = all_sum will be created as well
371 
372  spec->SaveTo(validFile2, TString::Format("%s{group=Cut,cat=%s}", name,cut));
373  spMC->SaveTo(validFile1, TString::Format("%s{group=Cut,cat=%s}", name,cut));
374 
375  if (components){
376  TDirectory* comp = validFile1->GetDirectory("MCComponents");
377  if(!comp) comp = validFile1->mkdir("MCComponents");
378  pred->NueComponent(). SaveTo(comp, TString::Format("%s_{group=Cut,cat=%s}{group=Component,cat=0_nue}", name,cut));
379  pred->NumuComponent(). SaveTo(comp, TString::Format("%s_{group=Cut,cat=%s}{group=Component,cat=1_numu}", name,cut));
380  pred->AntiNueComponent(). SaveTo(comp, TString::Format("%s_{group=Cut,cat=%s}{group=Component,cat=3_antinue}", name,cut));
381  pred->AntiNumuComponent().SaveTo(comp, TString::Format("%s_{group=Cut,cat=%s}{group=Component,cat=4_antinumu}", name,cut));
382  pred->NCTotalComponent(). SaveTo(comp, TString::Format("%s_{group=Cut,cat=%s}{group=Component,cat=2_nc}", name,cut));
383  (*spMC-(pred->TotalMC())). SaveTo(comp, TString::Format("%s_{group=Cut,cat=%s}{group=Component,cat=5_other}", name,cut));
384  }
385  prog.SetProgress((double)nsteps/(kNumSels*kNumVars));
386  nsteps++;
387  } //end var
388  auto spfl = Spectrum::LoadFrom(predFile, "spect_data_cutflow");
389  spfl->SaveTo(validFile2, TString::Format("%s{group=Cut,cat=%s}", "_cutflow",cut));
390 
391  spfl = Spectrum::LoadFrom(predFile, "spect_mc_cutflow");
392  spfl->SaveTo(validFile1, TString::Format("%s{group=Cut,cat=%s}", "_cutflow",cut));
393 
394  }// end cut
395  prog.Done();
396  std::cout << "Closing files...\n";
397  delete validFile1;
398  delete validFile2;
399  std::cout << "Formatted outputs saved to " << validFileName1 << " and " << validFileName2 << std::endl;
400 
401  }
402 }
const Var kHadE
Definition: NumuVars.h:23
const Var kHadNHit([](const caf::SRProxy *sr){unsigned int nought=0;if(sr->trk.kalman.ntracks< 1) return nought;return sr->slc.nhit-sr->trk.kalman.tracks[0].nhit;})
Definition: NumuVars.h:61
const XML_Char * name
Definition: expat.h:151
void AddNueHistDefWeight(std::vector< HistDef > &hd)
const Var kNKalman
Definition: NumuVars.cxx:540
const int kNumVars
Definition: vars.h:14
void AddNumuHistDefWeight(std::vector< HistDef > &hd)
Represent the binning of a Spectrum&#39;s x-axis.
Definition: Binning.h:16
const Var kNcellsFromEdge
Definition: NumuVars.cxx:560
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const Var kReMIdScatLLH
Definition: NumuVars.cxx:555
const Var kSlcMeanTime([](const caf::SRProxy *sr){return sr->slc.meantime/1000.;})
Definition: NumuVars.h:83
const Var kNumuHadTrkE
Definition: NumuVars.cxx:539
void SaveTo(const osc::IOscCalc &x, TDirectory *dir, const std::string &name)
const Binning kRemidBinning
Binning for plotting remid attractively.
Definition: Binning.cxx:80
void numu_data_mc_validation(const std::string predFileName, const bool makeFile=false, const std::string ldrData="", const std::string ldrMC="")
const Var kPPFXFluxCVWgt
Definition: PPFXWeights.h:16
dictionary components
const Var kSlcMaxZ([](const caf::SRProxy *sr){return sr->slc.boxmax.Z()/100.;})
Definition: NumuVars.h:93
const Var kSlcCalEPerNHit([](const caf::SRProxy *sr){if(sr->slc.nhit > 0) return sr->slc.calE/(1.78 *sr->slc.nhit);return-5.;})
Definition: NumuVars.h:101
const Var weight
const Var kSlcMaxY([](const caf::SRProxy *sr){return sr->slc.boxmax.Y()/100.;})
Definition: NumuVars.h:92
const Cut kNumuContainND2017([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return false;for(unsigned int i=0;i< sr->vtx.elastic.fuzzyk.nshwlid;++i){TVector3 start=sr->vtx.elastic.fuzzyk.png[i].shwlid.start;TVector3 stop=sr->vtx.elastic.fuzzyk.png[i].shwlid.stop;if(std::min(start.X(), stop.X())< -180.0) return false;if(std::max(start.X(), stop.X()) > 180.0) return false;if(std::min(start.Y(), stop.Y())< -180.0) return false;if(std::max(start.Y(), stop.Y()) > 180.0) return false;if(std::min(start.Z(), stop.Z())< 20.0) return false;if(std::max(start.Z(), stop.Z()) > 1525.0) return false;}if(sr->trk.kalman.ntracks< 1) return false;for(unsigned int i=0;i< sr->trk.kalman.ntracks;++i){if(i==sr->trk.kalman.idxremid) continue;else if(sr->trk.kalman.tracks[i].start.Z() > 1275||sr->trk.kalman.tracks[i].stop.Z() > 1275) return false;}return(sr->trk.kalman.ntracks > sr->trk.kalman.idxremid &&sr->slc.firstplane > 1 &&sr->slc.lastplane< 212 &&sr->trk.kalman.tracks[0].start.Z()< 1100 &&(sr->trk.kalman.tracks[0].stop.Z()< 1275 ||sr->sel.contain.kalyposattrans< 55) &&sr->sel.contain.kalfwdcellnd > 5 &&sr->sel.contain.kalbakcellnd > 10);})
Definition: NumuCuts2017.h:11
const TString name
const int nsteps
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2126
caf::Proxy< std::vector< caf::SRNeutrino > > nu
Definition: SRProxy.h:618
const Var kTrkStartY([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks< 1) return-10.0f;return sr->trk.kalman.tracks[0].start.Y()/100;})
Definition: NumuVars.h:52
const Var kSliceDuration([](const caf::SRProxy *sr){return(sr->slc.endtime-sr->slc.starttime);})
Definition: NumuVars.h:35
caf::Proxy< short int > nnu
Definition: SRProxy.h:617
const Var kSlcExtentY([](const caf::SRProxy *sr){return(sr->slc.boxmax.Y()-sr->slc.boxmin.Y())/100.;})
Definition: NumuVars.h:96
void SetSpillCut(const SpillCut &cut)
const Var kTrkEPerNHit([](const caf::SRProxy *sr){return(sr->trk.kalman.tracks[0].calE/sr->trk.kalman.tracks[0].nhit);})
const Var kReMIdMeasFrac
Definition: NumuVars.cxx:557
void AddNumuHistDefMoreTruth(std::vector< ana::HistDef > &hd)
const Var kDirZ([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks< 1) return-5.f;return sr->trk.kalman.tracks[0].dir.Z();})
Definition: NumuVars.h:39
const Var kTrkLength([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks< 1) return-5.f;return sr->trk.kalman.tracks[0].len/100;})
Definition: NumuVars.h:65
const Var kSlcMinX([](const caf::SRProxy *sr){return sr->slc.boxmin.X()/100.;})
Definition: NumuVars.h:87
const Var kHadEPerNHit([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks< 1) return 0.0f;int nHit=sr->slc.nhit-sr->trk.kalman.tracks[0].nhit;if(nHit<=0) return 0.0f;float hadE=sr->energy.numu.hadcalE;return hadE/nHit;})
Definition: NumuVars.h:63
const Var kNumuHadVisE([](const caf::SRProxy *sr){return kNumuHadCalE(sr)+kNumuHadTrkE(sr);})
Definition: NumuVars.h:124
const Var kSlcMaxX([](const caf::SRProxy *sr){return sr->slc.boxmax.X()/100.;})
Definition: NumuVars.h:91
const Cut kNumuContainND([](const caf::SRProxy *sr){return( sr->trk.kalman.ntracks > sr->trk.kalman.idxremid &&sr->slc.ncellsfromedge > 1 &&sr->slc.firstplane > 1 &&sr->slc.lastplane< 212 &&sr->trk.kalman.tracks[0].start.Z()< 1150 &&( sr->trk.kalman.tracks[0].stop.Z()< 1275 ||sr->sel.contain.kalyposattrans< 55) &&( sr->energy.numu.ndhadcalcatE +sr->energy.numu.ndhadcaltranE)< 0.03 &&sr->sel.contain.kalfwdcellnd > 4 &&sr->sel.contain.kalbakcellnd > 8);})
Definition: NumuCuts.h:22
const Var kDirY([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks< 1) return-5.f;return sr->trk.kalman.tracks[0].dir.Y();})
Definition: NumuVars.h:38
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
const Var kNumuHadCalE
Definition: NumuVars.cxx:538
const Var kTrueMuE
const Var kSlcMinY([](const caf::SRProxy *sr){return sr->slc.boxmin.Y()/100.;})
Definition: NumuVars.h:88
void AddNueHistDefShowerND(std::vector< ana::HistDef > &hd)
static std::unique_ptr< CheatDecomp > LoadFrom(TDirectory *dir, const std::string &name)
Definition: CheatDecomp.cxx:73
const Var kTrueE([](const caf::SRProxy *sr){assert(sr->mc.nnu==1);return sr->mc.nu[0].E;})
Definition: Vars.cxx:85
void AddNueHistDefSelectionExtras(std::vector< HistDef > &hd)
const Var kRemID
PID
Definition: Vars.cxx:81
const Cut sels[kNumSels]
Definition: vars.h:44
static std::unique_ptr< Spectrum > LoadFrom(TDirectory *dir, const std::string &name)
Definition: Spectrum.cxx:535
const Var kCaloE
Summed calorimetric energy of all hits in slice, uncorrected.
Definition: Vars.cxx:52
const Binning kHadronicEnergyBinning
const Var kNHit
Definition: Vars.cxx:71
const SpillCut kStandardDQCuts([](const caf::SRSpillProxy *spill){if(spill->dcmedgematchfrac==0 &&spill->fracdcm3hits==0 &&spill->nmissingdcmslg==0) return bool(spill->isgoodspill); if(spill->det==caf::kNEARDET && (spill->fracdcm3hits > 0.45|| spill->nmissingdcms > 0)) return false; if(spill->eventincomplete) return false; if(spill->det==caf::kFARDET && spill->nmissingdcmslg > 0) return false; if(spill->det==caf::kFARDET && !spill->ismc && spill->dcmedgematchfrac<=0.2) return false;return true;})
Cut out events with a noisy detector or with parts missing.
Definition: SpillCuts.h:16
const Var kTrkStartZ([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks< 1) return-10.0f;return sr->trk.kalman.tracks[0].start.Z()/100;})
Definition: NumuVars.h:53
const Var kCCE
Definition: NumuVars.h:21
const Binning kEnergyBinning
Struct to hold cut information.
const Var kSlcStartTime([](const caf::SRProxy *sr){return sr->slc.starttime/1000.;})
Definition: NumuVars.h:84
const Binning kXYBins
Definition: VarsAndCuts.h:95
caf::StandardRecord * sr
const HistDef defs[kNumVars]
Definition: vars.h:15
const Cut kNumuNCRej([](const caf::SRProxy *sr){return(sr->sel.remid.pid >0.75);})
Definition: NumuCuts.h:24
const int kNumSels
Definition: vars.h:43
std::vector< float > Spectrum
Definition: Constants.h:610
const Var kTrkStartX([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks< 1) return-10.0f;return sr->trk.kalman.tracks[0].start.X()/100;})
Definition: NumuVars.h:51
const SystShifts kNoShift
Definition: SystShifts.cxx:22
OStream cout
Definition: OStream.cxx:6
const Var kTrkEndZ([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks< 1) return-10.0f;return sr->trk.kalman.tracks[0].stop.Z()/100;})
Definition: NumuVars.h:57
void AddNueHistDefShower(std::vector< HistDef > &hd)
caf::Proxy< caf::SRTruthBranch > mc
Definition: SRProxy.h:2138
void AddNueHistDefTruth(std::vector< HistDef > &hd)
const Var kTrkNPlaneGap([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks > 0 &&sr->trk.kalman.idxremid!=999) return int(sr->trk.kalman.tracks[0].nplanegap);return 500;})
Definition: NumuVars.h:99
const Cut kNumuBasicQuality([](const caf::SRProxy *sr){return(sr->energy.numu.trkccE > 0 && sr->sel.remid.pid > 0 && sr->slc.nhit > 20 && sr->slc.ncontplanes > 4 && sr->trk.cosmic.ntracks > 0);})
Definition: NumuCuts.h:14
void SetProgress(double frac)
Update the progress fraction between zero and one.
Definition: Progress.cxx:41
const Var kTrkEndY([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks< 1) return-10.0f;return sr->trk.kalman.tracks[0].stop.Y()/100;})
Definition: NumuVars.h:56
const Cut kBENKaNumuFiducial([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return false;if(sr->trk.kalman.ntracks<=0) return false;return(sr->vtx.elastic.vtx.X() >-170 && sr->vtx.elastic.vtx.X()< 170 && sr->vtx.elastic.vtx.Y() >-170 && sr->vtx.elastic.vtx.Y()< 170 && sr->vtx.elastic.vtx.Z() > 30 && sr->vtx.elastic.vtx.Z()< 1150 && sr->trk.kalman.tracks[0].start.X() >-170 && sr->trk.kalman.tracks[0].start.X()< 170 && sr->trk.kalman.tracks[0].start.Y() >-170 && sr->trk.kalman.tracks[0].start.Y()< 170 && sr->trk.kalman.tracks[0].start.Z() > 30 && sr->trk.kalman.tracks[0].start.Z()< 1150 );})
Definition: BeamNueCuts.h:14
const Cut cut
const Var kTrkEndX([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks< 1) return-10.0f;return sr->trk.kalman.tracks[0].stop.X()/100;})
Definition: NumuVars.h:55
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
const Var kSlcEndTime([](const caf::SRProxy *sr){return sr->slc.endtime/1000.;})
Definition: NumuVars.h:85
const Var kNumuE2017ND
Definition: NumuEFxs.h:55
const Var kTrueMuonE([](const caf::SRProxy *sr){if(sr->mc.nnu==0) return 0.f;if(sr->mc.nu[0].prim.empty()) return 0.f;if(std::abs(sr->mc.nu[0].prim[0].pdg)!=13) return 0.f;return float(sr->mc.nu[0].prim[0].p.E);})
Definition: NumuVars.h:107
const Var kDirX([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks< 1) return-5.f;return sr->trk.kalman.tracks[0].dir.X();})
Definition: NumuVars.h:37
const Var kTrueHadE
A simple ascii-art progress bar.
Definition: Progress.h:9
const Var kNumuHadE2017ND(NumuHadE2017NDW(predict_prod3_nd_p3_had_energy))
Definition: NumuEFxs.h:53
const Var kDummy([](const caf::SRProxy *sr){return 1;})
const Var kReMIdDEDxLLH
Definition: NumuVars.cxx:556
const Cut kBENKaNumuContain([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks<=0) return false;return( sr->trk.kalman.tracks[0].stop.X() >-185 && sr->trk.kalman.tracks[0].stop.X()< 185 && sr->trk.kalman.tracks[0].stop.Y() >-185 && sr->trk.kalman.tracks[0].stop.Y()< 185 && sr->trk.kalman.tracks[0].stop.Z() > 19 && sr->trk.kalman.tracks[0].stop.Z()< 1275 );})
Definition: BeamNueCuts.h:16
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
void AddNueHistDefVertexND(std::vector< HistDef > &hd)
const Var kSlcExtentX([](const caf::SRProxy *sr){return(sr->slc.boxmax.X()-sr->slc.boxmin.X())/100.;})
Definition: NumuVars.h:95
const Var kXSecCVWgt2017
Definition: XsecTunes.h:37
const Var kMuE
Definition: NumuVars.h:22
const Var kSlcExtentZ([](const caf::SRProxy *sr){return(sr->slc.boxmax.Z()-sr->slc.boxmin.Z())/100.;})
Definition: NumuVars.h:97
const Binning kZBins
Definition: VarsAndCuts.h:96
void Done()
Call this when action is completed.
Definition: Progress.cxx:90
const Var kSlcUnCalibNHit([](const caf::SRProxy *sr){return sr->slc.nhit-sr->slc.ncalhit;})
Definition: NumuVars.h:81
TH1F * hd
Definition: Xdiff_gwt.C:57
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:107
const Var kTrueW
Definition: TruthVars.h:22
Just return the ND truth spectra as the decomposition.
Definition: CheatDecomp.h:10
const Var kUnweighted
The simplest possible Var, always 1. Used as a default weight.
Definition: Var.h:96
const Cut kNoCut
The simplest possible cut: pass everything, used as a default.
Definition: Cut.h:109
const Var kCosNumi([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks > 0 &&sr->trk.kalman.idxremid!=999){if(sr->hdr.det==1){return sr->trk.kalman.tracks[0].dir.Dot(beamDirND);}if(sr->hdr.det==2){return sr->trk.kalman.tracks[0].dir.Dot(beamDirFD);}}return-5.f;})
Definition: NumuVars.h:43
void AddNumuHistDef(std::vector< ana::HistDef > &hd)
const Var kSlcMinZ([](const caf::SRProxy *sr){return sr->slc.boxmin.Z()/100.;})
Definition: NumuVars.h:89
const Var kTrkNhits([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks< 1) return 65535;return int(sr->trk.kalman.tracks[0].nhit);})
Definition: NumuVars.h:59
const Var kNumuMuE2017ND(NumuMuE2017NDW(predict_prod3_nd_p3_act_energy, predict_prod3_nd_p3_cat_energy))
Definition: NumuEFxs.h:52
enum BeamMode string