Public Member Functions | Static Public Member Functions | Protected Attributes | Private Attributes | Static Private Attributes | List of all members
ana::SystShifts Class Reference

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

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-10-23/CAFAna/Core/SystShifts.h"

Inheritance diagram for ana::SystShifts:
ana::GaussianPriorSystShifts

Public Member Functions

 SystShifts ()
 
 SystShifts (const ISyst *syst, double shift)
 
 SystShifts (const ISyst *syst, stan::math::var shift)
 
 SystShifts (const std::map< const ISyst *, double > &shifts)
 
 SystShifts (const std::map< const ISyst *, stan::math::var > &shifts)
 
virtual ~SystShifts ()=default
 
int ID () const
 SystShifts with the same set of systs should have the same ID. More...
 
std::vector< const ISyst * > ActiveSysts () const
 
virtual std::unique_ptr< SystShiftsCopy () const
 
bool IsNominal () const
 
void RemoveShift (const ISyst *syst)
 
void SetShift (const ISyst *syst, double shift, bool force=false)
 
void SetShift (const ISyst *syst, stan::math::var shift)
 
template<typename T = double>
T GetShift (const ISyst *syst) const
 
void ResetToNominal ()
 
bool HasStan (const ISyst *s) const
 
bool HasAnyStan () const
 
double Penalty () const
 Penalty term for (frequentist) chi-squared fits. More...
 
virtual stan::math::var Prior () const
 
virtual stan::math::var LogPrior () const
 
void Shift (caf::SRProxy *sr, double &weight) const
 
