GenerateCovMx.C
Go to the documentation of this file.
1 /// macro MakeCovMx (it's for making covariance matrices)
2 // by J Hewes (jhewes15@fnal.gov)
3 
6 
7 using namespace ana;
8 
9 using std::cout;
10 using std::endl;
11 using std::string;
12 using std::vector;
13 
14 using covmx::Sample;
15 
16 void SetPredictions(vector<Sample>& samples, size_t i, size_t j) {
17 
18  for (size_t k = 0; k < samples.size(); ++k) {
19  if ((k == i || k == j) && !samples[k].HasPrediction()) {
20  SetPrediction(samples[k]);
21  } else if ((k != i && k != j) && samples[k].HasPrediction()) {
22  samples[k].ResetPrediction();
23  }
24  }
25 }
26 
27 void GenerateCovMx(int patch=-1) {
28 
29  // first, load samples and set info
30  vector<Sample> samples;
31  for (covmx::Polarity pol : { covmx::kFHC, covmx::kRHC }) {
33  samples.push_back(Sample(covmx::kNC, pol, det));
34  samples.push_back(Sample(covmx::kCCNue, pol, det));
36  samples.push_back(Sample(covmx::kCCNumu, pol, det, q));
37  }
38  }
39  }
40  //vector<Sample> samples = GetSamplesFromOptString(opt);
41  for (Sample& s : samples) {
42  cout << "Loading sample " << s.GetName() << endl;
43  SetInfo(s);
44  LoadSysts(s);
45  SetSystAlias(s);
46  }
47 
48  vector<const ISyst*> systs = GetAllSysts();
49 
50  TFile* outFile = TFile::Open("mgr.root", "recreate");
51  CovMxManager mgr(outFile, samples);
52 
53  // then, loop over those samples
54  size_t counter = 0;
55  for (size_t i = 0; i < samples.size(); ++i) {
56  for (size_t j = i; j < samples.size(); ++j) {
57  if ((RunningOnGrid() && counter == JobNumber())
58  || (!RunningOnGrid() && (patch == -1 || patch == (int)counter)) ) {
59  SetPredictions(samples, i, j);
60  for (const ISyst* syst : systs) mgr.AddSystematic(samples, syst, counter);
61  }
62  ++counter;
63  }
64  }
65 
66  delete outFile;
67 
68 }
69 
std::vector< const ISyst * > GetAllSysts()
size_t JobNumber()
What&#39;s the process number for a grid job?
Definition: Utilities.cxx:366
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
std::vector< SystGroupDef > systs
Definition: syst_header.h:385
bool RunningOnGrid()
Is this a grid (condor) job?
Definition: Utilities.cxx:359
void SetPredictions(vector< Sample > &samples, size_t i, size_t j)
Definition: GenerateCovMx.C:16
void SetPrediction(covmx::Sample &sample, bool systs=true)
Definition: Utilities.h:564
void SetInfo(covmx::Sample &sample, double res=0)
Definition: Utilities.h:556
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
const double j
Definition: BetheBloch.cxx:29
void SetSystAlias(covmx::Sample &sample)
OStream cout
Definition: OStream.cxx:6
void GenerateCovMx(int patch=-1)
Definition: GenerateCovMx.C:27
void AddSystematic(std::vector< covmx::Sample > &samples, const ISyst *syst, size_t patch)
std::vector< const ISyst * > LoadSysts(covmx::Sample sample)
Get systematics for a given sample.
Definition: Utilities.h:524
enum BeamMode string