NuMu2020_BasicPIDPlots_Spectrum.C
Go to the documentation of this file.
4 
5 #include "CAFAna/Core/Loaders.h"
7 #include "CAFAna/Core/Var.h"
8 
12 #include "CAFAna/Vars/XsecTunes.h"
13 
15 
16 #include "TH2.h"
17 #include "TFile.h"
19 #include <iostream>
20 
21 using namespace ana;
22 
23 
24 void NuMu2020_BasicPIDPlots_Spectrum( bool isFHC, bool isData, bool isFD, std::string period = "full" ) {
25 
26  std::string polarity = "fhc"; if (!isFHC ) polarity = "rhc" ;
27  std::string data = "mc" ; if ( isData) data = "data";
28  std::string detector = "nd" ; if ( isFD ) detector = "fd" ;
29 
30  std::cout << "\n================================= \n"
31  << "\n\t isFHC --> " << isFHC << " --> " << polarity
32  << "\n\t isData --> " << isData << " --> " << data
33  << "\n\t Period --> " << period
34  << "\n\t isFD --> " << isFD << " --> " << detector
35  << "\n================================= \n"
36  << std::endl;
37 
38  // Make my vector of cuts.
39  std::vector<std::pair<Cut, std::string> > MyCuts = BasicPIDPlots_Cuts( isFHC, isFD, isData );
40  const size_t NCuts = MyCuts.size();
41 
42  // What XSec and PPFX weights am I using?
43  Var kMyWeight = kUnweighted;
44  if (!isFD && !isData) kMyWeight = kXSecCVWgt2020 * kPPFXFluxCVWgt;
45 
46  // Figure out my definition, and then declare my spectrum loader.
47  std::string MyDef = "";
48  if ( isFD ) MyDef = "prod_caf_R19-11-18-prod5reco.i_fd_cosmic_"+polarity+"_full_v1_goodruns";
49  if (!isFD && isData) MyDef = "prod_caf_R19-11-18-prod5reco.d_nd_numi_" +polarity+"_full_v1";
50  if (!isFD && !isData) MyDef = "prod_caf_R19-11-18-prod5reco.d_nd_genie_N1810j0211a_nonswap_"+polarity+"_nova_v08_full_v1";
51  // Set my Loader
52  SpectrumLoader loader( MyDef );
53  if (!isFD) loader.SetSpillCut ( kStandardSpillCuts );
54 
55  // Declare my spectra
56  Spectrum *sNuRecoE [NCuts];
57  /*
58  Spectrum *sReMIdScore [NCuts];
59  Spectrum *sProngScoremuon[NCuts];
60  Spectrum *sCosRejScoreP4 [NCuts];
61  Spectrum *sCosRejScoreP5 [NCuts];
62  Spectrum *sOldPreselmuon [NCuts];
63  Spectrum *sOldPreselcosm [NCuts];
64  Spectrum *sLoosePTPmuon [NCuts];
65  Spectrum *sLoosePTPcosm [NCuts];
66  */
67  for (size_t cc=0; cc < NCuts; ++cc) {
68  Cut kThisCut = MyCuts[cc].first;
69  if (isFD) kThisCut = kThisCut && kInCosmicTimingWindow;
70 
71  sNuRecoE [cc] = new Spectrum( "Reco Nu E" , kOptEnBins , loader, kCCE , kThisCut, kNoShift, kMyWeight );
72  /*
73  sReMIdScore [cc] = new Spectrum( "ReMId Score" , kRemidBinning, loader, kRemID , kThisCut, kNoShift, kMyWeight );
74  sProngScoremuon[cc] = new Spectrum( "Prong CVN Muon Score" , kSimpBins , loader, kCVNBestMuonScore, kThisCut, kNoShift, kMyWeight );
75  sCosRejScoreP4 [cc] = new Spectrum( "Prod4 CosRej Score" , kSimpBins , loader, kNumuContPID2019 , kThisCut, kNoShift, kMyWeight );
76  sCosRejScoreP5 [cc] = new Spectrum( "Prod5 CosRej Score" , kSimpBins , loader, kNumuContPID , kThisCut, kNoShift, kMyWeight );
77  sOldPreselmuon [cc] = new Spectrum( "Old Presel Muon Score", kSimpBins , loader, kCVNm_oldpresel , kThisCut, kNoShift, kMyWeight );
78  sOldPreselcosm [cc] = new Spectrum( "Old Presel Cosm Score", kSimpBins , loader, kCVNcos_oldpresel, kThisCut, kNoShift, kMyWeight );
79  sLoosePTPmuon [cc] = new Spectrum( "Loose Pt/p Muon Score", kSimpBins , loader, kCVNm_looseptp , kThisCut, kNoShift, kMyWeight );
80  sLoosePTPcosm [cc] = new Spectrum( "Loose Pt/p Cosm Score", kSimpBins , loader, kCVNcos_looseptp , kThisCut, kNoShift, kMyWeight );
81  */
82  }
83 
84  // Set my loader going.
85  loader.Go();
86 
87  // Make my Output file
88  std::string OutName = "BasicPIDPlots_2020_"+detector+"_"+data+"_"+polarity+"_"+period+".root";
89  TFile *OutFile = TFile::Open(OutName.c_str(), "RECREATE");
90  for (size_t cc=0; cc < NCuts; ++cc) {
91  std::string ThisCutNa = MyCuts[cc].second;
92 
93  sNuRecoE [cc] -> SaveTo( OutFile, TString("RecoNuE" )+TString(ThisCutNa) ) ;
94  /*
95  sReMIdScore [cc] -> SaveTo( OutFile, TString("ReMIdScore" )+TString(ThisCutNa) ) ;
96  sProngScoremuon[cc] -> SaveTo( OutFile, TString("ProngCVNMuonScore" )+TString(ThisCutNa) ) ;
97  sOldPreselmuon [cc] -> SaveTo( OutFile, TString("OldPreselMuonScore")+TString(ThisCutNa) ) ;
98  sOldPreselcosm [cc] -> SaveTo( OutFile, TString("OldPreselCosmScore")+TString(ThisCutNa) ) ;
99  sLoosePTPmuon [cc] -> SaveTo( OutFile, TString("LoosePtpMuonScore" )+TString(ThisCutNa) ) ;
100  sLoosePTPcosm [cc] -> SaveTo( OutFile, TString("LoosePtpCosmScore" )+TString(ThisCutNa) ) ;
101  if (isFD) {
102  sCosRejScoreP4[cc]-> SaveTo( OutFile, TString("Prod4CosRejScore" )+TString(ThisCutNa) ) ;
103  sCosRejScoreP5[cc]-> SaveTo( OutFile, TString("Prod5CosRejScore" )+TString(ThisCutNa) ) ;
104  }
105  */
106  }
107  OutFile -> Close();
108 }
size_t NCuts
Definition: MakeCutFlow.C:50
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
std::vector< std::pair< Cut, std::string > > BasicPIDPlots_Cuts(bool isFHC, bool isFD, bool isData)
void SetSpillCut(const SpillCut &cut)
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
const XML_Char const XML_Char * data
Definition: expat.h:268
const Cut kInCosmicTimingWindow
Is the event far from the start and ends of the spill ? For FD cosmic selection.
Definition: TimingCuts.cxx:165
const Var kCCE
Definition: NumuVars.h:21
virtual void Go() override
Load all the registered spectra.
loader
Definition: demo0.py:10
std::vector< float > Spectrum
Definition: Constants.h:610
c1 Close()
static bool isFHC
const SystShifts kNoShift
Definition: SystShifts.cxx:22
OStream cout
Definition: OStream.cxx:6
const Binning kOptEnBins
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
void cc()
Definition: test_ana.C:28
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
TFile * OutFile
void NuMu2020_BasicPIDPlots_Spectrum(bool isFHC, bool isData, bool isFD, std::string period="full")
const Var kUnweighted
The simplest possible Var, always 1. Used as a default weight.
Definition: Var.h:96
const Var kXSecCVWgt2020
Definition: XsecTunes.h:106
enum BeamMode string