Belle II Software  release-08-01-10
Wire.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 wire in CDC.
11 //-----------------------------------------------------------------------------
12 
13 #ifndef TRGCDCWire_FLAG_
14 #define TRGCDCWire_FLAG_
15 
16 #include <vector>
17 #include "CLHEP/Geometry/Vector3D.h"
18 #include "CLHEP/Geometry/Point3D.h"
19 #include "trg/trg/Signal.h"
20 #include "trg/cdc/Cell.h"
21 #include "trg/cdc/Layer.h"
22 
23 #ifdef TRGCDC_SHORT_NAMES
24 #define TCWire TRGCDCWire
25 #endif
26 
27 namespace Belle2 {
34  typedef HepGeom::Vector3D<double> Vector3D;
36 #define WireInnerLeft 0
38 #define WireInnerRight 1
40 #define WireLeft 2
42 #define WireRight 3
44 #define WireOuterLeft 4
46 #define WireOuterRight 5
48 #define MaxNeighbors 6
49 
50  class TRGCDC;
51  class TRGCDCWireHit;
52  class TRGCDCWireHitMC;
53  class TRGCDCTrackSegment;
54 
56  class TRGCDCWire : public TRGCDCCell {
57 
58  public:
60  TRGCDCWire(unsigned id,
61  unsigned localId,
62  const TRGCDCLayer&,
65  const TRGClock& clock);
66 
68  virtual ~TRGCDCWire();
69 
70  public:// Selectors
71 
73  const TRGCDCWireHit* hit(void) const;
74 
75 // /// returns a pointer to a TRGCDCTrackSegment.
76 // const TRGCDCTrackSegment * const segment(void) const;
77 
79  const TRGCDCWire* neighbor(unsigned) const;
80 
82  bool consective(const TRGCDCWire&) const;
83 
85  bool adjacent(const TRGCDCWire&) const;
86 
88  int localIdForPlus(void) const;
89 
91  int localIdForMinus(void) const;
92 
94  std::string name(void) const override;
95 
97  void dump(const std::string& message = std::string(""),
98  const std::string& prefix = std::string("")) const override;
99 
100  public:// Modifiers
101 
103  void clear(void) override;
104 
106  const TRGCDCWireHit* hit(const TRGCDCWireHit*);
107 
110 
112  void addSignal(const TRGSignal& newSignal);
113 
114  public:// TRG
115 
117  const TRGSignal& signal(void) const override;
118 
119  private:
120 
122 // std::vector<const TRGCDCWireHitMC * const> _mcHits;
123  std::vector<const TRGCDCWireHitMC*> _mcHits;
124 
127 
129  friend class TRGCDC;
130  };
131 
132 //-----------------------------------------------------------------------------
133 
134  inline
135  const TRGCDCWireHit*
137  {
138  //TODO only this strong retyping work, is it OK?
139  return reinterpret_cast<const TRGCDCWireHit*>(TRGCDCCell::hit(reinterpret_cast<const TRGCDCCellHit*>(h)));
140  }
141 
142  inline
143  const TRGCDCWireHit*
144  TRGCDCWire::hit(void) const
145  {
146  //TODO only this strong retyping work, is it OK?
147  return reinterpret_cast<const TRGCDCWireHit*>(TRGCDCCell::hit());
148  }
149 
150  inline
151  const TRGCDCWireHitMC*
153  {
154  _mcHits.push_back(a);
155  return a;
156  }
157 
158  inline
159  void
161  {
162  _signal |= newSignal;
163  }
164 
165  inline
166  bool
168  {
169  if (neighbor(2) == & w) return true;
170  else if (neighbor(3) == & w) return true;
171  return false;
172  }
173 
174  inline
175  bool
177  {
178  for (unsigned i = 0; i < 7; i++)
179  if (neighbor(i) == & w)
180  return true;
181  return false;
182  }
183 
184  inline
185  int
187  {
188  //
189  // used in curl finder
190  //
191  // new version by NK
192  //
193  //ho const TCDCLayer &l = *layer();
194  //ho const int nw = l.nWires();
195 
196  const TRGCDCLayer& l = this->layer();
197  const unsigned nw = l.nCells();
198  if (localId() + 1 == nw)
199  return -1;
200  else
201  return localId();
202  }
203 
204  inline
205  int
207  {
208  //
209  // used in curl finder
210  //
211  // new version by NK
212  //
213  //ho const TRGCDCLayer &l = *layer();
214  //ho const int nw = l.nWires();
215 
216  const TRGCDCLayer& l = this->layer();
217  const unsigned nw = l.nCells();
218  if (0 == localId())
219  return nw;
220  else
221  return localId();
222  }
223 
224  inline
225  const TRGSignal&
226  TRGCDCWire::signal(void) const
227  {
228  return _signal;
229  }
230 
232 } // namespace Belle2
233 
234 #endif /* TRGCDCWire_FLAG_ */
235 
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
A class to represent a cell layer.
Definition: Layer.h:33
A class to represent a MC wire hit in CDC.
Definition: WireHitMC.h:34
A class to represent a wire hit in CDC.
Definition: WireHit.h:33
A class to represent a wire in CDC.
Definition: Wire.h:56
TRGSignal _signal
Trigger output.
Definition: Wire.h:126
std::vector< const TRGCDCWireHitMC * > _mcHits
MC wire hit.
Definition: Wire.h:123
The instance of TRGCDC is a singleton.
Definition: TRGCDC.h:69
A class to represent a digitized signal. Unit is nano second.
Definition: Clock.h:38
A class to represent a digitized signal. Unit is nano second.
Definition: Signal.h:23
bool adjacent(const TRGCDCWire &) const
returns true if a given wire is adjacent.
Definition: Wire.h:176
HepGeom::Vector3D< double > Vector3D
3D Vector
Definition: Cell.h:34
void addSignal(const TRGSignal &newSignal)
set signal |= newSignal
Definition: Wire.h:160
HepGeom::Point3D< double > Point3D
3D point
Definition: Cell.h:32
const HepGeom::Point3D< double > & forwardPosition(void) const
returns position in forward endplate.
Definition: Cell.h:314
virtual ~TRGCDCWire()
Destructor.
Definition: Wire.cc:47
bool consective(const TRGCDCWire &) const
returns true if a given wire is consective in a layer.
Definition: Wire.h:167
const HepGeom::Point3D< double > & backwardPosition(void) const
returns position in backward endplate.
Definition: Cell.h:321
const TRGCDCCellHit * hit(void) const
returns a pointer to a TRGCDCCellHit.
Definition: Cell.h:362
const TRGSignal & signal(void) const override
returns an input to the trigger. This is sync'ed to 1GHz clock.
Definition: Wire.h:226
const TRGCDCWire * neighbor(unsigned) const
returns a pointer to a neighbor wire. This function is expensive.
Definition: Wire.cc:73
const TRGCDCWireHit * hit(void) const
returns a pointer to a TRGCDCWireHit.
Definition: Wire.h:144
std::string name(void) const override
returns name.
Definition: Wire.cc:381
int localIdForPlus(void) const
returns localId but if maxLocalId, return -1.
Definition: Wire.h:186
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const override
dumps debug information.
Definition: Wire.cc:52
TRGCDCWire(unsigned id, unsigned localId, const TRGCDCLayer &, const HepGeom::Point3D< double > &forwardPosition, const HepGeom::Point3D< double > &backwardPosition, const TRGClock &clock)
Constructor.
Definition: Wire.cc:34
void clear(void) override
clears information.
Definition: Wire.cc:368
const TRGCDCLayer & layer(void) const
returns a pointer to a layer.
Definition: Cell.h:232
unsigned nCells(void) const
returns # of cells.
Definition: Layer.h:194
int localIdForMinus(void) const
returns localId but if 0, return maxLocalId + 1.
Definition: Wire.h:206
unsigned localId(void) const
returns local id in a layer.
Definition: Cell.h:204
Abstract base class for different kinds of events.