MaCh3  2.2.3
Reference Guide
Classes | Typedefs | Enumerations | Functions
ParameterStructs.h File Reference
#include <set>
#include <list>
#include <unordered_map>
#include "Manager/MaCh3Exception.h"
#include "Manager/MaCh3Logger.h"
#include "Manager/Core.h"
#include "TSpline.h"
#include "TObjString.h"
#include "TFile.h"
#include "TF1.h"
#include "TH2Poly.h"
#include "TH1.h"
Include dependency graph for ParameterStructs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  TypeParameterBase
 Base class storing info for parameters types, helping unify codebase. More...
 
struct  NormParameter
 ETA - Normalisations for cross-section parameters Carrier for whether you want to apply a systematic to an event or not. More...
 
struct  FunctionalParameter
 HH - Functional parameters Carrier for whether you want to apply a systematic to an event or not. More...
 
struct  SplineParameter
 KS: Struct holding info about Spline Systematics. More...
 
struct  OscillationParameter
 KS: Struct holding info about oscillation Systematics. More...
 

Typedefs

using FuncParFuncType = std::function< void(const double *, std::size_t)>
 

Enumerations

enum  RespFuncType { kTSpline3_red , kTF1_red , kRespFuncTypes }
 Make an enum of the spline interpolation type. More...
 
enum  SplineInterpolation {
  kTSpline3 , kLinear , kMonotonic , kAkima ,
  kKochanekBartels , kLinearFunc , kSplineInterpolations
}
 Make an enum of the spline interpolation type. More...
 
enum  SystType {
  kNorm , kSpline , kFunc , kOsc ,
  kSystTypes
}
 

Functions

template<typename T , size_t N>
std::vector< T > MakeVector (const T(&data)[N])
 Template to make vector out of an array of any length. More...
 
template<typename T >
void CleanVector (std::vector< T > &vec)
 Generic cleanup function. More...
 
template<typename T >
void CleanVector (std::vector< std::vector< T >> &vec)
 Generic cleanup function. More...
 
template<typename T >
void CleanVector (std::vector< std::vector< std::vector< T >>> &vec)
 Generic cleanup function. More...
 
template<typename T >
void CleanVector (std::vector< std::vector< std::vector< std::vector< std::vector< std::vector< std::vector< T >>>>>>> &vec)
 Generic cleanup function. More...
 
template<typename T >
void CleanContainer (std::vector< T * > &container)
 Generic cleanup function. More...
 
template<typename T >
void CleanContainer (std::vector< std::vector< T * >> &container)
 Generic cleanup function. More...
 
template<typename T >
void CleanContainer (std::vector< std::vector< std::vector< T * > > > &container)
 Generic cleanup function. More...
 
std::string GetTF1 (const SplineInterpolation i)
 Get function for TF1_red. More...
 
RespFuncType SplineInterpolation_ToRespFuncType (const SplineInterpolation i)
 Convert a RespFuncType type to a SplineInterpolation. More...
 
std::string SplineInterpolation_ToString (const SplineInterpolation i)
 Convert a LLH type to a string. More...
 
std::string SystType_ToString (const SystType i)
 Convert a Syst type type to a string. More...
 

Detailed Description

Author
Asher Kaboth
Clarence Wret
Patrick Dunne
Dan Barrow
Ed Atkin
Kamil Skwarczynski

Definition in file ParameterStructs.h.

Typedef Documentation

◆ FuncParFuncType

using FuncParFuncType = std::function<void (const double*, std::size_t)>

Definition at line 196 of file ParameterStructs.h.

Enumeration Type Documentation

◆ RespFuncType

Make an enum of the spline interpolation type.

Enumerator
kTSpline3_red 

Uses TSpline3_red for interpolation.

kTF1_red 

Uses TF1_red for interpolation.

kRespFuncTypes 

This only enumerates.

Definition at line 232 of file ParameterStructs.h.

232  {
233  kTSpline3_red,
234  kTF1_red,
236 };
@ kTF1_red
Uses TF1_red for interpolation.
@ kTSpline3_red
Uses TSpline3_red for interpolation.
@ kRespFuncTypes
This only enumerates.

◆ SplineInterpolation

Make an enum of the spline interpolation type.

Enumerator
kTSpline3 

Default TSpline3 interpolation.

kLinear 

Linear interpolation between knots.

kMonotonic 

EM: DOES NOT make the entire spline monotonic, only the segments.

kAkima 

EM: Akima spline iis allowed to be discontinuous in 2nd derivative and coefficients in any segment.

kKochanekBartels 

KS: Kochanek-Bartels spline: allows local control of tension, continuity, and bias.

kLinearFunc 

Liner interpolation using TF1 not spline.

kSplineInterpolations 

This only enumerates.

Definition at line 239 of file ParameterStructs.h.

