All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NumuVarsIcarus202106.cxx
Go to the documentation of this file.
1 #include <cmath>
3 #include "sbnanaobj/StandardRecord/Proxy/SRProxy.h"
4 
5 namespace ana
6 {
7  const Var kTruthIndex = SIMPLEVAR(truth.index);
8 
9  const Var kPrimaryEnergy = SIMPLEVAR(truth.E);
10 
11  const Var kMuMaxTrack([](const caf::SRSliceProxy* slc) -> float {
12  float len(-5.f);
13  for (auto const& trk : slc->reco.trk)
14  {
15  if ( (trk.truth.p.pdg == 13 || trk.truth.p.pdg == -13) && trk.truth.p.length > len ) len = trk.truth.p.length;
16  }
17  return len;
18  });
19 
20  const Var kPTrackInd([](const caf::SRSliceProxy* slc) -> int {
21  // The (dis)qualification of a slice is based upon the track level information.
22  float Longest(0);
23  int PTrackInd(-1);
24  for (std::size_t i(0); i < slc->reco.trk.size(); ++i)
25  {
26  auto const& trk = slc->reco.trk.at(i);
27  if(trk.bestplane == -1) continue;
28 
29  // First we calculate the distance of each track to the slice vertex.
30  const float Atslc = std::hypot(slc->vertex.x - trk.start.x,
31  slc->vertex.y - trk.start.y,
32  slc->vertex.z - trk.start.z);
33 
34  // We require that the distance of the track from the slice is less than
35  // 10 cm and that the parent of the track has been marked as the primary.
36  const bool AtSlice = ( Atslc < 10.0 && trk.pfp.parent_is_primary);
37 
38  const float Chi2Proton = trk.chi2pid[trk.bestplane].chi2_proton;
39  const float Chi2Muon = trk.chi2pid[trk.bestplane].chi2_muon;
40 
41  const bool Contained = ( !isnan(trk.end.x) &&
42  ( trk.end.x < -71.1 - 25 && trk.end.x > -369.33 + 25 ) &&
43  !isnan(trk.end.y) &&
44  ( trk.end.y > -181.7 + 25 && trk.end.y < 134.8 - 25 ) &&
45  !isnan(trk.end.z) &&
46  ( trk.end.z > -895.95 + 30 && trk.end.z < 895.95 - 50 ) );
47  const bool MaybeMuonExiting = ( !Contained && trk.len > 100);
48  const bool MaybeMuonContained = ( Contained && Chi2Proton > 60 && Chi2Muon < 30 && trk.len > 50 );
49  if ( AtSlice && ( MaybeMuonExiting || MaybeMuonContained ) && trk.len > Longest )
50  {
51  Longest = trk.len;
52  PTrackInd = i;
53  }
54  }
55  return PTrackInd;
56  });
57 
58  const Var kRecoMuonP([](const caf::SRSliceProxy* slc) -> float {
59  float p(-5.f);
60 
61  if ( kPTrackInd(slc) >= 0 )
62  {
63  auto const& trk = slc->reco.trk.at(kPTrackInd(slc));
64  const bool Contained = ( !isnan(trk.end.x) &&
65  ( trk.end.x < -71.1 - 25 && trk.end.x > -369.33 + 25 ) &&
66  !isnan(trk.end.y) &&
67  ( trk.end.y > -181.7 + 25 && trk.end.y < 134.8 - 25 ) &&
68  !isnan(trk.end.z) &&
69  ( trk.end.z > -895.95 + 30 && trk.end.z < 895.95 - 50 ) );
70  if(Contained) p = trk.rangeP.p_muon;
71  else p = trk.mcsP.fwdP_muon;
72  }
73  return p;
74  });
75 
76  const Var kTrueMuonP([](const caf::SRSliceProxy* slc) -> float {
77  float p(-5.f);
78 
79  if ( kPTrackInd(slc) >= 0 )
80  {
81  auto const& trk = slc->reco.trk.at(kPTrackInd(slc));
82  p = std::hypot(trk.truth.p.genp.x, trk.truth.p.genp.y, trk.truth.p.genp.z);
83  }
84  return p;
85  });
86 
87 
88 }
const Var kTrueMuonP([](const caf::SRSliceProxy *slc) -> float{float p(-5.f);{auto const &trk=slc->reco.trk.at(kPTrackInd(slc));p=std::hypot(trk.truth.p.genp.x, trk.truth.p.genp.y, trk.truth.p.genp.z);}return p;})
const Var kRecoMuonP([](const caf::SRSliceProxy *slc) -> float{float p(-5.f);{auto const &trk=slc->reco.trk.at(kPTrackInd(slc));const bool Contained=(!isnan(trk.end.x)&&(trk.end.x< -71.1-25 &&trk.end.x >-369.33+25)&&!isnan(trk.end.y)&&(trk.end.y >-181.7+25 &&trk.end.y< 134.8-25)&&!isnan(trk.end.z)&&(trk.end.z >-895.95+30 &&trk.end.z< 895.95-50));if(Contained) p=trk.rangeP.p_muon;else p=trk.mcsP.fwdP_muon;}return p;})
pdgs p
Definition: selectors.fcl:22
const Var kMuMaxTrack([](const caf::SRSliceProxy *slc) -> float{float len(-5.f);for(auto const &trk:slc->reco.trk){if((trk.truth.p.pdg==13||trk.truth.p.pdg==-13)&&trk.truth.p.length > len) len=trk.truth.p.length;}return len;})
process_name opflashCryoW ana
caf::Proxy< caf::SRSlice > SRSliceProxy
Definition: EpilogFwd.h:2
_Var< caf::SRSliceProxy > Var
Representation of a variable to be retrieved from a caf::StandardRecord object.
Definition: Var.h:73
const Var kPrimaryEnergy
const Var kTruthIndex
#define SIMPLEVAR(CAFNAME)
For Vars where literally all you need is a single CAF variable.
Definition: Var.h:82
const Var kPTrackInd([](const caf::SRSliceProxy *slc) -> int{float Longest(0);int PTrackInd(-1);for(std::size_t i(0);i< slc->reco.trk.size();++i){auto const &trk=slc->reco.trk.at(i);if(trk.bestplane==-1) continue;const float Atslc=std::hypot(slc->vertex.x-trk.start.x, slc->vertex.y-trk.start.y, slc->vertex.z-trk.start.z);const bool AtSlice=(Atslc< 10.0 &&trk.pfp.parent_is_primary);const float Chi2Proton=trk.chi2pid[trk.bestplane].chi2_proton;const float Chi2Muon=trk.chi2pid[trk.bestplane].chi2_muon;const bool Contained=(!isnan(trk.end.x)&&(trk.end.x< -71.1-25 &&trk.end.x >-369.33+25)&&!isnan(trk.end.y)&&(trk.end.y >-181.7+25 &&trk.end.y< 134.8-25)&&!isnan(trk.end.z)&&(trk.end.z >-895.95+30 &&trk.end.z< 895.95-50));const bool MaybeMuonExiting=(!Contained &&trk.len > 100);const bool MaybeMuonContained=(Contained &&Chi2Proton > 60 &&Chi2Muon< 30 &&trk.len > 50);{Longest=trk.len;PTrackInd=i;}}return PTrackInd;})