All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NueVars.cxx
Go to the documentation of this file.
3 #include "sbnanaobj/StandardRecord/Proxy/SRProxy.h"
4 #include <cassert>
5 
6 namespace ana {
7 // Get the Largest shower in the slice
9  [](const caf::SRSliceProxy* slc) -> int {
10  int bestIdx(-1);
11  double maxEnergy(-1);
12 
13  for (unsigned int i = 0; i < slc->reco.nshw; i++) {
14  auto const& shw = slc->reco.shw[i];
15  if (!shw.pfp.parent_is_primary)
16  continue;
17  if (shw.bestplane_energy > maxEnergy) {
18  bestIdx = i;
19  maxEnergy = shw.bestplane_energy;
20  }
21  }
22  return bestIdx;
23  });
24 
25 /// Pointer to largest reconstructed shower, or null pointer if none exists
26 const caf::SRShowerProxy* LargestRecoShower(const caf::SRSliceProxy* slc)
27 {
28  const int largestShwIdx = kLargestRecoShowerIdx(slc);
29  if(largestShwIdx == -1) return 0;
30  return &slc->reco.shw[largestShwIdx];
31 }
32 
33 // Currently assumes shw 0 is the primary
35  [](const caf::SRSliceProxy* slc) -> double {
36  const caf::SRShowerProxy* shw = LargestRecoShower(slc);
37  return shw ? double(shw->bestplane_energy) : -5;
38  });
39 
41  [](const caf::SRSliceProxy* slc) -> int {
42  const caf::SRShowerProxy* shw = LargestRecoShower(slc);
43  return shw ? int(shw->truth.p.pdg) : -5;
44  });
45 
46 // Currently assumes shw 0 is the primary
48  [](const caf::SRSliceProxy* slc) -> double {
49  const caf::SRShowerProxy* shw = LargestRecoShower(slc);
50  if(!shw || shw->bestplane_dEdx < 0) return -5.;
51  return shw->bestplane_dEdx;
52  });
53 
55  [](const caf::SRSliceProxy* slc) -> double {
56  const caf::SRShowerProxy* shw = LargestRecoShower(slc);
57  return shw ? double(shw->conversion_gap) : -5.;
58  });
59 
61  [](const caf::SRSliceProxy* slc) -> double {
62  const caf::SRShowerProxy* shw = LargestRecoShower(slc);
63  return shw ? double(shw->density) : -5.;
64  });
65 
67  [](const caf::SRSliceProxy* slc) -> double {
68  const caf::SRShowerProxy* shw = LargestRecoShower(slc);
69  return shw ? double(shw->plane[1].energy) : -5.; // so far taking whatever plane 1 is and first shw
70  });
71 
73  [](const caf::SRSliceProxy* slc) -> double {
74  const caf::SRShowerProxy* shw = LargestRecoShower(slc);
75  return shw ? double(shw->len) : -5.;
76  });
77 
79  [](const caf::SRSliceProxy* slc) -> double {
80  const caf::SRShowerProxy* shw = LargestRecoShower(slc);
81  return shw ? 180. * shw->open_angle / M_PI : -5.;
82  });
83 
85  [](const caf::SRSliceProxy* slc) -> double {
86  const caf::SRShowerProxy* shw = LargestRecoShower(slc);
87  return shw ? double(shw->start.x) : -9999.;
88  });
89 
91  [](const caf::SRSliceProxy* slc) -> double {
92  const caf::SRShowerProxy* shw = LargestRecoShower(slc);
93  return shw ? double(shw->start.y) : -9999.;
94  });
95 
97  [](const caf::SRSliceProxy* slc) -> double {
98  const caf::SRShowerProxy* shw = LargestRecoShower(slc);
99  return shw ? double(shw->start.z) : -9999.;
100  });
101 
102 const Var kRecoShower_EndX(
103  [](const caf::SRSliceProxy* slc) -> double {
104  const caf::SRShowerProxy* shw = LargestRecoShower(slc);
105  return shw ? double(shw->start.x + shw->dir.x * shw->len) : -9999.;
106  });
107 
108 const Var kRecoShower_EndY(
109  [](const caf::SRSliceProxy* slc) -> double {
110  const caf::SRShowerProxy* shw = LargestRecoShower(slc);
111  return shw ? double(shw->start.y + shw->dir.y * shw->len) : -9999.;
112  });
113 
114 const Var kRecoShower_EndZ(
115  [](const caf::SRSliceProxy* slc) -> double {
116  const caf::SRShowerProxy* shw = LargestRecoShower(slc);
117  return shw ? double(shw->start.z + shw->dir.z * shw->len) : -9999.;
118  });
119 
121  [](const caf::SRSliceProxy* slc) -> double {
122  const caf::SRShowerProxy* shw = LargestRecoShower(slc);
123  return shw ? double(shw->selVars.densityGradient) : -5.;
124  });
125 
127  [](const caf::SRSliceProxy* slc) -> double {
128  const caf::SRShowerProxy* shw = LargestRecoShower(slc);
129  return shw ? double(shw->selVars.densityGradientPower) : -5.;
130  });
131 
133  [](const caf::SRSliceProxy* slc) -> double {
134  const caf::SRShowerProxy* shw = LargestRecoShower(slc);
135  return shw ? double(shw->selVars.trackLength) : -5.;
136  });
137 
139  [](const caf::SRSliceProxy* slc) -> double {
140  const caf::SRShowerProxy* shw = LargestRecoShower(slc);
141  return shw ? double(shw->selVars.trackWidth) : -5.;
142  });
143 
145  [](const caf::SRSliceProxy* slc) -> unsigned {
146  unsigned int counter(0);
147  for (auto const& shw : slc->reco.shw) {
148  if (shw.bestplane_energy > 0.2f)
149  ++counter;
150  }
151  return counter;
152  });
153 
154 const Var kLongestTrackIdx(
155  [](const caf::SRSliceProxy* slc) -> int {
156  int bestIdx(-1);
157  double maxLength(-1);
158 
159  for (unsigned int i = 0; i < slc->reco.ntrk; i++) {
160  auto const& trk = slc->reco.trk[i];
161  if (!trk.pfp.parent_is_primary)
162  continue;
163 
164  if (trk.len > maxLength) {
165  bestIdx = i;
166  maxLength = trk.len;
167  }
168  }
169  return bestIdx;
170  });
171 
172 /// Pointer to longest reconstructed shower, or null pointer if none exists
173 const caf::SRTrackProxy* LongestRecoTrack(const caf::SRSliceProxy* slc)
174 {
175  const int longestTrackIdx = kLongestTrackIdx(slc);
176  if(longestTrackIdx == -1) return 0;
177  return &slc->reco.trk[longestTrackIdx];
178 }
179 
181  [](const caf::SRSliceProxy* slc) -> int {
182  const caf::SRTrackProxy* trk = LongestRecoTrack(slc);
183  return trk ? int(trk->truth.p.pdg) : -5;
184  });
185 
187  [](const caf::SRSliceProxy* slc) -> double {
188  const caf::SRTrackProxy* trk = LongestRecoTrack(slc);
189  return trk ? double(trk->len) : -5.;
190  });
191 
192 
193 const caf::SRTrkChi2PIDProxy* BestPlaneChi2PID(const caf::SRTrackProxy* trk)
194 {
195  if(trk->bestplane == -1) return 0;
196  return &trk->chi2pid[trk->bestplane];
197 }
198 
199 const caf::SRTrkChi2PIDProxy* LongestTrackBestPlaneChi2PID(const caf::SRSliceProxy* slc)
200 {
201  const caf::SRTrackProxy* trk = LongestRecoTrack(slc);
202  return trk ? BestPlaneChi2PID(trk) : 0;
203 }
204 
206  [](const caf::SRSliceProxy* slc) -> double {
207  const caf::SRTrkChi2PIDProxy* chi2 = LongestTrackBestPlaneChi2PID(slc);
208  return chi2 ? double(chi2->chi2_muon) : -5.;
209  });
210 
212  [](const caf::SRSliceProxy* slc) -> double {
213  const caf::SRTrkChi2PIDProxy* chi2 = LongestTrackBestPlaneChi2PID(slc);
214  return chi2 ? double(chi2->chi2_pion) : -5.;
215  });
216 
218  [](const caf::SRSliceProxy* slc) -> double {
219  const caf::SRTrkChi2PIDProxy* chi2 = LongestTrackBestPlaneChi2PID(slc);
220  return chi2 ? double(chi2->chi2_kaon) : -5.;
221  });
222 
224  [](const caf::SRSliceProxy* slc) -> double {
225  const caf::SRTrkChi2PIDProxy* chi2 = LongestTrackBestPlaneChi2PID(slc);
226  return chi2 ? double(chi2->chi2_proton) : -5.;
227  });
228 
229 const Var kMuonTrackLength(
230  [](const caf::SRSliceProxy* slc) -> double {
231  const caf::SRTrackProxy* trk = LongestRecoTrack(slc);
232  if(!trk) return -5;
233  if(trk && (kLongestTrackChi2Muon(slc) < 30.f && kLongestTrackChi2Proton(slc) > 60.f)) {
234  return trk->len;
235  }
236  return -5;
237  });
238 
240  [](const caf::SRSliceProxy* slc) -> int {
241  const caf::SRTrackProxy* trk = LongestRecoTrack(slc);
242  return trk ? (int)trk->dazzle.pdg : -5;
243  });
244 
246  [](const caf::SRSliceProxy* slc) -> float {
247  const caf::SRTrackProxy* trk = LongestRecoTrack(slc);
248  return trk ? (float)trk->dazzle.muonScore : -5.f;
249  });
250 
252  [](const caf::SRSliceProxy* slc) -> int {
253  const caf::SRShowerProxy* shw = LargestRecoShower(slc);
254  return shw ? (int)shw->razzle.pdg : -5;
255  });
256 
258  [](const caf::SRSliceProxy* slc) -> float {
259  const caf::SRShowerProxy* shw = LargestRecoShower(slc);
260  return shw ? (float)shw->razzle.electronScore : -5.f;
261  });
262 
263 }
const Var kRecoShower_EndX([](const caf::SRSliceProxy *slc) -> double{const caf::SRShowerProxy *shw=LargestRecoShower(slc);return shw?double(shw->start.x+shw->dir.x *shw->len):-9999.;})
Definition: NueVars.h:20
const Var kRecoShower_OpenAngle([](const caf::SRSliceProxy *slc) -> double{const caf::SRShowerProxy *shw=LargestRecoShower(slc);return shw?180.*shw->open_angle/M_PI:-5.;})
Definition: NueVars.h:16
const Var kRecoShower_trackLength([](const caf::SRSliceProxy *slc) -> double{const caf::SRShowerProxy *shw=LargestRecoShower(slc);return shw?double(shw->selVars.trackLength):-5.;})
Definition: NueVars.h:26
const Var kLongestTrackChi2Proton([](const caf::SRSliceProxy *slc) -> double{const caf::SRTrkChi2PIDProxy *chi2=LongestTrackBestPlaneChi2PID(slc);return chi2?double(chi2->chi2_proton):-5.;})
Definition: NueVars.h:38
const Var kRecoShower_trackWidth([](const caf::SRSliceProxy *slc) -> double{const caf::SRShowerProxy *shw=LargestRecoShower(slc);return shw?double(shw->selVars.trackWidth):-5.;})
Definition: NueVars.h:27
const Var kRecoShower_StartX([](const caf::SRSliceProxy *slc) -> double{const caf::SRShowerProxy *shw=LargestRecoShower(slc);return shw?double(shw->start.x):-9999.;})
Definition: NueVars.h:17
const Var kRecoShower_StartY([](const caf::SRSliceProxy *slc) -> double{const caf::SRShowerProxy *shw=LargestRecoShower(slc);return shw?double(shw->start.y):-9999.;})
Definition: NueVars.h:18
process_name opflashCryoW ana
const Var kRecoShowers_EnergyCut([](const caf::SRSliceProxy *slc) -> unsigned{unsigned int counter(0);for(auto const &shw:slc->reco.shw){++counter;}return counter;})
Definition: NueVars.h:31
const caf::SRTrkChi2PIDProxy * BestPlaneChi2PID(const caf::SRTrackProxy *trk)
Definition: NueVars.cxx:193
const Var kLongestTrackDazzleMuonScore([](const caf::SRSliceProxy *slc) -> float{const caf::SRTrackProxy *trk=LongestRecoTrack(slc);return trk?(float) trk->dazzle.muonScore:-5.f;})
Definition: NueVars.h:43
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 kMuonTrackLength([](const caf::SRSliceProxy *slc) -> double{const caf::SRTrackProxy *trk=LongestRecoTrack(slc);if(!trk) return-5;if(trk &&(kLongestTrackChi2Muon(slc)< 30.f &&kLongestTrackChi2Proton(slc) > 60.f)){return trk->len;}return-5;})
Definition: NueVars.h:40
const Var kRecoShower_BestEnergy([](const caf::SRSliceProxy *slc) -> double{const caf::SRShowerProxy *shw=LargestRecoShower(slc);return shw?double(shw->bestplane_energy):-5;})
Definition: NueVars.h:10
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
Definition: counter.h:285
const Var kRecoShower_EndY([](const caf::SRSliceProxy *slc) -> double{const caf::SRShowerProxy *shw=LargestRecoShower(slc);return shw?double(shw->start.y+shw->dir.y *shw->len):-9999.;})
Definition: NueVars.h:21
const Var kRecoShower_Length([](const caf::SRSliceProxy *slc) -> double{const caf::SRShowerProxy *shw=LargestRecoShower(slc);return shw?double(shw->len):-5.;})
Definition: NueVars.h:15
const Var kRecoShower_Energy([](const caf::SRSliceProxy *slc) -> double{const caf::SRShowerProxy *shw=LargestRecoShower(slc);return shw?double(shw->plane[1].energy):-5.;})
Definition: NueVars.h:14
const Var kLargestRecoShowerIdx([](const caf::SRSliceProxy *slc) -> int{int bestIdx(-1);double maxEnergy(-1);for(unsigned int i=0;i< slc->reco.nshw;i++){auto const &shw=slc->reco.shw[i];continue;if(shw.bestplane_energy > maxEnergy){bestIdx=i;maxEnergy=shw.bestplane_energy;}}return bestIdx;})
Definition: NueVars.h:9
const Var kLongestTrackChi2Pion([](const caf::SRSliceProxy *slc) -> double{const caf::SRTrkChi2PIDProxy *chi2=LongestTrackBestPlaneChi2PID(slc);return chi2?double(chi2->chi2_pion):-5.;})
Definition: NueVars.h:36
const Var kRecoShower_StartZ([](const caf::SRSliceProxy *slc) -> double{const caf::SRShowerProxy *shw=LargestRecoShower(slc);return shw?double(shw->start.z):-9999.;})
Definition: NueVars.h:19
const Var kRecoShowerRazzlePID([](const caf::SRSliceProxy *slc) -> int{const caf::SRShowerProxy *shw=LargestRecoShower(slc);return shw?(int) shw->razzle.pdg:-5;})
Definition: NueVars.h:44
const caf::SRTrackProxy * LongestRecoTrack(const caf::SRSliceProxy *slc)
Pointer to longest reconstructed shower, or null pointer if none exists.
Definition: NueVars.cxx:173
const Var kLongestTrackChi2Muon([](const caf::SRSliceProxy *slc) -> double{const caf::SRTrkChi2PIDProxy *chi2=LongestTrackBestPlaneChi2PID(slc);return chi2?double(chi2->chi2_muon):-5.;})
Definition: NueVars.h:35
const Var kRecoShower_Density([](const caf::SRSliceProxy *slc) -> double{const caf::SRShowerProxy *shw=LargestRecoShower(slc);return shw?double(shw->density):-5.;})
Definition: NueVars.h:13
const Var kLongestTrackTruePdg([](const caf::SRSliceProxy *slc) -> int{const caf::SRTrackProxy *trk=LongestRecoTrack(slc);return trk?int(trk->truth.p.pdg):-5;})
Definition: NueVars.h:30
const caf::SRShowerProxy * LargestRecoShower(const caf::SRSliceProxy *slc)
Pointer to largest reconstructed shower, or null pointer if none exists.
Definition: NueVars.cxx:26
const Var kLongestTrackIdx([](const caf::SRSliceProxy *slc) -> int{int bestIdx(-1);double maxLength(-1);for(unsigned int i=0;i< slc->reco.ntrk;i++){auto const &trk=slc->reco.trk[i];continue;if(trk.len > maxLength){bestIdx=i;maxLength=trk.len;}}return bestIdx;})
Definition: NueVars.h:33
const Var kRecoShower_EndZ([](const caf::SRSliceProxy *slc) -> double{const caf::SRShowerProxy *shw=LargestRecoShower(slc);return shw?double(shw->start.z+shw->dir.z *shw->len):-9999.;})
Definition: NueVars.h:22
const Var kRecoShower_ConversionGap([](const caf::SRSliceProxy *slc) -> double{const caf::SRShowerProxy *shw=LargestRecoShower(slc);return shw?double(shw->conversion_gap):-5.;})
Definition: NueVars.h:12
const Var kRecoShower_densityGradientPower([](const caf::SRSliceProxy *slc) -> double{const caf::SRShowerProxy *shw=LargestRecoShower(slc);return shw?double(shw->selVars.densityGradientPower):-5.;})
Definition: NueVars.h:25
const Var kRecoShowerRazzleElectronScore([](const caf::SRSliceProxy *slc) -> float{const caf::SRShowerProxy *shw=LargestRecoShower(slc);return shw?(float) shw->razzle.electronScore:-5.f;})
Definition: NueVars.h:45
const Var kRecoShower_BestdEdx([](const caf::SRSliceProxy *slc) -> double{const caf::SRShowerProxy *shw=LargestRecoShower(slc);if(!shw||shw->bestplane_dEdx< 0) return-5.;return shw->bestplane_dEdx;})
Definition: NueVars.h:11
const Var kLongestTrackDazzlePID([](const caf::SRSliceProxy *slc) -> int{const caf::SRTrackProxy *trk=LongestRecoTrack(slc);return trk?(int) trk->dazzle.pdg:-5;})
Definition: NueVars.h:42
const caf::SRTrkChi2PIDProxy * LongestTrackBestPlaneChi2PID(const caf::SRSliceProxy *slc)
Definition: NueVars.cxx:199
const Var kLongestTrackChi2Kaon([](const caf::SRSliceProxy *slc) -> double{const caf::SRTrkChi2PIDProxy *chi2=LongestTrackBestPlaneChi2PID(slc);return chi2?double(chi2->chi2_kaon):-5.;})
Definition: NueVars.h:37
const Var kRecoShower_TruePdg([](const caf::SRSliceProxy *slc) -> int{const caf::SRShowerProxy *shw=LargestRecoShower(slc);return shw?int(shw->truth.p.pdg):-5;})
Definition: NueVars.h:29
const Var kRecoShower_densityGradient([](const caf::SRSliceProxy *slc) -> double{const caf::SRShowerProxy *shw=LargestRecoShower(slc);return shw?double(shw->selVars.densityGradient):-5.;})
Definition: NueVars.h:24
const Var kLongestTrackLength([](const caf::SRSliceProxy *slc) -> double{const caf::SRTrackProxy *trk=LongestRecoTrack(slc);return trk?double(trk->len):-5.;})
Definition: NueVars.h:34