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

#include <SBNWeightSysts.h>

Inheritance diagram for ana::SBNWeightSyst:
ana::ISyst

Classes

struct  Univs
 

Public Member Functions

 SBNWeightSyst (const std::string &systName)
 
void Shift (double x, caf::SRSliceProxy *sr, 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

Univs GetUnivs (double x) const
 

Protected Attributes

int fIdx
 
std::unordered_map< double, UnivsfUnivs
 

Detailed Description

Definition at line 33 of file SBNWeightSysts.h.

Constructor & Destructor Documentation

ana::SBNWeightSyst::SBNWeightSyst ( const std::string &  systName)

Definition at line 47 of file SBNWeightSysts.cxx.

48  : ISyst(systName, systName),
49  fIdx(-1)
50  {
51  }
ISyst(const std::string &shortName, const std::string &latexName, bool applyPenalty=true, double min=-3, double max=+3)
Definition: ISyst.cxx:9

Member Function Documentation

SBNWeightSyst::Univs ana::SBNWeightSyst::GetUnivs ( double  x) const
protected

Definition at line 73 of file SBNWeightSysts.cxx.

74  {
75  auto it = fUnivs.find(x);
76  if(it != fUnivs.end()) return it->second;
77 
78  Univs u;
79  const UniverseOracle& uo = UniverseOracle::Instance();
80  // Neighbours
81  double x0, x1;
82  u.i0 = uo.ClosestShiftIndex(ShortName(), x, ESide::kBelow, &x0);
83 
84  if(x0 == x){
85  // Found an exact match (this is OK for small integer shifts, even with
86  // floating point comparisons
87  u.i1 = -1;
88  u.w0 = 1;
89  u.w1 = 0;
90  fUnivs[x] = u;
91  return u;
92  }
93 
94  // Otherwise we're interpolating
95  u.i1 = uo.ClosestShiftIndex(ShortName(), x, ESide::kAbove, &x1);
96  // Interpolation weights
97  u.w0 = (x1-x)/(x1-x0);
98  u.w1 = (x-x0)/(x1-x0);
99 
100  // std::cout << ShortName() << " " << x << " sigma, found indices " << u.i0 << " and " << u.i1 << " at " << x0 << " and " << x1 << ", will use weights " << u.w0 << " and " << u.w1 << std::endl;
101 
102  // If one of the neighbours wasn't found, we fall back to just using the
103  // neighbour we did find. It would probably be better to find two
104  // neighbours on the same side and extrapolate.
105  if(u.i0 == -1){u.i0 = u.i1; u.w0 = u.w1 = 0.5;}
106  if(u.i1 == -1){u.i1 = u.i0; u.w0 = u.w1 = 0.5;}
107 
108  fUnivs[x] = u;
109  return u;
110  }
process_name opflash particleana ie x
std::unordered_map< double, Univs > fUnivs
static UniverseOracle & Instance()
virtual std::string ShortName() const final
The name printed out to the screen.
Definition: ISyst.h:30
unsigned int ClosestShiftIndex(const std::string &name, double shift, ESide side=ESide::kEither, double *trueShift=0) const
Within that entry, which index corresponds most closely to &#39;shift&#39;?
void ana::SBNWeightSyst::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 54 of file SBNWeightSysts.cxx.

55  {
56  if(sr->truth.index < 0) return;
57 
59 
60  const caf::Proxy<std::vector<caf::SRMultiverse>>& wgts = sr->truth.wgt;
61  if(wgts.empty()) return;
62 
63  const Univs u = GetUnivs(x);
64 
65  double y = 0;
66  if(u.w0 != 0) y += u.w0 * wgts[fIdx].univ[u.i0];
67  if(u.w1 != 0) y += u.w1 * wgts[fIdx].univ[u.i1];
68 
69  weight *= y;
70  }
unsigned int SystIndex(const std::string &name) const
Which index in the weights array corresponds to the shifting of just this syst (in any parameter set)...
process_name opflash particleana ie x
static UniverseOracle & Instance()
virtual std::string ShortName() const final
The name printed out to the screen.
Definition: ISyst.h:30
process_name opflash particleana ie ie y
Univs GetUnivs(double x) const

Member Data Documentation

int ana::SBNWeightSyst::fIdx
mutableprotected

Definition at line 41 of file SBNWeightSysts.h.

std::unordered_map<double, Univs> ana::SBNWeightSyst::fUnivs
mutableprotected

Definition at line 49 of file SBNWeightSysts.h.


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