NuMu2019_BasicPIDPlots_FD.C
Go to the documentation of this file.
2 
6 
7 #include "CAFAna/Core/Loaders.h"
9 
15 
16 #include "TH2.h"
17 #include "TFile.h"
18 
19 #include <iostream>
20 
21 using namespace ana;
22 
23 // ---------------------------------------------- //
24 // This has to be ran out of R19-04-17-2019ana.a //
25 // ---------------------------------------------- //
26 
28 
29  std::string polarity = "fhc"; if (!isFHC) polarity = "rhc";
30  std::string data = "mc" ;
31  std::string detector = "fd" ;
32 
33  std::cout << "\n================================= \n"
34  << "\n\t isFHC --> " << isFHC << " --> " << polarity
35  << "\n\t Period --> " << period
36  << "\n\t Far detector isFD --> " << detector
37  << "\n================================= \n"
38  << std::endl;
39 
40  // Make my vector of cuts.
41  std::vector<std::pair<Cut, std::string> > TrueCuts, SelCuts, MyCuts;
42  TrueCuts.clear(); SelCuts.clear(); MyCuts.clear();
43  // Create my true cuts...
44  TrueCuts.push_back( std::make_pair( kNoCut , "_NoTrue" ) );
45  TrueCuts.push_back( std::make_pair( kHasNeutrino , "_TrueNu" ) );
46  TrueCuts.push_back( std::make_pair( kIsNumuCC && kIsNu , "_TrueNuMu" ) );
47  TrueCuts.push_back( std::make_pair( kIsNumuCC && kIsAntiNu, "_TrueAntiNuMu" ) );
48  // Create my selection cuts...
49  SelCuts.push_back( std::make_pair( kNumuQuality&&kNumuContainFD2017, "_QualCont" ) );
50  SelCuts.push_back( std::make_pair( kNumuCutFD2018 , "_FullCut" ) );
51  // Put them together...
52  for (size_t sel=0; sel<SelCuts.size(); ++sel) {
53  for (size_t tr=0; tr<TrueCuts.size(); ++tr) {
54  Cut kThisCut = SelCuts[sel].first && TrueCuts[tr].first;
55  std::string kThisName = SelCuts[sel].second + TrueCuts[tr].second;
56  MyCuts.push_back( std::make_pair( kThisCut, kThisName ) );
57  }
58  }
59  const size_t NCuts = MyCuts.size();
60 
61  // What XSec and PPFX weights am I using?
62  const Var kMyWeight = kXSecCVWgt2018 * kPPFXFluxCVWgt;
63 
64  // Figure out my definition, and then declare my spectrum loader.
65  std::string sTag = ".d";
66  if (!isFHC) sTag = ".e";
67  std::string MyNonSwapDef = "prod_caf_R17-11-14-prod4reco"+sTag+"_fd_genie_nonswap_" +polarity+"_nova_v08_full_v1";
68  std::string MyFluxSwapDef = "prod_caf_R17-11-14-prod4reco"+sTag+"_fd_genie_fluxswap_"+polarity+"_nova_v08_full_v1";
69  std::string MyTauSwapDef = "prod_caf_R17-11-14-prod4reco"+sTag+"_fd_genie_tau_" +polarity+"_nova_v08_full_v1";
70  Loaders *loader = new Loaders();
74  loader->SetSpillCut ( kStandardSpillCuts );
75 
76  // Declare my spectra
77  PredictionNoExtrap *sNuRecoE [NCuts];
78  PredictionNoExtrap *sReMIdScore [NCuts];
79  PredictionNoExtrap *sProngScoremuon[NCuts];
80  PredictionNoExtrap *sCosRejScoreP4 [NCuts];
81  PredictionNoExtrap *sCVNScoremuon [NCuts];
82 
83  // Declare some binnings.
85  const Binning kSimpBins = Binning::Simple(102, -0.01, 1.01 );
86 
87  for (size_t cc=0; cc < NCuts; ++cc) {
88  Cut kThisCut = MyCuts[cc].first;
89 
90  sNuRecoE [cc] = new PredictionNoExtrap( *loader, "Reco Nu E" , kOptEnBins , kCCE , kThisCut, kNoShift, kMyWeight );
91  sReMIdScore [cc] = new PredictionNoExtrap( *loader, "ReMId Score" , kRemidBinning, kRemID , kThisCut, kNoShift, kMyWeight );
92  sProngScoremuon[cc] = new PredictionNoExtrap( *loader, "Prong CVN Muon Score" , kSimpBins , kCVNBestMuonScore, kThisCut, kNoShift, kMyWeight );
93  sCosRejScoreP4 [cc] = new PredictionNoExtrap( *loader, "Prod4 CosRej Score" , kSimpBins , kNumuContPID , kThisCut, kNoShift, kMyWeight );
94  sCVNScoremuon [cc] = new PredictionNoExtrap( *loader, "CVN Muon Score" , kSimpBins , kCVNm , kThisCut, kNoShift, kMyWeight );
95  }
96 
97  // Set my loader going.
98  loader->Go();
99 
100  // Make my Output file
101  std::string OutName = "BasicPIDPlots_2019_"+detector+"_"+data+"_"+polarity+"_"+period+".root";
102  TFile *OutFile = TFile::Open(OutName.c_str(), "RECREATE");
103  for (size_t cc=0; cc < NCuts; ++cc) {
104  std::string ThisCutNa = MyCuts[cc].second;
105 
106  sNuRecoE [cc] -> SaveTo( OutFile, TString("RecoNuE" )+TString(ThisCutNa) ) ;
107  sReMIdScore [cc] -> SaveTo( OutFile, TString("ReMIdScore" )+TString(ThisCutNa) ) ;
108  sProngScoremuon[cc] -> SaveTo( OutFile, TString("ProngCVNMuonScore" )+TString(ThisCutNa) ) ;
109  sCosRejScoreP4 [cc] -> SaveTo( OutFile, TString("Prod4CosRejScore" )+TString(ThisCutNa) ) ;
110  sCVNScoremuon [cc] -> SaveTo( OutFile, TString("CVNMuonScore" )+TString(ThisCutNa) ) ;
111  }
112  OutFile -> Close();
113 }
const Cut kIsNumuCC(CCFlavSel(14, 14))
Select CC .
size_t NCuts
Definition: MakeCutFlow.C:50
Far Detector at Ash River.
Definition: SREnums.h:11
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 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
Collection of SpectrumLoaders for many configurations.
Definition: Loaders.h:23
const Cut kIsAntiNu([](const caf::SRProxy *sr){if(sr->mc.nnu==0) return false;assert(sr->mc.nnu==1);return sr->mc.nu[0].pdg< 0;})
Is this truly an antineutrino?
Definition: TruthCuts.h:53
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
Definition: DataMCLoad.C:336
const Cut kIsNu([](const caf::SRProxy *sr){if(sr->mc.nnu==0) return false;assert(sr->mc.nnu==1);return sr->mc.nu[0].pdg > 0;})
Definition: TruthCuts.h:54
void Go()
Call Go() on all the loaders.
Definition: Loaders.cxx:162
const XML_Char const XML_Char * data
Definition: expat.h:268
void SetSpillCut(const SpillCut &cut)
Definition: Loaders.cxx:121
const Cut kNumuContainFD2017
Definition: NumuCuts2017.h:21
const Var kRemID
PID
Definition: Vars.cxx:81
const Var kCCE
Definition: NumuVars.h:21
const Binning kSimpBins
loader
Definition: demo0.py:10
c1 Close()
static bool isFHC
const SystShifts kNoShift
Definition: SystShifts.cxx:22
OStream cout
Definition: OStream.cxx:6
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)
Definition: TruthCuts.h:61
const Binning kOptEnBins
void NuMu2019_BasicPIDPlots_FD(bool isFHC, std::string period="full")
void cc()
Definition: test_ana.C:28
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 Cut kNumuCutFD2018
Definition: NumuCuts2018.h:39
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.
const Cut kNumuQuality
Definition: NumuCuts.h:18
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
void SetLoaderPath(const std::string &path, caf::Det_t det, DataMC datamc, DataSource src=kBeam, SwappingConfig swap=kNonSwap)
Configure loader via wildcard path.
Definition: Loaders.cxx:25
const Var kCVNm
PID
Definition: Vars.cxx:39
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:107
const Cut kNoCut
The simplest possible cut: pass everything, used as a default.
Definition: Cut.h:109
enum BeamMode string