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

Simple record of shifts applied to systematic parameters. More...

#include <SystShifts.h>

Public Member Functions

 SystShifts ()
 
 SystShifts (const ISyst *syst, double shift)
 
 SystShifts (const std::map< const ISyst *, double > &shifts)
 
bool IsNominal () const
 
void SetShift (const ISyst *syst, double shift)
 Shifts are 0=nominal, -1,+1 = 1 sigma shifts. More...
 
double GetShift (const ISyst *syst) const
 
void ResetToNominal ()
 
double Penalty () const
 Penalty term for chi-squared fits. More...
 
void Shift (caf::SRSliceProxy *slc, double &weight) const
 
std::string ShortName () const
 Brief description of component shifts, for printing to screen. More...
 
std::string LatexName () const
 Long description of component shifts, for plot labels. More...
 
int ID () const
 SystShifts with the same set of systs should have the same ID. More...
 
std::vector< const ISyst * > ActiveSysts () const
 
void SaveTo (TDirectory *dir) const
 

Static Public Member Functions

static SystShifts Nominal ()
 
static SystShifts RandomThrow (const std::vector< const ISyst * > &systs)
 
static std::unique_ptr
< SystShifts
LoadFrom (TDirectory *dir)
 

Protected Attributes

std::unordered_map< const
ISyst *, double > 
fSysts
 
int fID
 

Static Protected Attributes

static int fgNextID = 1
 The next unused ID. More...
 

Detailed Description

Simple record of shifts applied to systematic parameters.

Definition at line 16 of file SystShifts.h.

Constructor & Destructor Documentation

ana::SystShifts::SystShifts ( )

Definition at line 20 of file SystShifts.cxx.

20  : fID(0)
21  {
22  }
ana::SystShifts::SystShifts ( const ISyst syst,
double  shift 
)

Definition at line 25 of file SystShifts.cxx.

26  : fID(fgNextID++)
27  {
28  if(shift != 0) fSysts.emplace(syst, shift);
29  }
std::unordered_map< const ISyst *, double > fSysts
Definition: SystShifts.h:54
static int fgNextID
The next unused ID.
Definition: SystShifts.h:58
shift
Definition: fcl_checks.sh:26
ana::SystShifts::SystShifts ( const std::map< const ISyst *, double > &  shifts)

Definition at line 32 of file SystShifts.cxx.

33  : fID(fgNextID++)
34  {
35  for(auto it: shifts) if(it.second != 0) fSysts.emplace(it.first, it.second);
36  }
std::unordered_map< const ISyst *, double > fSysts
Definition: SystShifts.h:54
static int fgNextID
The next unused ID.
Definition: SystShifts.h:58

Member Function Documentation

std::vector< const ISyst * > ana::SystShifts::ActiveSysts ( ) const

Definition at line 120 of file SystShifts.cxx.

121  {
122  std::vector<const ISyst*> ret;
123  for(auto it: fSysts) ret.push_back(it.first);
124  return ret;
125  }
std::unordered_map< const ISyst *, double > fSysts
Definition: SystShifts.h:54
double ana::SystShifts::GetShift ( const ISyst syst) const

Definition at line 56 of file SystShifts.cxx.

57  {
58  assert(syst);
59 
60  auto it = fSysts.find(syst);
61  return (it == fSysts.end()) ? 0 : it->second;
62  }
std::unordered_map< const ISyst *, double > fSysts
Definition: SystShifts.h:54
int ana::SystShifts::ID ( ) const
inline

SystShifts with the same set of systs should have the same ID.

Definition at line 44 of file SystShifts.h.

44 {return fID;}
bool ana::SystShifts::IsNominal ( ) const
inline

Definition at line 26 of file SystShifts.h.

26 {return fSysts.empty();}
std::unordered_map< const ISyst *, double > fSysts
Definition: SystShifts.h:54
std::string ana::SystShifts::LatexName ( ) const

Long description of component shifts, for plot labels.

Definition at line 106 of file SystShifts.cxx.

107  {
108  if(fSysts.empty()) return "Nominal";
109 
110  std::string ret;
111  for(auto it: fSysts){
112  if(!ret.empty()) ret += ", ";
113  ret += it.first->LatexName() + TString::Format(" = %+g", it.second).Data();
114  }
115 
116  return ret;
117  }
std::unordered_map< const ISyst *, double > fSysts
Definition: SystShifts.h:54
std::unique_ptr< SystShifts > ana::SystShifts::LoadFrom ( TDirectory *  dir)
static

Definition at line 151 of file SystShifts.cxx.

