MaCh3  2.2.3
Reference Guide
Classes | Namespaces | Enumerations | Functions
SampleStructs.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 "Constants/OscillatorConstants.h"
Include dependency graph for SampleStructs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  KinematicCut
 KS: Small struct used for applying kinematic cuts. More...
 
struct  BinShiftLookup
 KS: Store bin lookups allowing to quickly find bin after migration. More...
 
struct  SampleBinningInfo
 KS: Small struct storying info about used binning. More...
 

Namespaces

 MaCh3Utils
 

Enumerations

enum  TargetMat {
  kTarget_H = 1 , kTarget_C = 12 , kTarget_N = 14 , kTarget_O = 16 ,
  kTarget_Al = 27 , kTarget_Ar = 40 , kTarget_Ti = 48 , kTarget_Fe = 56 ,
  kTarget_Pb = 207
}
 Enum to track the target material. More...
 
enum  NuPDG {
  kNue = 12 , kNumu = 14 , kNutau = 16 , kNueBar = -12 ,
  kNumuBar = -14 , kNutauBar = -16
}
 Enum to track the incoming neutrino species. More...
 
enum  TestStatistic {
  kPoisson , kBarlowBeeston , kIceCube , kPearson ,
  kDembinskiAbdelmotteleb , kNTestStatistics
}
 Make an enum of the test statistic that we're using. More...
 

Functions

constexpr unsigned int str2int (const char *str, const int h=0)
 KS: This is mad way of converting string to int. Why? To be able to use string with switch. More...
 
std::string TargetMat_ToString (const TargetMat i)
 Converted the Target Mat to a string. More...
 
std::string TestStatistic_ToString (const TestStatistic TestStat)
 Convert a LLH type to a string. More...
 
int GetSampleFromGlobalBin (const std::vector< SampleBinningInfo > &BinningInfo, const size_t GlobalBin)
 Get the sample index corresponding to a global bin number. More...
 
void SetGlobalBinNumbers (std::vector< SampleBinningInfo > &BinningInfo)
 Sets the GlobalOffset for each SampleBinningInfo to enable linearization of multiple 2D binning samples. More...
 
double MaCh3Utils::GetMassFromPDG (const int PDG)
 Return mass for given PDG. More...
 
int MaCh3Utils::PDGToNuOscillatorFlavour (const int NuPdg)
 Convert from PDG flavour to NuOscillator type beware that in the case of anti-neutrinos the NuOscillator type simply gets multiplied by -1. More...
 
std::string MaCh3Utils::FormatDouble (const double value, const int precision)
 Convert double into string for precision, useful for playing with yaml if you don't want to have in config floating point precision... More...
 

Detailed Description

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

Definition in file SampleStructs.h.

Enumeration Type Documentation

◆ NuPDG

enum NuPDG

Enum to track the incoming neutrino species.

Enumerator
kNue 
kNumu 
kNutau 
kNueBar 
kNumuBar 
kNutauBar 

Definition at line 101 of file SampleStructs.h.

101  {
102 // *****************
103  kNue = 12,
104  kNumu = 14,
105  kNutau = 16,
106  kNueBar = -12,
107  kNumuBar = -14,
108  kNutauBar = -16
109 };
@ kNutauBar
@ kNutau
@ kNumuBar
@ kNueBar
@ kNue
@ kNumu

◆ TargetMat

enum TargetMat

Enum to track the target material.

Enumerator
kTarget_H 

Hydrogen (Atomic number 1)

kTarget_C 

Carbon 12 (Atomic number 6)

kTarget_N 

Nitrogen (Atomic number 7)

kTarget_O 

Oxygen 16 (Atomic number 8)

kTarget_Al 

Aluminum (Atomic number 13)

kTarget_Ar 

Argon (Atomic number 18)

kTarget_Ti 

Titanium (Atomic number 22)

kTarget_Fe 

Iron (Atomic number 26)

kTarget_Pb 

Lead (Atomic number 82)

Definition at line 44 of file SampleStructs.h.

44  {
45 // *****************
46  kTarget_H = 1,
47  kTarget_C = 12,
48  kTarget_N = 14,
49  kTarget_O = 16,
50  kTarget_Al = 27,
51  kTarget_Ar = 40,
52  kTarget_Ti = 48,
53  kTarget_Fe = 56,
54  kTarget_Pb = 207
55 };
@ kTarget_Fe
Iron (Atomic number 26)
Definition: SampleStructs.h:53
@ kTarget_C
Carbon 12 (Atomic number 6)
Definition: SampleStructs.h:47
@ kTarget_Al
Aluminum (Atomic number 13)
Definition: SampleStructs.h:50
@ kTarget_H
Hydrogen (Atomic number 1)
Definition: SampleStructs.h:46
@ kTarget_Ti
Titanium (Atomic number 22)
Definition: SampleStructs.h:52
@ kTarget_Ar
Argon (Atomic number 18)
Definition: SampleStructs.h:51
@ kTarget_N
Nitrogen (Atomic number 7)
Definition: SampleStructs.h:48
@ kTarget_Pb
Lead (Atomic number 82)
Definition: SampleStructs.h:54
@ kTarget_O
Oxygen 16 (Atomic number 8)
Definition: SampleStructs.h:49

◆ TestStatistic

Make an enum of the test statistic that we're using.

Enumerator
kPoisson 

Standard Poisson likelihood [2].

kBarlowBeeston 

Barlow-Beeston ([3]) following Conway approximation ([5])

kIceCube 

Based on [1].

kPearson 

Standard Pearson likelihood [24].

