make_training_sample.C
Go to the documentation of this file.
1 /*
2 
3  * Extract features for BDT training.
4 
5  *
6 
7  * To run through only 10 files, do
8 
9  * $ cafe -l 10 make_training_sample.C
10 
11  */
12 
13 #ifdef __CINT__
14 
15 void make_training_sample(int stride = 5000, int offset = 0)
16 
17 {
18 
19  std::cout << "Sorry, you must run in compiled mode" << std::endl;
20 
21 }
22 
23 #else
24 
25 // CAFAna includes
26 
27 #include "CAFAna/Core/EventList.h"
28 
29 #include "CAFAna/Core/MultiVar.h"
30 
31 //#include "3FlavorAna/Cuts/NumuCuts2018.h"
32 
33 #include "CAFAna/Cuts/SpillCuts.h"
34 
35 #include "CAFAna/Vars/Vars.h"
36 
37 
38 
39 
40 ///////NCPi0 Headers//////
44 /////////////////////////
45 
46 
47 using namespace ana;
48 
49 // Define my own Vars and Cuts
50 
51 const Var kRun = SIMPLEVAR(hdr.run);
52 
53 const Var kSubRun = SIMPLEVAR(hdr.subrun);
54 
55 const Var kCycle = SIMPLEVAR(hdr.cycle);
56 
57 const Var kEvt = SIMPLEVAR(hdr.evt);
58 
59 const Var kSlice = SIMPLEVAR(hdr.subevt);
60 
61 
62 
63 void make_training_sample(int stride = 5000, int offset = 0)
64 //void make_training_sample(int stride = 496, int offset = 0)
65 
66 {
67 
68  //string dataset = "defname: prod_caf_R17-03-01-prod3reco.d_nd_genie_nonswap_fhc_nova_v08_full_v1 with stride "+to_string(stride)+" offset "+to_string(offset);
69  string dataset = "defname: CVN_Prong_Prod4_ND_NuMI_MC_2view_Genielike_FlatFlux_CAFs with stride "+to_string(stride)+" offset "+to_string(offset);
70 
71 
72  MakeTextListFile(dataset, {kIsPreSel}, {"nd_fhc_nc_selection_stride_nominaldataset"+to_string(stride)+"_offset"+to_string(offset)+".txt"},{&kRun, &kSubRun, &kCycle, &kEvt, &kSlice, &kNpCVN1gamma, &kNpCVN2gamma, &kNCGapPng1, &kNCGapPng2, &kNCCurrent, &kPdgPi0},0);
73 
74  MakeTextListFile(dataset, {kIsPreSel}, {"nd_fhc_nc_selection_stride_2viewdataset"+to_string(stride)+"_offset"+to_string(offset)+".txt"},{&kRun, &kSubRun, &kCycle, &kEvt, &kSlice, &k2ViewCVN1gamma, &k2ViewCVN2gamma, &kNCGapPng1, &kNCGapPng2, &kNCCurrent, &kPdgPi0},0);
75 
76  MakeTextListFile(dataset, {kIsPreSel}, {"nd_fhc_nc_selection_stride_FlatFluxdataset"+to_string(stride)+"_offset"+to_string(offset)+".txt"},{&kRun, &kSubRun, &kCycle, &kEvt, &kSlice, &k2FlatFluxCVN1gamma, &k2FlatFluxCVN2gamma, &kNCGapPng1, &kNCGapPng2, &kNCCurrent, &kPdgPi0},0);
77 
78  MakeTextListFile(dataset, {kIsPreSel}, {"nd_fhc_nc_selection_stride_GenieLikedataset"+to_string(stride)+"_offset"+to_string(offset)+".txt"},{&kRun, &kSubRun, &kCycle, &kEvt, &kSlice, &k2GenieLikeCVN1gamma, &k2GenieLikeCVN2gamma, &kNCGapPng1, &kNCGapPng2, &kNCCurrent, &kPdgPi0},0);
79 
80 
81 }
82 
83 #endif
const Var kNCGapPng2([](const caf::SRProxy *sr){if(sr->vtx.nelastic==0) return 0.f;if(sr->vtx.elastic[0].fuzzyk.npng< 2) return float(-1);return float(sr->vtx.elastic[0].fuzzyk.png[1].shwlid.gap);})
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const Var kNCGapPng1([](const caf::SRProxy *sr){if(sr->vtx.nelastic==0) return 0.f;if(sr->vtx.elastic[0].fuzzyk.npng< 1) return float(-1);return float(sr->vtx.elastic[0].fuzzyk.png[0].shwlid.gap);})
void make_training_sample(int stride=5000, int offset=0)
const Var kNCCurrent([](const caf::SRProxy *sr){if(sr->vtx.nelastic==0) return 0;if(sr->mc.nnu==0) return 0;assert(sr->mc.nnu==1);if(sr->vtx.elastic[0].fuzzyk.nshwlid==0) return 0;if(sr->vtx.elastic[0].fuzzyk.npng==0) return 0;if(sr->mc.nu[0].iscc==0) return 1;return 0;})
const Var kNpCVN1gamma([](const caf::SRProxy *sr){if(sr->vtx.nelastic==0) return 0.f;if(sr->vtx.elastic[0].fuzzyk.npng< 1) return float(-1);return float(sr->vtx.elastic[0].fuzzyk.png[0].cvnpart.photonid);})
const Var k2GenieLikeCVN1gamma([](const caf::SRProxy *sr){if(sr->vtx.nelastic==0) return 0.f;if(sr->vtx.elastic[0].fuzzyk.npng< 1) return float(-1);return float(sr->vtx.elastic[0].fuzzyk.png[0].cvnpart2GenieLike.photonid);})
const Var k2FlatFluxCVN1gamma([](const caf::SRProxy *sr){if(sr->vtx.nelastic==0) return 0.f;if(sr->vtx.elastic[0].fuzzyk.npng< 1) return float(-1);return float(sr->vtx.elastic[0].fuzzyk.png[0].cvnpart2FlatFlux.photonid);})
void MakeTextListFile(const std::string &wildcard, const std::vector< Cut > &cut, const std::vector< std::string > &output, const std::vector< const Var * > &floatVars, const std::vector< const Var * > &intVars, const SpillCut *spillCut)
Make a file listing all the events passing the specified cut.
Definition: EventList.cxx:193
const Var kEvt
Definition: Vars.cxx:23
const Var kNpCVN2gamma([](const caf::SRProxy *sr){if(sr->vtx.nelastic==0) return 0.f;if(sr->vtx.elastic[0].fuzzyk.npng< 2) return float(-1);return float(sr->vtx.elastic[0].fuzzyk.png[1].cvnpart.photonid);})
const Var kPdgPi0([](const caf::SRProxy *sr){if(sr->mc.nu.size()==0) return 0;for(auto const &iPrim:sr->mc.nu[0].prim){if(iPrim.pdg==111) return 1;}return 0;})
const Var kSubRun
#define SIMPLEVAR(CAFNAME)
For Vars where literally all you need is a single CAF variable.
Definition: Var.h:88
const Cut kIsPreSel
Definition: ncpi0Cuts.h:1099
const Var kCycle
Definition: Vars.cxx:22
OStream cout
Definition: OStream.cxx:6
const Var k2ViewCVN2gamma([](const caf::SRProxy *sr){if(sr->vtx.nelastic==0) return 0.f;if(sr->vtx.elastic[0].fuzzyk.npng< 2) return float(-1);return float(sr->vtx.elastic[0].fuzzyk.png[1].cvnpart2View.photonid);})
const Var k2ViewCVN1gamma([](const caf::SRProxy *sr){if(sr->vtx.nelastic==0) return 0.f;if(sr->vtx.elastic[0].fuzzyk.npng< 1) return float(-1);return float(sr->vtx.elastic[0].fuzzyk.png[0].cvnpart2View.photonid);})
const Var kSlice
const Var kRun
Definition: Vars.cxx:20
const Var k2GenieLikeCVN2gamma([](const caf::SRProxy *sr){if(sr->vtx.nelastic==0) return 0.f;if(sr->vtx.elastic[0].fuzzyk.npng< 2) return float(-1);return float(sr->vtx.elastic[0].fuzzyk.png[1].cvnpart2GenieLike.photonid);})
const Var k2FlatFluxCVN2gamma([](const caf::SRProxy *sr){if(sr->vtx.nelastic==0) return 0.f;if(sr->vtx.elastic[0].fuzzyk.npng< 2) return float(-1);return float(sr->vtx.elastic[0].fuzzyk.png[1].cvnpart2FlatFlux.photonid);})
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34