NumubarCCpi0_Vars.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "CAFAna/Core/Var.h"
7 #include "TMath.h"
8 #include "TDatabasePDG.h"
9 
10 namespace ana
11 {
12  namespace numubarccpi0
13  {
14 
15  // Muon Mass
16  inline double MuonMass()
17  {
18  static TDatabasePDG* pdgdb = TDatabasePDG::Instance();
19  static double mass = pdgdb->GetParticle(-13)->Mass();
20  return mass;
21  }
22 
23  inline double NeutronMass()
24  {
25  static TDatabasePDG* pdgdb = TDatabasePDG::Instance();
26  static double mass = pdgdb->GetParticle(2112)->Mass();
27  return mass;
28  }
29 
30  inline double ProtonMass()
31  {
32  static TDatabasePDG* pdgdb = TDatabasePDG::Instance();
33  static double mass = pdgdb->GetParticle(2212)->Mass();
34  return mass;
35  }
36 
37  const Var kMuonMass([](const caf::SRProxy* sr)
38  {
39  return MuonMass();
40  });
41 
42  const Var kNeutronMass([](const caf::SRProxy* sr)
43  {
44  return NeutronMass();
45  });
46 
47  const Var kProtonMass([](const caf::SRProxy* sr)
48  {
49  return ProtonMass();
50  });
51 
52  // Pi0 Mass
53  inline double Pi0Mass()
54  {
55  static TDatabasePDG* pdgdb = TDatabasePDG::Instance();
56  static double mass = pdgdb->GetParticle(111)->Mass();
57  return mass;
58  }
59  const Var kPi0Mass([](const caf::SRProxy* sr)
60  {
61  return Pi0Mass();
62  });
63 
64  extern const NuTruthVar kTruthTag_NT;
65  const Var kTruthTag = VarFromNuTruthVar(kTruthTag_NT);
66 
67  // Number of true pi0s
70  const Var kNPrimaryPi0 = VarFromNuTruthVar(kNPrimaryPi0_NT);
71  const Var kNSecondaryPi0 = VarFromNuTruthVar(kNSecondaryPi0_NT);
72 
73  //Truth Variables
74  extern const NuTruthVar kTrueMuKE_NT;
75  extern const NuTruthVar kTrueMuP_NT;
76  extern const NuTruthVar kTrueNuE_NT;
77  const Var kTrueMuKE = VarFromNuTruthVar(kTrueMuKE_NT);
78  const Var kTrueMuP = VarFromNuTruthVar(kTrueMuP_NT);
79  const Var kTrueNuE = VarFromNuTruthVar(kTrueNuE_NT);
80 
81  extern const NuTruthVar kTrueNuQ2_NT;
82  extern const NuTruthVar kTrueNuW_NT;
83  const Var kTrueNuQ2 = VarFromNuTruthVar(kTrueNuQ2_NT);
84  const Var kTrueNuW = VarFromNuTruthVar(kTrueNuW_NT);
85 
89  const Var kTrueMuDirZ_Cos = VarFromNuTruthVar(kTrueMuDirZ_Cos_NT);
90  const Var kTrueMuDirZ_Rad = VarFromNuTruthVar(kTrueMuDirZ_Rad_NT);
91  const Var kTrueMuDirZ_Deg = VarFromNuTruthVar(kTrueMuDirZ_Deg_NT);
92 
100 
101  const Var kTruePrimPi0_ID = VarFromNuTruthVar(kTruePrimPi0_ID_NT);
102  const Var kTruePrimPi0E = VarFromNuTruthVar(kTruePrimPi0E_NT);
103  const Var kTruePrimPi0P = VarFromNuTruthVar(kTruePrimPi0P_NT);
104  const Var kTruePrimPi0DirZ_Cos = VarFromNuTruthVar(kTruePrimPi0DirZ_Cos_NT);
105  const Var kTruePrimPi0DirZ_Rad = VarFromNuTruthVar(kTruePrimPi0DirZ_Rad_NT);
106  const Var kTruePrimPi0DirZ_Deg = VarFromNuTruthVar(kTruePrimPi0DirZ_Deg_NT);
107  const Var kTruePrimPi0KE = VarFromNuTruthVar(kTruePrimPi0KE_NT);
108 
113 
114  const Var kTrueSecoPi0_ID1 = VarFromNuTruthVar(kTrueSecoPi0_ID1_NT);
115  const Var kTrueSecoPi0_ID2 = VarFromNuTruthVar(kTrueSecoPi0_ID2_NT);
116  const Var kTrueSecoPi0E = VarFromNuTruthVar(kTrueSecoPi0E_NT);
117  const Var kTrueSecoPi0P = VarFromNuTruthVar(kTrueSecoPi0P_NT);
118 
119  //Using Variables as defined in https://arxiv.org/pdf/2002.05812.pdf
120  //ToDo: These probably aren't ready for primetime just yet
121  //Need to go through the calculation in the near future
125 
126  const Var kTrueHadronicSystemP = VarFromNuTruthVar(kTrueHadronicSystemP_NT);
127  const Var kTrueDeltaPtt = VarFromNuTruthVar(kTrueDeltaPtt_NT);
128  const Var kTrueDeltaAlpha = VarFromNuTruthVar(kTrueDeltaAlpha_NT);
129 
130  // Number of prongs in one slice
131  extern const Var kNProngs;
132 
133  // Muon track / MuonID
134  extern const Var kBestTrack;
135  extern const Var kMuonID;
136 
137  // Muon-like prong index
138  extern const Var kMuonPngIdx;
139  extern const Var kCVNMuonIdx_4view;
140  extern const Var kCVNMuonIdx_5label;
141  double GetCVNProngMuonScore_4view(unsigned int ProngIdx, caf::SRProxy *sr);
142  double GetCVNProngMuonScore_5label(unsigned int ProngIdx, caf::SRProxy *sr);
149 
150  // Muon track lengths
151  extern const Var kTrkLenAct;
152  extern const Var kTrkLenCat;
153  const Var kTrkLenActandCat = kTrkLenAct + kTrkLenCat;
154 
155  // Muon energy for inclusive numuCC
156  extern const Var kIncXsecMuonE;
157  const Var kRecoMuKE = kIncXsecMuonE - kMuonMass;
158  extern const Var kIncXsecHadE;
159  // Neutrino Energy for Inclusive numuCC
160  const Var kIncXsecNuE = kIncXsecMuonE + kIncXsecHadE;
161  // Standard analysis vars and axes
163 
164  //Reco Muon Vars
165  extern const Var kRecoMuonP;
166  extern const Var kRecoMuonDirZ_Rag;
167  extern const Var kRecoMuonDirZ_Deg;
168  extern const Var kRecoMuonDirZ_Cos;
169 
170  //Reco Q2
171  extern const Var kRecoQ2;
172 
173  //Reco W
174  extern const Var kRecoW2;
175  extern const Var kRecoW;
176 
177 
178 
179  //Prong CVN stuff
180  int Prong1ID_Generator(const caf::SRProxy* sr, std::string id_type);
181  int Prong2ID_Generator(const caf::SRProxy* sr, std::string id_type);
182 
183  // Nominal 4-view CVN
184  extern const Var kProng1ID_4view;
185  extern const Var kProng2ID_4view;
186  extern const Var kProng1Score_4view;
187  extern const Var kProng2Score_4view;
188  extern const Var kProng1NHit_4view;
189  extern const Var kProng1NHitX_4view;
190  extern const Var kProng1NHitY_4view;
191  extern const Var kProng2NHit_4view;
192  extern const Var kProng2NHitX_4view;
193  extern const Var kProng2NHitY_4view;
194  extern const Var kProng1TruePDG_4view;
195  extern const Var kProng2TruePDG_4view;
196 
197  // SP Prong CVN -- emid network
198  extern const Var kProng1ID_emid;
199  extern const Var kProng2ID_emid;
200  extern const Var kProng1Score_emid;
201  extern const Var kProng2Score_emid;
202  extern const Var kProng1NHit_emid;
203  extern const Var kProng1NHitX_emid;
204  extern const Var kProng1NHitY_emid;
205  extern const Var kProng2NHit_emid;
206  extern const Var kProng2NHitX_emid;
207  extern const Var kProng2NHitY_emid;
208  extern const Var kProng1TruePDG_emid;
209  extern const Var kProng2TruePDG_emid;
210 
217 
218  extern const Var kProng1TruthEff_emid;
219  extern const Var kProng2TruthEff_emid;
220  extern const Var kProng1TruthPur_emid;
221  extern const Var kProng2TruthPur_emid;
222  extern const Var kProng1CalE_emid;
223  extern const Var kProng2CalE_emid;
224  extern const Var kProng1TruthE_emid;
225  extern const Var kProng2TruthE_emid;
226  extern const Var kProng1E_Reso_emid;
227  extern const Var kProng2E_Reso_emid;
228  extern const Var kProng1DirZ_Cos_emid;
229  extern const Var kProng2DirZ_Cos_emid;
230  extern const Var kProng1DirZ_Rad_emid;
231  extern const Var kProng2DirZ_Rad_emid;
232  //extern const Var kProng1DirZ_Deg_emid;
233  //extern const Var kProng2DirZ_Deg_emid;
238  //extern const Var kProng1TruthDirZ_Deg_emid;
239  //extern const Var kProng2TruthDirZ_Deg_emid;
246 
253  //extern const Var kTwoProngOpenAngle_Reso_Cos_emid;
255  //extern const Var kTwoProngOpenAngle_Reso_Deg_emid;
256 
257  // SP Prong CVN -- 5label network
258  extern const Var kProng1ID_5label;
259  extern const Var kProng2ID_5label;
260  extern const Var kProng1Score_5label;
261  extern const Var kProng2Score_5label;
262  extern const Var kProng1NHit_5label;
263  extern const Var kProng1NHitX_5label;
264  extern const Var kProng1NHitY_5label;
265  extern const Var kProng2NHit_5label;
266  extern const Var kProng2NHitX_5label;
267  extern const Var kProng2NHitY_5label;
268 
269  //Reco pi0 invariant mass
270  extern const Var kPi0Mass_4view;
271  extern const Var kPi0Mass_emid;
272  extern const Var kPi0Mass_5label;
273 
274  // Reco pi0 kinetic variables
275  extern const Var kRecoPi0P_4view;
279  extern const Var kRecoPi0P_1_emid;
280  extern const Var kRecoPi0P_2_emid;
284 
285 
286  //Resolution Vars
287  extern const Var kNuE_Diff;
288  extern const Var kQ2_Diff;
289  extern const Var kW_Diff;
290  extern const Var kMuP_Diff;
291  extern const Var kMuDeg_Diff;
292  extern const Var kPi0P_Diff;
293  extern const Var kPi0Deg_Diff;
294 
295  } // end of namespace numubarccpi0
296 } // end of namespace ana
const Var kProng2ID_4view([](const caf::SRProxy *sr){return Prong2ID_Generator(sr,"4view");})
const Var k4viewMuonPng_MuonScore_4view([](const caf::SRProxy *sr){return(float) GetCVNProngMuonScore_4view(kCVNMuonIdx_4view(sr), sr);})
const NuTruthVar kNPrimaryPi0_NT([](const caf::SRNeutrinoProxy *truth){int nprims=truth->prim.size();int countpi0=0;for(int i=0;i< nprims;++i){if(truth->prim[i].pdg==111) countpi0++;}return countpi0;})
const Var kProng1NHitX_emid([](const caf::SRProxy *sr){int png1=kProng1ID_emid(sr);if(png1< 0) return-5;return(int) sr->vtx.elastic.fuzzyk.png[png1].nhitx;})
const Var kProng1Score_emid([](const caf::SRProxy *sr){int png1=kProng1ID_emid(sr);if(png1< 0) return-5.0f;const auto &p1=sr->vtx.elastic.fuzzyk.png[png1];return(float)(p1.spprongcvnpartnumuccemid.emid);})
const Var kNuE_Diff([](const caf::SRProxy *sr){float truth=kTrueNuE(sr);float reco=kRecoE(sr);if(truth< 0||reco< 0) return(-5.0f);return(float)(reco-truth);})
const Var kPi0Mass([](const caf::SRProxy *sr){return Pi0Mass();})
const NuTruthVar kTrueMuDirZ_Rad_NT([](const caf::SRNeutrinoProxy *truth){if(abs(truth->pdg)!=14||!truth->iscc) return-5.0;int nprims=truth->prim.size();for(int iprim=0;iprim< nprims;iprim++){if(abs(truth->prim[iprim].pdg)==13){TVector3 mudir=truth->prim[iprim].p.Vect();TVector3 beamdir=NuMIBeamDirection(caf::kNEARDET);return mudir.Unit().Angle(beamdir.Unit());}}return-5.0;})
const NuTruthVar kTrueSecoPi0E_NT([](const caf::SRNeutrinoProxy *truth){int TruePi0_ID1=kTrueSecoPi0_ID1_NT(truth);int TruePi0_ID2=kTrueSecoPi0_ID2_NT(truth);if(TruePi0_ID1< 0||TruePi0_ID2< 0) return-5.0f;return(float) truth->prim[TruePi0_ID1].daughterEnergies[TruePi0_ID2];})
const Var kRecoPi0P_2_emid([](const caf::SRProxy *sr){int png1=kProng1ID_emid(sr);int png2=kProng2ID_emid(sr);if(png1< 0||png2< 0) return-5.0f;const auto &p1=sr->vtx.elastic.fuzzyk.png[png1];const auto &p2=sr->vtx.elastic.fuzzyk.png[png2];float pi0E=p1.calE+p2.calE;if(pi0E< Pi0Mass()) return-1.0f;return(float)(sqrt(std::pow(pi0E, 2)-std::pow(Pi0Mass(), 2)));})
const NuTruthVar kTrueMuP_NT([](const caf::SRNeutrinoProxy *truth){float pmag=-5;if(abs(truth->pdg)!=14||!truth->iscc) return pmag;int nprims=truth->prim.size();for(int iprim=0;iprim< nprims;iprim++){if(abs(truth->prim[iprim].pdg)==13){pmag=truth->prim[iprim].p.Mag();}}return pmag;})
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const Var kRecoPi0DirZ_Deg_4view([](const caf::SRProxy *sr){float RecoPi0DirZ_Rad=kRecoPi0DirZ_Rad_4view(sr);if(RecoPi0DirZ_Rad > TMath::Pi()||RecoPi0DirZ_Rad< 0.) return-5.0f;return(float)(RecoPi0DirZ_Rad *180./TMath::Pi());})
const Var kPi0P_Diff([](const caf::SRProxy *sr){float truth=kTruePrimPi0P(sr);float reco=kRecoPi0P_1_emid(sr);if(truth< 0||reco< 0) return(-5.0f);return(float)(reco-truth);})
const Var kProng2NHitY_5label([](const caf::SRProxy *sr){int png2=kProng2ID_5label(sr);if(png2< 0) return-5;return(int) sr->vtx.elastic.fuzzyk.png[png2].nhity;})
const Var kProng2DirZ_Diff_Rad_emid([](const caf::SRProxy *sr){int png2=kProng2ID_emid(sr);if(png2< 0) return-5.0f;auto &pngDir=sr->vtx.elastic.fuzzyk.png[png2].dir;TVector3 truthDir=sr->vtx.elastic.fuzzyk.png[png2].truth.p.Vect();return(float) pngDir.Unit().Angle(truthDir.Unit());})
const Var kProng2TruthPur_emid([](const caf::SRProxy *sr){int png2=kProng2ID_emid(sr);if(png2< 0) return-5.0f;return(float) sr->vtx.elastic.fuzzyk.png[png2].truth.pur;})
const Var kTruePrimPi0DirZ_Rad
const Var kRecoPi0DirZ_Cos_emid([](const caf::SRProxy *sr){int png1=kProng1ID_emid(sr);int png2=kProng2ID_emid(sr);if(png1< 0||png2< 0) return-5.0f;const auto &p1=sr->vtx.elastic.fuzzyk.png[png1];const auto &p2=sr->vtx.elastic.fuzzyk.png[png2];TVector3 p=p1.calE *p1.dir.Unit()+p2.calE *p2.dir.Unit();TVector3 beamDirND=NuMIBeamDirection(caf::kNEARDET);return(float) p.Unit().Dot(beamDirND.Unit());})
const NuTruthVar kTrueMuKE_NT([](const caf::SRNeutrinoProxy *nu){float ke=-5;if(abs(nu->pdg)!=14||!nu->iscc) return ke;int nprims=nu->prim.size();for(int iprim=0;iprim< nprims;iprim++){if(abs(nu->prim[iprim].pdg)==13){double E=nu->prim[iprim].p.T();ke=E-MuonMass();}}return ke;})
const Var kBestTrack([](const caf::SRProxy *sr){return(int) sr->trk.kalman.idxmuonid;})
const Var kProng1PhotonScore_emid([](const caf::SRProxy *sr){int png1=kProng1ID_emid(sr);if(png1< 0) return-5.0f;const auto &p1=sr->vtx.elastic.fuzzyk.png[png1];return(float)(p1.spprongcvnpart5label.photonid);})
const Var kProng1TruthE_emid([](const caf::SRProxy *sr){int png1=kProng1ID_emid(sr);if(png1< 0) return-5.0f;return(float) sr->vtx.elastic.fuzzyk.png[png1].truth.p.E;})
const Var kProng2TruePDG_4view([](const caf::SRProxy *sr){int png2=kProng2ID_4view(sr);if(png2< 0) return 0;return(int) sr->vtx.elastic.fuzzyk.png[png2].truth.pdg;})
const Var kProng1NHitY_emid([](const caf::SRProxy *sr){int png1=kProng1ID_emid(sr);if(png1< 0) return-5;return(int) sr->vtx.elastic.fuzzyk.png[png1].nhity;})
const Var kProng2Score_emid([](const caf::SRProxy *sr){int png2=kProng2ID_emid(sr);if(png2< 0) return-5.0f;const auto &p2=sr->vtx.elastic.fuzzyk.png[png2];return(float)(p2.spprongcvnpartnumuccemid.emid);})
const Var kPi0Mass_5label([](const caf::SRProxy *sr){int png1=kProng1ID_5label(sr);int png2=kProng2ID_5label(sr);if(png1< 0||png2< 0) return-5.0f;const auto &p1=sr->vtx.elastic.fuzzyk.png[png1];const auto &p2=sr->vtx.elastic.fuzzyk.png[png2];const float dot=p1.dir.Unit().Dot(p2.dir.Unit());return 1000 *sqrt(2 *p1.calE *p2.calE *(1-dot));})
const Var kProng2TruthDirZ_Cos_emid([](const caf::SRProxy *sr){int png2=kProng2ID_emid(sr);if(png2< 0) return-5.0f;TVector3 pngDir=sr->vtx.elastic.fuzzyk.png[png2].truth.p.Vect();TVector3 beamDirND=NuMIBeamDirection(caf::kNEARDET);return(float) pngDir.Unit().Dot(beamDirND.Unit());})
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2126
const NuTruthVar kTruePrimPi0P_NT([](const caf::SRNeutrinoProxy *truth){int TruePi0_ID=kTruePrimPi0_ID_NT(truth);if(TruePi0_ID< 0) return-5.0f;return(float) truth->prim[TruePi0_ID].p.Mag();})
const Var kProng1DirZ_Diff_Cos_emid([](const caf::SRProxy *sr){int png1=kProng1ID_emid(sr);if(png1< 0) return-5.0f;auto &pngDir=sr->vtx.elastic.fuzzyk.png[png1].dir;TVector3 truthDir=sr->vtx.elastic.fuzzyk.png[png1].truth.p.Vect();return(float) pngDir.Unit().Dot(truthDir.Unit());})
const NuTruthVar kTruePrimPi0DirZ_Cos_NT([](const caf::SRNeutrinoProxy *truth){int TruePi0_ID=kTruePrimPi0_ID_NT(truth);if(TruePi0_ID< 0) return-5.0f;TVector3 Pi0P=truth->prim[TruePi0_ID].p.Vect();TVector3 beamDirND=NuMIBeamDirection(caf::kNEARDET);return(float) Pi0P.Unit().Dot(beamDirND.Unit());})
const Var kMuP_Diff([](const caf::SRProxy *sr){float truth=kTrueMuP(sr);float reco=kRecoMuonP(sr);if(truth< 0||reco< 0) return(-5.0f);return(float)(reco-truth);})
double GetCVNProngMuonScore_4view(int ProngIdx, const caf::SRProxy *sr)
Function to return "adjusted" CVN-prong muon score:
const Var kProng2NHitX_4view([](const caf::SRProxy *sr){int png2=kProng2ID_4view(sr);if(png2< 0) return-5;return(int) sr->vtx.elastic.fuzzyk.png[png2].nhitx;})
const Var kProng2Score_5label([](const caf::SRProxy *sr){int png2=kProng2ID_5label(sr);if(png2< 0) return-5.0f;const auto &p2=sr->vtx.elastic.fuzzyk.png[png2];return(float)(p2.spprongcvnpart5label.emid);})
const Var kProng1ID_emid([](const caf::SRProxy *sr){return Prong1ID_Generator(sr,"emid");})
const Var kProng2NHit_5label([](const caf::SRProxy *sr){int png2=kProng2ID_5label(sr);if(png2< 0) return-5;return(int) sr->vtx.elastic.fuzzyk.png[png2].nhit;})
const Var kProng1DirZ_Cos_emid([](const caf::SRProxy *sr){int png1=kProng1ID_emid(sr);if(png1< 0) return-5.0f;auto &pngDir=sr->vtx.elastic.fuzzyk.png[png1].dir;TVector3 beamDirND=NuMIBeamDirection(caf::kNEARDET);return(float) pngDir.Unit().Dot(beamDirND.Unit());})
const NuTruthVar kTrueNuQ2_NT([](const caf::SRNeutrinoProxy *nu){return nu->q2;})
const Var kMuonPng_MuonScore_5label([](const caf::SRProxy *sr){return(float) GetCVNProngMuonScore_5label(kMuonPngIdx(sr), sr);})
const Var kProng2NHit_emid([](const caf::SRProxy *sr){int png2=kProng2ID_emid(sr);if(png2< 0) return-5;return(int) sr->vtx.elastic.fuzzyk.png[png2].nhit;})
const Var kRecoW2([](const caf::SRProxy *sr){float nuE=kRecoE(sr);float muE=kIncXsecMuonE(sr);float q2=kRecoQ2(sr);if(nuE< 0||muE< 0||q2< 0) return-5.0f;float mN=(sr->spill.isFHC)?kNeutronMass(sr):kProtonMass(sr);if((pow(mN, 2)+(2 *mN *(nuE-muE))-q2)< 0) return-5.0f;return(float)(pow(mN, 2)+(2 *mN *(nuE-muE))-q2);})
const Var kTwoProngTruthOpenAngle_Deg_emid([](const caf::SRProxy *sr){float TwoProngTruthOpenAngle_Rad=kTwoProngTruthOpenAngle_Rad_emid(sr);if(TwoProngTruthOpenAngle_Rad > TMath::Pi()||TwoProngTruthOpenAngle_Rad< 0.) return-5.0f;return(float)(TwoProngTruthOpenAngle_Rad *180./TMath::Pi());})
const Var kRecoPi0DirZ_Deg_emid([](const caf::SRProxy *sr){float RecoPi0DirZ_Rad=kRecoPi0DirZ_Rad_emid(sr);if(RecoPi0DirZ_Rad > TMath::Pi()||RecoPi0DirZ_Rad< 0.) return-5.0f;return(float)(RecoPi0DirZ_Rad *180./TMath::Pi());})
const Var kProng1ElectronScore_emid([](const caf::SRProxy *sr){int png1=kProng1ID_emid(sr);if(png1< 0) return-5.0f;const auto &p1=sr->vtx.elastic.fuzzyk.png[png1];return(float)(p1.spprongcvnpart5label.electronid);})
int Prong1ID_Generator(const caf::SRProxy *sr, std::string id_type)
const NuTruthVar kTrueDeltaAlpha_NT([](const caf::SRNeutrinoProxy *truth){TVector3 p_mu=kMuon_Momentum(truth);TVector3 p_h=kH_Momentum(truth);TVector3 p_nu=kNu_Momentum(truth);TVector3 p_mu_T=p_nu.Cross(p_mu);TVector3 p_h_T=p_nu.Cross(p_h);TVector3 delta_p_T(0, 0, 0);delta_p_T+=p_mu_T;delta_p_T+=p_h_T;double numerator=delta_p_T.Dot(-p_mu_T);double mag_p_mu_T=p_mu_T.Mag();double mag_delta_p_T=delta_p_T.Mag();if(mag_p_mu_T==0||mag_delta_p_T==0) return-5.0;double val=numerator/(mag_p_mu_T *mag_delta_p_T);if(std::isnan(val)) return-5.0;if(std::isinf(val)) return-5.0;double delta_alpha=TMath::ACos(val);if(std::isnan(delta_alpha)) return-5.0;if(std::isinf(delta_alpha)) return-5.0;if(delta_alpha > TMath::Pi()||delta_alpha< 0.) return-5.0;return(double)(delta_alpha *180./TMath::Pi());})
const Var kMuonPngIdx([](const caf::SRProxy *sr){int longest_idx=-5;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;int trk_idx=kBestTrack(sr);if(sr->trk.kalman.ntracks< 1||trk_idx< 0||trk_idx >=int(sr->trk.kalman.ntracks)) return-5;auto &trk=sr->trk.kalman.tracks[trk_idx];int best_idx=-5;float best_cos=-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(trk.dir.Unit().Dot(png.dir.Unit()) > best_cos){best_cos=trk.dir.Unit().Dot(png.dir.Unit());best_idx=png_idx;}}}return best_idx;})
const Var kProng2TruthEff_emid([](const caf::SRProxy *sr){int png2=kProng2ID_emid(sr);if(png2< 0) return-5.0f;return(float) sr->vtx.elastic.fuzzyk.png[png2].truth.eff;})
const Var kProng2NHitY_emid([](const caf::SRProxy *sr){int png2=kProng2ID_emid(sr);if(png2< 0) return-5;return(int) sr->vtx.elastic.fuzzyk.png[png2].nhity;})
const Var kProng2NHitY_4view([](const caf::SRProxy *sr){int png2=kProng2ID_4view(sr);if(png2< 0) return-5;return(int) sr->vtx.elastic.fuzzyk.png[png2].nhity;})
const Var kProng2Score_4view([](const caf::SRProxy *sr){int png2=kProng2ID_4view(sr);if(png2< 0) return-5.0f;const auto &p2=sr->vtx.elastic.fuzzyk.png[png2];return(float)(p2.cvnpart.emid);})
const Var kProng1TruePDG_emid([](const caf::SRProxy *sr){int png1=kProng1ID_emid(sr);if(png1< 0) return 0;return(int) sr->vtx.elastic.fuzzyk.png[png1].truth.pdg;})
const NuTruthVar kTruePrimPi0DirZ_Deg_NT([](const caf::SRNeutrinoProxy *truth){float TruePi0DirZ_Rad_NT=kTruePrimPi0DirZ_Rad_NT(truth);if(TruePi0DirZ_Rad_NT > TMath::Pi()||TruePi0DirZ_Rad_NT< 0.) return-5.0f;return(float)(TruePi0DirZ_Rad_NT *180./TMath::Pi());})
const Var kRecoMuonDirZ_Cos([](const caf::SRProxy *sr){int png_mu=kMuonPngIdx(sr);if(png_mu< 0) return-5.0f;const auto &png=sr->vtx.elastic.fuzzyk.png[png_mu];TVector3 p=png.calE *png.dir.Unit();TVector3 beamDirND=NuMIBeamDirection(caf::kNEARDET);return(float) p.Unit().Dot(beamDirND.Unit());})
const Var kCVNMuonIdx_5label([](const caf::SRProxy *sr){int longest_idx=-5;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;int best_idx=-5;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.spprongcvnpart5label.muonid > best_score){best_score=png.spprongcvnpart5label.muonid;best_idx=png_idx;}}}return best_idx;})
const Var kIncXsecHadE([](const caf::SRProxy *sr){int ibesttrk=kBestTrack(sr);if(sr->trk.kalman.ntracks< 1) return-1000.f;if(ibesttrk< 0||ibesttrk >=int(sr->trk.kalman.ntracks)) return-1000.f;float ExtraHadE=sr->trk.kalman.tracks[ibesttrk].overlapE;float CalhadE=sr->slc.calE-sr->trk.kalman.tracks[ibesttrk].calE;float vishadE=CalhadE+ExtraHadE;float hadE=0.0;hadE=VisibleHadE(vishadE);return hadE;})
const Var kProng2NHitX_5label([](const caf::SRProxy *sr){int png2=kProng2ID_5label(sr);if(png2< 0) return-5;return(int) sr->vtx.elastic.fuzzyk.png[png2].nhitx;})
const Var kProng1DirZ_Diff_Deg_emid([](const caf::SRProxy *sr){float Prong1DirZ_Diff_Rad=kProng1DirZ_Diff_Rad_emid(sr);if(Prong1DirZ_Diff_Rad > TMath::Pi()||Prong1DirZ_Diff_Rad< 0.) return-5.0f;return(float)(Prong1DirZ_Diff_Rad *180./TMath::Pi());})
const Var kIncXsecMuonE([](const caf::SRProxy *sr){float muonE=0.0;float muonEact=0.0;float muonEcat=0.0;float muonEactandcat=0.0;float trkLenAct=0.f;float trkLenCat=0.f;trkLenAct=kTrkLenAct(sr);trkLenCat=kTrkLenCat(sr);int ibesttrk=kBestTrack(sr);if(sr->trk.kalman.ntracks< 1) return-1000.f;if(ibesttrk< 0||ibesttrk >=int(sr->trk.kalman.ntracks)) return-1000.f;if(sr->trk.kalman.tracks[ibesttrk].leninact > 0 && sr->trk.kalman.tracks[ibesttrk].lenincat< 0) muonEact=MuonEAct(trkLenAct);else if(sr->trk.kalman.tracks[ibesttrk].leninact > 0 && sr->trk.kalman.tracks[ibesttrk].lenincat > 0){muonEcat=MuonECat(trkLenCat);muonEactandcat=MuonEActandCat(trkLenAct);muonE=muonEactandcat+muonEcat;}return muonE+muonEact;})
const NuTruthVar kTrueNuW_NT([](const caf::SRNeutrinoProxy *nu){float val=nu->W2;if(val< 0) return(double)-5.0;return(double) sqrt(nu->W2);})
const Var kNeutronMass([](const caf::SRProxy *sr){return NeutronMass();})
const Var kTruePrimPi0DirZ_Deg
const NuTruthVar kTruthTag_NT([](const caf::SRNeutrinoProxy *truth){bool AntiNuSig=kAntiNuSig_NT(truth);bool NuSig=kNuSig_NT(truth);bool SecoPi0=kNumuCC_NT(truth)&&kSecoPi0_NT(truth);bool NoPi0=kNumuCC_NT(truth)&&kNoPi0_NT(truth);bool NC=kNC_NT(truth);bool Other=kIsOther_NT(truth);if(AntiNuSig) return 1;else if(NuSig) return 2;else if(SecoPi0) return 3;else if(NoPi0) return 4;else if(NC) return 5;else if(Other) return 6;else return 0;})
const Var kRecoW([](const caf::SRProxy *sr){float nuE=kRecoE(sr);float muE=kIncXsecMuonE(sr);float q2=kRecoQ2(sr);if(nuE< 0||muE< 0||q2< 0) return-5.0f;float mN=(sr->spill.isFHC)?kNeutronMass(sr):kProtonMass(sr);float W2=(pow(mN, 2)+(2 *mN *(nuE-muE))-q2);if(W2< 0) return-5.0f;return(float)(sqrt(W2));})
const Var kMuDeg_Diff([](const caf::SRProxy *sr){float truth=kTrueMuDirZ_Deg(sr);float reco=kRecoMuonDirZ_Deg(sr);if(truth< 0||reco< 0) return(-5.0f);return(float)(reco-truth);})
const Var kPi0Mass_4view([](const caf::SRProxy *sr){int png1=kProng1ID_4view(sr);int png2=kProng2ID_4view(sr);if(png1< 0||png2< 0) return-5.0f;const auto &p1=sr->vtx.elastic.fuzzyk.png[png1];const auto &p2=sr->vtx.elastic.fuzzyk.png[png2];const float dot=p1.dir.Unit().Dot(p2.dir.Unit());return 1000 *sqrt(2 *p1.calE *p2.calE *(1-dot));})
const Var kProng1NHitY_4view([](const caf::SRProxy *sr){int png1=kProng1ID_4view(sr);if(png1< 0) return-5;return(int) sr->vtx.elastic.fuzzyk.png[png1].nhity;})
const Var k5labelMuonPng_MuonScore_5label([](const caf::SRProxy *sr){return(float) GetCVNProngMuonScore_5label(kCVNMuonIdx_5label(sr), sr);})
const Var kRecoPi0P_4view([](const caf::SRProxy *sr){int png1=kProng1ID_4view(sr);int png2=kProng2ID_4view(sr);if(png1< 0||png2< 0) return-5.0f;const auto &p1=sr->vtx.elastic.fuzzyk.png[png1];const auto &p2=sr->vtx.elastic.fuzzyk.png[png2];TVector3 p=p1.calE *p1.dir.Unit()+p2.calE *p2.dir.Unit();return(float) p.Mag();})
const Var kRecoMuonDirZ_Deg([](const caf::SRProxy *sr){float RecoMuonDirZ_Rad=kRecoMuonDirZ_Rad(sr);if(RecoMuonDirZ_Rad > TMath::Pi()||RecoMuonDirZ_Rad< 0.) return-5.0f;return(float)(RecoMuonDirZ_Rad *180./TMath::Pi());})
int Prong2ID_Generator(const caf::SRProxy *sr, std::string id_type)
const Var kProng2DirZ_Diff_Cos_emid([](const caf::SRProxy *sr){int png2=kProng2ID_emid(sr);if(png2< 0) return-5.0f;auto &pngDir=sr->vtx.elastic.fuzzyk.png[png2].dir;TVector3 truthDir=sr->vtx.elastic.fuzzyk.png[png2].truth.p.Vect();return(float) pngDir.Unit().Dot(truthDir.Unit());})
const Var kProng2PhotonScore_emid([](const caf::SRProxy *sr){int png2=kProng2ID_emid(sr);if(png2< 0) return-5.0f;const auto &p2=sr->vtx.elastic.fuzzyk.png[png2];return(float)(p2.spprongcvnpart5label.photonid);})
const Var kProng1TruthDirZ_Rad_emid([](const caf::SRProxy *sr){int png1=kProng1ID_emid(sr);if(png1< 0) return-5.0f;TVector3 pngDir=sr->vtx.elastic.fuzzyk.png[png1].truth.p.Vect();TVector3 beamDirND=NuMIBeamDirection(caf::kNEARDET);return(float) pngDir.Unit().Angle(beamDirND.Unit());})
const Var kW_Diff([](const caf::SRProxy *sr){float truth=kTrueNuW(sr);float reco=kRecoW(sr);if(truth< 0||reco< 0) return(-5.0f);return(float)(reco-truth);})
const Var kTwoProngOpenAngle_Reso_Rad_emid([](const caf::SRProxy *sr){float openAngle=kTwoProngOpenAngle_Rad_emid(sr);float truthOpenAngle=kTwoProngTruthOpenAngle_Rad_emid(sr);if(openAngle< 0.||openAngle > TMath::Pi()||truthOpenAngle< 0.||truthOpenAngle > TMath::Pi()) return-5.0f;return(float)(openAngle-truthOpenAngle);})
const NuTruthVar kTrueMuDirZ_Cos_NT([](const caf::SRNeutrinoProxy *truth){if(abs(truth->pdg)!=14||!truth->iscc) return-5.0;int nprims=truth->prim.size();for(int iprim=0;iprim< nprims;iprim++){if(abs(truth->prim[iprim].pdg)==13){TVector3 mudir=truth->prim[iprim].p.Vect();TVector3 beamdir=NuMIBeamDirection(caf::kNEARDET);return mudir.Unit().Dot(beamdir.Unit());}}return-5.0;})
const Var kProng1CalE_emid([](const caf::SRProxy *sr){int png1=kProng1ID_emid(sr);if(png1< 0) return-5.0f;return(float) sr->vtx.elastic.fuzzyk.png[png1].calE;})
const Var kProng1ID_5label([](const caf::SRProxy *sr){return Prong1ID_Generator(sr,"5label");})
const Var kMuonMass([](const caf::SRProxy *sr){return MuonMass();})
const NuTruthVar kTrueDeltaPtt_NT([](const caf::SRNeutrinoProxy *truth){TVector3 p_mu=kMuon_Momentum(truth);TVector3 p_h=kH_Momentum(truth);TVector3 p_nu=kNu_Momentum(truth);TVector3 p_mu_T=p_nu.Cross(p_mu);TVector3 p_h_T=p_nu.Cross(p_h);TVector3 delta_p_T(p_mu_T.X(), p_mu_T.Y(), p_mu_T.Z());delta_p_T+=p_h_T;TVector3 z_TT=p_mu_T.Unit();z_TT.SetX(0.);z_TT.SetY(0.);double delta_p_TT=delta_p_T.Dot(z_TT);if(std::isnan(delta_p_TT)) return-5.0;if(std::isinf(delta_p_TT)) return-5.0;return delta_p_TT;})
const Var kProng1Score_4view([](const caf::SRProxy *sr){int png1=kProng1ID_4view(sr);if(png1< 0) return-5.0f;const auto &p1=sr->vtx.elastic.fuzzyk.png[png1];return(float)(p1.cvnpart.emid);})
const Var k4viewMuonPng_MuonScore_5label([](const caf::SRProxy *sr){return(float) GetCVNProngMuonScore_5label(kCVNMuonIdx_4view(sr), sr);})
caf::StandardRecord * sr
const Var kProng2DirZ_Diff_Deg_emid([](const caf::SRProxy *sr){float Prong2DirZ_Diff_Rad=kProng2DirZ_Diff_Rad_emid(sr);if(Prong2DirZ_Diff_Rad > TMath::Pi()||Prong2DirZ_Diff_Rad< 0.) return-5.0f;return(float)(Prong2DirZ_Diff_Rad *180./TMath::Pi());})
const Var kProng1TruePDG_4view([](const caf::SRProxy *sr){int png1=kProng1ID_4view(sr);if(png1< 0) return 0;return(int) sr->vtx.elastic.fuzzyk.png[png1].truth.pdg;})
const Var kMuonPng_MuonScore_4view([](const caf::SRProxy *sr){return(float) GetCVNProngMuonScore_4view(kMuonPngIdx(sr), sr);})
const NuTruthVar kTrueSecoPi0_ID1_NT([](const caf::SRNeutrinoProxy *truth){int nprims=truth->prim.size();int pi0ID1=-1;float pi0E=-5.0;for(int i=0;i< nprims;++i){auto &daughterPDG=truth->prim[i].daughterlist;auto &daughterE=truth->prim[i].daughterEnergies;if(daughterPDG.empty()) continue;for(int j=0;j< (int) daughterPDG.size();++j){if(daughterPDG[j]==111 &&pi0E< daughterE[j]){pi0ID1=i;pi0E=daughterE[j];}}}if(pi0ID1< 0) return-5;return pi0ID1;})
const NuTruthVar kTruePrimPi0E_NT([](const caf::SRNeutrinoProxy *truth){int TruePi0_ID=kTruePrimPi0_ID_NT(truth);if(TruePi0_ID< 0) return-5.0f;return(float) truth->prim[TruePi0_ID].p.E;})
const NuTruthVar kTrueMuDirZ_Deg_NT([](const caf::SRNeutrinoProxy *truth){float TrueMuDirZ_Rad_NT=kTrueMuDirZ_Rad_NT(truth);if(TrueMuDirZ_Rad_NT > TMath::Pi()||TrueMuDirZ_Rad_NT< 0.) return-5.0f;return(float)(TrueMuDirZ_Rad_NT *180./TMath::Pi());})
const Var kMuonID([](const caf::SRProxy *sr){int ibesttrk=kBestTrack(sr);if(sr->trk.kalman.ntracks< 1) return-5.0f;if(ibesttrk< 0||ibesttrk >=int(sr->trk.kalman.ntracks)) return-5.0f;return(float) sr->trk.kalman.tracks[ibesttrk].muonid;})
const Var kTwoProngTruthOpenAngle_Cos_emid([](const caf::SRProxy *sr){int png1=kProng1ID_emid(sr);int png2=kProng2ID_emid(sr);if(png1< 0||png2< 0) return-5.0f;TVector3 png1Dir=sr->vtx.elastic.fuzzyk.png[png1].truth.p.Vect();TVector3 png2Dir=sr->vtx.elastic.fuzzyk.png[png2].truth.p.Vect();return(float) png1Dir.Unit().Dot(png2Dir.Unit());})
const Var kProng2E_Reso_emid([](const caf::SRProxy *sr){int png2=kProng2ID_emid(sr);if(png2< 0) return-5.0f;float calE=sr->vtx.elastic.fuzzyk.png[png2].calE;float trueE=sr->vtx.elastic.fuzzyk.png[png2].truth.p.E;if(trueE==0) return-5.0f;return(float)(calE-trueE)/trueE;})
const Var kCVNMuonIdx_4view([](const caf::SRProxy *sr){int longest_idx=-5;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;int best_idx=-5;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;})
const Var kProng1NHit_4view([](const caf::SRProxy *sr){int png1=kProng1ID_4view(sr);if(png1< 0) return-5;return(int) sr->vtx.elastic.fuzzyk.png[png1].nhit;})
const Var kRecoMuonP([](const caf::SRProxy *sr){int png_mu=kMuonPngIdx(sr);if(png_mu< 0) return-5.0f;const auto &png=sr->vtx.elastic.fuzzyk.png[png_mu];TVector3 p=png.calE *png.dir.Unit();return(float) p.Mag();})
const Var kTwoProngOpenAngle_Cos_emid([](const caf::SRProxy *sr){int png1=kProng1ID_emid(sr);int png2=kProng2ID_emid(sr);if(png1< 0||png2< 0) return-5.0f;auto &png1Dir=sr->vtx.elastic.fuzzyk.png[png1].dir;auto &png2Dir=sr->vtx.elastic.fuzzyk.png[png2].dir;return(float) png1Dir.Unit().Dot(png2Dir.Unit());})
const Var kProng1TruthPur_emid([](const caf::SRProxy *sr){int png1=kProng1ID_emid(sr);if(png1< 0) return-5.0f;return(float) sr->vtx.elastic.fuzzyk.png[png1].truth.pur;})
const Var kTrkLenAct([](const caf::SRProxy *sr){int ibesttrk=kBestTrack(sr);if(sr->trk.kalman.ntracks< 1) return-1000.f;if(ibesttrk< 0||ibesttrk >=int(sr->trk.kalman.ntracks)) return-1000.f; if(sr->trk.kalman.tracks[ibesttrk].leninact > 0 && sr->trk.kalman.tracks[ibesttrk].lenincat< 0) return float((sr->trk.kalman.tracks[ibesttrk].leninact/100.) +(sr->trk.kalman.tracks[ibesttrk].lenincat/100.)); if(sr->trk.kalman.tracks[ibesttrk].leninact > 0 && sr->trk.kalman.tracks[ibesttrk].lenincat > 0) return float(sr->trk.kalman.tracks[ibesttrk].leninact/100.); if(sr->trk.kalman.tracks[ibesttrk].leninact< 0 && sr->trk.kalman.tracks[ibesttrk].lenincat > 0) return 0.f;return-1000.f;})
const Var kQ2_Diff([](const caf::SRProxy *sr){float truth=kTrueNuQ2(sr);float reco=kRecoQ2(sr);if(truth< 0||reco< 0) return(-5.0f);return(float)(reco-truth);})
const NuTruthVar kTrueHadronicSystemP_NT([](const caf::SRNeutrinoProxy *truth){TVector3 p_h=kH_Momentum(truth);return p_h.Mag();})
const Var kProng1E_Reso_emid([](const caf::SRProxy *sr){int png1=kProng1ID_emid(sr);if(png1< 0) return-5.0f;float calE=sr->vtx.elastic.fuzzyk.png[png1].calE;float trueE=sr->vtx.elastic.fuzzyk.png[png1].truth.p.E;if(trueE==0) return-5.0f;return(float)(calE-trueE)/trueE;})
const Var kTwoProngOpenAngle_Rad_emid([](const caf::SRProxy *sr){int png1=kProng1ID_emid(sr);int png2=kProng2ID_emid(sr);if(png1< 0||png2< 0) return-5.0f;auto &png1Dir=sr->vtx.elastic.fuzzyk.png[png1].dir;auto &png2Dir=sr->vtx.elastic.fuzzyk.png[png2].dir;return(float) png1Dir.Unit().Angle(png2Dir.Unit());})
const Var kTwoProngOpenAngle_Deg_emid([](const caf::SRProxy *sr){float TwoProngOpenAngle_Rad=kTwoProngOpenAngle_Rad_emid(sr);if(TwoProngOpenAngle_Rad > TMath::Pi()||TwoProngOpenAngle_Rad< 0.) return-5.0f;return(float)(TwoProngOpenAngle_Rad *180./TMath::Pi());})
Var VarFromNuTruthVar(const NuTruthVar &stv, double _default)
Definition: Var.cxx:7
const Var kProng1ID_4view([](const caf::SRProxy *sr){return Prong1ID_Generator(sr,"4view");})
const Var kProng2NHitX_emid([](const caf::SRProxy *sr){int png2=kProng2ID_emid(sr);if(png2< 0) return-5;return(int) sr->vtx.elastic.fuzzyk.png[png2].nhitx;})
const Var kProng1ProtonScore_emid([](const caf::SRProxy *sr){int png1=kProng1ID_emid(sr);if(png1< 0) return-5.0f;const auto &p1=sr->vtx.elastic.fuzzyk.png[png1];return(float)(p1.spprongcvnpart5label.protonid);})
const Var kProng1NHitX_5label([](const caf::SRProxy *sr){int png1=kProng1ID_5label(sr);if(png1< 0) return-5;return(int) sr->vtx.elastic.fuzzyk.png[png1].nhitx;})
const Var kNProngs([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return-5;return(int) sr->vtx.elastic.fuzzyk.npng;})
const Var kProng1DirZ_Rad_emid([](const caf::SRProxy *sr){int png1=kProng1ID_emid(sr);if(png1< 0) return-5.0f;auto &pngDir=sr->vtx.elastic.fuzzyk.png[png1].dir;TVector3 beamDirND=NuMIBeamDirection(caf::kNEARDET);return(float) pngDir.Unit().Angle(beamDirND.Unit());})
const Var kTruePrimPi0DirZ_Cos
const Var kRecoMuonDirZ_Rag
const Var kTrkLenCat([](const caf::SRProxy *sr){int ibesttrk=kBestTrack(sr);if(sr->trk.kalman.ntracks< 1) return-1000.f;if(ibesttrk< 0||ibesttrk >=int(sr->trk.kalman.ntracks)) return-1000.f; if(sr->trk.kalman.tracks[ibesttrk].leninact > 0 && sr->trk.kalman.tracks[ibesttrk].lenincat< 0) return 0.f; if(sr->trk.kalman.tracks[ibesttrk].leninact > 0 && sr->trk.kalman.tracks[ibesttrk].lenincat > 0) return float(sr->trk.kalman.tracks[ibesttrk].lenincat/100.); if(sr->trk.kalman.tracks[ibesttrk].leninact< 0 && sr->trk.kalman.tracks[ibesttrk].lenincat > 0) return float((sr->trk.kalman.tracks[ibesttrk].leninact/100.) +(sr->trk.kalman.tracks[ibesttrk].lenincat/100.));return-1000.f;})
const Var kTwoProngTruthOpenAngle_Rad_emid([](const caf::SRProxy *sr){int png1=kProng1ID_emid(sr);int png2=kProng2ID_emid(sr);if(png1< 0||png2< 0) return-5.0f;TVector3 png1Dir=sr->vtx.elastic.fuzzyk.png[png1].truth.p.Vect();TVector3 png2Dir=sr->vtx.elastic.fuzzyk.png[png2].truth.p.Vect();return(float) png1Dir.Unit().Angle(png2Dir.Unit());})
const Var kProng2ID_5label([](const caf::SRProxy *sr){return Prong2ID_Generator(sr,"5label");})
const Var kProng1Score_5label([](const caf::SRProxy *sr){int png1=kProng1ID_5label(sr);if(png1< 0) return-5.0f;const auto &p1=sr->vtx.elastic.fuzzyk.png[png1];return(float)(p1.spprongcvnpart5label.emid);})
const NuTruthVar kTruePrimPi0DirZ_Rad_NT([](const caf::SRNeutrinoProxy *truth){int TruePi0_ID=kTruePrimPi0_ID_NT(truth);if(TruePi0_ID< 0) return-5.0f;TVector3 Pi0P=truth->prim[TruePi0_ID].p.Vect();TVector3 beamDirND=NuMIBeamDirection(caf::kNEARDET);return(float) Pi0P.Unit().Angle(beamDirND.Unit());})
const NuTruthVar kTruePrimPi0KE_NT([](const caf::SRNeutrinoProxy *truth){float nPrimaryPi0=kNPrimaryPi0_NT(truth);if(nPrimaryPi0< 1) return-5.f; float pi0_t=-5;const int nprims=truth->prim.size();for(int iprim=0;iprim< nprims;++iprim){if(truth->prim[iprim].pdg!=111) continue;double E=truth->prim[iprim].p.T();float ke=E-Pi0Mass();if(ke > pi0_t) pi0_t=ke;}return float(pi0_t);})
const Var kProng2NHit_4view([](const caf::SRProxy *sr){int png2=kProng2ID_4view(sr);if(png2< 0) return-5;return(int) sr->vtx.elastic.fuzzyk.png[png2].nhit;})
double GetCVNProngMuonScore_5label(int ProngIdx, const caf::SRProxy *sr)
const NuTruthVar kTrueSecoPi0P_NT([](const caf::SRNeutrinoProxy *truth){int TruePi0_ID1=kTrueSecoPi0_ID1_NT(truth);int TruePi0_ID2=kTrueSecoPi0_ID2_NT(truth);double pi0P=-5.0;if(TruePi0_ID1< 0||TruePi0_ID2< 0) return(float) pi0P;double pi0E=truth->prim[TruePi0_ID1].daughterEnergies[TruePi0_ID2];if(pi0E< Pi0Mass()) pi0P=0.;else pi0P=sqrt(std::pow(pi0E, 2)-std::pow(Pi0Mass(), 2));return(float) pi0P;})
const Var kProng1NHit_5label([](const caf::SRProxy *sr){int png1=kProng1ID_5label(sr);if(png1< 0) return-5;return(int) sr->vtx.elastic.fuzzyk.png[png1].nhit;})
const NuTruthVar kNSecondaryPi0_NT([](const caf::SRNeutrinoProxy *truth){int nprims=truth->prim.size();int countpi0=0;for(int i=0;i< nprims;++i){auto &daughters=truth->prim[i].daughterlist;if(daughters.empty()) continue;for(const auto &pdg:daughters){if(pdg==111) countpi0++;}}return countpi0;})
const Var k5labelMuonPng_MuonScore_4view([](const caf::SRProxy *sr){return(float) GetCVNProngMuonScore_4view(kCVNMuonIdx_5label(sr), sr);})
const Var kProng2TruthDirZ_Rad_emid([](const caf::SRProxy *sr){int png2=kProng2ID_emid(sr);if(png2< 0) return-5.0f;TVector3 pngDir=sr->vtx.elastic.fuzzyk.png[png2].truth.p.Vect();TVector3 beamDirND=NuMIBeamDirection(caf::kNEARDET);return(float) pngDir.Unit().Angle(beamDirND.Unit());})
const Var kRecoPi0P_1_emid([](const caf::SRProxy *sr){int png1=kProng1ID_emid(sr);int png2=kProng2ID_emid(sr);if(png1< 0||png2< 0) return-5.0f;const auto &p1=sr->vtx.elastic.fuzzyk.png[png1];const auto &p2=sr->vtx.elastic.fuzzyk.png[png2];TVector3 p=p1.calE *p1.dir.Unit()+p2.calE *p2.dir.Unit();return(float) p.Mag();})
const Var kTrueHadronicSystemP
const NuTruthVar kTruePrimPi0_ID_NT([](const caf::SRNeutrinoProxy *truth){int nprims=truth->prim.size();int pi0ID=-1;float pi0E=-5.0;for(int i=0;i< nprims;++i){if(truth->prim[i].pdg==111 &&pi0E< truth->prim[i].p.E){pi0ID=i;pi0E=truth->prim[i].p.E;}}if(pi0ID< 0) return-5;return pi0ID;})
const Var kProng1NHitY_5label([](const caf::SRProxy *sr){int png1=kProng1ID_5label(sr);if(png1< 0) return-5;return(int) sr->vtx.elastic.fuzzyk.png[png1].nhity;})
const Var kProng1TruthEff_emid([](const caf::SRProxy *sr){int png1=kProng1ID_emid(sr);if(png1< 0) return-5.0f;return(float) sr->vtx.elastic.fuzzyk.png[png1].truth.eff;})
const Var kRecoPi0DirZ_Cos_4view([](const caf::SRProxy *sr){int png1=kProng1ID_4view(sr);int png2=kProng2ID_4view(sr);if(png1< 0||png2< 0) return-5.0f;const auto &p1=sr->vtx.elastic.fuzzyk.png[png1];const auto &p2=sr->vtx.elastic.fuzzyk.png[png2];TVector3 p=p1.calE *p1.dir.Unit()+p2.calE *p2.dir.Unit();TVector3 beamDirND=NuMIBeamDirection(caf::kNEARDET);return(float) p.Unit().Dot(beamDirND.Unit());})
const Var kRecoPi0DirZ_Rad_4view([](const caf::SRProxy *sr){int png1=kProng1ID_4view(sr);int png2=kProng2ID_4view(sr);if(png1< 0||png2< 0) return-5.0f;const auto &p1=sr->vtx.elastic.fuzzyk.png[png1];const auto &p2=sr->vtx.elastic.fuzzyk.png[png2];TVector3 p=p1.calE *p1.dir.Unit()+p2.calE *p2.dir.Unit();TVector3 beamDirND=NuMIBeamDirection(caf::kNEARDET);return(float) p.Unit().Angle(beamDirND.Unit());})
const NuTruthVar kTrueSecoPi0_ID2_NT([](const caf::SRNeutrinoProxy *truth){int nprims=truth->prim.size();int pi0ID2=-1;float pi0E=-5.0;for(int i=0;i< nprims;++i){auto &daughterPDG=truth->prim[i].daughterlist;auto &daughterE=truth->prim[i].daughterEnergies;if(daughterPDG.empty()) continue;for(int j=0;j< (int) daughterPDG.size();++j){if(daughterPDG[j]==111 &&pi0E< daughterE[j]){pi0ID2=j;pi0E=daughterE[j];}}}if(pi0ID2< 0) return-5;return pi0ID2;})
const Var kProng1DirZ_Diff_Rad_emid([](const caf::SRProxy *sr){int png1=kProng1ID_emid(sr);if(png1< 0) return-5.0f;auto &pngDir=sr->vtx.elastic.fuzzyk.png[png1].dir;TVector3 truthDir=sr->vtx.elastic.fuzzyk.png[png1].truth.p.Vect();return(float) pngDir.Unit().Angle(truthDir.Unit());})
const Var kProng1TruthDirZ_Cos_emid([](const caf::SRProxy *sr){int png1=kProng1ID_emid(sr);if(png1< 0) return-5.0f;TVector3 pngDir=sr->vtx.elastic.fuzzyk.png[png1].truth.p.Vect();TVector3 beamDirND=NuMIBeamDirection(caf::kNEARDET);return(float) pngDir.Unit().Dot(beamDirND.Unit());})
const Var kProng2TruePDG_emid([](const caf::SRProxy *sr){int png2=kProng2ID_emid(sr);if(png2< 0) return 0;return(int) sr->vtx.elastic.fuzzyk.png[png2].truth.pdg;})
const Var kProtonMass([](const caf::SRProxy *sr){return ProtonMass();})
const Var kProng2CalE_emid([](const caf::SRProxy *sr){int png2=kProng2ID_emid(sr);if(png2< 0) return-5.0f;return(float) sr->vtx.elastic.fuzzyk.png[png2].calE;})
const Var kPi0Mass_emid([](const caf::SRProxy *sr){int png1=kProng1ID_emid(sr);int png2=kProng2ID_emid(sr);if(png1< 0||png2< 0) return-5.0f;const auto &p1=sr->vtx.elastic.fuzzyk.png[png1];const auto &p2=sr->vtx.elastic.fuzzyk.png[png2];const float dot=p1.dir.Unit().Dot(p2.dir.Unit());return 1000 *sqrt(2 *p1.calE *p2.calE *(1-dot));})
const Var kRecoPi0DirZ_Rad_emid([](const caf::SRProxy *sr){int png1=kProng1ID_emid(sr);int png2=kProng2ID_emid(sr);if(png1< 0||png2< 0) return-5.0f;const auto &p1=sr->vtx.elastic.fuzzyk.png[png1];const auto &p2=sr->vtx.elastic.fuzzyk.png[png2];TVector3 p=p1.calE *p1.dir.Unit()+p2.calE *p2.dir.Unit();TVector3 beamDirND=NuMIBeamDirection(caf::kNEARDET);return(float) p.Unit().Angle(beamDirND.Unit());})
const Var kProng2ProtonScore_emid([](const caf::SRProxy *sr){int png2=kProng2ID_emid(sr);if(png2< 0) return-5.0f;const auto &p2=sr->vtx.elastic.fuzzyk.png[png2];return(float)(p2.spprongcvnpart5label.protonid);})
const NuTruthVar kTrueNuE_NT([](const caf::SRNeutrinoProxy *nu){return nu->E;})
const Var kProng1NHit_emid([](const caf::SRProxy *sr){int png1=kProng1ID_emid(sr);if(png1< 0) return-5;return(int) sr->vtx.elastic.fuzzyk.png[png1].nhit;})
const Var kProng2TruthE_emid([](const caf::SRProxy *sr){int png2=kProng2ID_emid(sr);if(png2< 0) return-5.0f;return(float) sr->vtx.elastic.fuzzyk.png[png2].truth.p.E;})
const Var kProng2ID_emid([](const caf::SRProxy *sr){return Prong2ID_Generator(sr,"emid");})
const Var kProng2DirZ_Rad_emid([](const caf::SRProxy *sr){int png2=kProng2ID_emid(sr);if(png2< 0) return-5.0f;auto &pngDir=sr->vtx.elastic.fuzzyk.png[png2].dir;TVector3 beamDirND=NuMIBeamDirection(caf::kNEARDET);return(float) pngDir.Unit().Angle(beamDirND.Unit());})
const Var kPi0Deg_Diff([](const caf::SRProxy *sr){float truth=kTruePrimPi0DirZ_Deg(sr);float reco=kRecoPi0DirZ_Deg_emid(sr);if(truth< 0||reco< 0) return(-5.0f);return(float)(reco-truth);})
const Var kProng2DirZ_Cos_emid([](const caf::SRProxy *sr){int png2=kProng2ID_emid(sr);if(png2< 0) return-5.0f;auto &pngDir=sr->vtx.elastic.fuzzyk.png[png2].dir;TVector3 beamDirND=NuMIBeamDirection(caf::kNEARDET);return(float) pngDir.Unit().Dot(beamDirND.Unit());})
const Var kRecoQ2([](const caf::SRProxy *sr){float nuE=kRecoE(sr);float muE=kIncXsecMuonE(sr);float pmu=kRecoMuonP(sr);float cosmu=kRecoMuonDirZ_Cos(sr);if(nuE< 0||muE< 0||pmu< 0||cosmu==-5.0) return-5.0f;return(float)(2 *nuE *(muE-pmu *cosmu));})
const Var kProng2ElectronScore_emid([](const caf::SRProxy *sr){int png2=kProng2ID_emid(sr);if(png2< 0) return-5.0f;const auto &p2=sr->vtx.elastic.fuzzyk.png[png2];return(float)(p2.spprongcvnpart5label.electronid);})
const Var kProng1NHitX_4view([](const caf::SRProxy *sr){int png1=kProng1ID_4view(sr);if(png1< 0) return-5;return(int) sr->vtx.elastic.fuzzyk.png[png1].nhitx;})
enum BeamMode string