Namespaces | Classes | Functions | Variables
mcmc Namespace Reference

Namespaces

 config
 

Classes

struct  FileContents
 

Functions

std::vector< std::unique_ptr< ana::IExperiment > > BuildExperiments (const std::map< std::string, ana::Spectrum > &fakeData, const std::vector< ana::predictions > &preds)
 
std::unique_ptr< ana::IExperimentBuildMultiExperiment (const std::vector< const ana::IExperiment * > &expts)
 
std::map< std::string, ana::SpectrumLoadFakeData (const std::string &fakeDataFilename, const std::string &path)
 
FileContents LoadFromFile (const std::string &filename)
 
std::vector< ana::predictionsLoadPreds (bool extrap=false)
 Just wrap up all the args somewhere centralized for the moment. More...
 
void ResetCalculator (osc::IOscCalcAdjustable &calc)
 
void SaveToFile (const std::string &fileName, const ana::Spectrum *fakeData, const ana::MCMCSamples *warmup, const ana::MCMCSamples *samples, const ana::SystShifts *trueSystPulls, const osc::IOscCalcAdjustable *trueOscParams)
 
std::set< const ana::ISyst * > SupportedSysts (const ana::IExperiment *expt)
 Which systs does this experiment support? More...
 
std::string FullFilename (const std::string &dir, std::string file)
 
std::vector< std::unique_ptr< ana::IExperiment > > BuildExperiments (const std::map< std::string, ana::Spectrum > &fakeData, const std::vector< ana::predictions > &preds)
 
std::unique_ptr< ana::IExperimentBuildMultiExperiment (const std::vector< const ana::IExperiment * > &expts)
 
std::vector< const ana::IExperiment * > ExptPtrs (const std::vector< std::unique_ptr< ana::IExperiment >> &exptVector)
 
int GetRedHeatPalette ()
 

Variables

const double MOCKDATA_TH23 = 41 * TMath::DegToRad()
 
const double MOCKDATA_DM32 = 0.0024
 
const double MOCKDATA_DCP = (5./4.) * TMath::Pi()
 
const std::map< const ana::IFitVar *, std::pair< double, double > > fitVarDrawRanges
 

Function Documentation

std::vector<std::unique_ptr<ana::IExperiment> > mcmc::BuildExperiments ( const std::map< std::string, ana::Spectrum > &  fakeData,
const std::vector< ana::predictions > &  preds 
)

Definition at line 27 of file MCMC3FShared.cxx.

References om::cerr, allTimeWatchdog::endl, and runNovaSAM::ret.

Referenced by fit_3flavor_withsysts().

29  {
30  std::vector<std::unique_ptr<ana::IExperiment>> ret;
31  for (const auto & predBundle : preds)
32  {
33  if ( fakeData.find(predBundle.name) == fakeData.end() )
34  {
35  std::cerr << "Couldn't find fake data for prediction: " << predBundle.name << std::endl;
36  abort();
37  }
38 
39  if (predBundle.cos.first)
40  ret.emplace_back(std::make_unique<ana::SingleSampleExperiment>(predBundle.pred,
41  fakeData.at(predBundle.name),
42  *predBundle.cos.first,
43  predBundle.cos.second));
44  else
45  ret.emplace_back(std::make_unique<ana::SingleSampleExperiment>(predBundle.pred,
46  fakeData.at(predBundle.name)));
47  }
48 
49  return ret;
50  }
OStream cerr
Definition: OStream.cxx:7
std::vector<std::unique_ptr<ana::IExperiment> > mcmc::BuildExperiments ( const std::map< std::string, ana::Spectrum > &  fakeData,
const std::vector< ana::predictions > &  preds 
)

Referenced by FullFilename().

std::unique_ptr<ana::IExperiment> mcmc::BuildMultiExperiment ( const std::vector< const ana::IExperiment * > &  expts)

Definition at line 53 of file MCMC3FShared.cxx.

References demo5::expt, make_pair(), and SupportedSysts().

Referenced by fit_3flavor_withsysts(), and FullFilename().

54  {
55  auto multiexpt = std::make_unique<ana::MultiExperiment>();
56  std::set<const ana::ISyst*> allSysts;
57  for (const auto & expt : expts)
58  {
59  auto thisExptSysts = mcmc::SupportedSysts(expt);
60  std::copy(thisExptSysts.begin(), thisExptSysts.end(), std::inserter(allSysts, allSysts.end()));
61  }
62 
63  for (std::size_t exptIdx = 0; exptIdx < expts.size(); exptIdx++)
64  {
65  auto expt = expts[exptIdx];
66  multiexpt->Add(expt);
67 
68  auto thisExptSysts = mcmc::SupportedSysts(expt);
69  std::vector<std::pair<const ana::ISyst*, const ana::ISyst*>> correlations;
70  for (const auto & syst : allSysts)
71  {
72  if (std::find(thisExptSysts.begin(), thisExptSysts.end(), syst) == thisExptSysts.end())
73  correlations.emplace_back(std::make_pair(syst, nullptr));
74  }
75  multiexpt->SetSystCorrelations(exptIdx, correlations);
76  }
77 
78  return multiexpt;
79  }
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
Definition: DataMCLoad.C:336
expt
Definition: demo5.py:34
std::set< const ana::ISyst * > SupportedSysts(const ana::IExperiment *expt)
Which systs does this experiment support?
std::unique_ptr<ana::IExperiment> mcmc::BuildMultiExperiment ( const std::vector< const ana::IExperiment * > &  expts)

Definition at line 53 of file MCMC3FShared.cxx.

References demo5::expt, make_pair(), and SupportedSysts().

Referenced by fit_3flavor_withsysts(), and FullFilename().

54  {
55  auto multiexpt = std::make_unique<ana::MultiExperiment>();
56  std::set<const ana::ISyst*> allSysts;
57  for (const auto & expt : expts)
58  {
59  auto thisExptSysts = mcmc::SupportedSysts(expt);
60  std::copy(thisExptSysts.begin(), thisExptSysts.end(), std::inserter(allSysts, allSysts.end()));
61  }
62 
63  for (std::size_t exptIdx = 0; exptIdx < expts.size(); exptIdx++)
64  {
65  auto expt = expts[exptIdx];
66  multiexpt->Add(expt);
67 
68  auto thisExptSysts = mcmc::SupportedSysts(expt);
69  std::vector<std::pair<const ana::ISyst*, const ana::ISyst*>> correlations;
70  for (const auto & syst : allSysts)
71  {
72  if (std::find(thisExptSysts.begin(), thisExptSysts.end(), syst) == thisExptSysts.end())
73  correlations.emplace_back(std::make_pair(syst, nullptr));
74  }
75  multiexpt->SetSystCorrelations(exptIdx, correlations);
76  }
77 
78  return multiexpt;
79  }
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
Definition: DataMCLoad.C:336
expt
Definition: demo5.py:34
std::set< const ana::ISyst * > SupportedSysts(const ana::IExperiment *expt)
Which systs does this experiment support?
std::vector<const ana::IExperiment*> mcmc::ExptPtrs ( const std::vector< std::unique_ptr< ana::IExperiment >> &  exptVector)
inline

Definition at line 77 of file MCMC3FShared.h.

References calc, demo5::expt, plotROC::fileName, LoadFakeData(), LoadPreds(), path, ResetCalculator(), runNovaSAM::ret, ana::SaveToFile(), string, and PandAna.Demos.pi0_spectra::transform.

Referenced by fit_3flavor_withsysts().

78  {
79  std::vector<const ana::IExperiment*> ret;
80  std::transform(exptVector.begin(), exptVector.end(), std::back_inserter(ret),
81  [](const std::unique_ptr<ana::IExperiment>& expt){ return expt.get(); });
82  return std::move(ret);
83  }
expt
Definition: demo5.py:34
std::string mcmc::FullFilename ( const std::string dir,
std::string  file 
)
inline

