CutFlow_MC.C
Go to the documentation of this file.
5 
6 #include "CAFAna/Cuts/Cuts.h"
10 #include "CAFAna/Cuts/TimingCuts.h"
11 
12 #include "CAFAna/Core/Loaders.h"
13 #include "CAFAna/Core/Spectrum.h"
16 
17 #include "CAFAna/Vars/Vars.h"
22 
24 
28 
29 #include "OscLib/OscCalcPMNSOpt.h"
30 
31 #include "TH1.h"
32 #include "TH2.h"
33 #include "TCanvas.h"
34 
35 using namespace ana;
36 
37 #include <fstream>
38 
39 struct Plot {
42  Binning bins;
43  Var var;
44 };
45 
46 void CutFlow_MC()
47 {
48  // --- Set my loader
51 
52  // --- Set my oscillation calculator
55 
56  // --- Define my cuts and their names.
57  std::vector<Cut> TieredCuts;
58  std::vector<std::string> CutNames;
59  CutNames.emplace_back("NoCut"); TieredCuts.emplace_back(kNoCut);
60  CutNames.emplace_back("Quality"); TieredCuts.emplace_back(kNumuQuality);
61  CutNames.emplace_back("Containment"); TieredCuts.emplace_back(kNumuQuality && kNumuContainFD2017);
62  CutNames.emplace_back("Cosmic_Rej"); TieredCuts.emplace_back(kNumuQuality && kNumuContainFD2017 && kNumuCosmicRej2017);
63  CutNames.emplace_back("Particle_ID"); TieredCuts.emplace_back(kNumuQuality && kNumuContainFD2017 && kNumuCosmicRej2017 && kNumuPID2017 );
64 
65  size_t NCuts = TieredCuts.size();
66 
67  // --- Define my objects.
68  Plot plot = {"CC Energy [GeV]", "NuMuCCEnergy", kNumuCCEOptimisedBinning, kCCE};
69  PredictionNoExtrap* ReconEnergy[NCuts];
70 
71  // --- Set my objects.
72  for(size_t cut = 0; cut < NCuts; ++cut) {
73  const Cut ThisCut = TieredCuts[cut];
74  ReconEnergy[cut] = new PredictionNoExtrap( *loader, plot.label, plot.bins, plot.var, ThisCut, kNoShift, kPPFXFluxCVWgt*kXSecCVWgt2017 );
75  }
76 
77  // --- Set the loader off!
78  loader->Go();
79 
80  // --- Define an outfile.
81  std::string OutName = "MonteCarloCutFlow.root";
82  TFile *OutFile = new TFile(OutName.c_str(), "RECREATE");
83  OutFile -> cd();
84  for(size_t cut = 0; cut < NCuts; ++cut){
85  ReconEnergy[cut] -> Predict(&calc).SaveTo( OutFile, TString(CutNames[cut])+TString("_FullMC" ) ) ;
86  ReconEnergy[cut] -> PredictComponent(&calc, Flavors::kNuMuToNuMu, Current::kCC, Sign::kBoth).SaveTo( OutFile, TString(CutNames[cut])+TString("_NuMuCC" ) ) ;
87  ReconEnergy[cut] -> PredictComponent(&calc, Flavors::kAllNuE , Current::kCC, Sign::kBoth).SaveTo( OutFile, TString(CutNames[cut])+TString("_AllNue" ) ) ;
88  ReconEnergy[cut] -> PredictComponent(&calc, Flavors::kNuEToNuMu , Current::kCC, Sign::kBoth).SaveTo( OutFile, TString(CutNames[cut])+TString("_NuEToMu" ) ) ;
89  ReconEnergy[cut] -> PredictComponent(&calc, Flavors::kAll , Current::kNC, Sign::kBoth).SaveTo( OutFile, TString(CutNames[cut])+TString("_AllNC" ) ) ;
90  ReconEnergy[cut] -> PredictComponent(&calc, Flavors::kAllNuTau , Current::kCC, Sign::kBoth).SaveTo( OutFile, TString(CutNames[cut])+TString("_AllTau" ) ) ;
91  }
92 
93 } // End of function
For nominal spectra and reweighting systs (xsec/flux)
Definition: Prod3Loaders.h:40
size_t NCuts
Definition: MakeCutFlow.C:50
Represent the binning of a Spectrum&#39;s x-axis.
Definition: Binning.h:16
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
void ResetOscCalcToDefault(osc::IOscCalcAdjustable *calc)
Reset calculator to default assumptions for all parameters.
Definition: Calcs.cxx:23
const Var kPPFXFluxCVWgt
Definition: PPFXWeights.h:16
std::string label
Definition: CutFlow_Data.C:29
Collection of SpectrumLoaders for many configurations.
Definition: Loaders.h:23
osc::OscCalcDumb calc
void Go()
Call Go() on all the loaders.
Definition: Loaders.cxx:162
const char * label
void SetSpillCut(const SpillCut &cut)
Definition: Loaders.cxx:121
Charged-current interactions.
Definition: IPrediction.h:39
====================================================================== ///
Definition: CutFlow_Data.C:28
const Cut kNumuContainFD2017
Definition: NumuCuts2017.h:21
void CutFlow_MC()
Definition: CutFlow_MC.C:46
Optimized version of OscCalcPMNS.
Definition: StanTypedefs.h:31
const Var kCCE
Definition: NumuVars.h:21
loader
Definition: demo0.py:10
const Cut kNumuPID2017([](const caf::SRProxy *sr){return(sr->sel.remid.pid > 0.5 &&sr->sel.cvn.numuid > 0.5);})
Definition: NumuCuts2017.h:27
virtual void SaveTo(TDirectory *dir, const std::string &name) const override
const Cut kNumuCosmicRej2017([](const caf::SRProxy *sr){return(sr->sel.cosrej.anglekal > 0.5 && sr->sel.cosrej.numucontpid2020 > 0.5 && sr->slc.nhit< 400);})
Definition: NumuCuts2017.h:24
const SystShifts kNoShift
Definition: SystShifts.cxx:22
(&#39; survival&#39;)
Definition: IPrediction.h:19
const Binning bins
Definition: NumuCC_CPiBin.h:8
const Cut cut
Definition: exporter_fd.C:30
const Binning kNumuCCEOptimisedBinning
Optimised binning for numuCCE from L. Vinton. See docdb 16332. This was close to &#39;custC&#39; in that talk...
Definition: Binnings.cxx:28
Neutral-current interactions.
Definition: IPrediction.h:40
Both neutrinos and antineutrinos.
Definition: IPrediction.h:52
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
TFile * OutFile
Binning bins
Definition: CutFlow_Data.C:31
Prediction that just uses FD MC, with no extrapolation.
const Cut kNumuQuality
Definition: NumuCuts.h:18
All neutrinos, any flavor.
Definition: IPrediction.h:26
(&#39; appearance&#39;)
Definition: IPrediction.h:16
const Var kXSecCVWgt2017
Definition: XsecTunes.h:36
Var var
Definition: CutFlow_Data.C:32
c cd(1)
const Cut kNoCut
The simplest possible cut: pass everything, used as a default.
Definition: Cut.h:109
void plot(std::string label, std::map< std::string, std::map< std::string, Spectrum * >> &plots, bool log)
std::vector< std::string > CutNames
Definition: MakeCutFlow.C:49
enum BeamMode string