All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
demo.h
Go to the documentation of this file.
2 #include "sbnanaobj/StandardRecord/Proxy/SRProxy.h"
3 
4 #include "SBNAna/Vars/NumuVars.h"
6 
7 using namespace ana;
8 
9 // A Var is a little snippet of code that takes a "proxy" representing the
10 // event record and returns a single number to plot
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) -> double
20  {
21  int muIdx = kPrimMuonIdx(slc);
22  if( muIdx < 0 ) return -5.;
23 
24  return (double)slc->reco.trk[muIdx].costh;
25  });
26 
27 // Slice Vertex position
28 const Var kSlcVtxX([](const caf::SRSliceProxy *slc) -> double
29  {
30  return slc->slc.vertex.x;
31  });
32 
33 const Var kSlcVtxY([](const caf::SRSliceProxy *slc) -> double
34  {
35  return slc->slc.vertex.y;
36  });
37 
38 const Var kSlcVtxZ([](const caf::SRSliceProxy *slc) -> double
39  {
40  return slc->slc.vertex.z;
41  });
42 
43 // These are examples of useful structs to
44 // use when making a bunch of Spectra
45 struct PlotDef
46 {
47  std::string suffix = "";
48  std::string label = "";
49  Binning bins = Binning::Simple(3,0,3);
50  Var var = kCounting;
51 };
52 
53 // In this example, we are making the following Spectra
54 std::vector<PlotDef> plots =
55  {{"count", "", Binning::Simple(3,0,3), kCounting},
56  {"mucosth", "cos#theta", Binning::Simple(10,-1,1), kPrimTrkCosth},
57  {"vtxx", "X (cm)", Binning::Simple(10,-200,200), kSlcVtxX},
58  {"vtxy", "Y (cm)", Binning::Simple(10,-200,200), kSlcVtxY},
59  {"vtxz", "Z (cm)", Binning::Simple(10,0,500), kSlcVtxZ},
60  };
61 
62 // Selection Struc
63 struct SelDef
64 {
65  std::string suffix = "";
66  std::string label = "";
67  Cut cut = kNoCut;
68  int color = kBlack;
69 };
70 
71 // In this example, our signal is Numu cc
72 // See Cuts/TruthCuts to check out these cuts
73 const Cut kSig = kIsNumu && !kIsNC;
74 
75 // We are making the Spectra defined above
76 // for 3 different selections.
77 std::vector<SelDef> sels =
78  {{"nocut", "All Slices", kNoCut, kBlack},
79  {"sig", "True NumuCC", kSig, kRed+1},
80  {"bkg", "Not NumuCC", !kSig, kAzure+2},
81  };
82 
83 // If you wanted to add a new cut, define an
84 // expression for kYourCut (see examples in SBNAna/Cuts)
85 // and then add the following lines to the sels vector:
86 /* {"all_yourcut", "All Slices", kYourCut, kBlack}, */
87 /* {"sig_yourcut", "True NumuCC", (kSig && kYourCut), kRed+1}, */
88 /* {"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 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 kCounting
Definition: Vars.cxx:19
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:38