17 #include "CAFAna/Cuts/NueCutsSecondAna.h" 38 std::vector <HistDef>
defs;
40 AddNueHistDefSecondAnaBasic(defs);
47 AddNueHistDefForCvn(defs);
54 const int kIdUnweight = defs.size();
65 std::vector <CutDef >
sels = {
67 {
"1_NueSecondAnaDQ",kNueSecondAnaDQ},
68 {
"2_NueFDSecondAnaDecaf",kNueFDSecondAnaDecafCut},
69 {
"3_NueSecondAnaFullPresel", kNueSecondAnaFullPresel},
70 {
"4_NueSAFDCVNSsb" ,kNueSAFDCVNSsb},
71 {
"5_NueSAFDCVNSb", kNueSecondAnaFullPresel && kNueSecondAnaCVNSb},
77 std::vector<double> passes;
78 for (
unsigned int i=0;
i<sels.size();++
i){
79 if(sels[
i].
cut(sr)) passes.push_back(
i);
81 if(sr->
mc.
nnu==0)passes.push_back(sels.size()+1);
100 std::vector < std::vector<Spectrum *> > other_nonswap;
101 std::vector < std::vector<Spectrum *> > other_flxswap;
102 std::vector < std::vector<IPrediction*> > preds;
104 for(
int selIdx = 0; selIdx<(
int)sels.size(); ++selIdx){
105 std::vector<Spectrum *> temp_nonswap;
106 std::vector<Spectrum *> temp_flxswap;
107 std::vector<IPrediction *> temp_pred;
109 for(
int varIdx = 0; varIdx < (
int)defs.size(); ++varIdx){
115 temp_nonswap.emplace_back(sp_nonswap);
116 temp_flxswap.emplace_back(sp_flxswap);
118 temp_pred.emplace_back
123 other_nonswap.push_back(temp_nonswap);
124 other_flxswap.push_back(temp_flxswap);
125 preds.push_back(temp_pred);
128 auto spfl_nonswap =
new Spectrum (
"Cut Flow",flowBins,loaderNonSwap, kCutFlowVar,
kNoCut);
129 auto spfl_flxswap =
new Spectrum (
"Cut Flow",flowBins,loaderFlxSwap, kCutFlowVar,
kNoCut);
134 TFile*
fout =
new TFile(predFileName.c_str(),
"RECREATE");
137 for(
int selIdx = 0; selIdx < (
int)sels.size(); ++selIdx){
138 const char*
cut = sels[selIdx].name.c_str();
139 for(
int varIdx = 0; varIdx < (
int)defs.size(); ++varIdx){
140 const char*
name = defs[varIdx].name.c_str();
142 other_nonswap[selIdx][varIdx]->SaveTo(fout,
TString::Format(
"other_nonswap_%s_%s", name, cut));
143 other_flxswap[selIdx][varIdx]->SaveTo(fout,
TString::Format(
"other_flxswap_%s_%s", name, cut));
144 preds[selIdx][varIdx] ->SaveTo(fout,
TString::Format(
"pred_%s_%s", name, cut));
146 prog.SetProgress((
double)nsteps/(sels.size()*defs.size()+1));
149 spfl_nonswap->SaveTo(fout,
"spect_nonswap_cutflow");
150 spfl_flxswap->SaveTo(fout,
"spect_flxswap_cutflow");
153 std::cout <<
"Saved prediction to " << predFileName <<
"\n";
158 TFile * predFile =
new TFile (predFileName.c_str(),
"READ");
159 TString validFileName1 (predFileName);
160 validFileName1.ReplaceAll(
".root",
"_mc_validation.root");
161 TFile * validFile1 =
new TFile(validFileName1,
"RECREATE");
170 TDirectory* comp = 0;
171 if(components) comp = validFile1->mkdir(
"MCComponents");
181 for(
int selIdx = 0; selIdx <
kNumSels; ++selIdx){
182 const char*
cut = sels[selIdx].name.c_str();
184 for(
int varIdx = 0; varIdx <
kNumVars; ++varIdx){
185 const char*
name = defs[varIdx].name.c_str();
190 predFile->GetDirectory(
TString::Format(
"other_nonswap_%s_%s", name, cut)));
192 predFile->GetDirectory(
TString::Format(
"other_flxswap_%s_%s", name, cut)));
193 auto other = *other_nonswap + *other_flxswap;
195 for(
int i=0;
i<2;
i++){
198 oscName =
"NoOscillations";
202 oscName=
"DumbOscillations";
210 SaveTo(comp,
TString::Format(
"%s_{group=Cut,cat=%s}{group=Osc,cat=%s}{group=Component,cat=0_sig}", name,cut,oscName));
212 SaveTo(comp,
TString::Format(
"%s_{group=Cut,cat=%s}{group=Osc,cat=%s}{group=Component,cat=1_beam}", name,cut,oscName));
214 SaveTo(comp,
TString::Format(
"%s_{group=Cut,cat=%s}{group=Osc,cat=%s}{group=Component,cat=2_nc}", name,cut,oscName));
216 SaveTo(comp,
TString::Format(
"%s_{group=Cut,cat=%s}{group=Osc,cat=%s}{group=Component,cat=3_numu}", name,cut,oscName));
218 SaveTo(comp,
TString::Format(
"%s_{group=Cut,cat=%s}{group=Osc,cat=%s}{group=Component,cat=4_tau}", name,cut,oscName));
220 SaveTo(comp,
TString::Format(
"%s_{group=Cut,cat=%s}{group=Osc,cat=%s}{group=Component,cat=5_other}", name,cut,oscName));
223 prog.
SetProgress((
double)nsteps/(kNumSels*kNumVars*2.));
227 for(
auto oscName:{
"NoOscillations",
"DumbOscillations"}){
229 spfl->SaveTo(validFile1,
TString::Format(
"%s{group=Cut,cat=%s}{group=Osc,cat=%s}",
"_cutflow_nonswap",cut,oscName));
231 spfl->SaveTo(validFile1,
TString::Format(
"%s{group=Cut,cat=%s}{group=Osc,cat=%s}",
"_cutflow_flxswap",cut,oscName));
void AddNueHistDefWeight(std::vector< HistDef > &hd)
void AddNueHistDefShowerFD(std::vector< HistDef > &hd)
Represent the binning of a Spectrum's x-axis.
Cuts and Vars for the 2020 FD DiF Study.
void SaveTo(const osc::IOscCalc &x, TDirectory *dir, const std::string &name)
const std::vector< T > & GetVars() const
Proxy for caf::StandardRecord.
General interface to oscillation calculators.
caf::Proxy< short int > nnu
void SetSpillCut(const SpillCut &cut)
_NoOscillations< double > NoOscillations
Charged-current interactions.
void AddNueHistDefForLem(std::vector< HistDef > &)
void AddNueHistDefSelectionExtras(std::vector< HistDef > &hd)
static std::unique_ptr< Spectrum > LoadFrom(TDirectory *dir, const std::string &name)
Struct to hold cut information.
Simple oscillation probability calculator that has no solar term or mass hierarchy or delta so it's s...
virtual void Go() override
Load all the registered spectra.
const HistDef defs[kNumVars]
osc::NoOscillations noosc
std::vector< float > Spectrum
const SystShifts kNoShift
void AddNueHistDefShower(std::vector< HistDef > &hd)
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)
caf::Proxy< caf::SRTruthBranch > mc
const std::vector< Binning > & GetBinnings() const
void AddNueHistDefVertexFD(std::vector< HistDef > &hd)
void AddNueHistDefTruth(std::vector< HistDef > &hd)
void nue_fd_mc_validation(const std::string predFileName, const bool makeFile=false, const std::string ldrNonSwap="", const std::string ldrFluxSwap="", const std::string ldrTauSwap="")
void SetProgress(double frac)
Update the progress fraction between zero and one.
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
Neutral-current interactions.
A simple ascii-art progress bar.
void AddNueHistDefForLid(std::vector< HistDef > &hd)
Both neutrinos and antineutrinos.
const Var kDummy([](const caf::SRProxy *sr){return 1;})
Dummy loader that doesn't load any files.
const SpillCut kStandardSpillCuts
Apply this unless you're doing something special.
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
All neutrinos, any flavor.
void Done()
Call this when action is completed.
void AddNueHistDefConfusion(std::vector< HistDef > &hd)
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
const Var kUnweighted
The simplest possible Var, always 1. Used as a default weight.
void AddNueHistDefPIDs(std::vector< HistDef > &hd)
const Cut kNoCut
The simplest possible cut: pass everything, used as a default.
const std::vector< std::string > & GetLabels() const