Go to the documentation of this file.
1 // Macro to plot FD Data/MC spectra with systematic error band
5 #include "CAFAna/Core/Loaders.h"
6 #include "CAFAna/Core/Spectrum.h"
7 #include "CAFAna/Cuts/Cuts.h"
8 #include "NuXAna/Cuts/NusCuts.h"
13 #include "NuXAna/Systs/NusSysts.h"
14 #include "CAFAna/Systs/Systs.h"
15 #include "CAFAna/Vars/HistAxes.h"
20 #include "TFile.h"
22 #include "NuXAna/Vars/HistAxes.h"
24 #include <iostream>
25 #include <string>
26 #include <vector>
28 using namespace ana;
31  const std::vector<const ISyst*>& systs,
33  TDirectory* out, FILE* text, strings strs,
34  Spectrum* sData);
36 void PlotSysts(const Spectrum& nom,
37  const std::vector<Spectrum>& upShifts,
38  const std::vector<Spectrum>& downShifts,
39  TDirectory* out, FILE* text, strings strs,
40  Spectrum* sData);
43  const ISyst* syst,
45  TDirectory* out, strings strs);
47 void PlotSysts(Spectrum& nom, Spectrum& sp1, Spectrum& sm1,
48  TDirectory* out, strings strs, bool split = true);
50 TH1* GetHist(strings strs, int sigma);
53 {
54  TH1::AddDirectory(0);
56  Loaders loaders123b;
63  Loaders loaders3c3d;
70  loaders123b.SetSpillCut(kStandardSpillCuts);
71  loaders3c3d.SetSpillCut(kStandardSpillCuts);
74  loaderFDdata.SetSpillCut(kStandardSpillCuts);
76  // Create vector of systematics
77  std::vector<const ISyst*> systs = getAllNusSysts();
82  PredictionInterp pred123b(systs, calc, gen, loaders123b);
83  PredictionInterp pred3c3d(systs, calc, gen, loaders3c3d);
85  Spectrum* sCosmic = new Spectrum(loaderFDdata, kNCAxis,
87  kNoShift, kTimingSidebandWeight);
89  Spectrum* sCosOOT = new Spectrum(loaderFDdata, kNCAxis,
92  Spectrum* sData = new Spectrum(loaderFDdata, kNCAxis, kInBeamSpill && kNusFD);
94  loaders123b.Go();
95  loaders3c3d.Go();
96  loaderFDdata.Go();
98  const double pot_p1p2e3b =
102  const double pot_e3ce3d = kSecondAnaEpoch3cPOT + kSecondAnaEpoch3dPOT;
104  PredictionCombinePeriods pred({std::make_pair(&pred123b, pot_p1p2e3b),
105  std::make_pair(&pred3c3d, pot_e3ce3d)});
108  TFile* rootF = new TFile("Ana01_FDDataMCSystBandLoad.root", "RECREATE");
110  TDirectory* tmp = gDirectory;
111  TDirectory* saveDir = gDirectory;
113  // Save nominal spectra
114  saveDir = rootF->mkdir("sCosmic");
115  sCosmic->SaveTo(saveDir);
116  saveDir = rootF->mkdir("sCosOOT");
117  sCosOOT->SaveTo(saveDir);
118  saveDir = rootF->mkdir("sData");
119  sData->SaveTo(saveDir);
120  saveDir = rootF->mkdir("pred123b");
121  pred123b.SaveTo(saveDir);
122  saveDir = rootF->mkdir("pred3c3d");
123  pred3c3d.SaveTo(saveDir);
124  saveDir = rootF->mkdir("pred");
125  pred.SaveTo(saveDir);
127  rootF->Close();
128 }
Near Detector underground.
Definition: SREnums.h:10
void split(double tt, double *fr)
Implements systematic errors by interpolation between shifted templates.
Far Detector at Ash River.
Definition: SREnums.h:11
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
std::vector< SystGroupDef > systs
Definition: syst_header.h:385
void PlotSysts(IPrediction *pred, const std::vector< const ISyst * > &systs, osc::IOscCalc *calc, TDirectory *out, FILE *text, strings strs, Spectrum *sData)
const double kSecondAnaPeriod2POT
Definition: Exposures.h:74
const Cut kNusFD
Definition: NusCuts.h:46
Collection of SpectrumLoaders for many configurations.
Definition: Loaders.h:23
General interface to oscillation calculators.
Definition: StanTypedefs.h:22
const double kSecondAnaEpoch3dPOT
Definition: Exposures.h:77
const double kSecondAnaEpoch3bPOT
Definition: Exposures.h:75
Adapt the PMNS_Sterile calculator to standard interface.
const std::vector< std::string > fFDMC_non
Float_t tmp
Definition: plot.C:36
void SetSpillCut(const SpillCut &cut)
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
Definition: DataMCLoad.C:336
const double kSecondAnaPeriod1POT
Definition: Exposures.h:73
Generates extrapolated NC predictions using ProportionalDecomp.
void FDDataMCSystBandLoad()
osc::OscCalcDumb calc
Encapsulate code to systematically shift a caf::SRProxy.
Definition: ISyst.h:14
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
void Go()
Call Go() on all the loaders.
Definition: Loaders.cxx:162
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
const std::string fnamenear_concat
void SetSpillCut(const SpillCut &cut)
Definition: Loaders.cxx:121
virtual void SaveTo(TDirectory *dir, const std::string &name) const override
osc::OscCalcSterile * DefaultSterileCalc(int nflavors)
Create a sterile calculator with default assumptions for all parameters.
Definition: Calcs.cxx:97
std::vector< const ISyst * > getAllNusSysts()
Get a vector of all the nus group systs.
Definition: NusSysts.cxx:202
const std::string fnameneardata_concat
const std::vector< std::string > fFDMC_swp
const std::string fFDMC_non_3c
const Cut kNumuND
Definition: NumuCuts.h:55
virtual void Go() override
Load all the registered spectra.
void SaveTo(TDirectory *dir, const std::string &name) const
Definition: Spectrum.cxx:517
const HistAxis kNCAxis("Calorimetric Energy (GeV)", kNCDisappearanceEnergyBinning, kCaloE)
Axes used in Ana01 analysis by nus group.
Definition: HistAxes.h:8
std::vector< float > Spectrum
Definition: Constants.h:570
double sigma(TH1F *hist, double percentile)
const SystShifts kNoShift
Definition: SystShifts.cxx:21
void SetLoaderFiles(const std::vector< std::string > &files, caf::Det_t det, DataMC datamc, DataSource src=kBeam, SwappingConfig swap=kNonSwap)
Configure loader via explicit file list.
Definition: Loaders.cxx:45
const std::string fFDMC_tau_3c
const HistAxis kNCBinsNumuCCAxis("Reconstructed Neutrino Energy (GeV)", kNCDisappearanceEnergyBinning, kCCE)
Definition: HistAxes.h:9
const Var kTuftsWeightCC
Definition: XsecTunes.h:31
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
const std::vector< std::string > fFDMC_tau
const std::string fFDMC_swp_3c
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 double kSecondAnaEpoch3cPOT
Definition: Exposures.h:76
Standard interface to all prediction techniques.
Definition: IPrediction.h:57
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
Sum MC predictions from different periods scaled according to data POT targets.
void SetLoaderPath(const std::string &path, caf::Det_t det, DataMC datamc, DataSource src=kBeam, SwappingConfig swap=kNonSwap)
Configure loader via wildcard path.
Definition: Loaders.cxx:25
TH1 * GetHist(strings strs, int sigma)
const Cut kNusND
Definition: NusCuts.h:71
A helper structure to contain a group of string for plotting.
Definition: PPFXHelper.h:101
const std::vector< std::string > fnamefardata_unblind(MakeUnblindList())