CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch1/src/MuonAnalysis/MomentumScaleCalibration/interface/BackgroundHandler.h

Go to the documentation of this file.
00001 #ifndef BackgroundHandler_h
00002 #define BackgroundHandler_h
00003 
00004 #include "MuonAnalysis/MomentumScaleCalibration/interface/Functions.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 #include <vector>
00007 #include "MuonAnalysis/MomentumScaleCalibration/interface/MuScleFitUtils.h"
00008 #include "MuonAnalysis/MomentumScaleCalibration/interface/MassWindow.h"
00009 
00019 class BackgroundHandler
00020 {
00021 public:
00022   BackgroundHandler( const std::vector<int> & identifiers,
00023                      const std::vector<double> & leftWindowBorders,
00024                      const std::vector<double> & rightWindowBorders,
00025                      const double * ResMass,
00026                      const double * massWindowHalfWidth );
00027   ~BackgroundHandler();
00028 
00030   void initializeParNums();
00031 
00033   inline int regionsParNum()
00034   {
00035     return parNumsResonances_[0];
00036   }
00037 
00039   bool checkBackgroundWindow(const double & mass, const int iRegion)
00040   {
00041     return backgroundWindow_[iRegion].isIn(mass);
00042   }
00043 
00044   void countEventsInAllWindows(const std::vector<std::pair<reco::Particle::LorentzVector,reco::Particle::LorentzVector> > & muonPairs,
00045                                const double & weight);
00046 
00048   void setParameters(double* Start, double* Step, double* Mini, double* Maxi, int* ind, TString* parname, const std::vector<double> & parBgr, const std::vector<int> & parBgrOrder, const int muonType);
00049 
00051   bool unlockParameter(const std::vector<int> & resfind, const unsigned int ipar);
00052 
00054   std::pair<double, double> windowBorders( const bool doBackgroundFit, const int ires );
00055 
00061   double resMass( const bool doBackgroundFit, const int ires );
00062 
00069   void rescale( std::vector<double> & parBgr, const double * ResMass, const double * massWindowHalfWidth,
00070                 const std::vector<std::pair<reco::Particle::LorentzVector,reco::Particle::LorentzVector> > & muonPairs,
00071                 const double & weight = 1. );
00072 
00078   std::pair<double, double> backgroundFunction( const bool doBackgroundFit,
00079                                                 const double * parval, const int resTotNum, const int ires,
00080                                                 const bool * resConsidered, const double * ResMass, const double ResHalfWidth[],
00081                                                 const int MuonType, const double & mass, const double & resEta );
00082 private:
00084   void consistencyCheck( const std::vector<int> & identifiers,
00085                          const std::vector<double> & leftWindowBorders,
00086                          const std::vector<double> & rightWindowBorders ) const throw(cms::Exception);
00087 
00088   // Correspondence between regions and halfWidths used:
00089   // - for the Upsilons region we use the Upsilon
00090   // - for the J/Psi and Psi2S region we use the J/Psi
00091   int regToResHW_[3];
00092 
00093   // Correspondence between resonances and regions:
00094   // - Z -> region 0
00095   // - Uspilons -> region 1
00096   // - J/Psi and Psi2S -> region 2
00097   int resToReg_[6];
00098 
00099   // Used in the shifts of the parval
00100   // Contains 0 as the first number and Sum_0^(ires-1)(parNum(i)) for the rest,
00101   // so that calling parNums[ires] returns the sum of the number of parameters
00102   // of the previous functions (0 if none) and allows to shift the parval to the
00103   // parameters of the actual function.
00104   int parNumsRegions_[3];
00105   // These start from the correct parameters (take into account that the parRegions are
00106   // before the parResonances).
00107   int parNumsResonances_[6];
00108 
00109   // std::vector<double> leftWindowFactors_;
00110   // std::vector<double> rightWindowFactors_;
00111 
00112   std::vector<MassWindow> resonanceWindow_;
00113   std::vector<MassWindow> backgroundWindow_;
00114 };
00115 
00116 #endif // BackgroundHandler_h