55 else assert(
false and
"Option string must include detector: \"neardet\" or \"fardet\".");
59 covmx::Analysis c_ana;
72 else assert(
false and
"Option string must include analysis: \"nue\", \"numu\" or \"nus\".");
84 else assert(
false and
"Option string must include beam polarity: \"fhc\" or \"rhc\".");
92 else assert(
false and
"Option string must include file type: \"concat\" or \"fullcaf\".");
95 if (
CheckOption(opt,
"nosysts")) syst_type =
"nosysts";
96 else if (
CheckOption(opt,
"filesysts")) syst_type =
"systs";
97 else if (
CheckOption(opt,
"geniesysts")) syst_type =
"genie";
98 else assert(
false and
"Option string must include syst type: \"nosysts\", \"filesysts\" or \"geniesysts\".");
104 size_t qpos = optstring.find(
"quantile");
105 if (qpos != std::string::npos) {
106 if (optstring.substr(qpos+8, 1) !=
"=")
107 assert(
false and
"The quantile option must take the form \"quantile=xxx\".");
108 size_t start = qpos+9;
109 size_t end = optstring.find(
"_", qpos);
110 if (end != std::string::npos)
111 quantile =
std::stod(optstring.substr(start, end-start));
113 quantile =
std::stod(optstring.substr(start));
118 size_t usesyst = 999;
119 size_t spos = optstring.find(
"usesyst");
120 if (spos != std::string::npos) {
121 if (optstring.substr(spos+7, 1) !=
"=")
122 assert(
false and
"The usesyst option must take the form \"usesyst=xxx\".");
123 size_t start = spos+8;
124 size_t end = optstring.find(
"_", spos);
125 if (end != std::string::npos)
126 usesyst =
std::stod(optstring.substr(start, end-start));
128 usesyst =
std::stod(optstring.substr(start));
139 if (syst_type ==
"systs")
141 if (syst_type ==
"genie")
144 if (all_systs.size() > 0) {
146 if (usesyst == 999) {
147 std::cout <<
"No \"usesyst\" option specified, so running for all systs simultaneously!" <<
std::endl;
151 else if (usesyst >= all_systs.size()) {
152 std::ostringstream err;
153 err <<
"You asked for the systematic in position " 154 << usesyst <<
", but there are only " 155 << all_systs.size() <<
" systematics in the vector provided.";
156 assert(
false and err.str().c_str());
160 const ISyst* syst = all_systs[usesyst];
173 else assert(
false and
"Couldn't find valid caf type.");
193 else if (ana ==
"numu") {
196 assert(
false and
"For a numu prediction you must define a quantile between 0 and 3!");
197 std::string quant_dir =
"/pnfs/nova/persistent/users/jhewes15/quantiles";
198 std::string infile_quant = quant_dir +
"/quantiles__" + polarity +
"_full__numu2018.root";
201 TH2* FDSpec2D = (TH2*)infile->FindObjectAny(
"FDSpec2D");
211 else if (ana ==
"nus") {
212 if (nd) axis =
new const HistAxis(kNCNDAxisE);
213 else axis =
new const HistAxis(kNCFDAxisE);
221 if (nd) loaders.
SetND(
true);
230 if (systs.size() > 0)
236 if (systs.size() == 1)
237 systname = systs[0]->ShortName();
238 else if (systs.size() == 0)
239 systname =
"nosysts";
241 systname = syst_type;
243 std::ostringstream f_out_name;
244 f_out_name <<
"pred_" << ana <<
"_" << polarity <<
"_" <<
detector;
245 if (ana ==
"numu") f_out_name <<
"_q" <<
quantile;
246 f_out_name <<
"_" << systname <<
".root";
247 TFile* f_out = TFile::Open(f_out_name.str().c_str(),
"recreate");
250 std::ostringstream dirname;
251 dirname <<
"pred_" << ana <<
"_" << polarity <<
"_" <<
detector;
252 if (ana ==
"numu") dirname <<
"_q" <<
quantile;
253 dirname <<
"_" << systname;
255 pred->
SaveTo(f_out, dirname.str().c_str());
259 dirname <<
"pred_interp_" << ana <<
"_" << polarity <<
"_" <<
detector;
260 if (ana ==
"numu") dirname <<
"_q" <<
quantile;
261 dirname <<
"_" << systname;
262 pred_interp->
SaveTo(f_out, dirname.str().c_str());
void MakeCovarSim(TString opt)
Implements systematic errors by interpolation between shifted templates.
_HistAxis< Var > HistAxis
Cuts and Vars for the 2020 FD DiF Study.
std::vector< const ISyst * > getAllXsecSysts_2018()
Get master XSec syst list for 2018 analyses.
double stod(const std::string &val)
virtual const std::string & ShortName() const final
The name printed out to the screen.
const Cut kNue2018NDCVNSsb
const HistAxis kHadEFracAxis("E_{had.} / E_{#nu}", Binning::Simple(200, 0, 1), kHadEFrac)
HistAxis that implements Hadronic Energy fraction binning used by L.Vinton to derive Hadronic Energy ...
Adapt the PMNS_Sterile calculator to standard interface.
virtual void SaveTo(TDirectory *dir, const std::string &name) const
std::string pnfs2xrootd(std::string loc, bool unauth)
Encapsulate code to systematically shift a caf::SRProxy.
void Go()
Call Go() on all the loaders.
void SetSpillCut(const SpillCut &cut)
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.
_Cut< caf::SRProxy > Cut
Representation of a cut (selection) to be applied to a caf::StandardRecord object.
const HistAxis kNue2018AxisMergedPeripheral("NuE Energy / Analysis Bin", kNue2018BinningMergedPeripheral, kNue2018AnaBinMergedPeripheral)
const Cut kNus18ND
Full Nus18 ND analysis selection.
const HistAxis kNumuCCOptimisedAxis("Reconstructed Neutrino Energy (GeV)", kNumuCCEOptimisedBinning, kCCE)
HistAxis that implements optimised numuCCE from L. Vinton. See docdb 16332. This was close to 'custC'...
bool CheckOption(TString opts, TString opt)
unsigned int quantile(std::vector< std::vector< double >> v, float E, float hadEfrac)
const SystShifts kNoShift
virtual std::unique_ptr< IPrediction > Generate(Loaders &loaders, const SystShifts &shiftMC=kNoShift) const =0
const Cut kNue2018FDAllSamples
std::vector< Cut > QuantileCutsFromTH2(TH2 *quantileHist, const HistAxis &independentAxis, const HistAxis &quantileAxis, const unsigned int &numQuantiles, const bool verbose)
: Do the same as the QuantileCuts function but taking in the TH2 instead of making it...
assert(nhit_max >=nhit_nbins)
Standard interface to all prediction techniques.
const SpillCut kStandardSpillCuts
Apply this unless you're doing something special.
Given loaders and an MC shift, Generate() generates an IPrediction.
For nominal spectra and reweighting systs (xsec/flux)
Prevent histograms being added to the current directory.
Generates Near Detector predictions.
std::vector< const ISyst * > GetSystsFromFile(covmx::Sample sample)
Get systematics for a given sample.
std::vector< std::string > all_systs