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
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
BackgroundFunction::backgroundFunction_
backgroundFunctionBase ** backgroundFunction_
Definition: BackgroundFunction.h:71
mps_fire.i
i
Definition: mps_fire.py:428
BackgroundFunction::BackgroundFunction
BackgroundFunction(TString identifier)
Definition: BackgroundFunction.h:23
BackgroundFunction
Definition: BackgroundFunction.h:15
gather_cfg.cout
cout
Definition: gather_cfg.py:144
backgroundFunctionBase
Definition: Functions.h:1368
MuScleFitDBobject
Definition: MuScleFitDBobject.h:8
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
FileInPath.h
edm::FileInPath
Definition: FileInPath.h:64
BackgroundFunction::BackgroundFunction
BackgroundFunction(const MuScleFitDBobject *dbObject)
Definition: BackgroundFunction.h:39
BackgroundFunction::readParameters
void readParameters(TString fileName)
Parser of the parameters file.
Definition: BackgroundFunction.cc:3
BackgroundFunction::~BackgroundFunction
~BackgroundFunction()
Definition: BackgroundFunction.h:49
BaseFunction::parArray_
double ** parArray_
Definition: BaseFunction.h:42
backgroundFunctionService
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
BaseFunction
Definition: BaseFunction.h:14
BaseFunction.h
BackgroundFunction::backgroundFunctionVec_
std::vector< backgroundFunctionBase * > backgroundFunctionVec_
Definition: BackgroundFunction.h:72
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
BaseFunction::functionId_
std::vector< int > functionId_
Definition: BaseFunction.h:38
Functions.h