CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
BaseFunction Class Reference

#include <BaseFunction.h>

Inheritance diagram for BaseFunction:
BackgroundFunction MomentumScaleCorrector ResolutionFunction

Public Member Functions

 BaseFunction ()
 
 BaseFunction (const MuScleFitDBobject *dbObject)
 Constructor when receiving database parameters. More...
 
std::vector< double > fitQuality () const
 Return the vector of fit quality values. More...
 
std::vector< int > identifiers () const
 Return the vector of function identifiers. More...
 
std::vector< double > parameters () const
 Return the vector of parameters. More...
 

Protected Member Functions

template<class T >
void convertToArrays (T **&function_, const std::vector< T * > &functionVec_)
 Convert vectors to arrays for faster random access. The first pointer is replaced, thus it is taken by reference. More...
 

Protected Attributes

std::vector< double > fitQuality_
 
double ** fitQualityArray_
 
std::vector< int > functionId_
 
int iterationNum_
 
double ** parArray_
 
std::vector< double > parVecVec_
 

Detailed Description

This class is used as base from scale, resolution and background functions.

Definition at line 14 of file BaseFunction.h.

Constructor & Destructor Documentation

BaseFunction::BaseFunction ( )
inline

Definition at line 16 of file BaseFunction.h.

16 {}
BaseFunction::BaseFunction ( const MuScleFitDBobject dbObject)
inline

Constructor when receiving database parameters.

Definition at line 19 of file BaseFunction.h.

References functionId_, MuScleFitDBobject::identifiers, iterationNum_, MuScleFitDBobject::parameters, and parVecVec_.

19  {
20  functionId_ = dbObject->identifiers;
21  parVecVec_ = dbObject->parameters;
22  // Needed for the tests in convertToArrays
23  iterationNum_ = functionId_.size() - 1;
24  }
std::vector< double > parVecVec_
Definition: BaseFunction.h:39
std::vector< int > identifiers
std::vector< int > functionId_
Definition: BaseFunction.h:38
std::vector< double > parameters

Member Function Documentation

template<class T >
void BaseFunction::convertToArrays ( T **&  function_,
const std::vector< T * > &  functionVec_ 
)
protected

Convert vectors to arrays for faster random access. The first pointer is replaced, thus it is taken by reference.

Definition at line 48 of file BaseFunction.h.

References gather_cfg::cout, beamvalidation::exit(), cms::cuda::func, iterationNum_, parArray_, and parVecVec_.

Referenced by BackgroundFunction::BackgroundFunction(), MomentumScaleCorrector::MomentumScaleCorrector(), BackgroundFunction::readParameters(), MomentumScaleCorrector::readParameters(), ResolutionFunction::readParameters(), and ResolutionFunction::ResolutionFunction().

48  {
49  // Check for consistency of number of passed parameters and number of required parameters.
50  int totParNums = 0;
51  typename std::vector<T*>::const_iterator funcIt = functionVec_.begin();
52  for (; funcIt != functionVec_.end(); ++funcIt) {
53  totParNums += (*funcIt)->parNum();
54  }
55  int parVecVecSize = parVecVec_.size();
56  int functionVecSize = functionVec_.size();
57  if (functionVecSize != iterationNum_ + 1) {
58  std::cout << "Error: inconsistent number of functions(" << functionVecSize << ") and iterations("
59  << iterationNum_ + 1 << ")" << std::endl;
60  exit(1);
61  } else if (totParNums != parVecVecSize) {
62  std::cout << "Error: inconsistent total number of requested parameters(" << totParNums << ") and parameters read("
63  << parVecVecSize << ")" << std::endl;
64  exit(1);
65  }
66  // else if( parVecVecSize != functionVecSize ) {
67  // std::cout << "Error: inconsistent number of functions("<<functionVecSize<<") and parameter sets("<<parVecVecSize<<")" << std::endl;
68  // exit(1);
69  // }
70  // else if( parVecVecSize != iterationNum_+1 ) {
71  // std::cout << "Error: inconsistent number of parameter sets("<<parVecVecSize<<") and iterations("<<iterationNum_+1<<")" << std::endl;
72  // exit(1);
73  // }
74  // parArray_ = new double*[parVecVecSize];
75 
76  parArray_ = new double*[functionVecSize];
77 
78  // std::vector<double>::const_iterator parVec = parVecVec_.begin();
79  // iterationNum_ starts from 0.
80  function_ = new T*[functionVecSize];
81  typename std::vector<T*>::const_iterator func = functionVec_.begin();
82  std::vector<double>::const_iterator parVec = parVecVec_.begin();
83 
84  int iterationCounter = 0;
85  for (; func != functionVec_.end(); ++func, ++iterationCounter) {
86  // Loop on the parameters size for each function and create corresponding parameter arrays
87  int parNum = (*func)->parNum();
88  parArray_[iterationCounter] = new double[parNum];
89  for (int par = 0; par < parNum; ++par) {
90  parArray_[iterationCounter][par] = *parVec;
91  ++parVec;
92  }
93 
94  // parArray_[iterationCounter] = new double[parVec->size()];
95  // std::vector<double>::const_iterator par = parVec->begin();
96  // int parNum = 0;
97  // for ( ; par != parVec->end(); ++par, ++parNum ) {
98  // parArray_[iterationCounter][parNum] = *par;
99  // // std::cout << "parameter["<<parNum<<"] = " << parArray_[iterationCounter][parNum] << std::endl;
100  // }
101  // // return make_pair(parameters, parameterErrors);
102 
103  function_[iterationCounter] = *func;
104  }
105 }
std::vector< double > parVecVec_
Definition: BaseFunction.h:39
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t Func __host__ __device__ V int Func func
tuple cout
Definition: gather_cfg.py:144
long double T
double ** parArray_
Definition: BaseFunction.h:42
std::vector<double> BaseFunction::fitQuality ( ) const
inline

Return the vector of fit quality values.

Definition at line 31 of file BaseFunction.h.

References parVecVec_.

31 { return parVecVec_; }
std::vector< double > parVecVec_
Definition: BaseFunction.h:39
std::vector<int> BaseFunction::identifiers ( ) const
inline

Return the vector of function identifiers.

Definition at line 27 of file BaseFunction.h.

References functionId_.

27 { return functionId_; }
std::vector< int > functionId_
Definition: BaseFunction.h:38
std::vector<double> BaseFunction::parameters ( void  ) const
inline

Return the vector of parameters.

Definition at line 29 of file BaseFunction.h.

References parVecVec_.

29 { return parVecVec_; }
std::vector< double > parVecVec_
Definition: BaseFunction.h:39

Member Data Documentation

std::vector<double> BaseFunction::fitQuality_
protected

Definition at line 40 of file BaseFunction.h.

double** BaseFunction::fitQualityArray_
protected

Definition at line 43 of file BaseFunction.h.

std::vector<int> BaseFunction::functionId_
protected
int BaseFunction::iterationNum_
protected
double** BaseFunction::parArray_
protected
std::vector<double> BaseFunction::parVecVec_
protected