Definition at line 53 of file MCMC3FShared.h.

References BuildExperiments(), BuildMultiExperiment(), demo5::expt, file, shutoffs::filename, ana::LoadFromFile(), string, and SupportedSysts().

Referenced by fit_3flavor_withsysts(), and plot_3flavor_withsysts().

54  {
55  if (!dir.empty())
56  file = dir + "/" + file;
57 
58  return file;
59  }
TDirectory * dir
Definition: macro.C:5
TFile * file
Definition: cellShifts.C:17
int mcmc::GetRedHeatPalette ( )

Definition at line 36 of file plot_3flavor_withsysts.C.

References rootlogon::blue, colors, rootlogon::green, MECModelEnuComparisons::i, rootlogon::NRGBs, and rootlogon::stops.

Referenced by plot_3flavor_withsysts().

37  {
38  const int NRGBs = 9;
39  const int n_color_contours = 999;
40  static bool initialized=false;
41  static int* colors=new int[n_color_contours];
42  static int colmin = 0;
43 
44  if(!initialized){
45  // White -> red
46  Double_t stops[NRGBs] = { 0.00, 0.125, 0.250, 0.375, 0.500, 0.625, 0.750, 0.875, 1.000};
47  Double_t red[NRGBs] = { 1.00, 1.00, 0.99, 0.99, 0.98, 0.94, 0.80, 0.65, 0.40 };
48  Double_t green[NRGBs] = { 0.96, 0.88, 0.73, 0.57, 0.42, 0.23, 0.09, 0.06, 0.00 };
49  Double_t blue[NRGBs] = { 0.94, 0.82, 0.63, 0.45, 0.29, 0.17, 0.11, 0.08, 0.05 };
50  colmin=TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, n_color_contours);
51  for(uint i=0; i<n_color_contours; ++i) colors[i]=colmin+i;
52 
53  initialized=true;
54  }
55 
56  return colmin;
57  }
int colors[6]
Definition: tools.h:1
tuple blue
Definition: rootlogon.py:65
int NRGBs
Definition: rootlogon.py:77
unsigned int uint
std::map< std::string, ana::Spectrum > mcmc::LoadFakeData ( const std::string fakeDataFilename,
const std::string path 
)

Definition at line 84 of file MCMC3FShared.cxx.

References om::cerr, om::cout, allTimeWatchdog::endl, genie::utils::xml::GetString(), findDuplicateFiles::key, runNovaSAM::ret, and cvnie::subdir.

Referenced by BestFit(), DrawSurface(), ExptPtrs(), fit_3flavor_withsysts(), MakeSurface(), MakeSurfaceLLTest(), MakeSurfaceNoNDOsc(), and plot_3flavor_withsysts().

85  {
86  std::map<std::string, ana::Spectrum> ret;
87 
88  std::cout << "loading from fake data file: " << fakeDataFilename << std::endl;
89  TFile inF(fakeDataFilename.c_str());
90  if (inF.IsZombie())
91  abort();
92 
93  TDirectory * workDir = &inF;
94  if (!path.empty())
95  workDir = inF.GetDirectory(path.c_str());
96  if (!workDir)
97  {
98  std::cerr << "Couldn't open path '" << path << "' in file: '" << inF.GetName() << std::endl;
99  abort();
100  }
101 
102  for (const auto & k : *workDir->GetListOfKeys())
103  {
104  auto key = dynamic_cast<TKey*>(k);
105  auto subdir = dynamic_cast<TDirectory*>(key->ReadObj());
106  if (!subdir)
107  continue;
108 
109  if (!subdir->Get("type")
110  || dynamic_cast<TObjString*>(subdir->Get("type"))->GetString() != "Spectrum")
111  continue;
112 
113  std::cout << "Loading fake data spectrum: '" << key->GetName() << "'" << std::endl;
114  auto spec = ana::LoadFrom<ana::Spectrum>(workDir, key->GetName());
115  if (spec)
116  ret.emplace(std::piecewise_construct,
117  std::forward_as_tuple(key->GetName()),
118  std::forward_as_tuple(*spec.release()));
119  }
120 
121  return ret;
122  }
subdir
Definition: cvnie.py:7
OStream cerr
Definition: OStream.cxx:7
OStream cout
Definition: OStream.cxx:6
const std::string path
Definition: plot_BEN.C:43
string GetString(xmlDocPtr xml_doc, string node_path)
FileContents mcmc::LoadFromFile ( const std::string filename)

