Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ana::NuISyst Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-11-28/CAFAna/Systs/CovMxSysts.h"

Inheritance diagram for ana::NuISyst:
ana::ISyst ana::NCSyst ana::NueSyst ana::NumuSyst

Public Member Functions

 NuISyst (std::string name, std::string label, std::string sample_name="", std::map< int, std::pair< TH1 *, TH1 * > > shifts={})
 
 ~NuISyst ()
 
std::string SampleName () const
 
std::string BaseName () const
 Return base name of systematic. More...
 
virtual void SaveTo (TDirectory *dir) const
 SaveTo implementation for NuISyst. More...
 
virtual const std::stringShortName () const final
 The name printed out to the screen. More...
 
virtual const std::stringLatexName () const final
 The name used on plots (ROOT's TLatex syntax) More...
 
virtual void Shift (double sigma, caf::SRProxy *sr, double &weight) const
 Perform the systematic shift. More...
 
virtual void TruthShift (double sigma, caf::SRNeutrinoProxy *nu, double &weight) const
 
virtual bool IsGenieReweight () const
 GENIE reweights can only provide +/-1,2sigma. More...
 

Protected Member Functions

virtual double WeightFor (SystChannel channel, double sigma, double calE) const
 Get weight for a given energy, channel and sigma shift. More...
 

Protected Attributes

std::string fSampleName
 
std::map< int, std::pair< TH1 *, TH1 * > > fShifts
 

Detailed Description

Definition at line 19 of file CovMxSysts.h.

Constructor & Destructor Documentation

ana::NuISyst::NuISyst ( std::string  name,
std::string  label,
std::string  sample_name = "",
std::map< int, std::pair< TH1 *, TH1 * > >  shifts = {} 
)

Definition at line 24 of file CovMxSysts.cxx.

25  :
26  ISyst(name, label),
27  fSampleName(sampleName),
28  fShifts(shifts)
29  {}
const XML_Char * name
Definition: expat.h:151
const char * label
std::string fSampleName
Definition: CovMxSysts.h:31
std::map< int, std::pair< TH1 *, TH1 * > > fShifts
Definition: CovMxSysts.h:32
ISyst(const std::string &shortName, const std::string &latexName)
Definition: ISyst.cxx:10
ana::NuISyst::~NuISyst ( )

Definition at line 32 of file CovMxSysts.cxx.

References fShifts.

32  {
33 
34  // Clean up the weight histograms
35  for (auto shift : fShifts) {
36  if (shift.second.first) delete shift.second.first;
37  if (shift.second.second) delete shift.second.second;
38  }
39 
40  } // NuISyst destructor
std::map< int, std::pair< TH1 *, TH1 * > > fShifts
Definition: CovMxSysts.h:32

Member Function Documentation

string ana::NuISyst::BaseName ( ) const

Return base name of systematic.

Definition at line 44 of file CovMxSysts.cxx.

References fSampleName, and ana::ISyst::ShortName().

44  {
45  if (fSampleName.empty()) return ShortName(); // If there's no sample prefix to remove
46  return ShortName().substr(fSampleName.size()+1);
47  }
virtual const std::string & ShortName() const final
The name printed out to the screen.
Definition: ISyst.h:27
std::string fSampleName
Definition: CovMxSysts.h:31
virtual bool ana::ISyst::IsGenieReweight ( ) const
inlinevirtualinherited

GENIE reweights can only provide +/-1,2sigma.

Reimplemented in ana::SummedSyst.

Definition at line 56 of file ISyst.h.

56 {return false;}
virtual const std::string& ana::ISyst::LatexName ( ) const
inlinefinalvirtualinherited

The name used on plots (ROOT's TLatex syntax)

Definition at line 30 of file ISyst.h.

References ana::ISyst::fLatexName, ana::ISyst::Shift(), sigma(), sr, and ana::weight.

Referenced by ana::PredictionInterp::DebugPlotColz(), GetGENIEShiftLabels(), SaveTo(), SystsGENIEAna(), and WriteSystName().

30 {return fLatexName;}
std::string fLatexName
Definition: ISyst.h:60
std::string ana::NuISyst::SampleName ( ) const
inline

Definition at line 25 of file CovMxSysts.h.

References dir, ana::SaveTo(), sigma(), and string.

25 { return fSampleName; };
std::string fSampleName
Definition: CovMxSysts.h:31
void ana::NuISyst::SaveTo ( TDirectory *  dir) const
virtual

SaveTo implementation for NuISyst.

Reimplemented in ana::NueSyst, ana::NCSyst, and ana::NumuSyst.

Definition at line 51 of file CovMxSysts.cxx.

References fSampleName, fShifts, ana::ISyst::LatexName(), ana::ISyst::ShortName(), sigma(), tmp, and Write().

Referenced by ana::NumuSyst::SaveTo(), ana::NCSyst::SaveTo(), and ana::NueSyst::SaveTo().

51  {
52 
53  TDirectory* tmp = gDirectory;
54  dir->cd();
55  TObjString(ShortName().c_str()).Write("name");
56  TObjString(LatexName().c_str()).Write("label");
57  TObjString(fSampleName.c_str()).Write("samplename");
58  TDirectory* sigmasDir = dir->mkdir("Sigmas");
59 
60  // Save each shift
61  for (auto const& sigma : fShifts) {
62 
63  TDirectory* sigmaDir = sigmasDir->mkdir(Form("Sigma%d", sigma.first));
64 
65  // Save sigma value
66  TVectorD vSigma(1);
67  vSigma[0] = sigma.first;
68  sigmaDir->WriteTObject(&vSigma, "sigma");
69 
70  // Save shift histograms
71  sigmaDir->WriteTObject(sigma.second.first, "sig");
72  sigmaDir->WriteTObject(sigma.second.second, "bkg");
73  }
74  tmp->cd();
75 
76  } // function NuISyst::SaveTo
virtual const std::string & ShortName() const final
The name printed out to the screen.
Definition: ISyst.h:27
Float_t tmp
Definition: plot.C:36
std::string fSampleName
Definition: CovMxSysts.h:31
double sigma(TH1F *hist, double percentile)
virtual const std::string & LatexName() const final
The name used on plots (ROOT&#39;s TLatex syntax)
Definition: ISyst.h:30
TDirectory * dir
Definition: macro.C:5
std::map< int, std::pair< TH1 *, TH1 * > > fShifts
Definition: CovMxSysts.h:32
gm Write()
void ana::ISyst::Shift ( double  sigma,
caf::SRProxy sr,
double &  weight 
) const
virtualinherited

Perform the systematic shift.

Override this function if your systematic depends on non-SRNeutrino quantities. If it is SRNeutrino-only, implement the other function, and let this default forward to you when necessary.

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

Reimplemented in ana::MinosResSuppSyst, ana::MECDoubleGaussEnhSystDOWN, ana::MECDoubleGaussEnhSystUP, ana::MECDoubleGaussEnhSyst, ana::MECGaussEnhSyst, ana::MECDoubleGaussEnhSystNux, jw::MECInitStateNPFracShift, jw::CompNormSyst, ana::CompNormSyst, ana::BolombMuESyst2019, ana::DISHighWScaleSyst, ana::ContainmentSyst, ana::PileupMuESyst2019, ana::PileupMuESyst2020, ana::NumuRelEnergyScaleSyst, ana::RockMuonNormSyst, ana::NumuEnergyScaleSyst, ana::RemIDScaleSyst, ana::UnCorrMuCatMuESyst2019, ana::LEMScaleSyst, ana::NumuRelNormSyst, ana::UnCorrMuCatMuESyst2020, demo::DemoSyst2, ana::DirectRelHadEScaleSyst2017, ana::BeamIntensitySyst, ana::NumuNormSyst, ana::Nus18BaseSyst, ana::UnCorrNDMuEScaleSyst2019, ana::KaonScaleSyst, ana::FDMuEnergyScaleSyst, ana::UnCorrNDMuEScaleSyst2020, ana::NumuTauContaminationSyst, ana::MyWrongSignScale, ana::NueAcceptSystSignalKin2020RHC, ana::DirectHadEScaleSyst2017, ana::NumuCCScaleSyst, ana::Nus18FlatSyst, ana::FDHadEnergyScaleSyst, ana::NumuNCScaleSyst, ana::NueAcceptSystSignalKin2018RHC, ana::BeamNueScaleSyst, ana::NueAcceptSystBkg2018RHC, ana::UnCorrFDMuEScaleSyst2019, ana::UnCorrFDMuEScaleSyst2020, ana::MuEnergyScaleSyst, ana::WrongSignScale100, ana::NCScaleSyst, ana::NusFlatSyst, ana::RelMuEScaleSyst2017, ana::Nus17FlatSyst, ana::Numutest, ana::NumuSummedSmallGENIESyst, ana::Nus18SystFromHist, ana::NueAcceptSystSignalKin2020FHC, ana::WrongSignEnergyBin, ana::RelNormSyst, ana::MichelTaggingSyst2018, ana::Nuetest, ana::NusAna2020TauSyst, ana::GenericSystComponentScale< T >, ana::CorrMuEScaleSyst2019, ana::CorrMuEScaleSyst2020, ana::NumuGEANTScaleSyst, ana::GenericSystComponentScale< T >, ana::HadEnergyScaleSyst, ana::NueAcceptSystSignalKin2018FHC, ana::NormSyst, ana::WrongSignEnergyBinRHC, ana::NuWROSyst, ana::GenericSystComponentScale< T >, ana::LeptonAngleSyst, ana::NueExtrapSystSignalKin2017, ana::SystFromWeight, ana::MuEScaleSyst2017, ana::NCtest, ana::NusSystFromHist, ana::NueSyst, ana::Nus17SystFromHist, ana::SummedSyst, ana::DummyNue2017Syst, ana::DummyNumu2017Syst, ana::GeniePCASyst, ana::NueAcceptSystBkg2018FHC, ana::NumuGEANTNormSyst, ana::NusAna2020KaonSyst, ana::DummyAnaSyst, ana::NeutronVisEScaleSyst2018, ana::NueExtrapSystBkg2017, ana::DummyRockScaleSyst, ana::MichelTaggingSyst2020, ana::CosmicBkgScaleSyst, ana::WrongSignScale, ana::WrongSignContamination, ana::NCSyst, and ana::NumuSyst.

Definition at line 26 of file ISyst.cxx.

References caf::Proxy< caf::StandardRecord >::mc, caf::Proxy< caf::SRTruthBranch >::nnu, caf::Proxy< caf::SRTruthBranch >::nu, and ana::ISyst::TruthShift().

Referenced by fnex::CAFToEventList::FillMCVarVals(), ana::ISyst::LatexName(), and ana::GenericSystComponentScale< T >::Shift().

27  {
28  // Override this function if your systematic depends on non-SRNeutrino
29  // quantities. If it is SRNeutrino-only, implement the other function,
30  // and let this default forward to you when necessary.
31  if(sr->mc.nnu > 0) TruthShift(sigma, &sr->mc.nu[0], weight);
32  }
const Var weight
caf::Proxy< std::vector< caf::SRNeutrino > > nu
Definition: SRProxy.h:618
caf::Proxy< short int > nnu
Definition: SRProxy.h:617
virtual void TruthShift(double sigma, caf::SRNeutrinoProxy *nu, double &weight) const
Definition: ISyst.h:46
double sigma(TH1F *hist, double percentile)
caf::Proxy< caf::SRTruthBranch > mc
Definition: SRProxy.h:2138
virtual const std::string& ana::ISyst::ShortName ( ) const
inlinefinalvirtualinherited
virtual void ana::ISyst::TruthShift ( double  sigma,
caf::SRNeutrinoProxy nu,
double &  weight 
) const
inlinevirtualinherited

For systematics that deal only with the neutrino truth and not any reconstruction/PID details. Systematics defined this way will work on nuTree-derived spectra too (e.g. denominators of efficiencies).

Reimplemented in demo::DemoSyst1, ana::BeamSyst, ana::GenericSystComponentScale< T >, ana::GenericSystComponentScale< T >, ana::GenericSystComponentScale< T >, and ana::NOvARwgtSyst.

Definition at line 46 of file ISyst.h.

Referenced by ana::ISyst::Shift().

49  {
50  // Implement this function if your systematic depends only
51  // SRNeutrino. Left blank by default, since systematics using other
52  // information can do nothing sensible to the nuTree.
53  }
double ana::NuISyst::WeightFor ( SystChannel  channel,
double  sigma,
double  calE 
) const
protectedvirtual

Get weight for a given energy, channel and sigma shift.

Definition at line 80 of file CovMxSysts.cxx.

References ana::assert(), bin, febshutoff_auto::end, fShifts, it, ana::kSig, std::max(), and runNovaSAM::ret.

Referenced by ana::NumuSyst::Shift(), ana::NCSyst::Shift(), and ana::NueSyst::Shift().

80  {
81 
82  // If it's a one-sided shift (ie. no -1 sigma weights) then we want to return
83  // 1 for a negative sigma
84  if (sigma < 0 and not fShifts.count(-1)) return 1;
85  const int bin = fShifts.at(0).first->FindBin(calE);
86 
87  auto low = fShifts.begin();
88  auto end = fShifts.end();
89  std::advance(end, -2);
90  if (sigma < fShifts.begin()->first)
91  low = fShifts.begin();
92  else if (sigma >= end->first)
93  low = end;
94  else {
95  for (auto it = fShifts.begin(); it != end; ++it) {
96  if (sigma >= it->first) {
97  low = it;
98  break;
99  }
100  }
101  }
102 
103  auto high = low;
104  ++high;
105 
106  // // Why would we have templates differing by more than 1 sigma?
107  // // fracpart below assumes this
108  assert(high->first - low->first == 1);
109 
110  TH1* hLow = nullptr;
111  TH1* hHigh = nullptr;
112 
113  if (channel == SystChannel::kSig) {
114  hLow = low->second.first;
115  hHigh = high->second.first;
116  }
117  else {
118  hLow = low->second.second;
119  hHigh = high->second.second;
120  }
121 
122  const double fracpart = sigma - low->first;
123  const double ret = (fracpart*hHigh->GetBinContent(bin)) +
124  ((1-fracpart)*hLow->GetBinContent(bin));
125 
126  return std::max(0., ret); // Keep the LL from blowing up
127 
128  } // function NuISyst::WeightFor
T max(const caf::Proxy< T > &a, T b)
set< int >::iterator it
float bin[41]
Definition: plottest35.C:14
double sigma(TH1F *hist, double percentile)
std::map< int, std::pair< TH1 *, TH1 * > > fShifts
Definition: CovMxSysts.h:32
assert(nhit_max >=nhit_nbins)

Member Data Documentation

std::string ana::NuISyst::fSampleName
protected

Definition at line 31 of file CovMxSysts.h.

Referenced by BaseName(), and SaveTo().

std::map<int, std::pair<TH1*, TH1*> > ana::NuISyst::fShifts
protected

Definition at line 32 of file CovMxSysts.h.

Referenced by SaveTo(), WeightFor(), and ~NuISyst().


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