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_ncsel_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 = getNusAna2020AllSysts();
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/mx.root").c_str(), "read");
39  CovarianceMatrix* mx = LoadFrom<CovarianceMatrix>(inFile, tag.str()+"/allsysts").release();
40  TH2* hMx = mx->GetCovMxRelativeTH2(samples, calc);
41  plotFile->WriteTObject(hMx, "MxScaled");
42  hMx->Draw("colz");
43  c.SaveAs("plots/covmx/MxScaled.png");
44  delete hMx;
45  hMx = mx->GetFullCovMxTH2();
46  plotFile->WriteTObject(hMx, "MxFull");
47  hMx->Draw("colz");
48  c.SaveAs("plots/covmx/MxFull.png");
49  delete hMx;
50  hMx = mx->GetFullCorrMxTH2();
51  plotFile->WriteTObject(hMx, "MxCorrFull");
52  hMx->Draw("colz");
53  c.SaveAs("plots/covmx/MxFullCorr.png");
54  delete hMx;
55 
56  } catch(const exception& e) {
57  cout << endl << "Exception occurred! " << e.what() << endl;
58  }
59 
60 }
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
std::vector< SystGroupDef > systs
Definition: syst_header.h:385
void SetNus20Params(osc::OscCalcSterile *calc, std::string type="3flav")
Definition: Utilities.h:619
void SetEverything(covmx::Sample &sample, bool systs=false, double res=0)
Definition: Utilities.h:525
vector< const ISyst * > getNusAna2020AllSysts(covmx::Sample &s)
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
OStream cout
Definition: OStream.cxx:6
string InputPath()
std::vector< covmx::Sample > GetSamplesFromOptString(TString optString)
Function to take an option TString and return a vector of associated covmx::Samples.
Definition: Utilities.h:371
Prevent histograms being added to the current directory.
Definition: UtilsExt.h:46
Float_t e
Definition: plot.C:35
A class for generating a covariance matrices as a function of oscillation parameters and systematics ...
enum BeamMode string