CosmicPred.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 CosmicPred(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_sumdecaf_R19-11-18-prod5reco.i_fd_cosmic_"+beam+"_full_v1_goodruns_"+ana+"2020";
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(("fd_cosmic_pred_"+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 && kInCosmicTimingWindow, kNoShift));
53  for(auto thisCut : HadEFracQuantCuts){
54  pred_cosmic_numu.push_back(new Spectrum(loaders, axis_numu, cut_numufd && kInCosmicTimingWindow && 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_cos_q%d", quant));
62  }
63  }
64  if (ana == "nue"){
65  Spectrum* pred_cosmic_nue = new Spectrum (loaders, axis_nue_merged, cut_nuefd && kInCosmicTimingWindow, kNoShift);
66 
67  loaders.Go();
68 
69  outFile->cd();
70  pred_cosmic_nue->SaveTo(outFile, "nue_cos");
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
std::vector< double > Spectrum
Definition: Constants.h:746
void SetSpillCut(const SpillCut &cut)
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:39
const Cut cut_numufd
const Cut kInCosmicTimingWindow
Is the event far from the start and ends of the spill ? For FD cosmic selection.
Definition: TimingCuts.cxx:165
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:534
const Cut kNumu2020FD
Definition: NumuCuts2020.h:59
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
void CosmicPred(string beam="fhc", string ana="numu")
Definition: CosmicPred.C:29
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 kNue2020FDAllSamples
Definition: NueCuts2020.h:84
enum BeamMode string