MaCh3  2.6.1
Reference Guide
Public Member Functions | Public Attributes | List of all members
M3::Plotting::InputFile Struct Reference

Struct which wraps around the actual input file and also holds general information, and data from the file to be used by other classes. More...

#include <Utils/Plotting/InputManager.h>

Collaboration diagram for M3::Plotting::InputFile:
[legend]

Public Member Functions

 InputFile (const std::string &fName)
 Create InputFile instance based on a specified file. More...
 
 InputFile (const InputFile &)=delete
 
 InputFile (InputFile &&)=default
 
 ~InputFile ()
 Destructor. More...
 
void Close ()
 Close out the underlying root file. More...
 
void Summarise () const
 Print out a small summary of what is contained in the file. More...
 
void Dump () const
 Print out a more detailed summary of what is contained in the file. More...
 

Public Attributes

std::unique_ptr< MCMCProcessormcmcProc
 ptr to an MCMCProcessor instance to be used if this is a MaCh3 input file More...
 
TTree * posteriorTree = nullptr
 
std::shared_ptr< TFile > file
 Pointer to the underlying file for this InputFile instance. More...
 
std::string fileName
 The location of the underlying file. More...
 
std::string fitter
 Which fitter this file came from, detected by InputManager::fillFileInfo(). More...
 
bool hasLLHScans
 Whether or not this file contains any log likelihood scans. More...
 
std::vector< std::string > availableParams_LLH
 The parameters that this file contains likelihood scans for. More...
 
std::unordered_map< std::string, bool > hasLLHScans_map
 
std::unordered_map< std::string, std::unordered_map< std::string, std::shared_ptr< TGraph > > > LLHScans_map
 
std::unordered_map< std::string, std::unordered_map< std::string, bool > > availableParams_map_LLH
 
bool hasLLHScansBySample
 
std::vector< std::string > availableSamples_LLH
 
std::unordered_map< std::string, std::unordered_map< std::string, std::shared_ptr< TGraph > > > LLHScansBySample_map
 
std::unordered_map< std::string, std::unordered_map< std::string, bool > > availableParams_map_LLHBySample
 
bool hasPostFitErrors
 Whether or not this file contains any processed post fit errors. More...
 
std::vector< std::string > availableParams_postFitErrors
 The parameters that this file has post fit errors for. More...
 
std::unordered_map< std::string, std::unordered_map< std::string, double > > postFitErrors
 
std::unordered_map< std::string, std::unordered_map< std::string, double > > postFitValues
 
std::string defaultErrorType
 
bool has1dPosteriors
 Whether or not the file has processed 1d posteriors. More...
 
bool hasMCMCchain
 Whether or not the file has unprocessed MCMC chain steps. More...
 
int nMCMCentries
 The number of steps in the MCMC chain. More...
 
std::unordered_map< std::string, bool > availableParams_map_MCMCchain
 whether or not specific parameters exist in the MCMC posterior chain More...
 
std::unordered_map< std::string, bool > availableParams_map_1dPosteriors
 
std::vector< std::string > availableParams_1dPosteriors
 
std::vector< std::string > availableParams_MCMCchain
 
std::unordered_map< std::string, double * > MCMCstepParamsMap
 
std::unordered_map< std::string, int > MCMCstepTreeIndicesMap
 
std::unordered_map< std::string, std::shared_ptr< TGraph > > posteriors1d_map
 
bool hasSigmaVars
 Whether or not this file contains Sigma variations. More...
 

Detailed Description

Struct which wraps around the actual input file and also holds general information, and data from the file to be used by other classes.

This is just a little guy thats intended to be just a plain old data type which simply holds and organises information and data read from the underlying input file, just some methods to inspect the contents of the object. As such it does not implement methods to manipulate such data, which is all done via the InputManager() class. Reason for this object is to try to smooth over the cracks that come from very different file structures used by different fitters and provide a common format to be used for plot making. Intended use of this objects is only via InputManager which contains the methods to fill and manipulate it.

Author
Ewan Miller

Definition at line 36 of file InputManager.h.

Constructor & Destructor Documentation

◆ InputFile() [1/3]

M3::Plotting::InputFile::InputFile ( const std::string &  fName)
inline

Create InputFile instance based on a specified file.

Parameters
fNameThe name of the file to open.
Returns
The constructed InputFile.

Constructor which opens the specified file and sets default values for information parameters. Currently this assumes the specified file is a root file, and opens it as a TFile. In future it would be nice to extend this to be able to read different types of files, perhaps also moving the opening of the file to a different place to keep this struct nice and simple, perhaps into the InputManager.

Definition at line 45 of file InputManager.h.

