File indexing completed on 2024-04-06 12:22:36
0001 #ifndef BackgroundHandler_h
0002 #define BackgroundHandler_h
0003
0004 #include "MuonAnalysis/MomentumScaleCalibration/interface/Functions.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include <vector>
0007 #include "MuonAnalysis/MomentumScaleCalibration/interface/MassWindow.h"
0008 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
0009 #include "SimDataFormats/Track/interface/SimTrack.h"
0010 #include "DataFormats/Candidate/interface/LeafCandidate.h"
0011 #include "DataFormats/Math/interface/LorentzVector.h"
0012 #include <CLHEP/Vector/LorentzVector.h>
0013 #include "DataFormats/MuonReco/interface/Muon.h"
0014 #include "DataFormats/MuonReco/interface/MuonFwd.h"
0015 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
0016 #include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
0017 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
0018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0019
0020
0021 class TestBackgroundHandler;
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 class BackgroundHandler {
0033
0034 friend class TestBackgroundHandler;
0035
0036 public:
0037 BackgroundHandler(const std::vector<int>& identifiers,
0038 const std::vector<double>& leftWindowBorders,
0039 const std::vector<double>& rightWindowBorders,
0040 const double* ResMass,
0041 const double* massWindowHalfWidth);
0042 ~BackgroundHandler();
0043
0044
0045 void initializeParNums();
0046
0047
0048 inline int regionsParNum() { return parNumsResonances_[0]; }
0049
0050
0051 bool checkBackgroundWindow(const double& mass, const int iRegion) { return backgroundWindow_[iRegion].isIn(mass); }
0052
0053 void countEventsInAllWindows(
0054 const std::vector<std::pair<reco::Particle::LorentzVector, reco::Particle::LorentzVector> >& muonPairs,
0055 const double& weight);
0056
0057
0058 void setParameters(double* Start,
0059 double* Step,
0060 double* Mini,
0061 double* Maxi,
0062 int* ind,
0063 TString* parname,
0064 const std::vector<double>& parBgr,
0065 const std::vector<int>& parBgrOrder,
0066 const int muonType);
0067
0068
0069 bool unlockParameter(const std::vector<int>& resfind, const unsigned int ipar);
0070
0071
0072 std::pair<double, double> windowBorders(const bool doBackgroundFit, const int ires);
0073
0074
0075
0076
0077
0078
0079 double resMass(const bool doBackgroundFit, const int ires);
0080
0081
0082
0083
0084
0085
0086
0087 void rescale(std::vector<double>& parBgr,
0088 const double* ResMass,
0089 const double* massWindowHalfWidth,
0090 const std::vector<std::pair<reco::Particle::LorentzVector, reco::Particle::LorentzVector> >& muonPairs,
0091 const double& weight = 1.);
0092
0093
0094
0095
0096
0097
0098 std::pair<double, double> backgroundFunction(const bool doBackgroundFit,
0099 const double* parval,
0100 const int resTotNum,
0101 const int ires,
0102 const bool* resConsidered,
0103 const double* ResMass,
0104 const double ResHalfWidth[],
0105
0106 const int MuonType,
0107 const double& mass,
0108 const double& eta1,
0109 const double& eta2);
0110
0111 private:
0112
0113 void consistencyCheck(const std::vector<int>& identifiers,
0114 const std::vector<double>& leftWindowBorders,
0115 const std::vector<double>& rightWindowBorders) const noexcept(false);
0116
0117
0118
0119
0120 int regToResHW_[3];
0121
0122
0123
0124
0125
0126 int resToReg_[6];
0127
0128
0129
0130
0131
0132
0133 int parNumsRegions_[3];
0134
0135
0136 int parNumsResonances_[6];
0137
0138
0139
0140
0141 std::vector<MassWindow> resonanceWindow_;
0142 std::vector<MassWindow> backgroundWindow_;
0143 };
0144
0145 #endif