CMS 3D CMS Logo

BaseParticlePropagator.h
Go to the documentation of this file.
1 /*Emacs: -*- C++ -*- */
2 #ifndef CommonTools_BaseParticlePropagator_BaseParticlePropagator_h
3 #define CommonTools_BaseParticlePropagator_BaseParticlePropagator_h
4 
79 //FAMOS
81 
83 public:
86 
90  BaseParticlePropagator(const RawParticle& myPart, double r, double z, double B);
91  BaseParticlePropagator(const RawParticle& myPart, double r, double z, double B, double t);
92 
94  void init();
95 
98  bool propagate();
99 
102  bool backPropagate();
103 
107 
113  bool propagateToClosestApproach(double x0 = 0., double y0 = 0, bool first = true);
114  bool propagateToEcal(bool first = true);
115  bool propagateToPreshowerLayer1(bool first = true);
116  bool propagateToPreshowerLayer2(bool first = true);
117  bool propagateToEcalEntrance(bool first = true);
118  bool propagateToHcalEntrance(bool first = true);
119  bool propagateToVFcalEntrance(bool first = true);
120  bool propagateToHcalExit(bool first = true);
121  bool propagateToHOLayer(bool first = true);
122  bool propagateToNominalVertex(const XYZTLorentzVector& hit2 = XYZTLorentzVector(0., 0., 0., 0.));
123  bool propagateToBeamCylinder(const XYZTLorentzVector& v, double radius = 0.);
125  void setPropagationConditions(double r, double z, bool firstLoop = true);
126 
127 private:
130  // RawParticle particle;
132  double rCyl;
133  double rCyl2;
135  double zCyl;
137  double bField;
141  bool debug;
142 
143 protected:
145  int success;
147  bool fiducial;
148 
150  inline double c_light() const { return 299.792458; }
151 
152 private:
154  bool firstLoop;
156  bool decayed;
158  double properTime;
160  int propDir;
161 
162 public:
164  inline RawParticle const& particle() const { return particle_; }
165  inline RawParticle& particle() { return particle_; }
166  void setParticle(RawParticle const& iParticle) { particle_ = iParticle; }
167 
169  inline void setProperDecayTime(double t) { properDecayTime = t; }
170 
172  inline void increaseRCyl(double delta) {
173  rCyl = rCyl + delta;
174  rCyl2 = rCyl * rCyl;
175  }
176 
178  double xyImpactParameter(double x0 = 0., double y0 = 0.) const;
179 
181  inline double zImpactParameter(double x0 = 0, double y0 = 0.) const {
182  // Longitudinal impact parameter
183  return particle_.Z() - particle_.Pz() * std::sqrt(((particle_.X() - x0) * (particle_.X() - x0) +
184  (particle_.Y() - y0) * (particle_.Y() - y0)) /
185  particle_.Perp2());
186  }
187 
189  inline double helixRadius() const {
190  // The helix Radius
191  //
192  // The helix' Radius sign accounts for the orientation of the magnetic field
193  // (+ = along z axis) and the sign of the electric charge of the particle.
194  // It signs the rotation of the (charged) particle around the z axis:
195  // Positive means anti-clockwise, negative means clockwise rotation.
196  //
197  // The radius is returned in cm to match the units in RawParticle.
198  return particle_.charge() == 0 ? 0.0 : -particle_.Pt() / (c_light() * 1e-5 * bField * particle_.charge());
199  }
200 
201  inline double helixRadius(double pT) const {
202  // a faster version of helixRadius, once Perp() has been computed
203  return particle_.charge() == 0 ? 0.0 : -pT / (c_light() * 1e-5 * bField * particle_.charge());
204  }
205 
207  inline double helixStartPhi() const {
208  // The azimuth of the momentum at the vertex
209  return particle_.Px() == 0.0 && particle_.Py() == 0.0 ? 0.0 : std::atan2(particle_.Py(), particle_.Px());
210  }
211 
213  inline double helixCentreX() const {
214  // The x coordinate of the helix axis
215  return particle_.X() - helixRadius() * std::sin(helixStartPhi());
216  }
217 
218  inline double helixCentreX(double radius, double phi) const {
219  // Fast version of helixCentreX()
220  return particle_.X() - radius * std::sin(phi);
221  }
222 
224  inline double helixCentreY() const {
225  // The y coordinate of the helix axis
226  return particle_.Y() + helixRadius() * std::cos(helixStartPhi());
227  }
228 
229  inline double helixCentreY(double radius, double phi) const {
230  // Fast version of helixCentreX()
231  return particle_.Y() + radius * std::cos(phi);
232  }
233 
235  inline double helixCentreDistToAxis() const {
236  // The distance between the cylinder and the helix axes
237  double xC = helixCentreX();
238  double yC = helixCentreY();
239  return std::sqrt(xC * xC + yC * yC);
240  }
241 
242  inline double helixCentreDistToAxis(double xC, double yC) const {
243  // Faster version of helixCentreDistToAxis
244  return std::sqrt(xC * xC + yC * yC);
245  }
246 
248  inline double helixCentrePhi() const {
249  // The azimuth if the vector joining the cylinder and the helix axes
250  double xC = helixCentreX();
251  double yC = helixCentreY();
252  return xC == 0.0 && yC == 0.0 ? 0.0 : std::atan2(yC, xC);
253  }
254 
255  inline double helixCentrePhi(double xC, double yC) const {
256  // Faster version of helixCentrePhi()
257  return xC == 0.0 && yC == 0.0 ? 0.0 : std::atan2(yC, xC);
258  }
259 
261  inline bool inside() const {
262  return (particle_.R2() < rCyl2 - 0.00001 * rCyl && fabs(particle_.Z()) < zCyl - 0.00001);
263  }
264 
265  inline bool inside(double rPos2) const {
266  return (rPos2 < rCyl2 - 0.00001 * rCyl && fabs(particle_.Z()) < zCyl - 0.00001);
267  }
268 
270  inline bool onSurface() const { return (onBarrel() || onEndcap()); }
271 
272  inline bool onSurface(double rPos2) const { return (onBarrel(rPos2) || onEndcap(rPos2)); }
273 
275  inline bool onBarrel() const {
276  double rPos2 = particle_.R2();
277  return (fabs(rPos2 - rCyl2) < 0.00001 * rCyl && fabs(particle_.Z()) <= zCyl);
278  }
279 
280  inline bool onBarrel(double rPos2) const {
281  return (fabs(rPos2 - rCyl2) < 0.00001 * rCyl && fabs(particle_.Z()) <= zCyl);
282  }
283 
285  inline bool onEndcap() const { return (fabs(fabs(particle_.Z()) - zCyl) < 0.00001 && particle_.R2() <= rCyl2); }
286 
287  inline bool onEndcap(double rPos2) const { return (fabs(fabs(particle_.Z()) - zCyl) < 0.00001 && rPos2 <= rCyl2); }
288 
290  inline bool onFiducial() const { return fiducial; }
291 
293  inline bool hasDecayed() const { return decayed; }
294 
296  inline int getSuccess() const { return success; }
297 
299  inline void setMagneticField(double b) { bField = b; }
300 
302  inline double getMagneticField() const { return bField; }
303 
305  inline void setDebug() { debug = true; }
306  inline void resetDebug() { debug = false; }
307 };
308 
309 #endif
BaseParticlePropagator::helixCentrePhi
double helixCentrePhi(double xC, double yC) const
Definition: BaseParticlePropagator.h:255
BaseParticlePropagator::propagateToHcalExit
bool propagateToHcalExit(bool first=true)
Definition: BaseParticlePropagator.cc:528
BaseParticlePropagator::onEndcap
bool onEndcap() const
Is the vertex already on the cylinder endcap ?
Definition: BaseParticlePropagator.h:285
RawParticle
Definition: RawParticle.h:37
BaseParticlePropagator::propagateToEcalEntrance
bool propagateToEcalEntrance(bool first=true)
Definition: BaseParticlePropagator.cc:450
BaseParticlePropagator::particle
RawParticle const & particle() const
The particle being propagated.
Definition: BaseParticlePropagator.h:164
BaseParticlePropagator::propDir
int propDir
The propagation direction.
Definition: BaseParticlePropagator.h:160
BaseParticlePropagator::helixCentreX
double helixCentreX() const
The x coordinate of the helix axis.
Definition: BaseParticlePropagator.h:213
RawParticle::R2
double R2() const
vertex radius**2
Definition: RawParticle.h:291
BaseParticlePropagator::onBarrel
bool onBarrel() const
Is the vertex already on the cylinder barrel ?
Definition: BaseParticlePropagator.h:275
BaseParticlePropagator::decayed
bool decayed
The particle decayed while propagated !
Definition: BaseParticlePropagator.h:156
BaseParticlePropagator::rCyl2
double rCyl2
Definition: BaseParticlePropagator.h:133
RawParticle::Pt
double Pt() const
transverse momentum
Definition: RawParticle.h:308
BaseParticlePropagator::resetDebug
void resetDebug()
Definition: BaseParticlePropagator.h:306
BaseParticlePropagator::onSurface
bool onSurface() const
Is the vertex already on the cylinder surface ?
Definition: BaseParticlePropagator.h:270
BaseParticlePropagator::getSuccess
int getSuccess() const
Has propagation been performed and was barrel or endcap reached ?
Definition: BaseParticlePropagator.h:296
XYZTLorentzVector
math::XYZTLorentzVector XYZTLorentzVector
Definition: RawParticle.h:25
BaseParticlePropagator::setProperDecayTime
void setProperDecayTime(double t)
Set the proper decay time.
Definition: BaseParticlePropagator.h:169
findQualityFiles.v
v
Definition: findQualityFiles.py:179
RawParticle::charge
double charge() const
get the MEASURED charge
Definition: RawParticle.h:294
dqmdumpme.first
first
Definition: dqmdumpme.py:55
BaseParticlePropagator
Definition: BaseParticlePropagator.h:82
BaseParticlePropagator::debug
bool debug
The debug level.
Definition: BaseParticlePropagator.h:141
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
RawParticle::Z
double Z() const
z of vertex
Definition: RawParticle.h:288
BaseParticlePropagator::propagateToHcalEntrance
bool propagateToHcalEntrance(bool first=true)
Definition: BaseParticlePropagator.cc:476
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
BaseParticlePropagator::backPropagate
bool backPropagate()
Definition: BaseParticlePropagator.cc:291
BaseParticlePropagator::propagateToPreshowerLayer2
bool propagateToPreshowerLayer2(bool first=true)
Definition: BaseParticlePropagator.cc:431
BaseParticlePropagator::inside
bool inside(double rPos2) const
Definition: BaseParticlePropagator.h:265
PVValHelper::pT
Definition: PVValidationHelpers.h:70
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
BaseParticlePropagator::bField
double bField
Magnetic field in the cylinder, oriented along the Z axis.
Definition: BaseParticlePropagator.h:137
BaseParticlePropagator::getMagneticField
double getMagneticField() const
Get the magnetic field.
Definition: BaseParticlePropagator.h:302
DDAxes::z
BaseParticlePropagator::helixCentreY
double helixCentreY() const
The y coordinate of the helix axis.
Definition: BaseParticlePropagator.h:224
BaseParticlePropagator::propagateToHOLayer
bool propagateToHOLayer(bool first=true)
Definition: BaseParticlePropagator.cc:545
BaseParticlePropagator::zCyl
double zCyl
Half-height of the cylinder (centred at 0,0,0) to which propagation is done.
Definition: BaseParticlePropagator.h:135
OrderedSet.t
t
Definition: OrderedSet.py:90
b
double b
Definition: hdecay.h:118
BaseParticlePropagator::inside
bool inside() const
Is the vertex inside the cylinder ? (stricly inside : true)
Definition: BaseParticlePropagator.h:261
BaseParticlePropagator::zImpactParameter
double zImpactParameter(double x0=0, double y0=0.) const
Longitudinal impact parameter.
Definition: BaseParticlePropagator.h:181
BaseParticlePropagator::helixCentrePhi
double helixCentrePhi() const
The azimuth if the vector joining the cylinder and the helix axes.
Definition: BaseParticlePropagator.h:248
BaseParticlePropagator::fiducial
bool fiducial
The particle traverses some real material.
Definition: BaseParticlePropagator.h:147
BaseParticlePropagator::particle
RawParticle & particle()
Definition: BaseParticlePropagator.h:165
BaseParticlePropagator::propagate
bool propagate()
Definition: BaseParticlePropagator.cc:34
BaseParticlePropagator::init
void init()
Initialize internal switches and quantities.
Definition: BaseParticlePropagator.cc:17
BaseParticlePropagator::helixStartPhi
double helixStartPhi() const
The azimuth of the momentum at the vertex.
Definition: BaseParticlePropagator.h:207
dumpMFGeometry_cfg.delta
delta
Definition: dumpMFGeometry_cfg.py:25
BaseParticlePropagator::increaseRCyl
void increaseRCyl(double delta)
Just an internal trick.
Definition: BaseParticlePropagator.h:172
RawParticle::Y
double Y() const
y of vertex
Definition: RawParticle.h:287
BaseParticlePropagator::helixCentreDistToAxis
double helixCentreDistToAxis(double xC, double yC) const
Definition: BaseParticlePropagator.h:242
BaseParticlePropagator::success
int success
0:propagation still be done, 1:reached 'barrel', 2:reached 'endcaps'
Definition: BaseParticlePropagator.h:145
RawParticle::Py
double Py() const
y of the momentum
Definition: RawParticle.h:300
BaseParticlePropagator::propagateToPreshowerLayer1
bool propagateToPreshowerLayer1(bool first=true)
Definition: BaseParticlePropagator.cc:412
BaseParticlePropagator::c_light
double c_light() const
The speed of light in mm/ns (!) without clhep (yeaaahhh!)
Definition: BaseParticlePropagator.h:150
BaseParticlePropagator::properTime
double properTime
The proper time of the particle.
Definition: BaseParticlePropagator.h:158
BaseParticlePropagator::BaseParticlePropagator
BaseParticlePropagator()
Default c'tor.
Definition: BaseParticlePropagator.cc:5
RawParticle::Perp2
double Perp2() const
perpendicular momentum squared
Definition: RawParticle.h:311
BaseParticlePropagator::propagateToNominalVertex
bool propagateToNominalVertex(const XYZTLorentzVector &hit2=XYZTLorentzVector(0., 0., 0., 0.))
Definition: BaseParticlePropagator.cc:566
BaseParticlePropagator::rCyl
double rCyl
Simulated particle that is to be resp has been propagated.
Definition: BaseParticlePropagator.h:132
BaseParticlePropagator::particle_
RawParticle particle_
Definition: BaseParticlePropagator.h:128
BaseParticlePropagator::helixCentreX
double helixCentreX(double radius, double phi) const
Definition: BaseParticlePropagator.h:218
BaseParticlePropagator::setMagneticField
void setMagneticField(double b)
Set the magnetic field.
Definition: BaseParticlePropagator.h:299
BaseParticlePropagator::onBarrel
bool onBarrel(double rPos2) const
Definition: BaseParticlePropagator.h:280
BaseParticlePropagator::setPropagationConditions
void setPropagationConditions(double r, double z, bool firstLoop=true)
Set the propagation characteristics (rCyl, zCyl and first loop only)
Definition: BaseParticlePropagator.cc:318
alignCSCRings.r
r
Definition: alignCSCRings.py:93
BaseParticlePropagator::firstLoop
bool firstLoop
Do only the first half-loop.
Definition: BaseParticlePropagator.h:154
DDAxes::phi
TtFullHadDaughter::B
static const std::string B
Definition: TtFullHadronicEvent.h:9
BaseParticlePropagator::propagated
BaseParticlePropagator propagated() const
Definition: BaseParticlePropagator.cc:304
BaseParticlePropagator::xyImpactParameter
double xyImpactParameter(double x0=0., double y0=0.) const
Transverse impact parameter.
Definition: BaseParticlePropagator.cc:706
BaseParticlePropagator::helixRadius
double helixRadius() const
The helix Radius.
Definition: BaseParticlePropagator.h:189
RawParticle::X
double X() const
x of vertex
Definition: RawParticle.h:286
BaseParticlePropagator::propagateToBeamCylinder
bool propagateToBeamCylinder(const XYZTLorentzVector &v, double radius=0.)
Definition: BaseParticlePropagator.cc:586
BaseParticlePropagator::onSurface
bool onSurface(double rPos2) const
Definition: BaseParticlePropagator.h:272
RawParticle.h
BaseParticlePropagator::onFiducial
bool onFiducial() const
Is the vertex on some material ?
Definition: BaseParticlePropagator.h:290
CosmicsPD_Skims.radius
radius
Definition: CosmicsPD_Skims.py:135
BaseParticlePropagator::helixCentreDistToAxis
double helixCentreDistToAxis() const
The distance between the cylinder and the helix axes.
Definition: BaseParticlePropagator.h:235
BaseParticlePropagator::onEndcap
bool onEndcap(double rPos2) const
Definition: BaseParticlePropagator.h:287
BaseParticlePropagator::propagateToClosestApproach
bool propagateToClosestApproach(double x0=0., double y0=0, bool first=true)
Definition: BaseParticlePropagator.cc:325
BaseParticlePropagator::propagateToVFcalEntrance
bool propagateToVFcalEntrance(bool first=true)
Definition: BaseParticlePropagator.cc:505
BaseParticlePropagator::helixRadius
double helixRadius(double pT) const
Definition: BaseParticlePropagator.h:201
BaseParticlePropagator::helixCentreY
double helixCentreY(double radius, double phi) const
Definition: BaseParticlePropagator.h:229
BaseParticlePropagator::properDecayTime
double properDecayTime
The proper decay time of the particle.
Definition: BaseParticlePropagator.h:139
BaseParticlePropagator::setParticle
void setParticle(RawParticle const &iParticle)
Definition: BaseParticlePropagator.h:166
BaseParticlePropagator::setDebug
void setDebug()
Set the debug leve;.
Definition: BaseParticlePropagator.h:305
BaseParticlePropagator::propagateToEcal
bool propagateToEcal(bool first=true)
Definition: BaseParticlePropagator.cc:398
RawParticle::Px
double Px() const
x of the momentum
Definition: RawParticle.h:297
RawParticle::Pz
double Pz() const
z of the momentum
Definition: RawParticle.h:303
BaseParticlePropagator::hasDecayed
bool hasDecayed() const
Has the particle decayed while propagated ?
Definition: BaseParticlePropagator.h:293
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37