CMS 3D CMS Logo

ECALPositionCalculator.cc
Go to the documentation of this file.
1 
3 
4 // Framework includes
9 
10 static constexpr float R_ECAL = 136.5;
11 static constexpr float Z_Endcap = 328.0;
12 static constexpr float etaBarrelEndcap = 1.479;
13 
14 namespace egammaTools {
15 
16  double ecalPhi(const MagneticField &magField,
17  const math::XYZVector &momentum,
18  const math::XYZPoint &vertex,
19  const int charge) {
20  // Get kinematic variables
21 
22  float ptParticle = momentum.Rho();
23  float etaParticle = momentum.eta();
24  float phiParticle = momentum.phi();
25  float vRho = vertex.Rho();
26 
27  // Magnetic field
28 
29  const float RBARM = 1.357; // was 1.31 , updated on 16122003
30  const float ZENDM = 3.186; // was 3.15 , updated on 16122003
31 
32  float rbend = RBARM - (vRho / 100.0); //Assumed vRho in cm
33  float bend = 0.3 * magField.inTesla(GlobalPoint(0., 0., 0.)).z() * rbend / 2.0;
34  float phi = 0.0;
35 
36  if (fabs(etaParticle) <= etaBarrelEndcap) {
37  if (fabs(bend / ptParticle) <= 1.) {
38  phi = phiParticle - asin(bend / ptParticle) * charge;
39  if (phi > Geom::pi())
40  phi = phi - Geom::twoPi();
41  if (phi < -Geom::pi())
42  phi = phi + Geom::twoPi();
43  } else {
44  edm::LogWarning("") << "[EcalPositionFromTrack::phiTransformation] Warning: "
45  << "Too low Pt, giving up";
46  return phiParticle;
47  }
48 
49  } // end if in the barrel
50 
51  if (fabs(etaParticle) > etaBarrelEndcap) {
52  float rHit = 0.0;
53  rHit = ZENDM / sinh(fabs(etaParticle));
54  if (fabs(((rHit - (vRho / 100.0)) / rbend) * bend / ptParticle) <= 1.0) {
55  phi = phiParticle - asin(((rHit - (vRho / 100.0)) / rbend) * bend / ptParticle) * charge;
56  if (phi > Geom::pi())
57  phi = phi - Geom::twoPi();
58  if (phi < -Geom::pi())
59  phi = phi + Geom::twoPi();
60  } else {
61  edm::LogWarning("") << "[EcalPositionFromTrack::phiTransformation] Warning: "
62  << "Too low Pt, giving up";
63  return phiParticle;
64  }
65 
66  } // end if in the endcap
67 
68  return phi;
69  }
70 
71  double ecalEta(const math::XYZVector &momentum, const math::XYZPoint &vertex) {
72  // Get kinematic variables
73 
74  float etaParticle = momentum.eta();
75  float vZ = vertex.z();
76  float vRho = vertex.Rho();
77 
78  if (etaParticle != 0.0) {
79  float theta = 0.0;
80  float zEcal = (R_ECAL - vRho) * sinh(etaParticle) + vZ;
81 
82  if (zEcal != 0.0)
83  theta = atan(R_ECAL / zEcal);
84  if (theta < 0.0)
85  theta = theta + Geom::pi();
86 
87  float ETA = -log(tan(0.5 * theta));
88 
89  if (fabs(ETA) > etaBarrelEndcap) {
90  float Zend = Z_Endcap;
91  if (etaParticle < 0.0)
92  Zend = -Zend;
93  float Zlen = Zend - vZ;
94  float RR = Zlen / sinh(etaParticle);
95  theta = atan((RR + vRho) / Zend);
96  if (theta < 0.0)
97  theta = theta + Geom::pi();
98  ETA = -log(tan(0.5 * theta));
99  }
100  return ETA;
101 
102  } else {
103  edm::LogWarning("") << "[EcalPositionFromTrack::etaTransformation] Warning: "
104  << "Eta equals to zero, not correcting";
105  return etaParticle;
106  }
107  }
108 
109 } // namespace egammaTools
MagneticField::inTesla
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
egammaTools::ecalEta
double ecalEta(const math::XYZVector &momentum, const math::XYZPoint &vertex)
Definition: ECALPositionCalculator.cc:71
MessageLogger.h
ECALPositionCalculator.h
egammaTools::ecalPhi
double ecalPhi(const MagneticField &magField, const math::XYZVector &momentum, const math::XYZPoint &vertex, const int charge)
Definition: ECALPositionCalculator.cc:16
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
Geom::pi
constexpr double pi()
Definition: Pi.h:31
Geom::twoPi
constexpr double twoPi()
Definition: Pi.h:32
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
egammaTools
Definition: EcalClusterLocal.h:14
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
Pi.h
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
MagneticField.h
trklet::bend
double bend(double r, double rinv, double stripPitch)
Definition: Util.h:160
ETA
#define ETA
Definition: GenericBenchmark.cc:28
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
MagneticField
Definition: MagneticField.h:19
GlobalPoint.h
Z_Endcap
static constexpr float Z_Endcap
Definition: ECALPositionCalculator.cc:11
R_ECAL
static constexpr float R_ECAL
Definition: ECALPositionCalculator.cc:10
etaBarrelEndcap
static constexpr float etaBarrelEndcap
Definition: ECALPositionCalculator.cc:12