MakePPFXRatios.C
Go to the documentation of this file.
1 #ifdef __CINT__
3  bool concat = true, bool rhc = false) {
4  std::cout<< "Sorry, you gotta run in compiled mode." << std::cout;
5 }
6 #else
7 
11 
12 using namespace ana;
13 
15  bool concat = true, bool rhc = false)
16 {
17  DontAddDirectory guard;
18 
19  bool nd;
20  if (detector == "nd") nd = true;
21  else if (detector == "fd") nd = false;
22  else throw std::runtime_error("Detector string must be \"nd\" or \"fd\"; \""
23  + detector + "\" is not understood.");
24 
25  if (job < 1 || job > 5) throw std::runtime_error("Job int must be in range 1 -> 5!");
26 
28  const HistAxis kAxisE("Energy Deposited in Detector (GeV)", kNus18EnergyBinning, kNus18Energy);
29 
30  std::string filename = detector + "_ppfx_" + std::to_string(job) + ".root";
31  TFile* f = new TFile(filename.c_str(), "RECREATE");
32 
33  std::vector<Var> kPPFXFluxUnivWgts;
34  for (unsigned int i = 0; i < 100; ++i) {
35  const Var tempPPFXWgt([i](const caf::SRProxy* sr){
36  if (!sr->hdr.ismc) return 1.f;
37  if (sr->mc.nnu != 1) return 1.f;
38  if (sr->mc.nu[0].rwgt.ppfx.vuniv[i] <= 0) return 1.f;
39  return (float)sr->mc.nu[0].rwgt.ppfx.vuniv[i];
40  });
41  kPPFXFluxUnivWgts.push_back(tempPPFXWgt);
42  }
43 
44  for (int n = 20 * (job-1); n < 20 * job; ++n) {
45 
46  std::string detname = nd? "near detector" : "far detector";
47  std::cout << "Processing universe " << n << " for " << detname << "..." << std::endl;
48 
49  const Var kPPFXFluxUnivWgt = kPPFXFluxUnivWgts[n];
50  const Var kReweight = kXSecCVWgt2018*kPPFXFluxUnivWgt;
51 
52  // Set up the loaders
56  if (nd) loaders->SetND(true);
58 
59  if (nd) {
60 
61  NDPredictionGenerator ppfx_nd(kAxisE, kNus18ND, kNoShift, kReweight);
62  PredictionInterp universe({}, calc4f, ppfx_nd, *loaders);
63 
64  loaders->Go();
65 
66  universe.SaveTo(f, Form("universe_%i",n));
67 
68  } else {
69 
70  FDPredictionGenerator ppfx_fd(kAxisE, kNus18FD, kNoShift, kReweight);
71  PredictionInterp universe({}, calc4f, ppfx_fd, *loaders);
72 
73  loaders->Go();
74 
75  universe.SaveTo(f, Form("universe_%i",n));
76 
77  }
78 
79  } // for n
80 
81  f->Close();
82 }
83 
84 #endif
Implements systematic errors by interpolation between shifted templates.
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const Var kNus18Energy([](const caf::SRProxy *sr){bool h_FHC=sr->spill.isFHC;bool h_RHC=sr->spill.isRHC;double cale=sr->slc.calE;double recoE=0.;if(h_FHC &&sr->hdr.det==caf::kFARDET) recoE=FDscaleCalE18 *cale;else if(h_FHC &&sr->hdr.det==caf::kNEARDET) recoE=NDscaleCalE18 *cale;else if(h_RHC &&sr->hdr.det==caf::kFARDET) recoE=FDscaleCalE18RHC *cale;else if(h_RHC &&sr->hdr.det==caf::kNEARDET) recoE=NDscaleCalE18RHC *cale;return recoE;})
Definition: NusVars.h:63
caf::Proxy< caf::SRHeader > hdr
Definition: SRProxy.h:2137
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2126
Collection of SpectrumLoaders for many configurations.
Definition: Loaders.h:23
caf::Proxy< std::vector< caf::SRNeutrino > > nu
Definition: SRProxy.h:618
Adapt the PMNS_Sterile calculator to standard interface.
caf::Proxy< short int > nnu
Definition: SRProxy.h:617
string filename
Definition: shutoffs.py:106
const Cut kNus18FD
Definition: NusCuts18.h:100
void Go()
Call Go() on all the loaders.
Definition: Loaders.cxx:162
void SetSpillCut(const SpillCut &cut)
Definition: Loaders.cxx:121
osc::OscCalcSterile * DefaultSterileCalc(int nflavors)
Create a sterile calculator with default assumptions for all parameters.
Definition: Calcs.cxx:97
const Binning kNus18EnergyBinning
Energy binnings for Nus18 for nus analysis.
Definition: Binning.cxx:74
if(dump)
caf::StandardRecord * sr
void MakePPFXRatios(std::string detector, int job, bool concat=true, bool rhc=false)
const Cut kNus18ND
Full Nus18 ND analysis selection.
Definition: NusCuts18.h:137
const SystShifts kNoShift
Definition: SystShifts.cxx:21
OStream cout
Definition: OStream.cxx:6
caf::Proxy< caf::SRTruthBranch > mc
Definition: SRProxy.h:2138
const Var kXSecCVWgt2018
Definition: XsecTunes.h:49
std::vector< Loaders * > loaders
Definition: syst_header.h:386
void SetND(bool nd)
Definition: Loaders.h:65
caf::Proxy< bool > ismc
Definition: SRProxy.h:242
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
std::string to_string(ModuleType mt)
Definition: ModuleType.h:32
For nominal spectra and reweighting systs (xsec/flux)
Definition: Prod4Loaders.h:96
Prevent histograms being added to the current directory.
Definition: UtilsExt.h:46
Generates Near Detector predictions.
enum BeamMode string