void Shift (caf::SRNeutrinoProxy *sr, 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...
 
void SaveTo (TDirectory *dir, const std::string &name) const
 
template<>
double GetShift (const ISyst *syst) const
 
template<>
stan::math::var GetShift (const ISyst *syst) const
 

Static Public Member Functions

static SystShifts Nominal ()
 
static std::unique_ptr< SystShiftsLoadFrom (TDirectory *dir, const std::string &name)
 

Protected Attributes

std::unordered_map< const ISyst *, double > fSystsDbl
 
std::unordered_map< const ISyst *, stan::math::varfSystsStan
 

Private Attributes

int fID
 

Static Private Attributes

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

Detailed Description

Simple record of shifts applied to systematic parameters.

Definition at line 20 of file SystShifts.h.

Constructor & Destructor Documentation

ana::SystShifts::SystShifts ( )

Definition at line 27 of file SystShifts.cxx.

Referenced by Nominal().

28  : fID(fgNextID++)
29  {}
static int fgNextID
The next unused ID.
Definition: SystShifts.h:96
ana::SystShifts::SystShifts ( const ISyst syst,
double  shift 
)

Definition at line 32 of file SystShifts.cxx.

References fSystsDbl.

33  : fID(fgNextID++)
34  {
35  fSystsDbl.emplace(syst, shift);
36  }
static int fgNextID
The next unused ID.
Definition: SystShifts.h:96
std::unordered_map< const ISyst *, double > fSystsDbl
Definition: SystShifts.h:90
ana::SystShifts::SystShifts ( const ISyst syst,
stan::math::var  shift 
)

Definition at line 39 of file SystShifts.cxx.

References fSystsDbl, and fSystsStan.

40  : fID(fgNextID++)
41  {
42  fSystsStan.emplace(syst, shift);
43  // we're always going to maintain a "double" copy
44  // so that when the Stan cache gets invalidated we can still return something usable.
45  fSystsDbl.emplace(syst, util::GetValAs<double>(shift));
46  }
static int fgNextID
The next unused ID.
Definition: SystShifts.h:96
std::unordered_map< const ISyst *, stan::math::var > fSystsStan
Definition: SystShifts.h:91
std::unordered_map< const ISyst *, double > fSystsDbl
Definition: SystShifts.h:90
ana::SystShifts::SystShifts ( const std::map< const ISyst *, double > &  shifts)

Definition at line 49 of file SystShifts.cxx.

References fSystsDbl, and it.

50  : fID(fgNextID++)
51  {
52  for(auto it: shifts) fSystsDbl.emplace(it.first, it.second);
53  }
static int fgNextID
The next unused ID.
Definition: SystShifts.h:96
set< int >::iterator it
std::unordered_map< const ISyst *, double > fSystsDbl
Definition: SystShifts.h:90
ana::SystShifts::SystShifts ( const std::map< const ISyst *, stan::math::var > &  shifts)

Definition at line 56 of file SystShifts.cxx.

References fSystsDbl, fSystsStan, and it.

57  : fID(fgNextID++)
58  {
59  for(auto it: shifts)
60  {
61  fSystsStan.emplace(it.first, it.second);
62  fSystsDbl.emplace(it.first, util::GetValAs<double>(it.second));
63  }
64  }
static int fgNextID
The next unused ID.
Definition: SystShifts.h:96
set< int >::iterator it
std::unordered_map< const ISyst *, stan::math::var > fSystsStan
Definition: SystShifts.h:91
std::unordered_map< const ISyst *, double > fSystsDbl
Definition: SystShifts.h:90
virtual ana::SystShifts::~SystShifts ( )
virtualdefault

Member Function Documentation

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

Definition at line 220 of file SystShifts.cxx.

References fSystsDbl, it, and runNovaSAM::ret.

Referenced by ana::PredictionInterp::_PredictComponentSyst(), ana::DeriveFlux(), test::GetNumuPrediction(), ana::covmx::Sample::GetSystShifts(), Nominal(), ana::PlotSystShifts(), and ana::PredictionInterp::ShiftSpectrum().

221  {
222  std::vector<const ISyst*> ret;
223  for(auto it: fSystsDbl) ret.push_back(it.first);
224  return ret;
225  }
set< int >::iterator it
std::unordered_map< const ISyst *, double > fSystsDbl
Definition: SystShifts.h:90
std::unique_ptr< SystShifts > ana::SystShifts::Copy ( ) const
virtual

Allow derived classes to overload so they can copy themselves in case they overload Penalty(). Used in IFitter. Note that you own the copy...

Reimplemented in ana::GaussianPriorSystShifts.

Definition at line 67 of file SystShifts.cxx.

Referenced by ana::IFitter::FitHelper(), ana::StanFitter::FitHelperSeeded(), Nominal(), and ana::StanFitter::TestGradients().

68  {
69  return std::make_unique<SystShifts>(*this);
70  }
template<typename T = double>
T ana::SystShifts::GetShift ( const ISyst syst) const
template<>
double ana::SystShifts::GetShift ( const ISyst syst) const

Definition at line 112 of file SystShifts.cxx.

References ana::assert(), fSystsDbl, and it.

113  {
114  assert(syst);
115 
116  auto it = fSystsDbl.find(syst);
117  return (it == fSystsDbl.end()) ? 0 : it->second;
118  }
set< int >::iterator it
std::unordered_map< const ISyst *, double > fSystsDbl
Definition: SystShifts.h:90
assert(nhit_max >=nhit_nbins)
template<>
stan::math::var ana::SystShifts::GetShift ( const ISyst syst) const

Definition at line 122 of file SystShifts.cxx.

References ana::assert(), om::cout, allTimeWatchdog::endl, fSystsDbl, fSystsStan, it, ana::ISyst::ShortName(), and PandAna.Demos.tute_pid_validation::var.

123  {
124  assert(syst);
125 
126  auto it = fSystsStan.find(syst);
127  //assert ( (it == fSystsStan.end()) == (fSystsDbl.find(syst) == fSystsDbl.end()) ); // if you're asking for a Stan syst, and it's not there but a double one is, something went wrong
128  if (it == fSystsStan.end())
129  {
130  auto itDbl = fSystsDbl.find(syst);
131  if (itDbl != fSystsDbl.end())
132  {
133  std::cout << "Warning: creating stan::math::var out of double value for syst '" << syst->ShortName() << "'." << std::endl;
134  std::cout << " If you see this repeatedly, it's likely a problem. (A few times during startup is probably harmless.)" << std::endl;
135  fSystsStan[syst] = stan::math::var(itDbl->second);
136  it = fSystsStan.find(syst);
137  }
138  }
139  return (it == fSystsStan.end()) ? 0 : it->second;
140  }
set< int >::iterator it
std::unordered_map< const ISyst *, stan::math::var > fSystsStan
Definition: SystShifts.h:91
std::unordered_map< const ISyst *, double > fSystsDbl
Definition: SystShifts.h:90
OStream cout
Definition: OStream.cxx:6
assert(nhit_max >=nhit_nbins)
bool ana::SystShifts::HasAnyStan ( ) const
inline

Definition at line 64 of file SystShifts.h.

References fSystsStan, and Penalty().

Referenced by ana::PredictionInterp::ShiftBins(), and ana::PredictionInterp::ShiftSpectrum().

64 {return !fSystsStan.empty();}
std::unordered_map< const ISyst *, stan::math::var > fSystsStan
Definition: SystShifts.h:91
bool ana::SystShifts::HasStan ( const ISyst s) const
inline

Definition at line 63 of file SystShifts.h.

References fSystsStan.

Referenced by ana::MultiExperiment::ApplySystCorrs(), and ana::PredictionInterp::ShiftBins().

63 {return fSystsStan.count(s);}
std::unordered_map< const ISyst *, stan::math::var > fSystsStan
Definition: SystShifts.h:91
const XML_Char * s
Definition: expat.h:262
int ana::SystShifts::ID ( ) const
inline

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

Definition at line 32 of file SystShifts.h.

References fID.

Referenced by ana::SpectrumLoaderBase::GetSinkSCW().

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

Definition at line 43 of file SystShifts.h.

References fSystsDbl, GetShift(), RemoveShift(), ResetToNominal(), SetShift(), and T.

Referenced by ana::CovMxExperiment::ChiSq(), ana::DataMCComparison(), LatexName(), ana::IPrediction::PredictComponentSyst(), ana::IPrediction::PredictSyst(), ana::PredictionInterp::ShiftSpectrum(), and ShortName().

43 {return fSystsDbl.empty(); } // since there's always a 'double' copy of any stan ones too
std::unordered_map< const ISyst *, double > fSystsDbl
Definition: SystShifts.h:90
std::string ana::SystShifts::LatexName ( ) const

Long description of component shifts, for plot labels.

Definition at line 206 of file SystShifts.cxx.

References genie::utils::style::Format(), fSystsDbl, IsNominal(), it, and runNovaSAM::ret.

Referenced by Prior().

207  {
208  if(IsNominal()) return "Nominal";
209 
211  for(auto it: fSystsDbl){
212  if(!ret.empty()) ret += ", ";
213  ret += it.first->LatexName() + TString::Format(" = %+g", it.second).Data();
214  }
215 
216  return ret;
217  }
set< int >::iterator it
bool IsNominal() const
Definition: SystShifts.h:43
std::unordered_map< const ISyst *, double > fSystsDbl
Definition: SystShifts.h:90
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
std::unique_ptr< SystShifts > ana::SystShifts::LoadFrom ( TDirectory *  dir,
const std::string &  name 
)
static

Definition at line 256 of file SystShifts.cxx.

References ana::assert(), dir, make_syst_table_plots::h, MECModelEnuComparisons::i, runNovaSAM::ret, and getGoodRuns4SAM::tag.

Referenced by plot_recoE_numu(), Prior(), and test_stanfit_withsysts().

257  {
258  dir = dir->GetDirectory(name.c_str()); // switch to subdir
259  assert(dir);
260 
261  TObjString* tag = (TObjString*)dir->Get("type");
262  assert(tag);
263  assert(tag->GetString() == "SystShifts");
264  delete tag;
265 
266  auto ret = std::make_unique<SystShifts>();
267 
268  TH1* h = (TH1*)dir->Get("vals");
269  if(h){ // no histogram means nominal
270  for(int i = 1; i <= h->GetNbinsX(); ++i){
271  ret->SetShift(Registry<ISyst>::ShortNameToPtr(h->GetXaxis()->GetBinLabel(i)),
272  h->GetBinContent(i));
273  }
274  }
275 
276  delete dir;
277 
278  return ret;
279  }
const XML_Char * name
Definition: expat.h:151
TDirectory * dir
Definition: macro.C:5
assert(nhit_max >=nhit_nbins)
static const T * ShortNameToPtr(const std::string &s, bool allowFail=false)
Definition: Registry.cxx:60
stan::math::var ana::SystShifts::LogPrior ( ) const
virtual

If it's more efficient to implement log(prior) directly, override this

Reimplemented in ana::GaussianPriorSystShifts.

Definition at line 161 of file SystShifts.cxx.

References test_ParserArtEvents::log, and Prior().

Referenced by Prior(), and ana::GaussianPriorSystShifts::Prior().

161 { return log(Prior()); }
virtual stan::math::var Prior() const
Definition: SystShifts.h:72
static SystShifts ana::SystShifts::Nominal ( )
inlinestatic

Definition at line 34 of file SystShifts.h.

References ActiveSysts(), Copy(), and SystShifts().

Referenced by ana::MultiExperiment::Add(), CAF_makeCAFSensitivities_for_FNEX(), ana::CountingExperiment::CountingExperiment(), ana::CovMxExperiment::CovMxExperiment(), demoFitContours(), demoFitSlices(), ana::Dmsq32Constraint::Dmsq32Constraint(), ana::IFitter::ExpandSeeds(), fake_future_data(), ana::FrequentistSurface::FindMinimum(), ana::FindValley(), ana::GaussianConstraint::GaussianConstraint(), ana::GetBFSystBands(), getPredictions(), getPredictions_updatedAna(), goodness_of_fit(), joint_fit_2017_contours(), joint_fit_2017_slices(), joint_fit_2018_contours(), joint_fit_2018_slices(), joint_fit_2019_bestfit(), joint_fit_2019_contours(), joint_fit_2019_slices(), joint_fit_future_bestfit_univ(), joint_fit_future_contour_univ(), jointsensitivity(), make_fc_mass_and_oct_nersc_2018(), make_fc_mass_and_oct_nersc_2019(), make_fc_mh_nersc_2018(), make_fc_mh_nersc_2019(), make_fc_nus_surfs_nersc_2018(), make_fc_nus_surfs_nersc_2019(), make_fc_oct_nersc_2018(), make_fc_oct_nersc_2019(), make_fc_slices_nersc_2018(), make_fc_slices_nersc_2018_stats(), make_fc_slices_nersc_2019(), make_fc_surfaces_nersc_2018(), make_fc_surfaces_nersc_2018_stats(), make_fc_surfaces_nersc_2019(), make_nus17_fc_surfs(), MakeCAFSensitivities_for_FNEX(), makeMatrixElementSurface(), MakeSurface(), MakeSurfaceBinningStudy(), MakeSurfaceJoint(), MakeSurfaceLLTest(), MakeSurfaceNoNDOsc(), Nus18SystsNeutronLoad(), Plotting_DataAndPrediction(), ana::PredictionCombinePeriods::PredictComponent(), ana::Profile(), reach_2018_dCPfractions(), ana::ReactorExperiment::ReactorExperiment(), run_joint_fit_2020_bestfit(), run_joint_fit_2020_contours(), run_joint_fit_2020_slices(), sensitivity2018(), sensitivity2020(), SetBestFitParams(), ana::T2KToyExperiment::SetPOTAnti(), ana::SingleSampleExperiment::SingleSampleExperiment(), ana::Ssth23Constraint::Ssth23Constraint(), test_numupred2017(), Tutorial2019Fit(), Tutorial2019FitContours(), Tutorial2019FitSlices(), ana::covmx::CovarianceMatrix::~CovarianceMatrix(), and ana::LikelihoodCovMxExperiment::~LikelihoodCovMxExperiment().

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

Penalty term for (frequentist) chi-squared fits.

Definition at line 152 of file SystShifts.cxx.

References fSystsDbl, it, and runNovaSAM::ret.

Referenced by HasAnyStan().

153  {
154  double ret = 0;
155  // Systematics are all expressed in terms of sigmas
156  for(auto it: fSystsDbl) ret += it.second * it.second;
157  return ret;
158  }
set< int >::iterator it
std::unordered_map< const ISyst *, double > fSystsDbl
Definition: SystShifts.h:90
virtual stan::math::var ana::SystShifts::Prior ( ) const
inlinevirtual

Prior used in Bayesian fitting. Override as needed. If it's more efficient to calculate log(prior) explicitly, override LogPrior() as well

Reimplemented in ana::GaussianPriorSystShifts.

Definition at line 72 of file SystShifts.h.

References dir, LatexName(), LoadFrom(), LogPrior(), SaveTo(), Shift(), ShortName(), sr, and ana::weight.

Referenced by LogPrior().

72 { return 1.; }
void ana::SystShifts::RemoveShift ( const ISyst syst)

Remove a shift from the systs, regardless of whether it's a double or stan::math::var shift. (The double ones can be eliminated by SetShift(syst, 0), but the stan::math::var ones can't.)

