FitSystEffectsLoad.C
Go to the documentation of this file.
4 #include "CAFAna/Core/Loaders.h"
6 #include "NuXAna/Cuts/NusCuts.h"
12 #include "NuXAna/Systs/NusSysts.h"
14 #include "CAFAna/Vars/HistAxes.h"
17 
18 #include "OscLib/OscCalcSterile.h"
20 #include "NuXAna/Vars/HistAxes.h"
21 
22 #include <string>
23 #include <utility>
24 
25 using namespace ana;
26 
28 {
29  TH1::AddDirectory(0);
30 
31  Loaders loaders123b;
37 
38  Loaders loaders3c3d;
44 
45  loaders123b.SetSpillCut(kStandardSpillCuts);
46  loaders3c3d.SetSpillCut(kStandardSpillCuts);
47 
49  loaderFDdata.SetSpillCut(kStandardSpillCuts);
50 
53 
54  std::map<std::string, std::vector<const ISyst*> > systmap;
55  systmap["Beam"] = std::vector<const ISyst*>();
56  systmap["Birks"] = std::vector<const ISyst*>();
57  systmap["Calib"] = std::vector<const ISyst*>();
58  systmap["DataMC"] = std::vector<const ISyst*>();
59  systmap["GENIE"] = std::vector<const ISyst*>();
60  systmap["NDCont"] = std::vector<const ISyst*>();
61  systmap["NDRock"] = std::vector<const ISyst*>();
62  systmap["Norm"] = std::vector<const ISyst*>();
63  systmap["OscParam"] = std::vector<const ISyst*>();
64  systmap["Stats"] = std::vector<const ISyst*>();
65 
66  systmap["Beam"] .push_back(&kNusBeamSysts);
67  systmap["Birks"] .push_back(&kNusBirksSyst);
68  systmap["Calib"] .push_back(&kNusCalibFlatSyst);
69  systmap["Calib"] .push_back(&kNusCalibRelSyst);
70  systmap["Calib"] .push_back(&kNusCalibSlopeXSyst);
71  systmap["Calib"] .push_back(&kNusCalibSlopeYSyst);
72  systmap["DataMC"] .push_back(&kNusNueCCSyst);
73  systmap["DataMC"] .push_back(&kNusNumuCCSyst);
74  systmap["GENIE"] .push_back(&kNusGENIESmallSysts);
75  systmap["NDCont"] .push_back(&kNusNDContSyst);
76  systmap["NDRock"] .push_back(&kNusNDRockSyst);
77  systmap["Norm"] .push_back(&kNusNormSyst);
78  systmap["OscParam"].push_back(&NusOscParamSyst);
79  systmap["Stats"] .push_back(&kNusMCStatsSyst);
80 
81  systmap["All"] = getAllNusSysts();
82 
84 
85  std::map<std::string, PredictionInterp*> pred123bs;
86  std::map<std::string, PredictionInterp*> pred3c3ds;
87  std::map<std::string, PredictionCombinePeriods*> preds;
88 
89  for(const auto& syst : systmap) {
90  std::string axlabel = syst.first;
91 
92  pred123bs[axlabel] = new PredictionInterp(syst.second, calc, gen, loaders123b);
93  pred3c3ds[axlabel] = new PredictionInterp(syst.second, calc, gen, loaders3c3d);
94  }
95 
96  PredictionSterile* pred123b = (PredictionSterile*)gen.Generate(loaders123b).release();
97  PredictionSterile* pred3c3d = (PredictionSterile*)gen.Generate(loaders3c3d).release();
98 
99  Spectrum* sCosmic = new Spectrum(loaderFDdata, kNCAxis,
101  kNoShift, kTimingSidebandWeight);
102 
103  Spectrum* sCosOOT = new Spectrum(loaderFDdata, kNCAxis,
105 
106  Spectrum* sData = new Spectrum(loaderFDdata, kNCAxis, kInBeamSpill && kNusFD);
107 
108  // Fill the spectra!
109  loaders123b.Go();
110  loaders3c3d.Go();
111  loaderFDdata.Go();
112 
113  // Two scale factors for scaling spectra
115  const double pot_e3ce3d = kSecondAnaEpoch3cPOT+kSecondAnaEpoch3dPOT;
116 
117  for(const auto& syst : systmap) {
118  std::string axlabel = syst.first;
119 
120  preds[axlabel] = new PredictionCombinePeriods({
121  std::make_pair(pred123bs[axlabel], pot_p1p2e3b),
122  std::make_pair(pred3c3ds[axlabel], pot_e3ce3d)
123  });
124  }
125 
127  std::make_pair(pred123b, pot_p1p2e3b),
128  std::make_pair(pred3c3d, pot_e3ce3d)
129  });
130 
131  // Set up output filename
132  TFile* rootF = new TFile(outfile.c_str(), "RECREATE");
133 
134  // Save all of the objects
135  TDirectory* tmp = gDirectory;
136  TDirectory* saveDir = gDirectory;
138  std::string sep = "__";
139 
140  for(const auto& syst : systmap) {
141  std::string axlabel = syst.first;
142 
143  dir = "pred123b" + sep + axlabel;
144  saveDir = rootF->mkdir(dir.c_str());
145  pred123bs[axlabel]->SaveTo(saveDir);
146 
147  dir = "pred3c3d" + sep + axlabel;
148  saveDir = rootF->mkdir(dir.c_str());
149  pred3c3ds[axlabel]->SaveTo(saveDir);
150 
151  dir = "pred" + sep + axlabel;
152  saveDir = rootF->mkdir(dir.c_str());
153  preds[axlabel]->SaveTo(saveDir);
154  }
155 
156  // Save nominal spectra
157  saveDir = rootF->mkdir("pred123b");
158  pred123b->SaveTo(saveDir);
159  saveDir = rootF->mkdir("pred3c3d");
160  pred3c3d->SaveTo(saveDir);
161  saveDir = rootF->mkdir("pred");
162  pred->SaveTo(saveDir);
163  saveDir = rootF->mkdir("sCosmic");
164  sCosmic->SaveTo(saveDir);
165  saveDir = rootF->mkdir("sCosOOT");
166  sCosOOT->SaveTo(saveDir);
167  saveDir = rootF->mkdir("sData");
168  sData->SaveTo(saveDir);
169 
170  tmp->cd();
171  rootF->Close(); // Close the file
172 }
Near Detector underground.
Definition: SREnums.h:10
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
const double kSecondAnaPeriod2POT
Definition: Exposures.h:74
std::unique_ptr< IPrediction > Generate(Loaders &loaders, const SystShifts &shiftMC=kNoShift) const override
const NusFlatSyst kNusNDContSyst("ndcont","ND Containment", 1.0, 0.6)
Definition: NusSysts.h:92
const Cut kNusFD
Definition: NusCuts.h:46
Collection of SpectrumLoaders for many configurations.
Definition: Loaders.h:23
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
virtual void SaveTo(TDirectory *dir, const std::string &name) const override
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.
osc::OscCalcDumb calc
const NusSystFromHist kNusCalibFlatSyst(kNusAna01SystFile,"EX","CalFlat","Flat Miscalibration")
Definition: NusSysts.h:71
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 NusSystFromHist kNusBeamSysts(kNusAna01SystFile,"EX","Beam","All Beam")
Definition: NusSysts.h:69
const std::string fnamenear_concat
void SetSpillCut(const SpillCut &cut)
Definition: Loaders.cxx:121
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
const NusSystFromHist kNusBirksSyst(kNusAna01SystFile,"EX","Birks","Birks C")
Definition: NusSysts.h:70
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
const NusFlatSyst kNusMCStatsSyst("mcstat","MC Stats", 2.0, 4.8)
Definition: NusSysts.h:91
std::vector< float > Spectrum
Definition: Constants.h:570
const NusSystFromHist kNusGENIESmallSysts(kNusAna01SystFile,"EX","GENIESm","Summed small GENIE Systs")
Definition: NusSysts.h:75
const NusSystFromHist kNusNueCCSyst(kNusAna01SystFile,"EX","NueCC","#nu_{e} CC Background")
Definition: NusSysts.h:77
const char sep
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
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
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.
TDirectory * dir
Definition: macro.C:5
const NusSystFromHist kNusCalibRelSyst(kNusAna01SystFile,"EX","CalRel","Relative Detector Miscalibration")
Definition: NusSysts.h:72
const std::vector< std::string > fFDMC_tau
const NusFlatSyst kNusNormSyst("normNus","Normalization", 4.9, 4.9)
Definition: NusSysts.h:93
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 NusSystFromHist kNusNDRockSyst(kNusAna01SystFile,"EX","NDNDRock","ND Rock")
Definition: NusSysts.h:76
A prediction object compatible with sterile oscillations.
const double kSecondAnaEpoch3cPOT
Definition: Exposures.h:76
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.
const NusSystFromHist kNusCalibSlopeXSyst(kNusAna01SystFile,"EX","CalSlopeX","Sloped Miscalibration, X")
Definition: NusSysts.h:73
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
const NusSystFromHist kNusCalibSlopeYSyst(kNusAna01SystFile,"EX","CalSlopeY","Sloped Miscalibration, Y")
Definition: NusSysts.h:74
const Cut kNusND
Definition: NusCuts.h:71
void FitSystEffectsLoad(std::string outfile)
FILE * outfile
Definition: dump_event.C:13
const NusSystFromHist kNusNumuCCSyst(kNusAna01SystFile,"EX","NumuCC","#nu_{#mu} CC Background")
Definition: NusSysts.h:78
const std::vector< std::string > fnamefardata_unblind(MakeUnblindList())