![]() |
MaCh3
2.8.0
Reference Guide
|
Even-by-event class calculating response for spline parameters. It is possible to use GPU acceleration. More...
#include <Splines/UnbinnedSplineHandler.h>
Public Member Functions | |
| UnbinnedSplineHandler (std::vector< std::vector< TResponseFunction_red * > > &MasterSpline, const std::vector< RespFuncType > &SplineType, const bool SaveFlatTree=false, const std::string &_FastSplineName="SplineFile.root", const bool Use_GPU=true) | |
| Constructor. More... | |
| UnbinnedSplineHandler (const std::string &FileName) | |
| Constructor where you pass path to preprocessed root FileName. More... | |
| virtual | ~UnbinnedSplineHandler () |
| Destructor for UnbinnedSplineHandler class. 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... | |
| std::string | GetName () const override |
| Get class name. More... | |
| const M3::float_t * | RetPointer (const int event) const |
| KS: Get pointer to total weight to make fit faster wrooom! More... | |
| void | SetSplinePointers (std::vector< const M3::float_t * > spline_ParsPointers) |
| KS: Set pointers to spline params. 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... | |
| 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... | |
Private Member Functions | |
| void | Initialise () |
| KS: Set everything to null etc. More... | |
| void | ScanMasterSpline (std::vector< std::vector< TResponseFunction_red * > > &MasterSpline, unsigned int &nEvents, short int &MaxPoints, short int &numParams, int &nSplines, unsigned int &NSplinesValid, unsigned int &numKnots, unsigned int &nTF1Valid, unsigned int &nTF1_coeff, const std::vector< RespFuncType > &SplineType) |
| CW: Function to scan through the MasterSpline of TSpline3. More... | |
| void | PrepareForGPU (std::vector< std::vector< TResponseFunction_red * > > &MasterSpline, const std::vector< RespFuncType > &SplineType) |
| CW: Prepare the TSpline3_red objects for the GPU. More... | |
| void | MoveToGPU () |
| CW: The shared initialiser from constructors of TResponseFunction_red. More... | |
| void | PrintInitialsiation () const |
| KS: Print info about how much knots etc has been initialised. More... | |
| void | GetSplineCoeff_SepMany (TSpline3_red *&spl, int &nPoints, float *&xArray, float *&manyArray) const |
| CW: This loads up coefficients into two arrays: one x array and one yabcd array. More... | |
| void | CalcSplineWeights () final |
| CPU based code which eval weight for each spline. More... | |
| void | CalcTotalEventWeight () |
| Calc total event weight. More... | |
Private Attributes | |
| unsigned int | NEvents |
| Number of events. More... | |
| unsigned int | NTF1_valid |
| Number of valid TF1. More... | |
| unsigned int | nKnots |
| Sum of all knots over all splines. More... | |
| unsigned int | nTF1coeff |
| Sum of all coefficients over all TF1. More... | |
| float * | cpu_weights_spline_var |
| CPU arrays to hold weight for each spline. More... | |
| float * | cpu_weights_tf1_var |
| CPU arrays to hold weight for each TF1. More... | |
| M3::float_t * | cpu_total_weights |
| KS: This holds the total CPU weights that gets read in SampleHandler. More... | |
| std::vector< unsigned int > | cpu_nParamPerEvent |
| KS: CPU map keeping track how many parameters applies to each event, we keep two numbers here {number of splines per event, index where splines start for a given event}. More... | |
| std::vector< unsigned int > | cpu_nParamPerEvent_tf1 |
| KS: CPU map keeping track how many parameters applies to each event, we keep two numbers here {number of TF1 per event, index where TF1 start for a given event}. More... | |
| SplineMonoStruct * | cpu_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... | |
| std::vector< float > | cpu_coeff_TF1_many |
| CPU arrays to hold TF1 coefficients. More... | |
| std::vector< short int > | cpu_nPoints_arr |
| CPU arrays to hold number of points. More... | |
| std::vector< short int > | cpu_paramNo_TF1_arr |
| CW: CPU array with the number of points per spline (not per spline point!) More... | |
| bool | SaveSplineFile |
| Flag telling whether we are saving spline monolith into handy root file. More... | |
| std::string | FastSplineName |
| Name of Fast Spline to which will be saved. More... | |
Additional Inherited Members | |
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 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... | |
Even-by-event class calculating response for spline parameters. It is possible to use GPU acceleration.
Definition at line 8 of file UnbinnedSplineHandler.h.
| UnbinnedSplineHandler::UnbinnedSplineHandler | ( | std::vector< std::vector< TResponseFunction_red * > > & | MasterSpline, |
| const std::vector< RespFuncType > & | SplineType, | ||
| const bool | SaveFlatTree = false, |
||
| const std::string & | _FastSplineName = "SplineFile.root", |
||
| const bool | Use_GPU = true |
||
| ) |
Constructor.
| MasterSpline | Vector of TSpline3 pointers which we strip back |
| SplineType | Whether object is TSpline3 or TF1 |
| SaveFlatTree | Whether we want to save monolith into speedy flat tree |
| _FastSplineName | Name to which spline file will be saved |
Definition at line 27 of file UnbinnedSplineHandler.cpp.
| UnbinnedSplineHandler::UnbinnedSplineHandler | ( | const std::string & | FileName | ) |
Constructor where you pass path to preprocessed root FileName.
| FileName | path to pre-processed root file containing stripped monolith info |
Definition at line 424 of file UnbinnedSplineHandler.cpp.
|
virtual |
Destructor for UnbinnedSplineHandler class.
Definition at line 593 of file UnbinnedSplineHandler.cpp.
|
finalprivatevirtual |
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 695 of file UnbinnedSplineHandler.cpp.
|
private |
Calc total event weight.
Definition at line 760 of file UnbinnedSplineHandler.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 670 of file UnbinnedSplineHandler.cpp.
|
inlineoverridevirtual |
Get class name.
Reimplemented from SplineBase.
Definition at line 30 of file UnbinnedSplineHandler.h.
|
private |
CW: This loads up coefficients into two arrays: one x array and one yabcd array.
CW: This should maximize our cache hits!
| spl | pointer to TSpline3_red |
| nPoints | number of knots |
| xArray | array X value for each knot |
| manyArray | Array holding coefficients for each knot |
Definition at line 618 of file UnbinnedSplineHandler.cpp.
|
private |
KS: Set everything to null etc.
Definition at line 11 of file UnbinnedSplineHandler.cpp.
|
finalvirtual |
KS: Load preprocessed spline file.
| FileName | Path to ROOT file with predefined reduced Spline Monolith |
Implements SplineBase.
Definition at line 435 of file UnbinnedSplineHandler.cpp.
|
private |
CW: The shared initialiser from constructors of TResponseFunction_red.
Definition at line 231 of file UnbinnedSplineHandler.cpp.
|
private |
CW: Prepare the TSpline3_red objects for the GPU.
| MasterSpline | Vector of TResponseFunction_red pointers which we strip back |
Definition at line 44 of file UnbinnedSplineHandler.cpp.
|
finalvirtual |
KS: Prepare spline file that can be used for fast loading.
Implements SplineBase.
Definition at line 518 of file UnbinnedSplineHandler.cpp.
|
private |
KS: Print info about how much knots etc has been initialised.
Definition at line 802 of file UnbinnedSplineHandler.cpp.
|
inline |
KS: Get pointer to total weight to make fit faster wrooom!
| event | Name event number in used MC |
Definition at line 35 of file UnbinnedSplineHandler.h.
|
private |
CW: Function to scan through the MasterSpline of TSpline3.
| MasterSpline | Vector of TSpline3_red pointers which we strip back |
| NEvents | Number of MC events |
| MaxPoints | Maximal number of knots per splines |
| numParams | Total number of parameters |
| numKnots | Total number of knots, which is sum of individual knots per each spline |
| nTF1_coeff | Number of TF1 coefficients in all TF1 objects |
| SplineType | Whether object is TSpline3 or TF1 |
| NSplinesValid | Total number of valid (not null) TSpline3 |
| nTF1Valid | Total number of valid (not null) TF1 |
Definition at line 299 of file UnbinnedSplineHandler.cpp.
|
inline |
KS: Set pointers to spline params.
| spline_ParsPointers | Vector of pointers to spline params |
Definition at line 39 of file UnbinnedSplineHandler.h.
|
private |
CPU arrays to hold TF1 coefficients.
Definition at line 120 of file UnbinnedSplineHandler.h.
|
private |
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.
Definition at line 117 of file UnbinnedSplineHandler.h.
|
private |
KS: CPU map keeping track how many parameters applies to each event, we keep two numbers here {number of splines per event, index where splines start for a given event}.
Definition at line 111 of file UnbinnedSplineHandler.h.
|
private |
KS: CPU map keeping track how many parameters applies to each event, we keep two numbers here {number of TF1 per event, index where TF1 start for a given event}.
Definition at line 114 of file UnbinnedSplineHandler.h.
|
private |
CPU arrays to hold number of points.
Definition at line 123 of file UnbinnedSplineHandler.h.
|
private |
CW: CPU array with the number of points per spline (not per spline point!)
Definition at line 126 of file UnbinnedSplineHandler.h.
|
private |
KS: This holds the total CPU weights that gets read in SampleHandler.
Definition at line 108 of file UnbinnedSplineHandler.h.
|
private |
CPU arrays to hold weight for each spline.
Definition at line 104 of file UnbinnedSplineHandler.h.
|
private |
CPU arrays to hold weight for each TF1.
Definition at line 106 of file UnbinnedSplineHandler.h.
|
private |
Name of Fast Spline to which will be saved.
Definition at line 132 of file UnbinnedSplineHandler.h.
|
private |
Number of events.
Definition at line 93 of file UnbinnedSplineHandler.h.
|
private |
Sum of all knots over all splines.
Definition at line 99 of file UnbinnedSplineHandler.h.
|
private |
Number of valid TF1.
Definition at line 96 of file UnbinnedSplineHandler.h.
|
private |
Sum of all coefficients over all TF1.
Definition at line 101 of file UnbinnedSplineHandler.h.
|
private |
Flag telling whether we are saving spline monolith into handy root file.
Definition at line 129 of file UnbinnedSplineHandler.h.