Definition at line 73 of file SystShifts.cxx.

References fSystsDbl, and fSystsStan.

Referenced by ana::PredictionAddRock::_PredictComponentSyst(), ana::MultiExperiment::ApplySystCorrs(), IsNominal(), and ana::SingleSampleExperiment::PredHistIncCosmics().

74  {
75  fSystsStan.erase(syst);
76  fSystsDbl.erase(syst);
77  }
std::unordered_map< const ISyst *, stan::math::var > fSystsStan
Definition: SystShifts.h:91
std::unordered_map< const ISyst *, double > fSystsDbl
Definition: SystShifts.h:90
void ana::SystShifts::ResetToNominal ( )

Definition at line 143 of file SystShifts.cxx.

References fID, fSystsDbl, and fSystsStan.

Referenced by CAF_makeCAFSensitivities_for_FNEX(), demoFitContours(), demoFitSlices(), fake_future_data(), goodness_of_fit(), IsNominal(), joint_fit_2017_contours(), joint_fit_2017_slices(), joint_fit_2018_contours(), joint_fit_2018_slices(), joint_fit_2019_bestfit(), joint_fit_2019_contours(), joint_fit_2019_slices(), joint_fit_future_bestfit_univ(), joint_fit_future_contour_univ(), make_fc_mass_and_oct_nersc_2018(), make_fc_mass_and_oct_nersc_2019(), make_fc_mh_nersc_2018(), make_fc_oct_nersc_2018(), make_fc_oct_nersc_2019(), make_fc_slices_nersc_2018(), make_fc_slices_nersc_2018_stats(), make_fc_slices_nersc_2019(), make_fc_surfaces_2020(), make_fc_surfaces_2020_validation(), make_fc_surfaces_nersc_2018(), make_fc_surfaces_nersc_2018_stats(), make_fc_surfaces_nersc_2019(), make_mass_and_oct_fc_input_2019(), MakeCAFSensitivities_for_FNEX(), reach_2018_dCPfractions(), run_joint_fit_2020_bestfit(), run_joint_fit_2020_contours(), run_joint_fit_2020_slices(), test_stanfit_dummy(), test_stanfit_systpulls(), Tutorial2019Fit(), Tutorial2019FitContours(), and Tutorial2019FitSlices().

