All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TruthVars.cxx
Go to the documentation of this file.
3 
4 #include "sbnanaobj/StandardRecord/Proxy/SRProxy.h"
5 
6 #include <cassert>
7 #include <cmath>
8 
9 namespace ana
10 {
11  const Var kHasTruthMatch(
12  [](const caf::SRSliceProxy *slc) -> double
13  {
14  return ( slc->truth.index != -1);
15  }
16  );
17 
18  const Var kCompletness(
19  [](const caf::SRSliceProxy *slc) -> double
20  {
21  return ( kHasTruthMatch(slc) ? (float)slc->tmatch.eff : -5.f);
22  }
23  );
24 
25  const Var kTruthEnergy(
26  [](const caf::SRSliceProxy *slc) -> double
27  {
28  return ( kHasTruthMatch(slc) ? (float)slc->truth.E : -5.f );
29  }
30  );
31 
32  const Var kTruthVtxX(
33  [](const caf::SRSliceProxy *slc) -> double
34  {
35  return ( kHasTruthMatch(slc) ? (float)slc->truth.position.x : -999.f );
36  }
37  );
38 
39  const Var kTruthVtxY(
40  [](const caf::SRSliceProxy *slc) -> double
41  {
42  return ( kHasTruthMatch(slc) ? (float)slc->truth.position.y : -999.f );
43  }
44  );
45 
46  const Var kTruthVtxZ(
47  [](const caf::SRSliceProxy *slc) -> double
48  {
49  return ( kHasTruthMatch(slc) ? (float)slc->truth.position.z : -999.f );
50  }
51  );
52 
53  const Var kTruthVtxDistX(
54  [](const caf::SRSliceProxy *slc) -> double
55  {
56  return ( kHasTruthMatch(slc) ? (float)std::abs( slc->truth.position.x - kSlcVtxX(slc) ) : -999.f );
57  }
58  );
59 
60  const Var kTruthVtxDistY(
61  [](const caf::SRSliceProxy *slc) -> double
62  {
63  return ( kHasTruthMatch(slc) ? (float)std::abs( slc->truth.position.y - kSlcVtxY(slc) ) : -999.f );
64  }
65  );
66 
67  const Var kTruthVtxDistZ(
68  [](const caf::SRSliceProxy *slc) -> double
69  {
70  return ( kHasTruthMatch(slc) ? (float)std::abs( slc->truth.position.z - kSlcVtxZ(slc) ) : -999.f );
71  }
72  );
73 
74  const Var kTruthVtxDistMag(
75  [](const caf::SRSliceProxy *slc) -> double
76  {
77  return ( kHasTruthMatch(slc) ? (float)std::hypot( kTruthVtxDistX(slc), kTruthVtxDistY(slc), kTruthVtxDistZ(slc) ) : -5.f );
78  }
79  );
80 
81  // -----------------------------------------------------------------
82  // Spill vars
83 
84  const SpillVar kTruthNuEnergy([](const caf::SRSpillProxy* sr) -> double {
85  return (sr->mc.nnu != 1 ? -5.f : (float)sr->mc.nu[0].E);
86  });
87 
88  const SpillVar kTruthLeptonEnergy([](const caf::SRSpillProxy* sr) -> double {
89  if (sr->mc.nnu != 1) return -5.f;
90 
91  for (auto const& prim : sr->mc.nu[0].prim) {
92  if (std::abs(prim.pdg) != 11 && std::abs(prim.pdg) != 13)
93  continue;
94 
95  return prim.startE;
96  }
97  return -5.f;
98  });
99 
100 }
then if[["$THISISATEST"==1]]
Definition: neoSmazza.sh:95
const Var kCompletness([](const caf::SRSliceProxy *slc) -> double{return(kHasTruthMatch(slc)?(float) slc->tmatch.eff:-5.f);})
Definition: TruthVars.h:8
const Var kTruthEnergy([](const caf::SRSliceProxy *slc) -> double{return(kHasTruthMatch(slc)?(float) slc->truth.E:-5.f);})
Definition: TruthVars.h:10
const Var kTruthVtxY([](const caf::SRSliceProxy *slc) -> double{return(kHasTruthMatch(slc)?(float) slc->truth.position.y:-999.f);})
Definition: TruthVars.h:13
const Var kTruthVtxDistMag([](const caf::SRSliceProxy *slc) -> double{return(kHasTruthMatch(slc)?(float) std::hypot(kTruthVtxDistX(slc), kTruthVtxDistY(slc), kTruthVtxDistZ(slc)):-5.f);})
Definition: TruthVars.h:20
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 kSlcVtxX([](const caf::SRSliceProxy *slc) -> double{return slc->vertex.x;})
Definition: Vars.h:30
const SpillVar kTruthNuEnergy([](const caf::SRSpillProxy *sr) -> double{return(sr->mc.nnu!=1?-5.f:(float) sr->mc.nu[0].E);})
Definition: TruthVars.h:22
const Var kSlcVtxY([](const caf::SRSliceProxy *slc) -> double{return slc->vertex.y;})
Definition: Vars.h:31
const Var kTruthVtxZ([](const caf::SRSliceProxy *slc) -> double{return(kHasTruthMatch(slc)?(float) slc->truth.position.z:-999.f);})
Definition: TruthVars.h:14
T abs(T value)
_Var< caf::SRSpillProxy > SpillVar
Equivalent of Var acting on caf::SRSpill.
Definition: Var.h:76
const Var kSlcVtxZ([](const caf::SRSliceProxy *slc) -> double{return slc->vertex.z;})
Definition: Vars.h:32
for($it=0;$it< $RaceTrack_number;$it++)
caf::Proxy< caf::StandardRecord > SRSpillProxy
Definition: EpilogFwd.h:3
const Var kTruthVtxX([](const caf::SRSliceProxy *slc) -> double{return(kHasTruthMatch(slc)?(float) slc->truth.position.x:-999.f);})
Definition: TruthVars.h:12
const Var kTruthVtxDistY([](const caf::SRSliceProxy *slc) -> double{return(kHasTruthMatch(slc)?(float) std::abs(slc->truth.position.y-kSlcVtxY(slc)):-999.f);})
Definition: TruthVars.h:17
const Var kHasTruthMatch([](const caf::SRSliceProxy *slc) -> double{return(slc->truth.index!=-1);})
Definition: TruthVars.h:7
const Var kTruthVtxDistX([](const caf::SRSliceProxy *slc) -> double{return(kHasTruthMatch(slc)?(float) std::abs(slc->truth.position.x-kSlcVtxX(slc)):-999.f);})
Definition: TruthVars.h:16
const Var kTruthVtxDistZ([](const caf::SRSliceProxy *slc) -> double{return(kHasTruthMatch(slc)?(float) std::abs(slc->truth.position.z-kSlcVtxZ(slc)):-999.f);})
Definition: TruthVars.h:18
const SpillVar kTruthLeptonEnergy([](const caf::SRSpillProxy *sr) -> double{if(sr->mc.nnu!=1) return-5.f;for(auto const &prim:sr->mc.nu[0].prim){if(std::abs(prim.pdg)!=11 &&std::abs(prim.pdg)!=13) continue;return prim.startE;}return-5.f;})
Definition: TruthVars.h:23