MaCh3  2.8.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 
168 };
169 
170 // **************************************************
173 inline std::string GetTF1(const SplineInterpolation i) {
174  // **************************************************
175  std::string Func = "";
176  switch(i) {
178  Func = "([1]+[0]*x)";
179  break;
186  MACH3LOG_ERROR("Interpolation type {} not supported for TF1!", static_cast<int>(i));
187  throw MaCh3Exception(__FILE__, __LINE__);
188  default:
189  MACH3LOG_ERROR("UNKNOWN SPLINE INTERPOLATION SPECIFIED!");
190  MACH3LOG_ERROR("You gave {}", static_cast<int>(i));
191  throw MaCh3Exception(__FILE__ , __LINE__ );
192  }
193  return Func;
194 }
195 
196 // **************************************************
200 // **************************************************
202  switch(i) {
209  break;
211  Type = RespFuncType::kTF1_red;
212  break;
214  MACH3LOG_ERROR("kSplineInterpolations is not a valid interpolation type!");
215  throw MaCh3Exception(__FILE__, __LINE__);
216  default:
217  MACH3LOG_ERROR("UNKNOWN SPLINE INTERPOLATION SPECIFIED!");
218  MACH3LOG_ERROR("You gave {}", static_cast<int>(i));
219  throw MaCh3Exception(__FILE__, __LINE__);
220  }
221  return Type;
222 }
223 
224 // **************************************************
227 // **************************************************
228  std::string name = "";
229  switch(i) {
230  // TSpline3 (third order spline in ROOT)
232  name = "TSpline3";
233  break;
235  name = "Linear";
236  break;
238  name = "Monotonic";
239  break;
240  // (Experimental) Akima_Spline (crd order spline which is allowed to be discontinuous in 2nd deriv)
242  name = "Akima";
243  break;
245  name = "KochanekBartels";
246  break;
248  name = "LinearFunc";
249  break;
251  MACH3LOG_ERROR("kSplineInterpolations is not a valid interpolation type!");
252  throw MaCh3Exception(__FILE__, __LINE__);
253  default:
254  MACH3LOG_ERROR("UNKNOWN SPLINE INTERPOLATION SPECIFIED!");
255  MACH3LOG_ERROR("You gave {}", static_cast<int>(i));
256  throw MaCh3Exception(__FILE__ , __LINE__ );
257  }
258  return name;
259 }
260 
263 enum SystType {
268  kSystTypes
269 };
270 
271 // *******************
274 // *******************
277 
279  std::vector<int> _fSplineModes;
280 
282  std::string _fSplineNames;
283 
288 };
289 
290 // **************************************************
292 inline std::string SystType_ToString(const SystType i) {
293 // **************************************************
294  std::string name = "";
295  switch(i) {
296  case SystType::kNorm:
297  name = "Norm";
298  break;
299  case SystType::kSpline:
300  name = "Spline";
301  break;
302  case SystType::kFunc:
303  name = "Functional";
304  break;
305  case SystType::kOsc:
306  name = "Oscillation";
307  break;
309  MACH3LOG_ERROR("kSystTypes is not a valid SystType!");
310  throw MaCh3Exception(__FILE__, __LINE__);
311  default:
312  MACH3LOG_ERROR("UNKNOWN SYST TYPE SPECIFIED!");
313  MACH3LOG_ERROR("You gave {}", static_cast<int>(i));
314  throw MaCh3Exception(__FILE__ , __LINE__ );
315  }
316  return name;
317 }
318 
319 // *******************
323 // *******************
325  std::string NuOscName;
326 };
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 are 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.
std::string NuOscName
Parameter name in NuOscillator.
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