get_numi_data_histogram.C
Go to the documentation of this file.
1 #include "CAFAna/Core/Spectrum.h"
3 
4 #include "CAFAna/Cuts/Cuts.h"
10 
11 #include "CAFAna/Vars/Vars.h"
16 
20 
21 #include "CAFAna/Core/Loaders.h"
23 #include "TFile.h"
24 
25 #include <iostream>
26 #include <cmath>
27 using namespace ana;
28 
29 void get_numi_data_histogram(string beam = "fhc", string ana = "numu")
30 {
31 
33  auto cut_numufd = kNumu2020FD;
34  auto axis_nue_merged = kNue2020AxisMergedPeripheral;
35  auto cut_nuefd = kNue2020FDAllSamples;
36 
37  std::string dataset = "prod_sumrestricteddecaf_R19-11-18-prod5reco.r_fd_numi_"+beam+"_full_v1_restrictedbox_goodruns_"+ana+"2020_fddatav2";
38 
39  SpectrumLoader loaders(dataset);
41 
42  std::string infile_quant = "/cvmfs/nova.opensciencegrid.org/externals/numudata/v00.05/NULL/lib/ana2020/Quantiles/quantiles_"+beam+"_full_numu2020.root";
43  TFile* infile = new TFile(infile_quant.c_str());
44  TH2* FDSpec2D = (TH2*)infile->FindObjectAny("FDSpec2D");
45  std::vector<Cut> HadEFracQuantCuts = QuantileCutsFromTH2(FDSpec2D, axis_numu, kHadEFracAxis, 4);
46  infile->Close();
47  delete infile;
48 
49  TFile* outFile = new TFile(("data_2020_"+ana+"_"+beam+".root").c_str(),"RECREATE");
50  if (ana == "numu"){
51  std::vector<Spectrum*> pred_cosmic_numu;
52  pred_cosmic_numu.push_back(new Spectrum(loaders, axis_numu, cut_numufd && kInBeamSpill, kNoShift));
53  for(auto thisCut : HadEFracQuantCuts){
54  pred_cosmic_numu.push_back(new Spectrum(loaders, axis_numu, cut_numufd && kInBeamSpill && thisCut));
55  }
56 
57  loaders.Go();
58 
59  outFile->cd();
60  for(int quant=0; quant<5; quant++){
61  pred_cosmic_numu[quant]->SaveTo(outFile, Form("numu_data_q%d", quant));
62  }
63  }
64  if (ana == "nue"){
65  Spectrum* pred_cosmic_nue = new Spectrum (loaders, axis_nue_merged, cut_nuefd && kInBeamSpill, kNoShift);
66 
67  loaders.Go();
68 
69  outFile->cd();
70  pred_cosmic_nue->SaveTo(outFile, "nue_data");
71  }
72  outFile->Close();
73 }
74 
const SpillCut kStandardSpillCuts_FD_Prod4MotivatedDQ
Definition: SpillCuts.h:69
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
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)
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
void get_numi_data_histogram(string beam="fhc", string ana="numu")
const Cut cut_numufd
TFile * outFile
Definition: PlotXSec.C:135
string infile
const HistAxis kNue2020AxisMergedPeripheral("NuE Energy / Analysis Bin", kNue2020BinningMergedPeripheral, kNue2020AnaBinMergedPeripheral)
Definition: NueCuts2020.h:200
virtual void Go() override
Load all the registered spectra.
void SaveTo(TDirectory *dir, const std::string &name) const
Definition: Spectrum.cxx:506
const Cut kNumu2020FD
Definition: NumuCuts2020.h:59
std::vector< float > Spectrum
Definition: Constants.h:759
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:22
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
const HistAxis axis_numu
std::vector< Loaders * > loaders
Definition: syst_header.h:386
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 Cut kNue2020FDAllSamples
Definition: NueCuts2020.h:84
enum BeamMode string