All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
ana::NuMIFluxSyst Class Reference

#include <NuMIFluxSysts.h>

Inheritance diagram for ana::NuMIFluxSyst:
ana::ISyst

Public Member Functions

virtual ~NuMIFluxSyst ()
 
void Shift (double sigma, caf::SRSliceProxy *slc, double &weight) const override
 Perform the systematic shift. More...
 
- Public Member Functions inherited from ana::ISyst
 ISyst (const std::string &shortName, const std::string &latexName, bool applyPenalty=true, double min=-3, double max=+3)
 
 ISyst (const ISyst &)=delete
 
 ISyst (ISyst &&rhs)=delete
 
virtual ~ISyst ()
 
void operator= (const ISyst &)=delete
 
void operator= (ISyst &&)=delete
 
virtual std::string ShortName () const final
 The name printed out to the screen. More...
 
virtual std::string LatexName () const final
 The name used on plots (ROOT's TLatex syntax) More...
 
virtual double Penalty (double x) const
 
virtual bool ApplyPenalty () const
 Should a penalty be applied for this shift? More...
 
virtual double Min () const
 Return the min/max value for this syst. More...
 
virtual double Max () const
 
virtual int PredInterpMaxNSigma () const
 

Protected Member Functions

 NuMIFluxSyst (const std::string &dir, const std::string &prefix, const std::string &name)
 

Protected Attributes

std::string fHistName
 
std::string fName
 
TH1 * fScale [2][2][2]
 

Friends

const NuMIFluxSystGetNuMIFluxSyst (const std::string &, const std::string &, const std::string &)
 

Detailed Description

Definition at line 12 of file NuMIFluxSysts.h.

Constructor & Destructor Documentation

ana::NuMIFluxSyst::~NuMIFluxSyst ( )
virtual

Definition at line 18 of file NuMIFluxSysts.cxx.

19  {
20  for(int i = 0; i < 2; ++i)
21  for(int j = 0; j < 2; ++j)
22  for(int k = 0; k < 2; ++k)
23  delete fScale[i][j][k];
24  }
TH1 * fScale[2][2][2]
Definition: NuMIFluxSysts.h:34
pdgs k
Definition: selectors.fcl:22
ana::NuMIFluxSyst::NuMIFluxSyst ( const std::string &  dir,
const std::string &  prefix,
const std::string &  name 
)
inlineprotected

Definition at line 24 of file NuMIFluxSysts.h.

27  : ISyst("numi_"+name, "NuMI flux: "+name),
28  fHistName(dir+"/"+prefix+name), fName(name), fScale()
29  {
30  }
ISyst(const std::string &shortName, const std::string &latexName, bool applyPenalty=true, double min=-3, double max=+3)
Definition: ISyst.cxx:9
tuple dir
Definition: dropbox.py:28
std::string fName
Definition: NuMIFluxSysts.h:32
TH1 * fScale[2][2][2]
Definition: NuMIFluxSysts.h:34
std::string fHistName
Definition: NuMIFluxSysts.h:32
then echo fcl name

Member Function Documentation

void ana::NuMIFluxSyst::Shift ( double  sigma,
caf::SRSliceProxy sr,
double &  weight 
) const
overridevirtual

Perform the systematic shift.

Parameters
sigmaNumber of sigma to shift record by
srThe record to inspect and alter
weightScale this weight for reweighting systematics

Implements ana::ISyst.

Definition at line 27 of file NuMIFluxSysts.cxx.

28  {
29  if(slc->truth.index < 0) return; // No neutrino
30 
31  // TODO switch to regular detector flag as soon as it's filled reliably
32  if(slc->truth.baseline < 500){
33  std::cout << "Using NuMIFluxSyst on what appears not to be an icarus file (baseline = " << slc->truth.baseline << ")!" << std::endl;
34  abort();
35  }
36 
37  if(!fScale[0][0][0]){
38  const char* sbndata = getenv("SBNDATA_DIR");
39  if(!sbndata){
40  std::cout << "NuMIFluxSysts: $SBNDATA_DIR environment variable not set. Please setup the sbndata product." << std::endl;
41  abort();
42  }
43 
44  const std::string fname = std::string(sbndata)+"/beamData/NuMIdata/icarus_numi_flux_syst_ana.root";
45  TFile f(fname.c_str());
46  if(f.IsZombie()){
47  std::cout << "NuMIFluxSysts: Failed to open " << fname << std::endl;
48  abort();
49  }
50 
51  for(int hcIdx: {0, 1}){
52  for(int flavIdx: {0, 1}){
53  for(int signIdx: {0, 1}){
54  std::string hName = fHistName;
55  if(hcIdx == 0) hName += "_fhc"; else hName += "_rhc";
56  if(flavIdx == 0) hName += "_nue"; else hName += "_numu";
57  if(signIdx == 1) hName += "bar";
58 
59  TH1* h = (TH1*)f.Get(hName.c_str());
60  if(!h){
61  std::cout << "NuMIFluxSysts: failed to find " << hName << " in " << f.GetName() << std::endl;
62  abort();
63  }
64  h = (TH1*)h->Clone(UniqueName().c_str());
65  h->SetDirectory(0);
66 
67  fScale[hcIdx][flavIdx][signIdx] = h;
68  }
69  }
70  }
71  } // end if
72 
73  const int flav = abs(slc->truth.initpdg);
74  if(flav != 12 && flav != 14) return;
75 
76  const int hcIdx = 0; // TODO TODO always FHC
77  const int flavIdx = (flav == 12) ? 0 : 1;
78  const int signIdx = (slc->truth.initpdg > 0) ? 0 : 1;
79 
80  TH1* h = fScale[hcIdx][flavIdx][signIdx];
81  assert(h);
82 
83  const int bin = h->FindBin(slc->truth.E);
84 
85  if(bin == 0 || bin == h->GetNbinsX()+1) return;
86 
87  weight *= 1 + sigma*h->GetBinContent(bin);
88  }
string fname
Definition: demo.py:5
constexpr details::BinObj< T > bin(T value)
Returns a wrapper to print the specified data in binary format.
while getopts h
T abs(T value)
TH1 * fScale[2][2][2]
Definition: NuMIFluxSysts.h:34
std::string fHistName
Definition: NuMIFluxSysts.h:32
std::string UniqueName()
Return a different string each time, for creating histograms.
BEGIN_PROLOG could also be cout

Friends And Related Function Documentation

const NuMIFluxSyst* GetNuMIFluxSyst ( const std::string &  ,
const std::string &  ,
const std::string &   
)
friend

Definition at line 91 of file NuMIFluxSysts.cxx.

94  {
95  // Make sure we always give the same one back
96  static std::map<std::string, const NuMIFluxSyst*> cache;
97 
98  const std::string key = dir+"/"+prefix+name;
99  if(cache.count(key) == 0) cache[key] = new NuMIFluxSyst(dir, prefix, name);
100 
101  return cache[key];
102  }
tuple dir
Definition: dropbox.py:28
NuMIFluxSyst(const std::string &dir, const std::string &prefix, const std::string &name)
Definition: NuMIFluxSysts.h:24
then echo fcl name

Member Data Documentation

std::string ana::NuMIFluxSyst::fHistName
protected

Definition at line 32 of file NuMIFluxSysts.h.

std::string ana::NuMIFluxSyst::fName
protected

Definition at line 32 of file NuMIFluxSysts.h.

TH1* ana::NuMIFluxSyst::fScale[2][2][2]
mutableprotected

Definition at line 34 of file NuMIFluxSysts.h.


The documentation for this class was generated from the following files: