#include <ResolutionFunction.h>
Public Member Functions | |
resolutionFunctionBase< double * > * | function (const unsigned int i) |
Get the ith resolution function. | |
ResolutionFunction (const MuScleFitDBobject *dbObject) | |
ResolutionFunction (TString identifier) | |
template<class U > | |
double | sigmaCotgTh (const U &track, const int i=0) const |
The second, optional, parameter is the iteration number. | |
template<class U > | |
double | sigmaPhi (const U &track, const int i=0) const |
The second, optional, parameter is the iteration number. | |
template<class U > | |
double | sigmaPt (const U &track, const int i=0) const |
The second, optional, parameter is the iteration number. | |
~ResolutionFunction () | |
Protected Member Functions | |
void | readParameters (TString fileName) |
Parser of the parameters file. | |
Protected Attributes | |
resolutionFunctionBase< double * > ** | resolutionFunction_ |
std::vector < resolutionFunctionBase < double * > * > | resolutionFunctionVec_ |
Class for the resolution function. It can be built from local file or from db.
Definition at line 15 of file ResolutionFunction.h.
ResolutionFunction::ResolutionFunction | ( | TString | identifier | ) | [inline] |
The constructor takes a string identifying the parameters to read. It parses the txt file containing the parameters, extracts the index of the correction function and saves the corresponding pointer. It then fills the vector of parameters.
Definition at line 24 of file ResolutionFunction.h.
References gather_cfg::cout, BaseFunction::functionId_, and readParameters().
{ identifier.Prepend("MuonAnalysis/MomentumScaleCalibration/data/"); identifier.Append(".txt"); edm::FileInPath fileWithFullPath(identifier.Data()); readParameters( fileWithFullPath.fullPath() ); std::vector<int>::const_iterator idIt = functionId_.begin(); for( ; idIt != functionId_.end(); ++idIt ) std::cout << "idIt = " << *idIt << std::endl; }
ResolutionFunction::ResolutionFunction | ( | const MuScleFitDBobject * | dbObject | ) | [inline] |
This constructor is used when reading parameters from the db. It receives a pointer to an object of type MuScleFitDBobject containing the parameters and the functions identifiers. The object is the same for all the functions.
Definition at line 40 of file ResolutionFunction.h.
References BaseFunction::convertToArrays(), BaseFunction::functionId_, errorMatrix2Lands_multiChannel::id, resolutionFunction_, resolutionFunctionService(), and resolutionFunctionVec_.
: BaseFunction( dbObject ) { std::vector<int>::const_iterator id = functionId_.begin(); for( ; id != functionId_.end(); ++id ) { resolutionFunctionVec_.push_back( resolutionFunctionService( *id ) ); } // Fill the arrays that will be used when calling the correction function. convertToArrays(resolutionFunction_, resolutionFunctionVec_); }
ResolutionFunction::~ResolutionFunction | ( | ) | [inline] |
Definition at line 50 of file ResolutionFunction.h.
References BaseFunction::functionId_, i, BaseFunction::parArray_, and resolutionFunction_.
{ if( parArray_ != 0 ) { for( unsigned int i=0; i<functionId_.size(); ++i ) { delete[] parArray_[i]; delete resolutionFunction_[i]; } delete[] parArray_; delete[] resolutionFunction_; } }
resolutionFunctionBase<double * >* ResolutionFunction::function | ( | const unsigned int | i | ) | [inline] |
Get the ith resolution function.
Definition at line 93 of file ResolutionFunction.h.
References i, resolutionFunction_, and resolutionFunctionVec_.
{ if( resolutionFunctionVec_.size() > i ) return resolutionFunction_[i]; else return 0; }
void ResolutionFunction::readParameters | ( | TString | fileName | ) | [protected] |
Parser of the parameters file.
Definition at line 3 of file ResolutionFunction.cc.
References BaseFunction::convertToArrays(), BaseFunction::functionId_, recoMuon::in, align_cfg::iteration, BaseFunction::iterationNum_, geometryCSVtoXML::line, BaseFunction::parArray_, BaseFunction::parVecVec_, resolutionFunction_, resolutionFunctionService(), and resolutionFunctionVec_.
Referenced by ResolutionFunction().
{ iterationNum_ = 0; parArray_ = 0; // std::vector<double> parameterErrors; // Read the parameters file std::ifstream parametersFile(fileName.Data()); std::string line; std::string iteration("Iteration "); // Loop on the file lines while (parametersFile) { getline( parametersFile, line ); size_t lineInt = line.find("value"); // if( line.find(iteration) != std::string::npos ) { size_t iterationSubStr = line.find(iteration); // Take the iteration number if( iterationSubStr != std::string::npos ) { int functionNum = 0; // This can be used when dealing with multiple iterations // std::cout << "line = " << line << std::endl; std::stringstream sLine(line); std::string num; int wordCounter = 0; // Warning: this strongly depends on the parameters file structure. while( sLine >> num ) { ++wordCounter; // std::cout << "num["<<wordCounter<<"] = " << num << std::endl; if( wordCounter == 8 ) { std::stringstream in(num); in >> functionNum; } if( wordCounter == 13 ) { std::stringstream in(num); in >> iterationNum_; } } // std::cout << "iteration number = " << iterationNum_ << std::endl; // std::cout << "scale function number = " << scaleFunctionNum << std::endl; // Create a new vector to hold the parameters for this iteration // std::vector<double> parVec; // parVecVec_.push_back(parVec); // Set the scaleFunction // scaleFunction_ = scaleFunctionArrayForVec[scaleFunctionNum]; // scaleFunction_ = scaleFunctionArray[scaleFunctionNum]; functionId_.push_back(functionNum); // scaleFunctionVec_.push_back( scaleFunctionArray[scaleFunctionNum] ); resolutionFunctionVec_.push_back( resolutionFunctionService( functionNum ) ); } // Take the parameters for the current iteration if ( (lineInt != std::string::npos) ) { size_t subStr1 = line.find("value"); std::stringstream paramStr; double param = 0; // Even if all the rest of the line is taken, the following // convertion to a double will stop at the end of the first number. paramStr << line.substr(subStr1+5); paramStr >> param; // // Fill the last vector of parameters, which corresponds to this iteration. // parVecVec_.back().push_back(param); parVecVec_.push_back(param); // std::cout << "param = " << param << std::endl; // This is to extract parameter errors // size_t subStr2 = line.find("+-"); // std::stringstream parErrorStr; // double parError = 0; // parErrorStr << line.substr(subStr2+1); // parErrorStr >> parError; // parameterErrors.push_back(parError); // std::cout << "parError = " << parError << std::endl; } } convertToArrays( resolutionFunction_, resolutionFunctionVec_ ); }
double ResolutionFunction::sigmaCotgTh | ( | const U & | track, |
const int | i = 0 |
||
) | const [inline] |
The second, optional, parameter is the iteration number.
Definition at line 76 of file ResolutionFunction.h.
References gather_cfg::cout, cmsRelvalreport::exit, i, BaseFunction::iterationNum_, BaseFunction::parArray_, resolutionFunction_, and resolutionFunctionBase< T >::sigmaCotgTh().
Referenced by MuScleFitUtils::massResolution().
{ if( i > iterationNum_ || i < 0 ) { std::cout << "Error: wrong iteration number, there are " << iterationNum_ << "iterations, ther first one is 0" << std::endl; exit(1); } return resolutionFunction_[i]->sigmaCotgTh(track.pt(), track.eta(), parArray_[i]); }
double ResolutionFunction::sigmaPhi | ( | const U & | track, |
const int | i = 0 |
||
) | const [inline] |
The second, optional, parameter is the iteration number.
Definition at line 85 of file ResolutionFunction.h.
References gather_cfg::cout, cmsRelvalreport::exit, i, BaseFunction::iterationNum_, BaseFunction::parArray_, resolutionFunction_, and resolutionFunctionBase< T >::sigmaPhi().
Referenced by MuScleFitUtils::massResolution().
{ if( i > iterationNum_ || i < 0 ) { std::cout << "Error: wrong iteration number, there are " << iterationNum_ << "iterations, ther first one is 0" << std::endl; exit(1); } return resolutionFunction_[i]->sigmaPhi(track.pt(), track.eta(), parArray_[i]); }
double ResolutionFunction::sigmaPt | ( | const U & | track, |
const int | i = 0 |
||
) | const [inline] |
The second, optional, parameter is the iteration number.
Definition at line 67 of file ResolutionFunction.h.
References gather_cfg::cout, cmsRelvalreport::exit, i, BaseFunction::iterationNum_, BaseFunction::parArray_, resolutionFunction_, and resolutionFunctionBase< T >::sigmaPt().
Referenced by MuScleFitUtils::massResolution().
{ if( i > iterationNum_ || i < 0 ) { std::cout << "Error: wrong iteration number, there are " << iterationNum_ << "iterations, ther first one is 0" << std::endl; exit(1); } return resolutionFunction_[i]->sigmaPt(track.pt(), track.eta(), parArray_[i]); }
resolutionFunctionBase<double * >** ResolutionFunction::resolutionFunction_ [protected] |
Definition at line 103 of file ResolutionFunction.h.
Referenced by function(), readParameters(), ResolutionFunction(), sigmaCotgTh(), sigmaPhi(), sigmaPt(), and ~ResolutionFunction().
std::vector<resolutionFunctionBase<double * > * > ResolutionFunction::resolutionFunctionVec_ [protected] |
Definition at line 104 of file ResolutionFunction.h.
Referenced by function(), readParameters(), and ResolutionFunction().