NumuCosmic.C
Go to the documentation of this file.
1 #include "CAFAna/Core/Spectrum.h"
3 
4 #include "CAFAna/Cuts/Cuts.h"
9 
11 #include "CAFAna/Vars/Vars.h"
15 #include "CAFAna/Vars/XsecTunes.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 NumuCosmic(bool isFHC )
30 {
31  // What do my arguments mean?
32  std::string beam = "rhc";
33  if (isFHC) beam = "fhc";
34 
35  // Set my axis.
37 
38  // Set the default cuts to the combined quantile cuts for the Full FOM
39  Cut cut_numufd = kNumu2020;
40 
41  // Set the string for the cosmic definitions.
42  std::string dataset = "prod_caf_R19-11-18-prod5reco.i_fd_cosmic_"+beam+"_full_v1_goodruns";
43  SpectrumLoader loaders(dataset);
45 
46  //std::string infile_quant = (std::string)std::getenv("NUMUDATA_DIR")+"/lib/ana2020/Quantiles/quantiles_"+beam+"_full_numu2020.root";
47  std::string infile_quant = "/cvmfs/nova.opensciencegrid.org/externals/numudata/v00.03/NULL/lib/ana2020/Quantiles/quantiles_"+beam+"_full_numu2020.root";
48  TFile* infile = new TFile(infile_quant.c_str());
49 
50  TH2* FDSpec2D = (TH2*)infile->FindObjectAny("FDSpec2D_LoosePTP");
51  std::vector<Cut> HadEFracQuantCuts = QuantileCutsFromTH2(FDSpec2D, axis_numu, kHadEFracAxis, 4);
52  infile->Close();
53  delete infile;
54 
55  // Make a vector of spectra.
56  std::vector<Spectrum*> pred_cosmic_numu;
57 
58  // First, push back a combined quantile one.
59  pred_cosmic_numu.push_back(new Spectrum(loaders, axis_numu, cut_numufd && kInCosmicTimingWindow, kNoShift));
60  // Then, loop through my Quantile cuts.
61  for(int quant=0; quant<4; ++quant) {
62 
63  Cut ThisCut = cut_numufd && kInCosmicTimingWindow && HadEFracQuantCuts[quant];
64 
65  pred_cosmic_numu.push_back(new Spectrum(loaders, axis_numu, ThisCut, kNoShift));
66  }
67 
68  loaders.Go();
69 
70  TFile* outFile = new TFile(("fd_numu_cosmics_"+beam+".root").c_str(),"RECREATE");
71  outFile->cd();
72  for(int quant=0; quant<5; quant++){
73  pred_cosmic_numu[quant]->SaveTo(outFile, Form("numu_cos_q%d", quant));
74  }
75  outFile->Close();
76 }
77 
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)
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
virtual void Go() override
Load all the registered spectra.
void NumuCosmic(bool isFHC)
Definition: NumuCosmic.C:29
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
static bool isFHC
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 SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
enum BeamMode string