MaCh3  2.2.3
Reference Guide
inputManager.h
Go to the documentation of this file.
1 #pragma once
2 
3 // MaCh3 Includes
4 #include "Manager/MaCh3Logger.h"
5 #include "Manager/YamlHelper.h"
9 
10 // Other plotting includes
11 #include "plottingUtils.h"
12 
13 namespace MaCh3Plotting {
14 
17  kLLH,
21 
23 };
24 
35 struct InputFile {
44  InputFile(const std::string &fName) {
45  fileName = fName;
46 
47  file = std::make_shared<TFile>(fileName.c_str());
48  if (file->IsZombie()) {
49  MACH3LOG_ERROR("Failed to open file: {}", fileName);
50  throw MaCh3Exception(__FILE__ , __LINE__ );
51  }
52  hasLLHScans = false;
53  hasPostFitErrors = false;
54  hasSigmaVars = false;
55 
56  for (std::string LLHType : {"sample", "penalty", "total"})
57  {
58  hasLLHScans_map[LLHType] = false;
59  }
60  }
61 
62  // NO COPYING!!
63  InputFile( const InputFile& ) = delete;
64  // Moving ok
65  InputFile( InputFile&& ) = default;
66  // EM: ^^ there should only really be one instance of an InputFile for each
67  // underlying root file. If copying is allowed then it can lead to bad bad things
68  // like pointers getting deleted and then trying to be accessed by a copied
69  // InputFile instance
70 
73  MACH3LOG_DEBUG("###### Deleting InputFile Object holding file ######");
74  LLHScans_map.clear();
75  }
76 
79  void Close(){
80  MACH3LOG_DEBUG("[InputFile] closing file {}", fileName);
81  file->Close();
82  }
83 
87  void Summarise() const {
88  MACH3LOG_INFO("### Input File Summary ###");
89  MACH3LOG_INFO(" Root file loc: {}", fileName);
90  MACH3LOG_INFO(" Came from fitter: {}", fitter);
91  MACH3LOG_INFO(" N LLH scans: {}", availableParams_LLH.size());
92  MACH3LOG_INFO(" N Processed post fit errors: {}", availableParams_postFitErrors.size());
93  }
94 
97  void Dump() const {
98  Summarise();
99  MACH3LOG_INFO("Available LLH parameters: ");
100  for (std::string paramName : availableParams_LLH)
101  {
102  MACH3LOG_INFO(" {}", paramName);
103  }
104  MACH3LOG_INFO("Available Post Fit errors: ");
105  for (std::string paramName : availableParams_postFitErrors)
106  {
107  MACH3LOG_INFO(" {}", paramName);
108  }
109  }
110 
113  TTree *posteriorTree = nullptr;
114 
115  std::shared_ptr<TFile> file;
116  std::string fileName;
117 
118  std::string fitter;
119 
126 
127  // EM: info on the LLH scans
128  bool hasLLHScans;
129  std::vector<std::string>
131  std::unordered_map<std::string, bool>
134  std::unordered_map<std::string, std::unordered_map<std::string, std::shared_ptr<TGraph>>>
137  std::unordered_map<std::string, std::unordered_map<std::string, bool>>
141  // EM: maybe don't really need the "availableParams.." "hasLLHScans...", could just implement
142  // these as functions that look for the given parameter in the existing maps, might make things
143  // nicer
144 
145  // EM: info on LLH scans broken down by sample
148  std::vector<std::string> availableSamples_LLH;
150  std::unordered_map<std::string, std::unordered_map<std::string, std::shared_ptr<TGraph>>>
153  std::unordered_map<std::string, std::unordered_map<std::string, bool>>
157 
158  // EM: info on post fit errors
160  std::vector<std::string>
162  std::unordered_map<std::string, std::unordered_map<std::string, double>>
165  std::unordered_map<std::string, std::unordered_map<std::string, double>>
168  std::string defaultErrorType;
169 
170  // Stuff relating to MCMC
175 
178 
180  std::unordered_map<std::string, bool> availableParams_map_MCMCchain;
181  std::unordered_map<std::string, bool> availableParams_map_1dPosteriors;
182 
183  std::vector<std::string> availableParams_1dPosteriors;
184  std::vector<std::string> availableParams_MCMCchain;
185 
186  std::unordered_map<std::string, double*> MCMCstepParamsMap;
187  std::unordered_map<std::string, int> MCMCstepTreeIndicesMap;
188 
189  std::unordered_map<std::string, std::shared_ptr<TGraph>> posteriors1d_map;
190 
191  // EM: almost certainly won't want to load all of these into memory at the start
193 };
194 
219 public:
220  const std::string NOT_FOUND_STR =
221  "__PARAM_NAME_NOT_FOUND__";
222 
227  InputManager(const std::string &translationConfigName);
228 
231  void addFile(const std::string &fileName);
232 
236  {
237  MACH3LOG_DEBUG("##### Deleting InputManager Instance #####");
238  for (InputFile &file: _fileVec)
239  {
240  file.Close();
241  }
242  }
243 
244  // NO COPYING!
245  InputManager(const InputManager&) = delete;
246  // moving is ok
248  // EM: ^^ Do this as there should only ever really be one instance of the
249  // InputManager (should maybe make it a singleton actually)
250  // if copied then it can lead to things being deleted that we really don't
251  // want to be deleted
252 
257  static const std::string convertFileTypeNames(const fileTypeEnum fileType) {
258  switch (fileType)
259  {
260  case kLLH:
261  return "LLH";
262  case kPostFit:
263  return "PostFit";
264  case kMCMC:
265  return "MCMC";
266  case kSigmaVar:
267  return "SigmaVar";
268  case kNFileTypes:
269  return "NFileTypes";
270  default:
271  return "UNKNOWN_FILE_TYPE";
272  }
273  }
274 
278  void print(const std::string &printLevel = "summary") const;
279 
280  // FNs to get to the tasty tasty data stored in the files
281 
287  std::vector<std::vector<double>> getLLHScan(const int fileNum, const std::string& paramName, const std::string& LLHType) const {
288  if (!getEnabledLLH(fileNum, paramName, LLHType))
289  {
290  MACH3LOG_WARN("file at index {} does not have LLH scan for parameter {}", fileNum, paramName);
291  MACH3LOG_WARN("am returning an empty vector");
292  return std::vector<std::vector<double>>(2);
293  }
294  return TGraphToVector(*_fileVec[fileNum].LLHScans_map.at(LLHType).at(paramName));
295  }
296 
300  void getMCMCentry(const int fileNum, const int entry) const {
301  // EM: the const here is a little bit of a lie since GetEntry will in fact modify
302  // the pointers to the stored data for the MCMC chain values but hopefully this should be ok
303  const InputFile &file = _fileVec[fileNum];
304 
305  if( entry > file.nMCMCentries )
306  {
307  MACH3LOG_ERROR("Trying to access entries beyond what exist in file {}. No-can-do!", file.fileName);
308  }
309  else
310  {
311  MACH3LOG_TRACE("Getting entry {} in MCMC tree for file at index {}", entry, fileNum);
312  file.posteriorTree->GetEntry(entry);
313  MACH3LOG_TRACE(" Got successfully");
314  }
315  }
316 
320  double getMCMCvalue(int fileNum, std::string paramName) const {
321  if (!getEnabledMCMCchain(fileNum, paramName))
322  {
323  MACH3LOG_WARN("file at index {} does not have an MCMC entry for parameter {}", fileNum, paramName);
324  MACH3LOG_WARN("am returning a bad float");
325  return M3::_BAD_DOUBLE_;
326  }
327 
328  return *_fileVec[fileNum].MCMCstepParamsMap.at(paramName);
329  }
330 
335  std::vector<std::vector<double>> get1dPosterior(const int fileNum, const std::string& paramName) const {
336  if (!getEnabled1dPosteriors(fileNum, paramName))
337  {
338  MACH3LOG_WARN("file at index {} does not have a 1d posterior for parameter {}", fileNum, paramName);
339  MACH3LOG_WARN("am returning an empty vector");
340  return std::vector<std::vector<double>>(2);
341  }
342  return TGraphToVector(*_fileVec[fileNum].posteriors1d_map.at(paramName));
343  }
344 
347  int getnMCMCentries(const int fileNum) const {
348  return _fileVec[fileNum].nMCMCentries;
349  }
350 
358  inline TGraph getLLHScan_TGraph(const int fileNum, const std::string& paramName, const std::string& LLHType) const {
359  if (!getEnabledLLH(fileNum, paramName, LLHType))
360  {
361  MACH3LOG_WARN("file at index {} does not have LLH scan for parameter {}", fileNum, paramName);
362  MACH3LOG_WARN("am returning an empty TGraph");
363  return TGraph();
364  }
365  return *_fileVec[fileNum].LLHScans_map.at(LLHType).at(paramName);
366  }
367 
368  inline TH1D getLLHScan_TH1D(const int fileNum, const std::string& paramName, const std::string& LLHType) const {
369  if (!getEnabledLLH(fileNum, paramName, LLHType))
370  {
371  MACH3LOG_WARN("file at index {} does not have LLH scan for parameter {}", fileNum, paramName);
372  MACH3LOG_WARN("am returning an empty TH1D");
373  return TH1D();
374  }
375  return TGraphToTH1D(*_fileVec[fileNum].LLHScans_map.at(LLHType).at(paramName));
376  }
377 
384  std::vector<std::vector<double>> getSampleSpecificLLHScan(const int fileNum, const std::string& paramName, const std::string& sample) const {
385  if (!getEnabledLLHBySample(fileNum, paramName, sample))
386  {
387  MACH3LOG_WARN("file at index {} does not have LLH scan for sample {} for parameter {}", fileNum, sample, paramName);
388  MACH3LOG_WARN("am returning an empty vector");
389  return std::vector<std::vector<double>>(2);
390  }
391  return TGraphToVector(*_fileVec[fileNum].LLHScansBySample_map.at(sample).at(paramName));
392  }
393 
394  inline TGraph getSampleSpecificLLHScan_TGraph(const int fileNum, const std::string& paramName,
395  const std::string& sample) const {
396  if (!getEnabledLLHBySample(fileNum, paramName, sample))
397  {
398  MACH3LOG_WARN("file at index {} does not have LLH scan for sample {} for parameter {}", fileNum, sample, paramName);
399  MACH3LOG_WARN("am returning an empty TGraph");
400  return TGraph();
401  }
402  return *_fileVec[fileNum].LLHScansBySample_map.at(sample).at(paramName);
403  }
404 
405  inline TH1D getSampleSpecificLLHScan_TH1D(const int fileNum, const std::string& paramName, const std::string& sample) const {
406  if (!getEnabledLLHBySample(fileNum, paramName, sample))
407  {
408  MACH3LOG_WARN("file at index {} does not have LLH scan for sample {} for parameter {}", fileNum, sample, paramName);
409  MACH3LOG_WARN("am returning an empty TH1D");
410  return TH1D();
411  }
412  return TGraphToTH1D(*_fileVec[fileNum].LLHScansBySample_map.at(sample).at(paramName));
413  }
414 
420  inline bool getEnabledLLH(const int fileNum, const std::string& paramName,
421  std::string LLHType = "total") const {
422  return _fileVec[fileNum].availableParams_map_LLH.at(LLHType).at(paramName);
423  }
424 
431  inline bool getEnabledLLHBySample(const int fileNum, const std::string& paramName, const std::string& sample) const {
432  return _fileVec[fileNum].availableParams_map_LLHBySample.at(sample).at(paramName);
433  }
434 
439  inline bool getEnabledMCMCchain(const int fileNum, const std::string& paramName) const {
440  return _fileVec[fileNum].availableParams_map_MCMCchain.at(paramName);
441  }
442 
447  inline bool getEnabled1dPosteriors(const int fileNum, const std::string& paramName) const {
448  return _fileVec[fileNum].availableParams_map_1dPosteriors.at(paramName);
449  }
450 
458  double getPostFitError(const int fileNum, const std::string &paramName, std::string errorType = "") const;
459 
467  double getPostFitValue(const int fileNum, const std::string &paramName, std::string errorType = "") const;
468 
471  inline const std::vector<std::string> &getKnownParameters() const { return _knownParameters; }
472  inline const std::vector<std::string> &getKnownSamples() const { return _knownSamples; }
473  inline size_t getNInputFiles() const { return _fileVec.size(); }
474 
482  inline std::vector<std::string> getTaggedParameters(const std::vector<std::string> &tags, std::string checkType = "all") const {
483  return getTaggedValues(_knownParameters, _paramToTagsMap, tags, checkType);
484  }
485 
493  inline std::vector<std::string> getTaggedSamples(const std::vector<std::string> &tags, std::string checkType = "all") const {
494  return getTaggedValues(_knownSamples, _sampleToTagsMap, tags, checkType);
495  }
497 
500  inline InputFile const &getFile(int fileId) const { return _fileVec[fileId]; }
501  inline std::string translateName(int fileId, fileTypeEnum fileType, std::string paramName) const {
502  return getFitterSpecificParamName(_fileVec[fileId].fitter, fileType, paramName);
503  }
504  inline const std::vector<std::string> &getKnownLLHParameters(int fileId) const {
505  return _fileVec[fileId].availableParams_LLH;
506  }
507  inline const std::vector<std::string> &getKnownLLHSamples(int fileId) const {
508  return _fileVec[fileId].availableSamples_LLH;
509  }
510  inline const std::vector<std::string> &getKnownPostFitParameters(int fileId) const {
511  return _fileVec[fileId].availableParams_postFitErrors;
512  }
513  inline const std::vector<std::string> &getKnownMCMCParameters(int fileId) const {
514  return _fileVec[fileId].availableParams_MCMCchain;
515  }
516  inline const std::vector<std::string> &getKnown1dPosteriorParameters(int fileId) const {
517  return _fileVec[fileId].availableParams_1dPosteriors;
518  }
520 
521 private:
522  // Helper function to get tagged values from a vector of values
523  // specify the initial list of *values*, the map of values to their tags, the tags to check,
524  // and the type of check to perform (see getTaggedParameter() for details)
525  std::vector<std::string> getTaggedValues(const std::vector<std::string> &values,
526  const std::unordered_map<std::string,
527  std::vector<std::string>> &tagMap,
528  const std::vector<std::string> &tags, std::string checkType) const;
529 
530  // Helper function to parse a root file location string
531  // any instance of {PARAMETER} gets replaced with fitter specific parameter name
532  // similar for {SAMPLE}
533  // any other token that gets added in future can also just be added here and added to end of the
534  // argument list The string will also be split by the ":" delimeter into a directory and a name to
535  // look for in that directory
536  std::vector<std::string> parseLocation(const std::string &locationString, std::string &fitter,
537  fileTypeEnum fileType, const std::string &parameter = "",
538  const std::string &sample = "", const std::string &parameter2 = "") const;
539 
540  // helper function to look for an object defined by a vector of strings [ (directory to look in),
541  // (end of the name of the object) ] this just calls roots TDirectoryFile->Get() function so
542  // behaves in the same way:
543  // if the object exists then it is loaded and returned
544  // if it doesn't exist then just returns nullptr
545  std::shared_ptr<TObject> findRootObject(const InputFile &fileDef, const std::vector<std::string> &locationVec) const;
546 
547  // Check the input file for a particular post fit error for a particular parameter. if
548  // setInputFileError, will add the information to the InputFiles postFitErrors histogram.
549  bool findPostFitParamError(InputFile &inputFileDef, const std::string &parameter, std::string &fitter,
550  const std::string &errorType, const bool setInputFileError = false);
551 
552  // Check the input file for a particular post fit error for a particular parameter. if
553  // setInputFileError, will add the information to the InputFiles postFitErrors histogram.
554  bool findBySampleLLH(InputFile &inputFileDef, const std::string &parameter, std::string &fitter,
555  const std::string &sample, bool setInputFileScan = false);
556 
557  // check the input file for raw MCMC step values for a particular parameter
558  bool findRawChainSteps(InputFile &inputFileDef, const std::string &parameter, std::string &fitter, bool setInputBranch = false ) const ;
559 
560  // check the input file for processed 1d posteriors for a particular parameter
561  bool find1dPosterior(InputFile &inputFileDef, const std::string &parameter, std::string &fitter, bool setFileData = false) const ;
562 
563  // fns tp read an input file
564  void fillFileInfo(InputFile &inputFileDef, const bool printThoughts = true);
565  void fillFileData(InputFile &inputFileDef, const bool printThoughts = true);
566 
567  // helper function to read from the translation config file to get an option for a particular sub
568  // node (e.g. Parameters or Samples) returns true and sets "ret" if the option is specified for this
569  // fitter and parameter otherwise returns false
570  template <typename T>
571  inline bool getFitterSpecificOption(const std::string &fitter, const std::string &option, T &ret, const std::string &parameter,
572  YAML::Node subConfig) const{
573  if (subConfig[parameter])
574  {
575  // EM: this is config definition of fitter specific names for this parameter
576  YAML::Node paramTranslation = subConfig[parameter];
577 
578  if (paramTranslation[fitter])
579  {
580  // EM: then this is definition of how to find parameter in the specified fitter
581  YAML::Node fitterParamTranslation = paramTranslation[fitter];
582 
583  if (fitterParamTranslation[option])
584  {
585  ret = fitterParamTranslation[option].as<T>();
586  return true;
587  }
588  }
589  }
590  return false;
591  }
592 
593  // Specialised option getter for parameters
594  template <typename T>
595  inline bool getFitterSpecificParamOption(const std::string &fitter, const std::string &option, T &ret,
596  const std::string &parameter) const {
597  return getFitterSpecificOption<T>(fitter, option, ret, parameter, _parametersConfig);
598  }
599 
600  // specialised option getter for samples
601  template <typename T>
602  inline bool getFitterSpecificSampleOption(const std::string &fitter, std::string option, T &ret,
603  std::string parameter) const {
604  return getFitterSpecificOption<T>(fitter, option, ret, parameter, _samplesConfig);
605  }
606 
607  // helper function to read from the translation config to get the parameter name for a specific
608  // fitter and file type
609  inline std::string getFitterSpecificParamName(const std::string &fitter, fileTypeEnum fileType,
610  const std::string &parameter) const {
611  std::string specificName;
612  if (getFitterSpecificParamOption<std::string>(fitter, convertFileTypeNames(fileType),
613  specificName, parameter))
614  {
615  return specificName;
616  }
617  // EM: Default to just return the specified name
618  return parameter;
619  }
620 
621  // helper function to read from the translation config file to get the sample name for a specific
622  // fitter and file type
623  inline std::string getFitterSpecificSampleName(const std::string &fitter, fileTypeEnum fileType,
624  const std::string &sample) const {
625  std::string specificName;
626  if (getFitterSpecificSampleOption<std::string>(fitter, convertFileTypeNames(fileType),
627  specificName, sample))
628  {
629  return specificName;
630  }
631  // EM: Default to just return the specified name
632  return sample;
633  }
634 
635  // helper fn to test if string "str" ends with other string "ending"
636  inline bool strEndsWith(const std::string& str, const std::string& ending) const {
637  if (str.size() >= ending.size()) {
638  return str.compare(str.size() - ending.size(), ending.size(), ending) == 0;
639  }
640  return false;
641  }
642 
643 private:
644  // all parameters which are known to this InputManager: all the ones defined in the translation
645  // config used to create it
646  std::vector<std::string> _knownParameters;
647 
648  // all samples which are known to this InputManager: all the ones defined in the translation
649  // config used to create it
650  std::vector<std::string> _knownSamples;
651 
652  // hold the names of the fitters known to this manager
653  std::vector<std::string> _knownFitters;
654 
655  // map parameter names to their specified tags
656  std::unordered_map<std::string, std::vector<std::string>> _paramToTagsMap;
657  // map sample names to their specified tags
658  std::unordered_map<std::string, std::vector<std::string>> _sampleToTagsMap;
659 
660  // the configs defining the translation of parameters between fitters and also the directory
661  // structure for each fitter
662  YAML::Node _translatorConfig;
663  YAML::Node _fitterSpecConfig;
664  YAML::Node _parametersConfig;
665  YAML::Node _samplesConfig;
666 
667  // vector of InputFile objects that this manager is responsible for
668  std::vector<InputFile> _fileVec;
669 };
670 } // namespace MaCh3Plotting
KS: Based on this https://github.com/gabime/spdlog/blob/a2b4262090fd3f005c2315dcb5be2f0f1774a005/incl...
#define MACH3LOG_DEBUG
Definition: MaCh3Logger.h:24
#define MACH3LOG_ERROR
Definition: MaCh3Logger.h:27
#define MACH3LOG_INFO
Definition: MaCh3Logger.h:25
#define MACH3LOG_WARN
Definition: MaCh3Logger.h:26
#define MACH3LOG_TRACE
Definition: MaCh3Logger.h:23
Utility functions for handling YAML nodes.
Class responsible for processing MCMC chains, performing diagnostics, generating plots,...
Definition: MCMCProcessor.h:61
Custom exception class for MaCh3 errors.
This guy talks to the input files and is intended to smooth over the fact that our OA fitters use suc...
Definition: inputManager.h:218
const std::vector< std::string > & getKnownParameters() const
Definition: inputManager.h:471
std::vector< std::string > getTaggedSamples(const std::vector< std::string > &tags, std::string checkType="all") const
Get all samples which have some set of tags.
Definition: inputManager.h:493
std::vector< std::string > parseLocation(const std::string &locationString, std::string &fitter, fileTypeEnum fileType, const std::string &parameter="", const std::string &sample="", const std::string &parameter2="") const
std::vector< std::string > getTaggedValues(const std::vector< std::string > &values, const std::unordered_map< std::string, std::vector< std::string >> &tagMap, const std::vector< std::string > &tags, std::string checkType) const
bool getEnabledMCMCchain(const int fileNum, const std::string &paramName) const
Get whether or not a particular parameter has MCMC chain entries in a particular input file.
Definition: inputManager.h:439
std::unordered_map< std::string, std::vector< std::string > > _paramToTagsMap
Definition: inputManager.h:656
const std::vector< std::string > & getKnownLLHParameters(int fileId) const
Definition: inputManager.h:504
void getMCMCentry(const int fileNum, const int entry) const
Get the MCMC chain entry in an InputFile.
Definition: inputManager.h:300
TGraph getLLHScan_TGraph(const int fileNum, const std::string &paramName, const std::string &LLHType) const
Get the log likelihood scan for a particular parameter from a particular input file.
Definition: inputManager.h:358
double getPostFitError(const int fileNum, const std::string &paramName, std::string errorType="") const
Get the post fit error for a particular parameter from a particular input file.
bool getFitterSpecificOption(const std::string &fitter, const std::string &option, T &ret, const std::string &parameter, YAML::Node subConfig) const
Definition: inputManager.h:571
InputFile const & getFile(int fileId) const
Definition: inputManager.h:500
double getPostFitValue(const int fileNum, const std::string &paramName, std::string errorType="") const
Get the post fit value for a particular parameter from a particular input file.
std::vector< InputFile > _fileVec
Definition: inputManager.h:668
std::vector< std::string > getTaggedParameters(const std::vector< std::string > &tags, std::string checkType="all") const
Get all parameters which have some set of tags.
Definition: inputManager.h:482
std::vector< std::vector< double > > getLLHScan(const int fileNum, const std::string &paramName, const std::string &LLHType) const
Get the log likelihood scan data for a particular parameter from a particular input file.
Definition: inputManager.h:287
std::vector< std::string > _knownParameters
Definition: inputManager.h:646
InputManager(const std::string &translationConfigName)
Construct a new InputManager using specified fitter translation config file.
Definition: inputManager.cpp:6
const std::vector< std::string > & getKnownPostFitParameters(int fileId) const
Definition: inputManager.h:510
TH1D getLLHScan_TH1D(const int fileNum, const std::string &paramName, const std::string &LLHType) const
Definition: inputManager.h:368
bool find1dPosterior(InputFile &inputFileDef, const std::string &parameter, std::string &fitter, bool setFileData=false) const
const std::vector< std::string > & getKnownLLHSamples(int fileId) const
Definition: inputManager.h:507
std::vector< std::vector< double > > get1dPosterior(const int fileNum, const std::string &paramName) const
Get the 1d posterior particular parameter from a particular input file.
Definition: inputManager.h:335
InputManager(const InputManager &)=delete
const std::string NOT_FOUND_STR
the default string to return if something can't be found
Definition: inputManager.h:220
bool getEnabledLLHBySample(const int fileNum, const std::string &paramName, const std::string &sample) const
Get whether or not a particular parameter has an LLH scan in a particular input file for a particular...
Definition: inputManager.h:431
TGraph getSampleSpecificLLHScan_TGraph(const int fileNum, const std::string &paramName, const std::string &sample) const
Definition: inputManager.h:394
std::vector< std::vector< double > > getSampleSpecificLLHScan(const int fileNum, const std::string &paramName, const std::string &sample) const
Get the log likelihood scan for a particular parameter, for a specific sample, from a particular inpu...
Definition: inputManager.h:384
const std::vector< std::string > & getKnownSamples() const
Definition: inputManager.h:472
std::shared_ptr< TObject > findRootObject(const InputFile &fileDef, const std::vector< std::string > &locationVec) const
std::vector< std::string > _knownFitters
Definition: inputManager.h:653
void fillFileInfo(InputFile &inputFileDef, const bool printThoughts=true)
void addFile(const std::string &fileName)
Add a new InputFile object to this input manager.
bool getFitterSpecificParamOption(const std::string &fitter, const std::string &option, T &ret, const std::string &parameter) const
Definition: inputManager.h:595
bool getEnabled1dPosteriors(const int fileNum, const std::string &paramName) const
Get whether or not a particular parameter has 1d posteriors in a particular input file.
Definition: inputManager.h:447
bool strEndsWith(const std::string &str, const std::string &ending) const
Definition: inputManager.h:636
std::string getFitterSpecificParamName(const std::string &fitter, fileTypeEnum fileType, const std::string &parameter) const
Definition: inputManager.h:609
void fillFileData(InputFile &inputFileDef, const bool printThoughts=true)
bool getFitterSpecificSampleOption(const std::string &fitter, std::string option, T &ret, std::string parameter) const
Definition: inputManager.h:602
InputManager(InputManager &&)=default
bool findPostFitParamError(InputFile &inputFileDef, const std::string &parameter, std::string &fitter, const std::string &errorType, const bool setInputFileError=false)
std::string translateName(int fileId, fileTypeEnum fileType, std::string paramName) const
Definition: inputManager.h:501
bool findRawChainSteps(InputFile &inputFileDef, const std::string &parameter, std::string &fitter, bool setInputBranch=false) const
std::vector< std::string > _knownSamples
Definition: inputManager.h:650
std::string getFitterSpecificSampleName(const std::string &fitter, fileTypeEnum fileType, const std::string &sample) const
Definition: inputManager.h:623
bool getEnabledLLH(const int fileNum, const std::string &paramName, std::string LLHType="total") const
Get whether or not a particular parameter has an LLH scan in a particular input file.
Definition: inputManager.h:420
double getMCMCvalue(int fileNum, std::string paramName) const
Get the parameter value for the current step for a particular parameter from a particular input file.
Definition: inputManager.h:320
int getnMCMCentries(const int fileNum) const
Get the number of entries in the MCMC chain in a particular file.
Definition: inputManager.h:347
static const std::string convertFileTypeNames(const fileTypeEnum fileType)
Convert from fileTypeEnum to the name of the file type.
Definition: inputManager.h:257
std::unordered_map< std::string, std::vector< std::string > > _sampleToTagsMap
Definition: inputManager.h:658
bool findBySampleLLH(InputFile &inputFileDef, const std::string &parameter, std::string &fitter, const std::string &sample, bool setInputFileScan=false)
size_t getNInputFiles() const
Definition: inputManager.h:473
const std::vector< std::string > & getKnown1dPosteriorParameters(int fileId) const
Definition: inputManager.h:516
void print(const std::string &printLevel="summary") const
Print out what this Inputmanager instance knows about.
TH1D getSampleSpecificLLHScan_TH1D(const int fileNum, const std::string &paramName, const std::string &sample) const
Definition: inputManager.h:405
const std::vector< std::string > & getKnownMCMCParameters(int fileId) const
Definition: inputManager.h:513
std::vector< std::vector< double > > TGraphToVector(TGraph graph)
This handy little function lets you interpret a TGraph as a vector containing the same data.
TH1D TGraphToTH1D(TGraph graph, const std::string &newName, const std::string &newTitle)
This handy little function lets you interpret a TGraph as a TH1D.
constexpr static const double _BAD_DOUBLE_
Default value used for double initialisation.
Definition: Core.h:46
fileTypeEnum
Types of possible file that can be read.
Definition: inputManager.h:16
@ kNFileTypes
Number of types of file.
Definition: inputManager.h:22
@ kPostFit
Processed post fit errors.
Definition: inputManager.h:18
@ kLLH
Log Likelihood scan.
Definition: inputManager.h:17
@ kSigmaVar
Sigma variations.
Definition: inputManager.h:20
@ kMCMC
MCMC chain.
Definition: inputManager.h:19
Struct which wraps around the actual input file and also holds general information,...
Definition: inputManager.h:35
std::string fileName
The location of the underlying file.
Definition: inputManager.h:116
void Dump() const
Print out a more detailed summary of what is contained in the file.
Definition: inputManager.h:97
std::shared_ptr< TFile > file
Pointer to the underlying file for this InputFile instance.
Definition: inputManager.h:115
std::unordered_map< std::string, bool > hasLLHScans_map
Definition: inputManager.h:132
std::unordered_map< std::string, std::unordered_map< std::string, bool > > availableParams_map_LLH
Definition: inputManager.h:138
std::vector< std::string > availableParams_LLH
The parameters that this file contains likelihood scans for.
Definition: inputManager.h:130
std::unordered_map< std::string, bool > availableParams_map_MCMCchain
whether or not specific parameters exist in the MCMC posterior chain
Definition: inputManager.h:180
std::string defaultErrorType
Definition: inputManager.h:168
void Summarise() const
Print out a small summary of what is contained in the file.
Definition: inputManager.h:87
InputFile(const std::string &fName)
Create InputFile instance based on a specified file.
Definition: inputManager.h:44
InputFile(const InputFile &)=delete
std::unordered_map< std::string, std::unordered_map< std::string, std::shared_ptr< TGraph > > > LLHScans_map
Definition: inputManager.h:135
std::string fitter
Which fitter this file came from, detected by InputManager::fillFileInfo().
Definition: inputManager.h:118
bool hasLLHScans
Whether or not this file contains any log likelihood scans.
Definition: inputManager.h:128
bool has1dPosteriors
Whether or not the file has processed 1d posteriors.
Definition: inputManager.h:172
MCMCProcessor * mcmcProc
ptr to an MCMCProcessor instance to be used if this is a MaCh3 input file
Definition: inputManager.h:112
std::unordered_map< std::string, std::shared_ptr< TGraph > > posteriors1d_map
Definition: inputManager.h:189
std::unordered_map< std::string, std::unordered_map< std::string, double > > postFitErrors
Definition: inputManager.h:163
bool hasSigmaVars
Whether or not this file contains Sigma variations.
Definition: inputManager.h:192
std::vector< std::string > availableParams_MCMCchain
Definition: inputManager.h:184
std::unordered_map< std::string, bool > availableParams_map_1dPosteriors
Definition: inputManager.h:181
std::unordered_map< std::string, std::unordered_map< std::string, double > > postFitValues
Definition: inputManager.h:166
std::unordered_map< std::string, std::unordered_map< std::string, std::shared_ptr< TGraph > > > LLHScansBySample_map
Definition: inputManager.h:151
bool hasPostFitErrors
Whether or not this file contains any processed post fit errors.
Definition: inputManager.h:159
std::vector< std::string > availableParams_postFitErrors
The parameters that this file has post fit errors for.
Definition: inputManager.h:161
void Close()
Close out the underlying root file.
Definition: inputManager.h:79
std::unordered_map< std::string, int > MCMCstepTreeIndicesMap
Definition: inputManager.h:187
std::unordered_map< std::string, std::unordered_map< std::string, bool > > availableParams_map_LLHBySample
Definition: inputManager.h:154
std::unordered_map< std::string, double * > MCMCstepParamsMap
Definition: inputManager.h:186
InputFile(InputFile &&)=default
bool hasMCMCchain
Whether or not the file has unprocessed MCMC chain steps.
Definition: inputManager.h:174
int nMCMCentries
The number of steps in the MCMC chain.
Definition: inputManager.h:177
std::vector< std::string > availableSamples_LLH
Definition: inputManager.h:148
std::vector< std::string > availableParams_1dPosteriors
Definition: inputManager.h:183