All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NumuVarsSBND202106.cxx
Go to the documentation of this file.
3 #include "sbnanaobj/StandardRecord/Proxy/SRProxy.h"
5 #include <cassert>
6 
7 namespace ana
8 {
9 
10 
11 // const Var kIsTrackAtSlc([](const caf::SRSliceProxy *slc, const FidVol& vol)
12 // {
13 // double dist = sqrt((slc->reco.trk.start.x - slc->vertex.x)^2 + (slc->reco.trk.start.y - slc->vertex.y)^2 + (slc->reco.trk.start.z - slc->vertex.z)^2);
14 // return (dist < 10);
15 //
16 // });
17 
18 // const Var kIsTrackContained([](const caf::SRSliceProxy *slc, const FidVol& vol)
19 // {
20 // return (vol.xmin < slc->reco.trk.end.x && slc->reco.trk.end.x < vol.xmax &&
21 // vol.ymin < slc->reco.trk.end.y && slc->reco.trk.end.y < vol.ymax &&
22 // vol.zmin < slc->reco.trk.end.z && slc->reco.trk.end.z < vol.zmax);
23 // });
24 
25  const Var kPrimaryMuonTrkIdx([](const caf::SRSliceProxy *slc)
26  {
27  double longest = -1;
28  int best_idx = -1;
29  double dist = -1;
30  bool atslc, contained, maybe_muon_exiting, maybe_muon_contained;
31  float chi2_proton, chi2_muon;
32 
33  for(unsigned int trkidx = 0; trkidx < slc->reco.trk.size(); ++trkidx){
34  const caf::SRTrackProxy& trk = slc->reco.trk[trkidx];
35  if(trk.bestplane == -1) continue;
36 
37  //atslc
38  dist = sqrt((pow(trk.start.x - slc->vertex.x,2)) + (pow(trk.start.y - slc->vertex.y,2)) + (pow(trk.start.z - slc->vertex.z,2)));
39  atslc = dist < 10;
40  if(!atslc || !trk.pfp.parent_is_primary) continue;
41 
42  //contained
43  //contained = ( vol.xmin < trk.end.x && trk.end.x < vol.xmax && vol.ymin < trk.end.y && trk.end.y < vol.ymax && vol.zmin < trk.end.z && trk.end.z < vol.zmax);
44  //The following definition reproduce the numbers from SBNSoftware/sbncode/blob/develop/sbncode/NuMuSelection/jupyter-ana/selection.py
45  //instead of using the defined Fiducial Volume check implemented in sbnana/SBNAna/Cuts/VolumeDefinitions.h
46  contained = ( (-199.15 + 10) < trk.end.x && trk.end.x < (199.15 - 10) && (-200. + 10) < trk.end.y && trk.end.y < (200. - 10) && (0.0 + 10) < trk.end.z && trk.end.z < (500. - 50));
47 
48  //bestplane.chi2
49  chi2_proton = trk.chi2pid[trk.bestplane].chi2_proton;
50  chi2_muon = trk.chi2pid[trk.bestplane].chi2_muon;
51 
52  maybe_muon_exiting = !contained && trk.len > 100;
53  maybe_muon_contained = contained && chi2_proton > 60 && chi2_muon < 30 && trk.len > 50;
54 
55  if(!maybe_muon_contained && !maybe_muon_exiting) continue;
56 
57  if(trk.len > longest){
58  longest = trk.len;
59  best_idx = trkidx;
60  }
61  }
62  return best_idx;
63  });
64 
65  const Var kPrimaryMuonTrkP([](const caf::SRSliceProxy *slc)
66  {
67  //bool contained;
68  //int ptrkid = kPrimaryMuonTrkIdx(slc);
69 
70  //const caf::SRTrackProxy& ptrk = slc->reco.trk[ptrkid];
71  //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));
72  //if(contained) return ptrk.rangeP.p_muon;
73  //else return ptrk.mcsP.fwdP_muon;
74 
75  float recop(-5.f);
76  bool contained(false);
77 
78  if ( kPrimaryMuonTrkIdx(slc) >= 0 ){
79  auto const& ptrk = slc->reco.trk.at(kPrimaryMuonTrkIdx(slc));
80  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));
81 
82  if(contained) recop = ptrk.rangeP.p_muon;
83  else recop = ptrk.mcsP.fwdP_muon;
84  }
85  return recop;
86  });
87 
88  const Var kCRTTrkTime([](const caf::SRSliceProxy *slc) -> double
89  {
90  float crttrktime(-5.f);
91  if ( kPrimaryMuonTrkIdx(slc) >= 0 ){
92  int ptrkid = kPrimaryMuonTrkIdx(slc);
93  const caf::SRTrackProxy& ptrk = slc->reco.trk[ptrkid];
94  crttrktime = ptrk.crthit.hit.time;
95  }
96  return crttrktime;
97  });
98 
99  const Var kCRTTrkAngle([](const caf::SRSliceProxy *slc) -> double
100  {
101  float crttrkangle(-5.f);
102  if ( kPrimaryMuonTrkIdx(slc) >= 0 ){
103  int ptrkid = kPrimaryMuonTrkIdx(slc);
104  const caf::SRTrackProxy& ptrk = slc->reco.trk[ptrkid];
105  crttrkangle = ptrk.crttrack.angle;
106  }
107  return crttrkangle;
108  });
109 
110  const Var kCRTHitDist([](const caf::SRSliceProxy *slc) -> double
111  {
112  float crttrkdist(-5.f);
113  if ( kPrimaryMuonTrkIdx(slc) >= 0 ){
114  int ptrkid = kPrimaryMuonTrkIdx(slc);
115  const caf::SRTrackProxy& ptrk = slc->reco.trk[ptrkid];
116  crttrkdist = ptrk.crthit.distance;
117  }
118  return crttrkdist;
119  });
120 
121  const Var kNuScore([](const caf::SRSliceProxy *slc) -> double
122  {
123  return slc->nu_score;
124  });
125 
126  const Var kPrimaryMuonTrkLen([](const caf::SRSliceProxy *slc) -> double
127  {
128  float ptrklen(-5.f);
129  if ( kPrimaryMuonTrkIdx(slc) >= 0 ){
130  int ptrkid = kPrimaryMuonTrkIdx(slc);
131  const caf::SRTrackProxy& ptrk = slc->reco.trk[ptrkid];
132  ptrklen = ptrk.len;
133  }
134  return ptrklen;
135  });
136 
137 }
def ptrk
Definition: selection.py:74
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 kNuScore([](const caf::SRSliceProxy *slc){return(!isnan(slc->nu_score)&&slc->nu_score > 0.4);})
process_name opflashCryoW ana
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;})
_Var< caf::SRSliceProxy > Var
Representation of a variable to be retrieved from a caf::StandardRecord object.
Definition: Var.h:73
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 kPrimaryMuonTrkIdx([](const caf::SRSliceProxy *slc){double longest=-1;int best_idx=-1;double dist=-1;bool atslc, contained, maybe_muon_exiting, maybe_muon_contained;float chi2_proton, chi2_muon;for(unsigned int trkidx=0;trkidx< slc->reco.trk.size();++trkidx){const caf::SRTrackProxy &trk=slc->reco.trk[trkidx];if(trk.bestplane==-1) continue;dist=sqrt((pow(trk.start.x-slc->vertex.x, 2))+(pow(trk.start.y-slc->vertex.y, 2))+(pow(trk.start.z-slc->vertex.z, 2)));atslc=dist< 10;if(!atslc||!trk.pfp.parent_is_primary) continue;contained=((-199.15+10)< trk.end.x &&trk.end.x< (199.15-10)&&(-200.+10)< trk.end.y &&trk.end.y< (200.-10)&&(0.0+10)< trk.end.z &&trk.end.z< (500.-50));chi2_proton=trk.chi2pid[trk.bestplane].chi2_proton;chi2_muon=trk.chi2pid[trk.bestplane].chi2_muon;maybe_muon_exiting=!contained &&trk.len > 100;maybe_muon_contained=contained &&chi2_proton > 60 &&chi2_muon< 30 &&trk.len > 50;if(!maybe_muon_contained &&!maybe_muon_exiting) continue;if(trk.len > longest){longest=trk.len;best_idx=trkidx;}}return best_idx;})
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;})
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
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;})