CMS 3D CMS Logo

ParticlePropagator.cc
Go to the documentation of this file.
1 //CMSSW headers
4 
5 //FAMOS headers
14 
17 
19  double RCyl, double ZCyl,
20  const MagneticFieldMap* aFieldMap,
21  const RandomEngineAndDistribution* engine,
22  const HepPDT::ParticleDataTable* table) :
23  BaseParticlePropagator(myPart,RCyl,ZCyl,0.),
24  theFieldMap(aFieldMap),
25  random(engine),
26  theTable(table)
27 {
30 }
31 
33  const MagneticFieldMap* aFieldMap,
34  const RandomEngineAndDistribution* engine,
35  const HepPDT::ParticleDataTable* table) :
36  BaseParticlePropagator(myPart,0.,0.,0.),
37  theFieldMap(aFieldMap),
38  random(engine),
39  theTable(table)
40 
41 {
44 }
45 
47  const XYZTLorentzVector& vert, float q,
48  const MagneticFieldMap* aFieldMap,
49  const HepPDT::ParticleDataTable* table) :
50  BaseParticlePropagator(RawParticle(mom,vert,q),0.,0.,0.),
51  theFieldMap(aFieldMap),
52  random(nullptr),
53  theTable(table)
54 {
56 }
57 
59  const XYZVector& vert, float q,
60  const MagneticFieldMap* aFieldMap,
61  const HepPDT::ParticleDataTable* table) :
63  RawParticle(mom,XYZTLorentzVector(vert.X(),vert.Y(),vert.Z(),0.0), q),0.,0.,0.),
64  theFieldMap(aFieldMap),
65  random(nullptr),
66  theTable(table)
67 {
69 }
70 
72  const MagneticFieldMap* aFieldMap,
73  const RandomEngineAndDistribution* engine,
74  const HepPDT::ParticleDataTable* table) :
76  simTrack.type(),
77  simTrack.momentum(),
78  simTrack.vertex().position()),
79  0.,0.,0.),
80  theFieldMap(aFieldMap),
81  random(engine),
82  theTable(table)
83 {
85  if ( simTrack.decayTime() < 0. ) {
86  if ( simTrack.nDaughters() )
87  // This particle already decayed, don't decay it twice
88  this->setProperDecayTime(1E99);
89  else
90  // This particle hasn't decayed yet. Decay time according to particle lifetime
92  } else {
93  // Decay time pre-defined at generator level
94  this->setProperDecayTime(simTrack.decayTime());
95  }
96 }
97 
99  BaseParticlePropagator(myPropPart),
100  theFieldMap(myPropPart.theFieldMap)
101 {
102  // setMagneticField(fieldMap(x(),y(),z()));
103 }
104 
106  const MagneticFieldMap* aFieldMap,
107  const HepPDT::ParticleDataTable* table) :
108  BaseParticlePropagator(myPropPart),
109  theFieldMap(aFieldMap),
110  theTable(table)
111 {
113 }
114 
115 
116 void
118 
119  // And this is the proper time at which the particle will decay
120  double properDecayTime =
121  (particle().pid()==0||particle().pid()==22||abs(particle().pid())==11||abs(particle().pid())==2112||abs(particle().pid())==2212||
122  !random) ?
123  1E99 : -pdg::cTau(particle().pid(), theTable) * std::log(random->flatShoot());
124 
125  this->setProperDecayTime(properDecayTime);
126 
127 }
128 
129 
130 bool
132  setMagneticField(fieldMap(0.,0.,0.));
134 }
135 
136 bool
138  setMagneticField(fieldMap(0.,0.,0.));
140 }
141 
145 }
146 
147 double
148 ParticlePropagator::fieldMap(double xx,double yy, double zz) {
149  // Arguments now passed in cm.
150  // return MagneticFieldMap::instance()->inTesla(GlobalPoint(xx/10.,yy/10.,zz/10.)).z();
151  // Return a dummy value for neutral particles!
152  return particle().charge() == 0.0 || theFieldMap == nullptr ?
153  4. : theFieldMap->inTeslaZ(GlobalPoint(xx,yy,zz));
154 }
155 
156 double
157 ParticlePropagator::fieldMap(const TrackerLayer& layer, double coord, int success) {
158  // Arguments now passed in cm.
159  // return MagneticFieldMap::instance()->inTesla(GlobalPoint(xx/10.,yy/10.,zz/10.)).z();
160  // Return a dummy value for neutral particles!
161  return particle().charge() == 0.0 || theFieldMap == nullptr ?
162  4. : theFieldMap->inTeslaZ(layer,coord,success);
163 }
164 
165 bool
167 
168 
169  fiducial = true;
170  BoundDisk const* disk = layer.disk();
171  // bool disk = layer.forward();
172  // double innerradius=-999;
173  double innerradius = disk ? layer.diskInnerRadius() : -999. ;
174 
175  // if( disk ) {
176  // const Surface& surface = layer.surface();
177  // const BoundDisk & myDisk = dynamic_cast<const BoundDisk&>(surface);
178  // innerradius=myDisk.innerRadius();
179  // innerradius=myDisk->innerRadius();
180  // }
181 
182  bool done = propagate();
183 
184  // Set the magnetic field at the new location (if succesfully propagated)
185  if ( done && !hasDecayed() ) {
186  if ( success == 2 )
188  else if ( success == 1 )
190  }
191 
192  // There is some real material here
193  fiducial = !(!disk && success!=1) &&
194  !( disk && (success!=2 || particle().r()<innerradius));
195 
196  return done;
197 }
198 
199 void
201  bool firstLoop) {
202  // Set the magentic field
203  // setMagneticField(fieldMap(x(),y(),z()));
204 
205  // Set R and Z according to the Tracker Layer characteristics.
206  // const Surface& surface = layer.surface();
207 
208  if( layer.forward() ) {
209 
210  // const BoundDisk & myDisk = dynamic_cast<const BoundDisk&>(surface);
211  // ParticlePropagator works in mm, whereas the detector geometry is in cm
213  layer.diskOuterRadius(),
214  fabs(layer.disk()->position().z()),
215  firstLoop);
216 
217  // ... or if it is a cylinder barrel
218  } else {
219 
220  // const BoundCylinder & myCylinder = dynamic_cast<const BoundCylinder &>(surface);
221  // ParticlePropagator works now in cm
223  layer.cylinder()->bounds().width()/2.,
224  layer.cylinder()->bounds().length()/2.,
225  firstLoop);
226  }
227 
228 }
229 
const MagneticFieldMap * theFieldMap
bool hasDecayed() const
Has the particle decayed while propagated ?
type
Definition: HCALResponse.h:21
ParticlePropagator()
Default c&#39;tor.
double cTau(int pdgID, const HepPDT::ParticleDataTable *pdt)
double inTeslaZ(const GlobalPoint &) const
double flatShoot(double xmin=0.0, double xmax=1.0) const
bool propagateToNominalVertex(const XYZTLorentzVector &hit2=XYZTLorentzVector(0., 0., 0., 0.))
HepPDT::ParticleDataTable ParticleDataTable
bool forward() const
Is the layer forward ?
Definition: TrackerLayer.h:70
bool propagateToClosestApproach(double x0=0., double y0=0., bool first=true)
bool firstLoop
Do only the first half-loop.
int success
0:propagation still be done, 1:reached &#39;barrel&#39;, 2:reached &#39;endcaps&#39;
#define nullptr
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
#define X(str)
Definition: MuonsGrabber.cc:48
bool propagateToBoundSurface(const TrackerLayer &)
int nDaughters() const
Number of daughters.
void setPropagationConditions(double r, double z, bool firstLoop=true)
Set the propagation characteristics (rCyl, zCyl and first loop only)
int pid() const
get the HEP particle ID number
Definition: RawParticle.h:296
void setMagneticField(double b)
Set the magnetic field.
double fieldMap(double x, double y, double z)
TRandom random
Definition: MVATrainer.cc:138
RawParticle const & particle() const
The particle being propagated.
bool propagateToClosestApproach(double x0=0., double y0=0, bool first=true)
const HepPDT::ParticleDataTable * theTable
double properDecayTime
The proper decay time of the particle.
double diskInnerRadius() const
Returns the inner radius of a disk.
Definition: TrackerLayer.h:85
BoundDisk const * disk() const
Returns the surface.
Definition: TrackerLayer.h:79
void setPropagationConditions(const TrackerLayer &, bool firstLoop=true)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double charge() const
get the MEASURED charge
Definition: RawParticle.h:313
BaseParticlePropagator propagated() const
ParticlePropagator propagated() const
void setProperDecayTime(double t)
Set the proper decay time.
static int position[264][3]
Definition: ReadPGInfo.cc:509
bool propagateToNominalVertex(const XYZTLorentzVector &hit2=XYZTLorentzVector(0., 0., 0., 0.))
math::XYZVector XYZVector
Definition: RawParticle.h:28
double diskOuterRadius() const
Returns the outer radius of a disk.
Definition: TrackerLayer.h:88
double decayTime() const
Return the pre-defined decay time.
Definition: FSimTrack.h:213
const RandomEngineAndDistribution * random
BoundCylinder const * cylinder() const
Returns the cylinder.
Definition: TrackerLayer.h:76
bool fiducial
The particle traverses some real material.
math::XYZTLorentzVector XYZTLorentzVector
Definition: RawParticle.h:27