make_pid.C
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////
2 //
3 // Script to make data/mc comparisons for prong CVN with
4 // different cuts.
5 //
6 //////////////////////////////////////////////////////////
7 
8 #include "TCanvas.h"
9 #include "TH1.h"
10 #include "TF1.h"
11 #include "TFile.h"
12 #include "TLegend.h"
13 #include "TLegendEntry.h"
14 #include "TArrayD.h"
15 #include "TAxis.h"
16 #include "TLatex.h"
17 
18 #include "CAFAna/Core/Cut.h"
19 #include "CAFAna/Cuts/NueCutsFirstAna.h"
20 #include "CAFAna/Analysis/Plots.h"
21 #include "CAFAna/Analysis/Style.h"
23 #include "CAFAna/Core/Spectrum.h"
24 #include "CAFAna/Cuts/SpillCuts.h"
25 #include "CAFAna/Vars/Vars.h"
28 
30 
32 
33 using namespace ana;
34 
35 void make_pid(bool isFHC = 1){
36  const std::string fData = isFHC ?
37  "prod_decaf_R17-03-01-prod3reco.d_nd_numi_fhc_full_nue_or_numu_or_nus_contain_v1_goodruns" :
38  "prod_decaf_R17-03-01-prod3reco.l_nd_numi_rhc_full_nue_or_numu_or_nus_contain_v1_goodruns" ;
39 
40  const std::string fMC = isFHC ?
41  "prod_decaf_R17-03-01-prod3reco.d_nd_genie_nonswap_fhc_nova_v08_full_nue_or_numu_or_nus_contain_v1" :
42  "prod_decaf_R17-03-01-prod3reco.l_nd_genie_nonswap_rhc_nova_v08_full_nue_or_numu_or_nus_contain_v1" ;
43 
45  SpectrumLoaderBase* loaderMC = new SpectrumLoader(fMC);
46 
47  std::cout << "MC: " << fMC << std::endl;
48  std::cout << "Data: " << fData << std::endl;
49 
51  loaderMC->SetSpillCut(kStandardDQCuts);
52 
53  // One spectrum per selection, per Var (see .h)
54 
55  Spectrum* spect[kNSels][kNPlots];
56 
57  for(unsigned int i = 0;i < kNSels;++i){
58  for(unsigned int j = 0;j < kNPlots;++j){
59  if(j < 5)
60  spect[i][j] = new Spectrum(plots[j].label,plots[j].bins,
61  *loader,plots[j].var,sels[i].cut);
62  else
63  spect[i][j] = new Spectrum(plots[j].label,plots[j].bins,
64  *loaderMC,plots[j].var,sels[i].cut,
66  }
67  }
68 
69  // Go, loaders, go!
70 
71  loader->Go();
72  loaderMC->Go();
73 
74 
75  // Save output
76 
77  std::string cStr = isFHC ? "FHC" : "RHC";
78  TFile fout(("make_pid_output_"+cStr+".root").c_str(),"RECREATE");
79 
80  for(unsigned int i = 0;i < kNSels;++i){
81  for(unsigned int j = 0;j < kNPlots;++j){
82  spect[i][j]->SaveTo(&fout, sels[i].suffix+"_"+plots[j].suffix);
83  }
84  }
85 
86 
87 }
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const Var kPPFXFluxCVWgt
Definition: PPFXWeights.h:16
const unsigned int kNSels
void SetSpillCut(const SpillCut &cut)
const unsigned int kNPlots
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
const char * label
const SpillCut kTightBeamQualityCuts([](const caf::SRSpillProxy *s){if(s->ismc) return true; if(s->trigger==2) return true;if(s->spilltimesec==0 &&s->deltaspilltimensec==0 &&s->widthx==0) return bool(s->isgoodspill);if(std::abs(s->deltaspilltimensec) > 0.5e9) return false;if(s->spillpot< 2e12) return false;if(s->hornI< -202|| s->hornI >-198) return false;if(s->posx< -2.00|| s->posx >+2.00) return false;if(s->posy< -2.00|| s->posy >+2.00) return false;return kBeamWidthCut(s);})
Definition: SpillCuts.h:10
virtual void Go()=0
Load all the registered spectra.
const Cut sels[kNumSels]
Definition: vars.h:44
const std::vector< Plot > plots
const SpillCut kStandardDQCuts([](const caf::SRSpillProxy *spill){if(spill->dcmedgematchfrac==0 &&spill->fracdcm3hits==0 &&spill->nmissingdcmslg==0) return bool(spill->isgoodspill); if(spill->det==caf::kNEARDET && (spill->fracdcm3hits > 0.45|| spill->nmissingdcms > 0)) return false; if(spill->eventincomplete) return false; if(spill->det==caf::kFARDET && spill->nmissingdcmslg > 0) return false; if(spill->det==caf::kFARDET && !spill->ismc && spill->dcmedgematchfrac<=0.2) return false;return true;})
Cut out events with a noisy detector or with parts missing.
Definition: SpillCuts.h:16
void make_pid(bool isFHC=1)
Definition: make_pid.C:35
void SaveTo(TDirectory *dir, const std::string &name) const
Definition: Spectrum.cxx:506
const double j
Definition: BetheBloch.cxx:29
loader
Definition: demo0.py:10
std::vector< float > Spectrum
Definition: Constants.h:759
static bool isFHC
const SystShifts kNoShift
Definition: SystShifts.cxx:22
OStream cout
Definition: OStream.cxx:6
Base class for the various types of spectrum loader.
const Binning bins
Definition: NumuCC_CPiBin.h:8
const Cut cut
Definition: exporter_fd.C:30
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
const Var kXSecCVWgt2017
Definition: XsecTunes.h:36
enum BeamMode string