CMS 3D CMS Logo

Public Member Functions | Private Attributes

GflashTrajectory Class Reference

#include <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
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.

  :
   _cotTheta(0.0),_curvature(0.0),_z0(0.0),_d0(0.0),_phi0(0.0),
   _isStale(1),
   _sinPhi0(2),_cosPhi0(2),_sinTheta(2),_cosTheta(2),
   _s(-999.999),
   _aa(2),_ss(2),_cc(2)
{
  //detault constructor
}
GflashTrajectory::~GflashTrajectory ( )

Definition at line 73 of file GflashTrajectory.cc.

{
}

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(), asciidump::s, and funct::sin().

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

                                                           {
  _refreshCache();
  if (_s!=s){
    _s=s;
    _aa=2.0*_s*_curvature*_sinTheta;
    if (_aa==0.0) {
      _ss=0.0;
      _cc=1.0;
    }
    else {
      _ss=sin(_aa);
      _cc=cos(_aa);
    }
  }
}
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(), getSinPhi0(), and getSinTheta().

                                           {
  if (_isStale) {
    _isStale=false;
    double theta;
    if ( _cotTheta==0.0 ) {
       theta = M_PI/2.0;
    }
    else {
       theta=atan(1.0/_cotTheta);
       if (theta<0.0) theta+=M_PI;
    }
    if (theta==0.0) {
      _sinTheta=0.0;
      _cosTheta=1.0;
    }
    else {
      _cosTheta=cos(theta);
      _sinTheta=sqrt(1-_cosTheta*_cosTheta);
    }
    if (_phi0==0.0) {
      _sinPhi0=0.0;
      _cosPhi0=1.0;
    }
    else {
      _cosPhi0 = cos(_phi0);
      _sinPhi0 = sin(_phi0);
      //      _sinPhi0 = sqrt(1.0-_cosPhi0*_cosPhi0);
      //      if (_phi0>M_PI) _sinPhi0 = -_sinPhi0;
    }
  }
}
double GflashTrajectory::getCosPhi0 ( ) const

Definition at line 106 of file GflashTrajectory.cc.

References _cosPhi0, and _refreshCache().

                                         {
  _refreshCache();
  return _cosPhi0;
}
double GflashTrajectory::getCosTheta ( ) const

Definition at line 114 of file GflashTrajectory.cc.

References _cosTheta, and _refreshCache().

Referenced by getPathLengthAtZ().

                                          {
  _refreshCache();
  return _cosTheta;
}
double GflashTrajectory::getCotTheta ( ) const [inline]

Definition at line 21 of file GflashTrajectory.h.

References _cotTheta.

Referenced by getZAtR().

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

Definition at line 22 of file GflashTrajectory.h.

References _curvature.

Referenced by getL2DAtR().

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

Definition at line 24 of file GflashTrajectory.h.

References _d0.

Referenced by getL2DAtR().

