BPFVars.cxx
Go to the documentation of this file.
1 #include "CAFAna/Vars/BPFVars.h"
2 
4 
6 
7 #include "TVector3.h"
8 
9 namespace
10 {
13 }
14 
15 namespace ana
16 {
17  const Var kBPFBestMuonNpng(
18  [](const caf::SRProxy *sr)
19  {
20  float npng = -5.0;
21  if (kBPFValidMuon(sr) == false) return -999.f;
22 
23  npng = sr->vtx.elastic.fuzzyk.npng;
24 
25  return npng;
26 
27  });
28 
29  const Var kBPFBestMuonNhits(
30  [](const caf::SRProxy *sr)
31  {
32  float Nhits = -5.0;
33  if (kBPFValidMuon(sr) == false) return -999.f;
34 
35  //
36  // HARDCODED ASSUMPTION: about only having one vertex... ...for now...
37  //
38 
39  // get best muon prong index
40  unsigned int muIdx = (unsigned int)kCVNMuonIdx(sr);
41 
42  // Assuming we've passed the kBPFValidMuonTrack cut, take the value from the muon track.
43  if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid)
44  Nhits = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.nhit;
45 
46  return Nhits;
47 
48  });
49 
50  const Var kBPFBestMuonStartx(
51  [](const caf::SRProxy *sr)
52  {
53  float startx = -999.0;
54  if (kBPFValidMuon(sr) == false) return -999.f;
55 
56  //
57  // HARDCODED ASSUMPTION: about only having one vertex... ...for now...
58  //
59 
60  // get best muon prong index
61  unsigned int muIdx = (unsigned int)kCVNMuonIdx(sr);
62 
63  // Assuming we've passed the kBPFValidMuonTrack cut, take the value from the muon track.
64  if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid)
65  startx = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.start.x/100.0; // track values are in cm
66 
67  return startx;
68 
69  });
70 
71 
72  const Var kBPFBestMuonStarty(
73  [](const caf::SRProxy *sr)
74  {
75  float starty = -999.0;
76  if (kBPFValidMuon(sr) == false) return -999.f;
77 
78  //
79  // HARDCODED ASSUMPTION: about only having one vertex... ...for now...
80  //
81 
82  // get best muon prong index
83  unsigned int muIdx = (unsigned int)kCVNMuonIdx(sr);
84 
85  // Assuming we've passed the kBPFValidMuonTrack cut, take the value from the muon track.
86  if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid)
87  starty = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.start.y/100.0; // track values are in cm
88 
89  return starty;
90 
91  });
92 
93 
94  const Var kBPFBestMuonStartz(
95  [](const caf::SRProxy *sr)
96  {
97  float startz = -999.0;
98  if (kBPFValidMuon(sr) == false) return -999.f;
99 
100  //
101  // HARDCODED ASSUMPTION: about only having one vertex... ...for now...
102  //
103 
104  // get best muon prong index
105  unsigned int muIdx = (unsigned int)kCVNMuonIdx(sr);
106 
107  // Assuming we've passed the kBPFValidMuonTrack cut, take the value from the muon track.
108  if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid)
109  startz = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.start.z/100.0; // track values are in cm
110 
111  return startz;
112 
113  });
114 
115 
116  const Var kBPFBestMuonStopx(
117  [](const caf::SRProxy *sr)
118  {
119  float stopx = -999.0;
120  if (kBPFValidMuon(sr) == false) return -999.f;
121 
122  //
123  // HARDCODED ASSUMPTION: about only having one vertex... ...for now...
124  //
125 
126  // get best muon prong index
127  unsigned int muIdx = (unsigned int)kCVNMuonIdx(sr);
128 
129  // Assuming we've passed the kBPFValidMuonTrack cut, take the value from the muon track.
130  if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid)
131  stopx = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.stop.x/100.0; // track values are in cm
132 
133  return stopx;
134 
135  });
136 
137 
138  const Var kBPFBestMuonStopy(
139  [](const caf::SRProxy *sr)
140  {
141  float stopy = -999.0;
142  if (kBPFValidMuon(sr) == false) return -999.f;
143 
144  //
145  // HARDCODED ASSUMPTION: about only having one vertex... ...for now...
146  //
147 
148  // get best muon prong index
149  unsigned int muIdx = (unsigned int)kCVNMuonIdx(sr);
150 
151  // Assuming we've passed the kBPFValidMuonTrack cut, take the value from the muon track.
152  if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid)
153  stopy = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.stop.y/100.0; // track values are in cm
154 
155  return stopy;
156 
157  });
158 
159 
160  const Var kBPFBestMuonStopz(
161  [](const caf::SRProxy *sr)
162  {
163  float stopz = -999.0;
164  if (kBPFValidMuon(sr) == false) return -999.f;
165 
166  //
167  // HARDCODED ASSUMPTION: about only having one vertex... ...for now...
168  //
169 
170  // get best muon prong index
171  unsigned int muIdx = (unsigned int)kCVNMuonIdx(sr);
172 
173  // Assuming we've passed the kBPFValidMuonTrack cut, take the value from the muon track.
174  if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid)
175  stopz = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.stop.z/100.0; // track values are in cm
176 
177  return stopz;
178 
179  });
180 
181 
182  const Var kBPFBestMuonDirx(
183  [](const caf::SRProxy *sr)
184  {
185  float dirx = -5.0;
186  if (kBPFValidMuon(sr) == false) return -5.f;
187 
188  //
189  // HARDCODED ASSUMPTION: about only having one vertex... ...for now...
190  //
191 
192  // get best muon prong index
193  unsigned int muIdx = (unsigned int)kCVNMuonIdx(sr);
194 
195  // Assuming we've passed the kBPFValidMuonTrack cut, take the value from the muon track.
196  if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid)
197  dirx = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.dir.x;
198 
199  return dirx;
200 
201  });
202 
203 
204  const Var kBPFBestMuonDiry(
205  [](const caf::SRProxy *sr)
206  {
207  float diry = -5.0;
208  if (kBPFValidMuon(sr) == false) return -5.f;
209 
210  //
211  // HARDCODED ASSUMPTION: about only having one vertex... ...for now...
212  //
213 
214  // get best muon prong index
215  unsigned int muIdx = (unsigned int)kCVNMuonIdx(sr);
216 
217  // Assuming we've passed the kBPFValidMuonTrack cut, take the value from the muon track.
218  if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid)
219  diry = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.dir.y;
220 
221  return diry;
222 
223  });
224 
225  const Var kBPFBestMuonCosDirY(
226  [](const caf::SRProxy *sr)
227  {
228  float diry = kBPFBestMuonDiry(sr);
229  if (diry == -5)
230  return diry;
231  else
232  return (float)cos(diry);
233  });
234 
235 
236  const Var kBPFBestMuonDirz(
237  [](const caf::SRProxy *sr)
238  {
239  float dirz = -5.0;
240  if (kBPFValidMuon(sr) == false) return -5.f;
241 
242  //
243  // HARDCODED ASSUMPTION: about only having one vertex... ...for now...
244  //
245 
246  // get best muon prong index
247  unsigned int muIdx = (unsigned int)kCVNMuonIdx(sr);
248 
249  // Assuming we've passed the kBPFValidMuonTrack cut, take the value from the muon track.
250  if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid)
251  dirz = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.dir.z;
252 
253  return dirz;
254 
255  });
256 
257 
258  const Var kBPFBestMuonPx(
259  [](const caf::SRProxy *sr)
260  {
261  float px = -5.0;
262  if (kBPFValidMuon(sr) == false) return -5.f;
263 
264  //
265  // HARDCODED ASSUMPTION: about only having one vertex... ...for now...
266  //
267 
268  // get best muon prong index
269  unsigned int muIdx = (unsigned int)kCVNMuonIdx(sr);
270 
271  // Assuming we've passed the kBPFValidMuonTrack cut, take the value from the muon track.
272  if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid)
273  px = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.momentum.x;
274 
275  return px;
276 
277  });
278 
279 
280  const Var kBPFBestMuonPy(
281  [](const caf::SRProxy *sr)
282  {
283  float py = -5.0;
284  if (kBPFValidMuon(sr) == false) return -5.f;
285 
286  //
287  // HARDCODED ASSUMPTION: about only having one vertex... ...for now...
288  //
289 
290  // get best muon prong index
291  unsigned int muIdx = (unsigned int)kCVNMuonIdx(sr);
292 
293  // Assuming we've passed the kBPFValidMuonTrack cut, take the value from the muon track.
294  if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid)
295  py = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.momentum.y;
296 
297  return py;
298 
299  });
300 
301 
302  const Var kBPFBestMuonPz(
303  [](const caf::SRProxy *sr)
304  {
305  float pz = -5.0;
306  if (kBPFValidMuon(sr) == false) return -5.f;
307 
308  //
309  // HARDCODED ASSUMPTION: about only having one vertex... ...for now...
310  //
311 
312  // get best muon prong index
313  unsigned int muIdx = (unsigned int)kCVNMuonIdx(sr);
314 
315  // Assuming we've passed the kBPFValidMuonTrack cut, take the value from the muon track.
316  if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid)
317  pz = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.momentum.z;
318 
319  return pz;
320 
321  });
322 
323 
324  const Var kBPFBestMuonCalE(
325  [](const caf::SRProxy *sr)
326  {
327  float calE = -5.0;
328  if (kBPFValidMuon(sr) == false) return -5.f;
329 
330  //
331  // HARDCODED ASSUMPTION: about only having one vertex... ...for now...
332  //
333 
334  // get best muon prong index
335  unsigned int muIdx = (unsigned int)kCVNMuonIdx(sr);
336 
337  // Assuming we've passed the kBPFValidMuonTrack cut, take the value from the muon track.
338  if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid)
339  calE = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.calE;
340 
341  return calE;
342 
343  });
344 
345 
346  const Var kBPFBestMuonTrkE(
347  [](const caf::SRProxy *sr)
348  {
349  float trkE = -5.0;
350  if (kBPFValidMuon(sr) == false) return -5.f;
351 
352  //
353  // HARDCODED ASSUMPTION: about only having one vertex... ...for now...
354  //
355 
356  // get best muon prong index
357  unsigned int muIdx = (unsigned int)kCVNMuonIdx(sr);
358 
359  // Assuming we've passed the kBPFValidMuonTrack cut, take the value from the muon track.
360  if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid)
361  trkE = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.energy;
362 
363  return trkE;
364 
365  });
366 
367 
368  const Var kBPFBestMuonTrkLen(
369  [](const caf::SRProxy *sr)
370  {
371  float len = -1.0;
372  if (kBPFValidMuon(sr) == false) return -5.f;
373 
374  //
375  // HARDCODED ASSUMPTION: about only having one vertex... ...for now...
376  //
377 
378  // get best muon prong index
379  unsigned int muIdx = (unsigned int)kCVNMuonIdx(sr);
380 
381  // Assuming we've passed the kBPFValidMuonTrack cut, take the value from the muon track.
382  if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid)
383  len = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.len/100.0;
384 
385  return len;
386 
387  });
388 
390  [](const caf::SRProxy *sr)
391  {
392  int nplanegap = 500;
393  if (kBPFValidMuon(sr) == false) return 500;
394  // get best muon prong index
395  unsigned int muIdx = (unsigned int)kCVNMuonIdx(sr);
396 
397  // Assuming we've passed the kBPFValidMuonTrack cut, take the value from the muon track.
398  if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid)
399  nplanegap = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.nplanegap;
400 
401  return nplanegap;
402 
403  });
404 
406  [](const caf::SRProxy *sr)
407  {
408  int nplanes = 500;
409  if (kBPFValidMuon(sr) == false) return 500;
410  // get best muon prong index
411  unsigned int muIdx = (unsigned int)kCVNMuonIdx(sr);
412 
413  // Assuming we've passed the kBPFValidMuonTrack cut, take the value from the muon track.
414  if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid)
415  nplanes = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.nplane;
416 
417  return nplanes;
418 
419  });
420 
421 
422 
423  const Var kBPFBestMuonPtP(
424  [](const caf::SRProxy *sr)
425  {
426  float ptp = -5.0;
427  if (kBPFValidMuon(sr) == false) return -5.f;
428 
429  //
430  // HARDCODED ASSUMPTION: about only having one vertex... ...for now...
431  //
432 
433  // get best muon prong index
434  unsigned int muIdx = (unsigned int)kCVNMuonIdx(sr);
435 
436  // Assuming we've passed the kBPFValidMuonTrack cut, take the value from the muon track.
437  double Zbeam = -5.0;
438 
439  if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid) {
440  if(sr->hdr.det == caf::kNEARDET) Zbeam = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.dir.Dot(beamDirND);
441  if(sr->hdr.det == caf::kFARDET) Zbeam = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.dir.Dot(beamDirFD);
442  }
443 
444  if(Zbeam == -5.0) ptp = -5.0;
445  else ptp = sqrt(1 - Zbeam*Zbeam);
446 
447  return ptp;
448 
449  });
450 
451 
452  const Var kBPFBestMuonCosNumi(
453  [](const caf::SRProxy *sr)
454  {
455  float cosnumi = -5.0;
456  if (kBPFValidMuon(sr) == false) return -5.f;
457 
458  //
459  // HARDCODED ASSUMPTION: about only having one vertex... ...for now...
460  //
461 
462  // get best muon prong index
463  unsigned int muIdx = (unsigned int)kCVNMuonIdx(sr);
464 
465  // Assuming we've passed the kBPFValidMuonTrack cut, take the value from the muon track.
466  if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid) {
467  if(sr->hdr.det == caf::kNEARDET) cosnumi = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.dir.Dot(beamDirND);
468  if(sr->hdr.det == caf::kFARDET) cosnumi = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.dir.Dot(beamDirFD);
469  }
470 
471  return cosnumi;
472 
473  });
474 
475 
477  [](const caf::SRProxy *sr)
478  {
479  float length = -1.0;
480  if (kBPFValidMuon(sr) == false) return -5.f;
481 
482  // loop over all verticies, prongs, and tracks to find the longest muon track
483  if(sr->vtx.elastic.IsValid){
484  for(unsigned int png_idx = 0; png_idx < sr->vtx.elastic.fuzzyk.png.size(); png_idx++) {
485 
486  auto &png = sr->vtx.elastic.fuzzyk.png[png_idx];
487 
488  // Assuming we've passed the kBPFValidMuonTrack cut, take the value from the muon track.
489 
490  // otherwise check to see if this track is the longest so far
491  if(png.bpf.muon.len > length && png.bpf.muon.IsValid) {
492  length = png.bpf.muon.len;
493  }
494 
495  } // end loop over prongs
496 
497  } // end loop over verticies
498 
499  return length;
500 
501  });
502 
503 
504  const Var kBPFBestMuonChi2T(
505  [](const caf::SRProxy *sr)
506  {
507  float chi2T = -5.0;
508  if (kBPFValidMuon(sr) == false) return -5.f;
509 
510  //
511  // HARDCODED ASSUMPTION: about only having one vertex... ...for now...
512  //
513 
514  // get best muon prong index
515  unsigned int muIdx = (unsigned int)kCVNMuonIdx(sr);
516 
517  // Assuming we've passed the kBPFValidMuonTrack cut, take the value from the muon track.
518  if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid)
519  chi2T = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.chi2T;
520 
521  return chi2T;
522 
523  });
524 
525 
526  const Var kBPFBestMuondEdXLL(
527  [](const caf::SRProxy *sr)
528  {
529  float dEdXLL = -999.0;
530  if (kBPFValidMuon(sr) == false) return -5.f;
531 
532  //
533  // HARDCODED ASSUMPTION: about only having one vertex... ...for now...
534  //
535 
536  // get best muon prong index
537  unsigned int muIdx = (unsigned int)kCVNMuonIdx(sr);
538 
539  // Assuming we've passed the kBPFValidMuonTrack cut, take the value from the muon track.
540  if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid)
541  dEdXLL = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.dEdXLL;
542 
543  return dEdXLL;
544 
545  });
546 
547 
549  [](const caf::SRProxy *sr)
550  {
551  float hitRatio = -5.0;
552  if (kBPFValidMuon(sr) == false) return -5.f;
553 
554  //
555  // HARDCODED ASSUMPTION: about only having one vertex... ...for now...
556  //
557 
558  // get best muon prong index
559  unsigned int muIdx = (unsigned int)kCVNMuonIdx(sr);
560 
561  // Assuming we've passed the kBPFValidMuonTrack cut, take the value from the muon track.
562  if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid)
563  hitRatio = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.hitRatio;
564 
565  return hitRatio;
566 
567  });
568 
569 
571  [](const caf::SRProxy *sr)
572  {
573  float trkyposattrans = -5.0;
574  if (kBPFValidMuon(sr) == false) return -5.f;
575 
576  //
577  // HARDCODED ASSUMPTION: about only having one vertex... ...for now...
578  //
579 
580  // get best muon prong index
581  unsigned int muIdx = (unsigned int)kCVNMuonIdx(sr);
582 
583  // Assuming we've passed the kBPFValidMuonTrack cut, take the value from the muon track.
584  if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid)
585  trkyposattrans = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.trkyposattrans;
586 
587  return trkyposattrans;
588 
589  });
590 
591 
593  [](const caf::SRProxy *sr)
594  {
595  float trkfwdcellnd = -5.0;
596  if (kBPFValidMuon(sr) == false) return -5.f;
597 
598  //
599  // HARDCODED ASSUMPTION: about only having one vertex... ...for now...
600  //
601 
602  // get best muon prong index
603  unsigned int muIdx = (unsigned int)kCVNMuonIdx(sr);
604 
605  // Assuming we've passed the kBPFValidMuonTrack cut, take the value from the muon track.
606  if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid)
607  trkfwdcellnd = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.trkfwdcellnd;
608 
609  return trkfwdcellnd;
610 
611  });
612 
613 
614  const Var kBPFBestMuonFwdCell(
615  [](const caf::SRProxy *sr)
616  {
617  float trkfwdcell = -5.0;
618  if (kBPFValidMuon(sr) == false) return -5.f;
619 
620  //
621  // HARDCODED ASSUMPTION: about only having one vertex... ...for now...
622  //
623 
624  // get best muon prong index
625  unsigned int muIdx = (unsigned int)kCVNMuonIdx(sr);
626 
627  // Assuming we've passed the kBPFValidMuonTrack cut, take the value from the muon track.
628  if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid)
629  trkfwdcell = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.trkfwdcell;
630 
631  return trkfwdcell;
632 
633  });
634 
635 
637  [](const caf::SRProxy *sr)
638  {
639  float trkbakcellnd = -5.0;
640  if (kBPFValidMuon(sr) == false) return -5.f;
641 
642  //
643  // HARDCODED ASSUMPTION: about only having one vertex... ...for now...
644  //
645 
646  // get best muon prong index
647  unsigned int muIdx = (unsigned int)kCVNMuonIdx(sr);
648 
649  // Assuming we've passed the kBPFValidMuonTrack cut, take the value from the muon track.
650  if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid)
651  trkbakcellnd = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.trkbakcellnd;
652 
653  return trkbakcellnd;
654 
655  });
656 
657 
658  const Var kBPFBestMuonBakCell(
659  [](const caf::SRProxy *sr)
660  {
661  float trkbakcell = -5.0;
662  if (kBPFValidMuon(sr) == false) return -5.f;
663 
664  //
665  // HARDCODED ASSUMPTION: about only having one vertex... ...for now...
666  //
667 
668  // get best muon prong index
669  unsigned int muIdx = (unsigned int)kCVNMuonIdx(sr);
670 
671  // Assuming we've passed the kBPFValidMuonTrack cut, take the value from the muon track.
672  if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid)
673  trkbakcell = sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.trkbakcell;
674 
675  return trkbakcell;
676 
677  });
678 
679 
680 
681  const MultiVar kBPFPionRecoE(
682  [](const caf::SRProxy *sr)
683  {
684 
685  // get best muon prong index
686  unsigned int muIdx = (unsigned int)kCVNMuonIdx(sr);
687 
688  std::vector<double> recoE;
689 
690  // loop over all verticies, prongs, and tracks
691  if(sr->vtx.elastic.IsValid){
692  for(unsigned int png_idx = 0; png_idx < sr->vtx.elastic.fuzzyk.png.size(); png_idx++) {
693 
694  // if this prong was the one identified as the muon, then skip it
695  if((unsigned int)png_idx == muIdx) continue;
696 
697  auto &png = sr->vtx.elastic.fuzzyk.png[png_idx];
698 
699  if(!png.bpf.pion.IsValid) continue;
700  // otherwise add the reco E to the vector
701  recoE.push_back(png.bpf.pion.energy);
702 
703  } // end loop over prongs
704 
705  } // end loop over verticies
706 
707  return recoE;
708 
709  });
710 
711 
713  {
714  public:
715  BPFAllTrkLenHelper(int pdg) : fPDG(pdg) {}
716 
717  std::vector<double> operator()(const caf::SRProxy* sr)
718  {
719  std::vector<double> length;
720 
721  // loop over all vertices, prongs, and tracks
722  if( sr->vtx.elastic.IsValid){
723  for(const caf::SRFuzzyKProngProxy& png: sr->vtx.elastic.fuzzyk.png){
724 
725  if(fPDG == 13) length.push_back(png.bpf.muon.len);
726  if(fPDG == 211) length.push_back(png.bpf.pion.len);
727  if(fPDG == 2212) length.push_back(png.bpf.proton.len);
728 
729  } // end loop over prongs
730  } // end loop over verticies
731 
732  return length;
733  }
734  protected:
735  int fPDG;
736  };
737 
741 
742 }
const XML_Char int len
Definition: expat.h:262
caf::Proxy< size_t > npng
Definition: SRProxy.h:2038
Near Detector underground.
Definition: SREnums.h:10
std::vector< double > operator()(const caf::SRProxy *sr)
Definition: BPFVars.cxx:717
const Var kBPFBestMuonStopz([](const caf::SRProxy *sr){float stopz=-999.0;if(kBPFValidMuon(sr)==false) return-999.f; unsigned int muIdx=(unsigned int) kCVNMuonIdx(sr);if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid) stopz=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.stop.z/100.0;return stopz;})
: Reco End Z-position for the best muon track
Definition: BPFVars.h:75
caf::Proxy< caf::SRFuzzyK > fuzzyk
Definition: SRProxy.h:2059
const Var kBPFBestMuonTrkNPlaneGap([](const caf::SRProxy *sr){int nplanegap=500;if(kBPFValidMuon(sr)==false) return 500;unsigned int muIdx=(unsigned int) kCVNMuonIdx(sr);if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid) nplanegap=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.nplanegap;return nplanegap;})
: Number of missing planes for best muon track
Definition: BPFVars.h:141
Far Detector at Ash River.
Definition: SREnums.h:11
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const Var kBPFBestMuonDirx([](const caf::SRProxy *sr){float dirx=-5.0;if(kBPFValidMuon(sr)==false) return-5.f; unsigned int muIdx=(unsigned int) kCVNMuonIdx(sr);if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid) dirx=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.dir.x;return dirx;})
: Reco Start X-direction for the best muon track
Definition: BPFVars.h:81
const Var kBPFBestMuonHitRatio([](const caf::SRProxy *sr){float hitRatio=-5.0;if(kBPFValidMuon(sr)==false) return-5.f; unsigned int muIdx=(unsigned int) kCVNMuonIdx(sr);if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid) hitRatio=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.hitRatio;return hitRatio;})
: hitRatio for the best muon track
Definition: BPFVars.h:184
const Var kBPFBestMuonStopx([](const caf::SRProxy *sr){float stopx=-999.0;if(kBPFValidMuon(sr)==false) return-999.f; unsigned int muIdx=(unsigned int) kCVNMuonIdx(sr);if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid) stopx=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.stop.x/100.0;return stopx;})
: Reco End X-position for the best muon track
Definition: BPFVars.h:63
caf::Proxy< caf::SRBpfTrack > pion
Definition: SRProxy.h:1984
caf::Proxy< caf::SRHeader > hdr
Definition: SRProxy.h:2137
const TVector3 beamDirND
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2126
T sqrt(T number)
Definition: d0nt_math.hpp:156
const Var kBPFBestMuonStartx([](const caf::SRProxy *sr){float startx=-999.0;if(kBPFValidMuon(sr)==false) return-999.f; unsigned int muIdx=(unsigned int) kCVNMuonIdx(sr);if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid) startx=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.start.x/100.0;return startx;})
: Reco Start X-position for the best muon track
Definition: BPFVars.h:45
const MultiVar kBPFAllTrkLenProton(BPFAllTrkLenHelper(2212))
: track length for all BPF tracks under the proton assumption
Definition: BPFVars.h:239
const Var kBPFBestMuonStartz([](const caf::SRProxy *sr){float startz=-999.0;if(kBPFValidMuon(sr)==false) return-999.f; unsigned int muIdx=(unsigned int) kCVNMuonIdx(sr);if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid) startz=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.start.z/100.0;return startz;})
: Reco Start Z-position for the best muon track
Definition: BPFVars.h:57
const Var kBPFBestMuonDirz([](const caf::SRProxy *sr){float dirz=-5.0;if(kBPFValidMuon(sr)==false) return-5.f; unsigned int muIdx=(unsigned int) kCVNMuonIdx(sr);if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid) dirz=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.dir.z;return dirz;})
: Reco Start Z-direction for the best muon track
Definition: BPFVars.h:99
const Var kBPFBestMuonCalE([](const caf::SRProxy *sr){float calE=-5.0;if(kBPFValidMuon(sr)==false) return-5.f; unsigned int muIdx=(unsigned int) kCVNMuonIdx(sr);if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid) calE=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.calE;return calE;})
: Cal energy for the best muon track
Definition: BPFVars.h:123
const Var kCVNMuonIdx([](const caf::SRProxy *sr){float longest_idx=-5.0;float longest_len=-5.0;if(sr->vtx.elastic.IsValid){for(unsigned int png_idx=0;png_idx< sr->vtx.elastic.fuzzyk.png.size();png_idx++){auto &png=sr->vtx.elastic.fuzzyk.png[png_idx];if(png.len > longest_len){longest_len=png.len;longest_idx=png_idx;}}} if(longest_len > 500.0) return longest_idx;float best_idx=-5.0;float best_score=-5.0;if(sr->vtx.elastic.IsValid){for(unsigned int png_idx=0;png_idx< sr->vtx.elastic.fuzzyk.png.size();png_idx++){auto &png=sr->vtx.elastic.fuzzyk.png[png_idx];if(png.cvnpart.muonid > best_score){best_score=png.cvnpart.muonid;best_idx=png_idx;}}}return best_idx;})
: Prong index of best muon prong by CVN score & length
Definition: CVNProngVars.h:19
Proxy for caf::SRFuzzyKProng.
Definition: SRProxy.h:2003
const MultiVar kBPFAllTrkLenPion(BPFAllTrkLenHelper(211))
: track length for all BPF tracks under the pion assumption
Definition: BPFVars.h:234
const TVector3 beamDirFD
const Var kBPFBestMuonPx([](const caf::SRProxy *sr){float px=-5.0;if(kBPFValidMuon(sr)==false) return-5.f; unsigned int muIdx=(unsigned int) kCVNMuonIdx(sr);if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid) px=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.momentum.x;return px;})
: Reco X-momentum for the best muon track
Definition: BPFVars.h:105
_Var< caf::SRProxy > Var
Representation of a variable to be retrieved from a caf::StandardRecord object.
Definition: Var.h:74
const Var kBPFBestMuondEdXLL([](const caf::SRProxy *sr){float dEdXLL=-999.0;if(kBPFValidMuon(sr)==false) return-5.f; unsigned int muIdx=(unsigned int) kCVNMuonIdx(sr);if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid) dEdXLL=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.dEdXLL;return dEdXLL;})
: dEdXLL for the best muon track
Definition: BPFVars.h:177
caf::Proxy< caf::SRElastic > elastic
Definition: SRProxy.h:2118
caf::Proxy< float > len
Definition: SRProxy.h:1675
const Var kBPFBestMuonTrkE([](const caf::SRProxy *sr){float trkE=-5.0;if(kBPFValidMuon(sr)==false) return-5.f; unsigned int muIdx=(unsigned int) kCVNMuonIdx(sr);if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid) trkE=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.energy;return trkE;})
: Track energy for the best muon track
Definition: BPFVars.h:129
const Var kBPFBestMuonPz([](const caf::SRProxy *sr){float pz=-5.0;if(kBPFValidMuon(sr)==false) return-5.f; unsigned int muIdx=(unsigned int) kCVNMuonIdx(sr);if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid) pz=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.momentum.z;return pz;})
: Reco Z-momentum for the best muon track
Definition: BPFVars.h:117
caf::Proxy< std::vector< caf::SRFuzzyKProng > > png
Definition: SRProxy.h:2043
caf::Proxy< caf::SRBpf > bpf
Definition: SRProxy.h:2016
length
Definition: demo0.py:21
const Var kBPFBestMuonBakCell([](const caf::SRProxy *sr){float trkbakcell=-5.0;if(kBPFValidMuon(sr)==false) return-5.f; unsigned int muIdx=(unsigned int) kCVNMuonIdx(sr);if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid) trkbakcell=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.trkbakcell;return trkbakcell;})
: Projected number of cells from endpoint backward to detector edge for the best muon track ...
Definition: BPFVars.h:208
const Var kBPFBestMuonCosNumi([](const caf::SRProxy *sr){float cosnumi=-5.0;if(kBPFValidMuon(sr)==false) return-5.f; unsigned int muIdx=(unsigned int) kCVNMuonIdx(sr);if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid){if(sr->hdr.det==caf::kNEARDET) cosnumi=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.dir.Dot(beamDirND);if(sr->hdr.det==caf::kFARDET) cosnumi=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.dir.Dot(beamDirFD);}return cosnumi;})
: Cos(NuMI beam dir) w.r.t. Best BPF Muon track
Definition: BPFVars.h:156
caf::Proxy< caf::SRBpfTrack > muon
Definition: SRProxy.h:1983
const Var kBPFBestMuonNhits([](const caf::SRProxy *sr){float Nhits=-5.0;if(kBPFValidMuon(sr)==false) return-999.f; unsigned int muIdx=(unsigned int) kCVNMuonIdx(sr);if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid) Nhits=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.nhit;return Nhits;})
: Number of hits in the best muon track
Definition: BPFVars.h:39
caf::Proxy< caf::SRBpfTrack > proton
Definition: SRProxy.h:1985
caf::StandardRecord * sr
const Var kBPFBestMuonStopy([](const caf::SRProxy *sr){float stopy=-999.0;if(kBPFValidMuon(sr)==false) return-999.f; unsigned int muIdx=(unsigned int) kCVNMuonIdx(sr);if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid) stopy=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.stop.y/100.0;return stopy;})
: Reco End Y-position for the best muon track
Definition: BPFVars.h:69
const Var kBPFBestMuonPosAtTrans([](const caf::SRProxy *sr){float trkyposattrans=-5.0;if(kBPFValidMuon(sr)==false) return-5.f; unsigned int muIdx=(unsigned int) kCVNMuonIdx(sr);if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid) trkyposattrans=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.trkyposattrans;return trkyposattrans;})
: Position at the MuCat transition for the best muon track
Definition: BPFVars.h:192
const Var kBPFBestMuonStarty([](const caf::SRProxy *sr){float starty=-999.0;if(kBPFValidMuon(sr)==false) return-999.f; unsigned int muIdx=(unsigned int) kCVNMuonIdx(sr);if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid) starty=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.start.y/100.0;return starty;})
: Reco Start Y-position for the best muon track
Definition: BPFVars.h:51
const Var kBPFBestMuonDiry([](const caf::SRProxy *sr){float diry=-5.0;if(kBPFValidMuon(sr)==false) return-5.f; unsigned int muIdx=(unsigned int) kCVNMuonIdx(sr);if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid) diry=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.dir.y;return diry;})
: Reco Start Y-direction for the best muon track
Definition: BPFVars.h:87
int nplanes
Definition: geom.C:145
const TVector3 beamDirND
const MultiVar kBPFPionRecoE([](const caf::SRProxy *sr){unsigned int muIdx=(unsigned int) kCVNMuonIdx(sr);std::vector< double > recoE;if(sr->vtx.elastic.IsValid){for(unsigned int png_idx=0;png_idx< sr->vtx.elastic.fuzzyk.png.size();png_idx++){if((unsigned int) png_idx==muIdx) continue;auto &png=sr->vtx.elastic.fuzzyk.png[png_idx];if(!png.bpf.pion.IsValid) continue;recoE.push_back(png.bpf.pion.energy);}}return recoE;})
: EXAMPLE MULTIVAR: reco E for all "pion-like" tracks
Definition: BPFVars.h:224
const Var kBPFBestMuonFwdCell([](const caf::SRProxy *sr){float trkfwdcell=-5.0;if(kBPFValidMuon(sr)==false) return-5.f; unsigned int muIdx=(unsigned int) kCVNMuonIdx(sr);if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid) trkfwdcell=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.trkfwdcell;return trkfwdcell;})
: Projected number of cells from endpoint forward to detector edge for the best muon track ...
Definition: BPFVars.h:200
const MultiVar kBPFAllTrkLenMuon(BPFAllTrkLenHelper(13))
: track length for all BPF tracks under the muon assumption
Definition: BPFVars.h:229
caf::Proxy< bool > IsValid
Definition: SRProxy.h:2058
const Var kBPFBestMuonTrkNPlanes([](const caf::SRProxy *sr){int nplanes=500;if(kBPFValidMuon(sr)==false) return 500;unsigned int muIdx=(unsigned int) kCVNMuonIdx(sr);if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid) nplanes=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.nplane;return nplanes;})
: Number of planes for best muon track
Definition: BPFVars.h:147
BPFAllTrkLenHelper(int pdg)
Definition: BPFVars.cxx:715
const Var kBPFBestMuonCosDirY([](const caf::SRProxy *sr){float diry=kBPFBestMuonDiry(sr);if(diry==-5) return diry;else return(float) cos(diry);})
: Cosine of Reco Start Y-direction for the best muon track
Definition: BPFVars.h:93
_MultiVar< caf::SRProxy > MultiVar
Definition: MultiVar.h:52
const Cut kBPFValidMuon
: Make sure CVN-prong returns a valid muon score.
Definition: BPFCuts.cxx:16
T cos(T number)
Definition: d0nt_math.hpp:78
TCut cosnumi("cosnumi>0.95")
TVector3 NuMIBeamDirection(caf::Det_t det)
Average direction of NuMI neutrinos in a given detector This function is a copy of geo::GeometryBase:...
Definition: Utilities.cxx:329
const Var kBPFBestMuonFwdCellND([](const caf::SRProxy *sr){float trkfwdcellnd=-5.0;if(kBPFValidMuon(sr)==false) return-5.f; unsigned int muIdx=(unsigned int) kCVNMuonIdx(sr);if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid) trkfwdcellnd=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.trkfwdcellnd;return trkfwdcellnd;})
: Projected number of cells from endpoint forward to detector edge in ND for the best muon track ...
Definition: BPFVars.h:196
caf::Proxy< caf::SRVertexBranch > vtx
Definition: SRProxy.h:2146
const Var kBPFBestMuonChi2T([](const caf::SRProxy *sr){float chi2T=-5.0;if(kBPFValidMuon(sr)==false) return-5.f; unsigned int muIdx=(unsigned int) kCVNMuonIdx(sr);if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid) chi2T=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.chi2T;return chi2T;})
: chi2T for the best muon track
Definition: BPFVars.h:170
const Var kBPFBestMuonPy([](const caf::SRProxy *sr){float py=-5.0;if(kBPFValidMuon(sr)==false) return-5.f; unsigned int muIdx=(unsigned int) kCVNMuonIdx(sr);if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid) py=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.momentum.y;return py;})
: Reco Y-momentum for the best muon track
Definition: BPFVars.h:111
const Var kBPFBestMuonNpng([](const caf::SRProxy *sr){float npng=-5.0;if(kBPFValidMuon(sr)==false) return-999.f;npng=sr->vtx.elastic.fuzzyk.npng;return npng;})
: Best muon PID for the slice
Definition: BPFVars.h:33
const Var kBPFBestMuonPtP([](const caf::SRProxy *sr){float ptp=-5.0;if(kBPFValidMuon(sr)==false) return-5.f; unsigned int muIdx=(unsigned int) kCVNMuonIdx(sr);double Zbeam=-5.0;if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid){if(sr->hdr.det==caf::kNEARDET) Zbeam=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.dir.Dot(beamDirND);if(sr->hdr.det==caf::kFARDET) Zbeam=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.dir.Dot(beamDirFD);}if(Zbeam==-5.0) ptp=-5.0;else ptp=sqrt(1-Zbeam *Zbeam);return ptp;})
: Pt/P for Best Muon track
Definition: BPFVars.h:152
const Var kBPFLongestMuonTrkLen([](const caf::SRProxy *sr){float length=-1.0;if(kBPFValidMuon(sr)==false) return-5.f;if(sr->vtx.elastic.IsValid){for(unsigned int png_idx=0;png_idx< sr->vtx.elastic.fuzzyk.png.size();png_idx++){auto &png=sr->vtx.elastic.fuzzyk.png[png_idx]; if(png.bpf.muon.len > length &&png.bpf.muon.IsValid){length=png.bpf.muon.len;}}}return length;})
: EXAMPLE VAR: longest track length under the muon assumption
Definition: BPFVars.h:163
const Var kBPFBestMuonBakCellND([](const caf::SRProxy *sr){float trkbakcellnd=-5.0;if(kBPFValidMuon(sr)==false) return-5.f; unsigned int muIdx=(unsigned int) kCVNMuonIdx(sr);if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid) trkbakcellnd=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.trkbakcellnd;return trkbakcellnd;})
: Projected number of cells from endpoint backward to detector edge in ND for the best muon track ...
Definition: BPFVars.h:204
const Var kBPFBestMuonTrkLen([](const caf::SRProxy *sr){float len=-1.0;if(kBPFValidMuon(sr)==false) return-5.f; unsigned int muIdx=(unsigned int) kCVNMuonIdx(sr);if(sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.IsValid) len=sr->vtx.elastic.fuzzyk.png[muIdx].bpf.muon.len/100.0;return len;})
: Reco length for the best muon track
Definition: BPFVars.h:135
caf::Proxy< caf::Det_t > det
Definition: SRProxy.h:232