File indexing completed on 2024-04-06 12:22:36
0001
0002
0003
0004
0005
0006 #ifndef BackgroundFunction_h
0007 #define BackgroundFunction_h
0008
0009 #include <fstream>
0010 #include <sstream>
0011 #include "MuonAnalysis/MomentumScaleCalibration/interface/BaseFunction.h"
0012 #include "MuonAnalysis/MomentumScaleCalibration/interface/Functions.h"
0013 #include "FWCore/ParameterSet/interface/FileInPath.h"
0014
0015 class BackgroundFunction : public BaseFunction {
0016 public:
0017
0018
0019
0020
0021
0022
0023 BackgroundFunction(TString identifier) {
0024 identifier.Prepend("MuonAnalysis/MomentumScaleCalibration/data/");
0025 identifier.Append(".txt");
0026 edm::FileInPath fileWithFullPath(identifier.Data());
0027 readParameters(fileWithFullPath.fullPath());
0028
0029 std::vector<int>::const_iterator idIt = functionId_.begin();
0030 for (; idIt != functionId_.end(); ++idIt)
0031 std::cout << "idIt = " << *idIt << std::endl;
0032 }
0033
0034
0035
0036
0037
0038
0039 BackgroundFunction(const MuScleFitDBobject* dbObject) : BaseFunction(dbObject) {
0040 std::vector<int>::const_iterator id = functionId_.begin();
0041 for (; id != functionId_.end(); ++id) {
0042
0043 backgroundFunctionVec_.push_back(backgroundFunctionService(*id, 0., 200.));
0044 }
0045
0046 convertToArrays(backgroundFunction_, backgroundFunctionVec_);
0047 }
0048
0049 ~BackgroundFunction() {
0050 if (parArray_ != nullptr) {
0051 for (unsigned int i = 0; i < functionId_.size(); ++i) {
0052 delete[] parArray_[i];
0053 delete backgroundFunction_[i];
0054 }
0055 delete[] parArray_;
0056 delete[] backgroundFunction_;
0057 }
0058 }
0059
0060 backgroundFunctionBase* function(const unsigned int i) {
0061 if (backgroundFunctionVec_.size() > i)
0062 return backgroundFunction_[i];
0063 else
0064 return nullptr;
0065 }
0066
0067 protected:
0068
0069 void readParameters(TString fileName);
0070
0071 backgroundFunctionBase** backgroundFunction_;
0072 std::vector<backgroundFunctionBase*> backgroundFunctionVec_;
0073 };
0074
0075 #endif