MaCh3  2.6.1
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 M3 {
14 namespace Plotting {
17  kLLH,
21 
23 };
24 
36 struct InputFile {
45  InputFile(const std::string &fName) {
46  fileName = fName;
47 
48  file = std::make_shared<TFile>(fileName.c_str());
49  if (file->IsZombie()) {
50  MACH3LOG_ERROR("Failed to open file: {}", fileName);
51  throw MaCh3Exception(__FILE__ , __LINE__ );
52  }
53  hasLLHScans = false;
54  hasPostFitErrors = false;
55  hasSigmaVars = false;
56 
57  for (std::string LLHType : {"sample", "penalty", "total"})
58  {
59  hasLLHScans_map[LLHType] = false;
60  }
61  }
62 
63  // NO COPYING!!
64  InputFile( const InputFile& ) = delete;
65  // Moving ok
66  InputFile( InputFile&& ) = default;
67  // EM: ^^ there should only really be one instance of an InputFile for each
68  // underlying root file. If copying is allowed then it can lead to bad bad things
69  // like pointers getting deleted and then trying to be accessed by a copied
70  // InputFile instance
71 
74  MACH3LOG_DEBUG("###### Deleting InputFile Object holding file ######");
75  LLHScans_map.clear();
76  }
77 
80  void Close(){
81  MACH3LOG_DEBUG("[InputFile] closing file {}", fileName);
82  file->Close();
83  }
84 
88  void Summarise() const {
89  MACH3LOG_INFO("### Input File Summary ###");
90  MACH3LOG_INFO(" Root file loc: {}", fileName);
91  MACH3LOG_INFO(" Came from fitter: {}", fitter);
92  MACH3LOG_INFO(" N LLH scans: {}", availableParams_LLH.size());
93  MACH3LOG_INFO(" N Processed post fit errors: {}", availableParams_postFitErrors.size());
94  }
95 
98  void Dump() const {
99  Summarise();
100  MACH3LOG_INFO("Available LLH parameters: ");
101  for (std::string paramName : availableParams_LLH)
102  {
103  MACH3LOG_INFO(" {}", paramName);
104  }
105  MACH3LOG_INFO("Available Post Fit errors: ");
106  for (std::string paramName : availableParams_postFitErrors)
107  {
108  MACH3LOG_INFO(" {}", paramName);
109  }
110  }
111 
113  std::unique_ptr<MCMCProcessor> mcmcProc;
114  TTree *posteriorTree = nullptr;
115 
116  std::shared_ptr<TFile> file;
117  std::string fileName;
118 
119  std::string fitter;
120 
127 
128  // EM: info on the LLH scans
129  bool hasLLHScans;
130  std::vector<std::string>
132  std::unordered_map<std::string, bool>
135  std::unordered_map<std::string, std::unordered_map<std::string, std::shared_ptr<TGraph>>>
138  std::unordered_map<std::string, std::unordered_map<std::string, bool>>
142  // EM: maybe don't really need the "availableParams.." "hasLLHScans...", could just implement
143  // these as functions that look for the given parameter in the existing maps, might make things
144  // nicer
145 
146  // EM: info on LLH scans broken down by sample
149  std::vector<std::string> availableSamples_LLH;
151  std::unordered_map<std::string, std::unordered_map<std::string, std::shared_ptr<TGraph>>>
154  std::unordered_map<std::string, std::unordered_map<std::string, bool>>
158 
159  // EM: info on post fit errors
161  std::vector<std::string>
163  std::unordered_map<std::string, std::unordered_map<std::string, double>>
166  std::unordered_map<std::string, std::unordered_map<std::string, double>>
169  std::string defaultErrorType;
170 
171  // Stuff relating to MCMC
176 
179 
181  std::unordered_map<std::string, bool> availableParams_map_MCMCchain;
182  std::unordered_map<std::string, bool> availableParams_map_1dPosteriors;
183 
184  std::vector<std::string> availableParams_1dPosteriors;
185  std::vector<std::string> availableParams_MCMCchain;
186 
187  std::unordered_map<std::string, double*> MCMCstepParamsMap;
188  std::unordered_map<std::string, int> MCMCstepTreeIndicesMap;
189 
190  std::unordered_map<std::string, std::shared_ptr<TGraph>> posteriors1d_map;
191 
192  // EM: almost certainly won't want to load all of these into memory at the start
194 };
195 
223 public:
224  const std::string NOT_FOUND_STR =
225  "__PARAM_NAME_NOT_FOUND__";
226 
231  InputManager(const std::string &translationConfigName, const std::vector<std::string>& _fileNames);
232 
235  void addFile(const std::string &fileName);
236 
240  {
241  MACH3LOG_DEBUG("##### Deleting InputManager Instance #####");
242  for (InputFile &file: _fileVec)
243  {
244  file.Close();
245  }
246  }
247 
248  // NO COPYING!
249  InputManager(const InputManager&) = delete;
250  // moving is ok
252  // EM: ^^ Do this as there should only ever really be one instance of the
253  // InputManager (should maybe make it a singleton actually)
254  // if copied then it can lead to things being deleted that we really don't
255  // want to be deleted
256 
261  static const std::string convertFileTypeNames(const fileTypeEnum fileType) {
262  switch (fileType)
263  {
264  case kLLH:
265  return "LLH";
266  case kPostFit:
267  return "PostFit";
268  case kMCMC:
269  return "MCMC";
270  case kSigmaVar:
271  return "SigmaVar";
272  case kNFileTypes:
273  return "NFileTypes";
274  default:
275  return "UNKNOWN_FILE_TYPE";
276  }
277  }
278 
282  void print(const std::string &printLevel = "summary") const;
283 
284  // FNs to get to the tasty tasty data stored in the files
285 
291  std::vector<std::vector<double>> getLLHScan(const int fileNum, const std::string& paramName, const std::string& LLHType) const {
292  if (!getEnabledLLH(fileNum, paramName, LLHType))
293  {
294  MACH3LOG_WARN("file at index {} does not have LLH scan for parameter {}", fileNum, paramName);
295  MACH3LOG_WARN("am returning an empty vector");
296  return std::vector<std::vector<double>>(2);
297  }
298  return TGraphToVector(*_fileVec[fileNum].LLHScans_map.at(LLHType).at(paramName));
299  }
300 
304  void getMCMCentry(const int fileNum, const int entry) const {
305  // EM: the const here is a little bit of a lie since GetEntry will in fact modify
306  // the pointers to the stored data for the MCMC chain values but hopefully this should be ok
307  const InputFile &file = _fileVec[fileNum];
308 
309  if( entry > file.nMCMCentries )
310  {
311  MACH3LOG_ERROR("Trying to access entries beyond what exist in file {}. No-can-do!", file.fileName);
312  }
313  else
314  {
315  MACH3LOG_TRACE("Getting entry {} in MCMC tree for file at index {}", entry, fileNum);
316  file.posteriorTree->GetEntry(entry);
317  MACH3LOG_TRACE(" Got successfully");
318  }
319  }
320 
324  double getMCMCvalue(int fileNum, const std::string& paramName) const {
325  if (!getEnabledMCMCchain(fileNum, paramName))
326  {
327  MACH3LOG_WARN("file at index {} does not have an MCMC entry for parameter {}", fileNum, paramName);
328  MACH3LOG_WARN("am returning a bad float");
329  return M3::_BAD_DOUBLE_;
330  }
331 
332  return *_fileVec[fileNum].MCMCstepParamsMap.at(paramName);
333  }
334 
339  std::vector<std::vector<double>> get1dPosterior(const int fileNum, const std::string& paramName) const {
340  if (!getEnabled1dPosteriors(fileNum, paramName))
341  {
342  MACH3LOG_WARN("file at index {} does not have a 1d posterior for parameter {}", fileNum, paramName);
343  MACH3LOG_WARN("am returning an empty vector");
344  return std::vector<std::vector<double>>(2);
345  }
346  return TGraphToVector(*_fileVec[fileNum].posteriors1d_map.at(paramName));
347  }
348 
351  int getnMCMCentries(const int fileNum) const {
352  return _fileVec[fileNum].nMCMCentries;
353  }
354 
362  inline TGraph getLLHScan_TGraph(const int fileNum, const std::string& paramName, const std::string& LLHType) const {
363  if (!getEnabledLLH(fileNum, paramName, LLHType))
364  {
365  MACH3LOG_WARN("file at index {} does not have LLH scan for parameter {}", fileNum, paramName);
366  MACH3LOG_WARN("am returning an empty TGraph");
367  return TGraph();
368  }
369  return *_fileVec[fileNum].LLHScans_map.at(LLHType).at(paramName);
370  }
371 
372  inline TH1D getLLHScan_TH1D(const int fileNum, const std::string& paramName, const std::string& LLHType) const {
373  if (!getEnabledLLH(fileNum, paramName, LLHType))
374  {
375  MACH3LOG_WARN("file at index {} does not have LLH scan for parameter {}", fileNum, paramName);
376  MACH3LOG_WARN("am returning an empty TH1D");
377  return TH1D();
378  }
379  return TGraphToTH1D(*_fileVec[fileNum].LLHScans_map.at(LLHType).at(paramName));
380  }
381 
388  std::vector<std::vector<double>> getSampleSpecificLLHScan(const int fileNum, const std::string& paramName, const std::string& sample) const {
389  if (!getEnabledLLHBySample(fileNum, paramName, sample))
390  {
391  MACH3LOG_WARN("file at index {} does not have LLH scan for sample {} for parameter {}", fileNum, sample, paramName);
392  MACH3LOG_WARN("am returning an empty vector");
393  return std::vector<std::vector<double>>(2);
394  }
395  return TGraphToVector(*_fileVec[fileNum].LLHScansBySample_map.at(sample).at(paramName));
396  }
397 
398  inline TGraph getSampleSpecificLLHScan_TGraph(const int fileNum, const std::string& paramName,
399  const std::string& sample) const {
400  if (!getEnabledLLHBySample(fileNum, paramName, sample))
401  {
402  MACH3LOG_WARN("file at index {} does not have LLH scan for sample {} for parameter {}", fileNum, sample, paramName);
403  MACH3LOG_WARN("am returning an empty TGraph");
404  return TGraph();
405  }
406  return *_fileVec[fileNum].LLHScansBySample_map.at(sample).at(paramName);
407  }
408 
409  inline TH1D getSampleSpecificLLHScan_TH1D(const int fileNum, const std::string& paramName, const std::string& sample) const {
410  if (!getEnabledLLHBySample(fileNum, paramName, sample))
411  {
412  MACH3LOG_WARN("file at index {} does not have LLH scan for sample {} for parameter {}", fileNum, sample, paramName);
413  MACH3LOG_WARN("am returning an empty TH1D");
414  return TH1D();
415  }
416  return TGraphToTH1D(*_fileVec[fileNum].LLHScansBySample_map.at(sample).at(paramName));
417  }
418 
424  inline bool getEnabledLLH(const int fileNum, const std::string& paramName,
425  const std::string& LLHType = "total") const {
426  return _fileVec[fileNum].availableParams_map_LLH.at(LLHType).at(paramName);
427  }
428 
435  inline bool getEnabledLLHBySample(const int fileNum, const std::string& paramName, const std::string& sample) const {
436  return _fileVec[fileNum].availableParams_map_LLHBySample.at(sample).at(paramName);
437  }
438 
443  inline bool getEnabledMCMCchain(const int fileNum, const std::string& paramName) const {
444  return _fileVec[fileNum].availableParams_map_MCMCchain.at(paramName);
445  }
446 
451  inline bool getEnabled1dPosteriors(const int fileNum, const std::string& paramName) const {
452  return _fileVec[fileNum].availableParams_map_1dPosteriors.at(paramName);
453  }
454 
462  double getPostFitError(const int fileNum, const std::string &paramName, std::string errorType = "") const;
463 
471  double getPostFitValue(const int fileNum, const std::string &paramName, std::string errorType = "") const;
472 
475  inline const std::vector<std::string> &getKnownParameters() const { return _knownParameters; }
476  inline const std::vector<std::string> &getKnownSamples() const { return _knownSamples; }
477  inline size_t getNInputFiles() const { return _fileVec.size(); }
478 
486  inline std::vector<std::string> getTaggedParameters(const std::vector<std::string> &tags, std::string checkType = "all") const {
487  return getTaggedValues(_knownParameters, _paramToTagsMap, tags, checkType);
488  }
489 
497  inline std::vector<std::string> getTaggedSamples(const std::vector<std::string> &tags, std::string checkType = "all") const {
498  return getTaggedValues(_knownSamples, _sampleToTagsMap, tags, checkType);
499  }
501 
504  inline InputFile const &getFile(int fileId) const { return _fileVec[fileId]; }
505  inline std::string translateName(int fileId, fileTypeEnum fileType, std::string paramName) const {
506  return getFitterSpecificParamName(_fileVec[fileId].fitter, fileType, paramName);
507  }
508  inline const std::vector<std::string> &getKnownLLHParameters(int fileId) const {
509  return _fileVec[fileId].availableParams_LLH;
510  }
511  inline const std::vector<std::string> &getKnownLLHSamples(int fileId) const {
512  return _fileVec[fileId].availableSamples_LLH;
513  }
514  inline const std::vector<std::string> &getKnownPostFitParameters(int fileId) const {
515  return _fileVec[fileId].availableParams_postFitErrors;
516  }
517  inline const std::vector<std::string> &getKnownMCMCParameters(int fileId) const {
518  return _fileVec[fileId].availableParams_MCMCchain;
519  }
520  inline const std::vector<std::string> &getKnown1dPosteriorParameters(int fileId) const {
521  return _fileVec[fileId].availableParams_1dPosteriors;
522  }
524 
525 private:
526  // Helper function to get tagged values from a vector of values
527  // specify the initial list of *values*, the map of values to their tags, the tags to check,
528  // and the type of check to perform (see getTaggedParameter() for details)
529  std::vector<std::string> getTaggedValues(const std::vector<std::string> &values,
530  const std::unordered_map<std::string,
531  std::vector<std::string>> &tagMap,
532  const std::vector<std::string> &tags, std::string checkType) const;
533 
534  // Helper function to parse a root file location string
535  // any instance of {PARAMETER} gets replaced with fitter specific parameter name
536  // similar for {SAMPLE}
537  // any other token that gets added in future can also just be added here and added to end of the
538  // argument list The string will also be split by the ":" delimeter into a directory and a name to
539  // look for in that directory
540  std::vector<std::string> parseLocation(const std::string &locationString, std::string &fitter,
541  fileTypeEnum fileType, const std::string &parameter = "",
542  const std::string &sample = "", const std::string &parameter2 = "") const;
543 
544  // helper function to look for an object defined by a vector of strings [ (directory to look in),
545  // (end of the name of the object) ] this just calls roots TDirectoryFile->Get() function so
546  // behaves in the same way:
547  // if the object exists then it is loaded and returned
548  // if it doesn't exist then just returns nullptr
549  std::shared_ptr<TObject> findRootObject(const InputFile &fileDef, const std::vector<std::string> &locationVec) const;
550 
551  // Check the input file for a particular post fit error for a particular parameter. if
552  // setInputFileError, will add the information to the InputFiles postFitErrors histogram.
553  bool findPostFitParamError(InputFile &inputFileDef, const std::string &parameter, std::string &fitter,
554  const std::string &errorType, const bool setInputFileError = false);
555 
556  // Check the input file for a particular post fit error for a particular parameter. if
557  // setInputFileError, will add the information to the InputFiles postFitErrors histogram.
558  bool findBySampleLLH(InputFile &inputFileDef, const std::string &parameter, std::string &fitter,
559  const std::string &sample, bool setInputFileScan = false);
560 
561  // check the input file for raw MCMC step values for a particular parameter
562  bool findRawChainSteps(InputFile &inputFileDef, const std::string &parameter, std::string &fitter, bool setInputBranch = false ) const ;
563 
564  // check the input file for processed 1d posteriors for a particular parameter
565  bool find1dPosterior(InputFile &inputFileDef, const std::string &parameter, std::string &fitter, bool setFileData = false) const ;
566 
567  // fns tp read an input file
568  void fillFileInfo(InputFile &inputFileDef, const bool printThoughts = true);
569  void fillFileData(InputFile &inputFileDef, const bool printThoughts = true);
570 
571  // helper function to read from the translation config file to get an option for a particular sub
572  // node (e.g. Parameters or Samples) returns true and sets "ret" if the option is specified for this
573  // fitter and parameter otherwise returns false
574  template <typename T>
575  inline bool getFitterSpecificOption(const std::string &fitter, const std::string &option, T &ret, const std::string &parameter,
576  YAML::Node subConfig) const{
577  if (subConfig[parameter])
578  {
579  // EM: this is config definition of fitter specific names for this parameter
580  YAML::Node paramTranslation = subConfig[parameter];
581 
582  if (paramTranslation[fitter])
583  {
584  // EM: then this is definition of how to find parameter in the specified fitter
585  YAML::Node fitterParamTranslation = paramTranslation[fitter];
586 
587  if (fitterParamTranslation[option])
588  {
589  ret = fitterParamTranslation[option].as<T>();
590  return true;
591  }
592  }
593  }
594  return false;
595  }
596 
597  // Specialised option getter for parameters
598  template <typename T>
599  inline bool getFitterSpecificParamOption(const std::string &fitter, const std::string &option, T &ret,
600  const std::string &parameter) const {
601  return getFitterSpecificOption<T>(fitter, option, ret, parameter, _parametersConfig);
602  }
603 
604  // specialised option getter for samples
605  template <typename T>
606  inline bool getFitterSpecificSampleOption(const std::string &fitter, std::string option, T &ret,
607  std::string parameter) const {
608  return getFitterSpecificOption<T>(fitter, option, ret, parameter, _samplesConfig);
609  }
610 
611  // helper function to read from the translation config to get the parameter name for a specific
612  // fitter and file type
613  inline std::string getFitterSpecificParamName(const std::string &fitter, fileTypeEnum fileType,
614  const std::string &parameter) const {
615  std::string specificName;
616  if (getFitterSpecificParamOption<std::string>(fitter, convertFileTypeNames(fileType),
617  specificName, parameter))
618  {
619  return specificName;
620  }
621  // EM: Default to just return the specified name
622  return parameter;
623  }
624 
625  // helper function to read from the translation config file to get the sample name for a specific
626  // fitter and file type
627  inline std::string getFitterSpecificSampleName(const std::string &fitter, fileTypeEnum fileType,
628  const std::string &sample) const {
629  std::string specificName;
630  if (getFitterSpecificSampleOption<std::string>(fitter, convertFileTypeNames(fileType),
631  specificName, sample))
632  {
633  return specificName;
634  }
635  // EM: Default to just return the specified name
636  return sample;
637  }
638 
639 
640  std::vector<std::string> TryToFindDefaultParamNames(const std::string& fileNames) const;
641 
642  // helper fn to test if string "str" ends with other string "ending"
643  inline bool strEndsWith(const std::string& str, const std::string& ending) const {
644  if (str.size() >= ending.size()) {
645  return str.compare(str.size() - ending.size(), ending.size(), ending) == 0;
646  }
647  return false;
648  }
649 
650 private:
651  // all parameters which are known to this InputManager: all the ones defined in the translation
652  // config used to create it
653  std::vector<std::string> _knownParameters;
654 
655  // all samples which are known to this InputManager: all the ones defined in the translation
656  // config used to create it
657  std::vector<std::string> _knownSamples;
658 
659  // hold the names of the fitters known to this manager
660  std::vector<std::string> _knownFitters;
661 
662  // map parameter names to their specified tags
663  std::unordered_map<std::string, std::vector<std::string>> _paramToTagsMap;
664  // map sample names to their specified tags
665  std::unordered_map<std::string, std::vector<std::string>> _sampleToTagsMap;
666 
667  // the configs defining the translation of parameters between fitters and also the directory
668  // structure for each fitter
669  YAML::Node _translatorConfig;
670  YAML::Node _fitterSpecConfig;
671  YAML::Node _parametersConfig;
672  YAML::Node _samplesConfig;
673 
674  // vector of InputFile objects that this manager is responsible for
675  std::vector<InputFile> _fileVec;
676 };
677 } // namespace Plotting
678 } // namespace M3
Defines the custom exception class used throughout MaCh3.
MaCh3 Logging utilities built on top of SPDLOG.
#define MACH3LOG_DEBUG
Definition: MaCh3Logger.h:34
#define MACH3LOG_ERROR
Definition: MaCh3Logger.h:37
#define MACH3LOG_INFO
Definition: MaCh3Logger.h:35
#define MACH3LOG_WARN
Definition: MaCh3Logger.h:36
#define MACH3LOG_TRACE
Definition: MaCh3Logger.h:33
Utility functions for handling YAML nodes.
This guy talks to the input files and is intended to smooth over the fact that our OA fitters use suc...
Definition: InputManager.h:222
void print(const std::string &printLevel="summary") const
Print out what this Inputmanager instance knows about.
std::unordered_map< std::string, std::vector< std::string > > _paramToTagsMap
Definition: InputManager.h:663
std::string translateName(int fileId, fileTypeEnum fileType, std::string paramName) const
Definition: InputManager.h:505
const std::vector< std::string > & getKnownParameters() const
Definition: InputManager.h:475
void addFile(const std::string &fileName)
Add a new InputFile object to this input manager.
const std::vector< std::string > & getKnownSamples() const
Definition: InputManager.h:476
static const std::string convertFileTypeNames(const fileTypeEnum fileType)
Convert from fileTypeEnum to the name of the file type.
Definition: InputManager.h:261
TGraph getSampleSpecificLLHScan_TGraph(const int fileNum, const std::string &paramName, const std::string &sample) const
Definition: InputManager.h:398
void fillFileData(InputFile &inputFileDef, const bool printThoughts=true)
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:451
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:291
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< 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
void getMCMCentry(const int fileNum, const int entry) const
Get the MCMC chain entry in an InputFile.
Definition: InputManager.h:304
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:435
std::vector< std::string > _knownSamples
Definition: InputManager.h:657
int getnMCMCentries(const int fileNum) const
Get the number of entries in the MCMC chain in a particular file.
Definition: InputManager.h:351
InputManager(const InputManager &)=delete
std::string getFitterSpecificParamName(const std::string &fitter, fileTypeEnum fileType, const std::string &parameter) const
Definition: InputManager.h:613
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:339
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.
double getMCMCvalue(int fileNum, const std::string &paramName) const
Get the parameter value for the current step for a particular parameter from a particular input file.
Definition: InputManager.h:324
bool findRawChainSteps(InputFile &inputFileDef, const std::string &parameter, std::string &fitter, bool setInputBranch=false) const
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:388
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:497
bool find1dPosterior(InputFile &inputFileDef, const std::string &parameter, std::string &fitter, bool setFileData=false) const
std::shared_ptr< TObject > findRootObject(const InputFile &fileDef, const std::vector< std::string > &locationVec) const
TH1D getSampleSpecificLLHScan_TH1D(const int fileNum, const std::string &paramName, const std::string &sample) const
Definition: InputManager.h:409
size_t getNInputFiles() const
Definition: InputManager.h:477
std::vector< InputFile > _fileVec
Definition: InputManager.h:675
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:443
InputManager(const std::string &translationConfigName, const std::vector< std::string > &_fileNames)
Construct a new InputManager using specified fitter translation config file.
Definition: InputManager.cpp:6
std::vector< std::string > _knownParameters
Definition: InputManager.h:653
InputFile const & getFile(int fileId) const
Definition: InputManager.h:504
void fillFileInfo(InputFile &inputFileDef, const bool printThoughts=true)
const std::vector< std::string > & getKnownLLHSamples(int fileId) const
Definition: InputManager.h:511
bool getEnabledLLH(const int fileNum, const std::string &paramName, const std::string &LLHType="total") const
Get whether or not a particular parameter has an LLH scan in a particular input file.
Definition: InputManager.h:424
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
const std::vector< std::string > & getKnownPostFitParameters(int fileId) const
Definition: InputManager.h:514
const std::vector< std::string > & getKnownMCMCParameters(int fileId) const
Definition: InputManager.h:517
const std::vector< std::string > & getKnown1dPosteriorParameters(int fileId) const
Definition: InputManager.h:520
InputManager(InputManager &&)=default
std::string getFitterSpecificSampleName(const std::string &fitter, fileTypeEnum fileType, const std::string &sample) const
Definition: InputManager.h:627
std::vector< std::string > _knownFitters
Definition: InputManager.h:660
const std::string NOT_FOUND_STR
the default string to return if something can't be found
Definition: InputManager.h:224
TH1D getLLHScan_TH1D(const int fileNum, const std::string &paramName, const std::string &LLHType) const
Definition: InputManager.h:372
const std::vector< std::string > & getKnownLLHParameters(int fileId) const
Definition: InputManager.h:508
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:362
bool getFitterSpecificSampleOption(const std::string &fitter, std::string option, T &ret, std::string parameter) const
Definition: InputManager.h:606
bool findBySampleLLH(InputFile &inputFileDef, const std::string &parameter, std::string &fitter, const std::string &sample, bool setInputFileScan=false)
std::vector< std::string > TryToFindDefaultParamNames(const std::string &fileNames) const
bool strEndsWith(const std::string &str, const std::string &ending) const
Definition: InputManager.h:643
bool getFitterSpecificOption(const std::string &fitter, const std::string &option, T &ret, const std::string &parameter, YAML::Node subConfig) const
Definition: InputManager.h:575
bool findPostFitParamError(InputFile &inputFileDef, const std::string &parameter, std::string &fitter, const std::string &errorType, const bool setInputFileError=false)
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:486
std::unordered_map< std::string, std::vector< std::string > > _sampleToTagsMap
Definition: InputManager.h:665
bool getFitterSpecificParamOption(const std::string &fitter, const std::string &option, T &ret, const std::string &parameter) const
Definition: InputManager.h:599
Custom exception class used throughout MaCh3.
std::vector< std::vector< double > > TGraphToVector(const TGraph &graph)
This handy little function lets you interpret a TGraph as a vector containing the same data.
fileTypeEnum
Types of possible file that can be read.
Definition: InputManager.h:16
@ kMCMC
MCMC chain.
Definition: InputManager.h:19
@ kSigmaVar
Sigma variations.
Definition: InputManager.h:20
@ kNFileTypes
Number of types of file.
Definition: InputManager.h:22
@ kLLH
Log Likelihood scan.
Definition: InputManager.h:17
@ kPostFit
Processed post fit errors.
Definition: InputManager.h:18
TH1D TGraphToTH1D(const TGraph &graph, const std::string &newName, const std::string &newTitle)
This handy little function lets you interpret a TGraph as a TH1D.
Main namespace for MaCh3 software.
constexpr static const double _BAD_DOUBLE_
Default value used for double initialisation.
Definition: Core.h:53
Struct which wraps around the actual input file and also holds general information,...
Definition: InputManager.h:36
std::unordered_map< std::string, bool > availableParams_map_1dPosteriors
Definition: InputManager.h:182
std::unordered_map< std::string, std::unordered_map< std::string, bool > > availableParams_map_LLH
Definition: InputManager.h:139
std::shared_ptr< TFile > file
Pointer to the underlying file for this InputFile instance.
Definition: InputManager.h:116
bool hasSigmaVars
Whether or not this file contains Sigma variations.
Definition: InputManager.h:193
std::string defaultErrorType
Definition: InputManager.h:169
bool has1dPosteriors
Whether or not the file has processed 1d posteriors.
Definition: InputManager.h:173
bool hasPostFitErrors
Whether or not this file contains any processed post fit errors.
Definition: InputManager.h:160
std::vector< std::string > availableParams_MCMCchain
Definition: InputManager.h:185
int nMCMCentries
The number of steps in the MCMC chain.
Definition: InputManager.h:178
std::unordered_map< std::string, double * > MCMCstepParamsMap
Definition: InputManager.h:187
~InputFile()
Destructor.
Definition: InputManager.h:73
std::unordered_map< std::string, bool > availableParams_map_MCMCchain
whether or not specific parameters exist in the MCMC posterior chain
Definition: InputManager.h:181
bool hasLLHScans
Whether or not this file contains any log likelihood scans.
Definition: InputManager.h:129
std::unordered_map< std::string, std::shared_ptr< TGraph > > posteriors1d_map
Definition: InputManager.h:190
std::unordered_map< std::string, std::unordered_map< std::string, std::shared_ptr< TGraph > > > LLHScans_map
Definition: InputManager.h:136
std::string fileName
The location of the underlying file.
Definition: InputManager.h:117
void Summarise() const
Print out a small summary of what is contained in the file.
Definition: InputManager.h:88
std::vector< std::string > availableParams_postFitErrors
The parameters that this file has post fit errors for.
Definition: InputManager.h:162
std::unordered_map< std::string, std::unordered_map< std::string, std::shared_ptr< TGraph > > > LLHScansBySample_map
Definition: InputManager.h:152
std::unordered_map< std::string, std::unordered_map< std::string, double > > postFitValues
Definition: InputManager.h:167
void Dump() const
Print out a more detailed summary of what is contained in the file.
Definition: InputManager.h:98
bool hasMCMCchain
Whether or not the file has unprocessed MCMC chain steps.
Definition: InputManager.h:175
std::unordered_map< std::string, std::unordered_map< std::string, double > > postFitErrors
Definition: InputManager.h:164
std::vector< std::string > availableParams_1dPosteriors
Definition: InputManager.h:184
InputFile(const InputFile &)=delete
std::unique_ptr< MCMCProcessor > mcmcProc
ptr to an MCMCProcessor instance to be used if this is a MaCh3 input file
Definition: InputManager.h:113
InputFile(InputFile &&)=default
InputFile(const std::string &fName)
Create InputFile instance based on a specified file.
Definition: InputManager.h:45
std::vector< std::string > availableParams_LLH
The parameters that this file contains likelihood scans for.
Definition: InputManager.h:131
std::vector< std::string > availableSamples_LLH
Definition: InputManager.h:149
void Close()
Close out the underlying root file.
Definition: InputManager.h:80
std::string fitter
Which fitter this file came from, detected by InputManager::fillFileInfo().
Definition: InputManager.h:119
std::unordered_map< std::string, std::unordered_map< std::string, bool > > availableParams_map_LLHBySample
Definition: InputManager.h:155
std::unordered_map< std::string, int > MCMCstepTreeIndicesMap
Definition: InputManager.h:188
std::unordered_map< std::string, bool > hasLLHScans_map
Definition: InputManager.h:133