CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/FastSimulation/BaseParticlePropagator/interface/BaseParticlePropagator.h

Go to the documentation of this file.
00001 /*Emacs: -*- C++ -*- */
00002 #ifndef BASEPARTICLEPROPAGATOR_H
00003 #define BASEPARTICLEPROPAGATOR_H
00004 
00079 //FAMOS
00080 #include "FastSimulation/Particle/interface/RawParticle.h"
00081 
00082 class BaseParticlePropagator : public RawParticle {
00083   
00084 public:
00085 
00087   BaseParticlePropagator();
00088 
00092   BaseParticlePropagator(const RawParticle& myPart, 
00093                          double r, double z, double B);
00094   BaseParticlePropagator(const RawParticle& myPart, 
00095                          double r, double z, double B, double t);
00096 
00098   void init();
00099 
00102   bool propagate();
00103 
00106   bool backPropagate();
00107 
00110   BaseParticlePropagator propagated() const;
00111 
00116   bool propagateToClosestApproach(double x0=0.,double y0=0,bool first=true);
00117   bool propagateToEcal(bool first=true);
00118   bool propagateToPreshowerLayer1(bool first=true);
00119   bool propagateToPreshowerLayer2(bool first=true);
00120   bool propagateToEcalEntrance(bool first=true);
00121   bool propagateToHcalEntrance(bool first=true);
00122   bool propagateToVFcalEntrance(bool first=true);
00123   bool propagateToHcalExit(bool first=true);
00124   bool propagateToNominalVertex(const XYZTLorentzVector& hit2=XYZTLorentzVector(0.,0.,0.,0.));
00125   bool propagateToBeamCylinder(const XYZTLorentzVector& v, double radius=0.); 
00127   void setPropagationConditions(double r, double z, bool firstLoop=true);
00128 
00129 private:
00131   //  RawParticle   particle;
00133   double rCyl;
00134   double rCyl2;
00136   double zCyl;
00138   double bField;
00140   double properDecayTime;
00142   bool debug;
00143 
00144 protected:
00146   int success;
00148   bool fiducial;
00149 
00151   inline double c_light() const { return 299.792458; }
00152 
00153 private:
00155   bool firstLoop;
00157   bool decayed;
00159   double properTime;
00161   int propDir;
00162 
00163 public:
00164 
00166   inline void setProperDecayTime(double t) { properDecayTime = t; }
00167 
00169   inline void increaseRCyl(double delta) {rCyl = rCyl + delta; rCyl2 = rCyl*rCyl; }
00170 
00172   double xyImpactParameter(double x0=0., double y0=0.) const;
00173 
00175   inline double zImpactParameter(double x0=0, double y0=0.) const {
00176     // Longitudinal impact parameter
00177     return Z() - Pz() * std::sqrt( ((X()-x0)*(X()-x0) + (Y()-y0)*(Y()-y0) ) / Perp2());
00178   }
00179 
00181   inline double helixRadius() const { 
00182     // The helix Radius
00183     //
00184     // The helix' Radius sign accounts for the orientation of the magnetic field 
00185     // (+ = along z axis) and the sign of the electric charge of the particle. 
00186     // It signs the rotation of the (charged) particle around the z axis: 
00187     // Positive means anti-clockwise, negative means clockwise rotation.
00188     //
00189     // The radius is returned in cm to match the units in RawParticle.
00190     return charge() == 0 ? 0.0 : - Pt() / ( c_light() * 1e-5 * bField * charge() );
00191   }
00192 
00193   inline double helixRadius(double pT) const { 
00194     // a faster version of helixRadius, once Perp() has been computed
00195     return charge() == 0 ? 0.0 : - pT / ( c_light() * 1e-5 * bField * charge() );
00196   }
00197 
00199   inline double helixStartPhi() const { 
00200     // The azimuth of the momentum at the vertex
00201     return Px() == 0.0 && Py() == 0.0 ? 0.0 : std::atan2(Py(),Px());
00202   }
00203   
00205   inline double helixCentreX() const { 
00206     // The x coordinate of the helix axis
00207     return X() - helixRadius() * std::sin ( helixStartPhi() );
00208   }
00209 
00210   inline double helixCentreX(double radius, double phi) const { 
00211     // Fast version of helixCentreX()
00212     return X() - radius * std::sin (phi);
00213   }
00214 
00216   inline double helixCentreY() const { 
00217     // The y coordinate of the helix axis
00218     return Y() + helixRadius() * std::cos ( helixStartPhi() );
00219 }
00220 
00221   inline double helixCentreY(double radius, double phi) const { 
00222     // Fast version of helixCentreX()
00223     return Y() + radius * std::cos (phi);
00224   }
00225 
00227   inline double helixCentreDistToAxis() const { 
00228     // The distance between the cylinder and the helix axes
00229     double xC = helixCentreX();
00230     double yC = helixCentreY();
00231     return std::sqrt( xC*xC + yC*yC );
00232   }
00233 
00234   inline double helixCentreDistToAxis(double xC, double yC) const { 
00235     // Faster version of helixCentreDistToAxis
00236     return std::sqrt( xC*xC + yC*yC );
00237   }
00238 
00240   inline double helixCentrePhi() const { 
00241     // The azimuth if the vector joining the cylinder and the helix axes
00242     double xC = helixCentreX();
00243     double yC = helixCentreY();
00244     return xC == 0.0 && yC == 0.0 ? 0.0 : std::atan2(yC,xC);
00245   }
00246   
00247   inline double helixCentrePhi(double xC, double yC) const { 
00248     // Faster version of helixCentrePhi() 
00249     return xC == 0.0 && yC == 0.0 ? 0.0 : std::atan2(yC,xC);
00250   }
00251 
00253   inline bool inside() const {
00254     return (R2()<rCyl2-0.00001*rCyl && fabs(Z())<zCyl-0.00001);}
00255 
00256   inline bool inside(double rPos2) const {
00257     return (rPos2<rCyl2-0.00001*rCyl && fabs(Z())<zCyl-0.00001);}
00258 
00259 
00261   inline bool onSurface() const {
00262     return ( onBarrel() || onEndcap() ); 
00263   }
00264 
00265   inline bool onSurface(double rPos2) const {
00266     return ( onBarrel(rPos2) || onEndcap(rPos2) ); 
00267   }
00268 
00270   inline bool onBarrel() const {
00271     double rPos2 = R2();
00272     return ( fabs(rPos2-rCyl2) < 0.00001*rCyl && fabs(Z()) <= zCyl );
00273   }
00274 
00275   inline bool onBarrel(double rPos2) const {
00276     return ( fabs(rPos2-rCyl2) < 0.00001*rCyl && fabs(Z()) <= zCyl );
00277   }
00278 
00280   inline bool onEndcap() const {
00281     return ( fabs(fabs(Z())-zCyl) < 0.00001 && R2() <= rCyl2 ); 
00282   }
00283   
00284   inline bool onEndcap(double rPos2) const {
00285     return ( fabs(fabs(Z())-zCyl) < 0.00001 && rPos2 <= rCyl2 ); 
00286   }
00287 
00289   inline bool onFiducial() const { return fiducial; }
00290 
00292   inline bool hasDecayed() const { return decayed; }
00293 
00295   inline int  getSuccess() const { return success;  }
00296 
00298   inline void setMagneticField(double b) {  bField=b; }
00299 
00301   inline double getMagneticField() const {  return bField; }
00302 
00304   inline void setDebug() { debug = true; } 
00305   inline void resetDebug() { debug = false; }
00306     
00307 };
00308 
00309 #endif