CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ECALPositionCalculator.cc
Go to the documentation of this file.
1 
3 
4 // Framework includes
9 
10 static const float R_ECAL = 136.5;
11 static const float Z_Endcap = 328.0;
12 static const float etaBarrelEndcap = 1.479;
13 
14 double ECALPositionCalculator::ecalPhi(const MagneticField *magField,const math::XYZVector &momentum, const math::XYZPoint &vertex, int charge)
15 {
16 
17  // Get kinematic variables
18 
19  float ptParticle = momentum.Rho();
20  float etaParticle = momentum.eta();
21  float phiParticle = momentum.phi();
22  float vRho = vertex.Rho();
23 
24  // Magnetic field
25 
26  const float RBARM = 1.357 ; // was 1.31 , updated on 16122003
27  const float ZENDM = 3.186 ; // was 3.15 , updated on 16122003
28 
29  float rbend = RBARM-(vRho/100.0); //Assumed vRho in cm
30  float bend = 0.3 * magField->inTesla(GlobalPoint(0.,0.,0.)).z() * rbend / 2.0;
31  float phi = 0.0;
32 
33  if( fabs(etaParticle) <= etaBarrelEndcap)
34  {
35  if (fabs(bend/ptParticle) <= 1.)
36  {
37  phi = phiParticle - asin(bend/ptParticle)*charge;
38  if(phi > Geom::pi()) phi = phi - Geom::twoPi();
39  if(phi < -Geom::pi()) phi = phi + Geom::twoPi();
40  } else {
41  edm::LogWarning("") << "[EcalPositionFromTrack::phiTransformation] Warning: "
42  << "Too low Pt, giving up";
43  return phiParticle;
44  }
45 
46  } // end if in the barrel
47 
48  if(fabs(etaParticle) > etaBarrelEndcap)
49  {
50  float rHit = 0.0;
51  rHit = ZENDM / sinh(fabs(etaParticle));
52  if (fabs(((rHit-(vRho/100.0))/rbend)*bend/ptParticle) <= 1.0)
53  {
54  phi = phiParticle - asin(((rHit-(vRho/100.0)) / rbend)*bend/ptParticle)*charge;
55  if(phi > Geom::pi()) phi = phi - Geom::twoPi();
56  if(phi < -Geom::pi()) phi = phi + Geom::twoPi();
57  } else {
58  edm::LogWarning("") << "[EcalPositionFromTrack::phiTransformation] Warning: "
59  << "Too low Pt, giving up";
60  return phiParticle;
61  }
62 
63  } // end if in the endcap
64 
65  return phi;
66 
67 }
68 
69 double ECALPositionCalculator::ecalEta(const math::XYZVector &momentum, const math::XYZPoint &vertex)
70 {
71 
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  {
80  float theta = 0.0;
81  float zEcal = (R_ECAL-vRho)*sinh(etaParticle)+vZ;
82 
83  if(zEcal != 0.0) theta = atan(R_ECAL/zEcal);
84  if(theta < 0.0) theta = theta + Geom::pi() ;
85 
86  float ETA = - log(tan(0.5*theta));
87 
88  if( fabs(ETA) > etaBarrelEndcap )
89  {
90  float Zend = Z_Endcap ;
91  if(etaParticle < 0.0 ) Zend = - Zend;
92  float Zlen = Zend - vZ ;
93  float RR = Zlen/sinh(etaParticle);
94  theta = atan((RR+vRho)/Zend);
95  if(theta < 0.0) theta = theta+Geom::pi();
96  ETA = -log(tan(0.5*theta));
97  }
98  return ETA;
99 
100  } else {
101  edm::LogWarning("") << "[EcalPositionFromTrack::etaTransformation] Warning: "
102  << "Eta equals to zero, not correcting";
103  return etaParticle;
104  }
105 
106 }
107 
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Geom::Theta< T > theta() const
double ecalEta(const math::XYZVector &momentum, const math::XYZPoint &vertex)
double ecalPhi(const MagneticField *magField, const math::XYZVector &momentum, const math::XYZPoint &vertex, const int charge)
#define ETA
T z() const
Definition: PV3DBase.h:64
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
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
static const float etaBarrelEndcap
static const float Z_Endcap
double pi()
Definition: Pi.h:31
double twoPi()
Definition: Pi.h:32
static const float R_ECAL