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,const math::XYZVector &momentum, const math::XYZPoint &vertex, const int charge)
17 {
18 
19  // Get kinematic variables
20 
21  float ptParticle = momentum.Rho();
22  float etaParticle = momentum.eta();
23  float phiParticle = momentum.phi();
24  float vRho = vertex.Rho();
25 
26  // Magnetic field
27 
28  const float RBARM = 1.357 ; // was 1.31 , updated on 16122003
29  const float ZENDM = 3.186 ; // was 3.15 , updated on 16122003
30 
31  float rbend = RBARM-(vRho/100.0); //Assumed vRho in cm
32  float bend = 0.3 * magField.inTesla(GlobalPoint(0.,0.,0.)).z() * rbend / 2.0;
33  float phi = 0.0;
34 
35  if( fabs(etaParticle) <= etaBarrelEndcap)
36  {
37  if (fabs(bend/ptParticle) <= 1.)
38  {
39  phi = phiParticle - asin(bend/ptParticle)*charge;
40  if(phi > Geom::pi()) phi = phi - Geom::twoPi();
41  if(phi < -Geom::pi()) phi = phi + Geom::twoPi();
42  } else {
43  edm::LogWarning("") << "[EcalPositionFromTrack::phiTransformation] Warning: "
44  << "Too low Pt, giving up";
45  return phiParticle;
46  }
47 
48  } // end if in the barrel
49 
50  if(fabs(etaParticle) > etaBarrelEndcap)
51  {
52  float rHit = 0.0;
53  rHit = ZENDM / sinh(fabs(etaParticle));
54  if (fabs(((rHit-(vRho/100.0))/rbend)*bend/ptParticle) <= 1.0)
55  {
56  phi = phiParticle - asin(((rHit-(vRho/100.0)) / rbend)*bend/ptParticle)*charge;
57  if(phi > Geom::pi()) phi = phi - Geom::twoPi();
58  if(phi < -Geom::pi()) phi = phi + Geom::twoPi();
59  } else {
60  edm::LogWarning("") << "[EcalPositionFromTrack::phiTransformation] Warning: "
61  << "Too low Pt, giving up";
62  return phiParticle;
63  }
64 
65  } // end if in the endcap
66 
67  return phi;
68 
69 }
70 
71 double ecalEta(const math::XYZVector &momentum, const math::XYZPoint &vertex)
72 {
73 
74  // Get kinematic variables
75 
76  float etaParticle = momentum.eta();
77  float vZ = vertex.z();
78  float vRho = vertex.Rho();
79 
80  if (etaParticle != 0.0)
81  {
82  float theta = 0.0;
83  float zEcal = (R_ECAL-vRho)*sinh(etaParticle)+vZ;
84 
85  if(zEcal != 0.0) theta = atan(R_ECAL/zEcal);
86  if(theta < 0.0) theta = theta + Geom::pi() ;
87 
88  float ETA = - log(tan(0.5*theta));
89 
90  if( fabs(ETA) > etaBarrelEndcap )
91  {
92  float Zend = Z_Endcap ;
93  if(etaParticle < 0.0 ) Zend = - Zend;
94  float Zlen = Zend - vZ ;
95  float RR = Zlen/sinh(etaParticle);
96  theta = atan((RR+vRho)/Zend);
97  if(theta < 0.0) 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 
110 }
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Geom::Theta< T > theta() const
#define ETA
T z() const
Definition: PV3DBase.h:64
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
static float etaBarrelEndcap
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
double ecalEta(const math::XYZVector &momentum, const math::XYZPoint &vertex)
static float Z_Endcap
constexpr double pi()
Definition: Pi.h:31
constexpr double twoPi()
Definition: Pi.h:32
static float R_ECAL
#define constexpr
double ecalPhi(const MagneticField &magField, const math::XYZVector &momentum, const math::XYZPoint &vertex, const int charge)