MaCh3  2.8.0
Reference Guide
Public Member Functions | List of all members
PySplineBase Class Reference

EW: As SplineBase is an abstract base class we have to do some gymnastics to get it to get it into python. More...

#include <python/splines.h>

Inheritance diagram for PySplineBase:
[legend]
Collaboration diagram for PySplineBase:
[legend]

Public Member Functions

void Evaluate () override
 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...
 
void FindSplineSegment ()
 
void CalcSplineWeights () override
 CPU based code which eval weight for each spline. More...
 
 SplineBase (const bool Use_GPU=true)
 Constructor. 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...
 
virtual void PrepareSplineFile (std::string FileName)=0
 KS: Prepare spline file that can be used for fast loading. More...
 
virtual void LoadSplineFile (std::string FileName)=0
 KS: Load preprocessed spline file. 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...
 

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...
 

Detailed Description

EW: As SplineBase is an abstract base class we have to do some gymnastics to get it to get it into python.

Definition at line 24 of file splines.h.

Member Function Documentation

◆ CalcSplineWeights()

void PySplineBase::CalcSplineWeights ( )
inlineoverridevirtual

CPU based code which eval weight for each spline.

Splines are stored using a flat monolithic structure. The monolith is organised as follows:

Spline 0
Segment 0: [ Y | B | C | D ]
Segment 1: [ Y | B | C | D ]
Segment 2: [ Y | B | C | D ]
Spline 1
Segment 0: [ Y | B | C | D ]
Segment 1: [ Y | B | C | D ]
Segment 2: [ Y | B | C | D ]
Spline 2
Segment 0: [ Y | B | C | D ]
Segment 1: [ Y | B | C | D ]
Segment 2: [ Y | B | C | D ]
...

Once coefficient are grabbed we calculate weight using:

weight = Y + B*dx + C*dx^2 + D*dx^3;

Implements SplineBase.

Definition at line 57 of file splines.h.

57  {
58  PYBIND11_OVERRIDE_PURE_NAME(
59  void, /* Return type */
60  SplineBase, /* Parent class */
61  "calculate_weights", /* Name in python*/
62  CalcSplineWeights /* Name of function in C++ (must match Python name) */
63  );
64  }
void CalcSplineWeights() override
CPU based code which eval weight for each spline.
Definition: splines.h:57
Base class for calculating weight from spline.
Definition: SplineBase.h:30

◆ Evaluate()

void PySplineBase::Evaluate ( )
inlineoverridevirtual

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 30 of file splines.h.

30  {
31  PYBIND11_OVERRIDE_PURE_NAME(
32  void, /* Return type */
33  SplineBase, /* Parent class */
34  "evaluate", /* Name in python*/
35  Evaluate /* Name of function in C++ (must match Python name) */
36  );
37  }
void Evaluate() override
CW: This Eval should be used when using two separate x,{y,a,b,c,d} arrays to store the weights; proba...
Definition: splines.h:30

◆ FindSplineSegment()

void PySplineBase::FindSplineSegment ( )
inline

Definition at line 48 of file splines.h.

48  {
49  PYBIND11_OVERRIDE_PURE_NAME(
50  void, /* Return type */
51  SplineBase, /* Parent class */
52  "find_segment", /* Name in python*/
53  FindSplineSegment /* Name of function in C++ (must match Python name) */
54  );
55  }
void FindSplineSegment()
Definition: splines.h:48

◆ GetName()

std::string PySplineBase::GetName ( ) const
inlineoverridevirtual

Get class name.

Reimplemented from SplineBase.

Definition at line 39 of file splines.h.

39  {
40  PYBIND11_OVERRIDE_NAME(
41  std::string, /* Return type */
42  SplineBase, /* Parent class */
43  "get_name", /* Name in python*/
44  GetName /* Name of function in C++ (must match Python name) */
45  );
46  }
std::string GetName() const override
Get class name.
Definition: splines.h:39

◆ SplineBase()

SplineBase::SplineBase

Constructor.

Definition at line 33 of file SplineBase.cpp.

11  {
12 // *****************************************
13  #ifdef MaCh3_CUDA
14  useGPU = Use_GPU;
15  if(useGPU) MACH3LOG_INFO("Using GPU version of {}", GetName());
16  gpu_monolith = nullptr;
17  #else
18  // if we don't have GPU simply
19  useGPU = false;
20  #endif
21 
22  NSplines_valid = 0;
23  nParams = 0;
24  _max_knots = 0;
25  SplineSegments = nullptr;
26  ParamValues = nullptr;
27 }
#define MACH3LOG_INFO
Definition: MaCh3Logger.h:35
SplineMonolithGPU * gpu_monolith
KS: Store info about Spline monolith, this allow to obtain better step time. As all necessary informa...
Definition: SplineBase.h:120
unsigned int NSplines_valid
Number of valid splines.
Definition: SplineBase.h:117
short int nParams
Number of parameters that have splines.
Definition: SplineBase.h:113
short int _max_knots
Max knots for production.
Definition: SplineBase.h:115
short int * SplineSegments
Definition: SplineBase.h:109
float * ParamValues
Store parameter values they are not in FastSplineInfo as in case of GPU we need to copy paste it to G...
Definition: SplineBase.h:111
bool useGPU
Whether to use GPU or not.
Definition: SplineBase.h:123

The documentation for this class was generated from the following file: