MergePredictions.C
Go to the documentation of this file.
1 
3 #include "CAFAna/Core/Sample.h"
5 
9 
10 using namespace ana;
11 
12 using std::cout;
13 using std::endl;
14 using std::string;
15 
16 using covmx::Sample;
17 
18 void CopyPred(TDirectory* in, TDirectory* out, Sample s) {
19 
20  cout << "Moving prediction " << s.GetTag() << "...";
21 
22  time_t before, after;
23  time(&before);
24 
25  TDirectory* predDir = (s.selection == covmx::kCCNue) ?
26  in->GetDirectory(("pred_"+s.GetTag()).c_str()) :
27  in->GetDirectory(s.GetTag().c_str())->GetDirectory("pred");
28  IPrediction* pred = (s.detector == covmx::kNearDet) ?
29  (IPrediction*)LoadFrom<NDPredictionSterile>(predDir).release()
30  : (IPrediction*)LoadFrom<FDPredictionSterile>(predDir).release();
31  pred->SaveTo(out->mkdir("pred"));
32  delete pred;
33  predDir = (s.selection == covmx::kCCNue) ?
34  in->GetDirectory(("pred_interp_"+s.GetTag()).c_str()) :
35  in->GetDirectory(s.GetTag().c_str())->GetDirectory("pred_interp");
36  LoadSysts(s);
37  GetXsecSysts();
38  pred = LoadFrom<PredictionInterp>(predDir).release();
39  pred->SaveTo(out->mkdir("pred_interp"));
40  delete pred;
41 
42  time(&after);
43  double seconds = difftime(after, before);
44  cout << " done in " << seconds << " seconds." << endl;
45 
46 }
47 
48 void MergePredictions(TString opt) {
49 
50  string path = "/nova/data/users/jhewes15/";
51 
52  TFile* outFile = TFile::Open((path+"predictions.root").c_str(), "update");
53 
54  Sample s = GetSampleFromOptString(opt);
55  string inFileName = (s.selection == covmx::kCCNue) ? "pred.root" : "pred_existing.root";
56  TFile* inFile = TFile::Open((path+inFileName).c_str(), "read");
57  CopyPred(inFile, outFile->mkdir(s.GetTag().c_str()), s);
58 
59  delete inFile;
60  delete outFile;
61 }
62 
void CopyPred(TDirectory *in, TDirectory *out, Sample s)
def after(args)
Definition: fabricate.py:1416
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
virtual void SaveTo(TDirectory *dir, const std::string &name) const
::xsd::cxx::tree::time< char, simple_type > time
Definition: Database.h:194
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
const XML_Char * s
Definition: expat.h:262
TFile * outFile
Definition: PlotXSec.C:135
void MergePredictions(TString opt)
inFileName
if we get here, we&#39;re doing the base definitions:
Definition: mkDefs.py:169
OStream cout
Definition: OStream.cxx:6
const std::string path
Definition: plot_BEN.C:43
ifstream in
Definition: comparison.C:7
Standard interface to all prediction techniques.
Definition: IPrediction.h:57
enum BeamMode string