Belle II Software  release-06-01-15
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 
14 #include <TVector3.h>
15 
16 namespace Belle2 {
22  class CDCSimHit : public SimHitBase {
23 
24  private:
25 
28 
30  unsigned short m_trackId;
31 
33  int m_pdg;
34 
37 
39  float m_flightTime;
40 
42  float m_edep;
43 
45  float m_stepLength;
46 
48  // TVector3 m_momentum;
49  float m_momentum[3];
50 
52  // TVector3 m_posWire;
53  float m_posWire[3];
54 
56  // TVector3 m_posIn;
57  float m_posIn[3];
58 
60  // TVector3 m_posOut;
61  float m_posOut[3];
62 
64  // TVector3 m_posTrack;
65  float m_posTrack[3];
66 
73  unsigned char m_leftRight;
74 
76  float m_globalTime;
77 
78 
79  public:
85  void setWireID(int iCLayerID, int iWireID)
86  {
87  m_wireID.setWireID(iCLayerID, iWireID);
88  }
89 
91  void setTrackId(int trackId) { m_trackId = (unsigned short)trackId; }
92 
94  void setPDGCode(int pdg) { m_pdg = pdg; }
95 
97  void setDriftLength(double driftLength) { m_driftLength = driftLength; }
98 
100  void setFlightTime(double flightTime) { m_flightTime = flightTime; }
101 
103  void setGlobalTime(double globalTime) { m_globalTime = globalTime; }
104 
106  void setEnergyDep(double edep) { m_edep = edep; }
107 
109  void setStepLength(double stepLength) { m_stepLength = stepLength; }
110 
112  void setMomentum(TVector3 momentum)
113  {
114  m_momentum[0] = momentum.X();
115  m_momentum[1] = momentum.Y();
116  m_momentum[2] = momentum.Z();
117  }
118 
120  void setPosWire(TVector3 posWire)
121  {
122  m_posWire[0] = posWire.X();
123  m_posWire[1] = posWire.Y();
124  m_posWire[2] = posWire.Z();
125  }
126 
128  void setPosIn(TVector3 posIn)
129  {
130  m_posIn[0] = posIn.X();
131  m_posIn[1] = posIn.Y();
132  m_posIn[2] = posIn.Z();
133  }
134 
136  void setPosOut(TVector3 posOut)
137  {
138  m_posOut[0] = posOut.X();
139  m_posOut[1] = posOut.Y();
140  m_posOut[2] = posOut.Z();
141  }
142 
144  void setPosTrack(TVector3 posTrack)
145  {
146  m_posTrack[0] = posTrack.X();
147  m_posTrack[1] = posTrack.Y();
148  m_posTrack[2] = posTrack.Z();
149  }
150 
155  void setPosFlag(int zeroOrOne)
156  {
157  m_leftRight &= 0x6;
158  m_leftRight = (m_leftRight | (unsigned char)zeroOrOne);
159  }
160 
162  void setLeftRightPassageRaw(int minusOneOrZeroOrOne)
163  {
164  int zeroOrOne = (minusOneOrZeroOrOne <= 0) ? 0 : 1;
165  m_leftRight &= 0x5;
166  m_leftRight = (m_leftRight | ((unsigned char)zeroOrOne << 1));
167  }
168 
170  void setLeftRightPassage(int minusOneOrZeroOrOne)
171  {
172  int zeroOrOne = (minusOneOrZeroOrOne <= 0) ? 0 : 1;
173  m_leftRight &= 0x3;
174  m_leftRight = (m_leftRight | ((unsigned char)zeroOrOne << 2));
175  }
176 
178  WireID getWireID() const {return m_wireID;}
179 
181  int getTrackId() const { return m_trackId; }
182 
184  int getPDGCode() const { return m_pdg; }
185 
187  double getDriftLength() const { return m_driftLength; }
188 
190  double getFlightTime() const { return m_flightTime; }
191 
193  double getEnergyDep() const { return m_edep; }
194 
196  double getStepLength() const { return m_stepLength; }
197 
199  TVector3 getMomentum() const
200  {
201  return TVector3(m_momentum[0], m_momentum[1], m_momentum[2]);
202  }
203 
205  TVector3 getPosWire() const
206  {
207  return TVector3(m_posWire[0], m_posWire[1], m_posWire[2]);
208  }
209 
211  TVector3 getPosIn() const
212  {
213  return TVector3(m_posIn[0], m_posIn[1], m_posIn[2]);
214  }
215 
217  TVector3 getPosOut() const
218  {
219  return TVector3(m_posOut[0], m_posOut[1], m_posOut[2]);
220  }
221 
223  TVector3 getPosTrack() const
224  {
225  return TVector3(m_posTrack[0], m_posTrack[1], m_posTrack[2]);
226  }
227 
229  int getPosFlag() const
230  {
231  return (int)(m_leftRight & 0x1);
232  }
233 
236  {
237  // int minusOneOrOne = (int((m_leftRight & 0x2) >> 1) == 0) ? -1 : 1;
238  // return minusOneOrOne;
239  int zeroOrOne = (int((m_leftRight & 0x2) >> 1) == 0) ? 0 : 1;
240  return zeroOrOne;
241  }
242 
245  {
246  // int minusOneOrOne = (int((m_leftRight & 0x4) >> 2) == 0) ? -1 : 1;
247  // return minusOneOrOne;
248  int zeroOrOne = (int((m_leftRight & 0x4) >> 2) == 0) ? 0 : 1;
249  return zeroOrOne;
250  }
251 
252 
254  float getGlobalTime() const override { return m_globalTime; }
255 
257 
261  m_trackId(0), m_pdg(0), m_driftLength(0.0),
262  m_flightTime(0.0), m_edep(0.0), m_stepLength(1.0),
263  m_momentum(), m_posWire(),
264  m_posIn(), m_posOut(), m_posTrack(),
265  m_leftRight(0), m_globalTime(0.0)
266  {}
267 
269  CDCSimHit(int layerId,
270  int wireId,
271  int trackId,
272  int pdg,
273  double driftLength,
274  double flightTime,
275  double edep,
276  double stepLength,
277  TVector3 momentum,
278  TVector3 posWire,
279  TVector3 posIn,
280  TVector3 posOut,
281  TVector3 posTrack,
282  int leftRight,
283  double globalTime): SimHitBase()
284  {
285 
286  m_wireID.setWireID(layerId, wireId);
287  m_trackId = trackId;
288  m_pdg = pdg;
289  m_driftLength = driftLength;
290  m_flightTime = flightTime;
291  m_edep = edep;
292  m_stepLength = stepLength;
293  m_momentum[0] = momentum.X();
294  m_momentum[1] = momentum.Y();
295  m_momentum[2] = momentum.Z();
296  m_posWire[0] = posWire.X();
297  m_posWire[1] = posWire.Y();
298  m_posWire[2] = posWire.Z();
299  m_posIn[0] = posIn.X();
300  m_posIn[1] = posIn.Y();
301  m_posIn[2] = posIn.Z();
302  m_posOut[0] = posOut.X();
303  m_posOut[1] = posOut.Y();
304  m_posOut[2] = posOut.Z();
305  m_posTrack[0] = posTrack.X();
306  m_posTrack[1] = posTrack.Y();
307  m_posTrack[2] = posTrack.Z();
308  m_leftRight = (unsigned char)leftRight & 0x7; // mask 3 bits (LSB).
309  m_globalTime = globalTime;
310  }
311 
315  virtual void shiftInTime(float delta) override
316  {
317  m_globalTime += delta;
318  }
319 
320 
323  };
325 } // end namespace Belle2
Example Detector.
Definition: CDCSimHit.h:22
int getPDGCode() const
The method to get PDG code.
Definition: CDCSimHit.h:184
void setLeftRightPassageRaw(int minusOneOrZeroOrOne)
The method to set new left/right info. for digitization.
Definition: CDCSimHit.h:162
double getStepLength() const
The method to get step length.
Definition: CDCSimHit.h:196
float m_globalTime
Time of energy deposition.
Definition: CDCSimHit.h:76
void setPosOut(TVector3 posOut)
The method to set position of post-step.
Definition: CDCSimHit.h:136
int getTrackId() const
The method to get track id.
Definition: CDCSimHit.h:181
float m_flightTime
Flight time from IP.
Definition: CDCSimHit.h:39
TVector3 getPosWire() const
The method to get position on wire.
Definition: CDCSimHit.h:205
void setPosFlag(int zeroOrOne)
The method to set position flag.
Definition: CDCSimHit.h:155
unsigned char m_leftRight
The flag to denote this hit is in the left or right side.
Definition: CDCSimHit.h:73
double getFlightTime() const
The method to get flight time.
Definition: CDCSimHit.h:190
float m_posOut[3]
Position of post-step.
Definition: CDCSimHit.h:61
float getGlobalTime() const override
The method to get global time.
Definition: CDCSimHit.h:254
void setPosWire(TVector3 posWire)
The method to set position on wire.
Definition: CDCSimHit.h:120
WireID getWireID() const
Getter for WireID object.
Definition: CDCSimHit.h:178
void setWireID(int iCLayerID, int iWireID)
Setter for Wire ID.
Definition: CDCSimHit.h:85
void setGlobalTime(double globalTime)
The method to set global time.
Definition: CDCSimHit.h:103
double getEnergyDep() const
The method to get deposited energy.
Definition: CDCSimHit.h:193
void setTrackId(int trackId)
The method to set track id.
Definition: CDCSimHit.h:91
void setPDGCode(int pdg)
The method to set PDG code.
Definition: CDCSimHit.h:94
float m_posIn[3]
Position of pre-step.
Definition: CDCSimHit.h:57
TVector3 getMomentum() const
The method to get momentum.
Definition: CDCSimHit.h:199
int m_pdg
Particle PDG (can be one of secondaries).
Definition: CDCSimHit.h:33
void setEnergyDep(double edep)
The method to set deposited energy.
Definition: CDCSimHit.h:106
float m_stepLength
Step length of this hit.
Definition: CDCSimHit.h:45
void setDriftLength(double driftLength)
The method to set drift length.
Definition: CDCSimHit.h:97
CDCSimHit()
Empty constructor.
Definition: CDCSimHit.h:260
float m_posWire[3]
The position on wire which is closest to this hit.
Definition: CDCSimHit.h:53
CDCSimHit(int layerId, int wireId, int trackId, int pdg, double driftLength, double flightTime, double edep, double stepLength, TVector3 momentum, TVector3 posWire, TVector3 posIn, TVector3 posOut, TVector3 posTrack, int leftRight, double globalTime)
Useful Constructor.
Definition: CDCSimHit.h:269
void setStepLength(double stepLength)
The method to set step length.
Definition: CDCSimHit.h:109
void setMomentum(TVector3 momentum)
The method to set momentum.
Definition: CDCSimHit.h:112
ClassDefOverride(CDCSimHit, 6)
ROOT Macro.
int getPosFlag() const
The method to get old left/right info.
Definition: CDCSimHit.h:229
WireID m_wireID
The WireID of the hit.
Definition: CDCSimHit.h:27
double getDriftLength() const
The method to get drift length.
Definition: CDCSimHit.h:187
unsigned short m_trackId
The track id of this hit.
Definition: CDCSimHit.h:30
float m_driftLength
Drift length of this hit.
Definition: CDCSimHit.h:36
TVector3 getPosIn() const
The method to get position of pre-step.
Definition: CDCSimHit.h:211
void setFlightTime(double flightTime)
The method to set flight time.
Definition: CDCSimHit.h:100
float m_edep
Deposited energy of this hit.
Definition: CDCSimHit.h:42
virtual void shiftInTime(float delta) override
Shift the SimHit in time.
Definition: CDCSimHit.h:315
int getLeftRightPassageRaw() const
The method to get new left/right info. for digitization.
Definition: CDCSimHit.h:235
int getLeftRightPassage() const
The method to get new left/right info. for tracking.
Definition: CDCSimHit.h:244
TVector3 getPosTrack() const
The method to get position on the track.
Definition: CDCSimHit.h:223
void setPosTrack(TVector3 posTrack)
The method to set position on the track.
Definition: CDCSimHit.h:144
float m_momentum[3]
The momentum at closest point.
Definition: CDCSimHit.h:49
TVector3 getPosOut() const
The method to get position of post-step.
Definition: CDCSimHit.h:217
float m_posTrack[3]
Position on the track.
Definition: CDCSimHit.h:65
void setPosIn(TVector3 posIn)
The method to set position of pre-step.
Definition: CDCSimHit.h:128
void setLeftRightPassage(int minusOneOrZeroOrOne)
The method to set new left/right info. for tracking.
Definition: CDCSimHit.h:170
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
Abstract base class for different kinds of events.