00001
00002 #include "DataFormats/GeometrySurface/interface/BoundDisk.h"
00003 #include "DataFormats/GeometrySurface/interface/BoundCylinder.h"
00004
00005
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
00075 initProperDecayTime();
00076 else
00077
00078 this->setProperDecayTime(simTrack.decayTime());
00079 }
00080
00081 ParticlePropagator::ParticlePropagator(const ParticlePropagator& myPropPart) :
00082 BaseParticlePropagator(myPropPart),
00083 theFieldMap(myPropPart.theFieldMap)
00084 {
00085
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
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
00131
00132
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
00140
00141
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
00153
00154 double innerradius = disk ? layer.diskInnerRadius() : -999. ;
00155
00156
00157
00158
00159
00160
00161
00162
00163 bool done = propagate();
00164
00165
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
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
00184
00185
00186
00187
00188
00189 if( layer.forward() ) {
00190
00191
00192
00193 BaseParticlePropagator::setPropagationConditions(
00194 layer.diskOuterRadius(),
00195 fabs(layer.disk()->position().z()),
00196 firstLoop);
00197
00198
00199 } else {
00200
00201
00202
00203 BaseParticlePropagator::setPropagationConditions(
00204 layer.cylinder()->bounds().width()/2.,
00205 layer.cylinder()->bounds().length()/2.,
00206 firstLoop);
00207 }
00208
00209 }
00210