DrawCovMx.C
Go to the documentation of this file.
1 
4 
5 #include "TCanvas.h"
6 
7 using namespace ana;
8 
9 using std::ostringstream;
10 using std::string;
11 using std::vector;
12 
14 using covmx::Sample;
15 
16 void DrawCovMx() {
17 
18  try {
19 
20  DontAddDirectory guard;
21 
22  string opt = "numusel_nuesel_rhc_fhc_neardet_fardet";
23 
24  TFile* plotFile = TFile::Open(("plots/covmx/plots_"+opt+".root").c_str(), "recreate");
25  TDirectory* systDir = plotFile->mkdir("systs");
26 
27  vector<Sample> samples = GetSamplesFromOptString(opt.c_str());
28  for (Sample& s : samples) SetEverything(s);
29  vector<const ISyst*> systs = GetAllSysts();
30  auto calc = DefaultSterileCalc(4);
32  ostringstream tag;
33  for (size_t i = 0; i < samples.size(); ++i) {
34  if (i > 0) tag << "_";
35  tag << samples[i].GetID();
36  }
37  TCanvas c("c", "c", 1600, 900);
38  TFile* inFile = TFile::Open((InputPath()+"/covmx/mx3flav.root").c_str(), "read");
39  TDirectory* dir = inFile->GetDirectory(tag.str().c_str());
40  CovarianceMatrix* mx = LoadFrom<CovarianceMatrix>(dir).release();
41  TH2* hMx = mx->GetCovMxRelativeTH2(samples, calc);
42  plotFile->WriteTObject(hMx, "MxScaled");
43  hMx->Draw("colz");
44  c.SaveAs("plots/covmx/MxScaled.png");
45  delete hMx;
46  hMx = mx->GetFullCovMxTH2();
47  plotFile->WriteTObject(hMx, "MxFull");
48  hMx->Draw("colz");
49  c.SaveAs("plots/covmx/MxFull.png");
50  delete hMx;
51  hMx = mx->GetFullCorrMxTH2();
52  plotFile->WriteTObject(hMx, "MxCorrFull");
53  hMx->Draw("colz");
54  c.SaveAs("plots/covmx/MxFullCorr.png");
55  delete hMx;
56 
57  } catch(const exception& e) {
58  cout << endl << "Exception occurred! " << e.what() << endl;
59  }
60 
61 }
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
void SetEverything(covmx::Sample &sample, bool systs=false, double res=0)
Definition: Utilities.h:588
void DrawCovMx(bool rhc=false)
Definition: DrawCovMx.C:34
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
osc::OscCalcDumb calc
ifstream inFile
Definition: AnaPlotMaker.h:34
const XML_Char * s
Definition: expat.h:262
osc::OscCalcSterile * DefaultSterileCalc(int nflavors)
Create a sterile calculator with default assumptions for all parameters.
Definition: Calcs.cxx:97
void SetNus20Params(osc::OscCalcSterile *calc)
Definition: Utilities.h:682
OStream cout
Definition: OStream.cxx:6
TDirectory * dir
Definition: macro.C:5
std::vector< covmx::Sample > GetSamplesFromOptString(TString optString)
Function to take an option TString and return a vector of associated covmx::Samples.
Definition: Utilities.h:384
Prevent histograms being added to the current directory.
Definition: UtilsExt.h:46
Float_t e
Definition: plot.C:35
string InputPath()
Definition: Utilities.h:183
A class for generating a covariance matrices as a function of oscillation parameters and systematics ...
enum BeamMode string