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
T z() const
Definition: PV3DBase.h:61
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
static constexpr float R_ECAL
#define ETA
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
static constexpr float etaBarrelEndcap
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
double ecalEta(const math::XYZVector &momentum, const math::XYZPoint &vertex)
Log< level::Warning, false > LogWarning
constexpr double pi()
Definition: Pi.h:31
constexpr double twoPi()
Definition: Pi.h:32
Geom::Theta< T > theta() const
static constexpr float Z_Endcap
double ecalPhi(const MagneticField &magField, const math::XYZVector &momentum, const math::XYZPoint &vertex, const int charge)