TrimCAFs.C
Go to the documentation of this file.
1 // A macro to trim down a CAF file for use as an input to
2 // something like TMVA.
3 
4 #include "CAFAna/Core/Binning.h"
5 #include "CAFAna/Core/Spectrum.h"
7 
8 #include "CAFAna/Cuts/Cuts.h"
9 #include "CAFAna/Cuts/QuantileCuts.h"
10 #include "CAFAna/Cuts/SpillCuts.h"
11 #include "CAFAna/Cuts/NumuCuts2018.h"
12 
13 #include "CAFAna/Vars/BPFVars.h"
18 #include "CAFAna/Vars/HistAxes.h"
19 #include "CAFAna/Vars/NumuVars.h"
20 #include "CAFAna/Vars/PngCVNVars.h"
22 #include "CAFAna/Vars/Vars.h"
23 #include "CAFAna/Vars/WrongSignBDTVars.h"
24 #include "CAFAna/Vars/XsecTunes.h"
25 
27 
28 #include "Utilities/rootlogon.C"
29 
30 
31 #include "TTree.h"
32 #include "TString.h"
33 
34 using namespace ana;
35 
36 // -----------------------------------------------------------
37 // -----------------------------------------------------------
38 // --- Add a class to do the CAF cutting.
39 // -----------------------------------------------------------
40 // -----------------------------------------------------------
41 class CAFTreeMaker: public SpectrumLoader
42 {
43 public:
44  CAFTreeMaker(const std::string& wildcard, std::vector<Cut*> &cuts,
45  std::vector<TTree*> &trees, std::vector<Var*> &vars,
46  std::vector<std::string> varNames)
47  : SpectrumLoader(wildcard, kBeam),
48  fCuts(cuts),
49  fTrees(trees),
50  fVars(vars),
51  fNPassed(0)
52  {
53  // Create branches
54  fLocalVars.clear();
55  fLocalVars.resize(varNames.size(),0.);
56  for ( uint t = 0; t < fTrees.size(); ++t ) {
57  for ( uint v = 0; v < varNames.size(); ++v ) {
58  std::cout << "\tSetting branch address - " << varNames[v].c_str() << std::endl;
59  fTrees[t]->Branch( varNames[v].c_str(), &(fLocalVars[v]) );
60  }
61  }
62  }
63 
65  {
66  }
67 
68  void HandleRecord(caf::SRProxy* sr) override
69  {
70  if(fSpillCut && !(*fSpillCut)(&sr->spill)) return;
71  ++fNPassed;
72  // Fill my local vars.
73  for ( uint v = 0; v < fLocalVars.size(); ++v ) {
74  Var theVar = *(fVars[v]);
75  fLocalVars[v] = double( theVar(sr) );
76  }
77  // If passes cuts then fill trees.
78  for ( uint c = 0; c < fCuts.size(); ++c ) {
79  Cut theCut = *(fCuts[c]);
80  if ( theCut(sr) ) fTrees[c]->Fill();
81  }
82  }
83 
84  int GetNPassed() { return fNPassed; }
85 
86 protected:
87  std::vector<Cut*> fCuts;
88  std::vector<TTree*> fTrees;
89  std::vector<Var*> fVars;
90  std::vector<double> fLocalVars;
91  int fNPassed;
92 };
93 
94 // -----------------------------------------------------------
95 // -----------------------------------------------------------
96 // --- Now for my actual module.
97 // -----------------------------------------------------------
98 // -----------------------------------------------------------
99 void TrimCAFs( std::string sIdentifier, bool IsFHC=true, bool IsData=true, bool IsTrain = true ) {
100  // -----------------------------------------------------------
101  // --- First off, lets set some global things and make sure we know what we're running over...
102  // -----------------------------------------------------------
103  std::string sFHC_RHC = (IsFHC == true ? "fhc" :"rhc" );
104  std::string sIsData = (IsData == true ? "Cosmics":"BeamMC");
105  std::string sIsTrain = (IsTrain == true ? "Train" :"Test" );
106 
107  std::string OutName = "FlatTree-"+sFHC_RHC+"-"+sIsData+"-"+sIdentifier+"-"+sIsTrain+".root";
108 
109  // And write them out!
110  std::cout << "\n\nLots of input parameters, so I'm going to write them out now....;"
111  << "\n\t IsFHC " << (IsFHC == true ? "true --> Run in FHC " :"false --> Run in RHC" ) << " ==> sFHC_RHC is " << sFHC_RHC
112  << "\n\t IsData " << (IsData == true ? "true --> Run over Cosmics" :"false --> Run over MC" ) << " ==> sIsData is " << sIsData
113  << "\n\t Identifier is " << sIdentifier
114  << "\n\t IsTrain " << (IsTrain == true ? "true --> Training dataset" :"false --> Evaluation dataset" ) << " ==> sIsTrain is " << sIsTrain
115  << "\n\n OutName is therefore " << OutName
116  << "\n\n" << std::endl;
117 
118  // -----------------------------------------------------------
119  // --- Now lets get our Quartile cuts
120  // -----------------------------------------------------------
121  /*
122  auto cvmfs_dir =
123  if (!cvmfs_dir) {
124  std::cerr << "Couldn't find UPS dir for numu prediction!" << std::endl;
125  return;
126  }
127  */
128  std::string fdspecfile = (std::string)std::getenv("NUMUDATA_DIR")+"ana2018/Quantiles/quantiles__"+sFHC_RHC+"_full__numu2018.root";
129  //std::string fdspecfile = "/pnfs/nova/persistent/analysis/numu/Ana2018/official/Quantiles/quantiles__"+sFHC_RHC+"_full__numu2018.root";
130  TFile* inFile = TFile::Open( fdspecfile.c_str() );
131  TH2 *FDSpec2D = (TH2*)inFile->FindObjectAny( "FDSpec2D" ); //TString("FD_full_") + TString(sFHC_RHC) );
132  // How many quantiles?
133  const int NHadEFracQuantiles = 4; // defines how many divisions of hadEFrac are used
134  // Make my cuts.
135  //std::vector<Cut> HadEFracQuantCuts = QuantileAndPIDCutsFromTH2(FDSpec2D, kNumuCCOptimisedAxis, kHadEFracAxis, NHadEFracQuantiles, IsFHC);
136  std::vector<Cut> HadEFracQuantCuts = QuantileCutsFromTH2(FDSpec2D, kNumuCCOptimisedAxis, kHadEFracAxis, NHadEFracQuantiles);
137 
138  // -----------------------------------------------------------
139  // --- Create my output file.
140  // -----------------------------------------------------------
141  TFile *outFile = new TFile( OutName.c_str(), "RECREATE" );
142 
143  // -----------------------------------------------------------
144  // --- Lets figure out which definition I want to run over....
145  // -----------------------------------------------------------
146  std::string MyDef = "";
147  if ( IsData ) { MyDef = "karlwarb-prod4reco-cosmicrej-fd-cosmics-loose-"+sFHC_RHC+"-"+sIdentifier+"_"+sIsTrain; }
148  else { MyDef = "karlwarb-prod4reco-cosmicrej-fd-genie-nonswap-"+sFHC_RHC+"-"+sIdentifier+"_"+sIsTrain; }
149 
150  // -----------------------------------------------------------
151  // --- What weights do I want to use?
152  // -----------------------------------------------------------
153  Var kXSecWgt = kXSecCVWgt2018RPAFix_noDIS;
154 
155  // -----------------------------------------------------------
156  // --- What cuts do I want to use?
157  // -----------------------------------------------------------
158  Cut kMyBaseCut = kNumuQuality && kNumuContainFD2017;
159 
160  // -----------------------------------------------------------
161  // --- How many trees do I want to make?
162  // -----------------------------------------------------------
163  TTree *MyTrimTree = new TTree("TrimTree" ,"TrimTree");
164 
165  // -----------------------------------------------------------
166  // --- Push back my trees and cuts --> Need 1 to 1 correspond
167  // -----------------------------------------------------------
168  std::vector<TTree*> MyTrees;
169  std::vector<Cut*> MyCuts;
170  MyTrees.push_back( MyTrimTree ); MyCuts.push_back( &kMyBaseCut );
171 
172  // -----------------------------------------------------------
173  // --- Any custom vars?
174  // -----------------------------------------------------------
175  // --- Is this a neutrino interaction?
176  const Var kIsNu([](const caf::SRProxy* sr) {
177  if (kHasNeutrino(sr) == 1) return 1;
178  return 0;
179  });
180  // --- Is this a CC interaction?
181  const Var kIsCC([](const caf::SRProxy* sr) {
182  if (sr->mc.nnu == 0) return -1;
183  if (sr->mc.nu[0].iscc) { return 1; }
184  else { return 0; }
185  });
186  // --- Is this a NuMu interaction?
187  const Var kIsNuMu([](const caf::SRProxy* sr) {
188  if (sr->mc.nnu == 0) return -1;
189  if (abs(sr->mc.nu[0].pdg) == 14) { return 1; }
190  else { return 0; }
191  });
192  // -----------------------------------------------------------
193  // --- Define variables to include
194  // -----------------------------------------------------------
195  std::vector<Var*> MyVars;
196  std::vector<std::string> MyVarNames;
197  // --- Boring global variables.
198  MyVars.push_back( (Var*)(&kRun ) ); MyVarNames.push_back( "Run" ); // Run number
199  MyVars.push_back( (Var*)(&kEvt ) ); MyVarNames.push_back( "Evt" ); // Event number
200  MyVars.push_back( (Var*)(&kPPFXFluxCVWgt) ); MyVarNames.push_back( "PPFXWgt" ); // PPFX Event Weight
201  MyVars.push_back( (Var*)(&kXSecWgt ) ); MyVarNames.push_back( "XSecWgt" ); // XSec Weight.
202  // --- Some truth information...
203  MyVars.push_back( (Var*)(&kTrueE ) ); MyVarNames.push_back( "TrueNuE" ); // True Neutrino energy
204  MyVars.push_back( (Var*)(&kIsNu ) ); MyVarNames.push_back( "IsNu" ); // Is it a neutrino?
205  MyVars.push_back( (Var*)(&kIsCC ) ); MyVarNames.push_back( "IsCC" ); // Is it a CC interaction?
206  MyVars.push_back( (Var*)(&kIsNuMu) ); MyVarNames.push_back( "IsNuMu" ); // Is it a NuMu interaction?
207  MyVars.push_back( (Var*)(&kMode ) ); MyVarNames.push_back( "IntMode" ); // What is the interaction mode?
208 
209  // --- Some event level information.
210  MyVars.push_back( (Var*)(&kNHit ) ); MyVarNames.push_back( "SliceNHit" ); // Slice NHits
211  MyVars.push_back( (Var*)(&kCosmicForwardCell ) ); MyVarNames.push_back( "CosFwdCell" ); // Dist of Cosmic track proj Forward to Det Edge
212  MyVars.push_back( (Var*)(&kCosmicBackwardCell ) ); MyVarNames.push_back( "CosBakCell" ); // Dist of Cosmic track proj Backward to Det Edge.
213  MyVars.push_back( (Var*)(&kKalmanForwardCell ) ); MyVarNames.push_back( "KalTrkFwdCell" ); // Dist of Kalman track proj Forward to Det Edge
214  MyVars.push_back( (Var*)(&kKalmanBackwardCell ) ); MyVarNames.push_back( "KalTrkBakCell" ); // Dist of Kalman track proj Backward to Det Edge.
215  //MyVars.push_back( (Var*)(& ) ); MyVarNames.push_back( "BPFKalFwdCell" ); // Dist of Kalman track proj Forward to Det Edge
216  //MyVars.push_back( (Var*)(& ) ); MyVarNames.push_back( "BPFKalBakCell" ); // Dist of Kalman track proj Backward to Det Edge.
217 
218 
219  // --- Want some event id scores.
220  MyVars.push_back( (Var*)(&kCVNm ) ); MyVarNames.push_back( "CVNMuon18" ); // sr->sel.cvnProd3Train.numuid
221  MyVars.push_back( (Var*)(&kCVNm2017) ); MyVarNames.push_back( "CVNMuon17" ); // sr->sel.cvn2017.numuid
222  //MyVars.push_back( (Var*)(&kNumuContPID ) ); MyVarNames.push_back( "NumuContPID" ); // Old BDT variable.
223 
224  // --- /// Kalman Track specific Variables ///
225  // --- Kalman track variables.
226  MyVars.push_back( (Var*)(&kNKalman ) ); MyVarNames.push_back( "NKalTrks" ); // Number of Kalman Tracks
227  MyVars.push_back( (Var*)(&kTrkLength ) ); MyVarNames.push_back( "KalTrkLen" ); // Muon Track length
228  MyVars.push_back( (Var*)(&kTrkNhits ) ); MyVarNames.push_back( "KalTrkNHit" ); // Muon Num Hits
229  MyVars.push_back( (Var*)(&kTrkStartX ) ); MyVarNames.push_back( "KalTrkStX" ); // Kalman Tr Start X
230  MyVars.push_back( (Var*)(&kTrkStartY ) ); MyVarNames.push_back( "KalTrkStY" ); // Kalman Tr Start Y
231  MyVars.push_back( (Var*)(&kTrkStartZ ) ); MyVarNames.push_back( "KalTrkStZ" ); // Kalman Tr Start Z
232  MyVars.push_back( (Var*)(&kTrkEndX ) ); MyVarNames.push_back( "KalTrkEndX" ); // Kalman Tr End X
233  MyVars.push_back( (Var*)(&kTrkEndY ) ); MyVarNames.push_back( "KalTrkEndY" ); // Kalman Tr End Y
234  MyVars.push_back( (Var*)(&kTrkEndZ ) ); MyVarNames.push_back( "KalTrkEndZ" ); // Kalman Tr End Z
235  MyVars.push_back( (Var*)(&kDirX ) ); MyVarNames.push_back( "KalTrkDirX" ); // Kalman Tr Dir X
236  MyVars.push_back( (Var*)(&kDirY ) ); MyVarNames.push_back( "KalTrkDirY" ); // Kalman Tr Dir Y
237  MyVars.push_back( (Var*)(&kDirZ ) ); MyVarNames.push_back( "KalTrkDirZ" ); // Kalman Tr Dir Z
238  // --- Some topological and event ID information.
239  MyVars.push_back( (Var*)(&kNumuMuonPtP ) ); MyVarNames.push_back( "KalTrkPtOverP" ); // PtOverP
240  MyVars.push_back( (Var*)(&kCosNumi ) ); MyVarNames.push_back( "KalTrkCosNumi" ); // Cos of angle with NuMi Beam.
241  MyVars.push_back( (Var*)(&kRemID ) ); MyVarNames.push_back( "KalTrkRemID" ); // sr->sel.remid.pid
242 
243  // --- /// BPF track variables. ///
244  // --- Kalman track variables.
245  MyVars.push_back( (Var*)(&kBPFBestMuonNpng ) ); MyVarNames.push_back( "N3DProng" ); // Number of Prongs
246  MyVars.push_back( (Var*)(&kBPFBestMuonTrkLen ) ); MyVarNames.push_back( "BPFLen" ); // Muon Track length
247  MyVars.push_back( (Var*)(&kBPFBestMuonNhits ) ); MyVarNames.push_back( "BPFNHit" ); // Muon Num Hits
248  MyVars.push_back( (Var*)(&kBPFBestMuonStartx ) ); MyVarNames.push_back( "BPFStX" ); // BPF Tr Start X
249  MyVars.push_back( (Var*)(&kBPFBestMuonStarty ) ); MyVarNames.push_back( "BPFStY" ); // BPF Tr Start Y
250  MyVars.push_back( (Var*)(&kBPFBestMuonStartz ) ); MyVarNames.push_back( "BPFStZ" ); // BPF Tr Start Z
251  MyVars.push_back( (Var*)(&kBPFBestMuonStopx ) ); MyVarNames.push_back( "BPFEndX" ); // BPF Tr End X
252  MyVars.push_back( (Var*)(&kBPFBestMuonStopy ) ); MyVarNames.push_back( "BPFEndY" ); // BPF Tr End Y
253  MyVars.push_back( (Var*)(&kBPFBestMuonStopz ) ); MyVarNames.push_back( "BPFEndZ" ); // BPF Tr End Z
254  MyVars.push_back( (Var*)(&kBPFBestMuonDirx ) ); MyVarNames.push_back( "BPFDirX" ); // BPF Tr Dir X
255  MyVars.push_back( (Var*)(&kBPFBestMuonDiry ) ); MyVarNames.push_back( "BPFDirY" ); // BPF Tr Dir Y
256  MyVars.push_back( (Var*)(&kBPFBestMuonDirz ) ); MyVarNames.push_back( "BPFDirZ" ); // BPF Tr Dir Z
257  // --- Some topological and event ID information.
258  MyVars.push_back( (Var*)(&kBPFBestMuonPtP ) ); MyVarNames.push_back( "BPFPtOverP" ); // PtOverP
259  MyVars.push_back( (Var*)(&kBPFBestMuonCosNumi ) ); MyVarNames.push_back( "BPFCosNumi" ); // Cos of angle with NuMi Beam.
260  MyVars.push_back( (Var*)(&kCVNBestMuonScore ) ); MyVarNames.push_back( "BPFCVNScore" ); // Best CVN score for BPF track.
261  // -----------------------------------------------------------
262  // --- Now that everything is set up, lets make our TTrees!
263  // -----------------------------------------------------------
264  CAFTreeMaker treeMaker( MyDef, MyCuts, MyTrees, MyVars, MyVarNames );
265  treeMaker.SetSpillCut(kStandardSpillCuts);
266  treeMaker.Go();
267 
268  std::cout << "\nFinished looking through my TreeMaker code. I had " << treeMaker.GetNPassed() << " events pass cuts.\n" << std::endl;
269 
270  // -----------------------------------------------------------
271  // --- Finally, write everything to my output file.
272  // -----------------------------------------------------------
273  outFile->cd();
274  for ( uint t = 0; t < MyTrees.size(); ++t ) {
275  MyTrees[t]->Write();
276  }
277  outFile->Close();
278 } // --- DONE! ---
caf::Proxy< caf::SRSpill > spill
Definition: SRProxy.h:2143
const Var kMode([](const caf::SRProxy *sr){return(sr->mc.nnu==0)?-1:int(sr->mc.nu[0].mode);})
Neutrino interaction mode.
Definition: Vars.h:99
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
const Var kNKalman
Definition: NumuVars.cxx:540
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
void TrimCAFs(std::string sIdentifier, bool IsFHC=true, bool IsData=true, bool IsTrain=true)
Definition: TrimCAFs.C:99
const Var kKalmanBackwardCell
Definition: NumuVars.cxx:552
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
CAFTreeMaker(const std::string &wildcard, std::vector< Cut * > &cuts, std::vector< TTree * > &trees, std::vector< Var * > &vars, std::vector< std::string > varNames)
Definition: TrimCAFs.C:44
const Var kPPFXFluxCVWgt
Definition: PPFXWeights.h:16
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
bool IsFHC
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2126
caf::Proxy< std::vector< caf::SRNeutrino > > nu
Definition: SRProxy.h:618
const HistAxis kHadEFracAxis("E_{had.} / E_{#nu}", Binning::Simple(200, 0, 1), kHadEFrac)
HistAxis that implements Hadronic Energy fraction binning used by L.Vinton to derive Hadronic Energy ...
Definition: HistAxes.h:30
const Var kTrkStartY([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks< 1) return-10.0f;return sr->trk.kalman.tracks[0].start.Y()/100;})
Definition: NumuVars.h:52
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 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
void abs(TH1 *hist)
caf::Proxy< short int > nnu
Definition: SRProxy.h:617
void SetSpillCut(const SpillCut &cut)
const Var kDirZ([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks< 1) return-5.f;return sr->trk.kalman.tracks[0].dir.Z();})
Definition: NumuVars.h:39
const Var kTrkLength([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks< 1) return-5.f;return sr->trk.kalman.tracks[0].len/100;})
Definition: NumuVars.h:65
const Cut kIsNu([](const caf::SRProxy *sr){if(sr->mc.nnu==0) return false;assert(sr->mc.nnu==1);return sr->mc.nu[0].pdg > 0;})
Definition: TruthCuts.h:54
const Var kCosmicForwardCell
Definition: NumuVars.cxx:549
const Var kDirY([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks< 1) return-5.f;return sr->trk.kalman.tracks[0].dir.Y();})
Definition: NumuVars.h:38
void HandleRecord(caf::SRProxy *sr) override
Definition: TrimCAFs.C:68
ifstream inFile
Definition: AnaPlotMaker.h:34
const Var kTrueE([](const caf::SRProxy *sr){assert(sr->mc.nnu==1);return sr->mc.nu[0].E;})
Definition: Vars.cxx:85
TFile * outFile
Definition: PlotXSec.C:135
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
const Cut kNumuContainFD2017
Definition: NumuCuts2017.h:21
const Var kEvt
Definition: Vars.cxx:23
if(dump)
const Var kRemID
PID
Definition: Vars.cxx:81
correl_yv Fill(-(dy[iP-1][iC-1]), hyv->GetBinContent(iP, iC))
std::vector< std::string > wildcard(const std::string &wildcardString)
Definition: convert.C:9
std::string getenv(std::string const &name)
const Var kNHit
Definition: Vars.cxx:71
const Var kTrkStartZ([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks< 1) return-10.0f;return sr->trk.kalman.tracks[0].start.Z()/100;})
Definition: NumuVars.h:53
const Var kNumuMuonPtP([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks > 0 &&sr->trk.kalman.idxremid!=999){if(sr->hdr.det==1){double Zbeam=sr->trk.kalman.tracks[0].dir.Dot(beamDirND);double ptp=sqrt(1-Zbeam *Zbeam);return(float) ptp;}if(sr->hdr.det==2){double Zbeam=sr->trk.kalman.tracks[0].dir.Dot(beamDirFD);double ptp=sqrt(1-Zbeam *Zbeam);return(float) ptp;}}return-5.f;})
Definition: NumuVars.h:49
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::StandardRecord * sr
virtual void Go() override
Load all the registered spectra.
const std::map< std::pair< std::string, std::string >, Variable > vars
const Var kKalmanForwardCell
Definition: NumuVars.cxx:551
const Cut kIsCC([](const caf::SRProxy *sr){if(sr->mc.nnu==0) return false;assert(sr->mc.nnu==1);bool isCC=sr->mc.nu[0].iscc;return isCC;})
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 HistAxis kNumuCCOptimisedAxis("Reconstructed Neutrino Energy (GeV)", kNumuCCEOptimisedBinning, kCCE)
HistAxis that implements optimised numuCCE from L. Vinton. See docdb 16332. This was close to &#39;custC&#39;...
Definition: HistAxes.h:24
const Var kTrkStartX([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks< 1) return-10.0f;return sr->trk.kalman.tracks[0].start.X()/100;})
Definition: NumuVars.h:51
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
const Var kTrkEndZ([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks< 1) return-10.0f;return sr->trk.kalman.tracks[0].stop.Z()/100;})
Definition: NumuVars.h:57
OStream cout
Definition: OStream.cxx:6
const Cut kHasNeutrino([](const caf::SRProxy *sr){return(sr->mc.nnu!=0);})
Check if MC slice has neutrino information (useful for in-and-out tests)
Definition: TruthCuts.h:61
caf::Proxy< caf::SRTruthBranch > mc
Definition: SRProxy.h:2138
const Var kTrkEndY([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks< 1) return-10.0f;return sr->trk.kalman.tracks[0].stop.Y()/100;})
Definition: NumuVars.h:56
const Var kTrkEndX([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks< 1) return-10.0f;return sr->trk.kalman.tracks[0].stop.X()/100;})
Definition: NumuVars.h:55
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
const Var kDirX([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks< 1) return-5.f;return sr->trk.kalman.tracks[0].dir.X();})
Definition: NumuVars.h:37
~CAFTreeMaker()
Definition: TrimCAFs.C:64
std::vector< Cut > QuantileCutsFromTH2(TH2 *quantileHist, const HistAxis &independentAxis, const HistAxis &quantileAxis, const unsigned int &numQuantiles, const bool verbose)
: Do the same as the QuantileCuts function but taking in the TH2 instead of making it...
const Var kCosmicBackwardCell
Definition: NumuVars.cxx:550
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
const Var kRun
Definition: Vars.cxx:20
const Cut kNumuQuality
Definition: NumuCuts.h:18
const Var kCVNBestMuonScore([](const caf::SRProxy *sr){float muonScore=-5.0;if(kCVNMuonIdx(sr)< 0.0) return muonScore;if(!sr->vtx.elastic.IsValid) return muonScore;muonScore=sr->vtx.elastic.fuzzyk.png[(unsigned int) kCVNMuonIdx(sr)].cvnpart.muonid;if(sr->vtx.elastic.fuzzyk.png[(unsigned int) kCVNMuonIdx(sr)].len > 500.0) muonScore=1.0;return muonScore;})
: Muon score for best muon prong by CVN score & length
Definition: CVNProngVars.h:27
const Var kCVNm
PID
Definition: Vars.cxx:39
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 kCosNumi([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks > 0 &&sr->trk.kalman.idxremid!=999){if(sr->hdr.det==1){return sr->trk.kalman.tracks[0].dir.Dot(beamDirND);}if(sr->hdr.det==2){return sr->trk.kalman.tracks[0].dir.Dot(beamDirFD);}}return-5.f;})
Definition: NumuVars.h:43
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 kTrkNhits([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks< 1) return 65535;return int(sr->trk.kalman.tracks[0].nhit);})
Definition: NumuVars.h:59
const Var kXSecCVWgt2018RPAFix_noDIS
Definition: XsecTunes.h:57
int GetNPassed()
Definition: TrimCAFs.C:84
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
enum BeamMode string
unsigned int uint