CMS 3D CMS Logo

L1TkElectronTrackMatchAlgo.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 //
12 // system include files
13 #include <memory>
14 #include <cmath>
15 
19 
20  float constexpr max_eb_eta = 1.479;
21  float constexpr max_eb_z = 315.4;
22  float constexpr eb_rperp = 129.0;
23  // ------------ match EGamma and Track
25  const edm::Ptr<L1TTTrackType>& pTrk,
26  double& dph,
27  double& dr,
28  double& deta) {
29  GlobalPoint egPos = L1TkElectronTrackMatchAlgo::calorimeterPosition(egIter->phi(), egIter->eta(), egIter->energy());
30  dph = L1TkElectronTrackMatchAlgo::deltaPhi(egPos, pTrk);
32  deta = L1TkElectronTrackMatchAlgo::deltaEta(egPos, pTrk);
33  }
34  // ------------ match EGamma and Track
36  const edm::Ptr<L1TTTrackType>& pTrk,
37  double& dph,
38  double& dr,
39  double& deta) {
40  GlobalPoint egPos = L1TkElectronTrackMatchAlgo::calorimeterPosition(egIter->phi(), egIter->eta(), egIter->energy());
43  deta = L1TkElectronTrackMatchAlgo::deltaEta(egPos, pTrk);
44  }
45  // ------------ match EGamma and Track
46  void doMatch(const GlobalPoint& epos, const edm::Ptr<L1TTTrackType>& pTrk, double& dph, double& dr, double& deta) {
47  dph = L1TkElectronTrackMatchAlgo::deltaPhi(epos, pTrk);
49  deta = L1TkElectronTrackMatchAlgo::deltaEta(epos, pTrk);
50  }
51  // --------------- calculate deltaR between Track and EGamma object
52  double deltaPhi(const GlobalPoint& epos, const edm::Ptr<L1TTTrackType>& pTrk) {
53  double er = epos.perp();
54  double curv = pTrk->rInv();
55 
56  double dphi_curv = (asin(er * curv / (2.0)));
57  double trk_phi_ecal = reco::deltaPhi(pTrk->momentum().phi(), dphi_curv);
58 
59  double dphi = reco::deltaPhi(trk_phi_ecal, epos.phi());
60  return dphi;
61  }
62  // --------------- use cluster et to extrapolate tracks
64  GlobalPoint epos = L1TkElectronTrackMatchAlgo::calorimeterPosition(egIter->phi(), egIter->eta(), egIter->energy());
65  double er = epos.perp();
66  double et = egIter->et();
67  double pt = pTrk->momentum().perp();
68  double curv = pTrk->rInv();
69 
70  double dphi_curv = (asin(er * curv * pt / (2.0 * et)));
71  double trk_phi_ecal = reco::deltaPhi(pTrk->momentum().phi(), dphi_curv);
72 
73  double dphi = reco::deltaPhi(trk_phi_ecal, epos.phi());
74  return dphi;
75  }
76  // --------------- calculate deltaPhi between Track and EGamma object
77  double deltaR(const GlobalPoint& epos, const edm::Ptr<L1TTTrackType>& pTrk) {
78  //double dPhi = fabs(reco::deltaPhi(epos.phi(), pTrk->momentum().phi()));
79  double dPhi = L1TkElectronTrackMatchAlgo::deltaPhi(epos, pTrk);
80  double dEta = deltaEta(epos, pTrk);
81  return sqrt(dPhi * dPhi + dEta * dEta);
82  }
83  // --------------- calculate deltaEta between Track and EGamma object
84  double deltaEta(const GlobalPoint& epos, const edm::Ptr<L1TTTrackType>& pTrk) {
85  double corr_eta = 999.0;
86  double er = epos.perp();
87  double ez = epos.z();
88  double z0 = pTrk->POCA().z();
89  double theta = 0.0;
90  if (ez - z0 >= 0)
91  theta = atan(er / fabs(ez - z0));
92  else
93  theta = M_PI - atan(er / fabs(ez - z0));
94  corr_eta = -1.0 * log(tan(theta / 2.0));
95  double deleta = (corr_eta - pTrk->momentum().eta());
96  return deleta;
97  }
98  // -------------- get Calorimeter position
99  GlobalPoint calorimeterPosition(double phi, double eta, double e) {
100  double x = 0.;
101  double y = 0.;
102  double z = 0.;
103  double depth = 0.89 * (7.7 + log(e));
104  double theta = 2 * atan(exp(-1 * eta));
105  double r = 0;
106  if (fabs(eta) > max_eb_eta) {
107  double ecalZ = max_eb_z * fabs(eta) / eta;
108 
109  r = ecalZ / cos(2 * atan(exp(-1 * eta))) + depth;
110  x = r * cos(phi) * sin(theta);
111  y = r * sin(phi) * sin(theta);
112  z = r * cos(theta);
113  } else {
114  double zface = sqrt(cos(theta) * cos(theta) / (1 - cos(theta) * cos(theta)) * eb_rperp * eb_rperp);
115  r = sqrt(eb_rperp * eb_rperp + zface * zface) + depth;
116  x = r * cos(phi) * sin(theta);
117  y = r * sin(phi) * sin(theta);
118  z = r * cos(theta);
119  }
120  GlobalPoint pos(x, y, z);
121  return pos;
122  }
123 
124 } // namespace L1TkElectronTrackMatchAlgo
L1TkElectronTrackMatchAlgo
Definition: L1TkElectronTrackMatchAlgo.h:8
L1TkElectronTrackMatchAlgo::deltaPhi
double deltaPhi(const GlobalPoint &epos, const edm::Ptr< L1TTTrackType > &pTrk)
Definition: L1TkElectronTrackMatchAlgo.cc:52
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
reco::deltaPhi
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
BXVector::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: BXVector.h:18
pos
Definition: PixelAliasList.h:18
L1TkElectronTrackMatchAlgo::deltaR
double deltaR(const GlobalPoint &epos, const edm::Ptr< L1TTTrackType > &pTrk)
Definition: L1TkElectronTrackMatchAlgo.cc:77
L1TkElectronTrackMatchAlgo.h
HLT_2018_cff.dEta
dEta
Definition: HLT_2018_cff.py:12289
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
PVValHelper::eta
Definition: PVValidationHelpers.h:69
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
L1TkElectronTrackMatchAlgo::doMatchClusterET
void doMatchClusterET(BXVector< l1t::EGamma >::const_iterator egIter, const edm::Ptr< L1TTTrackType > &pTrk, double &dph, double &dr, double &deta)
HLT_2018_cff.dPhi
dPhi
Definition: HLT_2018_cff.py:12290
L1TkElectronTrackMatchAlgo::doMatch
void doMatch(BXVector< l1t::EGamma >::const_iterator egIter, const edm::Ptr< L1TTTrackType > &pTrk, double &dph, double &dr, double &deta)
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
HLTMuonOfflineAnalyzer_cfi.z0
z0
Definition: HLTMuonOfflineAnalyzer_cfi.py:98
Point3DBase< float, GlobalTag >
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
L1TkElectronTrackMatchAlgo::eb_rperp
constexpr float eb_rperp
Definition: L1TkElectronTrackMatchAlgo.cc:22
L1TkElectronTrackMatchAlgo::deltaEta
double deltaEta(const GlobalPoint &epos, const edm::Ptr< L1TTTrackType > &pTrk)
Definition: L1TkElectronTrackMatchAlgo.cc:84
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
L1TkElectronTrackMatchAlgo::max_eb_z
constexpr float max_eb_z
Definition: L1TkElectronTrackMatchAlgo.cc:21
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:50
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
edm::Ptr
Definition: AssociationVector.h:31
alignCSCRings.r
r
Definition: alignCSCRings.py:93
L1TkElectronTrackMatchAlgo::max_eb_eta
constexpr float max_eb_eta
Definition: L1TkElectronTrackMatchAlgo.cc:20
flavorHistoryFilter_cfi.dr
dr
Definition: flavorHistoryFilter_cfi.py:37
L1TkElectronTrackMatchAlgo::calorimeterPosition
GlobalPoint calorimeterPosition(double phi, double eta, double e)
Definition: L1TkElectronTrackMatchAlgo.cc:99
L1TkElectronTrackMatchAlgo::deltaPhiClusterET
double deltaPhiClusterET(BXVector< l1t::EGamma >::const_iterator egIter, const edm::Ptr< L1TTTrackType > &pTrk)
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
deltaPhi.h
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37