48 if (
file->IsZombie()) {
56 for (std::string LLHType : {
"sample",
"penalty",
"total"})
73 MACH3LOG_DEBUG(
"###### Deleting InputFile Object holding file ######");
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>>
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>>
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>>
221 "__PARAM_NAME_NOT_FOUND__";
231 void addFile(
const std::string &fileName);
271 return "UNKNOWN_FILE_TYPE";
278 void print(
const std::string &printLevel =
"summary")
const;
287 std::vector<std::vector<double>>
getLLHScan(
const int fileNum,
const std::string& paramName,
const std::string& LLHType)
const {
290 MACH3LOG_WARN(
"file at index {} does not have LLH scan for parameter {}", fileNum, paramName);
292 return std::vector<std::vector<double>>(2);
311 MACH3LOG_TRACE(
"Getting entry {} in MCMC tree for file at index {}", entry, fileNum);
323 MACH3LOG_WARN(
"file at index {} does not have an MCMC entry for parameter {}", fileNum, paramName);
328 return *
_fileVec[fileNum].MCMCstepParamsMap.at(paramName);
335 std::vector<std::vector<double>>
get1dPosterior(
const int fileNum,
const std::string& paramName)
const {
338 MACH3LOG_WARN(
"file at index {} does not have a 1d posterior for parameter {}", fileNum, paramName);
340 return std::vector<std::vector<double>>(2);
348 return _fileVec[fileNum].nMCMCentries;
358 inline TGraph
getLLHScan_TGraph(
const int fileNum,
const std::string& paramName,
const std::string& LLHType)
const {
361 MACH3LOG_WARN(
"file at index {} does not have LLH scan for parameter {}", fileNum, paramName);
365 return *
_fileVec[fileNum].LLHScans_map.at(LLHType).at(paramName);
368 inline TH1D
getLLHScan_TH1D(
const int fileNum,
const std::string& paramName,
const std::string& LLHType)
const {
371 MACH3LOG_WARN(
"file at index {} does not have LLH scan for parameter {}", fileNum, paramName);
384 std::vector<std::vector<double>>
getSampleSpecificLLHScan(
const int fileNum,
const std::string& paramName,
const std::string& sample)
const {
387 MACH3LOG_WARN(
"file at index {} does not have LLH scan for sample {} for parameter {}", fileNum, sample, paramName);
389 return std::vector<std::vector<double>>(2);
395 const std::string& sample)
const {
398 MACH3LOG_WARN(
"file at index {} does not have LLH scan for sample {} for parameter {}", fileNum, sample, paramName);
402 return *
_fileVec[fileNum].LLHScansBySample_map.at(sample).at(paramName);
408 MACH3LOG_WARN(
"file at index {} does not have LLH scan for sample {} for parameter {}", fileNum, sample, paramName);
421 std::string LLHType =
"total")
const {
422 return _fileVec[fileNum].availableParams_map_LLH.at(LLHType).at(paramName);
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);
440 return _fileVec[fileNum].availableParams_map_MCMCchain.at(paramName);
448 return _fileVec[fileNum].availableParams_map_1dPosteriors.at(paramName);
458 double getPostFitError(
const int fileNum,
const std::string ¶mName, std::string errorType =
"")
const;
467 double getPostFitValue(
const int fileNum,
const std::string ¶mName, std::string errorType =
"")
const;
482 inline std::vector<std::string>
getTaggedParameters(
const std::vector<std::string> &tags, std::string checkType =
"all")
const {
493 inline std::vector<std::string>
getTaggedSamples(
const std::vector<std::string> &tags, std::string checkType =
"all")
const {
505 return _fileVec[fileId].availableParams_LLH;
508 return _fileVec[fileId].availableSamples_LLH;
511 return _fileVec[fileId].availableParams_postFitErrors;
514 return _fileVec[fileId].availableParams_MCMCchain;
517 return _fileVec[fileId].availableParams_1dPosteriors;
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;
536 std::vector<std::string>
parseLocation(
const std::string &locationString, std::string &fitter,
537 fileTypeEnum fileType,
const std::string ¶meter =
"",
538 const std::string &sample =
"",
const std::string ¶meter2 =
"")
const;
545 std::shared_ptr<TObject>
findRootObject(
const InputFile &fileDef,
const std::vector<std::string> &locationVec)
const;
550 const std::string &errorType,
const bool setInputFileError =
false);
555 const std::string &sample,
bool setInputFileScan =
false);
558 bool findRawChainSteps(
InputFile &inputFileDef,
const std::string ¶meter, std::string &fitter,
bool setInputBranch =
false )
const ;
561 bool find1dPosterior(
InputFile &inputFileDef,
const std::string ¶meter, std::string &fitter,
bool setFileData =
false)
const ;
570 template <
typename T>
571 inline bool getFitterSpecificOption(
const std::string &fitter,
const std::string &option, T &ret,
const std::string ¶meter,
572 YAML::Node subConfig)
const{
573 if (subConfig[parameter])
576 YAML::Node paramTranslation = subConfig[parameter];
578 if (paramTranslation[fitter])
581 YAML::Node fitterParamTranslation = paramTranslation[fitter];
583 if (fitterParamTranslation[option])
585 ret = fitterParamTranslation[option].as<T>();
594 template <
typename T>
596 const std::string ¶meter)
const {
597 return getFitterSpecificOption<T>(fitter, option, ret, parameter,
_parametersConfig);
601 template <
typename T>
603 std::string parameter)
const {
604 return getFitterSpecificOption<T>(fitter, option, ret, parameter,
_samplesConfig);
610 const std::string ¶meter)
const {
611 std::string specificName;
613 specificName, parameter))
624 const std::string &sample)
const {
625 std::string specificName;
627 specificName, sample))
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;
KS: Based on this https://github.com/gabime/spdlog/blob/a2b4262090fd3f005c2315dcb5be2f0f1774a005/incl...
Utility functions for handling YAML nodes.
Class responsible for processing MCMC chains, performing diagnostics, generating plots,...
Custom exception class for MaCh3 errors.
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.
fileTypeEnum
Types of possible file that can be read.
@ kNFileTypes
Number of types of file.
@ kPostFit
Processed post fit errors.
@ kLLH
Log Likelihood scan.
@ kSigmaVar
Sigma variations.