CMS 3D CMS Logo

BackgroundFunction.h
Go to the documentation of this file.
1 
6 #ifndef BackgroundFunction_h
7 #define BackgroundFunction_h
8 
9 #include <fstream>
10 #include <sstream>
14 
16 public:
23  BackgroundFunction(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  BackgroundFunction(const MuScleFitDBobject* dbObject) : BaseFunction(dbObject) {
40  std::vector<int>::const_iterator id = functionId_.begin();
41  for (; id != functionId_.end(); ++id) {
42  // TODO: fix the values for the lower and upper limits
43  backgroundFunctionVec_.push_back(backgroundFunctionService(*id, 0., 200.));
44  }
45  // Fill the arrays that will be used when calling the correction function.
47  }
48 
50  if (parArray_ != nullptr) {
51  for (unsigned int i = 0; i < functionId_.size(); ++i) {
52  delete[] parArray_[i];
53  delete backgroundFunction_[i];
54  }
55  delete[] parArray_;
56  delete[] backgroundFunction_;
57  }
58  }
60  backgroundFunctionBase* function(const unsigned int i) {
61  if (backgroundFunctionVec_.size() > i)
62  return backgroundFunction_[i];
63  else
64  return nullptr;
65  }
66 
67 protected:
69  void readParameters(TString fileName);
70 
72  std::vector<backgroundFunctionBase*> backgroundFunctionVec_;
73 };
74 
75 #endif // BackgroundFunction_h
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:48
BackgroundFunction(const MuScleFitDBobject *dbObject)
std::vector< int > functionId_
Definition: BaseFunction.h:38
void readParameters(TString fileName)
Parser of the parameters file.
backgroundFunctionBase ** backgroundFunction_
std::vector< backgroundFunctionBase * > backgroundFunctionVec_
backgroundFunctionBase * backgroundFunctionService(const int identifier, const double &lowerLimit, const double &upperLimit)
Service to build the background functor corresponding to the passed identifier.
Definition: Functions.cc:114
BackgroundFunction(TString identifier)
double ** parArray_
Definition: BaseFunction.h:42