45  {
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  }
#define MACH3LOG_ERROR
Definition: MaCh3Logger.h:37
Custom exception class used throughout MaCh3.
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
bool hasPostFitErrors
Whether or not this file contains any processed post fit errors.
Definition: InputManager.h:160
bool hasLLHScans
Whether or not this file contains any log likelihood scans.
Definition: InputManager.h:129
std::string fileName
The location of the underlying file.
Definition: InputManager.h:117
std::unordered_map< std::string, bool > hasLLHScans_map
Definition: InputManager.h:133

◆ InputFile() [2/3]

M3::Plotting::InputFile::InputFile ( const InputFile )
delete

◆ InputFile() [3/3]

M3::Plotting::InputFile::InputFile ( InputFile &&  )
default

◆ ~InputFile()

M3::Plotting::InputFile::~InputFile ( )
inline

Destructor.

Definition at line 73 of file InputManager.h.

73  {
74  MACH3LOG_DEBUG("###### Deleting InputFile Object holding file ######");
75  LLHScans_map.clear();
76  }
#define MACH3LOG_DEBUG
Definition: MaCh3Logger.h:34
std::unordered_map< std::string, std::unordered_map< std::string, std::shared_ptr< TGraph > > > LLHScans_map
Definition: InputManager.h:136

Member Function Documentation

◆ Close()

void M3::Plotting::InputFile::Close ( )
inline

Close out the underlying root file.

Should only be done once this InputFile is done with, should only really ever be done by the InputManager that holds this object

Definition at line 80 of file InputManager.h.

80  {
81  MACH3LOG_DEBUG("[InputFile] closing file {}", fileName);
82  file->Close();
83  }

◆ Dump()

void M3::Plotting::InputFile::Dump ( ) const
inline

Print out a more detailed summary of what is contained in the file.

Todo:
Same as for Summarise(), could add a check that the file info has actually been filled.

Definition at line 98 of file InputManager.h.

98  {
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  }
#define MACH3LOG_INFO
Definition: MaCh3Logger.h:35
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::vector< std::string > availableParams_LLH
The parameters that this file contains likelihood scans for.
Definition: InputManager.h:131

◆ Summarise()

void M3::Plotting::InputFile::Summarise ( ) const
inline

Print out a small summary of what is contained in the file.

Todo:
Could add some flag to this to check if the relevant information has actually been filled already and if not give some warning or print only some of the values.

Definition at line 88 of file InputManager.h.

88  {
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  }
std::string fitter
Which fitter this file came from, detected by InputManager::fillFileInfo().
Definition: InputManager.h:119

Member Data Documentation

◆ availableParams_1dPosteriors

std::vector<std::string> M3::Plotting::InputFile::availableParams_1dPosteriors

Definition at line 184 of file InputManager.h.

◆ availableParams_LLH

std::vector<std::string> M3::Plotting::InputFile::availableParams_LLH

The parameters that this file contains likelihood scans for.

Definition at line 131 of file InputManager.h.

◆ availableParams_map_1dPosteriors

std::unordered_map<std::string, bool> M3::Plotting::InputFile::availableParams_map_1dPosteriors

Definition at line 182 of file InputManager.h.

◆ availableParams_map_LLH

std::unordered_map<std::string, std::unordered_map<std::string, bool> > M3::Plotting::InputFile::availableParams_map_LLH

Whether this file has LLH scans of a particular type for a particular parameter, organised as availableParams_map_LLH.at(LLHType).at(parameter)

Definition at line 139 of file InputManager.h.

◆ availableParams_map_LLHBySample

std::unordered_map<std::string, std::unordered_map<std::string, bool> > M3::Plotting::InputFile::availableParams_map_LLHBySample

Whether this file has LLH scans of a particular type for a particular parameter, organised as availableParams_map_LLH.at(sample).at(parameter)

Definition at line 155 of file InputManager.h.

◆ availableParams_map_MCMCchain

std::unordered_map<std::string, bool> M3::Plotting::InputFile::availableParams_map_MCMCchain

whether or not specific parameters exist in the MCMC posterior chain

Definition at line 181 of file InputManager.h.

◆ availableParams_MCMCchain

std::vector<std::string> M3::Plotting::InputFile::availableParams_MCMCchain

Definition at line 185 of file InputManager.h.

◆ availableParams_postFitErrors

std::vector<std::string> M3::Plotting::InputFile::availableParams_postFitErrors

The parameters that this file has post fit errors for.

Definition at line 162 of file InputManager.h.

◆ availableSamples_LLH

std::vector<std::string> M3::Plotting::InputFile::availableSamples_LLH

The samples that this file contains individual likelihood scans for.

Definition at line 149 of file InputManager.h.

◆ defaultErrorType

