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 
61  // EM+SC: 2013.01.11
62  // lorentzVector have both capital and lower case methods for pt(), eta() and phi
63  // if a lorentzVector is passed use, parArray form iteration i=0
64 
66  template <class U>
67  double sigmaPt(const U & track, const int i=0) const {
68  if( i > iterationNum_ || i < 0 ) {
69  std::cout << "Error: wrong iteration number, there are " << iterationNum_ << "iterations, ther first one is 0" << std::endl;
70  exit(1);
71  }
72  return resolutionFunction_[i]->sigmaPt(track.pt(), track.eta(), parArray_[i]);
73  }
75  template <class U>
76  double sigmaCotgTh(const U & track, const int i=0) const {
77  if( i > iterationNum_ || i < 0 ) {
78  std::cout << "Error: wrong iteration number, there are " << iterationNum_ << "iterations, ther first one is 0" << std::endl;
79  exit(1);
80  }
81  return resolutionFunction_[i]->sigmaCotgTh(track.pt(), track.eta(), parArray_[i]);
82  }
84  template <class U>
85  double sigmaPhi(const U & track, const int i=0) const {
86  if( i > iterationNum_ || i < 0 ) {
87  std::cout << "Error: wrong iteration number, there are " << iterationNum_ << "iterations, ther first one is 0" << std::endl;
88  exit(1);
89  }
90  return resolutionFunction_[i]->sigmaPhi(track.pt(), track.eta(), parArray_[i]);
91  }
93  resolutionFunctionBase<double * > * function( const unsigned int i )
94  {
95  if( resolutionFunctionVec_.size() > i ) return resolutionFunction_[i];
96  else return 0;
97  }
98 
99 protected:
101  void readParameters( TString fileName );
102 
104  std::vector<resolutionFunctionBase<double * > * > resolutionFunctionVec_;
105 };
106 
107 #endif // ResolutionFunction_h
double sigmaPt(const U &track, const int i=0) const
The second, optional, parameter is the iteration number.
ResolutionFunction(const MuScleFitDBobject *dbObject)
int i
Definition: DBlmapReader.cc:9
double sigmaCotgTh(const U &track, const int i=0) const
The second, optional, parameter is the iteration number.
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:56
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.
std::vector< int > functionId_
Definition: BaseFunction.h:46
double sigmaPhi(const U &track, const int i=0) const
The second, optional, parameter is the iteration number.
virtual double sigmaCotgTh(const double &pt, const double &eta, const T &parval)=0
resolutionFunctionBase< double * > * resolutionFunctionService(const int identifier)
Service to build the resolution functor corresponding to the passed identifier.
Definition: Functions.cc:38
tuple cout
Definition: gather_cfg.py:145
virtual double sigmaPhi(const double &pt, const double &eta, const T &parval)=0
ResolutionFunction(TString identifier)
double ** parArray_
Definition: BaseFunction.h:50