Class responsible for handling of systematic error parameters with different types defined in the config. Like spline, normalisation parameters etc.
More...
|
| ParameterHandlerGeneric (const std::vector< std::string > &FileNames, std::string name="xsec_cov", double threshold=-1, int FirstPCAdpar=-999, int LastPCAdpar=-999) |
| Constructor.
|
|
| ~ParameterHandlerGeneric () |
| Destructor.
|
|
std::vector< std::string > | GetParSampleID (const int i) const |
| ETA - just return the int of the SampleName, this can be removed to do a string comp at some point.
|
|
std::string | GetParamTypeString (const int i) const |
| ETA - just return a string of "spline", "norm" or "functional".
|
|
SystType | GetParamType (const int i) const |
| Returns enum describing our param type.
|
|
SplineInterpolation | GetParSplineInterpolation (const int i) const |
| Get interpolation type for a given parameter.
|
|
const std::vector< SplineInterpolation > | GetSplineInterpolationFromSampleName (const std::string &SampleName) |
| Get the interpolation types for splines affecting a particular SampleName.
|
|
std::string | GetParSplineName (const int i) const |
| Get the name of the spline associated with the spline at index i.
|
|
const std::vector< int > | GetGlobalSystIndexFromSampleName (const std::string &SampleName, const SystType Type) |
| DB Get spline parameters depending on given SampleName.
|
|
double | GetParSplineKnotUpperBound (const int i) const |
| EM: value at which we cap spline knot weight.
|
|
double | GetParSplineKnotLowerBound (const int i) const |
| EM: value at which we cap spline knot weight.
|
|
int | GetNumParamsFromSampleName (const std::string &SampleName, const SystType Type) |
| DB Grab the number of parameters for the relevant SampleName.
|
|
const std::vector< std::string > | GetParsNamesFromSampleName (const std::string &SampleName, const SystType Type) |
| DB Grab the parameter names for the relevant SampleName.
|
|
const std::vector< int > | GetParsIndexFromSampleName (const std::string &SampleName, const SystType Type) |
| DB Grab the parameter indices for the relevant SampleName.
|
|
const std::vector< std::string > | GetSplineParsNamesFromSampleName (const std::string &SampleName) |
| DB Get spline parameters depending on given SampleName.
|
|
const std::vector< std::string > | GetSplineFileParsNamesFromSampleName (const std::string &SampleName) |
| DB Get spline parameters depending on given SampleName.
|
|
const std::vector< std::vector< int > > | GetSplineModeVecFromSampleName (const std::string &SampleName) |
| DB Grab the Spline Modes for the relevant SampleName.
|
|
const std::vector< int > | GetSystIndexFromSampleName (const std::string &SampleName, const SystType Type) const |
| Grab the index of the syst relative to global numbering.
|
|
const std::vector< NormParameter > | GetNormParsFromSampleName (const std::string &SampleName) const |
| DB Get norm/func parameters depending on given SampleName.
|
|
const std::vector< FunctionalParameter > | GetFunctionalParametersFromSampleName (const std::string &SampleName) const |
| HH Get functional parameters for the relevant SampleName.
|
|
const std::vector< SplineParameter > | GetSplineParsFromSampleName (const std::string &SampleName) const |
| KS: Grab the Spline parameters for the relevant SampleName.
|
|
bool | IsParFromGroup (const int i, const std::string &Group) const |
| Checks if parameter belongs to a given group.
|
|
int | GetNumParFromGroup (const std::string &Group) const |
| KS: Check how many parameters are associated with given group.
|
|
void | SetGroupOnlyParameters (const std::string &Group, const std::vector< double > &Pars={}) |
| KS Function to set to prior parameters of a given group or values from vector.
|
|
void | SetGroupOnlyParameters (const std::vector< std::string > &Groups) |
| KS Function to set to prior parameters of a given groups or values from vector.
|
|
void | DumpMatrixToFile (const std::string &Name) |
| Dump Matrix to ROOT file, useful when we need to pass matrix info to another fitting group.
|
|
std::vector< const double * > | GetOscParsFromSampleName (const std::string &SampleName) |
| Get pointers to Osc params from Sample name.
|
|
Public Member Functions inherited from ParameterHandlerBase |
| ParameterHandlerBase (const std::vector< std::string > &YAMLFile, std::string name, double threshold=-1, int FirstPCAdpar=-999, int LastPCAdpar=-999) |
| ETA - constructor for a YAML file.
|
|
| ParameterHandlerBase (std::string name, std::string file, double threshold=-1, int FirstPCAdpar=-999, int LastPCAdpar=-999) |
| "Usual" constructors from root file
|
|
virtual | ~ParameterHandlerBase () |
| Destructor.
|
|
void | SetCovMatrix (TMatrixDSym *cov) |
| Set covariance matrix.
|
|
void | SetName (const std::string &name) |
| Set matrix name.
|
|
void | SetParName (const int i, const std::string &name) |
| change parameter name
|
|
void | SetSingleParameter (const int parNo, const double parVal) |
| Set value of single param to a given value.
|
|
void | SetPar (const int i, const double val) |
| Set all the covariance matrix parameters to a user-defined value.
|
|
void | SetParCurrProp (const int i, const double val) |
| Set current parameter value.
|
|
void | SetParProp (const int i, const double val) |
| Set proposed parameter value.
|
|
void | SetParameters (const std::vector< double > &pars={}) |
| Set parameter values using vector, it has to have same size as covariance class.
|
|
void | SetFlatPrior (const int i, const bool eL) |
| Set if parameter should have flat prior or not.
|
|
void | SetRandomThrow (const int i, const double rand) |
| Set random value useful for debugging/CI.
|
|
double | GetRandomThrow (const int i) const |
| Get random value useful for debugging/CI.
|
|
void | SetBranches (TTree &tree, const bool SaveProposal=false) |
| set branches for output file
|
|
void | SetStepScale (const double scale) |
| Set global step scale for covariance object.
|
|
void | SetIndivStepScale (const int ParameterIndex, const double StepScale) |
| DB Function to set fIndivStepScale from a vector (Can be used from execs and inside covariance constructors)
|
|
void | SetIndivStepScale (const std::vector< double > &stepscale) |
| DB Function to set fIndivStepScale from a vector (Can be used from execs and inside covariance constructors)
|
|
void | SetPrintLength (const unsigned int PriLen) |
| KS: In case someone really want to change this.
|
|
void | SaveUpdatedMatrixConfig () |
| KS: After step scale, prefit etc. value were modified save this modified config.
|
|
void | ThrowParProp (const double mag=1.) |
| Throw the proposed parameter by mag sigma. Should really just have the user specify this throw by having argument double.
|
|
void | ThrowParCurr (const double mag=1.) |
| Helper function to throw the current parameter by mag sigma. Can study bias in MCMC with this; put different starting parameters.
|
|
void | ThrowParameters () |
| Throw the parameters according to the covariance matrix. This shouldn't be used in MCMC code ase it can break Detailed Balance;.
|
|
void | RandomConfiguration () |
| Randomly throw the parameters in their 1 sigma range.
|
|
int | CheckBounds () const _noexcept_ |
| Check if parameters were proposed outside physical boundary.
|
|
double | CalcLikelihood () const _noexcept_ |
| Calc penalty term based on inverted covariance matrix.
|
|
virtual double | GetLikelihood () |
| Return CalcLikelihood if some params were thrown out of boundary return LARGE_LOGL
|
|
TMatrixDSym * | GetCovMatrix () const |
| Return covariance matrix.
|
|
TMatrixDSym * | GetInvCovMatrix () const |
| Return inverted covariance matrix.
|
|
double | GetInvCovMatrix (const int i, const int j) const |
| Return inverted covariance matrix.
|
|
double | GetCorrThrows (const int i) const |
| Return correlated throws.
|
|
bool | GetFlatPrior (const int i) const |
| Get if param has flat prior or not.
|
|
std::string | GetName () const |
| Get name of covariance.
|
|
std::string | GetParName (const int i) const |
| Get name of parameter.
|
|
int | GetParIndex (const std::string &name) const |
| Get index based on name.
|
|
std::string | GetParFancyName (const int i) const |
| Get fancy name of the Parameter.
|
|
std::string | GetInputFile () const |
| Get name of input file.
|
|
double | GetDiagonalError (const int i) const |
| Get diagonal error for ith parameter.
|
|
double | GetError (const int i) const |
| Get the error for the ith parameter.
|
|
void | ResetIndivStepScale () |
| Adaptive Step Tuning Stuff.
|
|
void | InitialiseAdaption (const YAML::Node &adapt_manager) |
| Initialise adaptive MCMC.
|
|
void | SaveAdaptiveToFile (const std::string &outFileName, const std::string &systematicName) |
| Save adaptive throw matrix to file.
|
|
bool | GetDoAdaption () const |
| Do we adapt or not.
|
|
void | SetThrowMatrix (TMatrixDSym *cov) |
| Use new throw matrix, used in adaptive MCMC.
|
|
void | UpdateThrowMatrix (TMatrixDSym *cov) |
|
void | SetNumberOfSteps (const int nsteps) |
| Set number of MCMC step, when running adaptive MCMC it is updated with given frequency. We need number of steps to determine frequency.
|
|
TMatrixDSym * | GetThrowMatrix () const |
| Get matrix used for step proposal.
|
|
double | GetThrowMatrix (const int i, const int j) const |
| Get matrix used for step proposal.
|
|
TMatrixD * | GetThrowMatrix_CholDecomp () const |
| Get the Cholesky decomposition of the throw matrix.
|
|
TH2D * | GetCorrelationMatrix () |
| KS: Convert covariance matrix to correlation matrix and return TH2D which can be used for fancy plotting.
|
|
const double * | RetPointer (const int iParam) |
| DB Pointer return to param position.
|
|
const std::vector< double > & | GetParPropVec () |
| Get a reference to the proposed parameter values Can be useful if you want to track these without having to copy values using getProposed()
|
|
int | GetNumParams () const |
| Get total number of parameters.
|
|
std::vector< double > | GetPreFitValues () const |
| Get the pre-fit values of the parameters.
|
|
std::vector< double > | GetProposed () const |
| Get vector of all proposed parameter values.
|
|
double | GetParProp (const int i) const |
| Get proposed parameter value.
|
|
double | GetParCurr (const int i) const |
| Get current parameter value.
|
|
double | GetParInit (const int i) const |
| Get prior parameter value.
|
|
double | GetUpperBound (const int i) const |
| Get upper parameter bound in which it is physically valid.
|
|
double | GetLowerBound (const int i) const |
| Get lower parameter bound in which it is physically valid.
|
|
double | GetIndivStepScale (const int ParameterIndex) const |
| Get individual step scale for selected parameter.
|
|
double | GetGlobalStepScale () const |
| Get global step scale for covariance object.
|
|
int | GetNParameters () const |
| Get number of params which will be different depending if using Eigen decomposition or not.
|
|
void | PrintNominal () const |
| Print prior value for every parameter.
|
|
void | PrintNominalCurrProp () const |
| Print prior, current and proposed value for each parameter.
|
|
void | PrintParameters () const |
|
void | PrintIndivStepScale () const |
| Print step scale for each parameter.
|
|
virtual void | ProposeStep () |
| Generate a new proposed state.
|
|
void | Randomize () _noexcept_ |
| "Randomize" the parameters in the covariance class for the proposed step. Used the proposal kernel and the current parameter value to set proposed step
|
|
void | CorrelateSteps () _noexcept_ |
| Use Cholesky throw matrix for better step proposal.
|
|
void | UpdateAdaptiveCovariance () |
| Method to update adaptive MCMC [12].
|
|
void | AcceptStep () _noexcept_ |
| Accepted this step.
|
|
void | ToggleFixAllParameters () |
| fix parameters at prior values
|
|
void | ToggleFixParameter (const int i) |
| fix parameter at prior values
|
|
void | ToggleFixParameter (const std::string &name) |
| Fix parameter at prior values.
|
|
bool | IsParameterFixed (const int i) const |
| Is parameter fixed or not.
|
|
bool | IsParameterFixed (const std::string &name) const |
| Is parameter fixed or not.
|
|
void | ConstructPCA (const double eigen_threshold, int FirstPCAdpar, int LastPCAdpar) |
| CW: Calculate eigen values, prepare transition matrices and remove param based on defined threshold.
|
|
bool | IsPCA () const |
| is PCA, can use to query e.g. LLH scans
|
|
YAML::Node | GetConfig () const |
| Getter to return a copy of the YAML node.
|
|
adaptive_mcmc::AdaptiveMCMCHandler * | GetAdaptiveHandler () const |
| Get pointer for AdaptiveHandler.
|
|
void | SetTune (const std::string &TuneName) |
| KS: Set proposed parameter values vector to be base on tune values, for example set proposed values to be of generated or maybe PostND.
|
|
PCAHandler * | GetPCAHandler () const |
| Get pointer for PCAHandler.
|
|
|
void | Print () |
| Print information about the whole object once it is set.
|
|
void | PrintGlobablInfo () |
| Prints general information about the ParameterHandler object.
|
|
void | PrintNormParams () |
| Prints normalization parameters.
|
|
void | PrintSplineParams () |
| Prints spline parameters.
|
|
void | PrintFunctionalParams () |
| Prints functional parameters.
|
|
void | PrintOscillationParams () |
| Prints oscillation parameters.
|
|
void | PrintParameterGroups () |
| Prints groups of parameters.
|
|
void | CheckCorrectInitialisation () |
| KS: Check if matrix is correctly initialised.
|
|
template<typename FilterFunc , typename ActionFunc > |
void | IterateOverParams (const std::string &SampleName, FilterFunc filter, ActionFunc action) |
| Iterates over parameters and applies a filter and action function.
|
|
void | InitParams () |
| Initializes the systematic parameters from the configuration file. This function loads parameters like normalizations and splines from the provided YAML file.
|
|
void | InitParametersTypeFromConfig () |
| Parses the YAML configuration to set up cross-section parameters. The YAML file defines the types of systematic errors, interpolation types, and bounds for splines.
|
|
NormParameter | GetNormParameter (const YAML::Node ¶m, const int Index) |
| Get Norm params.
|
|
OscillationParameter | GetOscillationParameters (const YAML::Node ¶m, const int Index) |
| Get Osc params.
|
|
FunctionalParameter | GetFunctionalParameters (const YAML::Node ¶m, const int Index) |
| Get Func params.
|
|
SplineParameter | GetSplineParameter (const YAML::Node ¶m, const int Index) |
| Get Spline params.
|
|
void | GetBaseParameter (const YAML::Node ¶m, const int Index, TypeParameterBase &Parameter) |
| Fill base parameters.
|
|
template<typename ParamT > |
std::vector< ParamT > | GetTypeParamsFromSampleName (const std::map< int, int > &indexMap, const std::vector< ParamT > ¶ms, const std::string &SampleName) const |
| Retrieve parameters that apply to a given sample name.
|
|
Protected Member Functions inherited from ParameterHandlerBase |
void | Init (const std::string &name, const std::string &file) |
| Initialisation of the class using matrix from root file.
|
|
void | Init (const std::vector< std::string > &YAMLFile) |
| Initialisation of the class using config.
|
|
void | ReserveMemory (const int size) |
| Initialise vectors with parameters information.
|
|
void | MakePosDef (TMatrixDSym *cov=nullptr) |
| Make matrix positive definite by adding small values to diagonal, necessary for inverting matrix.
|
|
void | MakeClosestPosDef (TMatrixDSym *cov) |
| HW: Finds closest possible positive definite matrix in Frobenius Norm ||.||_frob Where ||X||_frob=sqrt[sum_ij(x_ij^2)] (basically just turns an n,n matrix into vector in n^2 space then does Euclidean norm)
|
|
void | SetThrowMatrixFromFile (const std::string &matrix_file_name, const std::string &matrix_name, const std::string &means_name) |
| sets throw matrix from a file
|
|
bool | AppliesToSample (const int SystIndex, const std::string &SampleName) const |
| Check if parameter is affecting given sample name.
|
|
void | FlipParameterValue (const int index, const double FlipPoint) |
| KS: Flip parameter around given value, for example mass ordering around 0.
|
|
void | CircularParBounds (const int i, const double LowBound, const double UpBound) |
| HW :: This method is a tad hacky but modular arithmetic gives me a headache.
|
|
void | EnableSpecialProposal (const YAML::Node ¶m, const int Index) |
| Enable special proposal.
|
|
void | SpecialStepProposal () |
| Perform Special Step Proposal.
|
|
|
std::vector< SystType > | _fParamType |
| Type of parameter like norm, spline etc.
|
|
std::vector< std::string > | _fSplineNames |
| Name of spline in TTree (TBranch),.
|
|
std::vector< std::string > | _ParameterGroup |
| KS: Allow to group parameters for example to affect only cross-section or only flux etc.
|
|
std::vector< std::map< int, int > > | _fSystToGlobalSystIndexMap |
| Map between number of given parameter type with global parameter numbering. For example 2nd norm param may be 10-th global param.
|
|
std::vector< SplineParameter > | SplineParams |
| Vector containing info for normalisation systematics.
|
|
std::vector< NormParameter > | NormParams |
| Vector containing info for normalisation systematics.
|
|
std::vector< FunctionalParameter > | FuncParams |
| Vector containing info for functional systematics.
|
|
std::vector< OscillationParameter > | OscParams |
| Vector containing info for functional systematics.
|
|
Protected Attributes inherited from ParameterHandlerBase |
bool | doSpecialStepProposal |
| Check if any of special step proposal were enabled.
|
|
const std::string | inputFile |
| The input root file we read in.
|
|
std::string | matrixName |
| Name of cov matrix.
|
|
TMatrixDSym * | covMatrix |
| The covariance matrix.
|
|
TMatrixDSym * | invCovMatrix |
| The inverse covariance matrix.
|
|
std::vector< std::vector< double > > | InvertCovMatrix |
| KS: Same as above but much faster as TMatrixDSym cache miss.
|
|
std::vector< std::unique_ptr< TRandom3 > > | random_number |
| KS: Set Random numbers for each thread so each thread has different seed.
|
|
double * | randParams |
| Random number taken from gaussian around prior error used for corr_throw.
|
|
double * | corr_throw |
| Result of multiplication of Cholesky matrix and randParams.
|
|
double | _fGlobalStepScale |
| Global step scale applied to all params in this class.
|
|
int | PrintLength |
| KS: This is used when printing parameters, sometimes we have super long parameters name, we want to flexibly adjust couts.
|
|
std::vector< std::string > | _fNames |
| ETA _fNames is set automatically in the covariance class to be something like xsec_i, this is currently to make things compatible with the Diagnostic tools.
|
|
std::vector< std::string > | _fFancyNames |
| Fancy name for example rather than xsec_0 it is MAQE, useful for human reading.
|
|
YAML::Node | _fYAMLDoc |
| Stores config describing systematics.
|
|
int | _fNumPar |
| Number of systematic parameters.
|
|
std::vector< double > | _fPreFitValue |
| Parameter value dictated by the prior model. Based on it penalty term is calculated.
|
|
std::vector< double > | _fCurrVal |
| Current value of the parameter.
|
|
std::vector< double > | _fPropVal |
| Proposed value of the parameter.
|
|
std::vector< double > | _fError |
| Prior error on the parameter.
|
|
std::vector< double > | _fLowBound |
| Lowest physical bound, parameter will not be able to go beyond it.
|
|
std::vector< double > | _fUpBound |
| Upper physical bound, parameter will not be able to go beyond it.
|
|
std::vector< double > | _fIndivStepScale |
| Individual step scale used by MCMC algorithm.
|
|
std::vector< bool > | _fFlatPrior |
| Whether to apply flat prior or not.
|
|
std::vector< std::vector< std::string > > | _fSampleNames |
| Tells to which samples object param should be applied.
|
|
TMatrixDSym * | throwMatrix |
| Matrix which we use for step proposal before Cholesky decomposition (not actually used for step proposal)
|
|
TMatrixD * | throwMatrix_CholDecomp |
| Matrix which we use for step proposal after Cholesky decomposition.
|
|
double ** | throwMatrixCholDecomp |
| Throw matrix that is being used in the fit, much faster as TMatrixDSym cache miss.
|
|
bool | pca |
| perform PCA or not
|
|
bool | use_adaptive |
| Are we using AMCMC?
|
|
std::unique_ptr< PCAHandler > | PCAObj |
| Struct containing information about PCA.
|
|
std::unique_ptr< adaptive_mcmc::AdaptiveMCMCHandler > | AdaptiveHandler |
| Struct containing information about adaption.
|
|
std::unique_ptr< ParameterTunes > | Tunes |
| Struct containing information about adaption.
|
|
std::vector< int > | FlipParameterIndex |
| Indices of parameters with flip symmetry.
|
|
std::vector< double > | FlipParameterPoint |
| Central points around which parameters are flipped.
|
|
std::vector< int > | CircularBoundsIndex |
| Indices of parameters with circular bounds.
|
|
std::vector< std::pair< double, double > > | CircularBoundsValues |
| Circular bounds for each parameter (lower, upper)
|
|