test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ParticlePropagator.cc
Go to the documentation of this file.
1 //CMSSW headers
4 
5 //FAMOS headers
12 
15 
17  double RCyl, double ZCyl,
18  const MagneticFieldMap* aFieldMap,
19  const RandomEngineAndDistribution* engine) :
20  BaseParticlePropagator(myPart,RCyl,ZCyl,0.),
21  theFieldMap(aFieldMap),
22  random(engine)
23 {
24  setMagneticField(fieldMap(X(),Y(),Z()));
26 }
27 
29  const MagneticFieldMap* aFieldMap,
30  const RandomEngineAndDistribution* engine) :
31  BaseParticlePropagator(myPart,0.,0.,0.),
32  theFieldMap(aFieldMap),
33  random(engine)
34 
35 {
36  setMagneticField(fieldMap(X(),Y(),Z()));
38 }
39 
41  const XYZTLorentzVector& vert, float q,
42  const MagneticFieldMap* aFieldMap) :
43  BaseParticlePropagator(RawParticle(mom,vert),0.,0.,0.),
44  theFieldMap(aFieldMap),
45  random(0)
46 {
47  setCharge(q);
48  setMagneticField(fieldMap(X(),Y(),Z()));
49 }
50 
52  const XYZVector& vert, float q,
53  const MagneticFieldMap* aFieldMap) :
55  RawParticle(mom,XYZTLorentzVector(vert.X(),vert.Y(),vert.Z(),0.0)),0.,0.,0.),
56  theFieldMap(aFieldMap),
57  random(0)
58 {
59  setCharge(q);
60  setMagneticField(fieldMap(X(),Y(),Z()));
61 }
62 
64  const MagneticFieldMap* aFieldMap,
65  const RandomEngineAndDistribution* engine) :
66  BaseParticlePropagator(RawParticle(simTrack.type(),simTrack.momentum()),
67  0.,0.,0.),
68  theFieldMap(aFieldMap),
69  random(engine)
70 {
71  setVertex(simTrack.vertex().position());
72  setMagneticField(fieldMap(X(),Y(),Z()));
73  if ( simTrack.decayTime() < 0. ) {
74  if ( simTrack.nDaughters() )
75  // This particle already decayed, don't decay it twice
76  this->setProperDecayTime(1E99);
77  else
78  // This particle hasn't decayed yet. Decay time according to particle lifetime
80  } else {
81  // Decay time pre-defined at generator level
82  this->setProperDecayTime(simTrack.decayTime());
83  }
84 }
85 
87  BaseParticlePropagator(myPropPart),
88  theFieldMap(myPropPart.theFieldMap)
89 {
90  // setMagneticField(fieldMap(x(),y(),z()));
91 }
92 
94  const MagneticFieldMap* aFieldMap) :
95  BaseParticlePropagator(myPropPart),
96  theFieldMap(aFieldMap)
97 {
98  setMagneticField(fieldMap(X(),Y(),Z()));
99 }
100 
101 
102 void
104 
105  // And this is the proper time at which the particle will decay
106  double properDecayTime =
107  (pid()==0||pid()==22||abs(pid())==11||abs(pid())==2112||abs(pid())==2212||
108  !random) ?
109  1E99 : -PDGcTau() * std::log(random->flatShoot());
110 
111  this->setProperDecayTime(properDecayTime);
112 
113 }
114 
115 
116 bool
118  setMagneticField(fieldMap(0.,0.,0.));
120 }
121 
122 bool
124  setMagneticField(fieldMap(0.,0.,0.));
126 }
127 
131 }
132 
133 double
134 ParticlePropagator::fieldMap(double xx,double yy, double zz) {
135  // Arguments now passed in cm.
136  // return MagneticFieldMap::instance()->inTesla(GlobalPoint(xx/10.,yy/10.,zz/10.)).z();
137  // Return a dummy value for neutral particles!
138  return charge() == 0.0 || theFieldMap == 0 ?
139  4. : theFieldMap->inTeslaZ(GlobalPoint(xx,yy,zz));
140 }
141 
142 double
143 ParticlePropagator::fieldMap(const TrackerLayer& layer, double coord, int success) {
144  // Arguments now passed in cm.
145  // return MagneticFieldMap::instance()->inTesla(GlobalPoint(xx/10.,yy/10.,zz/10.)).z();
146  // Return a dummy value for neutral particles!
147  return charge() == 0.0 || theFieldMap == 0 ?
148  4. : theFieldMap->inTeslaZ(layer,coord,success);
149 }
150 
151 bool
153 
154 
155  fiducial = true;
156  BoundDisk const* disk = layer.disk();
157  // bool disk = layer.forward();
158  // double innerradius=-999;
159  double innerradius = disk ? layer.diskInnerRadius() : -999. ;
160 
161  // if( disk ) {
162  // const Surface& surface = layer.surface();
163  // const BoundDisk & myDisk = dynamic_cast<const BoundDisk&>(surface);
164  // innerradius=myDisk.innerRadius();
165  // innerradius=myDisk->innerRadius();
166  // }
167 
168  bool done = propagate();
169 
170  // Set the magnetic field at the new location (if succesfully propagated)
171  if ( done && !hasDecayed() ) {
172  if ( success == 2 )
174  else if ( success == 1 )
176  }
177 
178  // There is some real material here
179  fiducial = !(!disk && success!=1) &&
180  !( disk && (success!=2 || r()<innerradius));
181 
182  return done;
183 }
184 
185 void
187  bool firstLoop) {
188  // Set the magentic field
189  // setMagneticField(fieldMap(x(),y(),z()));
190 
191  // Set R and Z according to the Tracker Layer characteristics.
192  // const Surface& surface = layer.surface();
193 
194  if( layer.forward() ) {
195 
196  // const BoundDisk & myDisk = dynamic_cast<const BoundDisk&>(surface);
197  // ParticlePropagator works in mm, whereas the detector geometry is in cm
199  layer.diskOuterRadius(),
200  fabs(layer.disk()->position().z()),
201  firstLoop);
202 
203  // ... or if it is a cylinder barrel
204  } else {
205 
206  // const BoundCylinder & myCylinder = dynamic_cast<const BoundCylinder &>(surface);
207  // ParticlePropagator works now in cm
209  layer.cylinder()->bounds().width()/2.,
210  layer.cylinder()->bounds().length()/2.,
211  firstLoop);
212  }
213 
214 }
215 
const double Z[kNumberCalorimeter]
const MagneticFieldMap * theFieldMap
bool hasDecayed() const
Has the particle decayed while propagated ?
type
Definition: HCALResponse.h:21
void setCharge(float q)
set the MEASURED charge
Definition: RawParticle.cc:139
ParticlePropagator()
Default c&#39;tor.
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.))
bool forward() const
Is the layer forward ?
Definition: TrackerLayer.h:70
double z() const
z of vertex
Definition: RawParticle.h:272
bool propagateToClosestApproach(double x0=0., double y0=0., bool first=true)
bool firstLoop
Do only the first half-loop.
double PDGcTau() const
get the THEORETICAL lifetime
Definition: RawParticle.cc:264
int success
0:propagation still be done, 1:reached &#39;barrel&#39;, 2:reached &#39;endcaps&#39;
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:265
void setMagneticField(double b)
Set the magnetic field.
double fieldMap(double x, double y, double z)
TRandom random
Definition: MVATrainer.cc:138
bool propagateToClosestApproach(double x0=0., double y0=0, bool first=true)
math::XYZVector XYZVector
double properDecayTime
The proper decay time of the particle.
const math::XYZTLorentzVector & position() const
Temporary (until CMSSW moves to Mathcore) - No ! Actually very useful.
Definition: FSimVertex.h:49
double diskInnerRadius() const
Returns the inner radius of a disk.
Definition: TrackerLayer.h:85
double Y() const
y of vertex
Definition: RawParticle.h:275
double Z() const
z of vertex
Definition: RawParticle.h:276
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
const FSimVertex & vertex() const
Origin vertex.
double charge() const
get the MEASURED charge
Definition: RawParticle.h:282
BaseParticlePropagator propagated() const
ParticlePropagator propagated() const
double r() const
vertex radius
Definition: RawParticle.h:280
double X() const
x of vertex
Definition: RawParticle.h:274
void setProperDecayTime(double t)
Set the proper decay time.
bool propagateToNominalVertex(const XYZTLorentzVector &hit2=XYZTLorentzVector(0., 0., 0., 0.))
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:199
const RandomEngineAndDistribution * random
void setVertex(const XYZTLorentzVector &vtx)
set the vertex
Definition: RawParticle.h:288
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:15