Definition at line 126 of file MCMC3FShared.cxx.

References mcmc::config::FAKE_DATA_LABEL, inf, mcmc::config::SAMPLES_LABEL, mcmc::config::SYST_PULLS_LABEL, mcmc::config::TRUE_OSC_LABEL, and mcmc::config::WARMUP_LABEL.

Referenced by plot_3flavor_withsysts(), plot_cont_expfriends(), and plotContProf().

127  {
128  TFile inf(filename.c_str());
129  if (inf.IsZombie())
130  return {};
131 
132  std::unique_ptr<ana::Spectrum> fakeData;
133  if (inf.Get(config::FAKE_DATA_LABEL.c_str()))
134  fakeData = ana::LoadFrom<ana::Spectrum>(&inf, config::FAKE_DATA_LABEL);
135  std::unique_ptr<ana::MCMCSamples> warmup, samples;
136  if (inf.Get(config::WARMUP_LABEL.c_str()))
137  warmup = ana::LoadFrom<ana::MCMCSamples>(&inf, config::WARMUP_LABEL);
138  if (inf.Get(config::SAMPLES_LABEL.c_str()))
139  samples = ana::LoadFrom<ana::MCMCSamples>(&inf, config::SAMPLES_LABEL);
140  std::unique_ptr<ana::SystShifts> systTruePulls;
141  if (inf.Get(config::SYST_PULLS_LABEL.c_str()))
142  systTruePulls = ana::LoadFrom<ana::SystShifts>(&inf, config::SYST_PULLS_LABEL);
143  std::unique_ptr<osc::IOscCalcAdjustable> trueOscCalc;
144  if (inf.Get(config::TRUE_OSC_LABEL.c_str()))
145  trueOscCalc = ana::LoadFrom<osc::IOscCalcAdjustable>(&inf, config::TRUE_OSC_LABEL);
146 
147  return FileContents
148  {
149  std::move(fakeData),
150  std::move(warmup),
151  std::move(samples),
152  std::move(systTruePulls),
153  std::move(trueOscCalc)
154  };
155  }
TFile * inf
Definition: drawXsec.C:1
string filename
Definition: shutoffs.py:106
const std::string FAKE_DATA_LABEL
Definition: MCMC3FShared.h:45
const std::string SYST_PULLS_LABEL
Definition: MCMC3FShared.h:47
const std::string SAMPLES_LABEL
Definition: MCMC3FShared.h:46
const std::string TRUE_OSC_LABEL
Definition: MCMC3FShared.h:48
const std::string WARMUP_LABEL
Definition: MCMC3FShared.h:49
std::vector< ana::predictions > mcmc::LoadPreds ( bool  extrap)

Just wrap up all the args somewhere centralized for the moment.

Definition at line 158 of file MCMC3FShared.cxx.

References om::cerr, allTimeWatchdog::endl, and ana::LoadPredictions().

Referenced by ExptPtrs(), fit_3flavor_withsysts(), and plot_3flavor_withsysts().

