CMS 3D CMS Logo

GflashTrajectory Class Reference

#include <SimG4Core/GFlash/interface/GflashTrajectory.h>

List of all members.

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
HepVector3D 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
HepPoint3D getPosition (double s=0.0) const
double getSinPhi0 () const
double getSinTheta () const
double getZ0 () const
double getZAtR (double r) const
 GflashTrajectory ()
void initializeTrajectory (const HepVector3D &, const HepPoint3D &, 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 9 of file GflashTrajectory.h.


Constructor & Destructor Documentation

GflashTrajectory::GflashTrajectory (  ) 

Definition at line 9 of file GflashTrajectory.cc.

00010   :
00011    _cotTheta(0.0),_curvature(0.0),_z0(0.0),_d0(0.0),_phi0(0.0),
00012    _isStale(1),
00013    _sinPhi0(2),_cosPhi0(2),_sinTheta(2),_cosTheta(2),
00014    _s(-999.999),
00015    _aa(2),_ss(2),_cc(2)
00016 {
00017   //detault constructor
00018 }

GflashTrajectory::~GflashTrajectory (  ) 

Definition at line 77 of file GflashTrajectory.cc.

00078 {
00079 }


Member Function Documentation

void GflashTrajectory::_cacheSinesAndCosines ( double  s  )  const

Definition at line 261 of file GflashTrajectory.cc.

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

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

00261                                                            {
00262   _refreshCache();
00263   if (_s!=s){
00264     _s=s;
00265     _aa=2.0*_s*_curvature*_sinTheta;
00266     if (_aa==0.0) {
00267       _ss=0.0;
00268       _cc=1.0;
00269     }
00270     else {
00271       _ss=sin(_aa);
00272       _cc=cos(_aa);
00273     }
00274   }
00275 }

void GflashTrajectory::_refreshCache (  )  const

Definition at line 229 of file GflashTrajectory.cc.

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

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

00229                                            {
00230   if (_isStale) {
00231     _isStale=false;
00232     double theta;
00233     if ( _cotTheta==0.0 ) {
00234        theta = M_PI/2.0;
00235     }
00236     else {
00237        theta=atan(1.0/_cotTheta);
00238        if (theta<0.0) theta+=M_PI;
00239     }
00240     if (theta==0.0) {
00241       _sinTheta=0.0;
00242       _cosTheta=1.0;
00243     }
00244     else {
00245       _cosTheta=cos(theta);
00246       _sinTheta=sqrt(1-_cosTheta*_cosTheta);
00247     }
00248     if (_phi0==0.0) {
00249       _sinPhi0=0.0;
00250       _cosPhi0=1.0;
00251     }
00252     else {
00253       _cosPhi0 = cos(_phi0);
00254       _sinPhi0 = sin(_phi0);
00255       //      _sinPhi0 = sqrt(1.0-_cosPhi0*_cosPhi0);
00256       //      if (_phi0>M_PI) _sinPhi0 = -_sinPhi0;
00257     }
00258   }
00259 }

double GflashTrajectory::getCosPhi0 (  )  const

Definition at line 110 of file GflashTrajectory.cc.

References _cosPhi0, and _refreshCache().

00110                                          {
00111   _refreshCache();
00112   return _cosPhi0;
00113 }

double GflashTrajectory::getCosTheta (  )  const

Definition at line 118 of file GflashTrajectory.cc.

References _cosTheta, and _refreshCache().

Referenced by getPathLengthAtZ().

00118                                           {
00119   _refreshCache();
00120   return _cosTheta;
00121 }

double GflashTrajectory::getCotTheta (  )  const [inline]

Definition at line 24 of file GflashTrajectory.h.

References _cotTheta.

Referenced by getZAtR().

00024 { return _cotTheta; }

double GflashTrajectory::getCurvature (  )  const [inline]

Definition at line 25 of file GflashTrajectory.h.

References _curvature.

Referenced by getL2DAtR().

00025 { return _curvature; }

double GflashTrajectory::getD0 (  )  const [inline]

Definition at line 27 of file GflashTrajectory.h.

References _d0.

Referenced by getL2DAtR().

00027 { return _d0; };

HepVector3D GflashTrajectory::getDirection ( double  s = 0.0  )  const

Definition at line 139 of file GflashTrajectory.cc.

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

00140 {
00141   _cacheSinesAndCosines(s);
00142   if (s==0.0) {
00143       return HepVector3D(_cosPhi0*_sinTheta,_sinPhi0*_sinTheta,_cosTheta);
00144   }
00145   double   xtan     = _sinTheta*(_cosPhi0*_cc -_sinPhi0*_ss); 
00146   double   ytan     = _sinTheta*(_cosPhi0*_ss +_sinPhi0*_cc); 
00147   double ztan       = _cosTheta;
00148   return HepVector3D(xtan,ytan,ztan);
00149 }

void GflashTrajectory::getGflashTrajectoryPoint ( GflashTrajectoryPoint point,
double  s 
) const

Definition at line 152 of file GflashTrajectory.cc.

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

Referenced by GflashHadronShowerProfile::hadronicParameterization(), GflashHadronShowerProfile::longitudinalProfile(), and GflashEMShowerProfile::parameterization().

00152                                                                                             {
00153   
00154   _cacheSinesAndCosines(s);
00155 
00156   double cP0sT = _cosPhi0*_sinTheta, sP0sT = _sinPhi0*_sinTheta;
00157   if ( s && _curvature) {
00158     point.getPosition().set((_cosPhi0*_ss-
00159                              _sinPhi0*(2.0*_curvature*_d0+1.0-_cc))
00160                             /(2.0*_curvature),
00161                             (_sinPhi0*_ss+
00162                              _cosPhi0*(2.0*_curvature*_d0+1.0-_cc))
00163                             /(2.0*_curvature),
00164                             s*_cosTheta + _z0);
00165     
00166     point.getMomentum().set(cP0sT*_cc-sP0sT*_ss,
00167                             cP0sT*_ss+sP0sT*_cc,
00168                             _cosTheta);
00169     point.setPathLength(s);
00170   }
00171   else {
00172     point.getPosition().set(-_d0*_sinPhi0+s*cP0sT,
00173                             _d0*_cosPhi0+s*sP0sT,
00174                             _z0+s*_cosTheta);
00175     
00176     point.getMomentum().set(cP0sT,sP0sT,_cosTheta);
00177     
00178     point.setPathLength(s);
00179   }
00180   
00181 }

double GflashTrajectory::getL2DAtR ( double  r  )  const

Definition at line 196 of file GflashTrajectory.cc.

References c, d, getCurvature(), getD0(), and funct::sqrt().

Referenced by getPathLengthAtRhoEquals(), and getZAtR().

00196                                                    {
00197 
00198   double L2D;
00199 
00200   double c = getCurvature();
00201   double d = getD0();
00202 
00203   if (c!=0.0) {
00204     double rad = (rho*rho-d*d)/(1.0+2.0*c*d);
00205     double rprime;
00206     if (rad<0.0) {
00207       rprime = 0.0;
00208     }
00209     else {
00210       rprime = sqrt( rad );
00211     }
00212     if (c*rprime > 1.0 || c*rprime < -1.0) {
00213       L2D = c*rprime > 0. ? M_PI/c : -M_PI/c;
00214     }
00215     else
00216       L2D = asin(c*rprime)/c;
00217   } else {
00218     double rad = rho*rho-d*d;
00219     double rprime;
00220     if (rad<0.0) rprime = 0.0;
00221     else rprime = sqrt( rad );
00222     
00223     L2D = rprime;
00224   }
00225   return L2D;
00226 }

double GflashTrajectory::getPathLengthAtRhoEquals ( double  rho  )  const

Definition at line 183 of file GflashTrajectory.cc.

References getL2DAtR(), and getSinTheta().

Referenced by GflashHadronShowerProfile::hadronicParameterization(), and GflashEMShowerProfile::parameterization().

00184 {
00185   return (getSinTheta()?(getL2DAtR(rho)/getSinTheta()):0.0);
00186 }

double GflashTrajectory::getPathLengthAtZ ( double  z  )  const

Definition at line 188 of file GflashTrajectory.cc.

References getCosTheta(), and getZ0().

Referenced by GflashHadronShowerProfile::hadronicParameterization().

00188                                                         {
00189   return (getCosTheta()?(z-getZ0())/getCosTheta():0.0);
00190 }

double GflashTrajectory::getPhi0 (  )  const [inline]

Definition at line 28 of file GflashTrajectory.h.

References _phi0.

00028 { return _phi0;};

HepPoint3D GflashTrajectory::getPosition ( double  s = 0.0  )  const

Definition at line 123 of file GflashTrajectory.cc.

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

00124 {
00125   _cacheSinesAndCosines(s);
00126   if (s==0.0 || _curvature==0.0) {
00127       return HepPoint3D(-_d0*_sinPhi0+s*_cosPhi0*_sinTheta,
00128                         _d0*_cosPhi0+s*_sinPhi0*_sinTheta,
00129                         _z0+s*_cosTheta);
00130   } else {
00131       return HepPoint3D((_cosPhi0*_ss-_sinPhi0*(2.0*_curvature*_d0+1.0-_cc))
00132                         /(2.0*_curvature),
00133                         (_sinPhi0*_ss+_cosPhi0*(2.0*_curvature*_d0+1.0-_cc))
00134                         /(2.0*_curvature),   
00135                         _s*_cosTheta + _z0);
00136   }
00137 }

double GflashTrajectory::getSinPhi0 (  )  const

Definition at line 106 of file GflashTrajectory.cc.

References _refreshCache(), and _sinPhi0.

00106                                          {
00107   _refreshCache();
00108   return _sinPhi0;
00109 }

double GflashTrajectory::getSinTheta (  )  const

Definition at line 114 of file GflashTrajectory.cc.

References _refreshCache(), and _sinTheta.

Referenced by getPathLengthAtRhoEquals().

00114                                           {
00115   _refreshCache();
00116   return _sinTheta;
00117 }

double GflashTrajectory::getZ0 (  )  const [inline]

Definition at line 26 of file GflashTrajectory.h.

References _z0.

Referenced by getPathLengthAtZ().

00026 { return _z0; };

double GflashTrajectory::getZAtR ( double  r  )  const

Definition at line 192 of file GflashTrajectory.cc.

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

00192                                                  {
00193   return _z0 + getCotTheta()*getL2DAtR(rho);
00194 }

void GflashTrajectory::initializeTrajectory ( const HepVector3D &  MomentumGev,
const HepPoint3D &  PositionCm,
double  q,
double  Field 
)

Definition at line 22 of file GflashTrajectory.cc.

References _aa, _cc, _cosPhi0, _cosTheta, _cotTheta, _curvature, _d0, _isStale, _phi0, _s, _sinPhi0, _sinTheta, _ss, _z0, funct::cos(), direction, s, funct::sin(), Vector3DBase< T, FrameTag >::unit(), x, y, z, and Z0.

Referenced by GflashHadronShowerProfile::hadronicParameterization(), and GflashEMShowerProfile::parameterization().

00024  {
00025   double CotTheta = 0.0 ;
00026   double W = 0;
00027   double Z0 = 0;
00028   double D0 = 0;
00029   double Phi0 =0;
00030 
00031   if (BFieldTesla != 0.0 && q != 0.0) {
00032     double CurvatureConstant=0.0029979;
00033     double Helicity       = -1.0 * fabs(BFieldTesla) * fabs(q) / (BFieldTesla*q);
00034     double Radius         = fabs(MomentumGev.perp()/(CurvatureConstant*BFieldTesla*q));
00035     
00036     if(Radius==0.0) W = HUGE_VAL;   else     W        = Helicity/Radius;
00037     double phi1     = MomentumGev.phi();
00038     double x        = PositionCm.x(),        y        = PositionCm.y(),    z = PositionCm.z(); 
00039     double sinPhi1  = sin(phi1),             cosPhi1  = cos(phi1);
00040     double gamma    = atan((x*cosPhi1 + y*sinPhi1)/(x*sinPhi1-y*cosPhi1 -1/W));
00041     Phi0            = phi1+gamma;
00042     if(Phi0 >  M_PI) Phi0 = Phi0 - 2.0*M_PI; 
00043     if(Phi0 < -M_PI) Phi0 = Phi0 + 2.0*M_PI; 
00044     D0              = ((1/W + y*cosPhi1 - x*sinPhi1) /cos(gamma) - 1/W);
00045     CotTheta        = MomentumGev.z()/MomentumGev.perp();
00046     Z0              = z + gamma*CotTheta/W;
00047   }
00048   else {
00049     Hep3Vector direction          = MomentumGev.unit(); 
00050     Hep3Vector projectedDirection = Hep3Vector(direction.x(),direction.y(),0.0).unit();
00051     double s                      = projectedDirection.dot(PositionCm);
00052     double sprime                 = s/sin(direction.theta());
00053     Z0                            = (PositionCm - sprime*direction).z();
00054     Phi0                          = MomentumGev.phi();
00055     CotTheta                      = MomentumGev.z()/MomentumGev.perp();
00056     W                             = 0.0;
00057     D0                           = (PositionCm.y()*cos(Phi0) - PositionCm.x()*sin(Phi0));
00058   } 
00059   
00060    _cotTheta=CotTheta;
00061    _curvature=W/2;
00062    _z0=Z0;
00063    _d0=D0;
00064    _phi0=Phi0;
00065 
00066    _isStale=1;
00067    _s=-999.999;
00068    _aa =-999.999; 
00069    _ss =-999.999; 
00070    _cc =-999.999; 
00071    _sinPhi0 = 1.0;
00072    _cosPhi0 = 1.0;
00073    _sinTheta = 1.0;
00074    _cosTheta = 1.0;
00075 }

void GflashTrajectory::setCotTheta ( double  cotTheta  ) 

Definition at line 81 of file GflashTrajectory.cc.

References _cotTheta, and _isStale.

00081                                                   {
00082   _cotTheta=cotTheta;
00083   _isStale=true;
00084 }

void GflashTrajectory::setCurvature ( double  curvature  ) 

Definition at line 86 of file GflashTrajectory.cc.

References _curvature, and _isStale.

00086                                                    {
00087   _curvature=curvature;
00088   _isStale=true;
00089 }

void GflashTrajectory::setD0 ( double  d0  ) 

Definition at line 96 of file GflashTrajectory.cc.

References _d0, and _isStale.

00096                                      {
00097   _d0=d0;
00098   _isStale=true;
00099 }

void GflashTrajectory::setPhi0 ( double  phi0  ) 

Definition at line 101 of file GflashTrajectory.cc.

References _isStale, and _phi0.

00101                                          {
00102   _phi0=phi0;
00103   _isStale=true;
00104 }

void GflashTrajectory::setZ0 ( double  z0  ) 

Definition at line 91 of file GflashTrajectory.cc.

References _isStale, and _z0.

00091                                       {
00092   _z0 = z0;
00093   _isStale=true;
00094 }


Member Data Documentation

double GflashTrajectory::_aa [mutable, private]

Definition at line 72 of file GflashTrajectory.h.

Referenced by _cacheSinesAndCosines(), and initializeTrajectory().

double GflashTrajectory::_cc [mutable, private]

Definition at line 74 of file GflashTrajectory.h.

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

double GflashTrajectory::_cosPhi0 [mutable, private]

Definition at line 67 of file GflashTrajectory.h.

Referenced by _refreshCache(), getCosPhi0(), getDirection(), getGflashTrajectoryPoint(), getPosition(), and initializeTrajectory().

double GflashTrajectory::_cosTheta [mutable, private]

Definition at line 69 of file GflashTrajectory.h.

Referenced by _refreshCache(), getCosTheta(), getDirection(), getGflashTrajectoryPoint(), getPosition(), and initializeTrajectory().

double GflashTrajectory::_cotTheta [private]

Definition at line 58 of file GflashTrajectory.h.

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

double GflashTrajectory::_curvature [private]

Definition at line 59 of file GflashTrajectory.h.

Referenced by _cacheSinesAndCosines(), getCurvature(), getGflashTrajectoryPoint(), getPosition(), initializeTrajectory(), and setCurvature().

double GflashTrajectory::_d0 [private]

Definition at line 61 of file GflashTrajectory.h.

Referenced by getD0(), getGflashTrajectoryPoint(), getPosition(), initializeTrajectory(), and setD0().

bool GflashTrajectory::_isStale [mutable, private]

Definition at line 65 of file GflashTrajectory.h.

Referenced by _refreshCache(), initializeTrajectory(), setCotTheta(), setCurvature(), setD0(), setPhi0(), and setZ0().

double GflashTrajectory::_phi0 [private]

Definition at line 62 of file GflashTrajectory.h.

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

double GflashTrajectory::_s [mutable, private]

Definition at line 70 of file GflashTrajectory.h.

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

double GflashTrajectory::_sinPhi0 [mutable, private]

Definition at line 66 of file GflashTrajectory.h.

Referenced by _refreshCache(), getDirection(), getGflashTrajectoryPoint(), getPosition(), getSinPhi0(), and initializeTrajectory().

double GflashTrajectory::_sinTheta [mutable, private]

Definition at line 68 of file GflashTrajectory.h.

Referenced by _cacheSinesAndCosines(), _refreshCache(), getDirection(), getGflashTrajectoryPoint(), getPosition(), getSinTheta(), and initializeTrajectory().

double GflashTrajectory::_ss [mutable, private]

Definition at line 73 of file GflashTrajectory.h.

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

double GflashTrajectory::_z0 [private]

Definition at line 60 of file GflashTrajectory.h.

Referenced by getGflashTrajectoryPoint(), getPosition(), getZ0(), getZAtR(), initializeTrajectory(), and setZ0().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:21:24 2009 for CMSSW by  doxygen 1.5.4