get_cosmic_spectra.C
Go to the documentation of this file.
2 #include "CAFAna/Core/Spectrum.h"
6 
7 using namespace ana;
8 
9 #include "TFile.h"
10 #include <iostream>
11 
13 {
14 
15 
16  std::string fnameData = "prod_restrictedcaf_R17-03-01-prod3reco.k_fd_numi_fhc_full_v1_goodruns";
17 
18  SpectrumLoader loaderData(fnameData);
19  loaderData.SetSpillCut(kStandardSpillCuts);
20 
22  //TH1 will be scaled to spill, but the livetime will still be high. Use with care
23  Spectrum data_cosmic_scaled(loaderData, kNue2017Axis, kNue2017FDAllSamples&&kInTimingSideband, kNoShift, kTimingSidebandWeight);
24 
25  loaderData.Go();
26 
27  TFile* fout = new TFile("cosmic_prediction.root", "RECREATE");
28  data_cosmic.SaveTo(fout, "cosmic_spect");
29  data_cosmic_scaled.SaveTo(fout, "cosmic_spect_weighted");
30 
31  delete fout;
32 
33 // in order to get spectra from *.root file do:
34 
35 /* TFile * file = new TFile (predFileName.c_str(), "READ");
36  auto data_cosmic = Spectrum::LoadFrom(file, "cosmic_spect");
37  TH1* cos = data_cosmic->ToTH1(data_cosmic->Livetime(), kGray+1, kSolid, ana::EExposureType::kLivetime);
38  cout<<" bkg prediction: "<<cos->Integral()<<" with "<<data_cosmic->Livetime()<<" s livetime "<<endl;*/
39 }
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
void SetSpillCut(const SpillCut &cut)
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:39
const Cut kInTimingSideband([](const caf::SRProxy *sr){if(sr->spill.run > util::kLastBadTimingRun) return(kInTimingSideband_before(sr)|| kInTimingSideband_after(sr));else return(kInTimingSideband_before(sr)|| kInTimingSideband_afterA(sr)|| kInTimingSideband_afterB(sr));}, [](const caf::SRSpillProxy *spill){if(spill->run > util::kLastBadTimingRun) return(kInTimingSideband_before.Livetime(spill)+ kInTimingSideband_after.Livetime(spill));else return(kInTimingSideband_before.Livetime(spill)+ kInTimingSideband_afterA.Livetime(spill)+ kInTimingSideband_afterB.Livetime(spill));}, [](const caf::SRSpillProxy *spill){return 0;})
Definition: TimingCuts.h:12
virtual void Go() override
Load all the registered spectra.
void SaveTo(TDirectory *dir, const std::string &name) const
Definition: Spectrum.cxx:534
void get_cosmic_spectra()
const HistAxis kNue2017Axis("NuE Energy / Analysis Bin", kNue2017Binning, kNue2017AnaBin)
Definition: NueCuts2017.h:313
const SystShifts kNoShift
Definition: SystShifts.cxx:22
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
const Cut kNue2017FDAllSamples
Our FD selection including all samples, for making predictions, etc.
Definition: NueCuts2017.h:155
enum BeamMode string