159  {
160  if (extrap)
161  std::cerr << "MCMC3FShared.cxx::LoadPreds(): Warning: extrapolated predictions not implemented yet" << std::endl;
162  return ana::LoadPredictions(true /* load systs? */,
163  false, /* on grid? --> not actually used currently */
164  extrap ? "combo" : "noextrap", /* decomp desired. empty string means default: full |pt| extrap.
165  can indicate no-|pt| using "noPt".
166  combine this with "noextrap", "combo", or "prop"
167  to specify nue decomp if desired */
168  true, /* load nue predictions? */
169  true, /* load numu predictions? */
170  true, /* load FHC predictions? */
171  true, /* load RHC predictions? */
172  false //, /* running on NERSC? */
173 // extrap
174  );
175 
176  }
OStream cerr
Definition: OStream.cxx:7
std::vector< predictions > LoadPredictions(bool corrSysts=false, bool runOnGrid=false, std::string decomp="", bool nue=true, bool numu=true, bool fhc=true, bool rhc=true, bool NERSC=false)
void mcmc::ResetCalculator ( osc::IOscCalcAdjustable calc)

Definition at line 180 of file MCMC3FShared.cxx.

References std::asin(), e, osc::_IOscCalcAdjustable< T >::SetdCP(), osc::_IOscCalcAdjustable< T >::SetDmsq21(), osc::_IOscCalcAdjustable< T >::SetDmsq32(), osc::_IOscCalcAdjustable< T >::SetL(), osc::_IOscCalcAdjustable< T >::SetRho(), osc::_IOscCalcAdjustable< T >::SetTh12(), osc::_IOscCalcAdjustable< T >::SetTh13(), osc::_IOscCalcAdjustable< T >::SetTh23(), and std::sqrt().

Referenced by ExptPtrs(), fit_3flavor_withsysts(), and plot_3flavor_withsysts().

181  {
182  calc.SetL(810);
183  calc.SetRho(2.75);
184  calc.SetDmsq21(7.6e-5);
185  calc.SetDmsq32(2.5e-3);
186  calc.SetTh12(asin(sqrt(.87))/2);
187  calc.SetTh13(asin(sqrt(.10))/2);
188  calc.SetTh23(TMath::Pi() / 4);
189  calc.SetdCP(0);
190  }
virtual void SetL(double L)=0
virtual void SetDmsq21(const T &dmsq21)=0
T sqrt(T number)
Definition: d0nt_math.hpp:156
virtual void SetTh13(const T &th13)=0
virtual void SetDmsq32(const T &dmsq32)=0
virtual void SetRho(double rho)=0
virtual void SetTh23(const T &th23)=0
Float_t e
Definition: plot.C:35
virtual void SetTh12(const T &th12)=0
virtual void SetdCP(const T &dCP)=0
T asin(T number)
Definition: d0nt_math.hpp:60
void mcmc::SaveToFile ( const std::string fileName,
const ana::Spectrum fakeData,
const ana::MCMCSamples warmup,
const ana::MCMCSamples samples,
const ana::SystShifts trueSystPulls,
const osc::IOscCalcAdjustable trueOscParams 
)

Definition at line 194 of file MCMC3FShared.cxx.

References mcmc::config::FAKE_DATA_LABEL, mcmc::config::SAMPLES_LABEL, ana::SystShifts::SaveTo(), ana::SaveTo(), ana::MCMCSamples::SaveTo(), ana::Spectrum::SaveTo(), mcmc::config::SYST_PULLS_LABEL, mcmc::config::TRUE_OSC_LABEL, and mcmc::config::WARMUP_LABEL.

Referenced by fit_3flavor_withsysts().

