MaCh3  2.6.0
Reference Guide
ParameterStructs.h
Go to the documentation of this file.
1 #pragma once
2 
3 // C++ includes
4 #include <set>
5 #include <list>
6 #include <unordered_map>
7 
8 // MaCh3 includes
10 #include "Manager/MaCh3Logger.h"
11 #include "Manager/Core.h"
12 
14 // ROOT include
15 #include "TSpline.h"
16 #include "TObjString.h"
17 #include "TFile.h"
18 #include "TF1.h"
19 #include "TH2Poly.h"
20 #include "TH1.h"
22 
31 
32 // *******************
34 template< typename T, size_t N >
35 std::vector<T> MakeVector( const T (&data)[N] ) {
36 // *******************
37  return std::vector<T>(data, data+N);
38 }
39 
41 template <typename T>
42 void CleanVector(T&) {}
43 
44 // *******************
51 template <typename T>
52 void CleanVector(std::vector<T>& v) {
53 // *******************
54  for (auto& x : v)
55  CleanVector(x);
56 
57  v.clear();
58  v.shrink_to_fit();
59 }
60 
61 // *******************
63 template <typename T>
64 void CleanContainer(T&) {}
65 // *******************
66 
67 // *******************
71 template <typename T>
72 void CleanContainer(T*& ptr) {
73  // *******************
74  delete ptr;
75  ptr = nullptr;
76 }
77 
78 // *******************
85 template <typename T>
86 void CleanContainer(std::vector<T>& container) {
87  // *******************
88  for (auto& element : container)
89  CleanContainer(element);
90 
91  container.clear();
92  container.shrink_to_fit();
93 }
94 
95 // *******************
101 // *******************
103  std::string name;
104 
106  bool hasKinBounds = false;
109  std::vector< std::vector< std::vector<double> > > Selection;
114  std::vector< std::string > KinematicVarStr;
115 
118 };
119 
120 // *******************
126  std::vector<int> modes;
128  std::vector<int> pdgs;
130  std::vector<int> preoscpdgs;
132  std::vector<int> targets;
133 };
134 
135 // *******************
140 // *******************
142  std::vector<int> modes;
143 };
144 
150 };
151 
161 };
162 
163 // **************************************************
166 inline std::string GetTF1(const SplineInterpolation i) {
167  // **************************************************
168  std::string Func = "";
169  switch(i) {
171  Func = "([1]+[0]*x)";
172  break;
179  MACH3LOG_ERROR("Interpolation type {} not supported for TF1!", static_cast<int>(i));
180  throw MaCh3Exception(__FILE__, __LINE__);
181  default:
182  MACH3LOG_ERROR("UNKNOWN SPLINE INTERPOLATION SPECIFIED!");
183  MACH3LOG_ERROR("You gave {}", static_cast<int>(i));
184  throw MaCh3Exception(__FILE__ , __LINE__ );
185  }
186  return Func;
187 }
188 
189 // **************************************************
193 // **************************************************
195  switch(i) {
202  break;
204  Type = RespFuncType::kTF1_red;
205  break;
207  MACH3LOG_ERROR("kSplineInterpolations is not a valid interpolation type!");
208  throw MaCh3Exception(__FILE__, __LINE__);
209  default:
210  MACH3LOG_ERROR("UNKNOWN SPLINE INTERPOLATION SPECIFIED!");
211  MACH3LOG_ERROR("You gave {}", static_cast<int>(i));
212  throw MaCh3Exception(__FILE__, __LINE__);
213  }
214  return Type;
215 }
216 
217 // **************************************************
220 // **************************************************
221  std::string name = "";
222  switch(i) {
223  // TSpline3 (third order spline in ROOT)
225  name = "TSpline3";
226  break;
228  name = "Linear";
229  break;
231  name = "Monotonic";
232  break;
233  // (Experimental) Akima_Spline (crd order spline which is allowed to be discontinuous in 2nd deriv)
235  name = "Akima";
236  break;
238  name = "KochanekBartels";
239  break;
241  name = "LinearFunc";
242  break;
244  MACH3LOG_ERROR("kSplineInterpolations is not a valid interpolation type!");
245  throw MaCh3Exception(__FILE__, __LINE__);
246  default:
247  MACH3LOG_ERROR("UNKNOWN SPLINE INTERPOLATION SPECIFIED!");
248  MACH3LOG_ERROR("You gave {}", static_cast<int>(i));
249  throw MaCh3Exception(__FILE__ , __LINE__ );
250  }
251  return name;
252 }
253 
256 enum SystType {
261  kSystTypes
262 };
263 
264 // *******************
267 // *******************
270 
272  std::vector<int> _fSplineModes;
273 
275  std::string _fSplineNames;
276 
281 };
282 
283 // **************************************************
285 inline std::string SystType_ToString(const SystType i) {
286 // **************************************************
287  std::string name = "";
288  switch(i) {
289  case SystType::kNorm:
290  name = "Norm";
291  break;
292  case SystType::kSpline:
293  name = "Spline";
294  break;
295  case SystType::kFunc:
296  name = "Functional";
297  break;
298  case SystType::kOsc:
299  name = "Oscillation";
300  break;
302  MACH3LOG_ERROR("kSystTypes is not a valid SystType!");
303  throw MaCh3Exception(__FILE__, __LINE__);
304  default:
305  MACH3LOG_ERROR("UNKNOWN SYST TYPE SPECIFIED!");
306  MACH3LOG_ERROR("You gave {}", static_cast<int>(i));
307  throw MaCh3Exception(__FILE__ , __LINE__ );
308  }
309  return name;
310 }
311 
312 // *******************
316 // *******************
317 };
KS: Core MaCh3 definitions and compile-time configuration utilities.
#define _MaCh3_Safe_Include_Start_
KS: Avoiding warning checking for headers.
Definition: Core.h:126
#define _MaCh3_Safe_Include_End_
Defines the custom exception class used throughout MaCh3.
MaCh3 Logging utilities built on top of SPDLOG.
#define MACH3LOG_ERROR
Definition: MaCh3Logger.h:37
std::string SplineInterpolation_ToString(const SplineInterpolation i)
Convert a LLH type to a string.
void CleanContainer(T &)
Base case: do nothing for non-pointer types.
SplineInterpolation
Make an enum of the spline interpolation type.
@ 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.
RespFuncType
Make an enum of the spline interpolation type.
@ kTF1_red
Uses TF1_red for interpolation.
@ kTSpline3_red
Uses TSpline3_red for interpolation.
@ kRespFuncTypes
This only enumerates.
std::string GetTF1(const SplineInterpolation i)
Get function for TF1_red.
std::vector< T > MakeVector(const T(&data)[N])
Template to make vector out of an array of any length.
void CleanVector(T &)
Base case: do nothing for non-vector types.
std::string SystType_ToString(const SystType i)
Convert a Syst type type to a string.
RespFuncType SplineInterpolation_ToRespFuncType(const SplineInterpolation i)
Convert a RespFuncType type to a SplineInterpolation.
SystType
@ kNorm
For normalisation parameters.
@ kSpline
For splined parameters (1D)
@ kSystTypes
This only enumerates.
@ kOsc
For oscillation parameters.
@ kFunc
For functional parameters.
Custom exception class used throughout MaCh3.
constexpr static const int _BAD_INT_
Default value used for int initialisation.
Definition: Core.h:55
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.
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.
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