CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
BackgroundHandler.h
Go to the documentation of this file.
1 #ifndef BackgroundHandler_h
2 #define BackgroundHandler_h
3 
6 #include <vector>
9 
20 {
21 public:
22  BackgroundHandler( const std::vector<int> & identifiers,
23  const std::vector<double> & leftWindowBorders,
24  const std::vector<double> & rightWindowBorders,
25  const double * ResMass,
26  const double * massWindowHalfWidth );
28 
30  void initializeParNums();
31 
33  inline int regionsParNum()
34  {
35  return parNumsResonances_[0];
36  }
37 
39  bool checkBackgroundWindow(const double & mass, const int iRegion)
40  {
41  return backgroundWindow_[iRegion].isIn(mass);
42  }
43 
44  void countEventsInAllWindows(const std::vector<std::pair<reco::Particle::LorentzVector,reco::Particle::LorentzVector> > & muonPairs,
45  const double & weight);
46 
48  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);
49 
51  bool unlockParameter(const std::vector<int> & resfind, const unsigned int ipar);
52 
54  std::pair<double, double> windowBorders( const bool doBackgroundFit, const int ires );
55 
61  double resMass( const bool doBackgroundFit, const int ires );
62 
69  void rescale( std::vector<double> & parBgr, const double * ResMass, const double * massWindowHalfWidth,
70  const std::vector<std::pair<reco::Particle::LorentzVector,reco::Particle::LorentzVector> > & muonPairs,
71  const double & weight = 1. );
72 
78  std::pair<double, double> backgroundFunction( const bool doBackgroundFit,
79  const double * parval, const int resTotNum, const int ires,
80  const bool * resConsidered, const double * ResMass, const double ResHalfWidth[],
81  const int MuonType, const double & mass, const double & resEta );
82 private:
84  void consistencyCheck( const std::vector<int> & identifiers,
85  const std::vector<double> & leftWindowBorders,
86  const std::vector<double> & rightWindowBorders ) const throw(cms::Exception);
87 
88  // Correspondence between regions and halfWidths used:
89  // - for the Upsilons region we use the Upsilon
90  // - for the J/Psi and Psi2S region we use the J/Psi
91  int regToResHW_[3];
92 
93  // Correspondence between resonances and regions:
94  // - Z -> region 0
95  // - Uspilons -> region 1
96  // - J/Psi and Psi2S -> region 2
97  int resToReg_[6];
98 
99  // Used in the shifts of the parval
100  // Contains 0 as the first number and Sum_0^(ires-1)(parNum(i)) for the rest,
101  // so that calling parNums[ires] returns the sum of the number of parameters
102  // of the previous functions (0 if none) and allows to shift the parval to the
103  // parameters of the actual function.
105  // These start from the correct parameters (take into account that the parRegions are
106  // before the parResonances).
108 
109  // std::vector<double> leftWindowFactors_;
110  // std::vector<double> rightWindowFactors_;
111 
112  std::vector<MassWindow> resonanceWindow_;
113  std::vector<MassWindow> backgroundWindow_;
114 };
115 
116 #endif // BackgroundHandler_h
std::vector< MassWindow > backgroundWindow_
int regionsParNum()
Returns the total number of parameters used for the regions.
std::vector< MassWindow > resonanceWindow_
std::pair< double, double > backgroundFunction(const bool doBackgroundFit, const double *parval, const int resTotNum, const int ires, const bool *resConsidered, const double *ResMass, const double ResHalfWidth[], const int MuonType, const double &mass, const double &resEta)
void rescale(std::vector< double > &parBgr, const double *ResMass, const double *massWindowHalfWidth, const std::vector< std::pair< reco::Particle::LorentzVector, reco::Particle::LorentzVector > > &muonPairs, const double &weight=1.)
double resMass(const bool doBackgroundFit, const int ires)
void consistencyCheck(const std::vector< int > &identifiers, const std::vector< double > &leftWindowBorders, const std::vector< double > &rightWindowBorders) const
Used to check the consistency of passed parameters.
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)
Sets initial parameters for all the functions.
std::pair< double, double > windowBorders(const bool doBackgroundFit, const int ires)
Returns the appropriate window borders depending on whether the background is being fitted and on the...
bool unlockParameter(const std::vector< int > &resfind, const unsigned int ipar)
returns true if the parameter is to be unlocked
void countEventsInAllWindows(const std::vector< std::pair< reco::Particle::LorentzVector, reco::Particle::LorentzVector > > &muonPairs, const double &weight)
bool checkBackgroundWindow(const double &mass, const int iRegion)
Check if the mass value is inside the given background region.
BackgroundHandler(const std::vector< int > &identifiers, const std::vector< double > &leftWindowBorders, const std::vector< double > &rightWindowBorders, const double *ResMass, const double *massWindowHalfWidth)
void initializeParNums()
Initialize the parNums to be used in the shifts of parval.