#include <BaseFunction.h>
Public Member Functions | |
BaseFunction () | |
BaseFunction (const MuScleFitDBobject *dbObject) | |
Constructor when receiving database parameters. | |
std::vector< double > | fitQuality () const |
Return the vector of fit quality values. | |
std::vector< int > | identifiers () const |
Return the vector of function identifiers. | |
std::vector< double > | parameters () const |
Return the vector of parameters. | |
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. | |
Protected Attributes | |
std::vector< double > | fitQuality_ |
double ** | fitQualityArray_ |
std::vector< int > | functionId_ |
int | iterationNum_ |
double ** | parArray_ |
std::vector< double > | parVecVec_ |
This class is used as base from scale, resolution and background functions.
Definition at line 14 of file BaseFunction.h.
BaseFunction::BaseFunction | ( | ) | [inline] |
Definition at line 17 of file BaseFunction.h.
{}
BaseFunction::BaseFunction | ( | const MuScleFitDBobject * | dbObject | ) | [inline] |
Constructor when receiving database parameters.
Definition at line 20 of file BaseFunction.h.
References functionId_, MuScleFitDBobject::identifiers, iterationNum_, MuScleFitDBobject::parameters, and parVecVec_.
{ functionId_ = dbObject->identifiers; std::vector<int>::const_iterator id = functionId_.begin(); parVecVec_ = dbObject->parameters; // Needed for the tests in convertToArrays iterationNum_ = functionId_.size()-1; }
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 57 of file BaseFunction.h.
References gather_cfg::cout, cmsRelvalreport::exit, iterationNum_, Gflash::par, parArray_, and parVecVec_.
Referenced by BackgroundFunction::BackgroundFunction(), MomentumScaleCorrector::MomentumScaleCorrector(), MomentumScaleCorrector::readParameters(), ResolutionFunction::readParameters(), BackgroundFunction::readParameters(), and ResolutionFunction::ResolutionFunction().
{ // Check for consistency of number of passed parameters and number of required parameters. int totParNums = 0; typename std::vector<T*>::const_iterator funcIt = functionVec_.begin(); for( ; funcIt != functionVec_.end(); ++funcIt ) { totParNums += (*funcIt)->parNum(); } int parVecVecSize = parVecVec_.size(); int functionVecSize = functionVec_.size(); if( functionVecSize != iterationNum_+1 ) { std::cout << "Error: inconsistent number of functions("<<functionVecSize<<") and iterations("<<iterationNum_+1<<")" << std::endl; exit(1); } else if( totParNums != parVecVecSize ) { std::cout << "Error: inconsistent total number of requested parameters("<<totParNums<<") and parameters read("<<parVecVecSize<<")" << std::endl; exit(1); } // else if( parVecVecSize != functionVecSize ) { // std::cout << "Error: inconsistent number of functions("<<functionVecSize<<") and parameter sets("<<parVecVecSize<<")" << std::endl; // exit(1); // } // else if( parVecVecSize != iterationNum_+1 ) { // std::cout << "Error: inconsistent number of parameter sets("<<parVecVecSize<<") and iterations("<<iterationNum_+1<<")" << std::endl; // exit(1); // } // parArray_ = new double*[parVecVecSize]; parArray_ = new double*[functionVecSize]; // std::vector<double>::const_iterator parVec = parVecVec_.begin(); // iterationNum_ starts from 0. function_ = new T*[functionVecSize]; typename std::vector<T * >::const_iterator func = functionVec_.begin(); std::vector<double>::const_iterator parVec = parVecVec_.begin(); int iterationCounter = 0; for( ; func != functionVec_.end(); ++func, ++iterationCounter ) { // Loop on the parameters size for each function and create corresponding parameter arrays int parNum = (*func)->parNum(); parArray_[iterationCounter] = new double[parNum]; for( int par = 0; par < parNum; ++par ) { parArray_[iterationCounter][par] = *parVec; ++parVec; } // parArray_[iterationCounter] = new double[parVec->size()]; // std::vector<double>::const_iterator par = parVec->begin(); // int parNum = 0; // for ( ; par != parVec->end(); ++par, ++parNum ) { // parArray_[iterationCounter][parNum] = *par; // // std::cout << "parameter["<<parNum<<"] = " << parArray_[iterationCounter][parNum] << std::endl; // } // // return make_pair(parameters, parameterErrors); function_[iterationCounter] = *func; } }
std::vector<double> BaseFunction::fitQuality | ( | ) | const [inline] |
Return the vector of fit quality values.
Definition at line 38 of file BaseFunction.h.
References parVecVec_.
{ return parVecVec_; }
std::vector<int> BaseFunction::identifiers | ( | ) | const [inline] |
Return the vector of function identifiers.
Definition at line 30 of file BaseFunction.h.
References functionId_.
{ return functionId_; }
std::vector<double> BaseFunction::parameters | ( | void | ) | const [inline] |
Return the vector of parameters.
Definition at line 34 of file BaseFunction.h.
References parVecVec_.
{ return parVecVec_; }
std::vector<double> BaseFunction::fitQuality_ [protected] |
Definition at line 49 of file BaseFunction.h.
double** BaseFunction::fitQualityArray_ [protected] |
Definition at line 52 of file BaseFunction.h.
std::vector<int> BaseFunction::functionId_ [protected] |
Definition at line 47 of file BaseFunction.h.
Referenced by BackgroundFunction::BackgroundFunction(), BaseFunction(), identifiers(), MomentumScaleCorrector::MomentumScaleCorrector(), MomentumScaleCorrector::readParameters(), ResolutionFunction::readParameters(), BackgroundFunction::readParameters(), ResolutionFunction::ResolutionFunction(), BackgroundFunction::~BackgroundFunction(), MomentumScaleCorrector::~MomentumScaleCorrector(), and ResolutionFunction::~ResolutionFunction().
int BaseFunction::iterationNum_ [protected] |
Definition at line 53 of file BaseFunction.h.
Referenced by BaseFunction(), convertToArrays(), MomentumScaleCorrector::correct(), MomentumScaleCorrector::operator()(), MomentumScaleCorrector::readParameters(), ResolutionFunction::readParameters(), BackgroundFunction::readParameters(), ResolutionFunction::sigmaCotgTh(), ResolutionFunction::sigmaPhi(), and ResolutionFunction::sigmaPt().
double** BaseFunction::parArray_ [protected] |
Definition at line 51 of file BaseFunction.h.
Referenced by convertToArrays(), MomentumScaleCorrector::correct(), MomentumScaleCorrector::operator()(), MomentumScaleCorrector::readParameters(), ResolutionFunction::readParameters(), BackgroundFunction::readParameters(), ResolutionFunction::sigmaCotgTh(), ResolutionFunction::sigmaPhi(), ResolutionFunction::sigmaPt(), BackgroundFunction::~BackgroundFunction(), MomentumScaleCorrector::~MomentumScaleCorrector(), and ResolutionFunction::~ResolutionFunction().
std::vector<double> BaseFunction::parVecVec_ [protected] |
Definition at line 48 of file BaseFunction.h.
Referenced by BaseFunction(), convertToArrays(), fitQuality(), parameters(), MomentumScaleCorrector::readParameters(), ResolutionFunction::readParameters(), and BackgroundFunction::readParameters().