{ 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.

{
  _cacheSinesAndCosines(s);
  if (s==0.0) {
      return HepGeom::Vector3D<double> (_cosPhi0*_sinTheta,_sinPhi0*_sinTheta,_cosTheta);
  }
  double   xtan     = _sinTheta*(_cosPhi0*_cc -_sinPhi0*_ss); 
  double   ytan     = _sinTheta*(_cosPhi0*_ss +_sinPhi0*_cc); 
  double ztan       = _cosTheta;
  return HepGeom::Vector3D<double> (xtan,ytan,ztan);
}
void GflashTrajectory::getGflashTrajectoryPoint ( GflashTrajectoryPoint point,
double  s 
) const
double GflashTrajectory::getL2DAtR ( double  r) const

Definition at line 192 of file GflashTrajectory.cc.

References trackerHits::c, getCurvature(), getD0(), M_PI, and mathSSE::sqrt().

Referenced by getPathLengthAtRhoEquals(), and getZAtR().

                                                   {

  double L2D;

  double c = getCurvature();
  double d = getD0();

  if (c!=0.0) {
    double rad = (rho*rho-d*d)/(1.0+2.0*c*d);
    double rprime;
    if (rad<0.0) {
      rprime = 0.0;
    }
    else {
      rprime = sqrt( rad );
    }
    if (c*rprime > 1.0 || c*rprime < -1.0) {
      L2D = c*rprime > 0. ? M_PI/c : -M_PI/c;
    }
    else
      L2D = asin(c*rprime)/c;
  } else {
    double rad = rho*rho-d*d;
    double rprime;
    if (rad<0.0) rprime = 0.0;
    else rprime = sqrt( rad );
    
    L2D = rprime;
  }
  return L2D;
}
double GflashTrajectory::getPathLengthAtRhoEquals ( double  rho) const
double GflashTrajectory::getPathLengthAtZ ( double  z) const
double GflashTrajectory::getPhi0 ( ) const [inline]

Definition at line 25 of file GflashTrajectory.h.

References _phi0.

{ return _phi0;};
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.

{
  _cacheSinesAndCosines(s);
  if (s==0.0 || _curvature==0.0) {
      return HepGeom::Point3D<double> (-_d0*_sinPhi0+s*_cosPhi0*_sinTheta,
                        _d0*_cosPhi0+s*_sinPhi0*_sinTheta,
                        _z0+s*_cosTheta);
  } else {
      return HepGeom::Point3D<double> ((_cosPhi0*_ss-_sinPhi0*(2.0*_curvature*_d0+1.0-_cc))
                        /(2.0*_curvature),
                        (_sinPhi0*_ss+_cosPhi0*(2.0*_curvature*_d0+1.0-_cc))
                        /(2.0*_curvature),   
                        _s*_cosTheta + _z0);
  }
}
double GflashTrajectory::getSinPhi0 ( ) const

Definition at line 102 of file GflashTrajectory.cc.

References _refreshCache(), and _sinPhi0.

                                         {
  _refreshCache();
  return _sinPhi0;
}
double GflashTrajectory::getSinTheta ( ) const

Definition at line 110 of file GflashTrajectory.cc.

References _refreshCache(), and _sinTheta.

Referenced by getPathLengthAtRhoEquals().

                                          {
  _refreshCache();
  return _sinTheta;
}
double GflashTrajectory::getZ0 ( ) const [inline]

Definition at line 23 of file GflashTrajectory.h.

References _z0.

Referenced by getPathLengthAtZ().

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

Definition at line 188 of file GflashTrajectory.cc.

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

                                                 {
  return _z0 + getCotTheta()*getL2DAtR(rho);
}
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(), M_PI, lumiQueryAPI::q, asciidump::s, funct::sin(), ExpressReco_HICollisions_FallBack::x, ExpressReco_HICollisions_FallBack::y, z, and Z0.

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

 {
  double CotTheta = 0.0 ;
  double W = 0;
  double Z0 = 0;
  double D0 = 0;
  double Phi0 =0;

  if (BFieldTesla != 0.0 && q != 0.0) {
    double CurvatureConstant=0.0029979;
    double Helicity       = -1.0 * fabs(BFieldTesla) * fabs(q) / (BFieldTesla*q);
    double Radius         = fabs(MomentumGev.perp()/(CurvatureConstant*BFieldTesla*q));
    
    if(Radius==0.0) W = HUGE_VAL;   else     W        = Helicity/Radius;
    double phi1     = MomentumGev.phi();
    double x        = PositionCm.x(),        y        = PositionCm.y(),    z = PositionCm.z(); 
    double sinPhi1  = sin(phi1),             cosPhi1  = cos(phi1);
    double gamma    = atan((x*cosPhi1 + y*sinPhi1)/(x*sinPhi1-y*cosPhi1 -1/W));
    Phi0            = phi1+gamma;
    if(Phi0 >  M_PI) Phi0 = Phi0 - 2.0*M_PI; 
    if(Phi0 < -M_PI) Phi0 = Phi0 + 2.0*M_PI; 
    D0              = ((1/W + y*cosPhi1 - x*sinPhi1) /cos(gamma) - 1/W);
    CotTheta        = MomentumGev.z()/MomentumGev.perp();
    Z0              = z + gamma*CotTheta/W;
  }
  else {
    CLHEP::Hep3Vector direction          = MomentumGev.unit(); 
    CLHEP::Hep3Vector projectedDirection = CLHEP::Hep3Vector(direction.x(),direction.y(),0.0).unit();
    double s                      = projectedDirection.dot(PositionCm);
    double sprime                 = s/sin(direction.theta());
    Z0                            = (PositionCm - sprime*direction).z();
    Phi0                          = MomentumGev.phi();
    CotTheta                      = MomentumGev.z()/MomentumGev.perp();
    W                             = 0.0;
    D0                           = (PositionCm.y()*cos(Phi0) - PositionCm.x()*sin(Phi0));
  } 
  
   _cotTheta=CotTheta;
   _curvature=W/2;
   _z0=Z0;
   _d0=D0;
   _phi0=Phi0;

   _isStale=1;
   _s=-999.999;
   _aa =-999.999; 
   _ss =-999.999; 
   _cc =-999.999; 
   _sinPhi0 = 1.0;
   _cosPhi0 = 1.0;
   _sinTheta = 1.0;
   _cosTheta = 1.0;
}
void GflashTrajectory::setCotTheta ( double  cotTheta)

Definition at line 77 of file GflashTrajectory.cc.

References _cotTheta, and _isStale.

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

Definition at line 82 of file GflashTrajectory.cc.

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

void GflashTrajectory::setD0 ( double  d0)

Definition at line 92 of file GflashTrajectory.cc.

References _d0, _isStale, and debug_cff::d0.

                                     {
  _d0=d0;
  _isStale=true;
}
void GflashTrajectory::setPhi0 ( double  phi0)

Definition at line 97 of file GflashTrajectory.cc.

References _isStale, and _phi0.

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

Definition at line 87 of file GflashTrajectory.cc.

References _isStale, and _z0.

                                      {
  _z0 = z0;
  _isStale=true;
}

Member Data Documentation

double GflashTrajectory::_aa [mutable, private]

Definition at line 69 of file GflashTrajectory.h.

Referenced by _cacheSinesAndCosines(), and initializeTrajectory().

double GflashTrajectory::_cc [mutable, private]
double GflashTrajectory::_cosPhi0 [mutable, private]
double GflashTrajectory::_cosTheta [mutable, private]
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 [mutable, private]
double GflashTrajectory::_phi0 [private]

Definition at line 59 of file GflashTrajectory.h.

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

double GflashTrajectory::_s [mutable, private]

Definition at line 67 of file GflashTrajectory.h.

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

double GflashTrajectory::_sinPhi0 [mutable, private]
double GflashTrajectory::_sinTheta [mutable, private]
double GflashTrajectory::_ss [mutable, private]
double GflashTrajectory::_z0 [private]