MakeISysts.C
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////
2 // MakeISysts.C
3 // Jeremy Hewes (jhewes15@fnal.gov)
4 //
5 // Make ISysts from SystMakers for 2020 FHC NC analysis
6 //////////////////////////////////////////////////////////////
7 
8 #include "TFile.h"
9 
15 
17 
18 using namespace ana;
19 
20 using std::cout;
21 using std::endl;
22 using std::string;
23 using std::vector;
24 
25 using covmx::Sample;
26 
27 // -------------------------------------------------------------------------------------
28 void MakeISysts(string inFileName = "") {
29 
30  try {
31 
32  if (inFileName.empty()) inFileName = kNus20Path+"/systs/systs.root";
33  TFile* inFile = TFile::Open(inFileName.c_str(), "read");
34  std::string outFileName = "isysts.root";
35  TFile* outFile = TFile::Open(outFileName.c_str(), "recreate");
36 
37  auto calc = DefaultSterileCalc(4);
38  SetNus20Params(calc);
39 
40  TIter next(inFile->GetListOfKeys());
41  TKey* key;
42  while ((key = (TKey*)next())) {
43 
44  Sample sample = GetSampleFromOptString(key->GetName());
45  cout << "Generating ISysts for sample " << sample.GetTag() << endl;
46  SetInfo(sample);
47 
48  SystematicsMaker* systsMaker = SystematicsMaker::LoadFrom((TDirectory*)key->ReadObj()).release();
49 
50  // Run the syst makers
51  systsMaker->Go(sample, calc);
52 
53  // Get and save the isysts
54  vector<NuISyst*> systs = systsMaker->MakeISysts();
55  TDirectory* dir = outFile->mkdir(("isysts_"+sample.GetTag()).c_str());
56  for (NuISyst* syst : systs) {
57  if (sample.selection == covmx::kNC)
58  syst->SaveTo(dir->mkdir((sample.GetTag()+"_"+syst->BaseName()).c_str()), "NCSyst");
59  else if (sample.selection == covmx::kCCNumu)
60  syst->SaveTo(dir->mkdir((sample.GetTag()+"_"+syst->BaseName()).c_str()), "NumuSyst");
61  else if (sample.selection == covmx::kCCNue)
62  syst->SaveTo(dir->mkdir((sample.GetTag()+"_"+syst->BaseName()).c_str()), "NueSyst");
63  }
64  }
65 
66  delete inFile;
67  delete outFile;
68 
69  } catch(const std::exception& e) {
70  std::cout << std::endl << "Exception occurred! " << e.what() << std::endl;
71  }
72 
73 }
74 
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
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
void SetInfo(covmx::Sample &sample, double res=0)
Definition: Utilities.h:495
osc::OscCalcDumb calc
covmx::Sample GetSampleFromOptString(TString optString)
Function to take an option TString and return a single associated covmx::Sample.
Definition: Utilities.h:342
ifstream inFile
Definition: AnaPlotMaker.h:34
osc::OscCalcSterile * DefaultSterileCalc(int nflavors)
Create a sterile calculator with default assumptions for all parameters.
Definition: Calcs.cxx:97
TFile * outFile
Definition: PlotXSec.C:135
std::vector< NuISyst * > MakeISysts()
Make ISyst objects for each attached systematic and return them.
Definition: SystMaker.cxx:1568
const std::string kNus20Path
inFileName
if we get here, we&#39;re doing the base definitions:
Definition: mkDefs.py:169
OStream cout
Definition: OStream.cxx:6
void MakeISysts(std::string nd_path="/nova/data/users/jhewes15/nus19/systmakers/neardet", std::string nd_file="systsmaker_nc_fhc_2019.root", std::string fd_path="/nova/data/users/jhewes15/nus19/systmakers/fardet", std::string fd_file="systsmaker_nc_fhc_2019.root")
Definition: MakeISysts.C:14
TDirectory * dir
Definition: macro.C:5
void Go(const covmx::Sample sample, osc::IOscCalc *calc)
Definition: SystMaker.cxx:1608
Float_t e
Definition: plot.C:35
void next()
Definition: show_event.C:84
static std::unique_ptr< SystematicsMaker > LoadFrom(TDirectory *dir)
Definition: SystMaker.cxx:1692
enum BeamMode string