TestPred.C
Go to the documentation of this file.
1 
6 
7 using namespace ana;
8 
9 void TestPred() {
10 
11  // Set up systematics
12 
13  std::string filepath = "outputs/nus_systs_test/ISystTemp.root";
14  std::ostringstream name;
15  name << "isyst_nc_fhc_neardet";
16  TFile* f = TFile::Open(filepath.c_str(), "read");
17  TDirectory* dir = f->GetDirectory(name.str().c_str());
18  assert(dir);
19  std::vector<const ISyst*> systs;
20  TIter next(dir->GetListOfKeys());
21  TKey* key;
22  while ((key = (TKey*)next()))
23  systs.push_back(NusISyst::LoadFrom((TDirectory*)key->ReadObj()).release());
24 
25  // Load prediction
26 
27  PredictionInterp* pred = LoadFromFile<PredictionInterp>("outputs/nus_systs_test/pred_nus_fhc_neardet_file.root", "pred_interp_nus_fhc_neardet_file").release();
28 
29  // Osc calculator i guess
30 
31  auto calc = DefaultSterileCalc(4);
32  SetAngles(calc);
33 
34  for (const ISyst* syst : systs) {
35 
36  std::cout << "//////////////////////////////////////////////////" << std::endl;
37  std::cout << "running for syst " << syst->ShortName() << std::endl;
38 
39  SystShifts shiftup;
40  shiftup.SetShift(syst, +1);
41 
42  SystShifts shiftdown;
43  shiftdown.SetShift(syst, -1);
44 
45  TH1* shift_nom = pred->Predict(calc).ToTH1(9e20);
46  TH1* shift_up = pred->PredictSyst(calc, shiftup).ToTH1(9e20);
47  TH1* shift_down = pred->PredictSyst(calc, shiftdown).ToTH1(9e20);
48 
49  for (int i = 1; i <= shift_nom->GetNbinsX(); ++i)
50  std::cout << " OK in bin " << i << " we have nominal " <<
51  shift_nom->GetBinContent(i) << ", up " << shift_up->GetBinContent(i)
52  << ", down " << shift_down->GetBinContent(i) << std::endl;
53 
55 
56  }
57 }
58 
59 
const XML_Char * name
Definition: expat.h:151
Implements systematic errors by interpolation between shifted templates.
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
std::vector< SystGroupDef > systs
Definition: syst_header.h:385
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.
Definition: Spectrum.cxx:148
Simple record of shifts applied to systematic parameters.
Definition: SystShifts.h:20
Spectrum PredictSyst(osc::IOscCalc *calc, const SystShifts &shift) const override
osc::OscCalcDumb calc
void SetAngles(osc::OscCalcSterile *calc)
Encapsulate code to systematically shift a caf::SRProxy.
Definition: ISyst.h:14
std::unique_ptr< T > LoadFrom(TDirectory *dir, const std::string &label)
Definition: LoadFromFile.h:17
osc::OscCalcSterile * DefaultSterileCalc(int nflavors)
Create a sterile calculator with default assumptions for all parameters.
Definition: Calcs.cxx:97
void TestPred()
Definition: TestPred.C:9
OStream cout
Definition: OStream.cxx:6
Spectrum Predict(osc::IOscCalc *calc) const override
TDirectory * dir
Definition: macro.C:5
assert(nhit_max >=nhit_nbins)
void next()
Definition: show_event.C:84
void SetShift(const ISyst *syst, double shift, bool force=false)
Definition: SystShifts.cxx:80
enum BeamMode string