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 
84 public:
85 
88 
92  BaseParticlePropagator(const RawParticle& myPart,
93  double r, double z, double B);
94  BaseParticlePropagator(const RawParticle& myPart,
95  double r, double z, double B, double t);
96 
98  void init();
99 
102  bool propagate();
103 
106  bool backPropagate();
107 
111 
117  bool propagateToClosestApproach(double x0=0.,double y0=0,bool first=true);
118  bool propagateToEcal(bool first=true);
119  bool propagateToPreshowerLayer1(bool first=true);
120  bool propagateToPreshowerLayer2(bool first=true);
121  bool propagateToEcalEntrance(bool first=true);
122  bool propagateToHcalEntrance(bool first=true);
123  bool propagateToVFcalEntrance(bool first=true);
124  bool propagateToHcalExit(bool first=true);
125  bool propagateToHOLayer(bool first=true);
126  bool propagateToNominalVertex(const XYZTLorentzVector& hit2=XYZTLorentzVector(0.,0.,0.,0.));
127  bool propagateToBeamCylinder(const XYZTLorentzVector& v, double radius=0.);
129  void setPropagationConditions(double r, double z, bool firstLoop=true);
130 
131 private:
134  // RawParticle particle;
136  double rCyl;
137  double rCyl2;
139  double zCyl;
141  double bField;
145  bool debug;
146 
147 protected:
149  int success;
151  bool fiducial;
152 
154  inline double c_light() const { return 299.792458; }
155 
156 private:
158  bool firstLoop;
160  bool decayed;
162  double properTime;
164  int propDir;
165 
166 public:
167 
169  inline RawParticle const& particle() const { return particle_;}
170  inline RawParticle& particle() { return particle_;}
171  void setParticle(RawParticle const& iParticle) { particle_=iParticle;}
172 
174  inline void setProperDecayTime(double t) { properDecayTime = t; }
175 
177  inline void increaseRCyl(double delta) {rCyl = rCyl + delta; rCyl2 = rCyl*rCyl; }
178 
180  double xyImpactParameter(double x0=0., double y0=0.) const;
181 
183  inline double zImpactParameter(double x0=0, double y0=0.) const {
184  // Longitudinal impact parameter
185  return particle_.Z() - particle_.Pz() * std::sqrt( ((particle_.X()-x0)*(particle_.X()-x0) + (particle_.Y()-y0)*(particle_.Y()-y0) ) / 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  inline bool inside(double rPos2) const {
265  return (rPos2<rCyl2-0.00001*rCyl && fabs(particle_.Z())<zCyl-0.00001);}
266 
267 
269  inline bool onSurface() const {
270  return ( onBarrel() || onEndcap() );
271  }
272 
273  inline bool onSurface(double rPos2) const {
274  return ( onBarrel(rPos2) || onEndcap(rPos2) );
275  }
276 
278  inline bool onBarrel() const {
279  double rPos2 = particle_.R2();
280  return ( fabs(rPos2-rCyl2) < 0.00001*rCyl && fabs(particle_.Z()) <= zCyl );
281  }
282 
283  inline bool onBarrel(double rPos2) const {
284  return ( fabs(rPos2-rCyl2) < 0.00001*rCyl && fabs(particle_.Z()) <= zCyl );
285  }
286 
288  inline bool onEndcap() const {
289  return ( fabs(fabs(particle_.Z())-zCyl) < 0.00001 && particle_.R2() <= rCyl2 );
290  }
291 
292  inline bool onEndcap(double rPos2) const {
293  return ( fabs(fabs(particle_.Z())-zCyl) < 0.00001 && rPos2 <= rCyl2 );
294  }
295 
297  inline bool onFiducial() const { return fiducial; }
298 
300  inline bool hasDecayed() const { return decayed; }
301 
303  inline int getSuccess() const { return success; }
304 
306  inline void setMagneticField(double b) { bField=b; }
307 
309  inline double getMagneticField() const { return bField; }
310 
312  inline void setDebug() { debug = true; }
313  inline void resetDebug() { debug = false; }
314 
315 };
316 
317 #endif
bool hasDecayed() const
Has the particle decayed while propagated ?
bool onSurface(double rPos2) const
dbl * delta
Definition: mlp_gen.cc:36
double zCyl
Half-height of the cylinder (centred at 0,0,0) to which propagation is done.
double helixRadius() const
The helix Radius.
double zImpactParameter(double x0=0, double y0=0.) const
Longitudinal impact parameter.
double helixCentrePhi() const
The azimuth if the vector joining the cylinder and the helix axes.
bool propagateToPreshowerLayer1(bool first=true)
bool inside(double rPos2) const
double rCyl
Simulated particle that is to be resp has been propagated.
bool propagateToNominalVertex(const XYZTLorentzVector &hit2=XYZTLorentzVector(0., 0., 0., 0.))
void init()
Initialize internal switches and quantities.
double Perp2() const
perpendicular momentum squared
Definition: RawParticle.h:330
void increaseRCyl(double delta)
Just an internal trick.
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;
double properTime
The proper time of the particle.
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
BaseParticlePropagator()
Default c&#39;tor.
int getSuccess() const
Has propagation been performed and was barrel or endcap reached ?
bool propagateToBeamCylinder(const XYZTLorentzVector &v, double radius=0.)
void setPropagationConditions(double r, double z, bool firstLoop=true)
Set the propagation characteristics (rCyl, zCyl and first loop only)
void setMagneticField(double b)
Set the magnetic field.
RawParticle const & particle() const
The particle being propagated.
double helixCentrePhi(double xC, double yC) const
double c_light() const
The speed of light in mm/ns (!) without clhep (yeaaahhh!)
double R2() const
vertex radius**2
Definition: RawParticle.h:310
bool propagateToEcal(bool first=true)
void setParticle(RawParticle const &iParticle)
bool propagateToClosestApproach(double x0=0., double y0=0, bool first=true)
double helixCentreX() const
The x coordinate of the helix axis.
bool propagateToVFcalEntrance(bool first=true)
double helixCentreDistToAxis() const
The distance between the cylinder and the helix axes.
void setDebug()
Set the debug leve;.
double properDecayTime
The proper decay time of the particle.
T sqrt(T t)
Definition: SSEVec.h:18
bool propagateToHcalExit(bool first=true)
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
double Y() const
y of vertex
Definition: RawParticle.h:306
double Py() const
y of the momentum
Definition: RawParticle.h:319
double Pt() const
transverse momentum
Definition: RawParticle.h:327
double Z() const
z of vertex
Definition: RawParticle.h:307
bool onEndcap(double rPos2) const
static const std::string B
double Pz() const
z of the momentum
Definition: RawParticle.h:322
double charge() const
get the MEASURED charge
Definition: RawParticle.h:313
double helixCentreY(double radius, double phi) const
int propDir
The propagation direction.
bool propagateToEcalEntrance(bool first=true)
double helixCentreX(double radius, double phi) const
bool onEndcap() const
Is the vertex already on the cylinder endcap ?
bool decayed
The particle decayed while propagated !
BaseParticlePropagator propagated() const
double helixCentreY() const
The y coordinate of the helix axis.
bool inside() const
Is the vertex inside the cylinder ? (stricly inside : true)
double b
Definition: hdecay.h:120
bool onSurface() const
Is the vertex already on the cylinder surface ?
double X() const
x of vertex
Definition: RawParticle.h:305
bool debug
The debug level.
double helixStartPhi() const
The azimuth of the momentum at the vertex.
double getMagneticField() const
Get the magnetic field.
bool propagateToHcalEntrance(bool first=true)
double helixRadius(double pT) const
void setProperDecayTime(double t)
Set the proper decay time.
double Px() const
x of the momentum
Definition: RawParticle.h:316
double bField
Magnetic field in the cylinder, oriented along the Z axis.
bool onFiducial() const
Is the vertex on some material ?
bool propagateToHOLayer(bool first=true)
bool onBarrel(double rPos2) const
bool onBarrel() const
Is the vertex already on the cylinder barrel ?
bool propagateToPreshowerLayer2(bool first=true)
double helixCentreDistToAxis(double xC, double yC) const
double xyImpactParameter(double x0=0., double y0=0.) const
Transverse impact parameter.
bool fiducial
The particle traverses some real material.
math::XYZTLorentzVector XYZTLorentzVector
Definition: RawParticle.h:27