CutFlow_MC.C
Go to the documentation of this file.
2 
4 #include "CAFAna/Cuts/Cuts.h"
9 
10 #include "CAFAna/Core/Loaders.h"
11 #include "CAFAna/Core/Spectrum.h"
13 
14 #include "CAFAna/Vars/Vars.h"
19 
21 
23 
24 using namespace ana;
25 
26 #include <fstream>
27 
28 void CutFlow_MC()
29 {
30  // --- Set my loader
31  Loaders *FHC_Loader = new Prod4NomLoaders( ECAFType::kFullCAF, Loaders::kFHC, "full");
32  Loaders *RHC_Loader = new Prod4NomLoaders( ECAFType::kFullCAF, Loaders::kRHC, "full");
33  FHC_Loader->SetSpillCut(kStandardSpillCuts);
34  RHC_Loader->SetSpillCut(kStandardSpillCuts);
35 
36  // --- Define my cuts and their names.
37  std::vector<Cut> TieredCuts;
38  std::vector<std::string> CutNames;
39  // --- A set without true containment.
40  CutNames.emplace_back("NoCut"); TieredCuts.emplace_back(kNoCut);
41  CutNames.emplace_back("Quality"); TieredCuts.emplace_back(kNumuQuality);
42  CutNames.emplace_back("Containment"); TieredCuts.emplace_back(kNumuQuality && kNumuContainFD2017);
43  CutNames.emplace_back("Cosmic_Rej"); TieredCuts.emplace_back(kNumuQuality && kNumuContainFD2017 && kNumuCosmicRej2018);
44  CutNames.emplace_back("Particle_ID"); TieredCuts.emplace_back(kNumuQuality && kNumuContainFD2017 && kNumuCosmicRej2018 && kNumuPID2018 );
45  // --- A set with true containment.
46  CutNames.emplace_back("True-NoCut"); TieredCuts.emplace_back(kBoxCut && kNoCut);
47  CutNames.emplace_back("True-Quality"); TieredCuts.emplace_back(kBoxCut && kNumuQuality);
48  CutNames.emplace_back("True-Containment"); TieredCuts.emplace_back(kBoxCut && kNumuQuality && kNumuContainFD2017);
49  CutNames.emplace_back("True-Cosmic_Rej"); TieredCuts.emplace_back(kBoxCut && kNumuQuality && kNumuContainFD2017 && kNumuCosmicRej2018);
50  CutNames.emplace_back("True-Particle_ID"); TieredCuts.emplace_back(kBoxCut && kNumuQuality && kNumuContainFD2017 && kNumuCosmicRej2018 && kNumuPID2018 );
51 
52  size_t NCuts = TieredCuts.size();
53 
54  const Binning RatioBins = Binning::Simple(100, -0.05, 0.05 );
55  const Var kCDirScore([](const caf::SRProxy* sr){
56  return ((float)sr->sel.cosrej.cdirscore);
57  });
58 
59  // --- Define my objects.
60  PredictionNoExtrap* ReconEnergy_FHC[NCuts];
61  PredictionNoExtrap* ReconEnergy_RHC[NCuts];
62 
63  PredictionNoExtrap* CDir_FHC[NCuts];
64  PredictionNoExtrap* CDir_RHC[NCuts];
65 
66  // --- Set my objects.
67  for(size_t cut = 0; cut < NCuts; ++cut) {
68  const Cut ThisCut = TieredCuts[cut];
69  ReconEnergy_FHC[cut] = new PredictionNoExtrap( *FHC_Loader, "Reco Energy (GeV)", kNumuCCEOptimisedBinning, kCCE, ThisCut, kNoShift, kPPFXFluxCVWgt*kXSecCVWgt2018 );
70  ReconEnergy_RHC[cut] = new PredictionNoExtrap( *RHC_Loader, "Reco Energy (GeV)", kNumuCCEOptimisedBinning, kCCE, ThisCut, kNoShift, kPPFXFluxCVWgt*kXSecCVWgt2018 );
71 
72  CDir_FHC[cut] = new PredictionNoExtrap( *FHC_Loader, "CosRej CDir", RatioBins, kCDirScore, ThisCut, kNoShift, kPPFXFluxCVWgt*kXSecCVWgt2018 );
73  CDir_RHC[cut] = new PredictionNoExtrap( *RHC_Loader, "CosRej CDir", RatioBins, kCDirScore, ThisCut, kNoShift, kPPFXFluxCVWgt*kXSecCVWgt2018 );
74  }
75 
76  // --- Set the loader off!
77  FHC_Loader->Go();
78  RHC_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_FHC[cut] -> SaveTo( OutFile, TString(CutNames[cut])+TString("_FullMC_FHC" ) ) ;
86  ReconEnergy_RHC[cut] -> SaveTo( OutFile, TString(CutNames[cut])+TString("_FullMC_RHC" ) ) ;
87 
88  CDir_FHC[cut] -> SaveTo( OutFile, TString(CutNames[cut])+TString("_FullMC_CDir_FHC" ) ) ;
89  CDir_RHC[cut] -> SaveTo( OutFile, TString(CutNames[cut])+TString("_FullMC_CDir_RHC" ) ) ;
90  }
91 } // End of function
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 SaveTo(const osc::IOscCalc &x, TDirectory *dir, const std::string &name)
const Var kPPFXFluxCVWgt
Definition: PPFXWeights.h:16
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2126
Collection of SpectrumLoaders for many configurations.
Definition: Loaders.h:23
caf::Proxy< float > cdirscore
Definition: SRProxy.h:860
caf::Proxy< caf::SRCosRej > cosrej
Definition: SRProxy.h:1252
void Go()
Call Go() on all the loaders.
Definition: Loaders.cxx:162
const Cut kNumuCosmicRej2018([](const caf::SRProxy *sr){return(sr->sel.cosrej.anglekal > 0.5 && sr->sel.cosrej.numucontpid2019 > 0.53 && sr->slc.nhit< 400 && sr->sel.nuecosrej.pngptp< 0.9 );})
Definition: NumuCuts2018.h:19
void SetSpillCut(const SpillCut &cut)
Definition: Loaders.cxx:121
const Cut kNumuContainFD2017
Definition: NumuCuts2017.h:21
const Cut kBoxCut([](const caf::SRProxy *sr){if(sr->mc.nnu==0) return false;if(sr->mc.nu[0].vtx.x< -762) return false;if(sr->mc.nu[0].vtx.x > 763) return false;if(sr->mc.nu[0].vtx.y< -762) return false;if(sr->mc.nu[0].vtx.y > 763) return false;std::bitset< 14 > binary(sr->hdr.dibmask);std::pair< int, int > planesA=calcFirstLastLivePlane(sr->slc.firstplane, binary);std::pair< int, int > planesB=calcFirstLastLivePlane(sr->slc.lastplane, binary);if((planesA.first!=planesB.first)||(planesA.second!=planesB.second)) return false;if((planesA.second-planesA.first+1)/64< 4) return false;int first=planesA.first/64;int last=(planesA.second+1)/64;if(sr->mc.nu[0].vtx.z< ((first)*426.0)) return false;if(sr->mc.nu[0].vtx.z >((last)*426.0)) return false;return true;})
Definition: AnalysisMasks.h:25
void CutFlow_MC()
Definition: CutFlow_MC.C:46
const Var kCCE
Definition: NumuVars.h:21
caf::StandardRecord * sr
const SystShifts kNoShift
Definition: SystShifts.cxx:21
const Cut cut
Definition: exporter_fd.C:30
const Cut kNumuPID2018([](const caf::SRProxy *sr){std::cout<< "ERROR::kNumuPID2018, cutting on both cvnProd3Train and cvn2017."<< " Neither branch exists anymore. Returning False."<< std::endl;abort();return false;})
Definition: NumuCuts2018.h:22
const Var kXSecCVWgt2018
Definition: XsecTunes.h:49
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
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
TFile * OutFile
Prediction that just uses FD MC, with no extrapolation.
caf::Proxy< caf::SRIDBranch > sel
Definition: SRProxy.h:2141
For nominal spectra and reweighting systs (xsec/flux)
Definition: Prod4Loaders.h:96
const Cut kNumuQuality
Definition: NumuCuts.h:18
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:107
c cd(1)
const Cut kNoCut
The simplest possible cut: pass everything, used as a default.
Definition: Cut.h:109
const Binning RatioBins
std::vector< std::string > CutNames
Definition: MakeCutFlow.C:49
enum BeamMode string