CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/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/MassWindow.h"
00008 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
00009 #include "SimDataFormats/Track/interface/SimTrack.h"
00010 #include "DataFormats/Candidate/interface/LeafCandidate.h"
00011 #include "DataFormats/Math/interface/LorentzVector.h"
00012 #include <CLHEP/Vector/LorentzVector.h>
00013 #include "DataFormats/MuonReco/interface/Muon.h"
00014 #include "DataFormats/MuonReco/interface/MuonFwd.h"
00015 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
00016 #include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
00017 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
00018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00019 
00029 class BackgroundHandler
00030 {
00031 public:
00032   BackgroundHandler( const std::vector<int> & identifiers,
00033                      const std::vector<double> & leftWindowBorders,
00034                      const std::vector<double> & rightWindowBorders,
00035                      const double * ResMass,
00036                      const double * massWindowHalfWidth );
00037   ~BackgroundHandler();
00038 
00040   void initializeParNums();
00041 
00043   inline int regionsParNum()
00044   {
00045     return parNumsResonances_[0];
00046   }
00047 
00049   bool checkBackgroundWindow(const double & mass, const int iRegion)
00050   {
00051     return backgroundWindow_[iRegion].isIn(mass);
00052   }
00053 
00054   void countEventsInAllWindows(const std::vector<std::pair<reco::Particle::LorentzVector,reco::Particle::LorentzVector> > & muonPairs,
00055                                const double & weight);
00056 
00058   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);
00059 
00061   bool unlockParameter(const std::vector<int> & resfind, const unsigned int ipar);
00062 
00064   std::pair<double, double> windowBorders( const bool doBackgroundFit, const int ires );
00065 
00071   double resMass( const bool doBackgroundFit, const int ires );
00072 
00079   void rescale( std::vector<double> & parBgr, const double * ResMass, const double * massWindowHalfWidth,
00080                 const std::vector<std::pair<reco::Particle::LorentzVector,reco::Particle::LorentzVector> > & muonPairs,
00081                 const double & weight = 1. );
00082 
00088   std::pair<double, double> backgroundFunction( const bool doBackgroundFit,
00089                                                 const double * parval, const int resTotNum, const int ires,
00090                                                 const bool * resConsidered, const double * ResMass, const double ResHalfWidth[],
00091                                                 /* const int MuonType, const double & mass, const double & resEta ); */
00092                                                 const int MuonType, const double & mass, const double & eta1, const double & eta2 );
00093 private:
00095   void consistencyCheck( const std::vector<int> & identifiers,
00096                          const std::vector<double> & leftWindowBorders,
00097                          const std::vector<double> & rightWindowBorders ) const throw(cms::Exception);
00098 
00099   // Correspondence between regions and halfWidths used:
00100   // - for the Upsilons region we use the Upsilon
00101   // - for the J/Psi and Psi2S region we use the J/Psi
00102   int regToResHW_[3];
00103 
00104   // Correspondence between resonances and regions:
00105   // - Z -> region 0
00106   // - Uspilons -> region 1
00107   // - J/Psi and Psi2S -> region 2
00108   int resToReg_[6];
00109 
00110   // Used in the shifts of the parval
00111   // Contains 0 as the first number and Sum_0^(ires-1)(parNum(i)) for the rest,
00112   // so that calling parNums[ires] returns the sum of the number of parameters
00113   // of the previous functions (0 if none) and allows to shift the parval to the
00114   // parameters of the actual function.
00115   int parNumsRegions_[3];
00116   // These start from the correct parameters (take into account that the parRegions are
00117   // before the parResonances).
00118   int parNumsResonances_[6];
00119 
00120   // std::vector<double> leftWindowFactors_;
00121   // std::vector<double> rightWindowFactors_;
00122 
00123   std::vector<MassWindow> resonanceWindow_;
00124   std::vector<MassWindow> backgroundWindow_;
00125 };
00126 
00127 #endif // BackgroundHandler_h