144  {
145  fID = 0;
146 
147  fSystsDbl.clear();
148  fSystsStan.clear();
149  }
std::unordered_map< const ISyst *, stan::math::var > fSystsStan
Definition: SystShifts.h:91
std::unordered_map< const ISyst *, double > fSystsDbl
Definition: SystShifts.h:90
void ana::SystShifts::SaveTo ( TDirectory *  dir,
const std::string &  name 
) const

Definition at line 228 of file SystShifts.cxx.

References dir, fSystsDbl, make_syst_table_plots::h, make_syst_table_plots::ibin, it, and tmp.

Referenced by joint_fit_2019_bestfit(), Prior(), run_joint_fit_2020_bestfit(), and mcmc::SaveToFile().

229  {
230  TDirectory* tmp = gDirectory;
231 
232  dir = dir->mkdir(name.c_str()); // switch to subdir
233  dir->cd();
234 
235  TObjString("SystShifts").Write("type");
236 
237  // Don't write any histogram for the nominal case
238  if(!fSystsDbl.empty()){
239  TH1D h("", "", fSystsDbl.size(), 0, fSystsDbl.size());
240  int ibin = 0;
241  for(auto it: fSystsDbl){
242  ++ibin;
243  h.GetXaxis()->SetBinLabel(ibin, it.first->ShortName().c_str());
244  h.SetBinContent(ibin, it.second);
245  }
246  h.Write("vals");
247  }
248 
249  dir->Write();
250  delete dir;
251 
252  tmp->cd();
253  }
const XML_Char * name
Definition: expat.h:151
set< int >::iterator it
Float_t tmp
Definition: plot.C:36
std::unordered_map< const ISyst *, double > fSystsDbl
Definition: SystShifts.h:90
TDirectory * dir
Definition: macro.C:5
void ana::SystShifts::SetShift ( const ISyst syst,
double  shift,
bool  force = false 
)

