make_DataMCComp_numu.C
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This makes the noextrap predictions of a bunch of interesting numu variables.
3 // The map of variables are defined at the bottom of the header.
4 // Set the period arg to 0 to use the full datasets
5 // Plots are made using the associated plotting macro.
6 //
7 // Andrew Sutton - ats2mk@virginia.edu
8 //------------------------------------------------------------------------------
9 
10 #pragma once
11 
12 #include "DataMCComp_header.h"
13 
15 {
16  // Input options
18  if (horn == "fhc") flux = Loaders::kFHC;
19  else if (horn == "rhc") flux = Loaders::kRHC;
20  else {
21  std::cout << "\n\n********** No valid horn **********\n" << std::endl;
22  std::abort();
23  }
24 
25  std::string sPeriod = "period" + std::to_string(period);
26  std::string sRange = "period" + std::to_string(period);
27  Cut kPeriodCut = kNoCut;
28  if (period == 0) {
29  sPeriod = "full";
30  sRange = "full";
31  }
32  if (period > 9) {
33  std::cout << "\n\n********** No valid period **********\n" << std::endl;
34  std::abort();
35  }
36 
37  // Initial setup
38  Loaders *mcLoader = new Prod5NomLoaders(ECAFType::kNumuConcat, flux, sPeriod);
39  SpectrumLoader csLoader("prod_sumdecaf_R19-11-18-prod5reco.i_fd_cosmic_" + horn + "_" + sPeriod + "_v1_goodruns_numu2020");
40  SpectrumLoader dtLoader("prod_sumrestricteddecaf_R19-11-18-prod5reco.combi_opt2_fd_numi_" + horn + "_" + sRange +"_v1_numu2020_fddatav2");
44 
45  Cut myCut = kNumu2020FD && kPeriodCut;
47 
48  // Get Quants
49  std::string infile_quant = "/cvmfs/nova.opensciencegrid.org/externals/numudata/v00.05/NULL/lib/ana2020/Quantiles/quantiles_" + horn + "_full_numu2020.root";
50  TFile* infile = new TFile(infile_quant.c_str());
51  TH2* FDSpec2D = (TH2*)infile->FindObjectAny("FDSpec2D");
52  std::vector<Cut> quantCuts = QuantileCutsFromTH2(FDSpec2D, kNumuCCOptimisedAxis, kHadEFracAxis, 4, false);
53  quantCuts.push_back(kNoCut);
54  infile->Close();
55  delete infile;
56  const std::map< std::string, Cut> quantiles =
57  {
58  {"Quant1" , quantCuts[0]},
59  {"Quant2" , quantCuts[1]},
60  {"Quant3" , quantCuts[2]},
61  {"Quant4" , quantCuts[3]},
62  {"AllQuants", quantCuts[4]}
63  };
64 
65  // Make the preds
66  std::map< std::string, PredictionNoExtrap* > mcPreds;
67  std::map< std::string, Spectrum* > csSpecs;
68  std::map< std::string, Spectrum* > dtSpecs;
69  for (auto var : vars) {
70 
71  for (auto quant : quantiles) {
72  mcPreds["mcPred_" + var.first.first + "_" + quant.first] =
73  new PredictionNoExtrap(*mcLoader, var.first.second, var.second.bin,
74  var.second.var, myCut && quant.second,
75  kNoShift, mcWei);
76 
77  csSpecs["csSpec_" + var.first.first + "_" + quant.first] =
78  new Spectrum(var.first.second, var.second.bin, csLoader,
79  var.second.var, myCut && quant.second && kInCosmicTimingWindow,
81 
82  dtSpecs["dtSpec_" + var.first.first + "_" + quant.first] =
83  new Spectrum(var.first.second, var.second.bin, dtLoader,
84  var.second.var, myCut && quant.second && kInBeamSpill,
86 
87  }// end quant loop
88 
89  }
90 
91  // Liftoff
92  mcLoader->Go();
93  csLoader.Go();
94  dtLoader.Go();
95 
96  TFile *outfile = new TFile(("numuDataMC_" + horn + "_" + sRange + ".root").c_str(), "RECREATE");
97 
98 
99  for (auto pred : mcPreds)
100  pred.second->SaveTo(outfile, pred.first.c_str());
101 
102  for (auto spec : csSpecs)
103  spec.second->SaveTo(outfile, spec.first.c_str());
104 
105  for (auto spec : dtSpecs)
106  spec.second->SaveTo(outfile, spec.first.c_str());
107 
108 }
const SpillCut kStandardSpillCuts_FD_Prod4MotivatedDQ
Definition: SpillCuts.h:69
std::vector< double > quantiles(TH1D *h)
Definition: absCal.cxx:528
const Var kPPFXFluxCVWgt
Definition: PPFXWeights.h:16
Collection of SpectrumLoaders for many configurations.
Definition: Loaders.h:23
const HistAxis kHadEFracAxis("E_{had.} / E_{#nu}", Binning::Simple(200, 0, 1), kHadEFrac)
HistAxis that implements Hadronic Energy fraction binning used by L.Vinton to derive Hadronic Energy ...
Definition: HistAxes.h:30
void SetSpillCut(const SpillCut &cut)
Loaders::FluxType flux
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
string infile
For nominal spectra and reweighting systs (xsec/flux)
Definition: Prod5Loaders.h:101
virtual void Go() override
Load all the registered spectra.
const std::map< std::pair< std::string, std::string >, Variable > vars
const Cut kNumu2020FD
Definition: NumuCuts2020.h:59
std::vector< float > Spectrum
Definition: Constants.h:610
const HistAxis kNumuCCOptimisedAxis("Reconstructed Neutrino Energy (GeV)", kNumuCCEOptimisedBinning, kCCE)
HistAxis that implements optimised numuCCE from L. Vinton. See docdb 16332. This was close to &#39;custC&#39;...
Definition: HistAxes.h:24
const SystShifts kNoShift
Definition: SystShifts.cxx:21
OStream cout
Definition: OStream.cxx:6
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
std::vector< Cut > QuantileCutsFromTH2(TH2 *quantileHist, const HistAxis &independentAxis, const HistAxis &quantileAxis, const unsigned int &numQuantiles, const bool verbose)
: Do the same as the QuantileCuts function but taking in the TH2 instead of making it...
const Cut kInBeamSpill([](const caf::SRProxy *sr){if(sr->spill.run > util::kLastBadTimingRun) return kInBeamSpill_main(sr);else return kInBeamSpill_main(sr)||kInBeamSpill_shifted(sr);}, [](const caf::SRSpillProxy *spill){if(spill->run > util::kLastBadTimingRun) return kInBeamSpill_main.Livetime(spill);else return kInBeamSpill_main.Livetime(spill)+kInBeamSpill_shifted.Livetime(spill);}, [](const caf::SRSpillProxy *spill) -> double{return spill->spillpot;})
Does the event fall inside the window we call the beam spill?
Definition: TimingCuts.h:8
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
void make_DataMCComp_numu(std::string horn, uint period)
Prediction that just uses FD MC, with no extrapolation.
std::string to_string(ModuleType mt)
Definition: ModuleType.h:32
const Var kUnweighted
The simplest possible Var, always 1. Used as a default weight.
Definition: Var.h:96
FILE * outfile
Definition: dump_event.C:13
const Var kXSecCVWgt2020
Definition: XsecTunes.h:106
enum BeamMode string
unsigned int uint