kDembinskiAbdelmotteleb 

Based on [6].

kNTestStatistics 

Number of test statistics.

Definition at line 112 of file SampleStructs.h.

112  {
113  kPoisson,
115  kIceCube,
116  kPearson,
119 };
@ kNTestStatistics
Number of test statistics.
@ kPearson
Standard Pearson likelihood .
@ kBarlowBeeston
Barlow-Beeston () following Conway approximation ()
@ kIceCube
Based on .
@ kDembinskiAbdelmotteleb
Based on .
@ kPoisson
Standard Poisson likelihood .

Function Documentation

◆ GetSampleFromGlobalBin()

int GetSampleFromGlobalBin ( const std::vector< SampleBinningInfo > &  BinningInfo,
const size_t  GlobalBin 
)
inline

Get the sample index corresponding to a global bin number.

Parameters
BinningInfoVector of SampleBinningInfo structs.
GlobalBinThe global bin number.
Returns
The index of the sample, or garbage if not found.

Definition at line 304 of file SampleStructs.h.

304  {
305  for (size_t iSample = 0; iSample < BinningInfo.size(); ++iSample) {
306  const SampleBinningInfo& info = BinningInfo[iSample];
307  if (GlobalBin >= info.GlobalOffset && GlobalBin < info.GlobalOffset + info.nBins) {
308  return static_cast<int>(iSample);
309  }
310  }
311 
312  MACH3LOG_ERROR("Couldn't find sample corresponding to bin {}", GlobalBin);
313  throw MaCh3Exception(__FILE__, __LINE__);
314 
315  // GlobalBin is out of range for all samples
316  return M3::_BAD_INT_;
317 }
#define MACH3LOG_ERROR
Definition: MaCh3Logger.h:27
Custom exception class for MaCh3 errors.
constexpr static const int _BAD_INT_
Default value used for int initialisation.
Definition: Core.h:48
KS: Small struct storying info about used binning.
size_t GlobalOffset
If you have binning for multiple samples and trying to define 1D vector let's.
size_t nBins
Number of total bins.

◆ SetGlobalBinNumbers()

void SetGlobalBinNumbers ( std::vector< SampleBinningInfo > &  BinningInfo)
inline

Sets the GlobalOffset for each SampleBinningInfo to enable linearization of multiple 2D binning samples.

Parameters
BinningInfoVector of SampleBinningInfo structs to be updated with global offsets.

Definition at line 321 of file SampleStructs.h.

321  {
322  if (BinningInfo.empty()) {
323  MACH3LOG_ERROR("No binning samples provided.");
324  throw MaCh3Exception(__FILE__, __LINE__);
325  }
326 
327  size_t GlobalOffsetCounter = 0;
328  for(size_t iSample = 0; iSample < BinningInfo.size(); iSample++){
329  BinningInfo[iSample].GlobalOffset = GlobalOffsetCounter;
330  GlobalOffsetCounter += BinningInfo[iSample].nBins;
331  }
332 }

◆ str2int()

constexpr unsigned int str2int ( const char *  str,
const int  h = 0 
)
constexpr

KS: This is mad way of converting string to int. Why? To be able to use string with switch.

Definition at line 36 of file SampleStructs.h.

36  {
37 // *******************
38  return !str[h] ? 5381 : (str2int(str, h+1) * 33) ^ str[h];
39 }
constexpr unsigned int str2int(const char *str, const int h=0)
KS: This is mad way of converting string to int. Why? To be able to use string with switch.
Definition: SampleStructs.h:36

◆ TargetMat_ToString()

std::string TargetMat_ToString ( const TargetMat  i)
inline

Converted the Target Mat to a string.

Definition at line 59 of file SampleStructs.h.

59  {
60 // *****************
61  std::string name;
62 
63  switch(i) {
64  case kTarget_H:
65  name = "Hydrogen";
66  break;
67  case kTarget_C:
68  name = "Carbon";
69  break;
70  case kTarget_N:
71  name = "Nitrogen";
72  break;
73  case kTarget_O:
74  name = "Oxygen";
75  break;
76  case kTarget_Al:
77  name = "Aluminium";
78  break;
79  case kTarget_Ar:
80  name = "Argon";
81  break;
82  case kTarget_Ti:
83  name = "Titanium";
84  break;
85  case kTarget_Fe:
86  name = "Iron";
87  break;
88  case kTarget_Pb:
89  name = "Lead";
90  break;
91  default:
92  name = "TargetMat_Undefined";
93  break;
94  }
95 
96  return name;
97 }

◆ TestStatistic_ToString()

std::string TestStatistic_ToString ( const TestStatistic  TestStat)
inline

Convert a LLH type to a string.

Definition at line 123 of file SampleStructs.h.

123  {
124 // **************************************************
125  std::string name = "";
126 
127  switch(TestStat) {
129  name = "Poisson";
130  break;
132  name = "Barlow-Beeston";
133  break;
135  name = "IceCube";
136  break;
138  name = "Pearson";
139  break;
141  name = "Dembinski-Abdelmotteleb";
142  break;
144  MACH3LOG_ERROR("kNTestStatistics is not a valid TestStatistic!");
145  throw MaCh3Exception(__FILE__, __LINE__);
146  default:
147  MACH3LOG_ERROR("UNKNOWN LIKELIHOOD SPECIFIED!");
148  MACH3LOG_ERROR("You gave test-statistic {}", static_cast<int>(TestStat));
149  throw MaCh3Exception(__FILE__ , __LINE__ );
150  }
151  return name;
152 }