File indexing completed on 2024-04-06 12:29:43
0001 #ifndef PSimHit_H
0002 #define PSimHit_H
0003
0004 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
0005 #include "DataFormats/GeometryVector/interface/LocalVector.h"
0006 #include "SimDataFormats/EncodedEventId/interface/EncodedEventId.h"
0007
0008 class TrackingSlaveSD;
0009
0010
0011
0012
0013
0014
0015 class PSimHit {
0016 public:
0017 static constexpr unsigned int k_tidOffset = 200000000;
0018
0019 PSimHit() : theDetUnitId(0) {}
0020
0021 PSimHit(const Local3DPoint& entry,
0022 const Local3DPoint& exit,
0023 float pabs,
0024 float tof,
0025 float eloss,
0026 int particleType,
0027 unsigned int detId,
0028 unsigned int trackId,
0029 float theta,
0030 float phi,
0031 unsigned short processType = 0)
0032 : theEntryPoint(entry),
0033 theSegment(exit - entry),
0034 thePabs(pabs),
0035 theEnergyLoss(eloss),
0036 theThetaAtEntry(theta),
0037 thePhiAtEntry(phi),
0038 theTof(tof),
0039 theParticleType(particleType),
0040 theProcessType(processType),
0041 theDetUnitId(detId),
0042 theTrackId(trackId) {}
0043
0044
0045 Local3DPoint entryPoint() const { return theEntryPoint; }
0046
0047
0048 Local3DPoint exitPoint() const { return theEntryPoint + theSegment; }
0049
0050
0051
0052
0053
0054 Local3DPoint localPosition() const { return theEntryPoint + 0.5 * theSegment; }
0055
0056
0057 LocalVector momentumAtEntry() const { return LocalVector(thetaAtEntry(), phiAtEntry(), pabs()); }
0058
0059
0060 LocalVector localDirection() const { return LocalVector(thetaAtEntry(), phiAtEntry(), 1.f); }
0061
0062
0063 Geom::Theta<float> thetaAtEntry() const { return Geom::Theta<float>(theThetaAtEntry); }
0064
0065
0066 Geom::Phi<float> phiAtEntry() const { return Geom::Phi<float>(thePhiAtEntry); }
0067
0068
0069 float pabs() const { return thePabs; }
0070
0071
0072
0073
0074
0075 float timeOfFlight() const { return tof(); }
0076
0077
0078 float tof() const { return theTof; }
0079
0080
0081 float energyLoss() const { return theEnergyLoss; }
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091 int particleType() const { return theParticleType; }
0092
0093
0094
0095
0096
0097
0098
0099 unsigned int detUnitId() const { return theDetUnitId; }
0100
0101
0102
0103
0104
0105
0106
0107
0108 unsigned int trackId() const { return theTrackId; }
0109
0110
0111
0112
0113 unsigned int originalTrackId() const { return theTrackId % k_tidOffset; }
0114
0115 unsigned int offsetTrackId() const { return theTrackId / k_tidOffset; }
0116
0117 static unsigned int addTrackIdOffset(unsigned int tId, unsigned int offset) { return offset * k_tidOffset + tId; }
0118
0119 EncodedEventId eventId() const { return theEventId; }
0120
0121 void setEventId(EncodedEventId e) { theEventId = e; }
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131 unsigned short processType() const { return theProcessType; }
0132
0133 void setTof(float tof) { theTof = tof; }
0134
0135 protected:
0136
0137 Local3DPoint theEntryPoint;
0138 Local3DVector theSegment;
0139 float thePabs;
0140 float theEnergyLoss;
0141 float theThetaAtEntry;
0142 float thePhiAtEntry;
0143
0144 float theTof;
0145 int theParticleType;
0146 unsigned short theProcessType;
0147
0148
0149
0150 unsigned int theDetUnitId;
0151 unsigned int theTrackId;
0152 EncodedEventId theEventId;
0153
0154 friend class TrackingSlaveSD;
0155 };
0156
0157 std::ostream& operator<<(std::ostream& o, const PSimHit& hit);
0158
0159 #endif