CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
GflashTrajectory Class Reference

#include <GflashTrajectory.h>

Public Member Functions

void _cacheSinesAndCosines (double s) const
 
void _refreshCache () const
 
double getCosPhi0 () const
 
double getCosTheta () const
 
double getCotTheta () const
 
double getCurvature () const
 
double getD0 () const
 
HepGeom::Vector3D< double > getDirection (double s=0.0) const
 
void getGflashTrajectoryPoint (GflashTrajectoryPoint &point, double s) const
 
double getL2DAtR (double r) const
 
double getPathLengthAtRhoEquals (double rho) const
 
double getPathLengthAtZ (double z) const
 
double getPhi0 () const
 
HepGeom::Point3D< double > getPosition (double s=0.0) const
 
double getSinPhi0 () const
 
double getSinTheta () const
 
double getZ0 () const
 
double getZAtR (double r) const
 
 GflashTrajectory ()
 
void initializeTrajectory (const HepGeom::Vector3D< double > &, const HepGeom::Point3D< double > &, double q, double Field)
 
void setCotTheta (double cotTheta)
 
void setCurvature (double curvature)
 
void setD0 (double d0)
 
void setPhi0 (double phi0)
 
void setZ0 (double z0)
 
 ~GflashTrajectory ()
 

Private Attributes

double _aa
 
double _cc
 
double _cosPhi0
 
double _cosTheta
 
double _cotTheta
 
double _curvature
 
double _d0
 
bool _isStale
 
double _phi0
 
double _s
 
double _sinPhi0
 
double _sinTheta
 
double _ss
 
double _z0
 

Detailed Description

Definition at line 6 of file GflashTrajectory.h.

Constructor & Destructor Documentation

GflashTrajectory::GflashTrajectory ( )

Definition at line 5 of file GflashTrajectory.cc.

6  :
7  _cotTheta(0.0),_curvature(0.0),_z0(0.0),_d0(0.0),_phi0(0.0),
8  _isStale(1),
10  _s(-999.999),
11  _aa(2),_ss(2),_cc(2)
12 {
13  //detault constructor
14 }
GflashTrajectory::~GflashTrajectory ( )

Definition at line 73 of file GflashTrajectory.cc.

74 {
75 }

Member Function Documentation

void GflashTrajectory::_cacheSinesAndCosines ( double  s) const

Definition at line 257 of file GflashTrajectory.cc.

References _aa, _cc, _curvature, _refreshCache(), _s, _sinTheta, _ss, funct::cos(), alignCSCRings::s, and funct::sin().

Referenced by getDirection(), getGflashTrajectoryPoint(), getPhi0(), and getPosition().

257  {
258  _refreshCache();
259  if (_s!=s){
260  _s=s;
262  if (_aa==0.0) {
263  _ss=0.0;
264  _cc=1.0;
265  }
266  else {
267  _ss=sin(_aa);
268  _cc=cos(_aa);
269  }
270  }
271 }
void _refreshCache() const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
void GflashTrajectory::_refreshCache ( ) const

Definition at line 225 of file GflashTrajectory.cc.

References _cosPhi0, _cosTheta, _cotTheta, _isStale, _phi0, _sinPhi0, _sinTheta, funct::cos(), M_PI, funct::sin(), mathSSE::sqrt(), and theta().

Referenced by _cacheSinesAndCosines(), getCosPhi0(), getCosTheta(), getPhi0(), getSinPhi0(), and getSinTheta().