shift: 0 = nominal; +-1 = 1sigma shifts etc. Arbitrary shifts allowed set force=true to insert a syst even if the shift is 0

Definition at line 80 of file SystShifts.cxx.

References om::cerr, allTimeWatchdog::endl, fgNextID, fID, fSystsDbl, fSystsStan, and ana::ISyst::ShortName().

Referenced by ana::CovMxManager::AddSystematic(), ana::MultiExperiment::ApplySystCorrs(), ana::covmx::CovarianceMatrix::BuildFullCovMx(), CalcRWithSysts(), CalcRWithSystsNus17(), demoPlotSystBands(), demoStarPlots(), DrawBins(), DrawPulls(), demo::DrawUpDownRatioCanvas(), fake_future_data(), FCContour(), fill_col(), ana::IFitter::FitHelper(), ana::MinuitFitter::FitHelperSeeded(), ana::StanFitter::FitHelperSeeded(), genie_contours(), ana::GetBFSystBands(), getPredictions(), getPredictions_updatedAna(), ana::GetShift(), ana::GetSystBands(), ana::covmx::Sample::GetSystShifts(), ana::GetSystShiftsMultiverse(), goodness_of_fit(), IsNominal(), joint_fit_2017_make_fc_slice(), joint_fit_2017_make_fc_surf(), make_fc_mass_and_oct_nersc_2018(), make_fc_mass_and_oct_nersc_2019(), make_fc_mh_nersc_2018(), make_fc_mh_nersc_2019(), make_fc_oct_nersc_2018(), make_fc_oct_nersc_2019(), make_fc_slices_nersc_2018(), make_fc_slices_nersc_2018_stats(), make_fc_slices_nersc_2019(), make_fc_surfaces_2020(), make_fc_surfaces_2020_validation(), make_fc_surfaces_nersc_2018(), make_fc_surfaces_nersc_2018_stats(), make_fc_surfaces_nersc_2019(), make_starplots(), make_xsec_wgts_2018_hists(), MakeFakeData(), MakeSystRatios(), MatrixValidation(), mec_tuning(), mec_tuning_fitter_2020(), mec_tuning_preds_2020(), MichelDecompTest(), nuebar_signif(), plot_datapredictions(), plot_predictions(), plot_recoE_numu(), plotDataPred(), plotDataPred_SplitCanvas(), PlotSysts(), Plotting_DataAndPrediction(), ana::PlotWithAreaSystErrorBand(), ana::PlotWithSystErrorBand(), ana::PlotWithSystErrorBand_Quant(), pred_err(), ana::PredictionInterp::PredictionInterp(), SetBestFitParams(), SetShift(), starPlot(), syst_test(), test_stanfit_dummy(), test_stanfit_systpulls(), TestPred(), and ThrowFakeData().

