29 using std::back_inserter;
35 using std::ostringstream;
36 using std::runtime_error;
60 if (ndPred < 1 || ndPred > 6) {
62 err <<
"Near detector binning option must be an integer between 1 and 6!" 63 <<
" Value provided was " << ndPred;
64 throw runtime_error(err.str());
66 if (fdPred < 1 || fdPred > 6) {
68 err <<
"Far detector binning option must be an integer between 1 and 6!" 69 <<
" Value provided was " << fdPred;
70 throw runtime_error(err.str());
75 string path =
pnfs2xrootd(
"/pnfs/nova/persistent/analysis/nux/binning_studies/");
76 vector<string> suffix = {
"",
"_res10",
"_res20",
"_res30",
"_res40",
"_res50" };
80 string predFileName = path+
"pred/pred_"+s.GetTag()+suffix[ndPred-1]+
".root";
81 cout <<
"Loading prediction from " << predFileName <<
endl;
82 TFile*
f = TFile::Open(predFileName.c_str(),
"read");
83 pred = LoadFromFile<NDPredictionSterile>(
f,
"pred_"+s.GetTag()).
release();
87 string predFileName = path+
"pred/pred_"+s.GetTag()+suffix[fdPred-1]+
".root";
88 cout <<
"Loading prediction from " << predFileName <<
endl;
89 TFile*
f = TFile::Open(predFileName.c_str(),
"read");
90 pred = LoadFromFile<FDPredictionSterile>(
f,
"pred_"+s.GetTag()).
release();
94 s.SetPrediction(pred);
108 for (Sample& s : cfg.
samples) {
110 string cosmicFileName = path+
"cosmics/"+s.GetTag()+suffix[fdPred-1]+
".root";
111 cout <<
"Loading cosmic spectrum from " << cosmicFileName <<
endl;
112 TFile*
f = TFile::Open(cosmicFileName.c_str(),
"read");
113 s.SetCosmic(LoadFromFile<Spectrum>(f, s.GetTag()).
release());
118 cout << cfg.xVar->ShortName() <<
" " << cfg.yVar->ShortName() <<
endl;
126 cout <<
"Using Asimov fake data." <<
endl;
128 cout <<
"Oscillation parameters used for fake data:" <<
endl;
130 for (Sample& sample: cfg.
samples) {
134 if (sample.HasCosmic()) *data += *sample.GetCosmic();
135 tmp = data->
ToTH1(9e20);
136 sample.SetData(data);
143 cout <<
"Loading fake signal data, type " << cfg.
fakeDataSet <<
", pseudoexperiment " 148 TFile*
f = TFile::Open(filepath.str().c_str(),
"read");
152 for (Sample& s : cfg.
samples) {
159 CovarianceMatrix* mx =
nullptr;
161 mx =
new CovarianceMatrix(cfg.
samples);
167 if (itMx->GetName() ==
name) {
173 for (
string name : kBeamSystNames) {
174 if (itMx->GetName() ==
name) {
181 if (itMx->GetName() == syst->ShortName()) {
187 if (use) mx->AddMatrix(itMx);
192 if (itMx->GetName() == cfg.
systName) {
200 err <<
"Couldn't find matrix with name \"" << cfg.
systName <<
"\"!";
201 throw std::runtime_error(err.str());
206 if (itMx->GetName() != cfg.
systName) {
219 IChiSqExperiment*
expt(
nullptr);
229 expts.push_back(expt);
232 CovMxSurface surf(*cfg.xBins, *cfg.yBins, &multiExpt, calc, cfg.xVar, cfg.yVar,
234 cfg.jobNumber, cfg.nJobs);
237 string optstring = opt.Data();
238 string fitName = optstring.substr(0, optstring.find(
"_njobs"));
239 string outFileName = fitName +
".root";
240 TFile*
outFile = TFile::Open(outFileName.c_str(),
"recreate");
244 cout <<
endl <<
"Exception occurred! " << e.what() <<
endl;
Cuts and Vars for the 2020 FD DiF Study.
std::vector< covmx::Sample > samples
void SetNus20Params(osc::OscCalcSterile *calc, std::string type="3flav")
TH1D * ToTH1(double exposure, Color_t col=kBlack, Style_t style=kSolid, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Histogram made from this Spectrum, scaled to some exposure.
Adapt the PMNS_Sterile calculator to standard interface.
unsigned int fakeDataUniverse
::xsd::cxx::tree::exception< char > exception
std::string pnfs2xrootd(std::string loc, bool unauth)
void PrintOscParams(osc::OscCalcSterile *calc)
static SystShifts Nominal()
FakeDataType fakeDataType
Encapsulate code to systematically shift a caf::SRProxy.
void SaveTo(TDirectory *dir) const
Standard SaveTo implementation.
std::map< const IFitVar *, std::vector< double > > fitSeeds
Representation of a spectrum in any variable, with associated POT.
void SetAxis(TH1 *h, bool visible, int color, int style=1, bool scale=true)
const XML_Char const XML_Char * data
void SetFakeSignalParams(osc::OscCalcSterile *calc, size_t type)
osc::OscCalcSterile * DefaultSterileCalc(int nflavors)
Create a sterile calculator with default assumptions for all parameters.
std::vector< const IExperiment * > GetConstraints()
Gaussian constrains on atmospheric parameters.
static std::unique_ptr< Spectrum > LoadFrom(TDirectory *dir, const std::string &name)
const std::string kNus20Path
void MakeSurfaceBinningStudy(TString opt, size_t ndPred, size_t fdPred)
Compare a single data spectrum to the MC + cosmics expectation.
void OverrideLivetime(double newlive)
DO NOT USE UNLESS YOU ARE 110% CERTAIN THERE ISN'T A BETTER WAY!
std::vector< CovarianceMatrix * > GetMatrices(std::vector< covmx::Sample > samples, bool cvmfs=true)
std::vector< float > Spectrum
Compare a single data spectrum to the MC + cosmics expectation.
Combine multiple component experiments.
TString GetConfig(int dbcfg)
std::vector< const ISyst * > getAllXsecSysts_2018_RPAFix()
const std::vector< std::string > kDetectorSystNames
Standard interface to all prediction techniques.
Prevent histograms being added to the current directory.
std::vector< const IFitVar * > fitVars
A class for generating a covariance matrices as a function of oscillation parameters and systematics ...