MakeNusPrediction.C
Go to the documentation of this file.
3 #include "CAFAna/Core/Loaders.h"
6 #include "NuXAna/Cuts/NusCuts.h"
10 #include "CAFAna/Extrap/ExtrapSterile.h"
17 #include "CAFAna/Vars/HistAxes.h"
18 #include "NuXAna/Vars/HistAxes.h"
20 
21 #include "OscLib/OscCalcSterile.h"
22 
23 #include <utility>
24 
25 using namespace ana;
26 
28 {
29  TH1::AddDirectory(0);
30 
31  // Set up some calculators:
32  // Set up oscillation calculator that uses default 3 flavor parameters
34 
35  // ND DATA + MC
36  SpectrumLoader loaderNDMC(fnamenear_concat);
38  loaderNDMC.SetSpillCut(kStandardSpillCuts);
39  loaderNDdata.SetSpillCut(kStandardSpillCuts);
40 
41  // PERIOD 1, 2 + EPOCH 3B
42  SpectrumLoaderBase* loaderFDMC_non = new SpectrumLoader(fFDMC_non);
43  SpectrumLoaderBase* loaderFDMC_swp = new SpectrumLoader(fFDMC_swp);
44  SpectrumLoaderBase* loaderFDMC_tau = new SpectrumLoader(fFDMC_tau);
45  loaderFDMC_non->SetSpillCut(kStandardSpillCuts);
46  loaderFDMC_swp->SetSpillCut(kStandardSpillCuts);
47  loaderFDMC_tau->SetSpillCut(kStandardSpillCuts);
48 
49  // PERIOD 3C (and implied 3D)
50  SpectrumLoader loaderFDMC_non_3c(fFDMC_non_3c);
51  SpectrumLoader loaderFDMC_swp_3c(fFDMC_swp_3c);
52  SpectrumLoader loaderFDMC_tau_3c(fFDMC_tau_3c);
53  loaderFDMC_non_3c.SetSpillCut(kStandardSpillCuts);
54  loaderFDMC_swp_3c.SetSpillCut(kStandardSpillCuts);
55  loaderFDMC_tau_3c.SetSpillCut(kStandardSpillCuts);
56 
57  // FD DATA COSMICS
59  loaderFDCOS.SetSpillCut(kStandardSpillCuts);
60 
61  // Set up ND decompositon for ND spectra plots
62  ProportionalDecomp decompNC(
63  loaderNDMC, loaderNDdata, kNCAxis, kNusND,
65  ); // NC Decomp
66 
67  // Set up ND decompositon for Numu
68  ProportionalDecomp decompNumu(
69  loaderNDMC, loaderNDdata, kNCBinsNumuCCAxis, kNumuND,
71  ); // NC Decomp
72 
74  loaderNDMC, *loaderFDMC_swp, *loaderFDMC_non, *loaderFDMC_tau,
75  decompNC, decompNumu,
79  );
80 
82  loaderNDMC, loaderFDMC_swp_3c, loaderFDMC_non_3c, loaderFDMC_tau_3c,
83  decompNC, decompNumu,
87  );
88 
89 
90  // Set up the prediction object
91  PredictionSterile* pred_p1p2e3b = new PredictionSterile(&extrap_p1p2e3b);
92 
93  PredictionSterile* pred_e3ce3d = new PredictionSterile(&extrap_e3ce3d);
94 
95  // Set up the cosmic spectrum
96  Spectrum sCosmic(loaderFDCOS, kNCAxis, kInCosmicTimingWindow && kNusFD);
97 
98 
99  // Fill the spectra!
100  loaderNDMC.Go();
101  loaderNDdata.Go();
102  loaderFDMC_non->Go();
103  loaderFDMC_swp->Go();
104  loaderFDMC_tau->Go();
105  loaderFDMC_non_3c.Go();
106  loaderFDMC_swp_3c.Go();
107  loaderFDMC_tau_3c.Go();
108  loaderFDCOS.Go();
109 
110  // Two scale factors for scaling spectra, 1 data yr and 3 data yr
112  const double pot_e3ce3d = kSecondAnaEpoch3cPOT +kSecondAnaEpoch3dPOT;
113 
114 
115  // Create 2 cosmic spectra, one scaled to each of the above scale factors
116  // When we use out-of-time NuMI data this needs to be livetime scaled.
117  sCosmic.OverridePOT(sCosmic.Livetime()*2.5e18);
118 
119  Spectrum sCosmicSA = sCosmic.FakeData(kSecondAnaPOT);
120 
122  (std::make_pair(pred_p1p2e3b, pot_p1p2e3b)),
123  (std::make_pair(pred_e3ce3d, pot_e3ce3d))
124  });
125 
126 
127  // Create mock data predictions
128  Spectrum sFDPred = pred->Predict(calc3f); // Create an FD spectrum assuming 3 flavor osc
129  // Scale the FD beam to Second Analysis expected data POT
130  // add eqivalent cosmics
131  Spectrum sFDData = sFDPred.FakeData(kSecondAnaPOT) + sCosmicSA;
132 
133  // Set up output filename
134  TFile* rootF = new TFile(outfile.c_str(), "RECREATE");
135 
136  TDirectory* tmp = gDirectory;
137  TDirectory* saveDir = gDirectory;
138 
139  // Save all of the objects
140  saveDir = rootF->mkdir("decompNC");
141  decompNC.SaveTo(saveDir);
142  saveDir = rootF->mkdir("decompNumu");
143  decompNumu.SaveTo(saveDir);
144  saveDir = rootF->mkdir("extrap_p1p2e3b");
145  extrap_p1p2e3b.SaveTo(saveDir);
146  saveDir = rootF->mkdir("extrap_e3ce3b");
147  extrap_e3ce3d.SaveTo(saveDir);
148  saveDir = rootF->mkdir("prediction_p1p2e3b");
149  pred_p1p2e3b->SaveTo(saveDir);
150  saveDir = rootF->mkdir("prediction_e3ce3b");
151  pred_e3ce3d->SaveTo(saveDir);
152  saveDir = rootF->mkdir("prediction");
153  pred->SaveTo(saveDir);
154  saveDir = rootF->mkdir("sData");
155  sFDData.SaveTo(saveDir);
156  saveDir = rootF->mkdir("sCos");
157  sCosmic.SaveTo(saveDir);
158  saveDir = rootF->mkdir("sCosSA");
159  sCosmicSA.SaveTo(saveDir);
160 
161  tmp->cd();
162  rootF->Close(); // Close the file
163 }
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const double kSecondAnaPeriod2POT
Definition: Exposures.h:74
void OverridePOT(double newpot)
DO NOT USE UNLESS YOU ARE 110% CERTAIN THERE ISN&#39;T A BETTER WAY!
Definition: Spectrum.h:225
const std::string fnamecos_concat
const Cut kNusFD
Definition: NusCuts.h:46
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
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
const Cut kInCosmicTimingWindow
Is the event far from the start and ends of the spill ? For FD cosmic selection.
Definition: TimingCuts.cxx:165
virtual void Go()=0
Load all the registered spectra.
const std::string fnamenear_concat
osc::OscCalcSterile * DefaultSterileCalc(int nflavors)
Create a sterile calculator with default assumptions for all parameters.
Definition: Calcs.cxx:97
const std::string fnameneardata_concat
const std::vector< std::string > fFDMC_swp
Spectrum FakeData(double pot) const
Fake data is a MC spectrum scaled to the POT expected in the data.
Definition: Spectrum.cxx:341
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
const SystShifts kNoShift
Definition: SystShifts.cxx:21
void SaveTo(TDirectory *dir, const std::string &name) const override
Base class for the various types of spectrum loader.
::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
Splits Data proportionally according to MC.
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
A prediction object compatible with sterile oscillations.
const double kSecondAnaEpoch3cPOT
Definition: Exposures.h:76
void SaveTo(TDirectory *dir, const std::string &name) const override
void MakeNusPrediction(std::string outfile)
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 double kSecondAnaPOT
Definition: Exposures.h:87
static ModularExtrapSterile NCDisappearance(Loaders &loaders, const IDecomp &NCSurvDecomp, const IDecomp &NumuOscDecomp, const HistAxis &axis, const HistAxis &axisNumuND, const Cut &fdcut, const Cut &NCNDcut, const Cut &NumuNDcut, const SystShifts &shiftMC=kNoShift, const Var &weight=kUnweighted)
Creates a NC disappearance extrapolation.
double Livetime() const
Seconds. For informational purposes only. No calculations use this.
Definition: Spectrum.h:222
const Cut kNusND
Definition: NusCuts.h:71
void SaveTo(TDirectory *dir, const std::string &name) const override
FILE * outfile
Definition: dump_event.C:13
Spectrum Predict(osc::IOscCalc *calc) const override