std::string M3::Plotting::InputFile::defaultErrorType

Definition at line 169 of file InputManager.h.

◆ file

std::shared_ptr<TFile> M3::Plotting::InputFile::file

Pointer to the underlying file for this InputFile instance.

Definition at line 116 of file InputManager.h.

◆ fileName

std::string M3::Plotting::InputFile::fileName

The location of the underlying file.

Definition at line 117 of file InputManager.h.

◆ fitter

std::string M3::Plotting::InputFile::fitter

Which fitter this file came from, detected by InputManager::fillFileInfo().

Definition at line 119 of file InputManager.h.

◆ has1dPosteriors

bool M3::Plotting::InputFile::has1dPosteriors

Whether or not the file has processed 1d posteriors.

Definition at line 173 of file InputManager.h.

◆ hasLLHScans

bool M3::Plotting::InputFile::hasLLHScans

Whether or not this file contains any log likelihood scans.

Todo:

I think it would be nice to store all the InputFile data in some non root, maybe custom c++ types, and have separate reader classes for potential different input file formats that can convert to these types.

Currently all fitters use root but maybe some wonderful day in the far far future this wont be the case. Doing things this way we could maintain the possible future option of moving away from root???

Definition at line 129 of file InputManager.h.

◆ hasLLHScans_map

std::unordered_map<std::string, bool> M3::Plotting::InputFile::hasLLHScans_map

Whether this file contains specific types of likelihood scans, e.g. hasLLHScans_map.at("prior").

Definition at line 133 of file InputManager.h.

◆ hasLLHScansBySample

bool M3::Plotting::InputFile::hasLLHScansBySample

Whether or not this file contains log likelihood scans broken down per sample.

Definition at line 147 of file InputManager.h.

◆ hasMCMCchain

bool M3::Plotting::InputFile::hasMCMCchain

Whether or not the file has unprocessed MCMC chain steps.

Definition at line 175 of file InputManager.h.

◆ hasPostFitErrors

bool M3::Plotting::InputFile::hasPostFitErrors

Whether or not this file contains any processed post fit errors.

Definition at line 160 of file InputManager.h.

◆ hasSigmaVars

bool M3::Plotting::InputFile::hasSigmaVars

Whether or not this file contains Sigma variations.

Definition at line 193 of file InputManager.h.

◆ LLHScans_map

std::unordered_map<std::string, std::unordered_map<std::string, std::shared_ptr<TGraph> > > M3::Plotting::InputFile::LLHScans_map

The actual graphs of the likelihood scans, organised as LLHScans_map.at(LLHType).at(parameter).

Definition at line 136 of file InputManager.h.

◆ LLHScansBySample_map

std::unordered_map<std::string, std::unordered_map<std::string, std::shared_ptr<TGraph> > > M3::Plotting::InputFile::LLHScansBySample_map

The actual graphs of the likelihood scans, organised as LLHScans_map.at(sample).at(parameter).

Definition at line 152 of file InputManager.h.

◆ mcmcProc

std::unique_ptr<MCMCProcessor> M3::Plotting::InputFile::mcmcProc

ptr to an MCMCProcessor instance to be used if this is a MaCh3 input file

Definition at line 113 of file InputManager.h.

◆ MCMCstepParamsMap

std::unordered_map<std::string, double*> M3::Plotting::InputFile::MCMCstepParamsMap

Definition at line 187 of file InputManager.h.

◆ MCMCstepTreeIndicesMap

std::unordered_map<std::string, int> M3::Plotting::InputFile::MCMCstepTreeIndicesMap

Definition at line 188 of file InputManager.h.

◆ nMCMCentries

int M3::Plotting::InputFile::nMCMCentries

The number of steps in the MCMC chain.

Definition at line 178 of file InputManager.h.

◆ posteriors1d_map

std::unordered_map<std::string, std::shared_ptr<TGraph> > M3::Plotting::InputFile::posteriors1d_map

Definition at line 190 of file InputManager.h.

◆ posteriorTree

TTree* M3::Plotting::InputFile::posteriorTree = nullptr

Definition at line 114 of file InputManager.h.

◆ postFitErrors

std::unordered_map<std::string, std::unordered_map<std::string, double> > M3::Plotting::InputFile::postFitErrors

The actual errors on the parameters, organised as postFitErrors.at(errorType).at(parameter).

Definition at line 164 of file InputManager.h.

◆ postFitValues

std::unordered_map<std::string, std::unordered_map<std::string, double> > M3::Plotting::InputFile::postFitValues

The post fit values of the parameters, organised as postFitValues.at(errorType).at(parameter).

Definition at line 167 of file InputManager.h.


The documentation for this struct was generated from the following file: