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 {
17 public:
24  BackgroundFunction( 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  BackgroundFunction( const MuScleFitDBobject * dbObject ) : BaseFunction( dbObject )
41  {
42  std::vector<int>::const_iterator id = functionId_.begin();
43  for( ; id != functionId_.end(); ++id ) {
44  // TODO: fix the values for the lower and upper limits
45  backgroundFunctionVec_.push_back( backgroundFunctionService( *id , 0., 200. ) );
46  }
47  // Fill the arrays that will be used when calling the correction function.
49  }
50 
52  if( parArray_ != 0 ) {
53  for( unsigned int i=0; i<functionId_.size(); ++i ) {
54  delete[] parArray_[i];
55  delete backgroundFunction_[i];
56  }
57  delete[] parArray_;
58  delete[] backgroundFunction_;
59  }
60  }
62  backgroundFunctionBase * function( const unsigned int i )
63  {
64  if( backgroundFunctionVec_.size() > i ) return backgroundFunction_[i];
65  else return 0;
66  }
67 
68 protected:
70  void readParameters( TString fileName );
71 
73  std::vector<backgroundFunctionBase * > backgroundFunctionVec_;
74 };
75 
76 #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:56
BackgroundFunction(const MuScleFitDBobject *dbObject)
std::vector< backgroundFunctionBase * > backgroundFunctionVec_
std::vector< int > functionId_
Definition: BaseFunction.h:46
void readParameters(TString fileName)
Parser of the parameters file.
backgroundFunctionBase ** backgroundFunction_
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:62
BackgroundFunction(TString identifier)
double ** parArray_
Definition: BaseFunction.h:50