Functions
GenerateCovMx.C File Reference
#include "CAFAna/Prediction/CovarianceMatrix.h"
#include "NuXAna/Systs/NusAna2020Systs.h"
#include "NuXAna/macros/Nus20/Utilities.h"

Go to the source code of this file.

Functions

vector< const ISyst * > GetSystGroup (string tag)
 
void GenerateCovMx (TString opt)
 
bool Check (string tag, string name)
 

Function Documentation

bool Check ( string  tag,
string  name 
)

Definition at line 75 of file GenerateCovMx.C.

Referenced by GetSystGroup().

75  {
76  if (tag == name) return true;
77  if (tag.substr(0,3) == "no-" && tag != "no-" + name) return true;
78  return false;
79 }
const XML_Char * name
Definition: expat.h:151
void GenerateCovMx ( TString  opt)

Definition at line 20 of file GenerateCovMx.C.

References om::cout, dir, allTimeWatchdog::endl, ana::getNusAna2020AllSysts(), GetSamplesFromOptString(), GetSystGroup(), MECModelEnuComparisons::i, outFile, SetInfo(), SetPrediction(), ana::SetSystAlias(), systs, getGoodRuns4SAM::tag, and gen_hdf5record::types.

20  {
21 
22  vector<Sample> samples = GetSamplesFromOptString(opt);
23  for (Sample& s : samples) {
24  cout << "Loading sample " << s.GetName() << endl;
25  SetInfo(s);
27  SetPrediction(s, true);
28  SetSystAlias(s);
29  }
30 
31  vector<const ISyst*> systs = getNusAna2020AllSysts();
32 
33  TFile* outFile = TFile::Open("mx.root", "recreate");
34  ostringstream tag;
35  for (size_t i = 0; i < samples.size(); ++i) {
36  if (i > 0) tag << "_";
37  tag << samples[i].GetID();
38  }
39  TDirectory* dir = outFile->mkdir(tag.str().c_str());
40 
41  CovarianceMatrix mx(samples, systs);
42  mx.SaveTo(dir, "allsysts");
43 
44  if (opt.Contains("groups")) {
45  cout << "Generating grouped covariance matrices..." << endl;
46  vector<string> types = { "norm", "calib", "xsec", "beam", "mec",
47  "kaon", "neutron", "tau", "sel" };
48  for (string type : types) {
49  if (true) { // let block go out of scope
50  systs = GetSystGroup(type);
51  CovarianceMatrix mxGrp(samples, systs);
52  mxGrp.SaveTo(dir, type);
53  }
54  if (true) { // let block go out of scope
55  systs = GetSystGroup("no-"+type);
56  CovarianceMatrix mxGrp(samples, systs);
57  mxGrp.SaveTo(dir, "no-"+type);
58  }
59  }
60  }
61 
62  if (opt.Contains("individual")) {
63  cout << "Generating " << systs.size() << " individual covariance matrices..." << endl;
64  for (const ISyst* syst : systs) {
65  cout << "Processing syst " << syst->ShortName() << endl;
66  CovarianceMatrix mxIndiv(samples, { syst });
67  mxIndiv.SaveTo(dir, syst->ShortName());
68  }
69  }
70 
71  delete outFile;
72 
73 }
vector< const ISyst * > GetSystGroup(string tag)
Definition: GenerateCovMx.C:81
std::vector< SystGroupDef > systs
Definition: syst_header.h:385
vector< const ISyst * > getNusAna2020AllSysts(covmx::Sample &s)
void SetSystAlias(Sample &sample)
void SetPrediction(covmx::Sample &sample, bool systs=true)
Definition: Utilities.h:505
void SetInfo(covmx::Sample &sample, double res=0)
Definition: Utilities.h:497
Encapsulate code to systematically shift a caf::SRProxy.
Definition: ISyst.h:14
const XML_Char * s
Definition: expat.h:262
TFile * outFile
Definition: PlotXSec.C:135
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:373
vector< const ISyst * > GetSystGroup ( string  tag)

Definition at line 81 of file GenerateCovMx.C.

References ana::AddNusAna2020BeamSysts(), ana::AddNusAna2020KaonSyst(), ana::AddNusAna2020MECSysts(), ana::AddNusAna2020NeutronSyst(), ana::AddNusAna2020NormSysts(), ana::AddNusAna2020NumuSysts(), ana::AddNusAna2020TauSyst(), ana::AddNusAna2020XSecSysts(), Check(), ana::GetKeySysts(), and runNovaSAM::ret.

Referenced by GenerateCovMx().

81  {
82 
83  vector<const ISyst*> ret;
84 
85  if (Check(tag, "norm")) AddNusAna2020NormSysts(ret);
86  if (Check(tag, "calib")) {
87  for (const KeySyst* syst : GetKeySysts())
88  ret.push_back(dynamic_cast<const ISyst*>(syst));
89  }
90  if (Check(tag, "xsec")) AddNusAna2020XSecSysts(ret);
91  if (Check(tag, "beam")) AddNusAna2020BeamSysts(ret);
92  if (Check(tag, "mec")) AddNusAna2020MECSysts(ret);
93  if (Check(tag, "kaon")) AddNusAna2020KaonSyst(ret);
94  if (Check(tag, "neutron")) AddNusAna2020NeutronSyst(ret);
95  if (Check(tag, "tau")) AddNusAna2020TauSyst(ret);
96  if (Check(tag, "sel")) AddNusAna2020NumuSysts(ret);
97 
98  return ret;
99 
100 }
void AddNusAna2020XSecSysts(vector< const ISyst * > &systs)
void AddNusAna2020NeutronSyst(vector< const ISyst * > &systs)
void AddNusAna2020NormSysts(vector< const ISyst * > &systs, Sample &s)
bool Check(string tag, string name)
Definition: GenerateCovMx.C:75
vector< const KeySyst * > GetKeySysts()
void AddNusAna2020TauSyst(vector< const ISyst * > &systs)
void AddNusAna2020KaonSyst(vector< const ISyst * > &systs)
void AddNusAna2020MECSysts(vector< const ISyst * > &systs)
void AddNusAna2020NumuSysts(vector< const ISyst * > &systs)
void AddNusAna2020BeamSysts(vector< const ISyst * > &systs)