Belle II Software  release-08-01-10
Cell.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 //-----------------------------------------------------------------------------
10 // Description : A class to represent a cell (a wire or a track segment) in CDC.
11 //-----------------------------------------------------------------------------
12 
13 #ifndef TRGCDCCell_FLAG_
14 #define TRGCDCCell_FLAG_
15 
16 #include "CLHEP/Geometry/Vector3D.h"
17 #include "CLHEP/Geometry/Point3D.h"
18 #include "trg/trg/Signal.h"
19 #include "trg/cdc/Layer.h"
20 
21 #ifdef TRGCDC_SHORT_NAMES
22 #define TCCell TRGCDCCell
23 #endif
24 
25 namespace Belle2 {
34  typedef HepGeom::Vector3D<double> Vector3D;
35 
36  class TRGCDC;
37  class TRGCDCCellHit;
38 
40  class TRGCDCCell {
41 
42  public:
44  TRGCDCCell(unsigned id,
45  unsigned localId,
46  const TRGCDCLayer& layer,
49 
51  virtual ~TRGCDCCell();
52 
53  public:// Selectors
54 
56  unsigned id(void) const;
57 
59  unsigned localId(void) const;
60 
62  unsigned layerId(void) const;
63 
65  unsigned localLayerId(void) const;
66 
68  unsigned superLayerId(void) const;
69 
71  unsigned axialStereoLayerId(void) const;
72 
74  unsigned axialStereoSuperLayerId(void) const;
75 
77  const TRGCDCLayer& layer(void) const;
78 
80  unsigned state(void) const;
81 
83  bool axial(void) const;
84 
86  bool stereo(void) const;
87 
88 // /// returns a pointer to a neighbor wire. This function is expensive.
89 // virtual const TRGCDCCell * const neighbor(unsigned) const = 0;
90 
92  int localIdDifference(const TRGCDCCell&) const;
93 
95  virtual std::string name(void) const = 0;
96 
98  virtual void dump(const std::string& message = std::string(""),
99  const std::string& prefix = std::string("")) const;
100 
102  virtual const TRGSignal& signal(void) const = 0;
103 
104  public:// Geometry
105 
107  const HepGeom::Point3D<double>& forwardPosition(void) const;
108 
110  const HepGeom::Point3D<double>& backwardPosition(void) const;
112  double* backwardPosition(double p[3]) const;
113 
115  const HepGeom::Point3D<double>& xyPosition(void) const;
117  double* xyPosition(double p[3]) const;
118 
120  const Vector3D& direction(void) const;
121 
123 // void wirePosition(float zPosition,
124 // HepGeom::Point3D<double> & xyPosition,
125 // HepGeom::Point3D<double> & backwardPosition,
126 // Vector3D & direction) const;
127 
129  float cellSize(void) const;
130 
131  public:// Utility functions
132 
134  virtual bool hasMember(const std::string& a) const;
135 
136  public:// event by event information.
137 
139  const TRGCDCCellHit* hit(void) const;
140 
141  public:// Obsolete functions from Belle
142 
144  bool innerPart(void) const;
145 
147  bool mainPart(void) const;
148 
149  public:// Modifiers
150 
152  unsigned state(unsigned newState);
153 
155  virtual void clear(void);
156 
158  const TRGCDCCellHit* hit(const TRGCDCCellHit*);
159 
160  private:
161 
163  const unsigned _id;
164 
166  const unsigned _localId;
167 
170 
173 
176 
179 
182 
184  unsigned _state;
185 
188 
190  friend class TRGCDC;
191  };
192 
193 //-----------------------------------------------------------------------------
194 
195  inline
196  unsigned
197  TRGCDCCell::id(void) const
198  {
199  return _id;
200  }
201 
202  inline
203  unsigned
205  {
206  return _localId;
207  }
208 
209  inline
210  unsigned
212  {
213  return _layer.id();
214  }
215 
216  inline
217  unsigned
219  {
220  return _layer.superLayerId();
221  }
222 
223  inline
224  unsigned
226  {
227  return _layer.localLayerId();
228  }
229 
230  inline
231  const TRGCDCLayer&
232  TRGCDCCell::layer(void) const
233  {
234  return _layer;
235  }
236 
237  inline
238  unsigned
239  TRGCDCCell::state(void) const
240  {
241  return _state;
242  }
243 
244  inline
245  unsigned
246  TRGCDCCell::state(unsigned a)
247  {
248  return _state = a;
249  }
250 
251  inline
252  bool
253  TRGCDCCell::axial(void) const
254  {
255  return _layer.axial();
256  }
257 
258  inline
259  bool
260  TRGCDCCell::stereo(void) const
261  {
262  return _layer.stereo();
263  }
264 
265  inline
266  unsigned
268  {
269  return _layer.axialStereoLayerId();
270  }
271 
272  inline
273  unsigned
275  {
277  }
278 
279  inline
280  bool
282  {
283  std::cout << "TRGCDCCell::innerPart ... position not defined" << std::endl;
284  if (layerId() < 14) return true;
285  return false;
286  }
287 
288  inline
289  bool
291  {
292  std::cout << "TRGCDCCell::mainPart ... position not defined" << std::endl;
293  if (layerId() > 13) return true;
294  return false;
295  }
296 
297  inline
298  float
300  {
301  return _layer.cellSize();
302  }
303 
304  inline
305  void
307  {
308  _state = 0;
309  _hit = 0;
310  }
311 
312  inline
315  {
316  return _forwardPosition;
317  }
318 
319  inline
322  {
323  return _backwardPosition;
324  }
325 
326  inline
327  double*
328  TRGCDCCell::backwardPosition(double p[3]) const
329  {
330  p[0] = _backwardPosition.x();
331  p[1] = _backwardPosition.y();
332  p[2] = _backwardPosition.z();
333  return p;
334  }
335 
336  inline
339  {
340  return _xyPosition;
341  }
342 
343  inline
344  double*
345  TRGCDCCell::xyPosition(double a[3]) const
346  {
347  a[0] = _xyPosition.x();
348  a[1] = _xyPosition.y();
349  a[2] = 0.;
350  return a;
351  }
352 
353  inline
354  const Vector3D&
356  {
357  return _direction;
358  }
359 
360  inline
361  const TRGCDCCellHit*
362  TRGCDCCell::hit(void) const
363  {
364  return _hit;
365  }
366 
367  inline
368  const TRGCDCCellHit*
370  {
371  return _hit = a;
372  }
373 
374  inline
375  bool
376  TRGCDCCell::hasMember(const std::string& a) const
377  {
378  return name() == a;
379  }
380 
382 } // namespace Belle2
383 
384 #endif /* TRGCDCCell_FLAG_ */
385 
A class to represent a wire hit in CDC.
Definition: CellHit.h:74
A class to represent a wire in CDC.
Definition: Cell.h:40
const HepGeom::Point3D< double > _forwardPosition
Wire forward position.
Definition: Cell.h:175
const HepGeom::Point3D< double > _xyPosition
Wire center(?) position.
Definition: Cell.h:172
const unsigned _id
ID.
Definition: Cell.h:163
const unsigned _localId
Local ID.
Definition: Cell.h:166
const HepGeom::Point3D< double > _backwardPosition
Wire backward position.
Definition: Cell.h:178
const TRGCDCCellHit * _hit
Cell hit.
Definition: Cell.h:187
virtual std::string name(void) const =0
returns name.
const Vector3D _direction
Direction vector.
Definition: Cell.h:181
virtual const TRGSignal & signal(void) const =0
returns trigger output. Null will returned if no signal.
const TRGCDCLayer & _layer
Layer.
Definition: Cell.h:169
unsigned _state
Status in this event.
Definition: Cell.h:184
A class to represent a cell layer.
Definition: Layer.h:33
The instance of TRGCDC is a singleton.
Definition: TRGCDC.h:69
A class to represent a digitized signal. Unit is nano second.
Definition: Signal.h:23
HepGeom::Vector3D< double > Vector3D
3D Vector
Definition: Cell.h:34
HepGeom::Point3D< double > Point3D
3D point
Definition: Cell.h:32
float cellSize(void) const
calculates position and direction vector with sag correction.
Definition: Cell.h:299
const HepGeom::Point3D< double > & forwardPosition(void) const
returns position in forward endplate.
Definition: Cell.h:314
virtual void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
Definition: Cell.cc:52
bool innerPart(void) const
returns true if this wire is in the inner part.
Definition: Cell.h:281
bool mainPart(void) const
returns true if this wire is in the main part.
Definition: Cell.h:290
unsigned id(void) const
returns id.
Definition: Cell.h:197
const Vector3D & direction(void) const
returns direction vector of the wire.
Definition: Cell.h:355
virtual ~TRGCDCCell()
Destructor.
Definition: Cell.cc:47
unsigned layerId(void) const
returns layer id.
Definition: Cell.h:211
unsigned localLayerId(void) const
returns local layer id in a super layer.
Definition: Cell.h:225
const HepGeom::Point3D< double > & backwardPosition(void) const
returns position in backward endplate.
Definition: Cell.h:321
unsigned superLayerId(void) const
returns super layer id.
Definition: Cell.h:218
const TRGCDCCellHit * hit(void) const
returns a pointer to a TRGCDCCellHit.
Definition: Cell.h:362
unsigned axialStereoSuperLayerId(void) const
returns id of axial or stereo super layer id.
Definition: Cell.h:274
virtual bool hasMember(const std::string &a) const
returns true this has member named a.
Definition: Cell.h:376
bool stereo(void) const
returns true if this wire is in a stereo layer.
Definition: Cell.h:260
const HepGeom::Point3D< double > & xyPosition(void) const
returns middle position of a wire. z componet is 0.
Definition: Cell.h:338
TRGCDCCell(unsigned id, unsigned localId, const TRGCDCLayer &layer, const HepGeom::Point3D< double > &forwardPosition, const HepGeom::Point3D< double > &backwardPosition)
Constructor.
Definition: Cell.cc:30
const TRGCDCLayer & layer(void) const
returns a pointer to a layer.
Definition: Cell.h:232
unsigned axialStereoLayerId(void) const
returns id of axial or stereo layer id.
Definition: Cell.h:267
int localIdDifference(const TRGCDCCell &) const
returns local id difference.
Definition: Cell.cc:69
virtual void clear(void)
clears information.
Definition: Cell.h:306
unsigned state(void) const
returns state.
Definition: Cell.h:239
bool axial(void) const
returns true if this wire is in an axial layer.
Definition: Cell.h:253
unsigned localId(void) const
returns local id in a layer.
Definition: Cell.h:204
Abstract base class for different kinds of events.