CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/MuonAnalysis/MomentumScaleCalibration/interface/BackgroundFunction.h

Go to the documentation of this file.
00001 
00006 #ifndef BackgroundFunction_h
00007 #define BackgroundFunction_h
00008 
00009 #include <fstream>
00010 #include <sstream>
00011 #include "MuonAnalysis/MomentumScaleCalibration/interface/BaseFunction.h"
00012 #include "MuonAnalysis/MomentumScaleCalibration/interface/Functions.h"
00013 #include "FWCore/ParameterSet/interface/FileInPath.h"
00014 
00015 class BackgroundFunction : public BaseFunction
00016 {
00017 public:
00024   BackgroundFunction( TString identifier )
00025   {
00026     identifier.Prepend("MuonAnalysis/MomentumScaleCalibration/data/");
00027     identifier.Append(".txt");
00028     edm::FileInPath fileWithFullPath(identifier.Data());
00029     readParameters( fileWithFullPath.fullPath() );
00030 
00031     std::vector<int>::const_iterator idIt = functionId_.begin();
00032     for( ; idIt != functionId_.end(); ++idIt ) std::cout << "idIt = " << *idIt << std::endl;
00033   }
00040   BackgroundFunction( const MuScleFitDBobject * dbObject ) : BaseFunction( dbObject )
00041   {
00042     std::vector<int>::const_iterator id = functionId_.begin();
00043     for( ; id != functionId_.end(); ++id ) {
00044       // TODO: fix the values for the lower and upper limits
00045       backgroundFunctionVec_.push_back( backgroundFunctionService( *id , 0., 200. ) );
00046     }
00047     // Fill the arrays that will be used when calling the correction function.
00048     convertToArrays(backgroundFunction_, backgroundFunctionVec_);
00049   }
00050 
00051   ~BackgroundFunction() {
00052     if( parArray_ != 0 ) {
00053       for( unsigned int i=0; i<functionId_.size(); ++i ) {
00054         delete[] parArray_[i];
00055         delete backgroundFunction_[i];
00056       }
00057       delete[] parArray_;
00058       delete[] backgroundFunction_;
00059     }
00060   }
00062   backgroundFunctionBase * function( const unsigned int i )
00063   {
00064     if( backgroundFunctionVec_.size() > i ) return backgroundFunction_[i];
00065     else return 0;
00066   }
00067 
00068 protected:
00070   void readParameters( TString fileName );
00071 
00072   backgroundFunctionBase ** backgroundFunction_;
00073   std::vector<backgroundFunctionBase * > backgroundFunctionVec_;
00074 };
00075 
00076 #endif // BackgroundFunction_h