get_spectra_2dplots.C
Go to the documentation of this file.
2 #include "CAFAna/Core/Loaders.h"
3 #include "CAFAna/Core/Spectrum.h"
10 #include "CAFAna/Vars/Vars.h"
11 
12 #include "TFile.h"
13 
14 
15 using namespace ana;
16 
17 void get_spectra_2dplots(TString beam = "fhc", TString suffix = "cosmics")
18 {
19 
20  ////////////////////////////////////////////////////////////////////////////////
21  // Variables and cuts
22  ////////////////////////////////////////////////////////////////////////////////
23 
24  const Cut core_no_pid = kNue2020CorePresel && kNue2020FDNearestSlice;
26 
27  const HistAxis axis_core ("CVN Score", Binning::Simple(50, 0.75, 1.0), kCVNe_looseptp,
28  "Cosmic BDT", Binning::Simple(50, 0.3, 0.8), kCosPIDCoreBDT);
29  const HistAxis axis_peri ("CVN Score", Binning::Simple(50, 0.9, 1.0), kCVNe_looseptp,
30  "Cosmic BDT", Binning::Simple(50, 0.3, 0.8), kCosPIDPeriBDT);
31 
32  struct SpectDef{
33  TString name;
34  const HistAxis axis;
35  const Cut cut;
36  };
37 
38  std::vector <SpectDef> defs;
39  defs.push_back({"core_no_pid", axis_core, core_no_pid});
40  defs.push_back({"peri_no_pid", axis_peri, peri_no_pid});
41 
42  ////////////////////////////////////////////////////////////////////////////////
43  // Loaders and spectra for cosmic trigger
44  ////////////////////////////////////////////////////////////////////////////////
45  if(suffix.Contains("cosmics")){
46  std::string ldr;
47  if(beam=="fhc") ldr = "prod_sumdecaf_R19-11-18-prod5reco.i_fd_cosmic_fhc_full_v1_goodruns_nue2020";
48  if(beam=="rhc") ldr = "prod_sumdecaf_R19-11-18-prod5reco.i_fd_cosmic_rhc_full_v1_goodruns_nue2020";
51 
52  std::vector <Spectrum*> spects;
53  for(auto const & def:defs){
54  spects.push_back(new Spectrum(loader,def.axis,def.cut && kInCosmicTimingWindow));
55  }
56  loader.Go();
57 
58  TString filename = "spectra_"+ beam + "_" + suffix + ".root";
59  auto file = new TFile(filename,"recreate");
60  for(uint i =0; i < spects.size(); ++i){
61  spects[i]->SaveTo(file, "cosm_" + defs[i].name);
62  }
63  file->Close();
64  std::cout << "Saved to " << filename << std::endl;
65  return;
66  }//end cosmics
67 
68  ////////////////////////////////////////////////////////////////////////////////
69  // Loaders and predictions for MC
70  ////////////////////////////////////////////////////////////////////////////////
71  if(suffix.Contains("prediction")){
73  std::string ldrFDNonSwap, ldrFDFlxSwap, ldrFDTauSwap;
74  if(beam=="fhc"){
75  ldrFDNonSwap = "prod_sumdecaf_R19-11-18-prod5reco.f_fd_genie_N1810j0211a_nonswap_fhc_nova_v08_full_v1_nue2020";
76  ldrFDFlxSwap = "prod_sumdecaf_R19-11-18-prod5reco.f_fd_genie_N1810j0211a_fluxswap_fhc_nova_v08_full_v1_nue2020";
77  ldrFDTauSwap = "prod_sumdecaf_R19-11-18-prod5reco.f_fd_genie_N1810j0211a_tau_fhc_nova_v08_full_v1_nue2020";
78  }
79  if(beam=="rhc"){
80  ldrFDNonSwap = "prod_sumdecaf_R19-11-18-prod5reco.f_fd_genie_N1810j0211a_nonswap_rhc_nova_v08_full_v1_nue2020";
81  ldrFDFlxSwap = "prod_sumdecaf_R19-11-18-prod5reco.f_fd_genie_N1810j0211a_fluxswap_rhc_nova_v08_full_v1_nue2020";
82  ldrFDTauSwap = "prod_sumdecaf_R19-11-18-prod5reco.f_fd_genie_N1810j0211a_tau_rhc_nova_v08_full_v1_nue2020";
83  }
84 
89 
90  std::vector <IPrediction *> preds;
91  for(auto const & def:defs){
92  preds.push_back(new PredictionNoExtrap(loaders,def.axis,def.cut,kNoShift,
94  }
95  loaders.Go();
96 
97  TString filename = "preds_"+ beam + "_" + suffix + ".root";
98  auto file = new TFile(filename,"recreate");
99  for(uint i =0; i < preds.size(); ++i){
100  preds[i]->SaveTo(file, "pred_" + defs[i].name);
101  }
102  file->Close();
103  std::cout << "Saved to " << filename << std::endl;
104  return;
105  }//end predictions
106  else{
107  return;
108  }
109 }
void get_spectra_2dplots(TString beam="fhc", TString suffix="cosmics")
const XML_Char * name
Definition: expat.h:151
Far Detector at Ash River.
Definition: SREnums.h:11
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const Var kPPFXFluxCVWgt
Definition: PPFXWeights.h:16
Collection of SpectrumLoaders for many configurations.
Definition: Loaders.h:23
const Cut kNue2020FDNearestSlice([](const caf::SRProxy *sr){const double hibin=kIsRHC(sr)?kNue2020CVNRHCHighEdge:kNue2020CVNFHCHighEdge;const double topcut=(kCVNe_looseptp(sr) >=hibin)?50:400;return(fabs(sr->slc.closestslicetime) >=100|| sr->slc.closestsliceminfromtop >=topcut|| sr->slc.closestslicemindist >=500);})
Definition: NueCuts2020.h:24
string filename
Definition: shutoffs.py:106
void SetSpillCut(const SpillCut &cut)
const Cut kNue2020CorePresel
Definition: NueCuts2020.h:44
void Go()
Call Go() on all the loaders.
Definition: Loaders.cxx:162
const Cut kInCosmicTimingWindow
Is the event far from the start and ends of the spill ? For FD cosmic selection.
Definition: TimingCuts.cxx:165
void SetSpillCut(const SpillCut &cut)
Definition: Loaders.cxx:121
const Cut kNue2020PeripheralBasicEventCut
Definition: NueCuts2020.h:69
virtual void Go() override
Load all the registered spectra.
const HistDef defs[kNumVars]
Definition: vars.h:15
loader
Definition: demo0.py:10
std::vector< float > Spectrum
Definition: Constants.h:610
const Cut kNue2020FD
Definition: NueCuts2020.h:65
const SystShifts kNoShift
Definition: SystShifts.cxx:21
OStream cout
Definition: OStream.cxx:6
const Cut cut
Definition: exporter_fd.C:30
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
std::vector< Loaders * > loaders
Definition: syst_header.h:386
TFile * file
Definition: cellShifts.C:17
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
Prediction that just uses FD MC, with no extrapolation.
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
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:107
const Var kCVNe_looseptp
Definition: Vars.cxx:36
const Var kCosPIDCoreBDT
2020 nue cosmic rejection BDT variable - core
Definition: NueVars.cxx:112
const Var kCosPIDPeriBDT
2020 nue cosmic rejection BDT variable - peripheral
Definition: NueVars.cxx:113
const Var kXSecCVWgt2020
Definition: XsecTunes.h:106
enum BeamMode string
unsigned int uint