CMS 3D CMS Logo

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 public:
23  ResolutionFunction(TString identifier) {
24  identifier.Prepend("MuonAnalysis/MomentumScaleCalibration/data/");
25  identifier.Append(".txt");
26  edm::FileInPath fileWithFullPath(identifier.Data());
27  readParameters(fileWithFullPath.fullPath());
28 
29  std::vector<int>::const_iterator idIt = functionId_.begin();
30  for (; idIt != functionId_.end(); ++idIt)
31  std::cout << "idIt = " << *idIt << std::endl;
32  }
39  ResolutionFunction(const MuScleFitDBobject* dbObject) : BaseFunction(dbObject) {
40  std::vector<int>::const_iterator id = functionId_.begin();
41  for (; id != functionId_.end(); ++id) {
43  }
44  // Fill the arrays that will be used when calling the correction function.
46  }
47 
49  if (parArray_ != nullptr) {
50  for (unsigned int i = 0; i < functionId_.size(); ++i) {
51  delete[] parArray_[i];
52  delete resolutionFunction_[i];
53  }
54  delete[] parArray_;
55  delete[] resolutionFunction_;
56  }
57  }
58 
59  // EM+SC: 2013.01.11
60  // lorentzVector have both capital and lower case methods for pt(), eta() and phi
61  // if a lorentzVector is passed use, parArray form iteration i=0
62 
64  template <class U>
65  double sigmaPt(const U& track, const int i = 0) const {
66  if (i > iterationNum_ || i < 0) {
67  std::cout << "Error: wrong iteration number, there are " << iterationNum_ << "iterations, ther first one is 0"
68  << std::endl;
69  exit(1);
70  }
71  return resolutionFunction_[i]->sigmaPt(track.pt(), track.eta(), parArray_[i]);
72  }
74  template <class U>
75  double sigmaCotgTh(const U& track, const int i = 0) const {
76  if (i > iterationNum_ || i < 0) {
77  std::cout << "Error: wrong iteration number, there are " << iterationNum_ << "iterations, ther first one is 0"
78  << 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"
88  << std::endl;
89  exit(1);
90  }
91  return resolutionFunction_[i]->sigmaPhi(track.pt(), track.eta(), parArray_[i]);
92  }
94  resolutionFunctionBase<double*>* function(const unsigned int i) {
95  if (resolutionFunctionVec_.size() > i)
96  return resolutionFunction_[i];
97  else
98  return nullptr;
99  }
100 
101 protected:
103  void readParameters(TString fileName);
104 
106  std::vector<resolutionFunctionBase<double*>*> resolutionFunctionVec_;
107 };
108 
109 #endif // ResolutionFunction_h
BaseFunction::convertToArrays
void convertToArrays(T **&function_, const std::vector< T * > &functionVec_)
Convert vectors to arrays for faster random access. The first pointer is replaced,...
Definition: BaseFunction.h:48
ResolutionFunction::resolutionFunctionVec_
std::vector< resolutionFunctionBase< double * > * > resolutionFunctionVec_
Definition: ResolutionFunction.h:106
mps_fire.i
i
Definition: mps_fire.py:355
resolutionFunctionBase< double * >
gather_cfg.cout
cout
Definition: gather_cfg.py:144
ResolutionFunction::ResolutionFunction
ResolutionFunction(TString identifier)
Definition: ResolutionFunction.h:23
resolutionFunctionService
resolutionFunctionBase< double * > * resolutionFunctionService(const int identifier)
Service to build the resolution functor corresponding to the passed identifier.
Definition: Functions.cc:70
resolutionFunctionBase::sigmaCotgTh
virtual double sigmaCotgTh(const double &pt, const double &eta, const T &parval)=0
MuScleFitDBobject
Definition: MuScleFitDBobject.h:8
ResolutionFunction::sigmaPhi
double sigmaPhi(const U &track, const int i=0) const
The second, optional, parameter is the iteration number.
Definition: ResolutionFunction.h:85
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
ResolutionFunction::resolutionFunction_
resolutionFunctionBase< double * > ** resolutionFunction_
Definition: ResolutionFunction.h:105
FileInPath.h
edm::FileInPath
Definition: FileInPath.h:64
ResolutionFunction::ResolutionFunction
ResolutionFunction(const MuScleFitDBobject *dbObject)
Definition: ResolutionFunction.h:39
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
BaseFunction::parArray_
double ** parArray_
Definition: BaseFunction.h:42
resolutionFunctionBase::sigmaPhi
virtual double sigmaPhi(const double &pt, const double &eta, const T &parval)=0
ResolutionFunction
Definition: ResolutionFunction.h:15
BaseFunction
Definition: BaseFunction.h:14
resolutionFunctionBase::sigmaPt
virtual double sigmaPt(const double &pt, const double &eta, const T &parval)=0
ResolutionFunction::sigmaPt
double sigmaPt(const U &track, const int i=0) const
The second, optional, parameter is the iteration number.
Definition: ResolutionFunction.h:65
BaseFunction.h
BaseFunction::iterationNum_
int iterationNum_
Definition: BaseFunction.h:44
ResolutionFunction::~ResolutionFunction
~ResolutionFunction()
Definition: ResolutionFunction.h:48
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
BaseFunction::functionId_
std::vector< int > functionId_
Definition: BaseFunction.h:38
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
Functions.h
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:53
ResolutionFunction::sigmaCotgTh
double sigmaCotgTh(const U &track, const int i=0) const
The second, optional, parameter is the iteration number.
Definition: ResolutionFunction.h:75
ResolutionFunction::readParameters
void readParameters(TString fileName)
Parser of the parameters file.
Definition: ResolutionFunction.cc:3