CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/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 
00117   bool propagateToClosestApproach(double x0=0.,double y0=0,bool first=true);
00118   bool propagateToEcal(bool first=true);
00119   bool propagateToPreshowerLayer1(bool first=true);
00120   bool propagateToPreshowerLayer2(bool first=true);
00121   bool propagateToEcalEntrance(bool first=true);
00122   bool propagateToHcalEntrance(bool first=true);
00123   bool propagateToVFcalEntrance(bool first=true);
00124   bool propagateToHcalExit(bool first=true);
00125   bool propagateToHOLayer(bool first=true);
00126   bool propagateToNominalVertex(const XYZTLorentzVector& hit2=XYZTLorentzVector(0.,0.,0.,0.));
00127   bool propagateToBeamCylinder(const XYZTLorentzVector& v, double radius=0.); 
00129   void setPropagationConditions(double r, double z, bool firstLoop=true);
00130 
00131 private:
00133   //  RawParticle   particle;
00135   double rCyl;
00136   double rCyl2;
00138   double zCyl;
00140   double bField;
00142   double properDecayTime;
00144   bool debug;
00145 
00146 protected:
00148   int success;
00150   bool fiducial;
00151 
00153   inline double c_light() const { return 299.792458; }
00154 
00155 private:
00157   bool firstLoop;
00159   bool decayed;
00161   double properTime;
00163   int propDir;
00164 
00165 public:
00166 
00168   inline void setProperDecayTime(double t) { properDecayTime = t; }
00169 
00171   inline void increaseRCyl(double delta) {rCyl = rCyl + delta; rCyl2 = rCyl*rCyl; }
00172 
00174   double xyImpactParameter(double x0=0., double y0=0.) const;
00175 
00177   inline double zImpactParameter(double x0=0, double y0=0.) const {
00178     // Longitudinal impact parameter
00179     return Z() - Pz() * std::sqrt( ((X()-x0)*(X()-x0) + (Y()-y0)*(Y()-y0) ) / Perp2());
00180   }
00181 
00183   inline double helixRadius() const { 
00184     // The helix Radius
00185     //
00186     // The helix' Radius sign accounts for the orientation of the magnetic field 
00187     // (+ = along z axis) and the sign of the electric charge of the particle. 
00188     // It signs the rotation of the (charged) particle around the z axis: 
00189     // Positive means anti-clockwise, negative means clockwise rotation.
00190     //
00191     // The radius is returned in cm to match the units in RawParticle.
00192     return charge() == 0 ? 0.0 : - Pt() / ( c_light() * 1e-5 * bField * charge() );
00193   }
00194 
00195   inline double helixRadius(double pT) const { 
00196     // a faster version of helixRadius, once Perp() has been computed
00197     return charge() == 0 ? 0.0 : - pT / ( c_light() * 1e-5 * bField * charge() );
00198   }
00199 
00201   inline double helixStartPhi() const { 
00202     // The azimuth of the momentum at the vertex
00203     return Px() == 0.0 && Py() == 0.0 ? 0.0 : std::atan2(Py(),Px());
00204   }
00205   
00207   inline double helixCentreX() const { 
00208     // The x coordinate of the helix axis
00209     return X() - helixRadius() * std::sin ( helixStartPhi() );
00210   }
00211 
00212   inline double helixCentreX(double radius, double phi) const { 
00213     // Fast version of helixCentreX()
00214     return X() - radius * std::sin (phi);
00215   }
00216 
00218   inline double helixCentreY() const { 
00219     // The y coordinate of the helix axis
00220     return Y() + helixRadius() * std::cos ( helixStartPhi() );
00221 }
00222 
00223   inline double helixCentreY(double radius, double phi) const { 
00224     // Fast version of helixCentreX()
00225     return Y() + radius * std::cos (phi);
00226   }
00227 
00229   inline double helixCentreDistToAxis() const { 
00230     // The distance between the cylinder and the helix axes
00231     double xC = helixCentreX();
00232     double yC = helixCentreY();
00233     return std::sqrt( xC*xC + yC*yC );
00234   }
00235 
00236   inline double helixCentreDistToAxis(double xC, double yC) const { 
00237     // Faster version of helixCentreDistToAxis
00238     return std::sqrt( xC*xC + yC*yC );
00239   }
00240 
00242   inline double helixCentrePhi() const { 
00243     // The azimuth if the vector joining the cylinder and the helix axes
00244     double xC = helixCentreX();
00245     double yC = helixCentreY();
00246     return xC == 0.0 && yC == 0.0 ? 0.0 : std::atan2(yC,xC);
00247   }
00248   
00249   inline double helixCentrePhi(double xC, double yC) const { 
00250     // Faster version of helixCentrePhi() 
00251     return xC == 0.0 && yC == 0.0 ? 0.0 : std::atan2(yC,xC);
00252   }
00253 
00255   inline bool inside() const {
00256     return (R2()<rCyl2-0.00001*rCyl && fabs(Z())<zCyl-0.00001);}
00257 
00258   inline bool inside(double rPos2) const {
00259     return (rPos2<rCyl2-0.00001*rCyl && fabs(Z())<zCyl-0.00001);}
00260 
00261 
00263   inline bool onSurface() const {
00264     return ( onBarrel() || onEndcap() ); 
00265   }
00266 
00267   inline bool onSurface(double rPos2) const {
00268     return ( onBarrel(rPos2) || onEndcap(rPos2) ); 
00269   }
00270 
00272   inline bool onBarrel() const {
00273     double rPos2 = R2();
00274     return ( fabs(rPos2-rCyl2) < 0.00001*rCyl && fabs(Z()) <= zCyl );
00275   }
00276 
00277   inline bool onBarrel(double rPos2) const {
00278     return ( fabs(rPos2-rCyl2) < 0.00001*rCyl && fabs(Z()) <= zCyl );
00279   }
00280 
00282   inline bool onEndcap() const {
00283     return ( fabs(fabs(Z())-zCyl) < 0.00001 && R2() <= rCyl2 ); 
00284   }
00285   
00286   inline bool onEndcap(double rPos2) const {
00287     return ( fabs(fabs(Z())-zCyl) < 0.00001 && rPos2 <= rCyl2 ); 
00288   }
00289 
00291   inline bool onFiducial() const { return fiducial; }
00292 
00294   inline bool hasDecayed() const { return decayed; }
00295 
00297   inline int  getSuccess() const { return success;  }
00298 
00300   inline void setMagneticField(double b) {  bField=b; }
00301 
00303   inline double getMagneticField() const {  return bField; }
00304 
00306   inline void setDebug() { debug = true; } 
00307   inline void resetDebug() { debug = false; }
00308     
00309 };
00310 
00311 #endif