BlessedPlotsLoad.C
Go to the documentation of this file.
2 #include "CAFAna/Core/Loaders.h"
5 #include "NuXAna/Cuts/NusCuts.h"
9 #include "CAFAna/Extrap/ExtrapSterile.h"
15 #include "CAFAna/Vars/HistAxes.h"
17 
18 #include "OscLib/OscCalcSterile.h"
20 #include "NuXAna/Vars/HistAxes.h"
21 
22 using namespace ana;
23 
25 {
26  TH1::AddDirectory(0);
27 
28  // Set up some calculators:
29  // Set up oscillation calculator that uses default 3 flavor parameters
31 
32  // Set up paths to files for loading
34 
40 
41  // Only consider beam with 14 diblocks
43 
46 
47  // Set up ND decompositon for ND spectra plots
48  ProportionalDecomp decompNC(
49  loaders, kNCAxis, kNusND,
51  ); // NC Decomp
52 
53  // Set up the sterile prediction
54  SterileGenerator gen(
58  );
59 
60  // Set up the prediction object
62  loaders
63  ).release();
64 
65  // Set up the cosmic spectrum
66  Spectrum sCosmic(floadcos, kNCAxis, kInCosmicTimingWindow && kNusFD);
67 
68  // Create predictions necessary for calculating FD purity and efficiency
69  PredictionNoExtrap pFDPurEffNum(
70  loaders, kNCAxis, kNusFD && kIsNC,
72  );
73  PredictionNoExtrap pFDPurityDen(
74  loaders, kNCAxis, kNusFD,
76  );
77  PredictionNoExtrap pFDEfcncyDen(
80  );
81 
82  // Create Spectra necessary for calculating ND purity and efficiency
83  Spectrum sNDPurEffNum(
85  kNCAxis, kNusND && kIsNC,
87  );
88  Spectrum sNDPurityDen(
90  kNCAxis, kNusND,
92  );
93  Spectrum sNDEfcncyDen(
97  );
98 
99  // Fill the spectra!
100  loaders.Go();
101  floadcos.Go();
102 
103  // Two scale factors for scaling spectra, 1 data yr and 3 data yr
104  double pot1yr = 6e20;
105  double pot3yr = 18e20;
106 
107  // Create 2 cosmic spectra, one scaled to each of the above scale factors
108  sCosmic.OverridePOT(sCosmic.Livetime()*2.5e18);
109  Spectrum sCosmic1y = sCosmic.FakeData(pot1yr);
110  Spectrum sCosmic3y = sCosmic.FakeData(pot3yr);
111 
112  // Create mock data predictions
113  Spectrum sFDPred = pred->Predict(calc3f); // Create an FD spectrum assuming 3 flavor osc
114  // Scale the FD beam to 1 data year, add 1 data yr cosmics
115  Spectrum sFDData1y = sFDPred.FakeData(pot1yr) + sCosmic1y;
116  Spectrum sFDData3y = sFDPred.FakeData(pot3yr) + sCosmic3y; // Repeat for 3 data yr
117 
118  // Set up output filename
119  TFile* rootF = new TFile(outfile.c_str(), "RECREATE");
120 
121  TDirectory* tmp = gDirectory;
122  TDirectory* saveDir = gDirectory;
123 
124  // Save all of the objects
125  saveDir = rootF->mkdir("decompNC");
126  decompNC .SaveTo(saveDir);
127  saveDir = rootF->mkdir("prediction");
128  pred ->SaveTo(saveDir);
129  saveDir = rootF->mkdir("sData1Yr");
130  sFDData1y .SaveTo(saveDir);
131  saveDir = rootF->mkdir("sData3Yr");
132  sFDData3y .SaveTo(saveDir);
133  saveDir = rootF->mkdir("sCos1Yr");
134  sCosmic1y .SaveTo(saveDir);
135  saveDir = rootF->mkdir("sCos3Yr");
136  sCosmic3y .SaveTo(saveDir);
137  saveDir = rootF->mkdir("pFDPENum");
138  pFDPurEffNum.SaveTo(saveDir);
139  saveDir = rootF->mkdir("pFDPDen");
140  pFDPurityDen.SaveTo(saveDir);
141  saveDir = rootF->mkdir("pFDEDen");
142  pFDEfcncyDen.SaveTo(saveDir);
143  saveDir = rootF->mkdir("sNDPENum");
144  sNDPurEffNum.SaveTo(saveDir);
145  saveDir = rootF->mkdir("sNDPDen");
146  sNDPurityDen.SaveTo(saveDir);
147  saveDir = rootF->mkdir("sNDEDen");
148  sNDEfcncyDen.SaveTo(saveDir);
149 
150  tmp->cd();
151  rootF->Close(); // Close the file
152 }
Near Detector underground.
Definition: SREnums.h:10
const Cut kNusFDFiducial([](const caf::SRProxy *sr){ if(!sr->vtx.elastic.IsValid) return false;const TVector3 vtx=sr->vtx.elastic.vtx;if(vtx.X()< -680.0) return false;if(vtx.X() > 650.0) return false;if(vtx.Y()< -720.0) return false;if(vtx.Y() > 500.0) return false;if(vtx.Z()< 50.0) return false;if(vtx.Z() > 5450.0) return false;return true;})
FD Fiducial volume from docdb 15285.
Definition: NusCuts.h:17
Far Detector at Ash River.
Definition: SREnums.h:11
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const std::string fnametau_concat
const Cut kNusEventQuality([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return false;if(sr->sel.nuecosrej.hitsperplane >=8) return false;if(sr->vtx.elastic.fuzzyk.nshwlid==0) return false;if(sr->vtx.elastic.fuzzyk.png[0].shwlid.gap >=100.) return false;if(sr->slc.ncontplanes<=2) return false;return true;})
Data Quality cuts from docdb 14241.
Definition: NusCuts.h:14
std::unique_ptr< IPrediction > Generate(Loaders &loaders, const SystShifts &shiftMC=kNoShift) const override
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
Collection of SpectrumLoaders for many configurations.
Definition: Loaders.h:23
const Cut kNusNDFiducial([](const caf::SRProxy *sr){assert(sr->vtx.elastic.IsValid &&"Must apply DQ cuts");if(sr->vtx.elastic.vtx.X()< -100.0) return false;if(sr->vtx.elastic.vtx.X() > 100.0) return false;if(sr->vtx.elastic.vtx.Y()< -100.0) return false;if(sr->vtx.elastic.vtx.Y() > 100.0) return false;if(sr->vtx.elastic.vtx.Z()< 200.0) return false;if(sr->vtx.elastic.vtx.Z() > 1000.0) return false;return true;})
ND Fiducial volume from docdb 15242.
Definition: NusCuts.h:51
Adapt the PMNS_Sterile calculator to standard interface.
virtual void SaveTo(TDirectory *dir, const std::string &name) const override
Float_t tmp
Definition: plot.C:36
void SetSpillCut(const SpillCut &cut)
Generates extrapolated NC predictions using ProportionalDecomp.
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 kInCosmicTimingWindow
Is the event far from the start and ends of the spill ? For FD cosmic selection.
Definition: TimingCuts.cxx:165
const SpillCut kOnly14DB([](const caf::SRSpillProxy *spill){if(spill->det!=caf::kFARDET) return true;std::bitset< 14 > binary(spill->dibmask);for(int i=0;i< 14;++i){if(!binary[i]) return false;}return true;})
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
const std::string fnameneardata_concat
Spectrum Predict(osc::IOscCalc *calc) const override
const Cut kIsNC([](const caf::SRProxy *sr){if(sr->mc.nnu==0) return false;assert(sr->mc.nnu==1);return!sr->mc.nu[0].iscc;})
Is this a Neutral Current event?
Definition: TruthCuts.h:8
Spectrum FakeData(double pot) const
Fake data is a MC spectrum scaled to the POT expected in the data.
Definition: Spectrum.cxx:341
SpectrumLoaderBase & GetLoader(caf::Det_t det, DataMC datamc, DataSource src=kBeam, SwappingConfig swap=kNonSwap)
Retrieve a specific loader.
Definition: Loaders.cxx:129
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
virtual void SaveTo(TDirectory *dir, const std::string &name) const override
void BlessedPlotsLoad(std::string outfile)
const SystShifts kNoShift
Definition: SystShifts.cxx:21
void SaveTo(TDirectory *dir, const std::string &name) const override
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
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.
std::vector< Loaders * > loaders
Definition: syst_header.h:386
A prediction object compatible with sterile oscillations.
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
Prediction that just uses FD MC, with no extrapolation.
const std::string fnameswap_concat
const std::string fnamefar_concat
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
double Livetime() const
Seconds. For informational purposes only. No calculations use this.
Definition: Spectrum.h:222
const Cut kNusND
Definition: NusCuts.h:71
FILE * outfile
Definition: dump_event.C:13