NuOscillator
Loading...
Searching...
No Matches
OscProbCalcerBase.h
Go to the documentation of this file.
1#ifndef __OSCPROBCALCER_BASE_H__
2#define __OSCPROBCALCER_BASE_H__
3
5
6#include <vector>
7#include <string>
8
9#include "yaml-cpp/yaml.h"
10
19 public:
20 // ========================================================================================================================================================================
21 // Public functions which are calculation implementation agnostic
22
26 virtual ~OscProbCalcerBase();
27
33 void SetEnergyArray(std::vector<FLOAT_T> EnergyArray);
34
40 void SetCosineZArray(std::vector<FLOAT_T> CosineZArray);
41
55 const FLOAT_T* ReturnPointerToWeight(int InitNuFlav, int FinalNuFlav, FLOAT_T Energy, FLOAT_T CosineZ=DUMMYVAL);
56
63 void Reweight();
64
71 void DefineParameter(const std::string& ParName, FLOAT_T* ParValue);
72
78 void Reweight(const std::vector<FLOAT_T>& OscParams_);
79
86 void Setup();
87
94 bool SanityCheck();
95
99 void PrintWeights();
100
105
114 bool HasOscillationChannel(int GeneratedFlavour, int DetectedFlavour);
115
121
126 std::vector<NuOscillator::OscillationChannel> ReturnOscChannels() {return fOscillationChannels;}
127
132 std::vector<int> ReturnNeutrinoTypes() {return fNeutrinoTypes;}
133
138 std::vector<FLOAT_T> ReturnOscParamsCurr() {return fOscParamsCurr;}
139
145
151
156 std::vector<FLOAT_T> ReturnEnergyArray() {return fEnergyArray;}
157
162 std::vector<FLOAT_T> ReturnCosineZArray() {return fCosineZArray;}
163
169
175
180 int ReturnNWeights() {return fNWeights;}
181
186 std::vector<FLOAT_T> ReturnWeightArray() {return fWeightArray;}
187
195 std::vector<NuOscillator::OscillationProbability> ReturnProbabilities();
196
202
208
217 int ReturnNuTypeFromFlavour(int NuFlav);
218
224 void PrintOscParamsCurr();
225
226
227 // ========================================================================================================================================================================
228 // Public virtual functions which need calculater specific implementations
229
230 protected:
231
239 OscProbCalcerBase(YAML::Node InputConfig_);
240
248 OscProbCalcerBase(std::string ConfigName_) : OscProbCalcerBase(YAML::LoadFile(ConfigName_)) {}
249
250 // ========================================================================================================================================================================
251 // Protected functions which are calculation implementation agnostic
252
261 void IgnoreCosineZBinning(bool Ignore);
262
272 bool AreOscParamsChanged();
273
279 void SetCurrOscParams();
280
284 void ResetCurrOscParams();
285
291 void InitialiseNeutrinoTypesArray(int Size);
292
297
304
309
314
323 int ReturnCosineZIndexFromValue(FLOAT_T CosineZVal);
324
333 int ReturnEnergyIndexFromValue(FLOAT_T EnergyVal);
334
343 int ReturnOscChannelIndexFromFlavours(int InitNuFlav, int FinalNuFlav);
344
350 void SetExpectedParameterNames(const std::vector<std::string>& ExpectedOscParNames_) {
351 fExpectedOscillationParameterNames = ExpectedOscParNames_;
353 fOscParams = std::vector<FLOAT_T*>(fNOscParams,new FLOAT_T(0));
354 fOscillationParametersSetCheck = std::vector<bool>(fNOscParams,false);
355 }
356
361 if (fNOscParams == 0) {
362 std::cerr << "No oscillation parameter names to print" << std::endl;
363 return;
364 }
365
366 std::cout << "Expected Parameters:" << std::endl;
367 for (size_t iPar=0;iPar<fNOscParams;iPar++) {
368 std::cout << "\t" << iPar << " : " << fExpectedOscillationParameterNames[iPar] << std::endl;
369 }
370 }
371
378
383
384 // ========================================================================================================================================================================
385 // Protected virtual functions which are calculation implementation agnostic
386
395 virtual void CalculateProbabilities() = 0;
396
402 virtual void SetupPropagator() = 0;
403
417 virtual int ReturnWeightArrayIndex(int NuTypeIndex, int OscChanIndex, int EnergyIndex, int CosineZIndex=-1) = 0;
418
426 virtual long DefineWeightArraySize() = 0;
427
428 // ========================================================================================================================================================================
429 // Basic variables required for oscillation probability calculation
430
431 // Enums to define the mappings below. Each implementation is expected to define a mapping of which initial and neutrino flavours are considered, along with whether
432 // neutrinos and antineutrinos are considered
433
438
442 std::vector<int> fNeutrinoTypes;
443
448
452 std::vector<NuOscillator::OscillationChannel> fOscillationChannels;
453
458
463
467 std::vector<FLOAT_T> fEnergyArray;
468
472 std::vector<FLOAT_T> fCosineZArray;
473
478
482 std::vector<FLOAT_T> fWeightArray;
483
488
493
498
502 YAML::Node Config;
503
504 private:
505 // ========================================================================================================================================================================
506 // Sanity check variables
511
516
521
526
531
536
541
545 std::vector<FLOAT_T> fOscParamsCurr;
546
550 std::vector<FLOAT_T*> fOscParams;
551
555 std::vector<std::string> fExpectedOscillationParameterNames;
556
561
566
571
576};
577
578#endif
float FLOAT_T
Definition OscillatorConstants.h:16
#define DUMMYVAL
Definition OscillatorConstants.h:4
Oscillation calculation engine (CUDAProb3, ProbGPU, Prob3++, etc.) implementation agnostic base class...
Definition OscProbCalcerBase.h:18
int fNOscillationChannels
The number of oscillation channels which have been configured.
Definition OscProbCalcerBase.h:447
void PrintKnownOscillationChannels()
Print the oscillation channels which a particular instance has been configured with.
Definition OscProbCalcerBase.cpp:706
int fNEnergyPoints
The number of Energy points which are being evaluated by the oscillation probability engine.
Definition OscProbCalcerBase.h:457
int ReturnNOscParams()
Return the number of oscillation parameters the specific implementation expects.
Definition OscProbCalcerBase.h:120
virtual int ReturnWeightArrayIndex(int NuTypeIndex, int OscChanIndex, int EnergyIndex, int CosineZIndex=-1)=0
Return the index in the weight array for a specific combination of neutrino oscillation channel,...
int fNOscParams
Store the oscillation parameter set used to calculate the previous and current probabilities.
Definition OscProbCalcerBase.h:540
std::vector< bool > fOscillationParametersSetCheck
Check to determine which of the expected oscillation parameters have been registered.
Definition OscProbCalcerBase.h:560
YAML::Node Config
YAML Config object used to get runtime specific variables.
Definition OscProbCalcerBase.h:502
void SetEnergyArray(std::vector< FLOAT_T > EnergyArray)
Define the Energy which will be used when calculating the oscillation probabilities.
Definition OscProbCalcerBase.cpp:101
bool fWeightArrayInit
Boolean declaring whether fWeightArray has been initialised correctly.
Definition OscProbCalcerBase.h:525
bool fNuMappingSet
Boolean declaring whether fNeutrinoTypes and fOscillationChannels have been initialised correctly.
Definition OscProbCalcerBase.h:530
int ReturnEnergyIndexFromValue(FLOAT_T EnergyVal)
Return the index in fEnergyArray for a particular value of Energy. If it's not found,...
Definition OscProbCalcerBase.cpp:533
int ReturnNuTypeFromFlavour(int NuFlav)
Return the index in fNeutrinoTypes for a particular neutrino flavour (neutrino or antineutrino)
Definition OscProbCalcerBase.cpp:598
bool fPropagatorSet
Boolean declaring whether the specific propagator SetupPropagator() function has been called.
Definition OscProbCalcerBase.h:520
void IgnoreCosineZBinning(bool Ignore)
Some implementations don't care about the CosineZ values, so this is a method to set fCosineZArraySet...
Definition OscProbCalcerBase.cpp:181
int fNNeutrinoTypes
The number of neutrino types (neutrino and antineutrino)
Definition OscProbCalcerBase.h:437
int ReturnCosineZIndexFromValue(FLOAT_T CosineZVal)
Return the index in fCosineZArray for a particular value of CosineZ. If it's not found,...
Definition OscProbCalcerBase.cpp:562
std::vector< NuOscillator::OscillationChannel > ReturnOscChannels()
Return the oscillation channels the specific implementation expects.
Definition OscProbCalcerBase.h:126
std::string fImplementationName
Define the implementation name - Can be used for recasting later (similar to TObject::InheritsFrom() ...
Definition OscProbCalcerBase.h:492
OscProbCalcerBase(YAML::Node InputConfig_)
Default constructor.
Definition OscProbCalcerBase.cpp:9
void SanitiseProbabilities()
Ensure that the oscillation probabilities are within [0.,1.] range, if not throw error.
Definition OscProbCalcerBase.cpp:438
std::vector< FLOAT_T * > fOscParams
Vector of pointers to oscillation parameter values.
Definition OscProbCalcerBase.h:550
std::string ReturnImplementationName()
Return the specific implementation name.
Definition OscProbCalcerBase.h:168
bool ReturnCosineZIgnored()
Return a boolean which describes whether the specific implementation cares about CosineZ.
Definition OscProbCalcerBase.h:174
void SetCurrOscParams()
Save the oscillation parameters which have been requested.
Definition OscProbCalcerBase.cpp:501
bool fCosineZIgnored
Flag to define whether the CosineZ binning has been ignored in the specific implementation.
Definition OscProbCalcerBase.h:497
std::vector< FLOAT_T > fEnergyArray
The vector of Energy values being evaluated by the oscillation probability engine.
Definition OscProbCalcerBase.h:467
void PrintWeights()
Print the calculated oscillation probabilities.
Definition OscProbCalcerBase.cpp:508
virtual void CalculateProbabilities()=0
Calculate some oscillation probabilities for a particular oscillation parameter set.
void SetExpectedParameterNames(const std::vector< std::string > &ExpectedOscParNames_)
Define the list of parameter names that a particular instance of OscProbCalcer expects.
Definition OscProbCalcerBase.h:350
std::vector< FLOAT_T > ReturnOscParamsCurr()
Return the oscillation parameters which were used for the last calculation.
Definition OscProbCalcerBase.h:138
bool fUseLegacyMode_OscParsSet
Check to determine in Reweight(std::vector<FLOAT_T> OscParams) has been called.
Definition OscProbCalcerBase.h:570
std::vector< FLOAT_T > fWeightArray
Vector which stores the oscillation probabilities.
Definition OscProbCalcerBase.h:482
virtual long DefineWeightArraySize()=0
Define the size of fWeightArray.
int fNWeights
The number of oscillation probabilities being calculated.
Definition OscProbCalcerBase.h:477
void Reweight()
General function used to call the oscillation probability calculation.
Definition OscProbCalcerBase.cpp:327
bool ReturnHasSetEnergyArray()
Return whether the instance of OscProbCalcerBase() has already been assigned the Energy binning.
Definition OscProbCalcerBase.h:201
bool AreOscParamsChanged()
Check whether the oscillation parameters have changed since their previous value.
Definition OscProbCalcerBase.cpp:486
int fNCosineZPoints
The number of CosineZ points which are being evaluated by the oscillation probability engine.
Definition OscProbCalcerBase.h:462
void InitialiseNeutrinoTypesArray(int Size)
Initialise the fNeutrinoTypes mapping array to a particular size with dummy values.
Definition OscProbCalcerBase.cpp:628
std::vector< NuOscillator::OscillationChannel > fOscillationChannels
The mapping of oscillation channels which have been requested from the YAML config.
Definition OscProbCalcerBase.h:452
bool HasOscillationChannel(int GeneratedFlavour, int DetectedFlavour)
Check whether a particular oscillation channel has been configured in a particular instance of OscPro...
Definition OscProbCalcerBase.cpp:713
std::vector< FLOAT_T > ReturnWeightArray()
Return the vector of oscillation probabilites which have been calculated.
Definition OscProbCalcerBase.h:186
const FLOAT_T * ReturnPointerToWeight(int InitNuFlav, int FinalNuFlav, FLOAT_T Energy, FLOAT_T CosineZ=DUMMYVAL)
Return pointer to the weight array for a specific Energy and CosineZ.
Definition OscProbCalcerBase.cpp:218
bool fNoSanity
Boolean declaring whether the SanitiseProbabilities function should be called in the Reweight functio...
Definition OscProbCalcerBase.h:575
int ReturnOscChannelIndexFromFlavours(int InitNuFlav, int FinalNuFlav)
Loop through fOscillationChannels and determine which index corresponds to the requested flavours.
Definition OscProbCalcerBase.cpp:586
int ReturnNCosineZPoints()
Return the number of CosineZ points which are being used by the specific instance of OscProbCalcerBas...
Definition OscProbCalcerBase.h:150
void PrintOscParamsCurr()
Print current oscillation parameters.
Definition OscProbCalcerBase.cpp:430
void IntialiseWeightArray()
Initialise the array in which the oscillation probabilities will be stored with dummy values.
Definition OscProbCalcerBase.cpp:614
int ReturnNEnergyPoints()
Return the number of Energy points which are being used by the specific instance of OscProbCalcerBase...
Definition OscProbCalcerBase.h:144
void PrintExpectedParameterNames()
Print the expected parameter names.
Definition OscProbCalcerBase.h:360
void ResetCurrOscParams()
(Re-)Initialise the saved oscillation parameters in fOscParamsCurr
Definition OscProbCalcerBase.cpp:497
void InitialiseOscillationChannelMapping()
Read the [OscProbCalcerSetup][Implementation][OscChannelMapping] YAML node and configure fOscillation...
Definition OscProbCalcerBase.cpp:637
OscProbCalcerBase(std::string ConfigName_)
Wrapper Construct.
Definition OscProbCalcerBase.h:248
std::vector< FLOAT_T > fOscParamsCurr
Vector which stores the saved oscillation probabilities.
Definition OscProbCalcerBase.h:545
void CheckOscillationParametersDefined()
Check that all the expected oscillation parameters have been assigned a value.
Definition OscProbCalcerBase.cpp:374
void SetCosineZArray(std::vector< FLOAT_T > CosineZArray)
Define the CosineZ which will be used when calculating the oscillation probabilities.
Definition OscProbCalcerBase.cpp:141
std::vector< FLOAT_T > ReturnCosineZArray()
Return the vector of CosineZ points which are being used by the specific instance of OscProbCalcerBas...
Definition OscProbCalcerBase.h:162
void CheckNuFlavourMapping()
Check that the NuType/NuFlav mapping is set correctly based on the inputs from the particular impleme...
Definition OscProbCalcerBase.cpp:647
void Setup()
General function used to setup all variables used within the reweighting.
Definition OscProbCalcerBase.cpp:189
std::vector< FLOAT_T > ReturnEnergyArray()
Return the vector of Energy points which are being used by the specific instance of OscProbCalcerBase...
Definition OscProbCalcerBase.h:156
FLOAT_T PrecisionLimit
Precision limit which allows a slight unphysical probability to pass the SanitiseProbabilities check.
Definition OscProbCalcerBase.h:535
virtual void SetupPropagator()=0
Setup any implementation specific variables/functions.
bool fUseLegacyMode
Check to determine if LegacyMode has been requested.
Definition OscProbCalcerBase.h:565
std::vector< int > fNeutrinoTypes
The mapping of neutrino types to uniquely defined integers (i.e. index)
Definition OscProbCalcerBase.h:442
bool SanityCheck()
Ensures that the specific implementation has been correctly initialised.
Definition OscProbCalcerBase.cpp:688
std::vector< std::string > fExpectedOscillationParameterNames
Vector of expected oscillation parameter names.
Definition OscProbCalcerBase.h:555
virtual ~OscProbCalcerBase()
Destructor.
Definition OscProbCalcerBase.cpp:98
bool ReturnHasSetCosineZArray()
Return whether the instance of OscProbCalcerBase() has already been assigned the CosineZ binning.
Definition OscProbCalcerBase.h:207
std::vector< int > ReturnNeutrinoTypes()
Return the neutrino types the specific implementation expects.
Definition OscProbCalcerBase.h:132
void DefineParameter(const std::string &ParName, FLOAT_T *ParValue)
Function to register an oscillation parameter name and pointer to a value that will be used when calc...
Definition OscProbCalcerBase.cpp:387
int ReturnNWeights()
Return the number of oscillation probabilities that are being calculated.
Definition OscProbCalcerBase.h:180
bool fEnergyArraySet
Boolean declaring whether the Energy array has been set.
Definition OscProbCalcerBase.h:510
std::vector< NuOscillator::OscillationProbability > ReturnProbabilities()
Return vector of oscillation probabilities with associated neutrin type, oscillation channel,...
Definition OscProbCalcerBase.cpp:257
FLOAT_T GetOscillationParameter(int Index)
Return the value of the oscillation parameter associated with the index.
Definition OscProbCalcerBase.cpp:414
std::vector< FLOAT_T > fCosineZArray
The vector of CosineZ values being evaluated by the oscillation probability engine.
Definition OscProbCalcerBase.h:472
int fVerbose
Define the verbosity of the console output.
Definition OscProbCalcerBase.h:487
bool fCosineZArraySet
Boolean declaring whether the CosineZ array has been set.
Definition OscProbCalcerBase.h:515