File indexing completed on 2024-04-06 12:01:01
0001
0002 #ifndef CommonTools_BaseParticlePropagator_BaseParticlePropagator_h
0003 #define CommonTools_BaseParticlePropagator_BaseParticlePropagator_h
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080 #include "CommonTools/BaseParticlePropagator/interface/RawParticle.h"
0081
0082 class BaseParticlePropagator {
0083 public:
0084
0085 BaseParticlePropagator();
0086
0087
0088
0089
0090 BaseParticlePropagator(const RawParticle& myPart, double r, double z, double B);
0091 BaseParticlePropagator(const RawParticle& myPart, double r, double z, double B, double t);
0092
0093
0094 void init();
0095
0096
0097
0098 bool propagate();
0099
0100
0101
0102 bool backPropagate();
0103
0104
0105
0106 BaseParticlePropagator propagated() const;
0107
0108
0109
0110
0111
0112
0113 bool propagateToClosestApproach(double x0 = 0., double y0 = 0, bool first = true);
0114 bool propagateToEcal(bool first = true);
0115 bool propagateToPreshowerLayer1(bool first = true);
0116 bool propagateToPreshowerLayer2(bool first = true);
0117 bool propagateToEcalEntrance(bool first = true);
0118 bool propagateToHcalEntrance(bool first = true);
0119 bool propagateToVFcalEntrance(bool first = true);
0120 bool propagateToHcalExit(bool first = true);
0121 bool propagateToHOLayer(bool first = true);
0122 bool propagateToNominalVertex(const XYZTLorentzVector& hit2 = XYZTLorentzVector(0., 0., 0., 0.));
0123 bool propagateToBeamCylinder(const XYZTLorentzVector& v, double radius = 0.);
0124
0125 void setPropagationConditions(double r, double z, bool firstLoop = true);
0126
0127 private:
0128 RawParticle particle_;
0129
0130
0131
0132 double rCyl;
0133 double rCyl2;
0134
0135 double zCyl;
0136
0137 double bField;
0138
0139 double properDecayTime;
0140
0141 bool debug;
0142
0143 protected:
0144
0145 int success;
0146
0147 bool fiducial;
0148
0149
0150 inline double c_light() const { return 299.792458; }
0151
0152 private:
0153
0154 bool firstLoop;
0155
0156 bool decayed;
0157
0158 double properTime;
0159
0160 int propDir;
0161
0162 public:
0163
0164 inline RawParticle const& particle() const { return particle_; }
0165 inline RawParticle& particle() { return particle_; }
0166 void setParticle(RawParticle const& iParticle) { particle_ = iParticle; }
0167
0168
0169 inline void setProperDecayTime(double t) { properDecayTime = t; }
0170
0171
0172 inline void increaseRCyl(double delta) {
0173 rCyl = rCyl + delta;
0174 rCyl2 = rCyl * rCyl;
0175 }
0176
0177
0178 double xyImpactParameter(double x0 = 0., double y0 = 0.) const;
0179
0180
0181 inline double zImpactParameter(double x0 = 0, double y0 = 0.) const {
0182
0183 return particle_.Z() - particle_.Pz() * std::sqrt(((particle_.X() - x0) * (particle_.X() - x0) +
0184 (particle_.Y() - y0) * (particle_.Y() - y0)) /
0185 particle_.Perp2());
0186 }
0187
0188
0189 inline double helixRadius() const {
0190
0191
0192
0193
0194
0195
0196
0197
0198 return particle_.charge() == 0 ? 0.0 : -particle_.Pt() / (c_light() * 1e-5 * bField * particle_.charge());
0199 }
0200
0201 inline double helixRadius(double pT) const {
0202
0203 return particle_.charge() == 0 ? 0.0 : -pT / (c_light() * 1e-5 * bField * particle_.charge());
0204 }
0205
0206
0207 inline double helixStartPhi() const {
0208
0209 return particle_.Px() == 0.0 && particle_.Py() == 0.0 ? 0.0 : std::atan2(particle_.Py(), particle_.Px());
0210 }
0211
0212
0213 inline double helixCentreX() const {
0214
0215 return particle_.X() - helixRadius() * std::sin(helixStartPhi());
0216 }
0217
0218 inline double helixCentreX(double radius, double phi) const {
0219
0220 return particle_.X() - radius * std::sin(phi);
0221 }
0222
0223
0224 inline double helixCentreY() const {
0225
0226 return particle_.Y() + helixRadius() * std::cos(helixStartPhi());
0227 }
0228
0229 inline double helixCentreY(double radius, double phi) const {
0230
0231 return particle_.Y() + radius * std::cos(phi);
0232 }
0233
0234
0235 inline double helixCentreDistToAxis() const {
0236
0237 double xC = helixCentreX();
0238 double yC = helixCentreY();
0239 return std::sqrt(xC * xC + yC * yC);
0240 }
0241
0242 inline double helixCentreDistToAxis(double xC, double yC) const {
0243
0244 return std::sqrt(xC * xC + yC * yC);
0245 }
0246
0247
0248 inline double helixCentrePhi() const {
0249
0250 double xC = helixCentreX();
0251 double yC = helixCentreY();
0252 return xC == 0.0 && yC == 0.0 ? 0.0 : std::atan2(yC, xC);
0253 }
0254
0255 inline double helixCentrePhi(double xC, double yC) const {
0256
0257 return xC == 0.0 && yC == 0.0 ? 0.0 : std::atan2(yC, xC);
0258 }
0259
0260
0261 inline bool inside() const {
0262 return (particle_.R2() < rCyl2 - 0.00001 * rCyl && fabs(particle_.Z()) < zCyl - 0.00001);
0263 }
0264
0265 inline bool inside(double rPos2) const {
0266 return (rPos2 < rCyl2 - 0.00001 * rCyl && fabs(particle_.Z()) < zCyl - 0.00001);
0267 }
0268
0269
0270 inline bool onSurface() const { return (onBarrel() || onEndcap()); }
0271
0272 inline bool onSurface(double rPos2) const { return (onBarrel(rPos2) || onEndcap(rPos2)); }
0273
0274
0275 inline bool onBarrel() const {
0276 double rPos2 = particle_.R2();
0277 return (fabs(rPos2 - rCyl2) < 0.00001 * rCyl && fabs(particle_.Z()) <= zCyl);
0278 }
0279
0280 inline bool onBarrel(double rPos2) const {
0281 return (fabs(rPos2 - rCyl2) < 0.00001 * rCyl && fabs(particle_.Z()) <= zCyl);
0282 }
0283
0284
0285 inline bool onEndcap() const { return (fabs(fabs(particle_.Z()) - zCyl) < 0.00001 && particle_.R2() <= rCyl2); }
0286
0287 inline bool onEndcap(double rPos2) const { return (fabs(fabs(particle_.Z()) - zCyl) < 0.00001 && rPos2 <= rCyl2); }
0288
0289
0290 inline bool onFiducial() const { return fiducial; }
0291
0292
0293 inline bool hasDecayed() const { return decayed; }
0294
0295
0296 inline int getSuccess() const { return success; }
0297
0298
0299 inline void setMagneticField(double b) { bField = b; }
0300
0301
0302 inline double getMagneticField() const { return bField; }
0303
0304
0305 inline void setDebug() { debug = true; }
0306 inline void resetDebug() { debug = false; }
0307 };
0308
0309 #endif