All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AnaBasics/eventsel.h
Go to the documentation of this file.
2 #include "sbnanaobj/StandardRecord/Proxy/SRProxy.h"
3 
4 #include "SBNAna/Vars/Vars.h"
5 #include "SBNAna/Vars/NumuVars.h"
6 #include "SBNAna/Cuts/NumuCuts.h"
8 
9 using namespace ana;
10 
11 
12 // Useful for counting the number of events that pass a cut
13 const Var kCounting([](const caf::SRSliceProxy *slc)
14  {
15  return 1;
16  });
17 
18 // Costh of the numu primary track (See Vars/NumuVars.cxx)
19 const Var kPrimTrkCosth([](const caf::SRSliceProxy *slc)
20  {
21  int muIdx = kPrimMuonIdx(slc);
22  if( muIdx < 0 ) return -5.;
23 
24  return (double)slc->reco.trk[muIdx].costh;
25  });
26 
27 // Costh of the numu primary track (See Vars/NumuVars.cxx)
28 const Var kPrimTrkCRTdist([](const caf::SRSliceProxy *slc)
29  {
30  int muIdx = kPrimMuonIdx(slc);
31  if( muIdx < 0 ) return -5.;
32 
33  return (double)slc->reco.trk[muIdx].crthit.distance;
34  });
35 
36 
37 // These are examples of useful structs to
38 // use when making a bunch of Spectra
39 struct PlotDef
40 {
41  std::string suffix = "";
42  std::string label = "";
43  Binning bins = Binning::Simple(3,0,3);
44  Var var = kCounting;
45 };
46 
47 // In this example, we are making the following Spectra
48 std::vector<PlotDef> plots =
49  {{"count", "", Binning::Simple(3,0,3), kCounting},
50  {"mucosth", "cos#theta", Binning::Simple(50,-1,1), kPrimTrkCosth},
51  {"vtxx", "X (cm)", Binning::Simple(50,-200,200), kSlcVtxX},
52  {"vtxy", "Y (cm)", Binning::Simple(50,-200,200), kSlcVtxY},
53  {"vtxz", "Z (cm)", Binning::Simple(50,0,500), kSlcVtxZ},
54  {"mulen", "Primary Track Length", Binning::Simple(50,0,200), kPrimTrkLen},
55  {"mucrtdist", "Primary Track Distance to CRT hit", Binning::Simple(50,0,100), kPrimTrkCRTdist},
56  };
57 
58 // Selection Struc
59 struct SelDef
60 {
61  std::string suffix = "";
62  std::string label = "";
63  Cut cut = kNoCut;
64  int color = kBlack;
65 };
66 
67 // In this example, our signal is Numu cc
68 // See Cuts/TruthCuts to check out these cuts
69 const Cut kSig = kIsNumu && !kIsNC;
70 
71 // We are making the Spectra defined above
72 // for 3 different selections.
73 std::vector<SelDef> sels =
74  {{"nocut", "All Slices", kNoCut, kBlack},
75  {"sig", "True NumuCC", kSig, kRed+1},
76  {"bkg", "Not NumuCC", !kSig, kAzure+2},
77  };
78 
79 // If you wanted to add a new cut, define an
80 // expression for kYourCut (see examples in SBNAna/Cuts)
81 // and then add the following lines to the sels vector:
82 /* {"all_yourcut", "All Slices", kYourCut, kBlack}, */
83 /* {"sig_yourcut", "True NumuCC", (kSig && kYourCut), kRed+1}, */
84 /* {"bkg_yourcut", "Not NumuCC", (!kSig && kYourCut), kAzure+2}, */
const Cut kNoCut([](const caf::SRSliceProxy *){return true;})
The simplest possible cut: pass everything, used as a default.
const Cut kIsNC([](const caf::SRSliceProxy *slc){return kHasMatchedNu(slc)&&slc->truth.isnc;})
Is this a Neutral Current event?
Represent the binning of a Spectrum&#39;s x-axis.
Definition: Binning.h:18
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
process_name opflashCryoW ana
caf::Proxy< caf::SRSlice > SRSliceProxy
Definition: EpilogFwd.h:2
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
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 kSig
Definition: demo.h:73
const Var kSlcVtxZ([](const caf::SRSliceProxy *slc) -> double{return slc->vertex.z;})
Definition: Vars.h:32
const Cut kIsNumu([](const caf::SRSliceProxy *slc){return slc->truth.index >=0 &&abs(slc->truth.pdg)==14;})
std::vector< PlotDef > plots
Definition: demo.h:54
const Var kPrimTrkCosth([](const caf::SRSliceProxy *slc) -> double{int muIdx=kPrimMuonIdx(slc);if(muIdx< 0) return-5.;return(double) slc->reco.trk[muIdx].costh;})
std::vector< SelDef > sels
Definition: demo.h:77
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
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:38