239  {
240  kTSpline3,
241  kLinear,
242  kMonotonic,
243  kAkima,
245  kLinearFunc,
247 };
@ kTSpline3
Default TSpline3 interpolation.
@ kMonotonic
EM: DOES NOT make the entire spline monotonic, only the segments.
@ kSplineInterpolations
This only enumerates.
@ kKochanekBartels
KS: Kochanek-Bartels spline: allows local control of tension, continuity, and bias.
@ kLinear
Linear interpolation between knots.
@ kLinearFunc
Liner interpolation using TF1 not spline.
@ kAkima
EM: Akima spline iis allowed to be discontinuous in 2nd derivative and coefficients in any segment.

◆ SystType

enum SystType

Make an enum of systematic type recognised by covariance class

Todo:
KS: Consider using enum class, it is generally recommended as safer. It will require many static_cast
Enumerator
kNorm 

For normalisation parameters.

kSpline 

For splined parameters (1D)

kFunc 

For functional parameters.

kOsc 

For oscillation parameters.

kSystTypes 

This only enumerates.

Definition at line 342 of file ParameterStructs.h.

342  {
343  kNorm,
344  kSpline,
345  kFunc,
346  kOsc,
347  kSystTypes
348 };
@ kNorm
For normalisation parameters.
@ kSpline
For splined parameters (1D)
@ kSystTypes
This only enumerates.
@ kOsc
For oscillation parameters.
@ kFunc
For functional parameters.

Function Documentation

◆ CleanContainer() [1/3]

template<typename T >
void CleanContainer ( std::vector< std::vector< std::vector< T * > > > &  container)

Generic cleanup function.

Definition at line 140 of file ParameterStructs.h.

140  {
141 // *******************
142  for (auto& container2D : container) {
143  for (auto& container1D : container2D) {
144  for (T* ptr : container1D) {
145  if(ptr) delete ptr;
146  }
147  container1D.clear();
148  container1D.shrink_to_fit();
149  }
150  container2D.clear();
151  container2D.shrink_to_fit();
152  }
153  container.clear();
154  container.shrink_to_fit();
155 }

◆ CleanContainer() [2/3]

template<typename T >
void CleanContainer ( std::vector< std::vector< T * >> &  container)

Generic cleanup function.

Definition at line 128 of file ParameterStructs.h.

128  {
129 // *******************
130  for (auto& inner : container) {
131  CleanContainer(inner);
132  }
133  container.clear();
134  container.shrink_to_fit();
135 }
void CleanContainer(std::vector< T * > &container)
Generic cleanup function.

◆ CleanContainer() [3/3]

template<typename T >
void CleanContainer ( std::vector< T * > &  container)

Generic cleanup function.

Definition at line 115 of file ParameterStructs.h.

115  {
116 // *******************
117  for (T* ptr : container) {
118  if(ptr) delete ptr;
119  ptr = nullptr;
120  }
121  container.clear();
122  container.shrink_to_fit();
123 }

◆ CleanVector() [1/4]

template<typename T >
void CleanVector ( std::vector< std::vector< std::vector< std::vector< std::vector< std::vector< std::vector< T >>>>>>> &  vec)

Generic cleanup function.

Todo:
Use recursive to make it more scalable in future

Definition at line 82 of file ParameterStructs.h.

82  {
83 // *******************
84  for (auto& v6 : vec) {
85  for (auto& v5 : v6) {
86  for (auto& v4 : v5) {
87  for (auto& v3 : v4) {
88  for (auto& v2 : v3) {
89  for (auto& v1 : v2) {
90  v1.clear();
91  v1.shrink_to_fit();
92  }
93  v2.clear();
94  v2.shrink_to_fit();
95  }
96  v3.clear();
97  v3.shrink_to_fit();
98  }
99  v4.clear();
100  v4.shrink_to_fit();
101  }
102  v5.clear();
103  v5.shrink_to_fit();
104  }
105  v6.clear();
106  v6.shrink_to_fit();
107  }
108  vec.clear();
109  vec.shrink_to_fit();
110 }

◆ CleanVector() [2/4]

template<typename T >
void CleanVector ( std::vector< std::vector< std::vector< T >>> &  vec)

Generic cleanup function.

Definition at line 64 of file ParameterStructs.h.

64  {
65 // *******************
66  for (auto& inner2DVec : vec) {
67  for (auto& innerVec : inner2DVec) {
68  innerVec.clear();
69  innerVec.shrink_to_fit();
70  }
71  inner2DVec.clear();
72  inner2DVec.shrink_to_fit();
73  }
74  vec.clear();
75  vec.shrink_to_fit();
76 }

◆ CleanVector() [3/4]

template<typename T >
void CleanVector ( std::vector< std::vector< T >> &  vec)

Generic cleanup function.

Definition at line 51 of file ParameterStructs.h.

