8 double threshold,
int FirstPCA,
int LastPCA) {
10 MACH3LOG_INFO(
"Constructing instance of ParameterHandler using");
18 for(
unsigned int i = 0; i < YAMLFile.size(); i++)
24 if (threshold < 0 || threshold >= 1) {
25 MACH3LOG_INFO(
"Principal component analysis but given the threshold for the principal components to be less than 0, or greater than (or equal to) 1. This will not work");
28 MACH3LOG_INFO(
"Am instead calling the usual non-PCA constructor...");
53 std::map<std::pair<int,int>, std::unique_ptr<TMatrixDSym>>& ThrowSubMatrixOverrides) {
55 int running_num_file_pars = 0;
57 _fYAMLDoc[
"Systematics"] = YAML::Node(YAML::NodeType::Sequence);
58 for(
unsigned int i = 0; i < YAMLFile.size(); i++)
62 if (YAMLDocTemp[
"ThrowMatrixOverride"]) {
69 YAMLDocTemp[
"ThrowMatrixOverride"][
"file"].as<std::string>();
70 TFile *submatrix_file =
TFile::Open(filename.c_str());
73 YAMLDocTemp[
"ThrowMatrixOverride"][
"matrix"].as<std::string>();
74 std::unique_ptr<TMatrixDSym> submatrix{
75 submatrix_file->Get<TMatrixDSym>(matrixname.c_str())};
78 matrixname, filename);
81 auto numrows = submatrix->GetNrows();
85 ThrowSubMatrixOverrides[{running_num_file_pars,
86 running_num_file_pars + (numrows - 1)}] = std::move(submatrix);
90 if (!
bool(YAMLDocTemp[
"ThrowMatrixOverride"][
"check_names"]) ||
91 YAMLDocTemp[
"ThrowMatrixOverride"][
"check_names"].as<bool>()) {
92 auto nametree = submatrix_file->Get<TTree>(
"param_names");
95 "ThrowMatrixOverride: {{ check_names: False }} to "
96 "disable this check.",
100 std::string *param_name =
nullptr;
101 nametree->SetBranchAddress(
"name", ¶m_name);
103 if (nametree->GetEntries() !=
int(YAMLDocTemp[
"Systematics"].size())) {
105 "the corresponding yaml file only declares {} "
106 "parameters. Set ThrowMatrixOverride: {{ "
107 "check_names: False }} to disable this check.",
108 filename, nametree->GetEntries(),
109 YAMLDocTemp[
"Systematics"].size());
114 for (
const auto ¶m : YAMLDocTemp[
"Systematics"]) {
115 nametree->GetEntry(pit++);
116 auto yaml_pname = Get<std::string>(
117 param[
"Systematic"][
"Names"][
"FancyName"], __FILE__, __LINE__);
118 if ((*param_name) != yaml_pname) {
120 "TTree param_names in file: {} at entry {} has parameter {}, "
122 "the corresponding yaml parameter is named {}. Set "
123 "ThrowMatrixOverride: {{ "
124 "check_names: False }} to disable this check.",
125 filename, pit, (*param_name), yaml_pname);
130 submatrix_file->Close();
133 for (
const auto& item : YAMLDocTemp[
"Systematics"]) {
134 _fYAMLDoc[
"Systematics"].push_back(item);
135 running_num_file_pars++;
142 std::map<std::string, int>& CorrNamesMap) {
146 TMatrixDSym* _fCovMatrix =
new TMatrixDSym(
_fNumPar);
150 for (
auto const& pair : Correlations[j]) {
151 auto const& key = pair.first;
152 auto const& val = pair.second;
155 if (CorrNamesMap.find(key) != CorrNamesMap.end()) {
156 index = CorrNamesMap[key];
158 MACH3LOG_ERROR(
"Parameter {} not in list! Check your spelling?", key);
163 if(Correlations[index].find(
_fFancyNames[j]) != Correlations[index].end()) {
166 if(std::abs(Corr2 - Corr1) > FLT_EPSILON) {
175 (*_fCovMatrix)(j, index)= (*_fCovMatrix)(index, j) = Corr1*
_fError[j]*
_fError[index];
189 std::map<std::pair<int, int>, std::unique_ptr<TMatrixDSym>> ThrowSubMatrixOverrides;
196 for (
int iThread = 0; iThread < nThreads; iThread++) {
207 std::vector<std::map<std::string,double>> Correlations(
_fNumPar);
208 std::map<std::string, int> CorrNamesMap;
213 for (
auto const ¶m :
_fYAMLDoc[
"Systematics"])
215 _fFancyNames[i] = Get<std::string>(param[
"Systematic"][
"Names"][
"FancyName"], __FILE__ , __LINE__);
216 _fPreFitValue[i] = Get<double>(param[
"Systematic"][
"ParameterValues"][
"PreFitValue"], __FILE__ , __LINE__);
217 _fIndivStepScale[i] = Get<double>(param[
"Systematic"][
"StepScale"][
"MCMC"], __FILE__ , __LINE__);
218 _fError[i] = Get<double>(param[
"Systematic"][
"Error"], __FILE__ , __LINE__);
224 auto TempBoundsVec =
GetBounds(param[
"Systematic"][
"ParameterBounds"]);
229 _fFlatPrior[i] = GetFromManager<bool>(param[
"Systematic"][
"FlatPrior"],
false, __FILE__ , __LINE__);
232 if(GetFromManager<bool>(param[
"Systematic"][
"FixParam"],
false, __FILE__ , __LINE__)) {
236 if(param[
"Systematic"][
"SpecialProposal"]) {
241 CorrNamesMap[param[
"Systematic"][
"Names"][
"FancyName"].as<std::string>()]=i;
244 if(param[
"Systematic"][
"Correlations"]) {
245 for(
unsigned int Corr_i = 0; Corr_i < param[
"Systematic"][
"Correlations"].size(); ++Corr_i){
246 for (YAML::const_iterator it = param[
"Systematic"][
"Correlations"][Corr_i].begin(); it!=param[
"Systematic"][
"Correlations"][Corr_i].end();++it) {
247 Correlations[i][it->first.as<std::string>()] = it->second.as<
double>();
265 for(
auto const & matovr : ThrowSubMatrixOverrides){
269 Tunes = std::make_unique<ParameterTunes>(
_fYAMLDoc[
"Systematics"]);
272 for(
const auto &file : YAMLFile){
300 for (
auto const ¶m :
_fYAMLDoc[
"Systematics"])
302 _ParameterGroup[i] = Get<std::string>(param[
"Systematic"][
"ParameterGroup"], __FILE__ , __LINE__);
303 _fSampleNames[i] = GetFromManager<std::vector<std::string>>(param[
"Systematic"][
"SampleNames"], {}, __FILE__, __LINE__);
306 auto ParamType = Get<std::string>(param[
"Systematic"][
"Type"], __FILE__ , __LINE__);
335 MACH3LOG_ERROR(
"Given unrecognised systematic type: {}", ParamType);
336 std::string expectedTypes =
"Expecting ";
338 if (s > 0) expectedTypes +=
", ";
341 expectedTypes +=
".";
365 std::vector<std::string> returnVec;
368 auto &SystIndex = pair.second;
379 std::vector<SplineInterpolation> returnVec;
382 auto &SystIndex = pair.second;
395 std::vector< std::vector<int> > returnVec;
400 auto &SystIndex = pair.second;
418 norm.
modes = GetFromManager<std::vector<int>>(param[
"Mode"], {}, __FILE__ , __LINE__);
419 norm.
pdgs = GetFromManager<std::vector<int>>(param[
"NeutrinoFlavour"], {}, __FILE__ , __LINE__);
420 norm.
preoscpdgs = GetFromManager<std::vector<int>>(param[
"NeutrinoFlavourUnosc"], {}, __FILE__ , __LINE__);
421 norm.
targets = GetFromManager<std::vector<int>>(param[
"TargetNuclei"], {}, __FILE__ , __LINE__);
424 MACH3LOG_ERROR(
"Normalisation Parameter {} ({}), has lower parameters bound which can go below 0 and is equal {}",
426 MACH3LOG_ERROR(
"Normalisation parameters can't go bellow 0 as this is unphysical");
440 Parameter.
index = Index;
442 int NumKinematicCuts = 0;
443 if(param[
"KinematicCuts"]) {
444 NumKinematicCuts = int(param[
"KinematicCuts"].size());
446 std::vector<std::string> TempKinematicStrings;
447 std::vector<std::vector<std::vector<double>>> TempKinematicBounds;
449 for(
int KinVar_i = 0 ; KinVar_i < NumKinematicCuts ; ++KinVar_i) {
451 for (YAML::const_iterator it = param[
"KinematicCuts"][KinVar_i].begin();it!=param[
"KinematicCuts"][KinVar_i].end();++it) {
452 TempKinematicStrings.push_back(it->first.as<std::string>());
453 TempKinematicBounds.push_back(
Get2DBounds(it->second));
455 if(TempKinematicStrings.size() == 0) {
456 MACH3LOG_ERROR(
"Received a KinematicCuts node but couldn't read the contents (it's a list of single-element dictionaries (python) = map of pairs (C++))");
462 Parameter.
Selection = TempKinematicBounds;
467 bool HasKinBounds =
false;
480 std::vector<int> returnVec;
482 auto &SystIndex = pair.second;
484 returnVec.push_back(SystIndex);
495 std::vector<int> returnVec;
498 auto &systIndex = pair.second;
513 auto& SplinePar = param[
"SplineInformation"];
515 if (SplinePar[
"InterpolationType"]) {
524 Spline.
_fSplineNames = Get<std::string>(SplinePar[
"SplineName"], __FILE__ , __LINE__);
529 MACH3LOG_WARN(
"Spline knot capping enabled with bounds [{}, {}]. For reliable fits, consider modifying the input generation instead.",
545 std::string SampleNameCopy = SampleName;
546 std::transform(SampleNameCopy.begin(), SampleNameCopy.end(), SampleNameCopy.begin(), ::tolower);
549 if (SampleNameCopy.find(
'*') != std::string::npos) {
550 MACH3LOG_ERROR(
"Wildcards ('*') are not supported in sample name: '{}'", SampleName);
554 bool Applies =
false;
556 for (
size_t i = 0; i <
_fSampleNames[SystIndex].size(); i++) {
559 std::transform(pattern.begin(), pattern.end(), pattern.begin(), ::tolower);
562 std::string regexPattern =
"^" + std::regex_replace(pattern, std::regex(
"\\*"),
".*") +
"$";
564 std::regex regex(regexPattern);
565 if (std::regex_match(SampleNameCopy, regex)) {
569 }
catch (
const std::regex_error& e) {
584 func.
modes = GetFromManager<std::vector<int>>(param[
"Mode"], std::vector<int>(), __FILE__ , __LINE__);
622 template<
typename ParamT>
624 const std::vector<ParamT>& params,
const std::string& SampleName)
const {
626 std::vector<ParamT> returnVec;
627 for (
const auto& pair : indexMap) {
628 const auto& localIndex = pair.first;
629 const auto& globalIndex = pair.second;
631 returnVec.push_back(params[localIndex]);
644 [&](int) { returnVal += 1; }
653 std::vector<std::string> returnVec;
665 std::vector<int> returnVec;
668 [&](
int i) { returnVec.push_back(i); }
674 template <
typename FilterFunc,
typename ActionFunc>
677 for (
int i = 0; i <
_fNumPar; ++i) {
687 for (
int i = 0; i <
_fNumPar; ++i) {
689 _fNames[i] =
"param_"+std::to_string(i);
701 #pragma GCC diagnostic push
702 #pragma GCC diagnostic ignored "-Wuseless-cast"
706 #pragma GCC diagnostic pop
711 PCAObj->SetInitialParameters();
719 MACH3LOG_INFO(
"#################################################");
735 MACH3LOG_INFO(
"#################################################");
743 MACH3LOG_INFO(
"============================================================================================================================================================");
744 MACH3LOG_INFO(
"{:<5} {:2} {:<40} {:2} {:<10} {:2} {:<10} {:2} {:<10} {:2} {:<10} {:2} {:<10} {:2} {:<20} {:2} {:<10}",
"#",
"|",
"Name",
"|",
"Prior",
"|",
"Error",
"|",
"Lower",
"|",
"Upper",
"|",
"StepScale",
"|",
"SampleNames",
"|",
"Type");
745 MACH3LOG_INFO(
"------------------------------------------------------------------------------------------------------------------------------------------------------------");
747 std::string ErrString = fmt::format(
"{:.2f}",
_fError[i]);
748 std::string SampleNameString =
"";
750 if (!SampleNameString.empty()) {
751 SampleNameString +=
", ";
753 SampleNameString += SampleName;
755 MACH3LOG_INFO(
"{:<5} {:2} {:<40} {:2} {:<10} {:2} {:<10} {:2} {:<10} {:2} {:<10} {:2} {:<10} {:2} {:<20} {:2} {:<10}", i,
"|",
GetParFancyName(i),
"|",
_fPreFitValue[i],
"|",
"+/- " + ErrString,
"|",
_fLowBound[i],
"|",
_fUpBound[i],
"|",
_fIndivStepScale[i],
"|", SampleNameString,
"|",
SystType_ToString(
_fParamType[i]));
757 MACH3LOG_INFO(
"============================================================================================================================================================");
767 bool have_parameter_with_kin_bounds =
false;
770 MACH3LOG_INFO(
"┌────┬──────────┬────────────────────────────────────────┬────────────────────┬────────────────────┬────────────────────┐");
771 MACH3LOG_INFO(
"│{0:4}│{1:10}│{2:40}│{3:20}│{4:20}│{5:20}│",
"#",
"Global #",
"Name",
"Int. mode",
"Target",
"pdg");
772 MACH3LOG_INFO(
"├────┼──────────┼────────────────────────────────────────┼────────────────────┼────────────────────┼────────────────────┤");
774 for (
unsigned int i = 0; i <
NormParams.size(); ++i)
776 std::string intModeString;
777 for (
unsigned int j = 0; j <
NormParams[i].modes.size(); j++) {
778 intModeString += std::to_string(
NormParams[i].modes[j]);
779 intModeString +=
" ";
781 if (
NormParams[i].modes.empty()) intModeString +=
"all";
783 std::string targetString;
784 for (
unsigned int j = 0; j <
NormParams[i].targets.size(); j++) {
785 targetString += std::to_string(
NormParams[i].targets[j]);
788 if (
NormParams[i].targets.empty()) targetString +=
"all";
790 std::string pdgString;
791 for (
unsigned int j = 0; j <
NormParams[i].pdgs.size(); j++) {
792 pdgString += std::to_string(
NormParams[i].pdgs[j]);
795 if (
NormParams[i].pdgs.empty()) pdgString +=
"all";
799 if(
NormParams[i].hasKinBounds) have_parameter_with_kin_bounds =
true;
801 MACH3LOG_INFO(
"└────┴──────────┴────────────────────────────────────────┴────────────────────┴────────────────────┴────────────────────┘");
803 if(have_parameter_with_kin_bounds) {
804 MACH3LOG_INFO(
"Normalisation parameters KinematicCuts information");
805 MACH3LOG_INFO(
"┌────┬──────────┬────────────────────────────────────────┬────────────────────┬────────────────────────────────────────┐");
806 MACH3LOG_INFO(
"│{0:4}│{1:10}│{2:40}│{3:20}│{4:40}│",
"#",
"Global #",
"Name",
"KinematicCut",
"Value");
807 MACH3LOG_INFO(
"├────┼──────────┼────────────────────────────────────────┼────────────────────┼────────────────────────────────────────┤");
808 for (
unsigned int i = 0; i <
NormParams.size(); ++i)
813 const long unsigned int ncuts =
NormParams[i].KinematicVarStr.size();
814 for(
long unsigned int icut = 0; icut < ncuts; icut++) {
815 std::string kinematicCutValueString;
816 for(
const auto & value :
NormParams[i].Selection[icut]) {
817 for (
const auto& v : value) {
818 kinematicCutValueString += fmt::format(
"{:.2f} ", v);
824 MACH3LOG_INFO(
"│{: <4}│{: <10}│{: <40}│{: <20}│{: <40}│",
"",
"",
"",
NormParams[i].KinematicVarStr[icut], kinematicCutValueString);
827 MACH3LOG_INFO(
"└────┴──────────┴────────────────────────────────────────┴────────────────────┴────────────────────────────────────────┘");
830 MACH3LOG_INFO(
"No normalisation parameters have KinematicCuts defined");
838 MACH3LOG_INFO(
"=====================================================================================================================================================================");
839 MACH3LOG_INFO(
"{:<4} {:<2} {:<40} {:<2} {:<40} {:<2} {:<20} {:<2} {:<20} {:<2} {:<20} {:<2}",
"#",
"|",
"Name",
"|",
"Spline Name",
"|",
"Spline Interpolation",
"|",
"Low Knot Bound",
"|",
"Up Knot Bound",
"|");
840 MACH3LOG_INFO(
"---------------------------------------------------------------------------------------------------------------------------------------------------------------------");
843 auto &GlobalIndex = pair.second;
845 MACH3LOG_INFO(
"{:<4} {:<2} {:<40} {:<2} {:<40} {:<2} {:<20} {:<2} {:<20} {:<2} {:<20} {:<2}",
852 MACH3LOG_INFO(
"=====================================================================================================================================================================");
860 MACH3LOG_INFO(
"┌────┬──────────┬────────────────────────────────────────┐");
861 MACH3LOG_INFO(
"│{0:4}│{1:10}│{2:40}│",
"#",
"Global #",
"Name");
862 MACH3LOG_INFO(
"├────┼──────────┼────────────────────────────────────────┤");
864 auto &FuncIndex = pair.first;
865 auto &GlobalIndex = pair.second;
868 MACH3LOG_INFO(
"└────┴──────────┴────────────────────────────────────────┘");
876 MACH3LOG_INFO(
"┌────┬──────────┬────────────────────────────────────────┐");
877 MACH3LOG_INFO(
"│{0:4}│{1:10}│{2:40}│",
"#",
"Global #",
"Name");
878 MACH3LOG_INFO(
"├────┼──────────┼────────────────────────────────────────┤");
880 auto &OscIndex = pair.first;
881 auto &GlobalIndex = pair.second;
884 MACH3LOG_INFO(
"└────┴──────────┴────────────────────────────────────────┘");
891 std::unordered_map<std::string, int> paramCounts;
894 [¶mCounts](
const std::string& param) {
895 paramCounts[param]++;
900 for (
const auto& pair : paramCounts) {
901 MACH3LOG_INFO(
"Found {}: {} params", pair.second, pair.first);
908 std::unordered_set<std::string> uniqueGroups;
912 uniqueGroups.insert(param);
916 std::vector<std::string> result(uniqueGroups.begin(), uniqueGroups.end());
925 auto CheckForDuplicates = [](
const std::vector<std::string>& names,
const std::string& nameType,
bool Warning) {
926 std::unordered_map<std::string, size_t> seenStrings;
927 for (
size_t i = 0; i < names.size(); ++i) {
928 const auto& name = names[i];
929 if (seenStrings.find(name) != seenStrings.end()) {
930 size_t firstIndex = seenStrings[name];
932 MACH3LOG_WARN(
"There are two systematics with the same {} '{}', first at index {}, and again at index {}", nameType, name, firstIndex, i);
936 MACH3LOG_CRITICAL(
"There are two systematics with the same {} '{}', first at index {}, and again at index {}", nameType, name, firstIndex, i);
940 seenStrings[name] = i;
943 std::vector<std::string> SplineNameTemp(
SplineParams.size());
948 CheckForDuplicates(
_fFancyNames,
"_fFancyNames",
false);
949 CheckForDuplicates(SplineNameTemp,
"_fSplineNames",
true);
956 for(
size_t i = 0; i < Groups.size(); i++){
965 #pragma GCC diagnostic push
966 #pragma GCC diagnostic ignored "-Wuseless-cast"
969 for (
int i = 0; i <
_fNumPar; i++) {
974 if (Pars.size() != ExpectedSize) {
975 MACH3LOG_ERROR(
"Number of param in group {} is {}, while you passed {}", Group, ExpectedSize, Pars.size());
979 for (
int i = 0; i <
_fNumPar; i++) {
990 PCAObj->TransferToParam();
992 #pragma GCC diagnostic pop
1007 for(
size_t i = 0; i < Groups.size(); i++)
1023 for(
size_t i = 0; i < Groups.size(); i++)
1031 std::string groupLower = Group;
1035 std::transform(groupLower.begin(), groupLower.end(), groupLower.begin(), ::tolower);
1036 std::transform(paramGroupLower.begin(), paramGroupLower.end(), paramGroupLower.begin(), ::tolower);
1038 return groupLower == paramGroupLower;
1045 for (
int i = 0; i <
_fNumPar; i++) {
1055 std::vector<const M3::float_t*> returnVec;
1057 const auto& globalIndex = pair.second;
1059 returnVec.push_back(
RetPointer(globalIndex));
#define MACH3LOG_CRITICAL
std::string SplineInterpolation_ToString(const SplineInterpolation i)
Convert a LLH type to a string.
SplineInterpolation
Make an enum of the spline interpolation type.
@ kTSpline3
Default TSpline3 interpolation.
@ kSplineInterpolations
This only enumerates.
std::string SystType_ToString(const SystType i)
Convert a Syst type type to a string.
@ kNorm
For normalisation parameters.
@ kSpline
For splined parameters (1D)
@ kSystTypes
This only enumerates.
@ kOsc
For oscillation parameters.
@ kFunc
For functional parameters.
#define Get2DBounds(filename)
Type GetFromManager(const YAML::Node &node, const Type defval, const std::string File="", const int Line=1)
Get content of config file if node is not found take default value specified.
#define M3OpenConfig(filename)
Macro to simplify calling LoadYaml with file and line info.
#define GetBounds(filename)
Custom exception class used throughout MaCh3.
int GetNumParams() const
Get total number of parameters.
bool use_adaptive
Are we using AMCMC?
std::string inputFile
The input root file we read in.
TH2D * GetCorrelationMatrix() const
KS: Convert covariance matrix to correlation matrix and return TH2D which can be used for fancy plott...
void SetCovMatrix(TMatrixDSym *cov)
Set covariance matrix.
std::vector< M3::float_t > _fPropVal
Proposed value of the parameter.
std::unique_ptr< ParameterTunes > Tunes
Struct containing information about adaption.
void ReserveMemory(const int size)
Initialise vectors with parameters information.
std::vector< std::string > _fFancyNames
Fancy name for example rather than param_0 it is MAQE, useful for human reading.
bool doSpecialStepProposal
Check if any of special step proposal were enabled.
std::vector< bool > _fFlatPrior
Whether to apply flat prior or not.
std::string matrixName
Name of cov matrix.
std::string GetParFancyName(const int i) const
Get fancy name of the Parameter.
std::vector< double > _fError
Prior error on the parameter.
void SetFixParameter(const int i)
Set parameter to be fixed at prior value.
YAML::Node _fYAMLDoc
Stores config describing systematics.
std::unique_ptr< PCAHandler > PCAObj
Struct containing information about PCA.
int _fNumPar
Number of systematic parameters.
void ConstructPCA(const double eigen_threshold, int FirstPCAdpar, int LastPCAdpar)
CW: Calculate eigen values, prepare transition matrices and remove param based on defined threshold.
std::vector< double > _fLowBound
Lowest physical bound, parameter will not be able to go beyond it.
std::vector< double > _fCurrVal
Current value of the parameter.
const M3::float_t * RetPointer(const int iParam) const
DB Pointer return to param position.
TMatrixDSym * covMatrix
The covariance matrix.
std::vector< double > _fPreFitValue
Parameter value dictated by the prior model. Based on it penalty term is calculated.
void Randomize() _noexcept_
"Randomize" the parameters in the covariance class for the proposed step. Used the proposal kernel an...
std::vector< std::string > _fNames
ETA _fNames is set automatically in the covariance class to be something like param_i,...
void EnableSpecialProposal(const YAML::Node ¶m, const int Index)
Enable special proposal.
void SetFreeParameter(const int i)
Set parameter to be treated as free.
std::vector< double > _fUpBound
Upper physical bound, parameter will not be able to go beyond it.
void SetSubThrowMatrix(int first_index, int last_index, TMatrixDSym const &subcov)
bool pca
perform PCA or not
std::vector< double > _fIndivStepScale
Individual step scale used by MCMC algorithm.
std::vector< std::unique_ptr< TRandom3 > > random_number
KS: Set Random numbers for each thread so each thread has different seed.
void MakePosDef(TMatrixDSym *cov=nullptr)
Make matrix positive definite by adding small values to diagonal, necessary for inverting matrix.
int PrintLength
KS: This is used when printing parameters, sometimes we have super long parameters name,...
void PrintGlobablInfo() const
Prints general information about the ParameterHandler object.
void Print() const
Print information about the whole object once it is set.
std::vector< SplineParameter > SplineParams
Vector containing info for normalisation systematics.
FunctionalParameter GetFunctionalParameters(const YAML::Node ¶m, const int Index) const
Get Func params.
const std::vector< NormParameter > GetNormParsFromSampleName(const std::string &SampleName) const
DB Get norm/func parameters depending on given SampleName.
std::vector< std::string > GetUniqueParameterGroups() const
KS: Get names of all unique parameter groups.
ParameterHandlerGeneric(const std::vector< std::string > &FileNames, std::string name="xsec_cov", double threshold=-1, int FirstPCAdpar=-999, int LastPCAdpar=-999)
Constructor.
void PrintSplineParams() const
Prints spline parameters.
std::vector< const M3::float_t * > GetOscParsFromSampleName(const std::string &SampleName) const
Get pointers to Osc params from Sample name.
void IterateOverParams(const std::string &SampleName, FilterFunc filter, ActionFunc action) const
Iterates over parameters and applies a filter and action function.
const std::vector< int > GetParsIndexFromSampleName(const std::string &SampleName, const SystType Type) const
DB Grab the parameter indices for the relevant SampleName.
SplineParameter GetSplineParameter(const YAML::Node ¶m, const int Index) const
Get Spline params.
SystType GetParamType(const int i) const
Returns enum describing our param type.
const std::vector< int > GetSystIndexFromSampleName(const std::string &SampleName, const SystType Type) const
Grab the index of the syst relative to global numbering.
void GetBaseParameter(const YAML::Node ¶m, const int Index, TypeParameterBase &Parameter) const
Fill base parameters.
std::vector< NormParameter > NormParams
Vector containing info for normalisation systematics.
double GetParSplineKnotUpperBound(const int i) const
EM: value at which we cap spline knot weight.
std::vector< std::map< int, int > > _fSystToGlobalSystIndexMap
Map between number of given parameter type with global parameter numbering. For example 2nd norm para...
void LoadCorrelationFromConfig(std::vector< std::map< std::string, double >> &Correlations, std::map< std::string, int > &CorrNamesMap)
Load correlation from yaml config.
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.
std::vector< SystType > _fParamType
Type of parameter like norm, spline etc.
const std::vector< SplineParameter > GetSplineParsFromSampleName(const std::string &SampleName) const
KS: Grab the Spline parameters for the relevant SampleName.
void PrintOscillationParams() const
Prints oscillation parameters.
const std::vector< FunctionalParameter > GetFunctionalParametersFromSampleName(const std::string &SampleName) const
HH Get functional parameters for the relevant SampleName.
void SetFreeGroupOnlyParameters(const std::string &Group)
TN Method to set parameters within a group to be treated as free.
void InitParametersTypeFromConfig()
Parses the YAML configuration to set up cross-section parameters. The YAML file defines the types of ...
std::vector< std::vector< std::string > > _fSampleNames
Tells to which samples object param should be applied.
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.
std::vector< FunctionalParameter > FuncParams
Vector containing info for functional systematics.
int GetNumParamsFromSampleName(const std::string &SampleName, const SystType Type) const
DB Grab the number of parameters for the relevant SampleName.
void PrintFunctionalParams() const
Prints functional parameters.
const std::vector< std::string > GetParsNamesFromSampleName(const std::string &SampleName, const SystType Type) const
DB Grab the parameter names for the relevant SampleName.
std::vector< OscillationParameter > OscParams
Vector containing info for functional systematics.
void DumpMatrixToFile(const std::string &Name)
Dump Matrix to ROOT file, useful when we need to pass matrix info to another fitting group.
const std::vector< std::string > GetSplineParsNamesFromSampleName(const std::string &SampleName) const
DB Get spline parameters depending on given SampleName.
SplineInterpolation GetParSplineInterpolation(const int i) const
Get interpolation type for a given parameter.
void InitParameters()
Initializes the systematic parameters from the configuration file. This function loads parameters lik...
const std::vector< int > GetGlobalSystIndexFromSampleName(const std::string &SampleName, const SystType Type) const
DB Get spline parameters depending on given SampleName.
OscillationParameter GetOscillationParameters(const YAML::Node ¶m, const int Index) const
Get Osc params.
NormParameter GetNormParameter(const YAML::Node ¶m, const int Index) const
Get Norm params.
bool AppliesToSample(const int SystIndex, const std::string &SampleName) const
Check if parameter is affecting given sample name.
const std::vector< SplineInterpolation > GetSplineInterpolationFromSampleName(const std::string &SampleName) const
Get the interpolation types for splines affecting a particular SampleName.
bool IsParFromGroup(const int i, const std::string &Group) const
Checks if parameter belongs to a given group.
void CheckCorrectInitialisation() const
KS: Check if matrix is correctly initialised.
void InitialiseFromConfig(const std::vector< std::string > &YAMLFile)
Initialisation of the class using config.
void SetFixGroupOnlyParameters(const std::string &Group)
TN Method to set parameters within a group to be fixed to their prior values.
std::vector< std::string > _ParameterGroup
KS: Allow to group parameters for example to affect only cross-section or only flux etc.
void LoadAndMergeYAML(const std::vector< std::string > &YAMLFile, std::map< std::pair< int, int >, std::unique_ptr< TMatrixDSym >> &overrides)
Initialise single yaml based on several yaml files.
double GetParSplineKnotLowerBound(const int i) const
EM: value at which we cap spline knot weight.
void PrintNormParams() const
Prints normalization parameters.
int GetNumParFromGroup(const std::string &Group) const
KS: Check how many parameters are associated with given group.
const std::vector< std::vector< int > > GetSplineModeVecFromSampleName(const std::string &SampleName) const
DB Grab the Spline Modes for the relevant SampleName.
void PrintParameterGroups() const
Prints groups of parameters.
~ParameterHandlerGeneric()
Destructor.
constexpr static const double DefSplineKnotUpBound
Default value for spline knot capping, default mean not capping is being applied.
constexpr static const double DefSplineKnotLowBound
Default value for spline knot capping, default mean not capping is being applied.
void DumpParamHandlerToFile(const int _fNumPar, const std::vector< double > &_fPreFitValue, const std::vector< double > &_fError, const std::vector< double > &_fLowBound, const std::vector< double > &_fUpBound, const std::vector< double > &_fIndivStepScale, const std::vector< std::string > &_fFancyNames, const std::vector< bool > &_fFlatPrior, const std::vector< SplineParameter > &SplineParams, TMatrixDSym *covMatrix, TH2D *CorrMatrix, const std::string &Name)
Dump Matrix to ROOT file, useful when we need to pass matrix info to another fitting group.
TFile * Open(const std::string &Name, const std::string &Type, const std::string &File, const int Line)
Opens a ROOT file with the given name and mode.
int GetNThreads()
number of threads which we need for example for TRandom3
HH - Functional parameters Carrier for whether you want to apply a systematic to an event or not.
std::vector< int > modes
Mode which parameter applies to.
const M3::float_t * valuePtr
Parameter value pointer.
ETA - Normalisations for cross-section parameters Carrier for whether you want to apply a systematic ...
std::vector< int > preoscpdgs
Preosc PDG which parameter applies to.
std::vector< int > modes
Mode which parameter applies to.
std::vector< int > pdgs
PDG which parameter applies to.
std::vector< int > targets
Targets which parameter applies to.
KS: Struct holding info about oscillation Systematics.
Flat representation of a spline index entry.
KS: Struct holding info about Spline Systematics.
SplineInterpolation _SplineInterpolationType
Spline interpolation vector.
double _SplineKnotUpBound
EM: Cap spline knot higher value.
double _SplineKnotLowBound
EM: Cap spline knot lower value.
std::vector< int > _fSplineModes
Modes to which spline applies (valid only for binned splines)
std::string _fSplineNames
Name of spline in TTree (TBranch),.
Base class storing info for parameters types, helping unify codebase.
int index
Parameter number of this normalisation in current systematic model.
bool hasKinBounds
Does this parameter have kinematic bounds.
std::string name
Name of parameters.
std::vector< std::string > KinematicVarStr
std::vector< std::vector< std::vector< double > > > Selection