Scheduling.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "CAFAna/Core/Cut.h"
4 #include "CAFAna/Core/Var.h"
12 
13 
14 using namespace ana;
15 
16 void scheduleCuts(std::map<std::string,const Cut> &map_Cuts, std::map<std::string, const NuTruthCut> &map_NuCuts,
17  const Cut kOverlaid, const NuTruthCut kOverlaid_Nu, std::string const &s_Selection, bool isNominal = false, bool getDetailed = false, bool loosePresel = false)
18 {
19  Helper help;
20 
21  const Cut kSig = help.Sig_Cut (s_Selection);
22  const NuTruthCut kSig_Nu = help.Sig_NuCut(s_Selection);
23 
24  const Cut kSelection = help.Selection_Cut(s_Selection);
25 
26  const NuTruthCut kAnaTrueE_Nu = s_Selection.find("numu")!=std::string::npos ? kAnaTrueECut_Nu_Numu : kAnaTrueECut_Nu_Nue;
27  const Cut kAnaTrueE = s_Selection.find("numu")!=std::string::npos ? kAnaTrueECut_Numu : kAnaTrueECut_Nue;
28 
29 
30  const NuTruthCut kThisTrueOFiducial_Nu = loosePresel ? kTrueOFiducialLoose_Nu : kTrueOFiducial_Nu;
31  const Cut kThisTrueOFiducial = loosePresel ? kTrueOFiducialLoose : kTrueOFiducial;
32 
33  if(!isNominal){
34  if(s_Selection.find("numu")!=std::string::npos){
35 
36  const Cut kQuality = help.Quality_Cut (s_Selection);
37  const Cut kContainment = help.Containment_Cut(s_Selection);
38 
39  map_NuCuts.emplace("over", kOverlaid_Nu);
40  map_NuCuts.emplace("over_sig", kOverlaid_Nu && kSig_Nu);
41  map_NuCuts.emplace("over_fid", kOverlaid_Nu && kThisTrueOFiducial_Nu);
42  map_NuCuts.emplace("over_fid_sig", kOverlaid_Nu && kThisTrueOFiducial_Nu && kSig_Nu);
43  //map_NuCuts.emplace("over_fid_sig_e", kOverlaid_Nu && kThisTrueOFiducial_Nu && kSig_Nu && kTrueE250MeV_Nu);
44  map_NuCuts.emplace("over_fid_sig_ATE", kOverlaid_Nu && kThisTrueOFiducial_Nu && kSig_Nu && kAnaTrueE_Nu);
45 
46  map_Cuts.emplace("over_sig_rec", kOverlaid && kSig);
47  map_Cuts.emplace("over_fid_rec", kOverlaid && kThisTrueOFiducial);
48  map_Cuts.emplace("over_fid_sig_rec", kOverlaid && kThisTrueOFiducial && kSig);
49  map_Cuts.emplace("over_fid_sig_rec_qual", kOverlaid && kThisTrueOFiducial && kSig && kQuality);
50  map_Cuts.emplace("over_fid_sig_rec_cont", kOverlaid && kThisTrueOFiducial && kSig && kContainment);
51  map_Cuts.emplace("over_fid_sig_rec_cont_qual", kOverlaid && kThisTrueOFiducial && kSig && kContainment && kQuality);
52  map_Cuts.emplace("over_fid_sig_rec_sel", kOverlaid && kThisTrueOFiducial && kSig && kSelection);
53 
54  /*
55  map_Cuts.emplace("over_fid_sig_e_rec", kOverlaid && kThisTrueOFiducial && kSig && kTrueE250MeV);
56  map_Cuts.emplace("over_fid_sig_e_rec_qual", kOverlaid && kThisTrueOFiducial && kSig && kTrueE250MeV && kQuality);
57  map_Cuts.emplace("over_fid_sig_e_rec_cont", kOverlaid && kThisTrueOFiducial && kSig && kTrueE250MeV && kContainment);
58  map_Cuts.emplace("over_fid_sig_e_rec_cont_qual",kOverlaid && kThisTrueOFiducial && kSig && kTrueE250MeV && kContainment && kQuality);
59  map_Cuts.emplace("over_fid_sig_e_rec_sel", kOverlaid && kThisTrueOFiducial && kSig && kTrueE250MeV && kSelection);
60  */
61 
62  map_Cuts.emplace("over_fid_sig_ATE_rec", kOverlaid && kThisTrueOFiducial && kSig && kAnaTrueE);
63  map_Cuts.emplace("over_fid_sig_ATE_rec_qual", kOverlaid && kThisTrueOFiducial && kSig && kAnaTrueE && kQuality);
64  map_Cuts.emplace("over_fid_sig_ATE_rec_cont", kOverlaid && kThisTrueOFiducial && kSig && kAnaTrueE && kContainment);
65  map_Cuts.emplace("over_fid_sig_ATE_rec_cont_qual",kOverlaid && kThisTrueOFiducial && kSig && kAnaTrueE && kContainment && kQuality);
66  map_Cuts.emplace("over_fid_sig_ATE_rec_sel", kOverlaid && kThisTrueOFiducial && kSig && kAnaTrueE && kSelection);
67  }
68  else if(s_Selection.find("nue")!=std::string::npos){
69  const Cut kPresel = help.Presel_Cut(s_Selection);
70 
71  map_NuCuts.emplace("over", kOverlaid_Nu);
72  map_NuCuts.emplace("over_sig", kOverlaid_Nu && kSig_Nu);
73  map_NuCuts.emplace("over_fid", kOverlaid_Nu && kThisTrueOFiducial_Nu);
74  map_NuCuts.emplace("over_fid_sig", kOverlaid_Nu && kThisTrueOFiducial_Nu && kSig_Nu);
75  map_NuCuts.emplace("over_fid_sig_ATE", kOverlaid_Nu && kThisTrueOFiducial_Nu && kSig_Nu && kAnaTrueE_Nu);
76 
77  map_Cuts.emplace("over_sig_rec", kOverlaid && kSig);
78  map_Cuts.emplace("over_fid_rec", kOverlaid && kThisTrueOFiducial);
79  map_Cuts.emplace("over_fid_sig_rec", kOverlaid && kThisTrueOFiducial && kSig);
80  map_Cuts.emplace("over_fid_sig_rec_presel", kOverlaid && kThisTrueOFiducial && kSig && kPresel);
81  map_Cuts.emplace("over_fid_sig_rec_sel", kOverlaid && kThisTrueOFiducial && kSig && kSelection);
82 
83  map_Cuts.emplace("over_sig_ATE_rec", kOverlaid && kSig);
84  map_Cuts.emplace("over_fid_ATE_rec", kOverlaid && kAnaTrueE && kThisTrueOFiducial);
85  map_Cuts.emplace("over_fid_sig_ATE_rec", kOverlaid && kAnaTrueE && kThisTrueOFiducial && kSig);
86  map_Cuts.emplace("over_fid_sig_ATE_rec_presel", kOverlaid && kAnaTrueE && kThisTrueOFiducial && kSig && kPresel);
87  map_Cuts.emplace("over_fid_sig_ATE_rec_sel", kOverlaid && kAnaTrueE && kThisTrueOFiducial && kSig && kSelection);
88 
89  if(getDetailed) furtherBENBreakdown(map_Cuts, kOverlaid && kAnaTrueE && kThisTrueOFiducial && kSig);
90  }
91  }
92 
93  return;
94 }
95 
96 
97 void scheduleVars(std::map<std::string,const Var> &map_Vars, std::map<std::string,const NuTruthVar> &map_NuVars, std::string s_Selection)
98 {
99  if(s_Selection.find("numu2020")!=std::string::npos){
100  map_Vars.emplace("kCCE", kCCE);
101  map_Vars.emplace("kMuE", kMuE);
102  map_Vars.emplace("kHadE", kHadE);
103  }
104  if(s_Selection.find("nue2020")!=std::string::npos){
105  map_Vars.emplace("kNueEnergy2020", kNueEnergy2020);
106  map_Vars.emplace("kNueElectronE2020", kNueElectronE2020);
107  map_Vars.emplace("kHADE2020", kHadE);
108  map_Vars.emplace("kLongestProng", kLongestProng);
109  }
110 
111  map_Vars.emplace("kNHit", kNHit);
112  map_Vars.emplace("kCaloE", kCaloE);
113  map_Vars.emplace("kSlcEff", kSlcEff);
114 
115  map_Vars.emplace("kSliceCount", kSliceCount);
116  map_Vars.emplace("kPOTWeight", kSpillPOTRatioWeight);
117  map_Vars.emplace("kSpillPOT", kSpillPOT);
118 
119  map_Vars.emplace(s_Selection.find("nue2020")!=std::string::npos ? "kTrueEben" : "kTrueE", kTrueE_OV);
120  map_Vars.emplace("kTrueElong", kTrueE_OV);
121  map_Vars.emplace("kTrueLepE", kTrueLepE_OV);
122  map_Vars.emplace("kTrueQ2", kTrueQ2_OV);
123  map_Vars.emplace("kTrueW2", kTrueW2_OV);
124  map_Vars.emplace("kTrueXbj", kTrueXbj_OV);
125  map_Vars.emplace("kTrueYbj", kTrueYbj_OV);
126  map_Vars.emplace("kOTrueVtxX", kOTrueVtxX_OV);
127  map_Vars.emplace("kOTrueVtxY", kOTrueVtxY_OV);
128  map_Vars.emplace("kOTrueVtxZ", kOTrueVtxZ_OV);
129  map_Vars.emplace("kMode", kOverlayMode_OV);
130  map_Vars.emplace("kIsCC", kIsCC_OV);
131  map_Vars.emplace("kPDG", kPDG_OV);
132 
133  map_Vars.emplace("kSlcNoiseFrac", kSlcNoiseFrac);
134  map_Vars.emplace("kSlcNoiseFracN", kSlcNoiseFracN);
135  map_Vars.emplace("kSlcNoiseFracPE", kSlcNoiseFracPE);
136 
137 
138  map_Vars.emplace("kSlcMeanTime", kSlcMeanTime);
139  map_Vars.emplace("kSlcStartTime", kSlcStartTime);
140  map_Vars.emplace("kSlcEndTime", kSlcEndTime);
141  map_Vars.emplace("kSliceDuration", kSliceDuration);
142 
143  map_Vars.emplace("kRun", kRun);
144  //map_Vars.emplace("kSubRun", kSubRun);
145  //map_Vars.emplace("kEvt", kEvt);
146  map_Vars.emplace("kSlc", kSlc);
147 
148  map_NuVars.emplace(s_Selection.find("nue2020")!=std::string::npos ? "kTrueEben_Nu" : "kTrueE_Nu", kTrueE_Nu);
149  map_NuVars.emplace("kTrueElong_Nu", kTrueE_Nu);
150  map_NuVars.emplace("kTrueLepE_Nu", kTrueLepE_Nu);
151  map_NuVars.emplace("kTrueQ2_Nu", kTrueQ2_Nu);
152  map_NuVars.emplace("kTrueW2_Nu", kTrueW2_Nu);
153  map_NuVars.emplace("kTrueXbj_Nu", kTrueXbj_Nu);
154  map_NuVars.emplace("kTrueYbj_Nu", kTrueYbj_Nu);
155  map_NuVars.emplace("kOTrueVtxX_Nu", kOTrueVtxX_Nu);
156  map_NuVars.emplace("kOTrueVtxY_Nu", kOTrueVtxY_Nu);
157  map_NuVars.emplace("kOTrueVtxZ_Nu", kOTrueVtxZ_Nu);
158  map_NuVars.emplace("kMode_Nu", kOverlayMode_Nu);
159  map_NuVars.emplace("kIsCC_Nu", kIsCC_Nu);
160  map_NuVars.emplace("kPDG_Nu", kPDG_Nu);
161  map_NuVars.emplace("kSpillPOTInNuTruth_Nu", kUselessVar_Nu);
162 
163  return;
164 }
165 
const Var kHadE
Definition: NumuVars.h:23
const NuTruthVar kOTrueVtxZ_Nu([](const caf::SRNeutrinoProxy *nu){return float(nu->vtx.z);})
Definition: OverlayVars.h:24
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const Var kIsCC_OV
Definition: OverlayVars.h:41
const Cut Containment_Cut(std::string s_Selection)
Definition: Helper.h:367
const Var kSlcMeanTime([](const caf::SRProxy *sr){return sr->slc.meantime/1000.;})
Definition: NumuVars.h:83
const Cut Sig_Cut(std::string s_Selection)
Definition: Helper.h:265
const Var kSlc
Definition: Vars.cxx:24
const NuTruthVar kTrueQ2_Nu([](const caf::SRNeutrinoProxy *nu){return float(nu->q2);})
Definition: OverlayVars.h:18
const NuTruthVar kTrueYbj_Nu([](const caf::SRNeutrinoProxy *nu){return float(nu->y);})
Definition: OverlayVars.h:21
const Var kSlcNoiseFracPE([](const caf::SRProxy *sr){return sr->slc.fracnoisePE;})
Definition: OverlayVars.h:47
const Var kTrueQ2_OV
Definition: OverlayVars.h:33
const NuTruthCut Sig_NuCut(std::string s_Selection)
Definition: Helper.h:332
const NuTruthVar kOTrueVtxX_Nu([](const caf::SRNeutrinoProxy *nu){return float(nu->vtx.x);})
Definition: OverlayVars.h:22
const Cut kAnaTrueECut_Numu
Definition: OverlayCuts.cxx:88
const NuTruthVar kUselessVar_Nu([](const caf::SRNeutrinoProxy *nu){return 0.;})
Definition: OverlayVars.h:28
const Var kTrueYbj_OV
Definition: OverlayVars.h:36
const NuTruthCut kAnaTrueECut_Nu_Nue([](const caf::SRNeutrinoProxy *nu){return(nu->E >=0.&&nu->E< 6.0);})
Definition: OverlayCuts.h:31
const Var kTrueLepE_OV
Definition: OverlayVars.h:32
const Var kSliceDuration([](const caf::SRProxy *sr){return(sr->slc.endtime-sr->slc.starttime);})
Definition: NumuVars.h:35
const Var kSliceCount([](const caf::SRProxy *sr){return 0.;})
Definition: OverlayVars.h:13
const Var kTrueXbj_OV
Definition: OverlayVars.h:35
const Var kPDG_OV
Definition: OverlayVars.h:42
const Cut kTrueOFiducialLoose
Definition: OverlayCuts.cxx:57
const NuTruthVar kOTrueVtxY_Nu([](const caf::SRNeutrinoProxy *nu){return float(nu->vtx.y);})
Definition: OverlayVars.h:23
const Var kOTrueVtxZ_OV
Definition: OverlayVars.h:39
void scheduleVars(std::map< std::string, const Var > &map_Vars, std::map< std::string, const NuTruthVar > &map_NuVars, std::string s_Selection)
Definition: Scheduling.h:97
const NuTruthCut kTrueOFiducial_Nu([](const caf::SRNeutrinoProxy *nu){return(nu->vtx.X()< ovtxmax.X()&& nu->vtx.X() > ovtxmin.X()&& nu->vtx.Y() > ovtxmin.Y()&& nu->vtx.Y()< ovtxmax.Y()&& nu->vtx.Z() > ovtxmin.Z()&& nu->vtx.Z()< ovtxmax.Z());})
Definition: OverlayCuts.h:13
const Var kLongestProng([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return 0.f;if(sr->vtx.elastic.fuzzyk.npng==0) return 0.f;auto idx=sr->vtx.elastic.fuzzyk.longestidx;return float(sr->vtx.elastic.fuzzyk.png[idx].len);})
Definition: Vars.h:89
const Cut Quality_Cut(std::string s_Selection)
Definition: Helper.h:351
const NuTruthVar kTrueLepE_Nu([](const caf::SRNeutrinoProxy *nu){return float(nu->prim[0].p.E);})
Definition: OverlayVars.h:17
const Var kCaloE
Summed calorimetric energy of all hits in slice, uncorrected.
Definition: Vars.cxx:52
const Var kSpillPOT
Return the POT for the spill.
Definition: SpillVars.cxx:33
const Var kSlcEff([](const caf::SRProxy *sr){for(int i=0;i< (int) sr->mc.nallnus;i++) if(sr->mc.allnus[i].mode > 9999||!sr->spill.ismc) return(float) sr->mc.allnus[i].eff;return-5.f;})
Definition: OverlayVars.h:48
const Var kNHit
Definition: Vars.cxx:71
const Var kCCE
Definition: NumuVars.h:21
const Var kSlcStartTime([](const caf::SRProxy *sr){return sr->slc.starttime/1000.;})
Definition: NumuVars.h:84
const Cut kAnaTrueECut_Nue
Definition: OverlayCuts.cxx:95
const Var kTrueW2_OV
Definition: OverlayVars.h:34
const NuTruthVar kTrueXbj_Nu([](const caf::SRNeutrinoProxy *nu){return float(nu->x);})
Definition: OverlayVars.h:20
const Cut kContainment([](const caf::SRProxy *sr){if(sr->mc.nnu==0) return false;if(sr->vtx.nelastic==0) return false;if(sr->vtx.elastic[0].fuzzyk.nshwlid==0) return false;if(sr->vtx.elastic[0].fuzzyk.npng==0) return false;for(unsigned int i=0;i< sr->vtx.elastic[0].fuzzyk.nshwlid;i++){if((sr->vtx.elastic[0].fuzzyk.png[i].shwlid.stop.x)< -160.0) return false;if((sr->vtx.elastic[0].fuzzyk.png[i].shwlid.stop.x) > 120.0) return false;if((sr->vtx.elastic[0].fuzzyk.png[i].shwlid.stop.y)< -180.0) return false;if((sr->vtx.elastic[0].fuzzyk.png[i].shwlid.stop.y) > 155.0) return false;if((sr->vtx.elastic[0].fuzzyk.png[i].shwlid.stop.z)< 200.0) return false;if((sr->vtx.elastic[0].fuzzyk.png[i].shwlid.stop.z) > 1200.0) return false;}return true;})
const NuTruthVar kTrueE_Nu([](const caf::SRNeutrinoProxy *nu){return float(nu->E);;})
Definition: OverlayVars.h:16
const Var kNueElectronE2020([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return-1000.f;if(sr->vtx.elastic.fuzzyk.npng< 1) return-1000.f;float x=sr->vtx.elastic.fuzzyk.png[0].calE;float energy=x;double a0, a1, a2, a3, a4, a5, a6;if(sr->hdr.det==caf::kFARDET){if(sr->spill.isRHC){a0=-0.727211;a1=2.319804;a2=-2.697100;a3=1.604802;a4=-0.493659;a5=0.075183;a6=-0.004478;}else{a0=-0.428873;a1=1.486957;a2=-1.772140;a3=1.114639;a4=-0.358208;a5=0.056065;a6=-0.003376;}}else{return energy;}if(x > 0) energy=x-(a0+a1 *x+a2 *pow(x, 2)+ a3 *pow(x, 3)+a4 *pow(x, 4)+ a5 *pow(x, 5)+a6 *pow(x, 6));if(energy< 0) energy=x;return energy;})
Definition: NueEnergy2020.h:41
const Var kSlcNoiseFrac([](const caf::SRProxy *sr){return sr->slc.fracnoiseE;})
Definition: OverlayVars.h:45
const NuTruthVar kPDG_Nu([](const caf::SRNeutrinoProxy *nu){return float(nu->pdg);})
Definition: OverlayVars.h:27
const NuTruthVar kIsCC_Nu([](const caf::SRNeutrinoProxy *nu){return float(nu->iscc);})
Definition: OverlayVars.h:26
const Var kSlcNoiseFracN([](const caf::SRProxy *sr){return 1.*sr->slc.nnoisehit/sr->slc.ncalhit;})
Definition: OverlayVars.h:46
const Var kNueEnergy2020([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return-1.0;if(sr->vtx.elastic.fuzzyk.npng< 1) return-1.0;if(kIsRHC(sr)) return kNueEnergyRHC2020(sr);else return kNueEnergyFHC2020(sr);})
Nue energy with 3d prong info. only (old version of vars)
Definition: NueEnergy2020.h:38
const Var kOverlayMode_OV
Definition: OverlayVars.h:40
const NuTruthVar kOverlayMode_Nu([](const caf::SRNeutrinoProxy *nu){return(nu->mode >9999)?(float) nu->mode-10000.:(float) nu->mode;})
Definition: OverlayVars.h:25
const Var kSpillPOTRatioWeight([](const caf::SRProxy *sr){const double centralValue=40.e12;return sr->spill.spillpot/centralValue;})
Definition: OverlayVars.h:12
const Var kSlcEndTime([](const caf::SRProxy *sr){return sr->slc.endtime/1000.;})
Definition: NumuVars.h:85
const NuTruthCut kTrueOFiducialLoose_Nu([](const caf::SRNeutrinoProxy *nu){return(nu->vtx.X()< ovtxmaxLoose.X()&& nu->vtx.X() > ovtxminLoose.X()&& nu->vtx.Y() > ovtxminLoose.Y()&& nu->vtx.Y()< ovtxmaxLoose.Y()&& nu->vtx.Z() > ovtxminLoose.Z()&& nu->vtx.Z()< ovtxmaxLoose.Z());})
Definition: OverlayCuts.h:16
const Var kOTrueVtxY_OV
Definition: OverlayVars.h:38
const Cut Presel_Cut(std::string s_Selection)
Definition: Helper.h:383
void furtherBENBreakdown(std::map< std::string, const Cut > &map_Cuts, Cut kBaseCut)
Definition: Helper.h:597
Definition: Helper.h:14
const NuTruthVar kTrueW2_Nu([](const caf::SRNeutrinoProxy *nu){return float(nu->W2);})
Definition: OverlayVars.h:19
const Var kRun
Definition: Vars.cxx:20
const Cut kTrueOFiducial
Definition: OverlayCuts.cxx:44
const Var kMuE
Definition: NumuVars.h:22
const Var kOTrueVtxX_OV
Definition: OverlayVars.h:37
void scheduleCuts(std::map< std::string, const Cut > &map_Cuts, std::map< std::string, const NuTruthCut > &map_NuCuts, const Cut kOverlaid, const NuTruthCut kOverlaid_Nu, std::string const &s_Selection, bool isNominal=false, bool getDetailed=false, bool loosePresel=false)
Definition: Scheduling.h:16
const Var kTrueE_OV
Definition: OverlayVars.h:31
const NuTruthCut kAnaTrueECut_Nu_Numu([](const caf::SRNeutrinoProxy *nu){return(nu->E >=0.&&nu->E< 7.);})
Definition: OverlayCuts.h:28
const Cut Selection_Cut(std::string s_Selection)
Definition: Helper.h:399
enum BeamMode string