CMS 3D CMS Logo

ParticlePropagator.cc

Go to the documentation of this file.
00001 //CMSSW headers
00002 #include "DataFormats/GeometrySurface/interface/BoundDisk.h"
00003 #include "DataFormats/GeometrySurface/interface/BoundCylinder.h"
00004 
00005 //FAMOS headers
00006 #include "FastSimulation/ParticlePropagator/interface/ParticlePropagator.h"
00007 #include "FastSimulation/ParticlePropagator/interface/MagneticFieldMap.h"
00008 #include "FastSimulation/TrackerSetup/interface/TrackerLayer.h"
00009 #include "FastSimulation/Event/interface/FSimTrack.h"
00010 #include "FastSimulation/Event/interface/FSimVertex.h"
00011 #include "FastSimulation/Utilities/interface/RandomEngine.h"
00012 
00013 ParticlePropagator::ParticlePropagator() : 
00014   BaseParticlePropagator(), random(0) {;}
00015 
00016 ParticlePropagator::ParticlePropagator(const RawParticle& myPart,
00017                                        double RCyl, double ZCyl, 
00018                                        const MagneticFieldMap* aFieldMap,
00019                                        const RandomEngine* engine) :
00020   BaseParticlePropagator(myPart,RCyl,ZCyl,0.),
00021   theFieldMap(aFieldMap),
00022   random(engine)
00023 {
00024   setMagneticField(fieldMap(X(),Y(),Z()));
00025   initProperDecayTime();
00026 }
00027 
00028 ParticlePropagator::ParticlePropagator( const RawParticle& myPart,
00029                                         const MagneticFieldMap* aFieldMap,
00030                                         const RandomEngine* engine) : 
00031   BaseParticlePropagator(myPart,0.,0.,0.),
00032   theFieldMap(aFieldMap),
00033   random(engine)
00034  
00035 {
00036   setMagneticField(fieldMap(X(),Y(),Z()));
00037   initProperDecayTime();
00038 }
00039 
00040 ParticlePropagator::ParticlePropagator(const XYZTLorentzVector& mom, 
00041                                        const XYZTLorentzVector& vert, float q,
00042                                        const MagneticFieldMap* aFieldMap) :
00043   BaseParticlePropagator(RawParticle(mom,vert),0.,0.,0.),
00044   theFieldMap(aFieldMap),
00045   random(0)
00046 {
00047   setCharge(q);
00048   setMagneticField(fieldMap(X(),Y(),Z()));
00049 }
00050 
00051 ParticlePropagator::ParticlePropagator(const XYZTLorentzVector& mom, 
00052                                        const XYZVector& vert, float q,
00053                                        const MagneticFieldMap* aFieldMap) :
00054   BaseParticlePropagator(
00055     RawParticle(mom,XYZTLorentzVector(vert.X(),vert.Y(),vert.Z(),0.0)),0.,0.,0.),
00056   theFieldMap(aFieldMap),
00057   random(0)
00058 {
00059   setCharge(q);
00060   setMagneticField(fieldMap(X(),Y(),Z()));
00061 }
00062 
00063 ParticlePropagator::ParticlePropagator(const FSimTrack& simTrack,
00064                                        const MagneticFieldMap* aFieldMap,
00065                                        const RandomEngine* engine) : 
00066   BaseParticlePropagator(RawParticle(simTrack.type(),simTrack.momentum()),
00067                          0.,0.,0.),
00068   theFieldMap(aFieldMap),
00069   random(engine)
00070 {
00071   setVertex(simTrack.vertex().position());
00072   setMagneticField(fieldMap(X(),Y(),Z()));
00073   if ( simTrack.decayTime() < 0. ) 
00074     // No pre-defined decay time
00075     initProperDecayTime();
00076   else
00077     // Decay time pre-defined at generator level 
00078     this->setProperDecayTime(simTrack.decayTime());
00079 }
00080 
00081 ParticlePropagator::ParticlePropagator(const ParticlePropagator& myPropPart) :
00082   BaseParticlePropagator(myPropPart),
00083   theFieldMap(myPropPart.theFieldMap)
00084 {  
00085   //  setMagneticField(fieldMap(x(),y(),z()));
00086 }
00087 
00088 ParticlePropagator::ParticlePropagator(const BaseParticlePropagator& myPropPart,
00089                                        const MagneticFieldMap* aFieldMap) :
00090   BaseParticlePropagator(myPropPart),
00091   theFieldMap(aFieldMap)
00092 {  
00093   setMagneticField(fieldMap(X(),Y(),Z()));
00094 }
00095 
00096 
00097 void 
00098 ParticlePropagator::initProperDecayTime() {
00099 
00100   // And this is the proper time at which the particle will decay
00101   double properDecayTime = 
00102     (pid()==0||pid()==22||abs(pid())==11||abs(pid())==2112||abs(pid())==2212||
00103      !random) ?
00104     1E99 : -PDGcTau() * std::log(random->flatShoot());
00105 
00106   this->setProperDecayTime(properDecayTime);
00107 
00108 }
00109 
00110 
00111 bool
00112 ParticlePropagator::propagateToClosestApproach(double x0, double y0, bool first) {
00113   setMagneticField(fieldMap(0.,0.,0.));
00114   return BaseParticlePropagator::propagateToClosestApproach(x0,y0,first);
00115 }
00116 
00117 bool
00118 ParticlePropagator::propagateToNominalVertex(const XYZTLorentzVector& v) {
00119   setMagneticField(fieldMap(0.,0.,0.));
00120   return BaseParticlePropagator::propagateToNominalVertex(v);
00121 }
00122 
00123 ParticlePropagator
00124 ParticlePropagator::propagated() const {
00125   return ParticlePropagator(BaseParticlePropagator::propagated(),theFieldMap);
00126 }
00127 
00128 double
00129 ParticlePropagator::fieldMap(double xx,double yy, double zz) {
00130   // Arguments now passed in cm.
00131   //  return MagneticFieldMap::instance()->inTesla(GlobalPoint(xx/10.,yy/10.,zz/10.)).z();
00132   // Return a dummy value for neutral particles!
00133   return charge() == 0.0 || theFieldMap == 0 ? 
00134     4. : theFieldMap->inTeslaZ(GlobalPoint(xx,yy,zz));
00135 }
00136 
00137 double
00138 ParticlePropagator::fieldMap(const TrackerLayer& layer, double coord, int success) {
00139   // Arguments now passed in cm.
00140   //  return MagneticFieldMap::instance()->inTesla(GlobalPoint(xx/10.,yy/10.,zz/10.)).z();
00141   // Return a dummy value for neutral particles!
00142   return charge() == 0.0 || theFieldMap == 0 ? 
00143     4. : theFieldMap->inTeslaZ(layer,coord,success);
00144 }
00145 
00146 bool
00147 ParticlePropagator::propagateToBoundSurface(const TrackerLayer& layer) {
00148 
00149 
00150   fiducial = true;
00151   BoundDisk* disk = layer.disk();
00152   //  bool disk = layer.forward();
00153   //  double innerradius=-999;
00154   double innerradius = disk ? layer.diskInnerRadius() : -999. ;
00155 
00156   //  if( disk ) {
00157     //    const Surface& surface = layer.surface();
00158     //    const BoundDisk & myDisk = dynamic_cast<const BoundDisk&>(surface);
00159     //    innerradius=myDisk.innerRadius();       
00160   //    innerradius=myDisk->innerRadius();        
00161   //  }
00162 
00163   bool done = propagate();
00164 
00165   // Set the magnetic field at the new location (if succesfully propagated)
00166   if ( done && !hasDecayed() ) { 
00167     if ( success == 2 ) 
00168       setMagneticField(fieldMap(layer,r(),success));
00169     else if ( success == 1 )
00170       setMagneticField(fieldMap(layer,z(),success));
00171   }     
00172        
00173   // There is some real material here
00174   fiducial = !(!disk &&  success!=1) &&
00175              !( disk && (success!=2  || r()<innerradius));
00176 
00177   return done;
00178 }
00179 
00180 void 
00181 ParticlePropagator::setPropagationConditions(const TrackerLayer& layer, 
00182                                              bool firstLoop) { 
00183   // Set the magentic field
00184   // setMagneticField(fieldMap(x(),y(),z()));
00185 
00186   // Set R and Z according to the Tracker Layer characteristics.
00187   //  const Surface& surface = layer.surface();
00188 
00189   if( layer.forward() ) {
00190 
00191     //    const BoundDisk & myDisk = dynamic_cast<const BoundDisk&>(surface);
00192     // ParticlePropagator works in mm, whereas the detector geometry is in cm
00193     BaseParticlePropagator::setPropagationConditions(
00194                                   layer.diskOuterRadius(),
00195                                   fabs(layer.disk()->position().z()),
00196                                   firstLoop);       
00197 
00198   // ... or if it is a cylinder barrel 
00199   } else {
00200 
00201     //    const BoundCylinder & myCylinder = dynamic_cast<const BoundCylinder &>(surface);
00202     // ParticlePropagator works now in cm
00203     BaseParticlePropagator::setPropagationConditions(
00204                                          layer.cylinder()->bounds().width()/2.,
00205                                          layer.cylinder()->bounds().length()/2.,
00206                                          firstLoop);
00207   }
00208 
00209 }
00210 

Generated on Tue Jun 9 17:35:13 2009 for CMSSW by  doxygen 1.5.4