200  {
201  TFile outF(fileName.c_str(), "recreate");
202  if (outF.IsZombie())
203  abort();
204 
205  if (fakeData)
206  fakeData->SaveTo(&outF, config::FAKE_DATA_LABEL);
207  if (warmup)
208  warmup->SaveTo(&outF, config::WARMUP_LABEL);
209  if (samples)
210  samples->SaveTo(&outF, config::SAMPLES_LABEL);
211  if (trueSystPulls)
212  trueSystPulls->SaveTo(&outF, config::SYST_PULLS_LABEL);
213  if (trueOscParams)
214  ana::SaveTo(*dynamic_cast<const osc::IOscCalc*>(trueOscParams), &outF, config::TRUE_OSC_LABEL);
215 
216  outF.Close();
217  }
fileName
Definition: plotROC.py:78
void SaveTo(const osc::IOscCalc &x, TDirectory *dir, const std::string &name)
void SaveTo(TDirectory *dir, const std::string &name) const
Save this guy to a file so we don&#39;t have to rerun the MCMC.
const std::string FAKE_DATA_LABEL
Definition: MCMC3FShared.h:45
void SaveTo(TDirectory *dir, const std::string &name) const
Definition: Spectrum.cxx:506
const std::string SYST_PULLS_LABEL
Definition: MCMC3FShared.h:47
const std::string SAMPLES_LABEL
Definition: MCMC3FShared.h:46
void SaveTo(TDirectory *dir, const std::string &name) const
Definition: SystShifts.cxx:228
const std::string TRUE_OSC_LABEL
Definition: MCMC3FShared.h:48
const std::string WARMUP_LABEL
Definition: MCMC3FShared.h:49
std::set< const ana::ISyst * > mcmc::SupportedSysts ( const ana::IExperiment expt)

Which systs does this experiment support?

Definition at line 220 of file MCMC3FShared.cxx.

References e, ana::kRockScaleSyst, plot_validation_datamc::pred, and runNovaSAM::ret.

Referenced by BuildMultiExperiment(), fit_3flavor_withsysts(), and FullFilename().

221  {
222  std::set<const ana::ISyst*> ret;
223  const ana::IPrediction * pred = nullptr;
224 
225  if (auto multiexpt = dynamic_cast<const ana::MultiExperiment*>(expt))
226  {
227  for (const auto &e : multiexpt->GetExperiments())
228  {
229  std::set<const ana::ISyst *> thisExptSysts = SupportedSysts(e);
230  std::copy(thisExptSysts.begin(), thisExptSysts.end(), std::inserter(ret, ret.end()));
231  }
232  }
233  if (auto ssexpt = dynamic_cast<const ana::SingleSampleExperiment*>(expt))
234  pred = ssexpt->GetPrediction();
235 
236  if (auto predAddRock = dynamic_cast<const ana::PredictionAddRock*>(pred))
237  {
238  ret.insert(&ana::kRockScaleSyst);
239  pred = predAddRock->GetFiducialPred();
240  }
241 
242  if (auto predInterp = dynamic_cast<const ana::PredictionInterp*>(pred))
243  {
244  auto interpSyst = predInterp->GetAllSysts();
245  std::copy(interpSyst.begin(), interpSyst.end(), std::inserter(ret, ret.end()));
246  }
247 
248  return ret;
249  }
std::set< const ana::ISyst * > SupportedSysts(const ana::IExperiment *expt)
Which systs does this experiment support?
Standard interface to all prediction techniques.
Definition: IPrediction.h:57
Float_t e
Definition: plot.C:35
const DummyRockScaleSyst kRockScaleSyst

Variable Documentation

const std::map<const ana::IFitVar*, std::pair<double, double> > mcmc::fitVarDrawRanges
Initial value:
{
}
const FitVarWithPrior fitDeltaInPiUnits_UniformPriordCP
const ConstrainedFitVarWithPrior fitDmSq32Scaled_UniformPrior
const ConstrainedFitVarWithPrior fitSsqTh23_UniformPriorSsqTh23

Definition at line 30 of file plot_3flavor_withsysts.C.

Referenced by plot_3flavor_withsysts().

const double mcmc::MOCKDATA_DCP = (5./4.) * TMath::Pi()

Definition at line 32 of file fit_3flavor_withsysts.C.

const double mcmc::MOCKDATA_DM32 = 0.0024

Definition at line 31 of file fit_3flavor_withsysts.C.

const double mcmc::MOCKDATA_TH23 = 41 * TMath::DegToRad()

Definition at line 30 of file fit_3flavor_withsysts.C.