NuMu2020_BasicPIDPlots_ND.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_ND( bool isFHC, bool isData, 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" ;
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 Far detector 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, false, isData );
40  const size_t NCuts = MyCuts.size();
41 
42  // What XSec and PPFX weights am I using?
43  Var kMyWeight = kXSecCVWgt2020 * kPPFXFluxCVWgt;
44  if (isData) kMyWeight = kUnweighted;
45 
46  // Figure out my definition, and then declare my spectrum loader.
47  std::string MyDef = "prod_caf_R19-11-18-prod5reco.d_nd_numi_"+polarity+"_full_v1";
48  if (!isData) MyDef = "prod_caf_R19-11-18-prod5reco.d_nd_genie_N1810j0211a_nonswap_"+polarity+"_nova_v08_full_v1";
49  SpectrumLoader loader( MyDef );
51 
52  // Declare my spectra
53  Spectrum *sNuRecoE [NCuts];
54  Spectrum *sReMIdScore [NCuts];
55  Spectrum *sProngScoremuon[NCuts];
56  Spectrum *sCosRejScoreP4 [NCuts];
57  Spectrum *sCosRejScoreP5 [NCuts];
58  Spectrum *sOldPreselmuon [NCuts];
59  Spectrum *sOldPreselcosm [NCuts];
60  Spectrum *sLoosePTPmuon [NCuts];
61  Spectrum *sLoosePTPcosm [NCuts];
62 
63  for (size_t cc=0; cc < NCuts; ++cc) {
64  Cut kThisCut = MyCuts[cc].first;
65 
66  sNuRecoE [cc] = new Spectrum( "Reco Nu E" , kOptEnBins , loader, kCCE , kThisCut, kNoShift, kMyWeight );
67  sReMIdScore [cc] = new Spectrum( "ReMId Score" , kRemidBinning, loader, kRemID , kThisCut, kNoShift, kMyWeight );
68  sProngScoremuon[cc] = new Spectrum( "Prong CVN Muon Score" , kSimpBins , loader, kCVNBestMuonScore, kThisCut, kNoShift, kMyWeight );
69  sCosRejScoreP4 [cc] = new Spectrum( "Prod4 CosRej Score" , kSimpBins , loader, kNumuContPID2019 , kThisCut, kNoShift, kMyWeight );
70  sCosRejScoreP5 [cc] = new Spectrum( "Prod5 CosRej Score" , kSimpBins , loader, kNumuContPID , kThisCut, kNoShift, kMyWeight );
71  sOldPreselmuon [cc] = new Spectrum( "Old Presel Muon Score", kSimpBins , loader, kCVNm_oldpresel , kThisCut, kNoShift, kMyWeight );
72  sOldPreselcosm [cc] = new Spectrum( "Old Presel Cosm Score", kSimpBins , loader, kCVNcos_oldpresel, kThisCut, kNoShift, kMyWeight );
73  sLoosePTPmuon [cc] = new Spectrum( "Loose Pt/p Muon Score", kSimpBins , loader, kCVNm_looseptp , kThisCut, kNoShift, kMyWeight );
74  sLoosePTPcosm [cc] = new Spectrum( "Loose Pt/p Cosm Score", kSimpBins , loader, kCVNcos_looseptp , kThisCut, kNoShift, kMyWeight );
75  }
76 
77  // Set my loader going.
78  loader.Go();
79 
80  // Make my Output file
81  std::string OutName = "BasicPIDPlots_2020_"+detector+"_"+data+"_"+polarity+"_"+period+".root";
82  TFile *OutFile = TFile::Open(OutName.c_str(), "RECREATE");
83  for (size_t cc=0; cc < NCuts; ++cc) {
84  std::string ThisCutNa = MyCuts[cc].second;
85 
86  sNuRecoE [cc] -> SaveTo( OutFile, TString("RecoNuE" )+TString(ThisCutNa) ) ;
87  sReMIdScore [cc] -> SaveTo( OutFile, TString("ReMIdScore" )+TString(ThisCutNa) ) ;
88  sProngScoremuon[cc] -> SaveTo( OutFile, TString("ProngCVNMuonScore" )+TString(ThisCutNa) ) ;
89  sOldPreselmuon [cc] -> SaveTo( OutFile, TString("OldPreselMuonScore")+TString(ThisCutNa) ) ;
90  sOldPreselcosm [cc] -> SaveTo( OutFile, TString("OldPreselCosmScore")+TString(ThisCutNa) ) ;
91  sLoosePTPmuon [cc] -> SaveTo( OutFile, TString("LoosePtpMuonScore" )+TString(ThisCutNa) ) ;
92  sLoosePTPcosm [cc] -> SaveTo( OutFile, TString("LoosePtpCosmScore" )+TString(ThisCutNa) ) ;
93  if (isFD) {
94  sCosRejScoreP4[cc]-> SaveTo( OutFile, TString("Prod4CosRejScore" )+TString(ThisCutNa) ) ;
95  sCosRejScoreP5[cc]-> SaveTo( OutFile, TString("Prod5CosRejScore" )+TString(ThisCutNa) ) ;
96  }
97  }
98  OutFile -> Close();
99 }
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 Binning kRemidBinning
Binning for plotting remid attractively.
Definition: Binning.cxx:80
const Var kPPFXFluxCVWgt
Definition: PPFXWeights.h:16
const Var kNumuContPID
Definition: NumuVars.cxx:553
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
void NuMu2020_BasicPIDPlots_ND(bool isFHC, bool isData, std::string period="full")
const Var kRemID
PID
Definition: Vars.cxx:81
const Var kNumuContPID2019
Definition: NumuVars.cxx:554
const Var kCCE
Definition: NumuVars.h:21
const Binning kSimpBins
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 Var kCVNm_looseptp
Definition: Vars.cxx:40
const Var kCVNcos_looseptp
Definition: Vars.cxx:47
const SystShifts kNoShift
Definition: SystShifts.cxx:21
OStream cout
Definition: OStream.cxx:6
const Var kCVNm_oldpresel
Definition: Vars.cxx:41
const Binning kOptEnBins
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
void cc()
Definition: test_ana.C:28
const Var kCVNcos_oldpresel
Definition: Vars.cxx:48
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
TFile * OutFile
const Var kCVNBestMuonScore([](const caf::SRProxy *sr){float muonScore=-5.0;if(kCVNMuonIdx(sr)< 0.0) return muonScore;if(!sr->vtx.elastic.IsValid) return muonScore;muonScore=sr->vtx.elastic.fuzzyk.png[(unsigned int) kCVNMuonIdx(sr)].cvnpart.muonid;if(sr->vtx.elastic.fuzzyk.png[(unsigned int) kCVNMuonIdx(sr)].len > 500.0) muonScore=1.0;return muonScore;})
: Muon score for best muon prong by CVN score & length
Definition: CVNProngVars.h:27
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