All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
helper_eff_spill.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "helper.h"
4 
5 using namespace ana;
6 
7 const SpillVar kLeptonEnergy([](const caf::SRSpillProxy* sr) {
8  if (sr->mc.nnu != 1)
9  return -5.f;
10 
11  for (auto const& prim : sr->mc.nu[0].prim) {
12  if (std::abs(prim.pdg) != 11 && std::abs(prim.pdg) != 13)
13  continue;
14 
15  return (float)prim.startE;
16  }
17  return -5.f;
18 });
19 
20 const SpillCut kCosmicSpill([](const caf::SRSpillProxy* sr) {
21  return (sr->mc.nnu == 0);
22 });
23 
24 const SpillCut kSpillTrueNuFV([](const caf::SRSpillProxy* sr) {
25  if (kCosmicSpill(sr))
26  return true;
27 
28  if (!kSpillSingleNu(sr))
29  return false;
30 
31  return PtInVolAbsX(sr->mc.nu[0].position, fvndAbs);
32 });
33 
34 const SpillCut kSpillNuEEnergyCut([](const caf::SRSpillProxy* sr) {
35  if (kCosmicSpill(sr) || !(std::abs(sr->mc.nu[0].pdg) == 12 && sr->mc.nu[0].iscc))
36  return true;
37 
38  for (auto const& prim : sr->mc.nu[0].prim) {
39  if (std::abs(prim.pdg) != 11)
40  continue;
41 
42  if (prim.startE > 0.2)
43  return true;
44  }
45 
46  return false;
47 });
48 
49 const SpillCut kNuECCSpill([](const caf::SRSpillProxy* sr) {
50  if (kCosmicSpill(sr) || !kSpillSingleNu(sr))
51  return false;
52 
53  return (std::abs(sr->mc.nu[0].pdg) == 12 && sr->mc.nu[0].iscc && PtInVolAbsX(sr->mc.nu[0].position, fvndAbs) && kSpillNuEEnergyCut(sr));
54 });
55 
56 const SpillCut kNuMuCCSpill([](const caf::SRSpillProxy* sr) {
57  if (kCosmicSpill(sr) || !kSpillSingleNu(sr))
58  return false;
59  return (std::abs(sr->mc.nu[0].pdg) == 14 && sr->mc.nu[0].iscc && PtInVolAbsX(sr->mc.nu[0].position, fvndAbs));
60 });
61 
62 const SpillCut kNCSpill([](const caf::SRSpillProxy* sr) {
63  if (kCosmicSpill(sr) || !kSpillSingleNu(sr))
64  return false;
65  return ((bool)sr->mc.nu[0].isnc && PtInVolAbsX(sr->mc.nu[0].position, fvndAbs));
66 });
67 
68 const SpillCut kOtherNuSpill([](const caf::SRSpillProxy* sr) {
69  return (kSpillSingleNu(sr) && !(kCosmicSpill(sr) || kNuECCSpill(sr) || kNuMuCCSpill(sr) || kNCSpill(sr)));
70 });
71 
72 struct PlotDef {
73  std::string suffix = "";
74  std::string label = "";
75  Binning bins = Binning::Simple(3, 0, 3);
77 };
78 
79 const Binning kBDTBinning = Binning::Simple(40, 0, 1.0);
80 const Binning kEnergyBinningGeV = Binning::Simple(30, 0, 3);
81 const Binning kdEdxBinning = Binning::Simple(40, 0, 10);
82 const Binning kGapBinning = Binning::Simple(20, 0, 10);
83 const Binning kDensityBinning = Binning::Simple(20, 0., 20);
84 const Binning kOpenAngleBinning = Binning::Simple(20, 0., 1);
85 const Binning kLengthBinning = Binning::Simple(42, -5.01, 100);
86 const Binning kPEBinning = Binning::Simple(70, 0., 1400);
87 const Binning kTimeBinning = Binning::Simple(70, -3500, 3500);
88 const Binning kFlashBinning = Binning::Simple(40, -6.f, 34.f);
89 
90 std::vector<PlotDef> plots = {
91  { "count", "", Binning::Simple(3, 0, 3), kSpillCounting },
92  { "nuEnergy", "True Neutrino Energy [GeV]", kEnergyBinningGeV, kNuEnergy },
93  { "leptonEnergy", "True Lepton Energy [GeV]", kEnergyBinningGeV, kLeptonEnergy }
94 };
95 
96 struct SelDef {
97  std::string suffix = "";
98  std::string label = "";
100  int color = kBlack;
101 };
102 
103 const SpillCut kSpillVtxDistCut([](const caf::SRSpillProxy* sr) {
104  if (kCosmicSpill(sr))
105  return true;
106 
107  unsigned int counter(0);
108  for (auto const& slc : sr->slc) {
109  if (slc.tmatch.index < 0 || !kSlcIsRecoNu(&slc))
110  continue;
111  if (kVtxDistMagCut(&slc))
112  ++counter;
113  }
114 
115  return (bool)counter;
116 });
117 
119 // const Cut kSpillPreSelSlc = kSlcIsRecoNu && kPreNueSelND && kRecoComp;
120 
121 const SpillCut kSpillPreSel([](const caf::SRSpillProxy* sr) {
122 
123  unsigned int counter(0);
124  for (auto const& slc : sr->slc) {
125  if (slc.tmatch.index < 0)
126  continue;
127  if (kPreNueSelND(&slc))
128  ++counter;
129  }
130 
131  return counter;
132 });
133 
134 const SpillCut kSpillRecoSel([](const caf::SRSpillProxy* sr) {
135 
136  unsigned int counter(0);
137  for (auto const& slc : sr->slc) {
138  if (slc.tmatch.index < 0)
139  continue;
140  if (kPreNueSelND(&slc) && kRecoNueSel(&slc))
141  ++counter;
142  }
143 
144  return counter;
145 });
146 
147 const SpillCut kSpillFullSel([](const caf::SRSpillProxy* sr) {
148 
149  unsigned int counter(0);
150  for (auto const& slc : sr->slc) {
151  if (slc.tmatch.index < 0)
152  continue;
153  if (kPreNueSelND(&slc) && kRecoNueSel(&slc) && kFullNueSel(&slc))
154  ++counter;
155  }
156 
157  return counter;
158 });
159 
160 std::vector<SelDef> types = {
161  { "nuecc", "NuE CC", kNuECCSpill, kBlue + 1 },
162  { "numucc", "NuMu CC", kNuMuCCSpill, kRed + 1 },
163  { "nunc", "NC", kNCSpill, kOrange },
164  { "othernu", "Other Nu", kOtherNuSpill, kOrange },
165  // { "cosmic", "Cosmic", kCosmicSpill, kBlack },
166 };
167 
168 // const SpillCut kNuESpillTruthCuts = kSpillSingleNu; //&& kSpillNuEEnergyCut
169 const SpillCut kNuESpillTruthCuts = kSpillVtxDistCut && kSpillSingleNu; //&& kSpillNuEEnergyCut
170 
171 std::vector<SelDef> sels = {
172  { "spill_trueshowerenergy", "True Shower Energy", kNuESpillTruthCuts, kBlue },
173  { "spill_crtVeto", "CRT Veto", kNuESpillTruthCuts&& kCRTHitVetoND, kBlue },
174  { "spill_presel", "Pre Selection", kNuESpillTruthCuts&& kCRTHitVetoND&& kSpillPreSel, kBlue },
175  { "spill_recosel", "Reco Selection", kNuESpillTruthCuts&& kCRTHitVetoND&& kSpillRecoSel, kBlue },
176  { "spill_fullsel", "Full Selection", kNuESpillTruthCuts&& kCRTHitVetoND&& kSpillFullSel, kBlue },
177 };
const Binning kLengthBinning
const SpillCut kSpillTrueNuFV([](const caf::SRSpillProxy *sr){return true;return false;return PtInVolAbsX(sr->mc.nu[0].position, fvndAbs);})
const Cut kSlcCompletenessCut([](const caf::SRSliceProxy *slc){if(slc->truth.index< 0) return false;return(kCompletness(slc) > 0.5);})
then if[["$THISISATEST"==1]]
Definition: neoSmazza.sh:95
Represent the binning of a Spectrum&#39;s x-axis.
Definition: Binning.h:18
const Binning kTimeBinning
const SpillCut kSpillSingleNu([](const caf::SRSpillProxy *sr){return(sr->mc.nnu< 2);})
const Binning kDensityBinning
bool PtInVolAbsX(const caf::SRVector3DProxy &pt, const FidVol &vol)
const SpillCut kNCSpill
const Cut kPreNueSelND
Definition: NueCuts.h:36
const SpillCut kSpillPreSel([](const caf::SRSpillProxy *sr){unsigned int counter(0);for(auto const &slc:sr->slc){continue;++counter;}return counter;})
const SpillCut kSpillNuEEnergyCut([](const caf::SRSpillProxy *sr){if(kCosmicSpill(sr)||!(std::abs(sr->mc.nu[0].pdg)==12 &&sr->mc.nu[0].iscc)) return true;for(auto const &prim:sr->mc.nu[0].prim){continue;return true;}return false;})
const Cut kSpillPreSelSlc
const Binning kOpenAngleBinning
process_name opflashCryoW ana
const SpillCut kNuMuCCSpill([](const caf::SRSpillProxy *sr){if(kCosmicSpill(sr)||!kSpillSingleNu(sr)) return false;return(std::abs(sr->mc.nu[0].pdg)==14 &&sr->mc.nu[0].iscc &&PtInVolAbsX(sr->mc.nu[0].position, fvndAbs));})
const Binning kBDTBinning
const SpillCut kCRTHitVetoND([](const caf::SRSpillProxy *sr){for(auto const &crtHit:sr->crt_hits){return false;}return true;})
const SpillVar kLeptonEnergy([](const caf::SRSpillProxy *sr){return-5.f;for(auto const &prim:sr->mc.nu[0].prim){if(std::abs(prim.pdg)!=11 &&std::abs(prim.pdg)!=13) continue;return(float) prim.startE;}return-5.f;})
const Binning kdEdxBinning
const Binning kEnergyBinningGeV
int color
Definition: demo.h:68
Definition: demo.h:63
const Cut kFullNueSel
Definition: NueCuts.h:38
const SpillCut kOtherNuSpill([](const caf::SRSpillProxy *sr){return(kSpillSingleNu(sr)&&!(kCosmicSpill(sr)||kNuECCSpill(sr)||kNuMuCCSpill(sr)||kNCSpill(sr)));})
T abs(T value)
std::string label
Definition: demo.h:66
const SpillCut kCosmicSpill([](const caf::SRSpillProxy *sr){return(sr->mc.nnu==0);})
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
Definition: counter.h:285
const Cut kSlcIsRecoNu([](const caf::SRSliceProxy *slc){return!slc->is_clear_cosmic;})
std::vector< SelDef > types
Cut cut
Definition: demo.h:67
Var var
Definition: demo.h:50
for($it=0;$it< $RaceTrack_number;$it++)
caf::Proxy< caf::StandardRecord > SRSpillProxy
Definition: EpilogFwd.h:3
const Binning kPEBinning
std::string suffix
Definition: demo.h:65
std::vector< PlotDef > plots
Definition: demo.h:54
const SpillCut kNoSpillCut([](const caf::SRSpillProxy *){return true;})
The simplest possible cut: pass everything, used as a default.
const SpillVar kNuEnergy([](const caf::SRSpillProxy *sr){float energy=(sr->mc.nnu!=1?-5.f:(float) sr->mc.nu[0].E);return energy;})
std::vector< SelDef > sels
Definition: demo.h:77
std::string label
Definition: demo.h:48
const Cut kRecoNueSel
Definition: NueCuts.h:37
const SpillCut kNuESpillTruthCuts
const SpillCut kSpillRecoSel([](const caf::SRSpillProxy *sr){unsigned int counter(0);for(auto const &slc:sr->slc){continue;if(kPreNueSelND(&slc)&&kRecoNueSel(&slc))++counter;}return counter;})
Definition: demo.h:45
const SpillCut kSpillVtxDistCut([](const caf::SRSpillProxy *sr){return true;unsigned int counter(0);for(auto const &slc:sr->slc){continue;++counter;}return(bool) counter;})
const Binning kGapBinning
const SpillCut kNuECCSpill([](const caf::SRSpillProxy *sr){if(kCosmicSpill(sr)||!kSpillSingleNu(sr)) return false;return(std::abs(sr->mc.nu[0].pdg)==12 &&sr->mc.nu[0].iscc &&PtInVolAbsX(sr->mc.nu[0].position, fvndAbs)&&kSpillNuEEnergyCut(sr));})
const Binning kFlashBinning
const SpillVar kSpillCounting
Definition: Vars.cxx:20
std::string suffix
Definition: demo.h:47
Most useful for combining weights.
Definition: Var.h:23
const FidVol fvndAbs
const SpillCut kSpillFullSel([](const caf::SRSpillProxy *sr){unsigned int counter(0);for(auto const &slc:sr->slc){continue;if(kPreNueSelND(&slc)&&kRecoNueSel(&slc)&&kFullNueSel(&slc))++counter;}return counter;})
const Cut kVtxDistMagCut([](const caf::SRSliceProxy *slc){if(slc->truth.index< 0) return true;return(kTruthVtxDistMag(slc)< 1);})
Binning bins
Definition: demo.h:49