152  {
153  TObjString* tag = (TObjString*)dir->Get("type");
154  assert(tag);
155  assert(tag->GetString() == "SystShifts");
156 
157  auto ret = std::make_unique<SystShifts>();
158 
159  TH1* h = (TH1*)dir->Get("vals");
160  if(h){ // no histogram means nominal
161  for(int i = 1; i <= h->GetNbinsX(); ++i){
162  ret->SetShift(SystRegistry::ShortNameToSyst(h->GetXaxis()->GetBinLabel(i)),
163  h->GetBinContent(i));
164  }
165  }
166 
167  return ret;
168  }
while getopts h
tuple dir
Definition: dropbox.py:28
static const ISyst * ShortNameToSyst(const std::string &s, bool allowFail=false)
static SystShifts ana::SystShifts::Nominal ( )
inlinestatic

Definition at line 23 of file SystShifts.h.

23 {return SystShifts();}
double ana::SystShifts::Penalty ( ) const

Penalty term for chi-squared fits.

Definition at line 73 of file SystShifts.cxx.

74  {
75  double ret = 0;
76  // Systematics are all expressed in terms of sigmas
77  for(auto it: fSysts) {
78  // Only apply a penalty for systematics where this has been requested
79  if (it.first->ApplyPenalty())
80  ret += util::sqr(it.second);
81  }
82  return ret;
83  }
std::unordered_map< const ISyst *, double > fSysts
Definition: SystShifts.h:54
T sqr(T x)
More efficient square function than pow(x,2)
Definition: MathUtil.h:23
SystShifts ana::SystShifts::RandomThrow ( const std::vector< const ISyst * > &  systs)
static

Definition at line 39 of file SystShifts.cxx.

40  {
41  SystShifts ret;
42  for(const ISyst* s: systs) ret.SetShift(s, gRandom->Gaus(0, 1));
43  return ret;
44  }
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
void ana::SystShifts::ResetToNominal ( )

Definition at line 65 of file SystShifts.cxx.

66  {
67  fID = 0;
68 
69  fSysts.clear();
70  }
std::unordered_map< const ISyst *, double > fSysts
Definition: SystShifts.h:54
void ana::SystShifts::SaveTo ( TDirectory *  dir) const

Definition at line 128 of file SystShifts.cxx.

129  {
130  TDirectory* tmp = gDirectory;
131 
132  dir->cd();
133  TObjString("SystShifts").Write("type");
134 
135  // Don't write any histogram for the nominal case
136  if(!fSysts.empty()){
137  TH1D h("", "", fSysts.size(), 0, fSysts.size());
138  int ibin = 0;
139  for(auto it: fSysts){
140  ++ibin;
141  h.GetXaxis()->SetBinLabel(ibin, it.first->ShortName().c_str());
142  h.SetBinContent(ibin, it.second);
143  }
144  h.Write("vals");
145  }
146 
147  tmp->cd();
148  }
std::unordered_map< const ISyst *, double > fSysts
Definition: SystShifts.h:54
while getopts h
tuple dir
Definition: dropbox.py:28
void ana::SystShifts::SetShift ( const ISyst syst,
double  shift 
)

Shifts are 0=nominal, -1,+1 = 1 sigma shifts.

Definition at line 47 of file SystShifts.cxx.

48  {
49  fID = fgNextID++;
50 
51  fSysts.erase(syst);
52  if(shift != 0) fSysts.emplace(syst, shift);
53  }
std::unordered_map< const ISyst *, double > fSysts
Definition: SystShifts.h:54
static int fgNextID
The next unused ID.
Definition: SystShifts.h:58
shift
Definition: fcl_checks.sh:26
void ana::SystShifts::Shift ( caf::SRSliceProxy slc,
double &  weight 
) const

Definition at line 86 of file SystShifts.cxx.

87  {
88  for(auto it: fSysts) it.first->Shift(it.second, sr, weight);
89  }
std::unordered_map< const ISyst *, double > fSysts
Definition: SystShifts.h:54
std::string ana::SystShifts::ShortName ( ) const

Brief description of component shifts, for printing to screen.

Definition at line 92 of file SystShifts.cxx.

93  {
94  if(fSysts.empty()) return "nominal";
95 
96  std::string ret;
97  for(auto it: fSysts){
98  if(!ret.empty()) ret += ",";
99  ret += it.first->ShortName() + TString::Format("=%+g", it.second).Data();
100  }
101 
102  return ret;
103  }
std::unordered_map< const ISyst *, double > fSysts
Definition: SystShifts.h:54

Member Data Documentation

int ana::SystShifts::fgNextID = 1
staticprotected

The next unused ID.

Definition at line 58 of file SystShifts.h.

int ana::SystShifts::fID
protected

Definition at line 56 of file SystShifts.h.

std::unordered_map<const ISyst*, double> ana::SystShifts::fSysts
protected

Definition at line 54 of file SystShifts.h.


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