Belle II Software development
CDCSimHit.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <cdc/dataobjects/WireID.h>
12#include <simulation/dataobjects/SimHitBase.h>
13#include <framework/geometry/B2Vector3.h>
14
15namespace Belle2 {
21 class CDCSimHit : public SimHitBase {
22
23 private:
25 float m_momentum[3];
26
28 float m_posWire[3];
29
31 float m_posIn[3];
32
34 float m_posOut[3];
35
37 float m_posTrack[3];
38
41
44
47
50
52 float m_edep;
53
56
58 int m_pdg;
59
61 unsigned short m_trackId;
62
69 unsigned char m_leftRight;
70
71
72 public:
78 void setWireID(int iCLayerID, int iWireID)
79 {
80 m_wireID.setWireID(iCLayerID, iWireID);
81 }
82
84 void setTrackId(int trackId) { m_trackId = (unsigned short)trackId; }
85
87 void setPDGCode(int pdg) { m_pdg = pdg; }
88
90 void setDriftLength(double driftLength) { m_driftLength = driftLength; }
91
93 void setFlightTime(double flightTime) { m_flightTime = flightTime; }
94
96 void setGlobalTime(double globalTime) { m_globalTime = globalTime; }
97
99 void setEnergyDep(double edep) { m_edep = edep; }
100
102 void setStepLength(double stepLength) { m_stepLength = stepLength; }
103
105 void setMomentum(const B2Vector3D& momentum)
106 {
107 m_momentum[0] = momentum.X();
108 m_momentum[1] = momentum.Y();
109 m_momentum[2] = momentum.Z();
110 }
111
113 void setPosWire(const B2Vector3D& posWire)
114 {
115 m_posWire[0] = posWire.X();
116 m_posWire[1] = posWire.Y();
117 m_posWire[2] = posWire.Z();
118 }
119
121 void setPosIn(const B2Vector3D& posIn)
122 {
123 m_posIn[0] = posIn.X();
124 m_posIn[1] = posIn.Y();
125 m_posIn[2] = posIn.Z();
126 }
127
129 void setPosOut(const B2Vector3D& posOut)
130 {
131 m_posOut[0] = posOut.X();
132 m_posOut[1] = posOut.Y();
133 m_posOut[2] = posOut.Z();
134 }
135
137 void setPosTrack(const B2Vector3D& posTrack)
138 {
139 m_posTrack[0] = posTrack.X();
140 m_posTrack[1] = posTrack.Y();
141 m_posTrack[2] = posTrack.Z();
142 }
143
148 void setPosFlag(int zeroOrOne)
149 {
150 m_leftRight &= 0x6;
151 m_leftRight = (m_leftRight | (unsigned char)zeroOrOne);
152 }
153
155 void setLeftRightPassageRaw(int minusOneOrZeroOrOne)
156 {
157 int zeroOrOne = (minusOneOrZeroOrOne <= 0) ? 0 : 1;
158 m_leftRight &= 0x5;
159 m_leftRight = (m_leftRight | ((unsigned char)zeroOrOne << 1));
160 }
161
163 void setLeftRightPassage(int minusOneOrZeroOrOne)
164 {
165 int zeroOrOne = (minusOneOrZeroOrOne <= 0) ? 0 : 1;
166 m_leftRight &= 0x3;
167 m_leftRight = (m_leftRight | ((unsigned char)zeroOrOne << 2));
168 }
169
171 WireID getWireID() const {return m_wireID;}
172
174 int getTrackId() const { return m_trackId; }
175
177 int getPDGCode() const { return m_pdg; }
178
180 double getDriftLength() const { return m_driftLength; }
181
183 double getFlightTime() const { return m_flightTime; }
184
186 double getEnergyDep() const { return m_edep; }
187
189 double getStepLength() const { return m_stepLength; }
190
193 {
194 return B2Vector3D(m_momentum[0], m_momentum[1], m_momentum[2]);
195 }
196
199 {
200 return B2Vector3D(m_posWire[0], m_posWire[1], m_posWire[2]);
201 }
202
205 {
206 return B2Vector3D(m_posIn[0], m_posIn[1], m_posIn[2]);
207 }
208
211 {
212 return B2Vector3D(m_posOut[0], m_posOut[1], m_posOut[2]);
213 }
214
217 {
218 return B2Vector3D(m_posTrack[0], m_posTrack[1], m_posTrack[2]);
219 }
220
222 int getPosFlag() const
223 {
224 return (int)(m_leftRight & 0x1);
225 }
226
229 {
230 // int minusOneOrOne = (int((m_leftRight & 0x2) >> 1) == 0) ? -1 : 1;
231 // return minusOneOrOne;
232 int zeroOrOne = (int((m_leftRight & 0x2) >> 1) == 0) ? 0 : 1;
233 return zeroOrOne;
234 }
235
238 {
239 // int minusOneOrOne = (int((m_leftRight & 0x4) >> 2) == 0) ? -1 : 1;
240 // return minusOneOrOne;
241 int zeroOrOne = (int((m_leftRight & 0x4) >> 2) == 0) ? 0 : 1;
242 return zeroOrOne;
243 }
244
245
247 float getGlobalTime() const override { return m_globalTime; }
248
250
256 m_globalTime(0.0), m_driftLength(0.0), m_flightTime(0.0),
257 m_edep(0.0), m_stepLength(1.0),
258 m_pdg(0), m_trackId(0),
259 m_leftRight(0)
260 {}
261
263 CDCSimHit(int layerId,
264 int wireId,
265 int trackId,
266 int pdg,
267 double driftLength,
268 double flightTime,
269 double edep,
270 double stepLength,
271 B2Vector3D momentum,
272 B2Vector3D posWire,
273 B2Vector3D posIn,
274 B2Vector3D posOut,
275 B2Vector3D posTrack,
276 int leftRight,
277 double globalTime): SimHitBase()
278 {
279
280 m_wireID.setWireID(layerId, wireId);
281 m_trackId = trackId;
282 m_pdg = pdg;
283 m_driftLength = driftLength;
284 m_flightTime = flightTime;
285 m_edep = edep;
286 m_stepLength = stepLength;
287 m_momentum[0] = momentum.X();
288 m_momentum[1] = momentum.Y();
289 m_momentum[2] = momentum.Z();
290 m_posWire[0] = posWire.X();
291 m_posWire[1] = posWire.Y();
292 m_posWire[2] = posWire.Z();
293 m_posIn[0] = posIn.X();
294 m_posIn[1] = posIn.Y();
295 m_posIn[2] = posIn.Z();
296 m_posOut[0] = posOut.X();
297 m_posOut[1] = posOut.Y();
298 m_posOut[2] = posOut.Z();
299 m_posTrack[0] = posTrack.X();
300 m_posTrack[1] = posTrack.Y();
301 m_posTrack[2] = posTrack.Z();
302 m_leftRight = (unsigned char)leftRight & 0x7; // mask 3 bits (LSB).
303 m_globalTime = globalTime;
304 }
305
309 virtual void shiftInTime(float delta) override
310 {
311 m_globalTime += delta;
312 }
313
314
317 };
319} // end namespace Belle2
DataType Z() const
access variable Z (= .at(2) without boundary check)
Definition: B2Vector3.h:435
DataType X() const
access variable X (= .at(0) without boundary check)
Definition: B2Vector3.h:431
DataType Y() const
access variable Y (= .at(1) without boundary check)
Definition: B2Vector3.h:433
Example Detector.
Definition: CDCSimHit.h:21
int getPDGCode() const
The method to get PDG code.
Definition: CDCSimHit.h:177
void setLeftRightPassageRaw(int minusOneOrZeroOrOne)
The method to set new left/right info. for digitization.
Definition: CDCSimHit.h:155
void setPosIn(const B2Vector3D &posIn)
The method to set position of pre-step.
Definition: CDCSimHit.h:121
double getStepLength() const
The method to get step length.
Definition: CDCSimHit.h:189
float m_globalTime
Time of energy deposition.
Definition: CDCSimHit.h:43
int getTrackId() const
The method to get track id.
Definition: CDCSimHit.h:174
float m_flightTime
Flight time from IP.
Definition: CDCSimHit.h:49
void setPosFlag(int zeroOrOne)
The method to set position flag.
Definition: CDCSimHit.h:148
unsigned char m_leftRight
The flag to denote this hit is in the left or right side.
Definition: CDCSimHit.h:69
double getFlightTime() const
The method to get flight time.
Definition: CDCSimHit.h:183
B2Vector3D getPosWire() const
The method to get position on wire.
Definition: CDCSimHit.h:198
float m_posOut[3]
Position of post-step.
Definition: CDCSimHit.h:34
float getGlobalTime() const override
The method to get global time.
Definition: CDCSimHit.h:247
WireID getWireID() const
Getter for WireID object.
Definition: CDCSimHit.h:171
void setWireID(int iCLayerID, int iWireID)
Setter for Wire ID.
Definition: CDCSimHit.h:78
void setGlobalTime(double globalTime)
The method to set global time.
Definition: CDCSimHit.h:96
double getEnergyDep() const
The method to get deposited energy.
Definition: CDCSimHit.h:186
void setTrackId(int trackId)
The method to set track id.
Definition: CDCSimHit.h:84
void setPDGCode(int pdg)
The method to set PDG code.
Definition: CDCSimHit.h:87
float m_posIn[3]
Position of pre-step.
Definition: CDCSimHit.h:31
ClassDefOverride(CDCSimHit, 7)
ROOT Macro.
void setMomentum(const B2Vector3D &momentum)
The method to set momentum.
Definition: CDCSimHit.h:105
void setPosWire(const B2Vector3D &posWire)
The method to set position on wire.
Definition: CDCSimHit.h:113
int m_pdg
Particle PDG (can be one of secondaries).
Definition: CDCSimHit.h:58
void setEnergyDep(double edep)
The method to set deposited energy.
Definition: CDCSimHit.h:99
void setPosOut(const B2Vector3D &posOut)
The method to set position of post-step.
Definition: CDCSimHit.h:129
float m_stepLength
Step length of this hit.
Definition: CDCSimHit.h:55
void setDriftLength(double driftLength)
The method to set drift length.
Definition: CDCSimHit.h:90
CDCSimHit()
Empty constructor.
Definition: CDCSimHit.h:253
float m_posWire[3]
The position on wire which is closest to this hit.
Definition: CDCSimHit.h:28
void setStepLength(double stepLength)
The method to set step length.
Definition: CDCSimHit.h:102
int getPosFlag() const
The method to get old left/right info.
Definition: CDCSimHit.h:222
B2Vector3D getPosTrack() const
The method to get position on the track.
Definition: CDCSimHit.h:216
WireID m_wireID
The WireID of the hit.
Definition: CDCSimHit.h:40
double getDriftLength() const
The method to get drift length.
Definition: CDCSimHit.h:180
unsigned short m_trackId
The track id of this hit.
Definition: CDCSimHit.h:61
B2Vector3D getMomentum() const
The method to get momentum.
Definition: CDCSimHit.h:192
float m_driftLength
Drift length of this hit.
Definition: CDCSimHit.h:46
B2Vector3D getPosIn() const
The method to get position of pre-step.
Definition: CDCSimHit.h:204
B2Vector3D getPosOut() const
The method to get position of post-step.
Definition: CDCSimHit.h:210
void setFlightTime(double flightTime)
The method to set flight time.
Definition: CDCSimHit.h:93
float m_edep
Deposited energy of this hit.
Definition: CDCSimHit.h:52
virtual void shiftInTime(float delta) override
Shift the SimHit in time.
Definition: CDCSimHit.h:309
int getLeftRightPassageRaw() const
The method to get new left/right info. for digitization.
Definition: CDCSimHit.h:228
int getLeftRightPassage() const
The method to get new left/right info. for tracking.
Definition: CDCSimHit.h:237
void setPosTrack(const B2Vector3D &posTrack)
The method to set position on the track.
Definition: CDCSimHit.h:137
float m_momentum[3]
The momentum at closest point.
Definition: CDCSimHit.h:25
float m_posTrack[3]
Position on the track.
Definition: CDCSimHit.h:37
CDCSimHit(int layerId, int wireId, int trackId, int pdg, double driftLength, double flightTime, double edep, double stepLength, B2Vector3D momentum, B2Vector3D posWire, B2Vector3D posIn, B2Vector3D posOut, B2Vector3D posTrack, int leftRight, double globalTime)
Useful Constructor.
Definition: CDCSimHit.h:263
void setLeftRightPassage(int minusOneOrZeroOrOne)
The method to set new left/right info. for tracking.
Definition: CDCSimHit.h:163
Class SimHitBase - A common base for subdetector SimHits.
Definition: SimHitBase.h:28
Class to identify a wire inside the CDC.
Definition: WireID.h:34
void setWireID(unsigned short iSuperLayer, unsigned short iLayer, unsigned short iWire)
Setter using official numbering.
Definition: WireID.h:112
B2Vector3< double > B2Vector3D
typedef for common usage with double
Definition: B2Vector3.h:516
Abstract base class for different kinds of events.