225  {
226  if (_isStale) {
227  _isStale=false;
228  double theta;
229  if ( _cotTheta==0.0 ) {
230  theta = M_PI/2.0;
231  }
232  else {
233  theta=atan(1.0/_cotTheta);
234  if (theta<0.0) theta+=M_PI;
235  }
236  if (theta==0.0) {
237  _sinTheta=0.0;
238  _cosTheta=1.0;
239  }
240  else {
241  _cosTheta=cos(theta);
243  }
244  if (_phi0==0.0) {
245  _sinPhi0=0.0;
246  _cosPhi0=1.0;
247  }
248  else {
249  _cosPhi0 = cos(_phi0);
250  _sinPhi0 = sin(_phi0);
251  // _sinPhi0 = sqrt(1.0-_cosPhi0*_cosPhi0);
252  // if (_phi0>M_PI) _sinPhi0 = -_sinPhi0;
253  }
254  }
255 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
T sqrt(T t)
Definition: SSEVec.h:18
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
#define M_PI
double GflashTrajectory::getCosPhi0 ( ) const

Definition at line 106 of file GflashTrajectory.cc.

References _cosPhi0, and _refreshCache().

Referenced by getPhi0().

106  {
107  _refreshCache();
108  return _cosPhi0;
109 }
void _refreshCache() const
double GflashTrajectory::getCosTheta ( ) const

Definition at line 114 of file GflashTrajectory.cc.

References _cosTheta, and _refreshCache().

Referenced by getPathLengthAtZ(), and getPhi0().

114  {
115  _refreshCache();
116  return _cosTheta;
117 }
void _refreshCache() const
double GflashTrajectory::getCotTheta ( ) const
inline

Definition at line 21 of file GflashTrajectory.h.

References _cotTheta.

Referenced by getZAtR().

21 { return _cotTheta; }
double GflashTrajectory::getCurvature ( ) const
inline

Definition at line 22 of file GflashTrajectory.h.

References _curvature.

Referenced by getL2DAtR().

22 { return _curvature; }
double GflashTrajectory::getD0 ( ) const
inline

Definition at line 24 of file GflashTrajectory.h.

References _d0.

Referenced by getL2DAtR().

24 { return _d0; };
HepGeom::Vector3D< double > GflashTrajectory::getDirection ( double  s = 0.0) const

Definition at line 135 of file GflashTrajectory.cc.

References _cacheSinesAndCosines(), _cc, _cosPhi0, _cosTheta, _sinPhi0, _sinTheta, and _ss.

Referenced by getPhi0().

136 {
138  if (s==0.0) {
139  return HepGeom::Vector3D<double> (_cosPhi0*_sinTheta,_sinPhi0*_sinTheta,_cosTheta);
140  }
141  double xtan = _sinTheta*(_cosPhi0*_cc -_sinPhi0*_ss);
142  double ytan = _sinTheta*(_cosPhi0*_ss +_sinPhi0*_cc);
143  double ztan = _cosTheta;
144  return HepGeom::Vector3D<double> (xtan,ytan,ztan);
145 }
void _cacheSinesAndCosines(double s) const
void GflashTrajectory::getGflashTrajectoryPoint ( GflashTrajectoryPoint point,
double  s 
) const

Definition at line 148 of file GflashTrajectory.cc.

References _cacheSinesAndCosines(), _cc, _cosPhi0, _cosTheta, _curvature, _d0, _sinPhi0, _sinTheta, _ss, _z0, GflashTrajectoryPoint::getMomentum(), GflashTrajectoryPoint::getPosition(), and GflashTrajectoryPoint::setPathLength().

Referenced by getPhi0(), HFGflash::gfParameterization(), GflashHadronShowerProfile::hadronicParameterization(), CalorimetryManager::HDShowerSimulation(), GflashHadronShowerProfile::hoProfile(), GflashEMShowerProfile::parameterization(), GflashShowino::simulateFirstInteractionPoint(), and GflashShowino::updateShowino().

148  {
149 
151 
152  double cP0sT = _cosPhi0*_sinTheta, sP0sT = _sinPhi0*_sinTheta;
153  if ( s && _curvature) {
154  point.getPosition().set((_cosPhi0*_ss-
155  _sinPhi0*(2.0*_curvature*_d0+1.0-_cc))
156  /(2.0*_curvature),
157  (_sinPhi0*_ss+
158  _cosPhi0*(2.0*_curvature*_d0+1.0-_cc))
159  /(2.0*_curvature),
160  s*_cosTheta + _z0);
161 
162  point.getMomentum().set(cP0sT*_cc-sP0sT*_ss,
163  cP0sT*_ss+sP0sT*_cc,
164  _cosTheta);
165  point.setPathLength(s);
166  }
167  else {
168  point.getPosition().set(-_d0*_sinPhi0+s*cP0sT,
169  _d0*_cosPhi0+s*sP0sT,
170  _z0+s*_cosTheta);
171 
172  point.getMomentum().set(cP0sT,sP0sT,_cosTheta);
173 
174  point.setPathLength(s);
175  }
176 
177 }
void setPathLength(double pathLength)
void _cacheSinesAndCosines(double s) const
Gflash3Vector & getPosition()
Gflash3Vector & getMomentum()
double GflashTrajectory::getL2DAtR ( double  r) const

Definition at line 192 of file GflashTrajectory.cc.

References EnergyCorrector::c, edmIntegrityCheck::d, getCurvature(), getD0(), M_PI, and mathSSE::sqrt().

Referenced by getPathLengthAtRhoEquals(), getPhi0(), and getZAtR().

192  {
193 
194  double L2D;
195 
196  double c = getCurvature();
197  double d = getD0();
198 
199  if (c!=0.0) {
200  double rad = (rho*rho-d*d)/(1.0+2.0*c*d);
201  double rprime;
202  if (rad<0.0) {
203  rprime = 0.0;
204  }
205  else {
206  rprime = sqrt( rad );
207  }
208  if (c*rprime > 1.0 || c*rprime < -1.0) {
209  L2D = c*rprime > 0. ? M_PI/c : -M_PI/c;
210  }
211  else
212  L2D = asin(c*rprime)/c;
213  } else {
214  double rad = rho*rho-d*d;
215  double rprime;
216  if (rad<0.0) rprime = 0.0;
217  else rprime = sqrt( rad );
218 
219  L2D = rprime;
220  }
221  return L2D;
222 }
T sqrt(T t)
Definition: SSEVec.h:18
#define M_PI
double getCurvature() const
double getD0() const
double GflashTrajectory::getPathLengthAtRhoEquals ( double  rho) const
double GflashTrajectory::getPathLengthAtZ ( double  z) const
double GflashTrajectory::getPhi0 ( ) const
inline
HepGeom::Point3D< double > GflashTrajectory::getPosition ( double  s = 0.0) const

Definition at line 119 of file GflashTrajectory.cc.

References _cacheSinesAndCosines(), _cc, _cosPhi0, _cosTheta, _curvature, _d0, _s, _sinPhi0, _sinTheta, _ss, and _z0.

Referenced by getPhi0().

120 {
122  if (s==0.0 || _curvature==0.0) {
123  return HepGeom::Point3D<double> (-_d0*_sinPhi0+s*_cosPhi0*_sinTheta,
125  _z0+s*_cosTheta);
126  } else {
127  return HepGeom::Point3D<double> ((_cosPhi0*_ss-_sinPhi0*(2.0*_curvature*_d0+1.0-_cc))
128  /(2.0*_curvature),
129  (_sinPhi0*_ss+_cosPhi0*(2.0*_curvature*_d0+1.0-_cc))
130  /(2.0*_curvature),
131  _s*_cosTheta + _z0);
132  }
133 }
void _cacheSinesAndCosines(double s) const
double GflashTrajectory::getSinPhi0 ( ) const

Definition at line 102 of file GflashTrajectory.cc.

References _refreshCache(), and _sinPhi0.

Referenced by getPhi0().

102  {
103  _refreshCache();
104  return _sinPhi0;
105 }
void _refreshCache() const
double GflashTrajectory::getSinTheta ( ) const

Definition at line 110 of file GflashTrajectory.cc.

References _refreshCache(), and _sinTheta.

Referenced by getPathLengthAtRhoEquals(), and getPhi0().

110  {
111  _refreshCache();
112  return _sinTheta;
113 }
void _refreshCache() const
double GflashTrajectory::getZ0 ( ) const
inline

Definition at line 23 of file GflashTrajectory.h.

References _z0.

Referenced by getPathLengthAtZ().

23 { return _z0; };
double GflashTrajectory::getZAtR ( double  r) const

Definition at line 188 of file GflashTrajectory.cc.

References _z0, getCotTheta(), and getL2DAtR().

Referenced by getPhi0().

188  {
189  return _z0 + getCotTheta()*getL2DAtR(rho);
190 }
double getL2DAtR(double r) const
double getCotTheta() const
void GflashTrajectory::initializeTrajectory ( const HepGeom::Vector3D< double > &  MomentumGev,
const HepGeom::Point3D< double > &  PositionCm,
double  q,
double  Field 
)

Definition at line 18 of file GflashTrajectory.cc.

References _aa, _cc, _cosPhi0, _cosTheta, _cotTheta, _curvature, _d0, _isStale, _phi0, _s, _sinPhi0, _sinTheta, _ss, _z0, funct::cos(), CustomPhysics_cfi::gamma, M_PI, lumiQueryAPI::q, alignCSCRings::s, funct::sin(), x, y, z, and Z0.

Referenced by HFGflash::gfParameterization(), and GflashShowino::initialize().

20  {
21  double CotTheta = 0.0 ;
22  double W = 0;
23  double Z0 = 0;
24  double D0 = 0;
25  double Phi0 =0;
26 
27  if (BFieldTesla != 0.0 && q != 0.0) {
28  double CurvatureConstant=0.0029979;
29  double Helicity = -1.0 * fabs(BFieldTesla) * fabs(q) / (BFieldTesla*q);
30  double Radius = fabs(MomentumGev.perp()/(CurvatureConstant*BFieldTesla*q));
31 
32  if(Radius==0.0) W = HUGE_VAL; else W = Helicity/Radius;
33  double phi1 = MomentumGev.phi();
34  double x = PositionCm.x(), y = PositionCm.y(), z = PositionCm.z();
35  double sinPhi1 = sin(phi1), cosPhi1 = cos(phi1);
36  double gamma = atan((x*cosPhi1 + y*sinPhi1)/(x*sinPhi1-y*cosPhi1 -1/W));
37  Phi0 = phi1+gamma;
38  if(Phi0 > M_PI) Phi0 = Phi0 - 2.0*M_PI;
39  if(Phi0 < -M_PI) Phi0 = Phi0 + 2.0*M_PI;
40  D0 = ((1/W + y*cosPhi1 - x*sinPhi1) /cos(gamma) - 1/W);
41  CotTheta = MomentumGev.z()/MomentumGev.perp();
42  Z0 = z + gamma*CotTheta/W;
43  }
44  else {
45  CLHEP::Hep3Vector direction = MomentumGev.unit();
46  CLHEP::Hep3Vector projectedDirection = CLHEP::Hep3Vector(direction.x(),direction.y(),0.0).unit();
47  double s = projectedDirection.dot(PositionCm);
48  double sprime = s/sin(direction.theta());
49  Z0 = (PositionCm - sprime*direction).z();
50  Phi0 = MomentumGev.phi();
51  CotTheta = MomentumGev.z()/MomentumGev.perp();
52  W = 0.0;
53  D0 = (PositionCm.y()*cos(Phi0) - PositionCm.x()*sin(Phi0));
54  }
55 
56  _cotTheta=CotTheta;
57  _curvature=W/2;
58  _z0=Z0;
59  _d0=D0;
60  _phi0=Phi0;
61 
62  _isStale=1;
63  _s=-999.999;
64  _aa =-999.999;
65  _ss =-999.999;
66  _cc =-999.999;
67  _sinPhi0 = 1.0;
68  _cosPhi0 = 1.0;
69  _sinTheta = 1.0;
70  _cosTheta = 1.0;
71 }
static const double Z0
Divides< arg, void > D0
Definition: Factorize.h:143
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
#define M_PI
void GflashTrajectory::setCotTheta ( double  cotTheta)

Definition at line 77 of file GflashTrajectory.cc.

References _cotTheta, and _isStale.

77  {
78  _cotTheta=cotTheta;
79  _isStale=true;
80 }
void GflashTrajectory::setCurvature ( double  curvature)

Definition at line 82 of file GflashTrajectory.cc.

References _curvature, _isStale, and PixelRecoUtilities::curvature().

82  {
84  _isStale=true;
85 }
T curvature(T InversePt, const edm::EventSetup &iSetup)
void GflashTrajectory::setD0 ( double  d0)

Definition at line 92 of file GflashTrajectory.cc.

References _d0, _isStale, and allConversions_cfi::d0.

void GflashTrajectory::setPhi0 ( double  phi0)

Definition at line 97 of file GflashTrajectory.cc.

References _isStale, and _phi0.

97  {
98  _phi0=phi0;
99  _isStale=true;
100 }
void GflashTrajectory::setZ0 ( double  z0)

Definition at line 87 of file GflashTrajectory.cc.

References _isStale, and _z0.

87  {
88  _z0 = z0;
89  _isStale=true;
90 }

Member Data Documentation

double GflashTrajectory::_aa
mutableprivate

Definition at line 69 of file GflashTrajectory.h.

Referenced by _cacheSinesAndCosines(), and initializeTrajectory().

double GflashTrajectory::_cc
mutableprivate
double GflashTrajectory::_cosPhi0
mutableprivate
double GflashTrajectory::_cosTheta
mutableprivate
double GflashTrajectory::_cotTheta
private

Definition at line 55 of file GflashTrajectory.h.

Referenced by _refreshCache(), getCotTheta(), initializeTrajectory(), and setCotTheta().

double GflashTrajectory::_curvature
private
double GflashTrajectory::_d0
private
bool GflashTrajectory::_isStale
mutableprivate
double GflashTrajectory::_phi0
private

Definition at line 59 of file GflashTrajectory.h.

Referenced by _refreshCache(), getPhi0(), initializeTrajectory(), and setPhi0().

double GflashTrajectory::_s
mutableprivate

Definition at line 67 of file GflashTrajectory.h.

Referenced by _cacheSinesAndCosines(), getPosition(), and initializeTrajectory().

double GflashTrajectory::_sinPhi0
mutableprivate
double GflashTrajectory::_sinTheta
mutableprivate
double GflashTrajectory::_ss
mutableprivate
double GflashTrajectory::_z0
private