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:
24
27
29 unsigned short m_trackId;
30
32 int m_pdg;
33
36
39
41 float m_edep;
42
45
47 float m_momentum[3];
48
50 float m_posWire[3];
51
53 float m_posIn[3];
54
56 float m_posOut[3];
57
59 float m_posTrack[3];
60
67 unsigned char m_leftRight;
68
71
72
73 public:
79 void setWireID(int iCLayerID, int iWireID)
80 {
81 m_wireID.setWireID(iCLayerID, iWireID);
82 }
83
85 void setTrackId(int trackId) { m_trackId = (unsigned short)trackId; }
86
88 void setPDGCode(int pdg) { m_pdg = pdg; }
89
91 void setDriftLength(double driftLength) { m_driftLength = driftLength; }
92
94 void setFlightTime(double flightTime) { m_flightTime = flightTime; }
95
97 void setGlobalTime(double globalTime) { m_globalTime = globalTime; }
98
100 void setEnergyDep(double edep) { m_edep = edep; }
101
103 void setStepLength(double stepLength) { m_stepLength = stepLength; }
104
106 void setMomentum(const B2Vector3D& momentum)
107 {
108 m_momentum[0] = momentum.X();
109 m_momentum[1] = momentum.Y();
110 m_momentum[2] = momentum.Z();
111 }
112
114 void setPosWire(const B2Vector3D& posWire)
115 {
116 m_posWire[0] = posWire.X();
117 m_posWire[1] = posWire.Y();
118 m_posWire[2] = posWire.Z();
119 }
120
122 void setPosIn(const B2Vector3D& posIn)
123 {
124 m_posIn[0] = posIn.X();
125 m_posIn[1] = posIn.Y();
126 m_posIn[2] = posIn.Z();
127 }
128
130 void setPosOut(const B2Vector3D& posOut)
131 {
132 m_posOut[0] = posOut.X();
133 m_posOut[1] = posOut.Y();
134 m_posOut[2] = posOut.Z();
135 }
136
138 void setPosTrack(const B2Vector3D& posTrack)
139 {
140 m_posTrack[0] = posTrack.X();
141 m_posTrack[1] = posTrack.Y();
142 m_posTrack[2] = posTrack.Z();
143 }
144
149 void setPosFlag(int zeroOrOne)
150 {
151 m_leftRight &= 0x6;
152 m_leftRight = (m_leftRight | (unsigned char)zeroOrOne);
153 }
154
156 void setLeftRightPassageRaw(int minusOneOrZeroOrOne)
157 {
158 int zeroOrOne = (minusOneOrZeroOrOne <= 0) ? 0 : 1;
159 m_leftRight &= 0x5;
160 m_leftRight = (m_leftRight | ((unsigned char)zeroOrOne << 1));
161 }
162
164 void setLeftRightPassage(int minusOneOrZeroOrOne)
165 {
166 int zeroOrOne = (minusOneOrZeroOrOne <= 0) ? 0 : 1;
167 m_leftRight &= 0x3;
168 m_leftRight = (m_leftRight | ((unsigned char)zeroOrOne << 2));
169 }
170
172 WireID getWireID() const {return m_wireID;}
173
175 int getTrackId() const { return m_trackId; }
176
178 int getPDGCode() const { return m_pdg; }
179
181 double getDriftLength() const { return m_driftLength; }
182
184 double getFlightTime() const { return m_flightTime; }
185
187 double getEnergyDep() const { return m_edep; }
188
190 double getStepLength() const { return m_stepLength; }
191
194 {
195 return B2Vector3D(m_momentum[0], m_momentum[1], m_momentum[2]);
196 }
197
200 {
201 return B2Vector3D(m_posWire[0], m_posWire[1], m_posWire[2]);
202 }
203
206 {
207 return B2Vector3D(m_posIn[0], m_posIn[1], m_posIn[2]);
208 }
209
212 {
213 return B2Vector3D(m_posOut[0], m_posOut[1], m_posOut[2]);
214 }
215
218 {
219 return B2Vector3D(m_posTrack[0], m_posTrack[1], m_posTrack[2]);
220 }
221
223 int getPosFlag() const
224 {
225 return (int)(m_leftRight & 0x1);
226 }
227
230 {
231 // int minusOneOrOne = (int((m_leftRight & 0x2) >> 1) == 0) ? -1 : 1;
232 // return minusOneOrOne;
233 int zeroOrOne = (int((m_leftRight & 0x2) >> 1) == 0) ? 0 : 1;
234 return zeroOrOne;
235 }
236
239 {
240 // int minusOneOrOne = (int((m_leftRight & 0x4) >> 2) == 0) ? -1 : 1;
241 // return minusOneOrOne;
242 int zeroOrOne = (int((m_leftRight & 0x4) >> 2) == 0) ? 0 : 1;
243 return zeroOrOne;
244 }
245
246
248 float getGlobalTime() const override { return m_globalTime; }
249
251
255 m_trackId(0), m_pdg(0), m_driftLength(0.0),
256 m_flightTime(0.0), m_edep(0.0), m_stepLength(1.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:178
void setLeftRightPassageRaw(int minusOneOrZeroOrOne)
The method to set new left/right info. for digitization.
Definition: CDCSimHit.h:156
void setPosIn(const B2Vector3D &posIn)
The method to set position of pre-step.
Definition: CDCSimHit.h:122
double getStepLength() const
The method to get step length.
Definition: CDCSimHit.h:190
float m_globalTime
Time of energy deposition.
Definition: CDCSimHit.h:70
int getTrackId() const
The method to get track id.
Definition: CDCSimHit.h:175
float m_flightTime
Flight time from IP.
Definition: CDCSimHit.h:38
void setPosFlag(int zeroOrOne)
The method to set position flag.
Definition: CDCSimHit.h:149
unsigned char m_leftRight
The flag to denote this hit is in the left or right side.
Definition: CDCSimHit.h:67
double getFlightTime() const
The method to get flight time.
Definition: CDCSimHit.h:184
B2Vector3D getPosWire() const
The method to get position on wire.
Definition: CDCSimHit.h:199
float m_posOut[3]
Position of post-step.
Definition: CDCSimHit.h:56
float getGlobalTime() const override
The method to get global time.
Definition: CDCSimHit.h:248
WireID getWireID() const
Getter for WireID object.
Definition: CDCSimHit.h:172
void setWireID(int iCLayerID, int iWireID)
Setter for Wire ID.
Definition: CDCSimHit.h:79
void setGlobalTime(double globalTime)
The method to set global time.
Definition: CDCSimHit.h:97
double getEnergyDep() const
The method to get deposited energy.
Definition: CDCSimHit.h:187
void setTrackId(int trackId)
The method to set track id.
Definition: CDCSimHit.h:85
void setPDGCode(int pdg)
The method to set PDG code.
Definition: CDCSimHit.h:88
float m_posIn[3]
Position of pre-step.
Definition: CDCSimHit.h:53
void setMomentum(const B2Vector3D &momentum)
The method to set momentum.
Definition: CDCSimHit.h:106
void setPosWire(const B2Vector3D &posWire)
The method to set position on wire.
Definition: CDCSimHit.h:114
int m_pdg
Particle PDG (can be one of secondaries).
Definition: CDCSimHit.h:32
void setEnergyDep(double edep)
The method to set deposited energy.
Definition: CDCSimHit.h:100
void setPosOut(const B2Vector3D &posOut)
The method to set position of post-step.
Definition: CDCSimHit.h:130
float m_stepLength
Step length of this hit.
Definition: CDCSimHit.h:44
void setDriftLength(double driftLength)
The method to set drift length.
Definition: CDCSimHit.h:91
CDCSimHit()
Empty constructor.
Definition: CDCSimHit.h:254
float m_posWire[3]
The position on wire which is closest to this hit.
Definition: CDCSimHit.h:50
void setStepLength(double stepLength)
The method to set step length.
Definition: CDCSimHit.h:103
ClassDefOverride(CDCSimHit, 6)
ROOT Macro.
int getPosFlag() const
The method to get old left/right info.
Definition: CDCSimHit.h:223
B2Vector3D getPosTrack() const
The method to get position on the track.
Definition: CDCSimHit.h:217
WireID m_wireID
The WireID of the hit.
Definition: CDCSimHit.h:26
double getDriftLength() const
The method to get drift length.
Definition: CDCSimHit.h:181
unsigned short m_trackId
The track id of this hit.
Definition: CDCSimHit.h:29
B2Vector3D getMomentum() const
The method to get momentum.
Definition: CDCSimHit.h:193
float m_driftLength
Drift length of this hit.
Definition: CDCSimHit.h:35
B2Vector3D getPosIn() const
The method to get position of pre-step.
Definition: CDCSimHit.h:205
B2Vector3D getPosOut() const
The method to get position of post-step.
Definition: CDCSimHit.h:211
void setFlightTime(double flightTime)
The method to set flight time.
Definition: CDCSimHit.h:94
float m_edep
Deposited energy of this hit.
Definition: CDCSimHit.h:41
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:229
int getLeftRightPassage() const
The method to get new left/right info. for tracking.
Definition: CDCSimHit.h:238
void setPosTrack(const B2Vector3D &posTrack)
The method to set position on the track.
Definition: CDCSimHit.h:138
float m_momentum[3]
The momentum at closest point.
Definition: CDCSimHit.h:47
float m_posTrack[3]
Position on the track.
Definition: CDCSimHit.h:59
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:164
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.