81  {
82  fID = fgNextID++;
83 
84  // if this slot already exists in the Stan systs, and we're not setting the same value,
85  // some shenanigans are going on that we need to figure out. abort.
86  auto itStan = fSystsStan.find(syst);
87  if(itStan != fSystsStan.end() && itStan->second != shift)
88  {
89  std::cerr << "Error Syst '" << syst->ShortName() << " already has a Stan pull set (" << itStan->second << ") "
90  << "and you're trying to set a different double one (" << shift << ")." << std::endl;
91  std::cerr << "You almost certainly didn't mean to do that." << std::endl;
92  std::cerr << "Abort." << std::endl;
93  abort();
94  }
95 
96  fSystsDbl.erase(syst);
97  if(force || shift != 0.) fSystsDbl.emplace(syst, shift);
98  }
static int fgNextID
The next unused ID.
Definition: SystShifts.h:96
std::unordered_map< const ISyst *, stan::math::var > fSystsStan
Definition: SystShifts.h:91
OStream cerr
Definition: OStream.cxx:7
std::unordered_map< const ISyst *, double > fSystsDbl
Definition: SystShifts.h:90
void ana::SystShifts::SetShift ( const ISyst syst,
stan::math::var  shift 
)

Definition at line 101 of file SystShifts.cxx.

