All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
XSecSelection/eventsel.h
Go to the documentation of this file.
2 #include "sbnanaobj/StandardRecord/Proxy/SRProxy.h"
3 
11 
12 using namespace ana;
13 
14 
15 // Useful for counting the number of events that pass a cut
16 const Var kCounting_scale([](const caf::SRSliceProxy *slc)
17  {
18  double count = 6e20/3.08823e19;
19  return count;
20  });
21 
22 // Costh of the numu primary track (See Vars/NumuVars.cxx)
23 const Var kPrimTrkCosth([](const caf::SRSliceProxy *slc)
24  {
25  int muIdx = kPrimMuonIdx(slc);
26  if( muIdx < 0 ) return -5.;
27 
28  return (double)slc->reco.trk[muIdx].costh;
29  });
30 
31 // Costh of the numu primary track (See Vars/NumuVars.cxx)
32 const Var kPrimTrkCRTdist([](const caf::SRSliceProxy *slc)
33  {
34  int muIdx = kPrimMuonIdx(slc);
35  if( muIdx < 0 ) return -5.;
36 
37  return (double)slc->reco.trk[muIdx].crthit.distance;
38  });
39 
40 
41 // These are examples of useful structs to
42 // use when making a bunch of Spectra
43 struct PlotDef
44 {
45  std::string suffix = "";
46  std::string label = "";
47  Binning bins = Binning::Simple(3,0,3);
48  Var var = kCounting;
49 };
50 
51 // In this example, we are making the following Spectra
52 std::vector<PlotDef> plots =
53  {{"count", "", Binning::Simple(3,0,3), kCounting},
54  {"count_scale", "", Binning::Simple(3,0,3), kCounting_scale},
55  {"mucosth", "cos#theta", Binning::Simple(50,-1,1), kPrimTrkCosth},
56  {"vtxx", "X (cm)", Binning::Simple(50,-200,200), kSlcVtxX},
57  {"vtxy", "Y (cm)", Binning::Simple(50,-200,200), kSlcVtxY},
58  {"vtxz", "Z (cm)", Binning::Simple(50,0,500), kSlcVtxZ},
59  {"mulen", "Primary Track Length", Binning::Simple(50,0,200), kPrimTrkLen},
60  {"mucrtdist", "Primary Track Distance to CRT hit", Binning::Simple(50,0,100), kPrimTrkCRTdist},
61  {"CRTangle", "CRT Track Angle", Binning::Simple(20,0,1), kCRTTrkAngle},
62  {"CRTHitTime", "CRT Hit Time", Binning::Simple(20,0,100), kCRTTrkTime},
63  {"CRTHitDist", "CRT Hit Distance", Binning::Simple(20,0,100), kCRTHitDist},
64  {"muonprimtrkp", "Primary Track Momentum", Binning::Simple(24,0,2), kPrimaryMuonTrkP},
65  {"muonprimtrklen", "Primary Track Lenght", Binning::Simple(18,40,400), kPrimaryMuonTrkLen},
66  //{"flashmatch", "Flash Score", Binning::Simple(25,0,25), kSlcHasFlashMatch},
67  {"nuscore", "Pandora Nu Score", Binning::Simple(25,0,1), kNuScore},
68  };
69 
70 // Selection Struc
71 struct SelDef
72 {
73  std::string suffix = "";
74  std::string label = "";
75  Cut cut = kNoCut;
76  int color = kBlack;
77 };
78 
79 //const Cut kIsNuSlice = ( kTruthIndex >= 0.f );
80 //const Cut kIsNuSlice = kIsNumu && !kIsNC;
81 const Cut kIsNuSlice([](const caf::SRSliceProxy* slc) {
82  return (slc->truth.index >= 0 );
83  });
84 const Cut kIsCosmic = ( !kIsNuSlice );
85 const Cut kIsNuMuCC([](const caf::SRSliceProxy* slc) {
86  return ( kIsNuSlice(slc) && slc->truth.iscc && ( slc->truth.pdg == 14 || slc->truth.pdg == -14 ) );
87  });
89 
105 
106 // We are making the Spectra defined above
107 std::vector<SelDef> sels =
108  {{"nocut_numucc", "All Slices", kNoCut_numucc, kRed},
109  {"nocut_cosmic", "All Slices", kNoCut_cosmic, kRed+1},
110  {"nocut_othernu", "All Slices", kNoCut_othernu, kRed+2},
111  {"PreSel_numucc", "PreSel", kPreSelection_numucc, kOrange+7},
112  {"PreSel_cosmic", "PreSel", kPreSelection_cosmic, kOrange+6},
113  {"PreSel_othernu", "PreSel", kPreSelection_othernu, kOrange+5},
114  {"FMatch_numucc", "PreSel+FlashM", kFlashMatching_numucc, kMagenta-4},
115  {"FMatch_cosmic", "PreSel+FlashM", kFlashMatching_cosmic, kMagenta-3},
116  {"FMatch_othernu", "PreSel+FlashM", kFlashMatching_othernu, kMagenta-2},
117  {"Mtrk_numucc", "PreSel+FlashM+MuonID", kMuonTrk_numucc, kCyan-7},
118  {"Mtrk_cosmic", "PreSel+FlashM+MuonID", kMuonTrk_cosmic, kCyan-6},
119  {"Mtrk_othernu", "PreSel+FlashM+MuonID", kMuonTrk_othernu, kCyan-5},
120  {"all_numucc", "PreSel+FlashM+MuonID+CRT", kALLCuts_numucc, kGreen+2},
121  {"all_cosmic", "PreSel+FlashM+MuonID+CRT", kALLCuts_cosmic, kGreen+3},
122  {"all_othernu", "PreSel+FlashM+MuonID+CRT", kALLCuts_othernu, kGreen+4},
123  };
124 
125 // If you wanted to add a new cut, define an
126 // expression for kYourCut (see examples in SBNAna/Cuts)
127 // and then add the following lines to the sels vector:
128 /* {"all_yourcut", "All Slices", kYourCut, kBlack}, */
129 /* {"sig_yourcut", "True NumuCC", (kSig && kYourCut), kRed+1}, */
130 /* {"bkg_yourcut", "Not NumuCC", (!kSig && kYourCut), kAzure+2}, */
const Cut kIsNuMuCC([](const caf::SRSliceProxy *slc){return(kIsNuSlice(slc)&&slc->truth.iscc &&(slc->truth.pdg==14||slc->truth.pdg==-14));})
const Var kCounting_scale([](const caf::SRSliceProxy *slc){double count=6e20/3.08823e19;return count;})
const Cut kNoCut([](const caf::SRSliceProxy *){return true;})
The simplest possible cut: pass everything, used as a default.
const Cut kSlcFlashMatchTimeCut([](const caf::SRSliceProxy *slc){if(std::isnan(slc->fmatch.time)) return false;bool InBeam=(slc->fmatch.time > 0.&&slc->fmatch.time< 1.800);return(InBeam);})
Represent the binning of a Spectrum&#39;s x-axis.
Definition: Binning.h:18
const Cut kMuonTrk_cosmic
const Cut kIsNuSlice
const Cut kNoCut_numucc
const Cut kFlashMatching_numucc
const Cut kMuonTrk_othernu
const Var kPrimMuonIdx([](const caf::SRSliceProxy *slc) -> double{if((int) slc->reco.ntrk==0) return-5.0;double best_idx=0;double best_len=-5.0;for(unsigned int trkIdx=0;trkIdx< slc->reco.ntrk;trkIdx++){auto &trk=slc->reco.trk[trkIdx];if(trk.chi2pid[2].pid_ndof< 0) return-5.0;bool isMuonLike=trk.chi2pid[2].chi2_pion > trk.chi2pid[2].chi2_muon;if(isMuonLike &&trk.len > best_len){best_len=trk.len;best_idx=trkIdx;}}return best_idx;})
Definition: NumuVars.h:11
const Cut kHasPrimaryMuonTrk([](const caf::SRSliceProxy *slc){int ptrkid=kPrimaryMuonTrkIdx(slc);double ptrkrecop=kPrimaryMuonTrkP(slc);return(ptrkid!=-1 &&!isnan(ptrkrecop)&&ptrkrecop > 0.&&ptrkrecop< 7.5);})
const Cut kALLCuts_cosmic
const Var kCRTTrkAngle([](const caf::SRSliceProxy *slc) -> double{float crttrkangle(-5.f);if(kPrimaryMuonTrkIdx(slc) >=0){int ptrkid=kPrimaryMuonTrkIdx(slc);const caf::SRTrackProxy &ptrk=slc->reco.trk[ptrkid];crttrkangle=ptrk.crttrack.angle;}return crttrkangle;})
const Cut kNoCut_cosmic
const Cut kNuScore([](const caf::SRSliceProxy *slc){return(!isnan(slc->nu_score)&&slc->nu_score > 0.4);})
const Cut kPreSelection_othernu
process_name opflashCryoW ana
const Cut kIsNuOther
const Cut kMuonTrk_numucc
caf::Proxy< caf::SRSlice > SRSliceProxy
Definition: EpilogFwd.h:2
const Var kCRTTrkTime([](const caf::SRSliceProxy *slc) -> double{float crttrktime(-5.f);if(kPrimaryMuonTrkIdx(slc) >=0){int ptrkid=kPrimaryMuonTrkIdx(slc);const caf::SRTrackProxy &ptrk=slc->reco.trk[ptrkid];crttrktime=ptrk.crthit.hit.time;}return crttrktime;})
const Var kSlcVtxX([](const caf::SRSliceProxy *slc) -> double{return slc->vertex.x;})
Definition: Vars.h:30
const Var kSlcVtxY([](const caf::SRSliceProxy *slc) -> double{return slc->vertex.y;})
Definition: Vars.h:31
const Cut kFlashMatching_othernu
Definition: demo.h:63
const Var kPrimTrkCRTdist([](const caf::SRSliceProxy *slc){int muIdx=kPrimMuonIdx(slc);if(muIdx< 0) return-5.;return(double) slc->reco.trk[muIdx].crthit.distance;})
const Cut kCRTTrackAngleCut([](const caf::SRSliceProxy *slc){int ptrkid=kPrimaryMuonTrkIdx(slc);const caf::SRTrackProxy &ptrk=slc->reco.trk[ptrkid];return(isnan(ptrk.crttrack.angle)||ptrk.crttrack.angle > 0.05);})
const Var kPrimaryMuonTrkLen([](const caf::SRSliceProxy *slc) -> double{float ptrklen(-5.f);if(kPrimaryMuonTrkIdx(slc) >=0){int ptrkid=kPrimaryMuonTrkIdx(slc);const caf::SRTrackProxy &ptrk=slc->reco.trk[ptrkid];ptrklen=ptrk.len;}return ptrklen;})
const Var kSlcVtxZ([](const caf::SRSliceProxy *slc) -> double{return slc->vertex.z;})
Definition: Vars.h:32
const Cut kIsCosmic
const Cut kNoCut_othernu
std::vector< PlotDef > plots
Definition: demo.h:54
const Cut kSlcNuScoreCut([](const caf::SRSliceProxy *slc){return(kSlcIsRecoNu(slc)&&slc->nu_score >0.4);})
const Var kPrimTrkCosth([](const caf::SRSliceProxy *slc) -> double{int muIdx=kPrimMuonIdx(slc);if(muIdx< 0) return-5.;return(double) slc->reco.trk[muIdx].costh;})
const Cut kALLCuts_othernu
const Cut kPreSelection_cosmic
const Var kPrimaryMuonTrkP([](const caf::SRSliceProxy *slc){float recop(-5.f);bool contained(false);if(kPrimaryMuonTrkIdx(slc) >=0){auto const &ptrk=slc->reco.trk.at(kPrimaryMuonTrkIdx(slc));contained=((-199.15+10)< ptrk.end.x &&ptrk.end.x< (199.15-10)&&(-200.+10)< ptrk.end.y &&ptrk.end.y< (200.-10)&&(0.0+10)< ptrk.end.z &&ptrk.end.z< (500.-50));if(contained) recop=ptrk.rangeP.p_muon;else recop=ptrk.mcsP.fwdP_muon;}return recop;})
std::vector< SelDef > sels
Definition: demo.h:77
const Cut kPreSelection_numucc
const Cut kCRTHitDistanceCut([](const caf::SRSliceProxy *slc){int ptrkid=kPrimaryMuonTrkIdx(slc);const caf::SRCRTHitMatchProxy &crthit=slc->reco.trk[ptrkid].crthit;if(std::isnan(crthit.hit.time)||std::isnan(crthit.distance)) return true;return crthit.distance > 5||(crthit.hit.time > 0.&&crthit.hit.time< 1.800);})
Definition: demo.h:45
const Var kPrimTrkLen([](const caf::SRSliceProxy *slc) -> double{double len=-5.0;if(slc->reco.ntrk > 0){int muIdx=(int) kPrimMuonIdx(slc);if(muIdx >=0){len=slc->reco.trk[muIdx].len;}}return len;})
Definition: NumuVars.h:9
const Var kCounting
Definition: Vars.cxx:19
const Cut kALLCuts_numucc
const Cut kSlcFlashMatchScoreCut([](const caf::SRSliceProxy *slc){return(slc->fmatch.score< 7);})
const Var kCRTHitDist([](const caf::SRSliceProxy *slc) -> double{float crttrkdist(-5.f);if(kPrimaryMuonTrkIdx(slc) >=0){int ptrkid=kPrimaryMuonTrkIdx(slc);const caf::SRTrackProxy &ptrk=slc->reco.trk[ptrkid];crttrkdist=ptrk.crthit.distance;}return crttrkdist;})
std::size_t count(Cont const &cont)
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:38
const Cut kFlashMatching_cosmic
const Cut kInFV([](const caf::SRSliceProxy *slc){return(slc->vertex.x >(-199.15+10)&&slc->vertex.x< (199.15-10)&&slc->vertex.y >(-200.+10)&&slc->vertex.y< (200.-10)&&slc->vertex.z >(0.0+10)&&slc->vertex.z< (500.-50));})