MakeNumuCovMx.C
Go to the documentation of this file.
1 /// MakeCovMx.C by J. Hewes (jhewes15@fnal.gov)
2 // Macro to make covariance matrices
3 
4 #include "CAFAna/Core/Sample.h"
5 #include "CAFAna/Core/ISyst.h"
12 // #include "NuXAna/macros/Nus20/Systs/SystUtilities.h"
13 
14 using namespace ana;
15 
16 using std::cout;
17 using std::endl;
18 using std::exception;
19 using std::vector;
20 
22 using covmx::Sample;
23 
24 void MakeNumuCovMx() {
25 
26  try {
27 
29  sample.SetPOT(9.5e20);
30  sample.SetLivetime(0);
31  SetAxis(sample);
32 
33  vector<const ISyst*> keySysts = GetAllSysts();
34  vector<const ISyst*> systs = LoadSystsFromFile("/nova/app/users/mrajaoal/my_new_release/CAFAna/nus/Nus20/Systs/isysts.root", "isysts_numusel_fhc_neardet");
35  sample.SetPrediction(LoadFromFile<PredictionInterp>("/nova/app/users/mrajaoal/my_new_release/CAFAna/nus/Nus20/Inputs/pred_numusel_fhc_neardet.root", "pred_interp_numusel_fhc_neardet").release());
36  SetSystAlias(sample);
37 
38  auto calc = DefaultSterileCalc(4);
40 
41  std::vector<double> nom;
42  TH1D* h = sample.GetPrediction()->Predict(calc).ToTH1(sample.GetPOT());
43  for (int i = 1; i <= h->GetNbinsX(); ++i) nom.push_back(h->GetBinContent(i));
44 
45  // Output file
46  TFile* outFile = TFile::Open("covmx.root", "recreate");
47  TDirectory* histDir = outFile->mkdir("hists");
48  for (const ISyst* syst : keySysts) {
49  CovarianceMatrix mx({sample}, {syst});
50  mx.Predict({sample}, calc);
51  mx.SaveTo(outFile->mkdir(syst->ShortName().c_str()));
52  histDir->WriteTObject(mx.GetCovMxRelativeTH2(nom), syst->ShortName().c_str());
53  }
54  outFile->Close();
55 
56  } catch(const exception& e) {
57  cout << endl << "Exception occurred! " << e.what() << endl;
58  }
59 
60 } // macro MakeCovMx
std::vector< const ISyst * > GetAllSysts()
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
std::vector< SystGroupDef > systs
Definition: syst_header.h:385
std::vector< const ISyst * > LoadSystsFromFile(std::string filePath, std::string dirName)
Load systematics from file.
Definition: Utilities.h:483
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
osc::OscCalcDumb calc
Encapsulate code to systematically shift a caf::SRProxy.
Definition: ISyst.h:14
void SetAxis(TH1 *h, bool visible, int color, int style=1, bool scale=true)
osc::OscCalcSterile * DefaultSterileCalc(int nflavors)
Create a sterile calculator with default assumptions for all parameters.
Definition: Calcs.cxx:97
void MakeNumuCovMx()
Definition: MakeNumuCovMx.C:24
TFile * outFile
Definition: PlotXSec.C:135
void SetNus20Params(osc::OscCalcSterile *calc)
Definition: Utilities.h:682
void SetSystAlias(covmx::Sample &sample)
OStream cout
Definition: OStream.cxx:6
Float_t e
Definition: plot.C:35
A class for generating a covariance matrices as a function of oscillation parameters and systematics ...