CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ResolutionFunction.h
Go to the documentation of this file.
1 
6 #ifndef ResolutionFunction_h
7 #define ResolutionFunction_h
8 
9 #include <fstream>
10 #include <sstream>
14 
16 {
17 public:
24  ResolutionFunction( TString identifier )
25  {
26  identifier.Prepend("MuonAnalysis/MomentumScaleCalibration/data/");
27  identifier.Append(".txt");
28  edm::FileInPath fileWithFullPath(identifier.Data());
29  readParameters( fileWithFullPath.fullPath() );
30 
31  std::vector<int>::const_iterator idIt = functionId_.begin();
32  for( ; idIt != functionId_.end(); ++idIt ) std::cout << "idIt = " << *idIt << std::endl;
33  }
40  ResolutionFunction( const MuScleFitDBobject * dbObject ) : BaseFunction( dbObject )
41  {
42  std::vector<int>::const_iterator id = functionId_.begin();
43  for( ; id != functionId_.end(); ++id ) {
45  }
46  // Fill the arrays that will be used when calling the correction function.
48  }
49 
51  if( parArray_ != 0 ) {
52  for( unsigned int i=0; i<functionId_.size(); ++i ) {
53  delete[] parArray_[i];
54  delete resolutionFunction_[i];
55  }
56  delete[] parArray_;
57  delete[] resolutionFunction_;
58  }
59  }
60 
62  template <class U>
63  double sigmaPt(const U & track, const int i = 0) {
64  if( i > iterationNum_ || i < 0 ) {
65  std::cout << "Error: wrong iteration number, there are " << iterationNum_ << "iterations, ther first one is 0" << std::endl;
66  exit(1);
67  }
68  return resolutionFunction_[i]->sigmaPt(track.pt(), track.eta(), parArray_[i]);
69  }
71  template <class U>
72  double sigmaCotgTh(const U & track, const int i = 0) {
73  if( i > iterationNum_ || i < 0 ) {
74  std::cout << "Error: wrong iteration number, there are " << iterationNum_ << "iterations, ther first one is 0" << std::endl;
75  exit(1);
76  }
77  return resolutionFunction_[i]->sigmaCotgTh(track.pt(), track.eta(), parArray_[i]);
78  }
80  template <class U>
81  double sigmaPhi(const U & track, const int i = 0) {
82  if( i > iterationNum_ || i < 0 ) {
83  std::cout << "Error: wrong iteration number, there are " << iterationNum_ << "iterations, ther first one is 0" << std::endl;
84  exit(1);
85  }
86  return resolutionFunction_[i]->sigmaPhi(track.pt(), track.eta(), parArray_[i]);
87  }
89  resolutionFunctionBase<double * > * function( const unsigned int i )
90  {
91  if( resolutionFunctionVec_.size() > i ) return resolutionFunction_[i];
92  else return 0;
93  }
94 protected:
96  void readParameters( TString fileName );
97 
99  std::vector<resolutionFunctionBase<double * > * > resolutionFunctionVec_;
100 };
101 
102 #endif // ResolutionFunction_h
ResolutionFunction(const MuScleFitDBobject *dbObject)
int i
Definition: DBlmapReader.cc:9
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.
Definition: BaseFunction.h:57
resolutionFunctionBase< double * > ** resolutionFunction_
virtual double sigmaPt(const double &pt, const double &eta, const T &parval)=0
std::vector< resolutionFunctionBase< double * > * > resolutionFunctionVec_
void readParameters(TString fileName)
Parser of the parameters file.
double sigmaPt(const U &track, const int i=0)
The second, optional, parameter is the iteration number.
std::vector< int > functionId_
Definition: BaseFunction.h:47
double sigmaCotgTh(const U &track, const int i=0)
The second, optional, parameter is the iteration number.
virtual double sigmaCotgTh(const double &pt, const double &eta, const T &parval)=0
double sigmaPhi(const U &track, const int i=0)
The second, optional, parameter is the iteration number.
resolutionFunctionBase< double * > * resolutionFunctionService(const int identifier)
Service to build the resolution functor corresponding to the passed identifier.
Definition: Functions.cc:88
tuple cout
Definition: gather_cfg.py:41
virtual double sigmaPhi(const double &pt, const double &eta, const T &parval)=0
ResolutionFunction(TString identifier)
double ** parArray_
Definition: BaseFunction.h:51