MakeCovMx.C
Go to the documentation of this file.
1 /// Macro to load the manager class and use it to produce and save a covariance matrix
5 
6 #include "TFile.h"
7 
8 using namespace ana;
9 
10 using std::cout;
11 using std::endl;
12 using std::string;
13 using std::vector;
14 
16 using covmx::Sample;
17 
18 void MakeCovMx(TString opt) {
19 
20  try {
21 
22  string filePath = InputPath() + "/covmx/mgr.root";
23  TFile* inFile = TFile::Open(filePath.c_str(), "read");
24 
25  vector<Sample> samples = GetSamplesFromOptString(opt);
26  vector<const ISyst*> systs = GetAllSysts();
27  auto mgr = LoadFrom<CovMxManager>(inFile);
28  CovarianceMatrix* mx = mgr->GetCovarianceMatrix(samples, systs);
29 
30  TFile* outFile = TFile::Open("covmx.root", "recreate");
31  ostringstream dirName;
32  for (size_t i = 0; i < samples.size(); ++i) {
33  if (i > 0) dirName << "_";
34  dirName << samples[i].GetID();
35  }
36  mx->SaveTo(outFile->mkdir(dirName.str().c_str()));
37  delete outFile;
38 
39  } catch(const exception& e) {
40  cout << endl << "Exception occurred! " << e.what() << endl;
41  }
42 
43 }
44 
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
void MakeCovMx()
Definition: MakeCovMx.C:14
std::vector< SystGroupDef > systs
Definition: syst_header.h:385
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
ifstream inFile
Definition: AnaPlotMaker.h:34
TFile * outFile
Definition: PlotXSec.C:135
OStream cout
Definition: OStream.cxx:6
string InputPath()
std::string dirName
Definition: PlotSpectra.h:47
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
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