![]() |
MaCh3
2.8.0
Reference Guide
|
Bin-by-bin class calculating response for spline parameters. More...
#include <Splines/BinnedSplineHandler.h>
Public Member Functions | |
| BinnedSplineHandler (ParameterHandlerGeneric *ParamHandler, MaCh3Modes *Modes_, const bool Use_GPU=true) | |
| Constructor. More... | |
| virtual | ~BinnedSplineHandler () |
| Destructor. More... | |
| void | Evaluate () final |
| CW: This Eval should be used when using two separate x,{y,a,b,c,d} arrays to store the weights; probably the best one here! Same thing but pass parameter spline segments instead of variations. More... | |
| void | AddSample (const std::string &SampleName, const std::string &SampleTitle, const std::vector< std::string > &OscChanFileNames, const std::vector< std::string > &SplineVarNames) |
| add oscillation channel to spline monolith More... | |
| void | TransferToMonolith () |
| flatten multidimensional spline array into proper monolith More... | |
| void | CleanUpMemory () |
| Remove setup variables not needed for spline evaluations. More... | |
| virtual void | FillSampleArray (const std::string &SampleTitle, const std::vector< std::string > &OscChanFileNames) |
| Loads and processes splines from ROOT files for a given sample. More... | |
| std::vector< SplineIndex > | GetEventSplines (const std::string &SampleTitle, int iOscChan, int EventMode, const std::vector< double > &VarVals) |
| Return the splines which affect a given event. More... | |
| int | CountNumberOfLoadedSplines (bool NonFlat=false, int Verbosity=0) const |
| Count how many splines we have. More... | |
| const M3::float_t * | RetPointer (const SplineIndex &Variables) const |
| get pointer to spline weight based on bin variables More... | |
| void | PrepareSplineFile (std::string FileName) final |
| KS: Prepare spline file that can be used for fast loading. More... | |
| void | LoadSplineFile (std::string FileName) final |
| KS: Load preprocessed spline file. More... | |
Public Member Functions inherited from SplineBase | |
| SplineBase (const bool Use_GPU=true) | |
| Constructor. More... | |
| virtual | ~SplineBase () |
| Destructor. More... | |
| virtual std::string | GetName () const |
| Get class name. More... | |
| short int | GetNParams () const |
| Get number of spline parameters. More... | |
| void | SynchroniseMemTransfer () const |
| KS: After calculations are done on GPU we copy memory to CPU. This operation is asynchronous meaning while memory is being copied some operations are being carried. Memory must be copied before actual reweight. This function make sure all has been copied. More... | |
Protected Types | |
| enum | TokenOrdering { kSystToken , kModeToken , kVarBinToken } |
Protected Member Functions | |
| void | CalcSplineWeights () final |
| CPU based code which eval weight for each spline. More... | |
| void | PrepForReweight () |
| Initialise flat structure. More... | |
| void | BuildSampleIndexingArray (const std::string &SampleTitle) |
| Only need 1 indexing array everything else interfaces with this to get binning properties. More... | |
| std::vector< TAxis * > | FindSplineBinning (const std::string &FileName, const std::string &SampleTitle) |
| Grab histograms with spline binning. More... | |
| void | PrintBinning (TAxis *Axis) const |
| Print spline binning. More... | |
| void | PrintSampleDetails (const std::string &SampleTitle) const |
| Print info like Sample ID of spline params etc. More... | |
| void | PrintArrayDetails (const std::string &SampleTitle) const |
| Print info like Sample ID of spline params etc. More... | |
| int | GetSampleIndex (const std::string &SampleTitle) const |
| Get index of sample based on name. More... | |
| bool | isValidSplineIndex (const std::string &SampleTitle, int iSyst, int iOscChan, int iMode, const std::vector< int > &iVar) const |
| Ensure we have spline for a given bin. More... | |
| std::vector< std::vector< int > > | StripDuplicatedModes (const std::vector< std::vector< int > > &InputVector) const |
| Creates an array to be filled with monolith indexes for each sample (allows for indexing between 7D binning and 1D Vector). More... | |
| void | GetSplineCoeff_SepMany (int splineindex, M3::float_t *&xArray, M3::float_t *&manyArray) |
| Rather work with spline coefficients in the splines, let's copy ND and use coefficient arrays. More... | |
| virtual std::vector< std::string > | GetTokensFromSplineName (const std::string &FullSplineName)=0 |
| Extract metadata tokens encoded in a spline name. allows experiment to have different formats of splines. More... | |
Protected Member Functions inherited from SplineBase | |
| void | FindSplineSegment () |
| CW:Code used in step by step reweighting, Find Spline Segment for each param. More... | |
| void | PrepareFastSplineInfoDir (std::unique_ptr< TFile > &SplineFile) const |
| KS: Prepare Fast Spline Info within SplineFile. More... | |
| void | LoadFastSplineInfoDir (std::unique_ptr< TFile > &SplineFile) |
| KS: Load preprocessed FastSplineInfo. More... | |
| void | GetTF1Coeff (TF1_red *&spl, int &nPoints, float *&coeffs) const |
| CW: Gets the polynomial coefficients for TF1. More... | |
| void | SetupSegments () |
| Since we find segment before actual reweight and sometimes we want to copy it to GPU we have different functionality depending if GPU or CPU. More... | |
Protected Attributes | |
| ParameterHandlerGeneric * | ParHandler |
| Pointer to covariance from which we get information about spline params. More... | |
| std::vector< std::string > | SampleNames |
| std::vector< std::string > | SampleTitles |
| std::vector< int > | Dimensions |
| std::vector< std::vector< std::string > > | DimensionLabels |
| std::vector< int > | nSplineParams |
| std::vector< int > | nOscChans |
| std::vector< std::vector< std::vector< TAxis * > > > | SplineBinning |
| Holds TAxis for [sample][channel][dimension]. More... | |
| std::vector< std::vector< std::string > > | SplineFileParPrefixNames |
| [Sample][Syst] More... | |
| std::vector< std::vector< std::vector< int > > > | SplineModeVecs |
| std::vector< std::vector< int > > | GlobalSystIndex |
| This holds the global spline index and is used to grab the current parameter value to evaluate splines at. Each internal vector will be of size of the number of spline systematics which affect that sample. More... | |
| std::vector< std::vector< SplineInterpolation > > | SplineInterpolationTypes |
| spline interpolation types for each sample. These vectors are from a call to GetSplineInterpolationFromSampleID() More... | |
| std::vector< std::string > | UniqueSystNames |
| name of each spline parameter More... | |
| std::vector< int > | UniqueSystIndices |
| Global index of each spline param, it allows us to match spline ordering with global. More... | |
| std::vector< SplineIndex > | IndexVect |
| Variables related to determined which modes have splines and which piggy-back of other modes. More... | |
| std::map< std::tuple< int, int, int, int, std::vector< int > >, int > | IndexVectMap |
| Map between spline origin/properties (iSample, iOscChan, iSyst, iMode, iVar1, iVar2, iVar3) and the index of the spline in IndexVect. More... | |
| std::vector< unsigned int > | nKnots_arr |
| KS: CPU Number of knots per spline. More... | |
| std::vector< TSpline3_red * > | splinevec_Monolith |
| holds each spline object before stripping into coefficient monolith More... | |
| unsigned int | MonolithIndex |
| int | CoeffIndex |
| std::vector< int > | monolith_index |
| keep track which splines are flat (-1) otherwise map with flattened splines More... | |
| M3::float_t * | xcoeff_arr |
| x coefficients for each spline More... | |
| M3::float_t * | manycoeff_arr |
| ybcd coefficients for each spline More... | |
| std::vector< M3::float_t > | cpu_spline_weights |
| Stores weight from spline evaluation for each single spline. More... | |
| std::vector< short int > | paramNo_arr |
| CW: CPU array with the number of points per spline (not per spline point!) More... | |
| MaCh3Modes * | Modes |
| pointer to MaCh3 Mode from which we get spline suffix More... | |
Protected Attributes inherited from SplineBase | |
| std::vector< FastSplineInfo > | SplineInfoArray |
| short int * | SplineSegments |
| float * | ParamValues |
| Store parameter values they are not in FastSplineInfo as in case of GPU we need to copy paste it to GPU. More... | |
| short int | nParams |
| Number of parameters that have splines. More... | |
| short int | _max_knots |
| Max knots for production. More... | |
| unsigned int | NSplines_valid |
| Number of valid splines. More... | |
| SplineMonolithGPU * | gpu_monolith |
| KS: Store info about Spline monolith, this allow to obtain better step time. As all necessary information for spline weight calculation are here meaning better cache hits. More... | |
| bool | useGPU |
| Whether to use GPU or not. More... | |
Private Member Functions | |
| void | MoveToGPU () |
| CW: The shared initialiser from constructors of TResponseFunction_red. More... | |
| void | InvestigateMissingSplines () const |
| This function will find missing splines in file. More... | |
| void | LoadSettingsDir (std::unique_ptr< TFile > &SplineFile) |
| KS: Load preprocessed Settings. More... | |
| void | LoadMonolithDir (std::unique_ptr< TFile > &SplineFile) |
| KS: Load preprocessed Monolith. More... | |
| void | LoadIndexDir (std::unique_ptr< TFile > &SplineFile) |
| KS: Load preprocessed Index. More... | |
| void | PrepareSettingsDir (std::unique_ptr< TFile > &SplineFile) const |
| KS: Prepare Settings Info within SplineFile. More... | |
| void | PrepareMonolithDir (std::unique_ptr< TFile > &SplineFile) const |
| KS: Prepare Monolith Info within SplineFile. More... | |
| void | PrepareIndexDir (std::unique_ptr< TFile > &SplineFile) const |
| KS: Prepare Index Info within SplineFile. More... | |
| void | PrepareOtherInfoDir (std::unique_ptr< TFile > &SplineFile) const |
| KS: Prepare Other Info within SplineFile. More... | |
Bin-by-bin class calculating response for spline parameters.
Definition at line 11 of file BinnedSplineHandler.h.
|
protected |
| _MaCh3_Safe_Include_Start_ _MaCh3_Safe_Include_End_ BinnedSplineHandler::BinnedSplineHandler | ( | ParameterHandlerGeneric * | ParamHandler, |
| MaCh3Modes * | Modes_, | ||
| const bool | Use_GPU = true |
||
| ) |
Constructor.
Definition at line 17 of file BinnedSplineHandler.cpp.
|
virtual |
Destructor.
Definition at line 37 of file BinnedSplineHandler.cpp.
| void BinnedSplineHandler::AddSample | ( | const std::string & | SampleName, |
| const std::string & | SampleTitle, | ||
| const std::vector< std::string > & | OscChanFileNames, | ||
| const std::vector< std::string > & | SplineVarNames | ||
| ) |
add oscillation channel to spline monolith
Definition at line 81 of file BinnedSplineHandler.cpp.
|
protected |
Only need 1 indexing array everything else interfaces with this to get binning properties.
Definition at line 340 of file BinnedSplineHandler.cpp.
|
finalprotectedvirtual |
CPU based code which eval weight for each spline.
Splines are stored using a flat monolithic structure. The monolith is organised as follows:
Once coefficient are grabbed we calculate weight using:
Implements SplineBase.
Definition at line 300 of file BinnedSplineHandler.cpp.
| void BinnedSplineHandler::CleanUpMemory | ( | ) |
Remove setup variables not needed for spline evaluations.
Definition at line 55 of file BinnedSplineHandler.cpp.
| int BinnedSplineHandler::CountNumberOfLoadedSplines | ( | bool | NonFlat = false, |
| int | Verbosity = 0 |
||
| ) | const |
Count how many splines we have.
Definition at line 485 of file BinnedSplineHandler.cpp.
|
finalvirtual |
CW: This Eval should be used when using two separate x,{y,a,b,c,d} arrays to store the weights; probably the best one here! Same thing but pass parameter spline segments instead of variations.
Implements SplineBase.
Definition at line 278 of file BinnedSplineHandler.cpp.
|
virtual |
Loads and processes splines from ROOT files for a given sample.
Definition at line 867 of file BinnedSplineHandler.cpp.
|
protected |
Grab histograms with spline binning.
Definition at line 386 of file BinnedSplineHandler.cpp.
| std::vector< SplineIndex > BinnedSplineHandler::GetEventSplines | ( | const std::string & | SampleTitle, |
| int | iOscChan, | ||
| int | EventMode, | ||
| const std::vector< double > & | VarVals | ||
| ) |
Return the splines which affect a given event.
Definition at line 740 of file BinnedSplineHandler.cpp.
|
protected |
Get index of sample based on name.
| SampleTitle | The title of the sample to search for. |
Definition at line 662 of file BinnedSplineHandler.cpp.
|
protected |
Rather work with spline coefficients in the splines, let's copy ND and use coefficient arrays.
Definition at line 626 of file BinnedSplineHandler.cpp.
|
protectedpure virtual |
Extract metadata tokens encoded in a spline name. allows experiment to have different formats of splines.
|
private |
This function will find missing splines in file.
Definition at line 135 of file BinnedSplineHandler.cpp.
|
protected |
Ensure we have spline for a given bin.
Definition at line 705 of file BinnedSplineHandler.cpp.
|
private |
KS: Load preprocessed Index.
| SplineFile | File from which we load new tree |
Definition at line 1118 of file BinnedSplineHandler.cpp.
|
private |
KS: Load preprocessed Monolith.
| SplineFile | File from which we load new tree |
Definition at line 1086 of file BinnedSplineHandler.cpp.
|
private |
KS: Load preprocessed Settings.
| SplineFile | File from which we load new tree |
Definition at line 1034 of file BinnedSplineHandler.cpp.
|
finalvirtual |
KS: Load preprocessed spline file.
| FileName | Path to ROOT file with predefined reduced Spline Monolith |
Implements SplineBase.
Definition at line 990 of file BinnedSplineHandler.cpp.
|
private |
CW: The shared initialiser from constructors of TResponseFunction_red.
Definition at line 833 of file BinnedSplineHandler.cpp.
|
private |
KS: Prepare Index Info within SplineFile.
| SplineFile | File from which we load new tree |
Definition at line 1270 of file BinnedSplineHandler.cpp.
|
private |
KS: Prepare Monolith Info within SplineFile.
| SplineFile | File from which we load new tree |
Definition at line 1243 of file BinnedSplineHandler.cpp.
|
private |
KS: Prepare Other Info within SplineFile.
| SplineFile | File from which we load new tree |
Definition at line 1287 of file BinnedSplineHandler.cpp.
|
private |
KS: Prepare Settings Info within SplineFile.
| SplineFile | File from which we load new tree |
Definition at line 1200 of file BinnedSplineHandler.cpp.
|
finalvirtual |
KS: Prepare spline file that can be used for fast loading.
Implements SplineBase.
Definition at line 1173 of file BinnedSplineHandler.cpp.
|
protected |
Initialise flat structure.
Definition at line 537 of file BinnedSplineHandler.cpp.
|
protected |
Print info like Sample ID of spline params etc.
Definition at line 685 of file BinnedSplineHandler.cpp.
|
protected |
|
protected |
Print info like Sample ID of spline params etc.
Definition at line 674 of file BinnedSplineHandler.cpp.
| const M3::float_t * BinnedSplineHandler::RetPointer | ( | const SplineIndex & | Variables | ) | const |
get pointer to spline weight based on bin variables
Definition at line 469 of file BinnedSplineHandler.cpp.
|
protected |
Creates an array to be filled with monolith indexes for each sample (allows for indexing between 7D binning and 1D Vector).
Check if there are any repeated modes. This is used to reduce the number of modes in case many interaction modes get averaged into one spline
Definition at line 797 of file BinnedSplineHandler.cpp.
| void BinnedSplineHandler::TransferToMonolith | ( | ) |
flatten multidimensional spline array into proper monolith
Definition at line 191 of file BinnedSplineHandler.cpp.
|
protected |
Definition at line 116 of file BinnedSplineHandler.h.
|
protected |
Stores weight from spline evaluation for each single spline.
Definition at line 126 of file BinnedSplineHandler.h.
|
protected |
Definition at line 81 of file BinnedSplineHandler.h.
|
protected |
Definition at line 80 of file BinnedSplineHandler.h.
|
protected |
This holds the global spline index and is used to grab the current parameter value to evaluate splines at. Each internal vector will be of size of the number of spline systematics which affect that sample.
Definition at line 95 of file BinnedSplineHandler.h.
|
protected |
Variables related to determined which modes have splines and which piggy-back of other modes.
Definition at line 106 of file BinnedSplineHandler.h.
|
protected |
Map between spline origin/properties (iSample, iOscChan, iSyst, iMode, iVar1, iVar2, iVar3) and the index of the spline in IndexVect.
Definition at line 108 of file BinnedSplineHandler.h.
|
protected |
ybcd coefficients for each spline
Definition at line 123 of file BinnedSplineHandler.h.
|
protected |
pointer to MaCh3 Mode from which we get spline suffix
Definition at line 131 of file BinnedSplineHandler.h.
|
protected |
keep track which splines are flat (-1) otherwise map with flattened splines
Definition at line 119 of file BinnedSplineHandler.h.
|
protected |
Definition at line 115 of file BinnedSplineHandler.h.
|
protected |
KS: CPU Number of knots per spline.
Definition at line 110 of file BinnedSplineHandler.h.
|
protected |
Definition at line 83 of file BinnedSplineHandler.h.
|
protected |
Definition at line 82 of file BinnedSplineHandler.h.
|
protected |
CW: CPU array with the number of points per spline (not per spline point!)
Definition at line 128 of file BinnedSplineHandler.h.
|
protected |
Pointer to covariance from which we get information about spline params.
Definition at line 75 of file BinnedSplineHandler.h.
|
protected |
Definition at line 78 of file BinnedSplineHandler.h.
|
protected |
Definition at line 79 of file BinnedSplineHandler.h.
|
protected |
Holds TAxis for [sample][channel][dimension].
Definition at line 85 of file BinnedSplineHandler.h.
|
protected |
[Sample][Syst]
Definition at line 87 of file BinnedSplineHandler.h.
|
protected |
spline interpolation types for each sample. These vectors are from a call to GetSplineInterpolationFromSampleID()
Definition at line 98 of file BinnedSplineHandler.h.
|
protected |
A vector of vectors of the spline modes that a systematic applies to This gets compared against the event mode to figure out if a syst should apply to an event or not
Definition at line 91 of file BinnedSplineHandler.h.
|
protected |
holds each spline object before stripping into coefficient monolith
Definition at line 113 of file BinnedSplineHandler.h.
|
protected |
Global index of each spline param, it allows us to match spline ordering with global.
Definition at line 103 of file BinnedSplineHandler.h.
|
protected |
name of each spline parameter
Definition at line 101 of file BinnedSplineHandler.h.
|
protected |
x coefficients for each spline
Definition at line 121 of file BinnedSplineHandler.h.