References fSystsStan, and SetShift().

102  {
103  fSystsStan.erase(syst);
104  // note: _always_ put the syst in, even if the value is 0.
105  // autodiff relies on the calculation happening so as to get the gradient
106  fSystsStan.emplace(syst, shift);
107  SetShift(syst, util::GetValAs<double>(shift), true);
108  }
std::unordered_map< const ISyst *, stan::math::var > fSystsStan
Definition: SystShifts.h:91
void SetShift(const ISyst *syst, double shift, bool force=false)
Definition: SystShifts.cxx:80
void ana::SystShifts::Shift ( caf::SRProxy sr,
double &  weight 
) const

Definition at line 164 of file SystShifts.cxx.

References om::cout, allTimeWatchdog::endl, fSystsDbl, it, and w.

Referenced by ana::GetWeightFromShifts(), jw::GetWeightFromShifts(), ana::SystApplier::HandleRecord(), and Prior().

166  {
167  // always fSystsDbl here because this is only used in the event loop, not in fitting
168  // (so the autodiff'd version is not needed)
169  for(auto it: fSystsDbl){
170  double w = 1;
171  it.first->Shift(it.second, sr, w);
172  if(w < 0){
173  std::cout << "SystShifts: Got negative weight " << w
174  << " while shifting "
175  << it.first->ShortName()
176  << " to " << it.second << " sigma " << std::endl;
177  abort();
178  }
179  weight *= w;
180  }
181  }
set< int >::iterator it
const Var weight
std::unordered_map< const ISyst *, double > fSystsDbl
Definition: SystShifts.h:90
OStream cout
Definition: OStream.cxx:6
Float_t w
Definition: plot.C:20
void ana::SystShifts::Shift ( caf::SRNeutrinoProxy sr,
double &  weight 
) const

Definition at line 184 of file SystShifts.cxx.

References fSystsDbl, and it.

185  {
186  // always fSystsDbl here because this is only used in the event loop, not in fitting
187  // (so the autodiff'd version is not needed)
188  for(auto it: fSystsDbl) it.first->TruthShift(it.second, nu, weight);
189  }
set< int >::iterator it
const Var weight
std::unordered_map< const ISyst *, double > fSystsDbl
Definition: SystShifts.h:90
std::string ana::SystShifts::ShortName ( ) const

Brief description of component shifts, for printing to screen.

Definition at line 192 of file SystShifts.cxx.

References genie::utils::style::Format(), fSystsDbl, IsNominal(), it, and runNovaSAM::ret.

Referenced by ana::SystApplier::HandleRecord(), and Prior().

193  {
194  if(IsNominal()) return "nominal";
195 
197  for(auto it: fSystsDbl){
198  if(!ret.empty()) ret += ",";
199  ret += it.first->ShortName() + TString::Format("=%+g", it.second).Data();
200  }
201 
202  return ret;
203  }
set< int >::iterator it
bool IsNominal() const
Definition: SystShifts.h:43
std::unordered_map< const ISyst *, double > fSystsDbl
Definition: SystShifts.h:90
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154

Member Data Documentation

int ana::SystShifts::fgNextID = 1
staticprivate

The next unused ID.

Definition at line 96 of file SystShifts.h.

Referenced by SetShift().

int ana::SystShifts::fID
private

Definition at line 94 of file SystShifts.h.

Referenced by ID(), ResetToNominal(), and SetShift().

std::unordered_map<const ISyst*, double> ana::SystShifts::fSystsDbl
protected
std::unordered_map<const ISyst*, stan::math::var> ana::SystShifts::fSystsStan
mutableprotected

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