CMS 3D CMS Logo

BackgroundHandler.h
Go to the documentation of this file.
1 #ifndef BackgroundHandler_h
2 #define BackgroundHandler_h
3 
6 #include <vector>
12 #include <CLHEP/Vector/LorentzVector.h>
19 
20 // Unit test for testing BackgroundHandler
21 class TestBackgroundHandler;
22 
33  // For tests
34  friend class TestBackgroundHandler;
35 
36 public:
37  BackgroundHandler(const std::vector<int>& identifiers,
38  const std::vector<double>& leftWindowBorders,
39  const std::vector<double>& rightWindowBorders,
40  const double* ResMass,
41  const double* massWindowHalfWidth);
43 
45  void initializeParNums();
46 
48  inline int regionsParNum() { return parNumsResonances_[0]; }
49 
51  bool checkBackgroundWindow(const double& mass, const int iRegion) { return backgroundWindow_[iRegion].isIn(mass); }
52 
54  const std::vector<std::pair<reco::Particle::LorentzVector, reco::Particle::LorentzVector> >& muonPairs,
55  const double& weight);
56 
58  void setParameters(double* Start,
59  double* Step,
60  double* Mini,
61  double* Maxi,
62  int* ind,
63  TString* parname,
64  const std::vector<double>& parBgr,
65  const std::vector<int>& parBgrOrder,
66  const int muonType);
67 
69  bool unlockParameter(const std::vector<int>& resfind, const unsigned int ipar);
70 
72  std::pair<double, double> windowBorders(const bool doBackgroundFit, const int ires);
73 
79  double resMass(const bool doBackgroundFit, const int ires);
80 
87  void rescale(std::vector<double>& parBgr,
88  const double* ResMass,
89  const double* massWindowHalfWidth,
90  const std::vector<std::pair<reco::Particle::LorentzVector, reco::Particle::LorentzVector> >& muonPairs,
91  const double& weight = 1.);
92 
98  std::pair<double, double> backgroundFunction(const bool doBackgroundFit,
99  const double* parval,
100  const int resTotNum,
101  const int ires,
102  const bool* resConsidered,
103  const double* ResMass,
104  const double ResHalfWidth[],
105  /* const int MuonType, const double & mass, const double & resEta ); */
106  const int MuonType,
107  const double& mass,
108  const double& eta1,
109  const double& eta2);
110 
111 private:
113  void consistencyCheck(const std::vector<int>& identifiers,
114  const std::vector<double>& leftWindowBorders,
115  const std::vector<double>& rightWindowBorders) const noexcept(false);
116 
117  // Correspondence between regions and halfWidths used:
118  // - for the Upsilons region we use the Upsilon
119  // - for the J/Psi and Psi2S region we use the J/Psi
120  int regToResHW_[3];
121 
122  // Correspondence between resonances and regions:
123  // - Z -> region 0
124  // - Uspilons -> region 1
125  // - J/Psi and Psi2S -> region 2
126  int resToReg_[6];
127 
128  // Used in the shifts of the parval
129  // Contains 0 as the first number and Sum_0^(ires-1)(parNum(i)) for the rest,
130  // so that calling parNums[ires] returns the sum of the number of parameters
131  // of the previous functions (0 if none) and allows to shift the parval to the
132  // parameters of the actual function.
134  // These start from the correct parameters (take into account that the parRegions are
135  // before the parResonances).
137 
138  // std::vector<double> leftWindowFactors_;
139  // std::vector<double> rightWindowFactors_;
140 
141  std::vector<MassWindow> resonanceWindow_;
142  std::vector<MassWindow> backgroundWindow_;
143 };
144 
145 #endif // BackgroundHandler_h
Muon.h
MessageLogger.h
BackgroundHandler
Definition: BackgroundHandler.h:32
BackgroundHandler::consistencyCheck
void consistencyCheck(const std::vector< int > &identifiers, const std::vector< double > &leftWindowBorders, const std::vector< double > &rightWindowBorders) const noexcept(false)
Used to check the consistency of passed parameters.
Definition: BackgroundHandler.cc:306
HLT_2018_cff.eta1
eta1
Definition: HLT_2018_cff.py:8220
BackgroundHandler::unlockParameter
bool unlockParameter(const std::vector< int > &resfind, const unsigned int ipar)
returns true if the parameter is to be unlocked
Definition: BackgroundHandler.cc:141
BackgroundHandler::setParameters
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.
Definition: BackgroundHandler.cc:102
BackgroundHandler::countEventsInAllWindows
void countEventsInAllWindows(const std::vector< std::pair< reco::Particle::LorentzVector, reco::Particle::LorentzVector > > &muonPairs, const double &weight)
Definition: BackgroundHandler.cc:280
BackgroundHandler::BackgroundHandler
BackgroundHandler(const std::vector< int > &identifiers, const std::vector< double > &leftWindowBorders, const std::vector< double > &rightWindowBorders, const double *ResMass, const double *massWindowHalfWidth)
Definition: BackgroundHandler.cc:11
GenParticle.h
BackgroundHandler::checkBackgroundWindow
bool checkBackgroundWindow(const double &mass, const int iRegion)
Check if the mass value is inside the given background region.
Definition: BackgroundHandler.h:51
ires
int ires[2]
Definition: CascadeWrapper.h:19
BackgroundHandler::regionsParNum
int regionsParNum()
Returns the total number of parameters used for the regions.
Definition: BackgroundHandler.h:48
BackgroundHandler::initializeParNums
void initializeParNums()
Initialize the parNums to be used in the shifts of parval.
Definition: BackgroundHandler.cc:90
MuonFwd.h
MuScleFitGenFilter_cfi.resfind
resfind
Definition: MuScleFitGenFilter_cfi.py:11
GenParticleFwd.h
LeafCandidate.h
BackgroundHandler::TestBackgroundHandler
friend class TestBackgroundHandler
Definition: BackgroundHandler.h:34
HLT_2018_cff.eta2
eta2
Definition: HLT_2018_cff.py:8221
BackgroundHandler::~BackgroundHandler
~BackgroundHandler()
Definition: BackgroundHandler.cc:88
BackgroundHandler::backgroundFunction
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 &eta1, const double &eta2)
Definition: BackgroundHandler.cc:249
BackgroundHandler::resonanceWindow_
std::vector< MassWindow > resonanceWindow_
Definition: BackgroundHandler.h:141
LorentzVector.h
BackgroundHandler::backgroundWindow_
std::vector< MassWindow > backgroundWindow_
Definition: BackgroundHandler.h:142
BackgroundHandler::parNumsRegions_
int parNumsRegions_[3]
Definition: BackgroundHandler.h:133
BackgroundHandler::parNumsResonances_
int parNumsResonances_[6]
Definition: BackgroundHandler.h:136
BackgroundHandler::windowBorders
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...
Definition: BackgroundHandler.cc:170
MassWindow.h
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
BackgroundHandler::rescale
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.)
Definition: BackgroundHandler.cc:192
BackgroundHandler::resMass
double resMass(const bool doBackgroundFit, const int ires)
Definition: BackgroundHandler.cc:182
Functions.h
SimTrack.h
HepMCProduct.h
SimTrackContainer.h
BackgroundHandler::regToResHW_
int regToResHW_[3]
Definition: BackgroundHandler.h:120
weight
Definition: weight.py:1
BackgroundHandler::resToReg_
int resToReg_[6]
Definition: BackgroundHandler.h:126