![]() |
MaCh3
2.2.3
Reference Guide
|
Class responsible for processing MCMC chains, performing diagnostics, generating plots, and managing Bayesian analysis. More...
#include <Fitters/MCMCProcessor.h>
Public Member Functions | |
MCMCProcessor (const std::string &InputFile) | |
Constructs an MCMCProcessor object with the specified input file and options. More... | |
virtual | ~MCMCProcessor () |
Destroys the MCMCProcessor object. More... | |
void | Initialise () |
Scan chain, what parameters we have and load information from covariance matrices. More... | |
void | MakePostfit (const std::map< std::string, std::pair< double, double >> &Edges={}) |
Make 1D projection for each parameter and prepare structure. More... | |
void | MakeCovariance () |
Calculate covariance by making 2D projection of each combination of parameters. More... | |
void | CacheSteps () |
KS:By caching each step we use multithreading. More... | |
void | MakeCovariance_MP (const bool Mute=false) |
Calculate covariance by making 2D projection of each combination of parameters using multithreading. More... | |
void | MakeSubOptimality (const int NIntervals=10) |
Make and Draw SubOptimality [27]. More... | |
void | ResetHistograms () |
Reset 2D posteriors, in case we would like to calculate in again with different BurnInCut. More... | |
void | DrawPostfit () |
Draw the post-fit comparisons. More... | |
void | MakeViolin () |
Make and Draw Violin. More... | |
void | MakeCredibleIntervals (const std::vector< double > &CredibleIntervals={0.99, 0.90, 0.68 }, const std::vector< Color_t > &CredibleIntervalsColours={kCyan+4, kCyan-2, kCyan-10}, const bool CredibleInSigmas=false) |
Make and Draw Credible intervals. More... | |
void | DrawCovariance () |
Draw the post-fit covariances. More... | |
void | MakeCovarianceYAML (const std::string &OutputYAMLFile, const std::string &MeansMethod) const |
Make YAML file from post-fit covariance. More... | |
void | MakeCredibleRegions (const std::vector< double > &CredibleRegions={0.99, 0.90, 0.68}, const std::vector< Style_t > &CredibleRegionStyle={kDashed, kSolid, kDotted}, const std::vector< Color_t > &CredibleRegionColor={kGreen-3, kGreen-10, kGreen}, const bool CredibleInSigmas=false, const bool Draw2DPosterior=true, const bool DrawBestFit=true) |
Make and Draw Credible Regions. More... | |
void | MakeTrianglePlot (const std::vector< std::string > &ParNames, const std::vector< double > &CredibleIntervals={0.99, 0.90, 0.68 }, const std::vector< Color_t > &CredibleIntervalsColours={kCyan+4, kCyan-2, kCyan-10}, const std::vector< double > &CredibleRegions={0.99, 0.90, 0.68}, const std::vector< Style_t > &CredibleRegionStyle={kDashed, kSolid, kDotted}, const std::vector< Color_t > &CredibleRegionColor={kGreen-3, kGreen-10, kGreen}, const bool CredibleInSigmas=false) |
Make fancy triangle plot for selected parameters. More... | |
void | CheckCredibleIntervalsOrder (const std::vector< double > &CredibleIntervals, const std::vector< Color_t > &CredibleIntervalsColours) const |
Checks the order and size consistency of the CredibleIntervals and CredibleIntervalsColours vectors. More... | |
void | CheckCredibleRegionsOrder (const std::vector< double > &CredibleRegions, const std::vector< Style_t > &CredibleRegionStyle, const std::vector< Color_t > &CredibleRegionColor) |
Checks the order and size consistency of the CredibleRegions , CredibleRegionStyle , and CredibleRegionColor vectors. More... | |
void | GetPolarPlot (const std::vector< std::string > &ParNames) |
Make funny polar plot. More... | |
void | GetBayesFactor (const std::vector< std::string > &ParName, const std::vector< std::vector< double >> &Model1Bounds, const std::vector< std::vector< double >> &Model2Bounds, const std::vector< std::vector< std::string >> &ModelNames) |
Calculate Bayes factor for vector of params, and model boundaries. More... | |
void | GetSavageDickey (const std::vector< std::string > &ParName, const std::vector< double > &EvaluationPoint, const std::vector< std::vector< double >> &Bounds) |
Calculate Bayes factor for point like hypothesis using SavageDickey. More... | |
void | SavageDickeyPlot (std::unique_ptr< TH1D > &PriorHist, std::unique_ptr< TH1D > &PosteriorHist, const std::string &Title, const double EvaluationPoint) const |
Produce Savage Dickey plot. More... | |
void | ReweightPrior (const std::vector< std::string > &Names, const std::vector< double > &NewCentral, const std::vector< double > &NewError) |
Reweight Prior by giving new central value and new error. More... | |
void | SmearChain (const std::vector< std::string > &Names, const std::vector< double > &NewCentral, const bool &SaveBranch) |
Smear chain contours. More... | |
void | ParameterEvolution (const std::vector< std::string > &Names, const std::vector< int > &NIntervals) |
Make .gif of parameter evolution. More... | |
void | ThinMCMC (const int ThinningCut) const |
Thin MCMC Chain, to save space and maintain low autocorrelations. More... | |
void | DiagMCMC () |
KS: Perform MCMC diagnostic including Autocorrelation, Trace etc. More... | |
int | GetNParams () const |
Get total number of used parameters. More... | |
int | GetNXSec () const |
int | GetNND () const |
int | GetNFD () const |
YAML::Node | GetCovConfig (const int i) const |
Get Yaml config obtained from a Chain. More... | |
int | GetGroup (const std::string &name) const |
Number of params from a given group, for example flux. More... | |
TH1D * | GetHpost (const int i) const |
Get 1D posterior for a given parameter. More... | |
TH2D * | GetHpost2D (const int i, const int j) const |
Get 2D posterior for a given parameter combination. More... | |
TH2D * | GetViolin () const |
Get Violin plot for all parameters with posterior values. More... | |
TH2D * | GetViolinPrior () const |
Get Violin plot for all parameters with prior values. More... | |
std::vector< std::string > | GetXSecCov () const |
std::string | GetNDCov () const |
std::string | GetFDCov () const |
void | GetPostfit (TVectorD *&Central, TVectorD *&Errors, TVectorD *&Central_Gauss, TVectorD *&Errors_Gauss, TVectorD *&Peaks) |
Get the post-fit results (arithmetic and Gaussian) More... | |
void | GetCovariance (TMatrixDSym *&Cov, TMatrixDSym *&Corr) |
Get the post-fit covariances and correlations. More... | |
void | GetPostfit_Ind (TVectorD *&Central, TVectorD *&Errors, TVectorD *&Peaks, ParameterEnum kParam) |
Or the individual post-fits. More... | |
const std::vector< TString > & | GetBranchNames () const |
Get the vector of branch names from root file. More... | |
void | GetNthParameter (const int param, double &Prior, double &PriorError, TString &Title) const |
Get properties of parameter by passing it number. More... | |
int | GetParamIndexFromName (const std::string &Name) |
Get parameter number based on name. More... | |
Long64_t | GetnEntries () |
Get Number of entries that Chain has, for merged chains will not be the same Nsteps. More... | |
Long64_t | GetnSteps () |
Get Number of Steps that Chain has, for merged chains will not be the same nEntries. More... | |
void | SetNBins (const int NewBins) |
Modify number of bins used for 1D and 2D Histograms. More... | |
void | SetEntries (const int NewEntries) |
Set number of entries to make potentially MCMC Processing faster. More... | |
void | SetStepCut (const std::string &Cuts) |
Set the step cutting by string. More... | |
void | SetStepCut (const int Cuts) |
Set the step cutting by int. More... | |
void | CheckStepCut () const |
Check if step cut isn't larger than highest values of step in a chain. More... | |
void | SetPlotRelativeToPrior (const bool PlotOrNot) |
You can set relative to prior or relative to generated. It is advised to use relate to prior. More... | |
void | SetPrintToPDF (const bool PlotOrNot) |
void | SetPlotErrorForFlatPrior (const bool PlotOrNot) |
Set whether you want to plot error for parameters which have flat prior. More... | |
void | SetPlotBinValue (const bool PlotOrNot) |
void | SetFancyNames (const bool PlotOrNot) |
void | SetSmoothing (const bool PlotOrNot) |
Set whether want to use smoothing for histograms using ROOT algorithm. More... | |
void | SetPost2DPlotThreshold (const double Threshold) |
Code will only plot 2D posteriors if Correlation are larger than defined threshold. More... | |
void | SetUseFFTAutoCorrelation (const bool useFFT) |
Toggle using the FFT-based autocorrelation calculator. More... | |
void | SetExcludedTypes (std::vector< std::string > Name) |
Setter related what parameters we want to exclude from analysis, for example if cross-section parameters look like xsec_, then passing "xsec_" will. More... | |
void | SetExcludedNames (std::vector< std::string > Name) |
void | SetExcludedGroups (std::vector< std::string > Name) |
void | SetnBatches (const int Batches) |
Set value of Nbatches used for batched mean, this need to be done earlier as batches are made when reading tree. More... | |
void | SetnLags (const int nLags) |
void | SetOutputSuffix (const std::string Suffix) |
Sett output suffix, this way jobs using the same file will have different names. More... | |
void | SetPosterior1DCut (const std::string Cut) |
Allow to set addtional cuts based on ROOT TBrowser cut, for to only affect one mass ordering. More... | |
Protected Member Functions | |
std::unique_ptr< TH1D > | MakePrefit () |
Prepare prefit histogram for parameter overlay plot. More... | |
void | MakeOutputFile () |
prepare output root file and canvas to which we will save EVERYTHING More... | |
void | DrawCorrelations1D () |
Draw 1D correlations which might be more helpful than looking at huge 2D Corr matrix. More... | |
void | DrawCorrelationsGroup (const std::unique_ptr< TH2D > &CorrMatrix) const |
Produces correlation matrix but instead of giving name for each param it only give name for param group. More... | |
void | ReadInputCov () |
CW: Read the input Covariance matrix entries. Get stuff like parameter input errors, names, and so on. More... | |
void | ReadInputCovLegacy () |
void | FindInputFiles () |
Read the output MCMC file and find what inputs were used. More... | |
void | FindInputFilesLegacy () |
void | ReadModelFile () |
Read the xsec file and get the input central values and errors. More... | |
virtual void | LoadAdditionalInfo () |
allow loading additional info for example used for oscillation parameters More... | |
void | ReadNDFile () |
Read the ND cov file and get the input central values and errors. More... | |
void | ReadFDFile () |
Read the FD cov file and get the input central values and errors. More... | |
void | PrintInfo () const |
Print info like how many params have been loaded etc. More... | |
void | ScanInput () |
Scan Input etc. More... | |
void | ScanParameterOrder () |
Scan order of params from a different groups. More... | |
void | SetupOutput () |
Prepare all objects used for output. More... | |
void | PrepareDiagMCMC () |
CW: Prepare branches etc. for DiagMCMC. More... | |
void | ParamTraces () |
CW: Draw trace plots of the parameters i.e. parameter vs step. More... | |
void | AutoCorrelation () |
KS: Calculate autocorrelations supports both OpenMP and CUDA :) More... | |
void | AutoCorrelation_FFT () |
MJR: Autocorrelation function using FFT algorithm for extra speed. More... | |
void | CalculateESS (const int nLags, const std::vector< std::vector< double >> &LagL) |
KS: calc Effective Sample Size. More... | |
void | BatchedAnalysis () |
Get the batched means variance estimation and variable indicating if number of batches is sensible [4] [28]. More... | |
void | BatchedMeans () |
CW: Batched means, literally read from an array and chuck into TH1D. More... | |
void | GewekeDiagnostic () |
Geweke Diagnostic based on the methods described by Fang (2014) and Karlsbakk (2011). [8] [20]. More... | |
void | AcceptanceProbabilities () |
Acceptance Probability. More... | |
void | PowerSpectrumAnalysis () |
RC: Perform spectral analysis of MCMC [7]. More... | |
std::vector< double > | GetMargins (const std::unique_ptr< TCanvas > &Canv) const |
Get TCanvas margins, to be able to reset them if particular function need different margins. More... | |
void | SetMargins (std::unique_ptr< TCanvas > &Canv, const std::vector< double > &margins) |
Set TCanvas margins to specified values. More... | |
void | SetTLineStyle (TLine *Line, const Color_t Colour, const Width_t Width, const ELineStyle Style) const |
Configures a TLine object with the specified style parameters. More... | |
void | SetLegendStyle (TLegend *Legend, const double size) const |
Configures the style of a TLegend object. More... | |
Protected Attributes | |
std::string | MCMCFile |
Name of MCMC file. More... | |
std::string | OutputSuffix |
Output file suffix useful when running over same file with different settings. More... | |
std::vector< std::vector< std::string > > | CovPos |
Covariance matrix file name position. More... | |
std::vector< std::string > | CovNamePos |
Covariance matrix name position. More... | |
std::vector< YAML::Node > | CovConfig |
Covariance matrix config. More... | |
TChain * | Chain |
Main chain storing all steps etc. More... | |
std::string | StepCut |
BurnIn Cuts. More... | |
std::string | Posterior1DCut |
Cut used when making 1D Posterior distribution. More... | |
unsigned int | UpperCut |
KS: Used only for SubOptimality. More... | |
unsigned int | BurnInCut |
Value of burn in cut. More... | |
int | nBranches |
Number of branches in a TTree. More... | |
int | nEntries |
KS: For merged chains number of entries will be different from nSteps. More... | |
int | nSteps |
KS: For merged chains number of entries will be different from nSteps. More... | |
int | nSamples |
Number of sample PDF objects. More... | |
int | nSysts |
Number of covariance objects. More... | |
int | nDraw |
Number of all parameters used in the analysis. More... | |
std::vector< TString > | BranchNames |
std::vector< std::string > | ExcludedTypes |
std::vector< std::string > | ExcludedNames |
std::vector< std::string > | ExcludedGroups |
std::vector< bool > | IamVaried |
Is the ith parameter varied. More... | |
std::vector< std::vector< TString > > | ParamNames |
Name of parameters which we are going to analyse. More... | |
std::vector< std::vector< double > > | ParamCentral |
Parameters central values which we are going to analyse. More... | |
std::vector< std::vector< double > > | ParamNom |
std::vector< std::vector< double > > | ParamErrors |
Uncertainty on a single parameter. More... | |
std::vector< std::vector< bool > > | ParamFlat |
Whether Param has flat prior or not. More... | |
std::vector< int > | nParam |
Number of parameters per type. More... | |
std::vector< ParameterEnum > | ParamType |
Make an enum for which class this parameter belongs to so we don't have to keep string comparing. More... | |
std::vector< int > | ParamTypeStartPos |
std::vector< std::string > | ParameterGroup |
std::vector< TString > | SampleName_v |
Vector of each systematic. More... | |
std::vector< TString > | SystName_v |
Vector of each sample PDF object. More... | |
std::string | OutputName |
Name of output files. More... | |
TString | CanvasName |
Name of canvas which help to save to the sample pdf. More... | |
bool | PlotFlatPrior |
Whether we plot flat prior or not, we usually provide error even for flat prior params. More... | |
bool | plotRelativeToPrior |
Whether we plot relative to prior or nominal, in most cases is prior. More... | |
bool | MadePostfit |
Sanity check if Postfit is already done to not make several times. More... | |
bool | printToPDF |
Will plot all plot to PDF not only to root file. More... | |
bool | FancyPlotNames |
Whether we want fancy plot names or not. More... | |
bool | plotBinValue |
If true it will print value on each bin of covariance matrix. More... | |
bool | ApplySmoothing |
Apply smoothing for 2D histos using root algorithm. More... | |
double | Post2DPlotThreshold |
KS: Set Threshold when to plot 2D posterior as by default we get a LOT of plots. More... | |
bool | useFFTAutoCorrelation |
MJR: Use FFT-based autocorrelation algorithm (save time & resources)? More... | |
std::vector< int > | NDSamplesBins |
std::vector< std::string > | NDSamplesNames |
std::unique_ptr< TF1 > | Gauss |
Gaussian fitter. More... | |
TFile * | OutputFile |
The output file. More... | |
std::unique_ptr< TCanvas > | Posterior |
Fancy canvas used for our beautiful plots. More... | |
TVectorD * | Central_Value |
Vector with central value for each parameter. More... | |
TVectorD * | Means |
Vector with mean values using Arithmetic Mean. More... | |
TVectorD * | Errors |
Vector with errors values using RMS. More... | |
TVectorD * | Means_Gauss |
Vector with mean values using Gaussian fit. More... | |
TVectorD * | Errors_Gauss |
Vector with error values using Gaussian fit. More... | |
TVectorD * | Means_HPD |
Vector with mean values using Highest Posterior Density. More... | |
TVectorD * | Errors_HPD |
Vector with error values using Highest Posterior Density. More... | |
TVectorD * | Errors_HPD_Positive |
Vector with positive error (right hand side) values using Highest Posterior Density. More... | |
TVectorD * | Errors_HPD_Negative |
Vector with negative error (left hand side) values using Highest Posterior Density. More... | |
TMatrixDSym * | Covariance |
Posterior Covariance Matrix. More... | |
TMatrixDSym * | Correlation |
Posterior Correlation Matrix. More... | |
std::vector< TH1D * > | hpost |
Holds 1D Posterior Distributions. More... | |
std::vector< std::vector< TH2D * > > | hpost2D |
Holds 2D Posterior Distributions. More... | |
std::unique_ptr< TH2D > | hviolin |
Holds violin plot for all dials. More... | |
std::unique_ptr< TH2D > | hviolin_prior |
Holds prior violin plot for all dials,. More... | |
double ** | ParStep |
Array holding values for all parameters. More... | |
unsigned int * | StepNumber |
Step number for step, important if chains were merged. More... | |
int | nBins |
Number of bins. More... | |
double | DrawRange |
Drawrange for SetMaximum. More... | |
bool | CacheMCMC |
MCMC Chain has been cached. More... | |
bool | doDiagMCMC |
Doing MCMC Diagnostic. More... | |
int | nBatches |
Number of batches for Batched Mean. More... | |
int | AutoCorrLag |
LagL used in AutoCorrelation. More... | |
double * | ParamSums |
Total parameter sum for each param. More... | |
double ** | BatchedAverages |
Values of batched average for every param and batch. More... | |
double ** | SampleValues |
Holds the sample values. More... | |
double ** | SystValues |
Holds the systs values. More... | |
double * | AccProbValues |
Holds all accProb. More... | |
double * | AccProbBatchedAverages |
Holds all accProb in batches. More... | |
bool | ReweightPosterior |
Whether to apply reweighting weight or not. More... | |
std::string | ReweightName |
Name of branch used for chain reweighting. More... | |
double * | WeightValue |
Stores value of weight for each step. More... | |
Class responsible for processing MCMC chains, performing diagnostics, generating plots, and managing Bayesian analysis.
This class provides utilities to handle MCMC output generated by mcmc::runMCMC. It is particularly useful for extracting values from previous MCMC runs and initiating new MCMC runs with those values. Inspired by nd280_utils/DrawComp.cpp.
Definition at line 61 of file MCMCProcessor.h.
_MaCh3_Safe_Include_Start_ _MaCh3_Safe_Include_End_ MCMCProcessor::MCMCProcessor | ( | const std::string & | InputFile | ) |
Constructs an MCMCProcessor object with the specified input file and options.
InputFile | The path to the input file containing MCMC data. |
Definition at line 17 of file MCMCProcessor.cpp.
|
virtual |
Destroys the MCMCProcessor object.
Definition at line 109 of file MCMCProcessor.cpp.
|
inlineprotected |
Acceptance Probability.
Definition at line 4428 of file MCMCProcessor.cpp.
|
inlineprotected |
KS: Calculate autocorrelations supports both OpenMP and CUDA :)
Definition at line 3685 of file MCMCProcessor.cpp.
|
inlineprotected |
MJR: Autocorrelation function using FFT algorithm for extra speed.
Definition at line 3590 of file MCMCProcessor.cpp.
|
inlineprotected |
Get the batched means variance estimation and variable indicating if number of batches is sensible [4] [28].
Definition at line 4059 of file MCMCProcessor.cpp.
|
inlineprotected |
CW: Batched means, literally read from an array and chuck into TH1D.
Definition at line 4001 of file MCMCProcessor.cpp.
void MCMCProcessor::CacheSteps | ( | ) |
KS:By caching each step we use multithreading.
Definition at line 1072 of file MCMCProcessor.cpp.
|
inlineprotected |
KS: calc Effective Sample Size.
nLags | Should be the same nLags as used in AutoCorrelation() |
LagL | Value of LagL for each dial and each Lag |
This function computes the Effective Sample Size (ESS) using the autocorrelations calculated by AutoCorrelation(). Ensure that the parameter nLags here matches the number of lags used in AutoCorrelation() to obtain accurate results. [30] [14] [9]
Definition at line 3904 of file MCMCProcessor.cpp.
void MCMCProcessor::CheckCredibleIntervalsOrder | ( | const std::vector< double > & | CredibleIntervals, |
const std::vector< Color_t > & | CredibleIntervalsColours | ||
) | const |
Checks the order and size consistency of the CredibleIntervals
and CredibleIntervalsColours
vectors.
CredibleIntervals | A vector of credible interval values. |
CredibleIntervalsColours | A vector of colors associated with each credible interval. |
MaCh3Exception | If the sizes are not equal or the intervals are not in decreasing order. |
Definition at line 4474 of file MCMCProcessor.cpp.
void MCMCProcessor::CheckCredibleRegionsOrder | ( | const std::vector< double > & | CredibleRegions, |
const std::vector< Style_t > & | CredibleRegionStyle, | ||
const std::vector< Color_t > & | CredibleRegionColor | ||
) |
Checks the order and size consistency of the CredibleRegions
, CredibleRegionStyle
, and CredibleRegionColor
vectors.
CredibleRegions | A vector of credible region values. |
CredibleRegionStyle | A vector of styles associated with each credible region. |
CredibleRegionColor | A vector of colors associated with each credible region. |
MaCh3Exception | If the sizes are not equal or the regions are not in decreasing order. |
Definition at line 4493 of file MCMCProcessor.cpp.
void MCMCProcessor::CheckStepCut | ( | ) | const |
Check if step cut isn't larger than highest values of step in a chain.
Definition at line 2685 of file MCMCProcessor.cpp.
void MCMCProcessor::DiagMCMC | ( | ) |
KS: Perform MCMC diagnostic including Autocorrelation, Trace etc.
Definition at line 3304 of file MCMCProcessor.cpp.
|
inlineprotected |
Draw 1D correlations which might be more helpful than looking at huge 2D Corr matrix.
Definition at line 1641 of file MCMCProcessor.cpp.
|
inlineprotected |
Produces correlation matrix but instead of giving name for each param it only give name for param group.
CorrMatrix | correlation matrix that we are going to plot |
Definition at line 1531 of file MCMCProcessor.cpp.
void MCMCProcessor::DrawCovariance | ( | ) |
Draw the post-fit covariances.
Definition at line 1385 of file MCMCProcessor.cpp.
void MCMCProcessor::DrawPostfit | ( | ) |
Draw the post-fit comparisons.
Definition at line 436 of file MCMCProcessor.cpp.
|
inlineprotected |
Read the output MCMC file and find what inputs were used.
Definition at line 2411 of file MCMCProcessor.cpp.
|
inlineprotected |
Definition at line 2476 of file MCMCProcessor.cpp.
void MCMCProcessor::GetBayesFactor | ( | const std::vector< std::string > & | ParName, |
const std::vector< std::vector< double >> & | Model1Bounds, | ||
const std::vector< std::vector< double >> & | Model2Bounds, | ||
const std::vector< std::vector< std::string >> & | ModelNames | ||
) |
Calculate Bayes factor for vector of params, and model boundaries.
ParName | Vector with parameter names for which we calculate Bayes factor |
Model1Bounds | Lower and upper bound for hypothesis 1. Within this bound we calculate integral used later for Bayes Factor |
Model2Bounds | Lower and upper bound for hypothesis 2. Within this bound we calculate integral used later for Bayes Factor |
ModelNames | Names for hypothesis 1 and 2 |
Definition at line 2816 of file MCMCProcessor.cpp.
|
inline |
void MCMCProcessor::GetCovariance | ( | TMatrixDSym *& | Cov, |
TMatrixDSym *& | Corr | ||
) |
Get the post-fit covariances and correlations.
Cov | Covariance matrix |
Corr | Correlation matrix |
Definition at line 196 of file MCMCProcessor.cpp.
|
inline |
|
inline |
Definition at line 236 of file MCMCProcessor.h.
int MCMCProcessor::GetGroup | ( | const std::string & | name | ) | const |
Number of params from a given group, for example flux.
Definition at line 4512 of file MCMCProcessor.cpp.
|
inline |
Get 1D posterior for a given parameter.
i | parameter index |
Definition at line 223 of file MCMCProcessor.h.
|
inline |
Get 2D posterior for a given parameter combination.
i | parameter index X |
j | parameter index Y |
Definition at line 227 of file MCMCProcessor.h.
|
protected |
Get TCanvas margins, to be able to reset them if particular function need different margins.
Definition at line 4556 of file MCMCProcessor.cpp.
|
inline |
Definition at line 235 of file MCMCProcessor.h.
|
inline |
Get Number of entries that Chain has, for merged chains will not be the same Nsteps.
Definition at line 254 of file MCMCProcessor.h.
|
inline |
Definition at line 213 of file MCMCProcessor.h.
|
inline |
Definition at line 212 of file MCMCProcessor.h.
|
inline |
|
inline |
Get Number of Steps that Chain has, for merged chains will not be the same nEntries.
Definition at line 256 of file MCMCProcessor.h.
void MCMCProcessor::GetNthParameter | ( | const int | param, |
double & | Prior, | ||
double & | PriorError, | ||
TString & | Title | ||
) | const |
Get properties of parameter by passing it number.
Definition at line 2696 of file MCMCProcessor.cpp.
|
inline |
Definition at line 211 of file MCMCProcessor.h.
int MCMCProcessor::GetParamIndexFromName | ( | const std::string & | Name | ) |
void MCMCProcessor::GetPolarPlot | ( | const std::vector< std::string > & | ParNames | ) |
Make funny polar plot.
ParNames | Vector with parameter names for which Polar Plot will be made |
Definition at line 2747 of file MCMCProcessor.cpp.
void MCMCProcessor::GetPostfit | ( | TVectorD *& | Central, |
TVectorD *& | Errors, | ||
TVectorD *& | Central_Gauss, | ||
TVectorD *& | Errors_Gauss, | ||
TVectorD *& | Peaks | ||
) |
Get the post-fit results (arithmetic and Gaussian)
Definition at line 163 of file MCMCProcessor.cpp.
void MCMCProcessor::GetPostfit_Ind | ( | TVectorD *& | Central, |
TVectorD *& | Errors, | ||
TVectorD *& | Peaks, | ||
ParameterEnum | kParam | ||
) |
void MCMCProcessor::GetSavageDickey | ( | const std::vector< std::string > & | ParName, |
const std::vector< double > & | EvaluationPoint, | ||
const std::vector< std::vector< double >> & | Bounds | ||
) |
Calculate Bayes factor for point like hypothesis using SavageDickey.
Definition at line 2873 of file MCMCProcessor.cpp.
|
inline |
Get Violin plot for all parameters with posterior values.
Definition at line 229 of file MCMCProcessor.h.
|
inline |
Get Violin plot for all parameters with prior values.
Definition at line 231 of file MCMCProcessor.h.
|
inline |
Definition at line 234 of file MCMCProcessor.h.
|
inlineprotected |
Geweke Diagnostic based on the methods described by Fang (2014) and Karlsbakk (2011). [8] [20].
Definition at line 4296 of file MCMCProcessor.cpp.
void MCMCProcessor::Initialise | ( | ) |
Scan chain, what parameters we have and load information from covariance matrices.
Definition at line 153 of file MCMCProcessor.cpp.
|
inlineprotectedvirtual |
allow loading additional info for example used for oscillation parameters
Reimplemented in OscProcessor.
Definition at line 343 of file MCMCProcessor.h.
void MCMCProcessor::MakeCovariance | ( | ) |
Calculate covariance by making 2D projection of each combination of parameters.
Definition at line 959 of file MCMCProcessor.cpp.
void MCMCProcessor::MakeCovariance_MP | ( | const bool | Mute = false | ) |
Calculate covariance by making 2D projection of each combination of parameters using multithreading.
Mute | Allow silencing many messages, especially important if we calculate matrix many times |
Definition at line 1200 of file MCMCProcessor.cpp.
void MCMCProcessor::MakeCovarianceYAML | ( | const std::string & | OutputYAMLFile, |
const std::string & | MeansMethod | ||
) | const |
Make YAML file from post-fit covariance.
Definition at line 1478 of file MCMCProcessor.cpp.
void MCMCProcessor::MakeCredibleIntervals | ( | const std::vector< double > & | CredibleIntervals = {0.99, 0.90, 0.68 } , |
const std::vector< Color_t > & | CredibleIntervalsColours = {kCyan+4, kCyan-2, kCyan-10} , |
||
const bool | CredibleInSigmas = false |
||
) |
Make and Draw Credible intervals.
CredibleIntervals | Vector with values of credible intervals, must be in descending order |
CredibleIntervalsColours | Color_t telling what colour to use for each Interval line |
CredibleInSigmas | Bool telling whether intervals are in percentage or in sigmas, then special conversions is used |
Scale the histograms so it shows the posterior probability
Definition at line 701 of file MCMCProcessor.cpp.
void MCMCProcessor::MakeCredibleRegions | ( | const std::vector< double > & | CredibleRegions = {0.99, 0.90, 0.68} , |
const std::vector< Style_t > & | CredibleRegionStyle = {kDashed, kSolid, kDotted} , |
||
const std::vector< Color_t > & | CredibleRegionColor = {kGreen-3, kGreen-10, kGreen} , |
||
const bool | CredibleInSigmas = false , |
||
const bool | Draw2DPosterior = true , |
||
const bool | DrawBestFit = true |
||
) |
Make and Draw Credible Regions.
CredibleRegions | Vector with values of credible intervals, must be in descending order |
CredibleRegionStyle | Style_t telling what line style to use for each Interval line |
CredibleRegionColor | Color_t telling what colour to use for each Interval line |
CredibleInSigmas | Bool telling whether intervals are in percentage or in sigmas, then special conversions is used |
Definition at line 1776 of file MCMCProcessor.cpp.
|
inlineprotected |
prepare output root file and canvas to which we will save EVERYTHING
Definition at line 205 of file MCMCProcessor.cpp.
void MCMCProcessor::MakePostfit | ( | const std::map< std::string, std::pair< double, double >> & | Edges = {} | ) |
Make 1D projection for each parameter and prepare structure.
Definition at line 239 of file MCMCProcessor.cpp.
|
inlineprotected |
Prepare prefit histogram for parameter overlay plot.
Definition at line 2331 of file MCMCProcessor.cpp.
void MCMCProcessor::MakeSubOptimality | ( | const int | NIntervals = 10 | ) |
Make and Draw SubOptimality [27].
Definition at line 1316 of file MCMCProcessor.cpp.
void MCMCProcessor::MakeTrianglePlot | ( | const std::vector< std::string > & | ParNames, |
const std::vector< double > & | CredibleIntervals = {0.99, 0.90, 0.68 } , |
||
const std::vector< Color_t > & | CredibleIntervalsColours = {kCyan+4, kCyan-2, kCyan-10} , |
||
const std::vector< double > & | CredibleRegions = {0.99, 0.90, 0.68} , |
||
const std::vector< Style_t > & | CredibleRegionStyle = {kDashed, kSolid, kDotted} , |
||
const std::vector< Color_t > & | CredibleRegionColor = {kGreen-3, kGreen-10, kGreen} , |
||
const bool | CredibleInSigmas = false |
||
) |
Make fancy triangle plot for selected parameters.
CredibleIntervals | Vector with values of credible intervals, must be in descending order |
CredibleIntervalsColours | Color_t telling what colour to use for each Interval line |
CredibleInSigmas | Bool telling whether intervals are in percentage or in sigmas, then special conversions is used |
CredibleRegions | Vector with values of credible intervals, must be in descending order |
CredibleRegionStyle | Style_t telling what line style to use for each Interval line |
CredibleRegionColor | Color_t telling what colour to use for each Interval line |
Scale the histograms so it shows the posterior probability
Definition at line 1893 of file MCMCProcessor.cpp.
void MCMCProcessor::MakeViolin | ( | ) |
Make and Draw Violin.
Definition at line 808 of file MCMCProcessor.cpp.
void MCMCProcessor::ParameterEvolution | ( | const std::vector< std::string > & | Names, |
const std::vector< int > & | NIntervals | ||
) |
Make .gif of parameter evolution.
Names | Parameter names for which we do .gif |
NIntervals | Number of intervals for a gif |
Definition at line 3222 of file MCMCProcessor.cpp.
|
inlineprotected |
CW: Draw trace plots of the parameters i.e. parameter vs step.
Definition at line 3497 of file MCMCProcessor.cpp.
|
inlineprotected |
RC: Perform spectral analysis of MCMC [7].
Definition at line 4174 of file MCMCProcessor.cpp.
|
inlineprotected |
CW: Prepare branches etc. for DiagMCMC.
Definition at line 3334 of file MCMCProcessor.cpp.
|
inlineprotected |
Print info like how many params have been loaded etc.
Definition at line 4529 of file MCMCProcessor.cpp.
|
inlineprotected |
Read the FD cov file and get the input central values and errors.
Definition at line 2629 of file MCMCProcessor.cpp.
|
inlineprotected |
CW: Read the input Covariance matrix entries. Get stuff like parameter input errors, names, and so on.
Definition at line 2393 of file MCMCProcessor.cpp.
|
inlineprotected |
Definition at line 2402 of file MCMCProcessor.cpp.
|
inlineprotected |
Read the xsec file and get the input central values and errors.
Definition at line 2525 of file MCMCProcessor.cpp.
|
inlineprotected |
Read the ND cov file and get the input central values and errors.
Definition at line 2586 of file MCMCProcessor.cpp.
void MCMCProcessor::ResetHistograms | ( | ) |
Reset 2D posteriors, in case we would like to calculate in again with different BurnInCut.
Definition at line 2729 of file MCMCProcessor.cpp.
void MCMCProcessor::ReweightPrior | ( | const std::vector< std::string > & | Names, |
const std::vector< double > & | NewCentral, | ||
const std::vector< double > & | NewError | ||
) |
Reweight Prior by giving new central value and new error.
Names | Parameter names for which we do reweighting |
NewCentral | New central value for which we reweight |
NewError | New error used for calculating weight |
Definition at line 3015 of file MCMCProcessor.cpp.
void MCMCProcessor::SavageDickeyPlot | ( | std::unique_ptr< TH1D > & | PriorHist, |
std::unique_ptr< TH1D > & | PosteriorHist, | ||
const std::string & | Title, | ||
const double | EvaluationPoint | ||
) | const |
Produce Savage Dickey plot.
PriorHist | Histogram with prior distribution |
PosteriorHist | Histogram with posterior distribution |
Definition at line 2953 of file MCMCProcessor.cpp.
|
inlineprotected |
Scan Input etc.
Definition at line 2151 of file MCMCProcessor.cpp.
|
inlineprotected |
|
inline |
Set number of entries to make potentially MCMC Processing faster.
Definition at line 262 of file MCMCProcessor.h.
|
inline |
Definition at line 310 of file MCMCProcessor.h.
|
inline |
Definition at line 309 of file MCMCProcessor.h.
|
inline |
Setter related what parameters we want to exclude from analysis, for example if cross-section parameters look like xsec_, then passing "xsec_" will.
Batches | Vector with parameters type names we want to exclude |
Definition at line 308 of file MCMCProcessor.h.
|
inline |
Definition at line 297 of file MCMCProcessor.h.
|
protected |
Configures the style of a TLegend object.
Legend | Pointer to the TLegend object to modify |
size | The text size to set for the legend |
Definition at line 4588 of file MCMCProcessor.cpp.
|
protected |
|
inline |
Set value of Nbatches used for batched mean, this need to be done earlier as batches are made when reading tree.
Batches | Number of batches, default is 20 |
Definition at line 314 of file MCMCProcessor.h.
|
inline |
Modify number of bins used for 1D and 2D Histograms.
Definition at line 258 of file MCMCProcessor.h.
|
inline |
Definition at line 315 of file MCMCProcessor.h.
|
inline |
Sett output suffix, this way jobs using the same file will have different names.
Definition at line 318 of file MCMCProcessor.h.
|
inline |
Definition at line 296 of file MCMCProcessor.h.
|
inline |
Set whether you want to plot error for parameters which have flat prior.
Definition at line 295 of file MCMCProcessor.h.
|
inline |
You can set relative to prior or relative to generated. It is advised to use relate to prior.
PlotOrNot | bool controlling plotRelativeToPrior argument |
Definition at line 292 of file MCMCProcessor.h.
|
inline |
Code will only plot 2D posteriors if Correlation are larger than defined threshold.
Threshold | This threshold is compared with correlation value |
Definition at line 302 of file MCMCProcessor.h.
|
inline |
Allow to set addtional cuts based on ROOT TBrowser cut, for to only affect one mass ordering.
Definition at line 320 of file MCMCProcessor.h.
|
inline |
Definition at line 293 of file MCMCProcessor.h.
|
inline |
Set whether want to use smoothing for histograms using ROOT algorithm.
Definition at line 299 of file MCMCProcessor.h.
void MCMCProcessor::SetStepCut | ( | const int | Cuts | ) |
Set the step cutting by int.
Cuts | integer telling cut value |
Definition at line 2674 of file MCMCProcessor.cpp.
void MCMCProcessor::SetStepCut | ( | const std::string & | Cuts | ) |
Set the step cutting by string.
Cuts | string telling cut value |
Definition at line 2664 of file MCMCProcessor.cpp.
|
protected |
Configures a TLine object with the specified style parameters.
Line | Pointer to the TLine object to modify. Must not be nullptr. |
Colour | The color to set for the line. |
Width | The width of the line. |
Style | The line style (e.g., solid, dashed, etc.). |
Definition at line 4580 of file MCMCProcessor.cpp.
|
inlineprotected |
Prepare all objects used for output.
Definition at line 2256 of file MCMCProcessor.cpp.
|
inline |
Toggle using the FFT-based autocorrelation calculator.
Definition at line 304 of file MCMCProcessor.h.
void MCMCProcessor::SmearChain | ( | const std::vector< std::string > & | Names, |
const std::vector< double > & | NewCentral, | ||
const bool & | SaveBranch | ||
) |
Smear chain contours.
Names | Parameter names for which we do smearing |
Error | Error based on which we smear |
SaveBranch | Whether we save unsmeared branch or not |
Definition at line 3127 of file MCMCProcessor.cpp.
|
inline |
Thin MCMC Chain, to save space and maintain low autocorrelations.
ThinningCut | every which entry you want to thin |
Average | If true will perform MCMC averaging instead of thinning |
Definition at line 203 of file MCMCProcessor.h.
|
protected |
Holds all accProb in batches.
Definition at line 583 of file MCMCProcessor.h.
|
protected |
Holds all accProb.
Definition at line 581 of file MCMCProcessor.h.
|
protected |
Apply smoothing for 2D histos using root algorithm.
Definition at line 497 of file MCMCProcessor.h.
|
protected |
LagL used in AutoCorrelation.
Definition at line 568 of file MCMCProcessor.h.
|
protected |
Values of batched average for every param and batch.
Definition at line 573 of file MCMCProcessor.h.
|
protected |
Definition at line 446 of file MCMCProcessor.h.
|
protected |
Value of burn in cut.
Definition at line 431 of file MCMCProcessor.h.
|
protected |
MCMC Chain has been cached.
Definition at line 560 of file MCMCProcessor.h.
|
protected |
Name of canvas which help to save to the sample pdf.
Definition at line 480 of file MCMCProcessor.h.
|
protected |
Vector with central value for each parameter.
Definition at line 517 of file MCMCProcessor.h.
|
protected |
Main chain storing all steps etc.
Definition at line 423 of file MCMCProcessor.h.
|
protected |
Posterior Correlation Matrix.
Definition at line 538 of file MCMCProcessor.h.
|
protected |
Posterior Covariance Matrix.
Definition at line 536 of file MCMCProcessor.h.
|
protected |
Covariance matrix config.
Definition at line 420 of file MCMCProcessor.h.
|
protected |
Covariance matrix name position.
Definition at line 418 of file MCMCProcessor.h.
|
protected |
Covariance matrix file name position.
Definition at line 416 of file MCMCProcessor.h.
|
protected |
Doing MCMC Diagnostic.
Definition at line 562 of file MCMCProcessor.h.
|
protected |
Drawrange for SetMaximum.
Definition at line 557 of file MCMCProcessor.h.
|
protected |
Vector with errors values using RMS.
Definition at line 521 of file MCMCProcessor.h.
|
protected |
Vector with error values using Gaussian fit.
Definition at line 525 of file MCMCProcessor.h.
|
protected |
Vector with error values using Highest Posterior Density.
Definition at line 529 of file MCMCProcessor.h.
|
protected |
Vector with negative error (left hand side) values using Highest Posterior Density.
Definition at line 533 of file MCMCProcessor.h.
|
protected |
Vector with positive error (right hand side) values using Highest Posterior Density.
Definition at line 531 of file MCMCProcessor.h.
|
protected |
Definition at line 449 of file MCMCProcessor.h.
|
protected |
Definition at line 448 of file MCMCProcessor.h.
|
protected |
Definition at line 447 of file MCMCProcessor.h.
|
protected |
Whether we want fancy plot names or not.
Definition at line 493 of file MCMCProcessor.h.
|
protected |
Gaussian fitter.
Definition at line 507 of file MCMCProcessor.h.
|
protected |
Holds 1D Posterior Distributions.
Definition at line 541 of file MCMCProcessor.h.
|
protected |
Holds 2D Posterior Distributions.
Definition at line 543 of file MCMCProcessor.h.
|
protected |
Holds violin plot for all dials.
Definition at line 545 of file MCMCProcessor.h.
|
protected |
Holds prior violin plot for all dials,.
Definition at line 547 of file MCMCProcessor.h.
|
protected |
Is the ith parameter varied.
Definition at line 452 of file MCMCProcessor.h.
|
protected |
Sanity check if Postfit is already done to not make several times.
Definition at line 489 of file MCMCProcessor.h.
|
protected |
Name of MCMC file.
Definition at line 412 of file MCMCProcessor.h.
|
protected |
Vector with mean values using Arithmetic Mean.
Definition at line 519 of file MCMCProcessor.h.
|
protected |
Vector with mean values using Gaussian fit.
Definition at line 523 of file MCMCProcessor.h.
|
protected |
Vector with mean values using Highest Posterior Density.
Definition at line 527 of file MCMCProcessor.h.
|
protected |
Number of batches for Batched Mean.
Definition at line 566 of file MCMCProcessor.h.
|
protected |
Number of bins.
Definition at line 555 of file MCMCProcessor.h.
|
protected |
Number of branches in a TTree.
Definition at line 433 of file MCMCProcessor.h.
|
protected |
Number of all parameters used in the analysis.
Definition at line 443 of file MCMCProcessor.h.
|
protected |
Definition at line 503 of file MCMCProcessor.h.
|
protected |
Definition at line 504 of file MCMCProcessor.h.
|
protected |
KS: For merged chains number of entries will be different from nSteps.
Definition at line 435 of file MCMCProcessor.h.
|
protected |
Number of parameters per type.
Definition at line 463 of file MCMCProcessor.h.
|
protected |
Number of sample PDF objects.
Definition at line 439 of file MCMCProcessor.h.
|
protected |
KS: For merged chains number of entries will be different from nSteps.
Definition at line 437 of file MCMCProcessor.h.
|
protected |
Number of covariance objects.
Definition at line 441 of file MCMCProcessor.h.
|
protected |
The output file.
Definition at line 510 of file MCMCProcessor.h.
|
protected |
Name of output files.
Definition at line 478 of file MCMCProcessor.h.
|
protected |
Output file suffix useful when running over same file with different settings.
Definition at line 414 of file MCMCProcessor.h.
|
protected |
Parameters central values which we are going to analyse.
Definition at line 456 of file MCMCProcessor.h.
|
protected |
Uncertainty on a single parameter.
Definition at line 459 of file MCMCProcessor.h.
|
protected |
Definition at line 470 of file MCMCProcessor.h.
|
protected |
Whether Param has flat prior or not.
Definition at line 461 of file MCMCProcessor.h.
|
protected |
Name of parameters which we are going to analyse.
Definition at line 454 of file MCMCProcessor.h.
|
protected |
Definition at line 457 of file MCMCProcessor.h.
|
protected |
Total parameter sum for each param.
Definition at line 571 of file MCMCProcessor.h.
|
protected |
Make an enum for which class this parameter belongs to so we don't have to keep string comparing.
Definition at line 465 of file MCMCProcessor.h.
|
protected |
KS: in MCMC output there is order of parameters so for example first goes xsec then nd det etc. Idea is that this parameter will keep track of it so code is flexible
Definition at line 468 of file MCMCProcessor.h.
|
protected |
Array holding values for all parameters.
Definition at line 550 of file MCMCProcessor.h.
|
protected |
If true it will print value on each bin of covariance matrix.
Definition at line 495 of file MCMCProcessor.h.
|
protected |
Whether we plot flat prior or not, we usually provide error even for flat prior params.
Definition at line 483 of file MCMCProcessor.h.
|
protected |
Whether we plot relative to prior or nominal, in most cases is prior.
Definition at line 487 of file MCMCProcessor.h.
|
protected |
KS: Set Threshold when to plot 2D posterior as by default we get a LOT of plots.
Definition at line 499 of file MCMCProcessor.h.
|
protected |
Fancy canvas used for our beautiful plots.
Definition at line 513 of file MCMCProcessor.h.
|
protected |
Cut used when making 1D Posterior distribution.
Definition at line 427 of file MCMCProcessor.h.
|
protected |
Will plot all plot to PDF not only to root file.
Definition at line 491 of file MCMCProcessor.h.
|
protected |
Name of branch used for chain reweighting.
Definition at line 588 of file MCMCProcessor.h.
|
protected |
Whether to apply reweighting weight or not.
Definition at line 586 of file MCMCProcessor.h.
|
protected |
Vector of each systematic.
Definition at line 473 of file MCMCProcessor.h.
|
protected |
Holds the sample values.
Definition at line 576 of file MCMCProcessor.h.
|
protected |
BurnIn Cuts.
Definition at line 425 of file MCMCProcessor.h.
|
protected |
Step number for step, important if chains were merged.
Definition at line 552 of file MCMCProcessor.h.
|
protected |
Vector of each sample PDF object.
Definition at line 475 of file MCMCProcessor.h.
|
protected |
Holds the systs values.
Definition at line 578 of file MCMCProcessor.h.
|
protected |
KS: Used only for SubOptimality.
Definition at line 429 of file MCMCProcessor.h.
|
protected |
MJR: Use FFT-based autocorrelation algorithm (save time & resources)?
Definition at line 501 of file MCMCProcessor.h.
|
protected |
Stores value of weight for each step.
Definition at line 590 of file MCMCProcessor.h.