51  {
52 // *******************
53  for (auto& innerVec : vec) {
54  innerVec.clear();
55  innerVec.shrink_to_fit();
56  }
57  vec.clear();
58  vec.shrink_to_fit();
59 }

◆ CleanVector() [4/4]

template<typename T >
void CleanVector ( std::vector< T > &  vec)

Generic cleanup function.

Definition at line 42 of file ParameterStructs.h.

42  {
43 // *******************
44  vec.clear();
45  vec.shrink_to_fit();
46 }

◆ GetTF1()

std::string GetTF1 ( const SplineInterpolation  i)
inline

Get function for TF1_red.

Parameters
iInterpolation type

Definition at line 252 of file ParameterStructs.h.

252  {
253  // **************************************************
254  std::string Func = "";
255  switch(i) {
257  Func = "([1]+[0]*x)";
258  break;
265  MACH3LOG_ERROR("Interpolation type {} not supported for TF1!", static_cast<int>(i));
266  throw MaCh3Exception(__FILE__, __LINE__);
267  default:
268  MACH3LOG_ERROR("UNKNOWN SPLINE INTERPOLATION SPECIFIED!");
269  MACH3LOG_ERROR("You gave {}", static_cast<int>(i));
270  throw MaCh3Exception(__FILE__ , __LINE__ );
271  }
272  return Func;
273 }
#define MACH3LOG_ERROR
Definition: MaCh3Logger.h:27
Custom exception class for MaCh3 errors.

◆ MakeVector()

template<typename T , size_t N>
std::vector<T> MakeVector ( const T(&)  data[N])

Template to make vector out of an array of any length.

Definition at line 34 of file ParameterStructs.h.

34  {
35 // *******************
36  return std::vector<T>(data, data+N);
37 }

◆ SplineInterpolation_ToRespFuncType()

RespFuncType SplineInterpolation_ToRespFuncType ( const SplineInterpolation  i)
inline

Convert a RespFuncType type to a SplineInterpolation.

Parameters
iInterpolation type

Definition at line 278 of file ParameterStructs.h.

278  {
279 // **************************************************
281  switch(i) {
288  break;
290  Type = RespFuncType::kTF1_red;
291  break;
293  MACH3LOG_ERROR("kSplineInterpolations is not a valid interpolation type!");
294  throw MaCh3Exception(__FILE__, __LINE__);
295  default:
296  MACH3LOG_ERROR("UNKNOWN SPLINE INTERPOLATION SPECIFIED!");
297  MACH3LOG_ERROR("You gave {}", static_cast<int>(i));
298  throw MaCh3Exception(__FILE__, __LINE__);
299  }
300  return Type;
301 }
RespFuncType
Make an enum of the spline interpolation type.

◆ SplineInterpolation_ToString()

std::string SplineInterpolation_ToString ( const SplineInterpolation  i)
inline

Convert a LLH type to a string.

Definition at line 305 of file ParameterStructs.h.

305  {
306 // **************************************************
307  std::string name = "";
308  switch(i) {
309  // TSpline3 (third order spline in ROOT)
311  name = "TSpline3";
312  break;
314  name = "Linear";
315  break;
317  name = "Monotonic";
318  break;
319  // (Experimental) Akima_Spline (crd order spline which is allowed to be discontinuous in 2nd deriv)
321  name = "Akima";
322  break;
324  name = "KochanekBartels";
325  break;
327  name = "LinearFunc";
328  break;
330  MACH3LOG_ERROR("kSplineInterpolations is not a valid interpolation type!");
331  throw MaCh3Exception(__FILE__, __LINE__);
332  default:
333  MACH3LOG_ERROR("UNKNOWN SPLINE INTERPOLATION SPECIFIED!");
334  MACH3LOG_ERROR("You gave {}", static_cast<int>(i));
335  throw MaCh3Exception(__FILE__ , __LINE__ );
336  }
337  return name;
338 }

◆ SystType_ToString()

std::string SystType_ToString ( const SystType  i)
inline

Convert a Syst type type to a string.

Definition at line 368 of file ParameterStructs.h.

368  {
369 // **************************************************
370  std::string name = "";
371  switch(i) {
372  case SystType::kNorm:
373  name = "Norm";
374  break;
375  case SystType::kSpline:
376  name = "Spline";
377  break;
378  case SystType::kFunc:
379  name = "Functional";
380  break;
381  case SystType::kOsc:
382  name = "Oscillation";
383  break;
385  MACH3LOG_ERROR("kSystTypes is not a valid SystType!");
386  throw MaCh3Exception(__FILE__, __LINE__);
387  default:
388  MACH3LOG_ERROR("UNKNOWN SYST TYPE SPECIFIED!");
389  MACH3LOG_ERROR("You gave {}", static_cast<int>(i));
390  throw MaCh3Exception(__FILE__ , __LINE__ );
391  }
392  return name;
393 }