MaCh3  2.4.2
Reference Guide
ParameterHandlerGeneric.cpp
Go to the documentation of this file.
2 
3 // ********************************************
4 // ETA - YAML constructor
5 // this will replace the root file constructor but let's keep it in
6 // to do some validations
7 ParameterHandlerGeneric::ParameterHandlerGeneric(const std::vector<std::string>& YAMLFile, std::string name, double threshold, int FirstPCA, int LastPCA)
8  : ParameterHandlerBase(YAMLFile, name, threshold, FirstPCA, LastPCA){
9 // ********************************************
11 
12  //ETA - again this really doesn't need to be hear...
13  for (int i = 0; i < _fNumPar; i++)
14  {
15  // Sort out the print length
16  if(int(_fNames[i].length()) > PrintLength) PrintLength = int(_fNames[i].length());
17  } // end the for loop
18 
19  MACH3LOG_DEBUG("Constructing instance of ParameterHandler");
20  InitParams();
21  // Print
22  Print();
23 }
24 
25 // ********************************************
27 // ********************************************
29 
30  _fParamType = std::vector<SystType>(_fNumPar);
31  _ParameterGroup = std::vector<std::string>(_fNumPar);
32 
33  //KS: We know at most how params we expect so reserve memory for max possible params. Later we will shrink to size to not waste memory. Reserving means slightly faster loading and possible less memory fragmentation.
34  NormParams.reserve(_fNumPar);
35  SplineParams.reserve(_fNumPar);
36  FuncParams.reserve(_fNumPar);
37  OscParams.reserve(_fNumPar);
38 
39  int i = 0;
40  unsigned int ParamCounter[SystType::kSystTypes] = {0};
41  //ETA - read in the systematics. Would be good to add in some checks to make sure
42  //that there are the correct number of entries i.e. are the _fNumPars for Names,
43  //PreFitValues etc etc.
44  for (auto const &param : _fYAMLDoc["Systematics"])
45  {
46  _ParameterGroup[i] = Get<std::string>(param["Systematic"]["ParameterGroup"], __FILE__ , __LINE__);
47 
48  //Fill the map to get the correlations later as well
49  auto ParamType = Get<std::string>(param["Systematic"]["Type"], __FILE__ , __LINE__);
50  //Now load in variables for spline systematics only
51  if (ParamType.find(SystType_ToString(SystType::kSpline)) != std::string::npos)
52  {
53  //Set param type
55  // Fill Spline info
56  SplineParams.push_back(GetSplineParameter(param["Systematic"], i));
57 
58  if (param["Systematic"]["SplineInformation"]["SplineName"]) {
59  _fSplineNames.push_back(param["Systematic"]["SplineInformation"]["SplineName"].as<std::string>());
60  }
61 
62  //Insert the mapping from the spline index i.e. the length of _fSplineNames etc
63  //to the Systematic index i.e. the counter for things like _fSampleID
64  _fSystToGlobalSystIndexMap[SystType::kSpline].insert(std::make_pair(ParamCounter[SystType::kSpline], i));
65  ParamCounter[SystType::kSpline]++;
66  } else if(param["Systematic"]["Type"].as<std::string>() == SystType_ToString(SystType::kNorm)) {
68  NormParams.push_back(GetNormParameter(param["Systematic"], i));
69  _fSystToGlobalSystIndexMap[SystType::kNorm].insert(std::make_pair(ParamCounter[SystType::kNorm], i));
70  ParamCounter[SystType::kNorm]++;
71  } else if(param["Systematic"]["Type"].as<std::string>() == SystType_ToString(SystType::kFunc)){
73  FuncParams.push_back(GetFunctionalParameters(param["Systematic"], i));
74  _fSystToGlobalSystIndexMap[SystType::kFunc].insert(std::make_pair(ParamCounter[SystType::kFunc], i));
75  ParamCounter[SystType::kFunc]++;
76  } else if(param["Systematic"]["Type"].as<std::string>() == SystType_ToString(SystType::kOsc)){
78  OscParams.push_back(GetOscillationParameters(param["Systematic"], i));
79  _fSystToGlobalSystIndexMap[SystType::kOsc].insert(std::make_pair(ParamCounter[SystType::kOsc], i));
80  ParamCounter[SystType::kOsc]++;
81  } else{
82  MACH3LOG_ERROR("Given unrecognised systematic type: {}", param["Systematic"]["Type"].as<std::string>());
83  std::string expectedTypes = "Expecting ";
84  for (int s = 0; s < SystType::kSystTypes; ++s) {
85  if (s > 0) expectedTypes += ", ";
86  expectedTypes += SystType_ToString(static_cast<SystType>(s)) + "\"";
87  }
88  expectedTypes += ".";
89  MACH3LOG_ERROR(expectedTypes);
90  throw MaCh3Exception(__FILE__, __LINE__);
91  }
92  i++;
93  } //end loop over params
94 
95  //Add a sanity check,
96  if(_fSplineNames.size() != ParamCounter[SystType::kSpline]){
97  MACH3LOG_ERROR("_fSplineNames is of size {} but found {} spline parameters", _fSplineNames.size(), ParamCounter[SystType::kSpline]);
98  throw MaCh3Exception(__FILE__, __LINE__);
99  }
100  //KS We resized them above to all params to fight memory fragmentation, now let's resize to fit only allocated memory to save RAM
101  NormParams.shrink_to_fit();
102  SplineParams.shrink_to_fit();
103  FuncParams.shrink_to_fit();
104  OscParams.shrink_to_fit();
105 }
106 
107 // ********************************************
109 // ********************************************
110  MACH3LOG_DEBUG("Deleting ParameterHandler");
111 }
112 
113 // ********************************************
114 // DB Grab the Spline Names for the relevant SampleName
115 const std::vector<std::string> ParameterHandlerGeneric::GetSplineParsNamesFromSampleName(const std::string& SampleName) {
116 // ********************************************
117  std::vector<std::string> returnVec;
118  for (auto &pair : _fSystToGlobalSystIndexMap[SystType::kSpline]) {
119  auto &SplineIndex = pair.first;
120  auto &SystIndex = pair.second;
121  if (AppliesToSample(SystIndex, SampleName)) { //If parameter applies to required Sample
122  returnVec.push_back(_fSplineNames.at(SplineIndex));
123  }
124  }
125  return returnVec;
126 }
127 
128 // ********************************************
129 const std::vector<SplineInterpolation> ParameterHandlerGeneric::GetSplineInterpolationFromSampleName(const std::string& SampleName) {
130 // ********************************************
131  std::vector<SplineInterpolation> returnVec;
132  for (auto &pair : _fSystToGlobalSystIndexMap[SystType::kSpline]) {
133  auto &SplineIndex = pair.first;
134  auto &SystIndex = pair.second;
135 
136  if (AppliesToSample(SystIndex, SampleName)) { //If parameter applies to required SampleID
137  returnVec.push_back(SplineParams.at(SplineIndex)._SplineInterpolationType);
138  }
139  }
140  return returnVec;
141 }
142 
143 // ********************************************
144 // DB Grab the Spline Modes for the relevant SampleName
145 const std::vector< std::vector<int> > ParameterHandlerGeneric::GetSplineModeVecFromSampleName(const std::string& SampleName) {
146 // ********************************************
147  std::vector< std::vector<int> > returnVec;
148  //Need a counter or something to correctly get the index in _fSplineModes since it's not of length nPars
149  //Should probably just make a std::map<std::string, int> for param name to FD spline index
150  for (auto &pair : _fSystToGlobalSystIndexMap[SystType::kSpline]) {
151  auto &SplineIndex = pair.first;
152  auto &SystIndex = pair.second;
153  if (AppliesToSample(SystIndex, SampleName)) { //If parameter applies to required SampleID
154  returnVec.push_back(SplineParams.at(SplineIndex)._fSplineModes);
155  }
156  }
157  return returnVec;
158 }
159 
160 // ********************************************
161 // Get Norm params
162 NormParameter ParameterHandlerGeneric::GetNormParameter(const YAML::Node& param, const int Index) {
163 // ********************************************
164  NormParameter norm;
165 
166  GetBaseParameter(param, Index, norm);
167 
168  // ETA size 0 to mean apply to all
169  // Ultimately all this information ends up in the NormParams vector
170  norm.modes = GetFromManager<std::vector<int>>(param["Mode"], {}, __FILE__ , __LINE__);
171  norm.pdgs = GetFromManager<std::vector<int>>(param["NeutrinoFlavour"], {}, __FILE__ , __LINE__);
172  norm.preoscpdgs = GetFromManager<std::vector<int>>(param["NeutrinoFlavourUnosc"], {}, __FILE__ , __LINE__);
173  norm.targets = GetFromManager<std::vector<int>>(param["TargetNuclei"], {}, __FILE__ , __LINE__);
174 
175  if(_fLowBound[Index] < 0.) {
176  MACH3LOG_ERROR("Normalisation Parameter {} ({}), has lower parameters bound which can go below 0 and is equal {}",
177  GetParFancyName(Index), Index, _fLowBound[Index]);
178  MACH3LOG_ERROR("Normalisation parameters can't go bellow 0 as this is unphysical");
179  throw MaCh3Exception(__FILE__, __LINE__);
180  }
181  int NumKinematicCuts = 0;
182  if(param["KinematicCuts"]) {
183  NumKinematicCuts = int(param["KinematicCuts"].size());
184 
185  std::vector<std::string> TempKinematicStrings;
186  std::vector<std::vector<std::vector<double>>> TempKinematicBounds;
187  //First element of TempKinematicBounds is always -999, and size is then 3
188  for(int KinVar_i = 0 ; KinVar_i < NumKinematicCuts ; ++KinVar_i) {
189  //ETA: This is a bit messy, Kinematic cuts is a list of maps
190  for (YAML::const_iterator it = param["KinematicCuts"][KinVar_i].begin();it!=param["KinematicCuts"][KinVar_i].end();++it) {
191  TempKinematicStrings.push_back(it->first.as<std::string>());
192  TempKinematicBounds.push_back(Get2DBounds(it->second));
193  }
194  if(TempKinematicStrings.size() == 0) {
195  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++))");
196  MACH3LOG_ERROR("For Param {}", norm.name);
197  throw MaCh3Exception(__FILE__, __LINE__);
198  }
199  }//KinVar_i
200  norm.KinematicVarStr = TempKinematicStrings;
201  norm.Selection = TempKinematicBounds;
202  }
203 
204  //Next ones are kinematic bounds on where normalisation parameter should apply
205  //We set a bool to see if any bounds exist so we can short-circuit checking all of them every step
206  bool HasKinBounds = false;
207 
208  if(norm.KinematicVarStr.size() > 0) HasKinBounds = true;
209 
210  norm.hasKinBounds = HasKinBounds;
211  //End of kinematic bound checking
212 
213  return norm;
214 }
215 
216 // ********************************************
217 // Get Base Param
218 void ParameterHandlerGeneric::GetBaseParameter(const YAML::Node& param, const int Index, TypeParameterBase& Parameter) {
219 // ********************************************
220  // KS: For now we don't use so avoid compilation error
221  (void) param;
222 
223  Parameter.name = GetParFancyName(Index);
224 
225  // Set the global parameter index of the normalisation parameter
226  Parameter.index = Index;
227 }
228 
229 
230 // ********************************************
231 // Grab the global syst index for the relevant SampleName
232 // i.e. get a vector of size nSplines where each entry is filled with the global syst number
233 const std::vector<int> ParameterHandlerGeneric::GetGlobalSystIndexFromSampleName(const std::string& SampleName, const SystType Type) {
234 // ********************************************
235  std::vector<int> returnVec;
236  for (auto &pair : _fSystToGlobalSystIndexMap[Type]) {
237  auto &SystIndex = pair.second;
238  if (AppliesToSample(SystIndex, SampleName)) { //If parameter applies to required SampleID
239  returnVec.push_back(SystIndex);
240  }
241  }
242  return returnVec;
243 }
244 
245 // ********************************************
246 // Grab the global syst index for the relevant SampleName
247 // i.e. get a vector of size nSplines where each entry is filled with the global syst number
248 const std::vector<int> ParameterHandlerGeneric::GetSystIndexFromSampleName(const std::string& SampleName, const SystType Type) const {
249 // ********************************************
250  std::vector<int> returnVec;
251  for (auto &pair : _fSystToGlobalSystIndexMap[Type]) {
252  auto &SplineIndex = pair.first;
253  auto &systIndex = pair.second;
254  if (AppliesToSample(systIndex, SampleName)) { //If parameter applies to required SampleID
255  returnVec.push_back(SplineIndex);
256  }
257  }
258  return returnVec;
259 }
260 
261 // ********************************************
262 // Get Norm params
263 SplineParameter ParameterHandlerGeneric::GetSplineParameter(const YAML::Node& param, const int Index) {
264 // ********************************************
265  SplineParameter Spline;
266 
267  GetBaseParameter(param, Index, Spline);
268  //Now get the Spline interpolation type
269  if (param["SplineInformation"]["InterpolationType"]){
270  for(int InterpType = 0; InterpType < kSplineInterpolations ; ++InterpType){
271  if(param["SplineInformation"]["InterpolationType"].as<std::string>() == SplineInterpolation_ToString(SplineInterpolation(InterpType)))
272  Spline._SplineInterpolationType = SplineInterpolation(InterpType);
273  }
274  } else { //KS: By default use TSpline3
276  }
277  Spline._SplineKnotUpBound = GetFromManager<double>(param["SplineInformation"]["SplineKnotUpBound"], M3::DefSplineKnotUpBound, __FILE__ , __LINE__);
278  Spline._SplineKnotLowBound = GetFromManager<double>(param["SplineInformation"]["SplineKnotLowBound"], M3::DefSplineKnotLowBound, __FILE__ , __LINE__);
279 
281  MACH3LOG_WARN("Spline knot capping enabled with bounds [{}, {}]. For reliable fits, consider modifying the input generation instead.",
282  Spline._SplineKnotLowBound, Spline._SplineKnotUpBound);
283  }
284  //If there is no mode information given then this will be an empty vector
285  Spline._fSplineModes = GetFromManager(param["SplineInformation"]["Mode"], std::vector<int>(), __FILE__ , __LINE__);
286 
287  return Spline;
288 }
289 
290 // ********************************************
291 // Get Func params
293 // ********************************************
294  FunctionalParameter func;
295  GetBaseParameter(param, Index, func);
296 
297  func.pdgs = GetFromManager<std::vector<int>>(param["NeutrinoFlavour"], std::vector<int>(), __FILE__ , __LINE__);
298  func.targets = GetFromManager<std::vector<int>>(param["TargetNuclei"], std::vector<int>(), __FILE__ , __LINE__);
299  func.modes = GetFromManager<std::vector<int>>(param["Mode"], std::vector<int>(), __FILE__ , __LINE__);
300  func.preoscpdgs = GetFromManager<std::vector<int>>(param["NeutrinoFlavourUnosc"], std::vector<int>(), __FILE__ , __LINE__);
301 
302  // HH - Copied from GetXsecNorm
303  int NumKinematicCuts = 0;
304  if(param["KinematicCuts"]) {
305  NumKinematicCuts = int(param["KinematicCuts"].size());
306 
307  std::vector<std::string> TempKinematicStrings;
308  std::vector<std::vector<std::vector<double>>> TempKinematicBounds;
309  //First element of TempKinematicBounds is always -999, and size is then 3
310  for(int KinVar_i = 0 ; KinVar_i < NumKinematicCuts ; ++KinVar_i){
311  //ETA: This is a bit messy, Kinematic cuts is a list of maps
312  for (YAML::const_iterator it = param["KinematicCuts"][KinVar_i].begin();it!=param["KinematicCuts"][KinVar_i].end();++it) {
313  TempKinematicStrings.push_back(it->first.as<std::string>());
314  TempKinematicBounds.push_back(Get2DBounds(it->second));
315  }
316  if(TempKinematicStrings.size() == 0) {
317  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++))");
318  MACH3LOG_ERROR("For Param {}", func.name);
319  throw MaCh3Exception(__FILE__, __LINE__);
320  }
321  }//KinVar_i
322  func.KinematicVarStr = TempKinematicStrings;
323  func.Selection = TempKinematicBounds;
324  }
325  func.valuePtr = RetPointer(Index);
326  return func;
327 }
328 
329 // ********************************************
330 // Get Osc params
332 // ********************************************
333  OscillationParameter OscParamInfo;
334  GetBaseParameter(param, Index, OscParamInfo);
335 
336  return OscParamInfo;
337 }
338 
339 // ********************************************
340 // HH: Grab the Functional parameters for the relevant SampleName
341 const std::vector<FunctionalParameter> ParameterHandlerGeneric::GetFunctionalParametersFromSampleName(const std::string& SampleName) const {
342 // ********************************************
344 }
345 
346 // ********************************************
347 // DB Grab the Normalisation parameters for the relevant SampleName
348 const std::vector<NormParameter> ParameterHandlerGeneric::GetNormParsFromSampleName(const std::string& SampleName) const {
349 // ********************************************
351 }
352 
353 // ********************************************
354 // KS Grab the Spline parameters for the relevant SampleName
355 const std::vector<SplineParameter> ParameterHandlerGeneric::GetSplineParsFromSampleName(const std::string& SampleName) const {
356 // ********************************************
358 }
359 
360 // ********************************************
361 template<typename ParamT>
362 std::vector<ParamT> ParameterHandlerGeneric::GetTypeParamsFromSampleName(const std::map<int, int>& indexMap, const std::vector<ParamT>& params, const std::string& SampleName) const {
363 // ********************************************
364  std::vector<ParamT> returnVec;
365  for (const auto& pair : indexMap) {
366  const auto& localIndex = pair.first;
367  const auto& globalIndex = pair.second;
368  if (AppliesToSample(globalIndex, SampleName)) {
369  returnVec.push_back(params[localIndex]);
370  }
371  }
372  return returnVec;
373 }
374 
375 // ********************************************
376 // DB Grab the number of parameters for the relevant SampleName
377 int ParameterHandlerGeneric::GetNumParamsFromSampleName(const std::string& SampleName, const SystType Type) {
378 // ********************************************
379  int returnVal = 0;
380  IterateOverParams(SampleName,
381  [&](int i) { return GetParamType(i) == Type; }, // Filter condition
382  [&](int) { returnVal += 1; } // Action to perform if filter passes
383  );
384  return returnVal;
385 }
386 
387 // ********************************************
388 // DB Grab the parameter names for the relevant SampleName
389 const std::vector<std::string> ParameterHandlerGeneric::GetParsNamesFromSampleName(const std::string& SampleName, const SystType Type) {
390 // ********************************************
391  std::vector<std::string> returnVec;
392  IterateOverParams(SampleName,
393  [&](int i) { return GetParamType(i) == Type; }, // Filter condition
394  [&](int i) { returnVec.push_back(GetParFancyName(i)); } // Action to perform if filter passes
395  );
396  return returnVec;
397 }
398 
399 // ********************************************
400 // DB DB Grab the parameter indices for the relevant SampleName
401 const std::vector<int> ParameterHandlerGeneric::GetParsIndexFromSampleName(const std::string& SampleName, const SystType Type) {
402 // ********************************************
403  std::vector<int> returnVec;
404  IterateOverParams(SampleName,
405  [&](int i) { return GetParamType(i) == Type; }, // Filter condition
406  [&](int i) { returnVec.push_back(i); } // Action to perform if filter passes
407  );
408  return returnVec;
409 }
410 
411 // ********************************************
412 template <typename FilterFunc, typename ActionFunc>
413 void ParameterHandlerGeneric::IterateOverParams(const std::string& SampleName, FilterFunc filter, ActionFunc action) {
414 // ********************************************
415  for (int i = 0; i < _fNumPar; ++i) {
416  if ((AppliesToSample(i, SampleName)) && filter(i)) { // Common filter logic
417  action(i); // Specific action for each function
418  }
419  }
420 }
421 
422 // ********************************************
424 // ********************************************
425  for (int i = 0; i < _fNumPar; ++i) {
426  //ETA - set the name to be param_% as this is what ProcessorMCMC expects
427  _fNames[i] = "param_"+std::to_string(i);
428 
429  // KS: Plenty
430  if(_fParamType[i] == kOsc){
431  _fNames[i] = _fFancyNames[i];
432 
433  if(_ParameterGroup[i] != "Osc"){
434  MACH3LOG_ERROR("Parameter {}, is of type Oscillation but doesn't belong to Osc group", _fFancyNames[i]);
435  MACH3LOG_ERROR("It belongs to {} group", _ParameterGroup[i]);
436  throw MaCh3Exception(__FILE__ , __LINE__ );
437  }
438  }
439  // Set ParameterHandler parameters (Curr = current, Prop = proposed, Sigma = step)
440  _fCurrVal[i] = _fPreFitValue[i];
441  _fPropVal[i] = _fCurrVal[i];
442  }
443  Randomize();
444  //KS: Transfer the starting parameters to the PCA basis, you don't want to start with zero..
445  if (pca) {
446  PCAObj->SetInitialParameters();
447  }
448 }
449 
450 // ********************************************
451 // Print everything we know about the inputs we're Getting
453 // ********************************************
454  MACH3LOG_INFO("#################################################");
455  MACH3LOG_INFO("Printing ParameterHandlerGeneric:");
456 
458 
459  PrintNormParams();
460 
462 
464 
466 
468 
469  MACH3LOG_INFO("Finished");
470  MACH3LOG_INFO("#################################################");
471 
473 } // End
474 
475 // ********************************************
477 // ********************************************
478  MACH3LOG_INFO("============================================================================================================================================================");
479  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");
480  MACH3LOG_INFO("------------------------------------------------------------------------------------------------------------------------------------------------------------");
481  for (int i = 0; i < GetNumParams(); i++) {
482  std::string ErrString = fmt::format("{:.2f}", _fError[i]);
483  std::string SampleNameString = "";
484  for (const auto& SampleName : _fSampleNames[i]) {
485  if (!SampleNameString.empty()) {
486  SampleNameString += ", ";
487  }
488  SampleNameString += SampleName;
489  }
490  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]));
491  }
492  MACH3LOG_INFO("============================================================================================================================================================");
493 }
494 
495 // ********************************************
497 // ********************************************
498  // Output the normalisation parameters as a sanity check!
499  MACH3LOG_INFO("Normalisation parameters: {}", NormParams.size());
500  if(_fSystToGlobalSystIndexMap[SystType::kNorm].size() == 0) return;
501 
502  bool have_parameter_with_kin_bounds = false;
503 
504  //KS: Consider making some class producing table..
505  MACH3LOG_INFO("┌────┬──────────┬────────────────────────────────────────┬────────────────────┬────────────────────┬────────────────────┐");
506  MACH3LOG_INFO("│{0:4}│{1:10}│{2:40}│{3:20}│{4:20}│{5:20}│", "#", "Global #", "Name", "Int. mode", "Target", "pdg");
507  MACH3LOG_INFO("├────┼──────────┼────────────────────────────────────────┼────────────────────┼────────────────────┼────────────────────┤");
508 
509  for (unsigned int i = 0; i < NormParams.size(); ++i)
510  {
511  std::string intModeString;
512  for (unsigned int j = 0; j < NormParams[i].modes.size(); j++) {
513  intModeString += std::to_string(NormParams[i].modes[j]);
514  intModeString += " ";
515  }
516  if (NormParams[i].modes.empty()) intModeString += "all";
517 
518  std::string targetString;
519  for (unsigned int j = 0; j < NormParams[i].targets.size(); j++) {
520  targetString += std::to_string(NormParams[i].targets[j]);
521  targetString += " ";
522  }
523  if (NormParams[i].targets.empty()) targetString += "all";
524 
525  std::string pdgString;
526  for (unsigned int j = 0; j < NormParams[i].pdgs.size(); j++) {
527  pdgString += std::to_string(NormParams[i].pdgs[j]);
528  pdgString += " ";
529  }
530  if (NormParams[i].pdgs.empty()) pdgString += "all";
531 
532  MACH3LOG_INFO("│{: <4}│{: <10}│{: <40}│{: <20}│{: <20}│{: <20}│", i, NormParams[i].index, NormParams[i].name, intModeString, targetString, pdgString);
533 
534  if(NormParams[i].hasKinBounds) have_parameter_with_kin_bounds = true;
535  }
536  MACH3LOG_INFO("└────┴──────────┴────────────────────────────────────────┴────────────────────┴────────────────────┴────────────────────┘");
537 
538  if(have_parameter_with_kin_bounds) {
539  MACH3LOG_INFO("Normalisation parameters KinematicCuts information");
540  MACH3LOG_INFO("┌────┬──────────┬────────────────────────────────────────┬────────────────────┬────────────────────────────────────────┐");
541  MACH3LOG_INFO("│{0:4}│{1:10}│{2:40}│{3:20}│{4:40}│", "#", "Global #", "Name", "KinematicCut", "Value");
542  MACH3LOG_INFO("├────┼──────────┼────────────────────────────────────────┼────────────────────┼────────────────────────────────────────┤");
543  for (unsigned int i = 0; i < NormParams.size(); ++i)
544  {
545  //skip parameters with no KinematicCuts
546  if(!NormParams[i].hasKinBounds) continue;
547 
548  const long unsigned int ncuts = NormParams[i].KinematicVarStr.size();
549  for(long unsigned int icut = 0; icut < ncuts; icut++) {
550  std::string kinematicCutValueString;
551  for(const auto & value : NormParams[i].Selection[icut]) {
552  for (const auto& v : value) {
553  kinematicCutValueString += fmt::format("{:.2f} ", v);
554  }
555  }
556  if(icut == 0)
557  MACH3LOG_INFO("│{: <4}│{: <10}│{: <40}│{: <20}│{: <40}│", i, NormParams[i].index, NormParams[i].name, NormParams[i].KinematicVarStr[icut], kinematicCutValueString);
558  else
559  MACH3LOG_INFO("│{: <4}│{: <10}│{: <40}│{: <20}│{: <40}│", "", "", "", NormParams[i].KinematicVarStr[icut], kinematicCutValueString);
560  }//icut
561  }//i
562  MACH3LOG_INFO("└────┴──────────┴────────────────────────────────────────┴────────────────────┴────────────────────────────────────────┘");
563  }
564  else
565  MACH3LOG_INFO("No normalisation parameters have KinematicCuts defined");
566 }
567 
568 // ********************************************
570 // ********************************************
571  MACH3LOG_INFO("Spline parameters: {}", _fSystToGlobalSystIndexMap[SystType::kSpline].size());
572  if(_fSystToGlobalSystIndexMap[SystType::kSpline].size() == 0) return;
573  MACH3LOG_INFO("=====================================================================================================================================================================");
574  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", "|");
575  MACH3LOG_INFO("---------------------------------------------------------------------------------------------------------------------------------------------------------------------");
576  for (auto &pair : _fSystToGlobalSystIndexMap[SystType::kSpline]) {
577  auto &SplineIndex = pair.first;
578  auto &GlobalIndex = pair.second;
579 
580  MACH3LOG_INFO("{:<4} {:<2} {:<40} {:<2} {:<40} {:<2} {:<20} {:<2} {:<20} {:<2} {:<20} {:<2}",
581  SplineIndex, "|", GetParFancyName(GlobalIndex), "|",
582  _fSplineNames[SplineIndex], "|",
584  GetParSplineKnotLowerBound(SplineIndex), "|",
585  GetParSplineKnotUpperBound(SplineIndex), "|");
586  }
587  MACH3LOG_INFO("=====================================================================================================================================================================");
588 }
589 
590 // ********************************************
592 // ********************************************
593  MACH3LOG_INFO("Functional parameters: {}", _fSystToGlobalSystIndexMap[SystType::kFunc].size());
594  if(_fSystToGlobalSystIndexMap[SystType::kFunc].size() == 0) return;
595  MACH3LOG_INFO("┌────┬──────────┬────────────────────────────────────────┐");
596  MACH3LOG_INFO("│{0:4}│{1:10}│{2:40}│", "#", "Global #", "Name");
597  MACH3LOG_INFO("├────┼──────────┼────────────────────────────────────────┤");
598  for (auto &pair : _fSystToGlobalSystIndexMap[SystType::kFunc]) {
599  auto &FuncIndex = pair.first;
600  auto &GlobalIndex = pair.second;
601  MACH3LOG_INFO("│{0:4}│{1:<10}│{2:40}│", std::to_string(FuncIndex), GlobalIndex, GetParFancyName(GlobalIndex));
602  }
603  MACH3LOG_INFO("└────┴──────────┴────────────────────────────────────────┘");
604 }
605 
606 // ********************************************
608 // ********************************************
609  MACH3LOG_INFO("Oscillation parameters: {}", _fSystToGlobalSystIndexMap[SystType::kOsc].size());
610  if(_fSystToGlobalSystIndexMap[SystType::kOsc].size() == 0) return;
611  MACH3LOG_INFO("┌────┬──────────┬────────────────────────────────────────┐");
612  MACH3LOG_INFO("│{0:4}│{1:10}│{2:40}│", "#", "Global #", "Name");
613  MACH3LOG_INFO("├────┼──────────┼────────────────────────────────────────┤");
614  for (auto &pair : _fSystToGlobalSystIndexMap[SystType::kOsc]) {
615  auto &OscIndex = pair.first;
616  auto &GlobalIndex = pair.second;
617  MACH3LOG_INFO("│{0:4}│{1:<10}│{2:40}│", std::to_string(OscIndex), GlobalIndex, GetParFancyName(GlobalIndex));
618  }
619  MACH3LOG_INFO("└────┴──────────┴────────────────────────────────────────┘");
620 }
621 
622 // ********************************************
624 // ********************************************
625  // KS: Create a map to store the counts of unique strings, in principle this could be in header file
626  std::unordered_map<std::string, int> paramCounts;
627 
628  std::for_each(_ParameterGroup.begin(), _ParameterGroup.end(),
629  [&paramCounts](const std::string& param) {
630  paramCounts[param]++;
631  });
632 
633  MACH3LOG_INFO("Printing parameter groups");
634  // Output the counts
635  for (const auto& pair : paramCounts) {
636  MACH3LOG_INFO("Found {}: {} params", pair.second, pair.first);
637  }
638 }
639 
640 // ********************************************
642 // ********************************************
643  std::unordered_set<std::string> uniqueGroups;
644 
645  // Fill the set with unique values
646  for (const auto& param : _ParameterGroup) {
647  uniqueGroups.insert(param);
648  }
649 
650  // Convert to vector and return
651  std::vector<std::string> result(uniqueGroups.begin(), uniqueGroups.end());
652  return result;
653 }
654 
655 // ********************************************
656 // KS: Check if matrix is correctly initialised
658 // ********************************************
659  // KS: Lambda Function which simply checks if there are no duplicates in std::vector
660  auto CheckForDuplicates = [](const std::vector<std::string>& names, const std::string& nameType) {
661  std::unordered_map<std::string, size_t> seenStrings;
662  for (size_t i = 0; i < names.size(); ++i) {
663  const auto& name = names[i];
664  if (seenStrings.find(name) != seenStrings.end()) {
665  size_t firstIndex = seenStrings[name];
666  MACH3LOG_CRITICAL("There are two systematics with the same {} '{}', first at index {}, and again at index {}", nameType, name, firstIndex, i);
667  throw MaCh3Exception(__FILE__, __LINE__);
668  }
669  seenStrings[name] = i;
670  }
671  };
672 
673  // KS: Checks if there are no duplicates in fancy names etc, this can happen if we merge configs etc
674  CheckForDuplicates(_fFancyNames, "_fFancyNames");
675  CheckForDuplicates(_fSplineNames, "_fSplineNames");
676 }
677 
678 // ********************************************
679 // Function to set to prior parameters of a given group
680 void ParameterHandlerGeneric::SetGroupOnlyParameters(const std::vector< std::string>& Groups) {
681 // ********************************************
682  for(size_t i = 0; i < Groups.size(); i++){
683  SetGroupOnlyParameters(Groups[i]);
684  }
685 }
686 
687 // ********************************************
688 // Function to set to prior parameters of a given group
689 void ParameterHandlerGeneric::SetGroupOnlyParameters(const std::string& Group, const std::vector<double>& Pars) {
690 // ********************************************
691  // If empty, set the proposed to prior
692  if (Pars.empty()) {
693  for (int i = 0; i < _fNumPar; i++) {
694  if(IsParFromGroup(i, Group)) _fPropVal[i] = _fPreFitValue[i];
695  }
696  } else{
697  const size_t ExpectedSize = static_cast<size_t>(GetNumParFromGroup(Group));
698  if (Pars.size() != ExpectedSize) {
699  MACH3LOG_ERROR("Number of param in group {} is {}, while you passed {}", Group, ExpectedSize, Pars.size());
700  throw MaCh3Exception(__FILE__, __LINE__);
701  }
702  int Counter = 0;
703  for (int i = 0; i < _fNumPar; i++) {
704  // If belongs to group set value from parsed vector, otherwise use propose value
705  if(IsParFromGroup(i, Group)){
706  _fPropVal[i] = Pars[Counter];
707  Counter++;
708  }
709  }
710  }
711  // And if pca make the transfer
712  if (pca) {
713  PCAObj->TransferToPCA();
714  PCAObj->TransferToParam();
715  }
716 }
717 
718 // ********************************************
719 // Toggle fix/free to parameters of a given group
721 // ********************************************
722  for (int i = 0; i < _fNumPar; ++i)
723  if(IsParFromGroup(i, Group)) ToggleFixParameter(i);
724 }
725 
726 // ********************************************
727 // Toggle fix/free to parameters of several groups
728 void ParameterHandlerGeneric::ToggleFixGroupOnlyParameters(const std::vector< std::string>& Groups) {
729 // ********************************************
730  for(size_t i = 0; i < Groups.size(); i++)
731  ToggleFixGroupOnlyParameters(Groups[i]);
732 }
733 
734 // ********************************************
735 // Set parameters to be fixed in a given group
737 // ********************************************
738  for (int i = 0; i < _fNumPar; ++i)
739  if(IsParFromGroup(i, Group)) SetFixParameter(i);
740 }
741 
742 // ********************************************
743 // Set parameters of several groups to be fixed
744 void ParameterHandlerGeneric::SetFixGroupOnlyParameters(const std::vector< std::string>& Groups) {
745 // ********************************************
746  for(size_t i = 0; i < Groups.size(); i++)
747  SetFixGroupOnlyParameters(Groups[i]);
748 }
749 
750 // ********************************************
751 // Set parameters to be free in a given group
753 // ********************************************
754  for (int i = 0; i < _fNumPar; ++i)
755  if(IsParFromGroup(i, Group)) SetFreeParameter(i);
756 }
757 
758 // ********************************************
759 // Set parameters of several groups to be fixed
760 void ParameterHandlerGeneric::SetFreeGroupOnlyParameters(const std::vector< std::string>& Groups) {
761 // ********************************************
762  for(size_t i = 0; i < Groups.size(); i++)
763  SetFreeGroupOnlyParameters(Groups[i]);
764 }
765 
766 // ********************************************
767 // Checks if parameter belongs to a given group
768 bool ParameterHandlerGeneric::IsParFromGroup(const int i, const std::string& Group) const {
769 // ********************************************
770  std::string groupLower = Group;
771  std::string paramGroupLower = _ParameterGroup[i];
772 
773  // KS: Convert both strings to lowercase, this way comparison will be case insensitive
774  std::transform(groupLower.begin(), groupLower.end(), groupLower.begin(), ::tolower);
775  std::transform(paramGroupLower.begin(), paramGroupLower.end(), paramGroupLower.begin(), ::tolower);
776 
777  return groupLower == paramGroupLower;
778 }
779 
780 // ********************************************
781 int ParameterHandlerGeneric::GetNumParFromGroup(const std::string& Group) const {
782 // ********************************************
783  int Counter = 0;
784  for (int i = 0; i < _fNumPar; i++) {
785  if(IsParFromGroup(i, Group)) Counter++;
786  }
787  return Counter;
788 }
789 
790 // ********************************************
791 // DB Grab the Normalisation parameters for the relevant sample name
792 std::vector<const double*> ParameterHandlerGeneric::GetOscParsFromSampleName(const std::string& SampleName) {
793 // ********************************************
794  std::vector<const double*> returnVec;
795  for (const auto& pair : _fSystToGlobalSystIndexMap[SystType::kOsc]) {
796  const auto& globalIndex = pair.second;
797  if (AppliesToSample(globalIndex, SampleName)) {
798  returnVec.push_back(RetPointer(globalIndex));
799  }
800  }
801  return returnVec;
802 }
803 
804 // ********************************************
805 // Dump Matrix to ROOT file, useful when we need to pass matrix info to another fitting group
806 void ParameterHandlerGeneric::DumpMatrixToFile(const std::string& Name) {
807 // ********************************************
808  TFile* outputFile = new TFile(Name.c_str(), "RECREATE");
809 
810  TObjArray* param_names = new TObjArray();
811  TObjArray* spline_interpolation = new TObjArray();
812  TObjArray* spline_names = new TObjArray();
813 
814  TVectorD* param_prior = new TVectorD(_fNumPar);
815  TVectorD* flat_prior = new TVectorD(_fNumPar);
816  TVectorD* stepscale = new TVectorD(_fNumPar);
817  TVectorD* param_lb = new TVectorD(_fNumPar);
818  TVectorD* param_ub = new TVectorD(_fNumPar);
819 
820  TVectorD* param_knot_weight_lb = new TVectorD(_fNumPar);
821  TVectorD* param_knot_weight_ub = new TVectorD(_fNumPar);
822  TVectorD* error = new TVectorD(_fNumPar);
823 
824  for(int i = 0; i < _fNumPar; ++i)
825  {
826  TObjString* nameObj = new TObjString(_fFancyNames[i].c_str());
827  param_names->AddLast(nameObj);
828 
829  TObjString* splineType = new TObjString("TSpline3");
830  spline_interpolation->AddLast(splineType);
831 
832  TObjString* splineName = new TObjString("");
833  spline_names->AddLast(splineName);
834 
835  (*param_prior)[i] = _fPreFitValue[i];
836  (*flat_prior)[i] = _fFlatPrior[i];
837  (*stepscale)[i] = _fIndivStepScale[i];
838  (*error)[i] = _fError[i];
839 
840  (*param_lb)[i] = _fLowBound[i];
841  (*param_ub)[i] = _fUpBound[i];
842 
843  //Default values
844  (*param_knot_weight_lb)[i] = -9999;
845  (*param_knot_weight_ub)[i] = +9999;
846  }
847 
848  for (auto &pair : _fSystToGlobalSystIndexMap[SystType::kSpline]) {
849  auto &SplineIndex = pair.first;
850  auto &SystIndex = pair.second;
851 
852  (*param_knot_weight_lb)[SystIndex] = SplineParams.at(SplineIndex)._SplineKnotLowBound;
853  (*param_knot_weight_ub)[SystIndex] = SplineParams.at(SplineIndex)._SplineKnotUpBound;
854 
855  TObjString* splineType = new TObjString(SplineInterpolation_ToString(SplineParams.at(SplineIndex)._SplineInterpolationType).c_str());
856  spline_interpolation->AddAt(splineType, SystIndex);
857 
858  TObjString* splineName = new TObjString(_fSplineNames[SplineIndex].c_str());
859  spline_names->AddAt(splineName, SystIndex);
860  }
861  param_names->Write("xsec_param_names", TObject::kSingleKey);
862  delete param_names;
863  spline_interpolation->Write("xsec_spline_interpolation", TObject::kSingleKey);
864  delete spline_interpolation;
865  spline_names->Write("xsec_spline_names", TObject::kSingleKey);
866  delete spline_names;
867 
868  param_prior->Write("xsec_param_prior");
869  delete param_prior;
870  flat_prior->Write("xsec_flat_prior");
871  delete flat_prior;
872  stepscale->Write("xsec_stepscale");
873  delete stepscale;
874  param_lb->Write("xsec_param_lb");
875  delete param_lb;
876  param_ub->Write("xsec_param_ub");
877  delete param_ub;
878 
879  param_knot_weight_lb->Write("xsec_param_knot_weight_lb");
880  delete param_knot_weight_lb;
881  param_knot_weight_ub->Write("xsec_param_knot_weight_ub");
882  delete param_knot_weight_ub;
883  error->Write("xsec_error");
884  delete error;
885 
886  covMatrix->Write("xsec_cov");
887  TH2D* CorrMatrix = GetCorrelationMatrix();
888  CorrMatrix->Write("hcov");
889  delete CorrMatrix;
890 
891  outputFile->Close();
892  delete outputFile;
893 
894  MACH3LOG_INFO("Finished dumping ParameterHandler object");
895 }
#define MACH3LOG_CRITICAL
Definition: MaCh3Logger.h:38
#define MACH3LOG_DEBUG
Definition: MaCh3Logger.h:34
#define MACH3LOG_ERROR
Definition: MaCh3Logger.h:37
#define MACH3LOG_INFO
Definition: MaCh3Logger.h:35
#define MACH3LOG_WARN
Definition: MaCh3Logger.h:36
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.
SystType
@ kNorm
For normalisation parameters.
@ kSpline
For splined parameters (1D)
@ kSystTypes
This only enumerates.
@ kOsc
For oscillation parameters.
@ kFunc
For functional parameters.
#define Get2DBounds(filename)
Definition: YamlHelper.h:591
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.
Definition: YamlHelper.h:329
Custom exception class used throughout MaCh3.
Base class responsible for handling of systematic error parameters. Capable of using PCA or using ada...
int GetNumParams() const
Get total number of parameters.
void ToggleFixParameter(const int i)
Toggle fixing parameter at prior values.
const double * RetPointer(const int iParam)
DB Pointer return to param position.
bool AppliesToSample(const int SystIndex, const std::string &SampleName) const
Check if parameter is affecting given sample name.
std::vector< std::string > _fFancyNames
Fancy name for example rather than param_0 it is MAQE, useful for human reading.
std::vector< bool > _fFlatPrior
Whether to apply flat prior or not.
std::string GetParFancyName(const int i) const
Get fancy name of the Parameter.
std::vector< double > _fError
Prior error on the parameter.
TH2D * GetCorrelationMatrix()
KS: Convert covariance matrix to correlation matrix and return TH2D which can be used for fancy plott...
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.
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.
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 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.
bool pca
perform PCA or not
std::vector< double > _fIndivStepScale
Individual step scale used by MCMC algorithm.
int PrintLength
KS: This is used when printing parameters, sometimes we have super long parameters name,...
std::vector< double > _fPropVal
Proposed value of the parameter.
std::vector< std::vector< std::string > > _fSampleNames
Tells to which samples object param should be applied.
void PrintNormParams()
Prints normalization parameters.
FunctionalParameter GetFunctionalParameters(const YAML::Node &param, const int Index)
Get Func params.
std::vector< SplineParameter > SplineParams
Vector containing info for normalisation systematics.
void PrintParameterGroups()
Prints groups of parameters.
SplineParameter GetSplineParameter(const YAML::Node &param, const int Index)
Get Spline params.
const std::vector< NormParameter > GetNormParsFromSampleName(const std::string &SampleName) const
DB Get norm/func parameters depending on given SampleName.
void Print()
Print information about the whole object once it is set.
ParameterHandlerGeneric(const std::vector< std::string > &FileNames, std::string name="xsec_cov", double threshold=-1, int FirstPCAdpar=-999, int LastPCAdpar=-999)
Constructor.
std::vector< std::string > _fSplineNames
Name of spline in TTree (TBranch),.
void PrintOscillationParams()
Prints oscillation parameters.
SystType GetParamType(const int i) const
Returns enum describing our param type.
void ToggleFixGroupOnlyParameters(const std::string &Group)
TN Method to toggle fix/free parameters within a group.
const std::vector< int > GetSystIndexFromSampleName(const std::string &SampleName, const SystType Type) const
Grab the index of the syst relative to global numbering.
void PrintSplineParams()
Prints spline parameters.
void InitParams()
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)
DB Get spline parameters depending on given SampleName.
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 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.
void PrintFunctionalParams()
Prints functional parameters.
void CheckCorrectInitialisation()
KS: Check if matrix is correctly initialised.
const std::vector< int > GetParsIndexFromSampleName(const std::string &SampleName, const SystType Type)
DB Grab the parameter indices for the relevant SampleName.
const std::vector< SplineParameter > GetSplineParsFromSampleName(const std::string &SampleName) const
KS: Grab the Spline parameters for the relevant SampleName.
void PrintGlobablInfo()
Prints general information about the ParameterHandler object.
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.
NormParameter GetNormParameter(const YAML::Node &param, const int Index)
Get Norm params.
void InitParametersTypeFromConfig()
Parses the YAML configuration to set up cross-section parameters. The YAML file defines the types of ...
std::vector< ParamT > GetTypeParamsFromSampleName(const std::map< int, int > &indexMap, const std::vector< ParamT > &params, const std::string &SampleName) const
Retrieve parameters that apply to a given sample name.
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.
std::vector< FunctionalParameter > FuncParams
Vector containing info for functional systematics.
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.
SplineInterpolation GetParSplineInterpolation(const int i) const
Get interpolation type for a given parameter.
std::vector< std::string > GetUniqueParameterGroups()
KS: Get names of all unique parameter groups.
const std::vector< std::string > GetSplineParsNamesFromSampleName(const std::string &SampleName)
DB Get spline parameters depending on given SampleName.
OscillationParameter GetOscillationParameters(const YAML::Node &param, const int Index)
Get Osc params.
bool IsParFromGroup(const int i, const std::string &Group) const
Checks if parameter belongs to a given group.
void SetFixGroupOnlyParameters(const std::string &Group)
TN Method to set parameters within a group to be fixed to their prior values.
void IterateOverParams(const std::string &SampleName, FilterFunc filter, ActionFunc action)
Iterates over parameters and applies a filter and action function.
void GetBaseParameter(const YAML::Node &param, const int Index, TypeParameterBase &Parameter)
Fill base parameters.
std::vector< std::string > _ParameterGroup
KS: Allow to group parameters for example to affect only cross-section or only flux etc.
const std::vector< SplineInterpolation > GetSplineInterpolationFromSampleName(const std::string &SampleName)
Get the interpolation types for splines affecting a particular SampleName.
double GetParSplineKnotLowerBound(const int i) const
EM: value at which we cap spline knot weight.
std::vector< const double * > GetOscParsFromSampleName(const std::string &SampleName)
Get pointers to Osc params from Sample name.
const std::vector< std::vector< int > > GetSplineModeVecFromSampleName(const std::string &SampleName)
DB Grab the Spline Modes for the relevant SampleName.
int GetNumParFromGroup(const std::string &Group) const
KS: Check how many parameters are associated with given group.
constexpr static const double DefSplineKnotUpBound
Default value for spline knot capping, default mean not capping is being applied.
Definition: Core.h:86
constexpr static const double DefSplineKnotLowBound
Default value for spline knot capping, default mean not capping is being applied.
Definition: Core.h:88
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.
std::vector< std::string > KinematicVarStr
const double * valuePtr
Parameter value pointer.
std::vector< int > targets
Targets which parameter applies to.
std::vector< int > pdgs
PDG which parameter applies to.
std::vector< std::vector< std::vector< double > > > Selection
std::vector< int > preoscpdgs
Preosc PDG which parameter applies to.
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.
bool hasKinBounds
Does this parameter have kinematic bounds.
std::vector< std::vector< std::vector< double > > > Selection
std::vector< int > modes
Mode which parameter applies to.
std::vector< int > pdgs
PDG which parameter applies to.
std::vector< std::string > KinematicVarStr
std::vector< int > targets
Targets which parameter applies to.
KS: Struct holding info about oscillation Systematics.
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)
Base class storing info for parameters types, helping unify codebase.
int index
Parameter number of this normalisation in current systematic model.
std::string name
Name of parameters.