Belle II Software  release-08-01-10
CDCWireHit.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 #pragma once
9 
10 #include <tracking/trackFindingCDC/topology/EStereoKind.h>
11 #include <tracking/trackFindingCDC/topology/ISuperLayer.h>
12 #include <tracking/trackFindingCDC/topology/ILayer.h>
13 
14 #include <tracking/trackFindingCDC/ca/AutomatonCell.h>
15 
16 #include <tracking/trackFindingCDC/numerics/ERightLeft.h>
17 #include <tracking/trackFindingCDC/numerics/Index.h>
18 
19 #include <tracking/trackFindingCDC/utilities/FunctorTag.h>
20 
21 #include <cdc/dataobjects/WireID.h>
22 
23 #include <utility>
24 #include <iosfwd>
25 #include <cassert>
26 
27 namespace Belle2 {
32  class CDCHit;
33  namespace CDC {
34  class TDCCountTranslatorBase;
35  class ADCCountTranslatorBase;
36  }
37  namespace TrackFindingCDC {
38  class CDCTrajectory2D;
39  class CDCWireSuperLayer;
40  class CDCWire; // IWYU pragma: keep
41  class Circle2D;
42  class Vector3D;
43  class Vector2D;
44 
55  class CDCWireHit {
56  public:
59 
62 
64  static constexpr const double c_simpleDriftLengthVariance = 0.000169;
65 
67  CDCWireHit() = default;
68 
80  CDCWireHit(const CDCHit* ptrHit,
81  double driftLength,
82  double driftLengthVariance = c_simpleDriftLengthVariance,
83  double chargeDeposit = 0,
84  double driftTime = 0);
85 
96  explicit CDCWireHit(const CDCHit* ptrHit,
97  CDC::TDCCountTranslatorBase* ptrTDCCountTranslator = nullptr,
98  CDC::ADCCountTranslatorBase* ptrADCCountTranslator = nullptr);
99 
101  CDCWireHit(const WireID& wireID,
102  double driftLength,
103  double driftLengthVariance = c_simpleDriftLengthVariance,
104  double chargeDeposit = 0);
105 
107  bool operator==(const CDCWireHit& rhs) const
108  {
109  return getWireID() == rhs.getWireID() and getRefDriftLength() == rhs.getRefDriftLength();
110  }
111 
113  bool operator<(const CDCWireHit& rhs) const
114  {
115  return
116  std::make_pair(getWireID().getEWire(), getRefDriftLength()) <
117  std::make_pair(rhs.getWireID().getEWire(), rhs.getRefDriftLength());
118  }
119 
121  friend bool operator<(const CDCWireHit& wireHit, const CDCWire& wire)
122  {
123  return &wireHit.getWire() < &wire;
124  }
125 
127  // Same as above but the other way round.
128  friend bool operator<(const CDCWire& wire, const CDCWireHit& wireHit)
129  {
130  return &wire < &wireHit.getWire();
131  }
132 
134  // Same as above but with CDCWireHit as a pointer.
135  friend bool operator<(const CDCWireHit* wireHit, const CDCWire& wire)
136  {
137  assert(wireHit);
138  return *wireHit < wire;
139  }
140 
142  // Same as above but the other way round and with CDCWireHit as a pointer.
143  friend bool operator<(const CDCWire& wire, const CDCWireHit* wireHit)
144  {
145  assert(wireHit);
146  return wire < *wireHit;
147  }
148 
150  bool operator<(const CDCHit& hit);
151 
152  friend bool operator<(const CDCWireHit& wireHit, const CDCHit& hit);
153 
155  // Same as above but the other way round.
156  friend bool operator<(const CDCHit& hit, const CDCWireHit& wireHit);
157 
159  const CDCHit* getHit() const
160  {
161  return m_hit;
162  }
163 
165  Index getStoreIHit() const;
166 
168  const CDCWire& getWire() const
169  {
170  // if (not m_wire) return attachWire();
171  if (not m_wire) return attachWire();
172  return *m_wire;
173  }
174 
182  const CDCWire& attachWire() const;
183 
185  const WireID& getWireID() const
186  {
187  return m_wireID;
188  }
189 
191  EStereoKind getStereoKind() const
192  {
194  }
195 
197  bool isAxial() const
198  {
200  }
201 
203  ISuperLayer getISuperLayer() const
204  {
205  return getWireID().getISuperLayer();
206  }
207 
209  ILayer getILayer() const
210  {
211  return getWireID().getILayer();
212  }
213 
215  const Vector2D& getRefPos2D() const;
216 
218  const Vector3D& getRefPos3D() const;
219 
221  double getRefCylindricalR() const;
222 
224  double getRefDriftLength() const
225  {
226  return m_refDriftLength;
227  }
228 
231  {
233  }
234 
236  double getRefChargeDeposit() const
237  {
238  return m_refChargeDeposit;
239  }
240 
242  bool isOnWire(const CDCWire& wire) const
243  {
244  return &getWire() == &wire;
245  }
246 
256  Vector2D reconstruct2D(const CDCTrajectory2D& trajectory2D) const;
257 
271  Vector3D reconstruct3D(const CDCTrajectory2D& trajectory2D, ERightLeft rlInfo, double z = 0) const;
272 
283  Circle2D conformalTransformed(const Vector2D& relativeTo) const;
284 
287  {
288  return m_automatonCell;
289  }
290 
293  {
294  return &m_automatonCell;
295  }
296 
298  int getISuperCluster() const
299  {
300  return m_iSuperCluster;
301  }
302 
304  void setISuperCluster(int iSuperCluster)
305  {
306  m_iSuperCluster = iSuperCluster;
307  }
308 
310  double getDriftTime() const
311  {
312  return m_refDriftTime;
313  }
314 
315  private:
318 
320  mutable CDCWire const* m_wire = nullptr;
321 
324 
326  double m_refDriftLength = 0;
327 
330 
332  double m_refChargeDeposit = 0.0;
333 
335  int m_iSuperCluster = -1;
336 
338  double m_refDriftTime = 0.0f;
339 
341  const CDCHit* m_hit = nullptr;
342  };
343 
345  struct GetWireHit {
347  operator FunctorTag();
348 
350  template<class T, class SFINAE = decltype(&T::getWireHit)>
351  const CDCWireHit & operator()(const T& t) const
352  {
353  return t.getWireHit();
354  }
355 
357  const CDCWireHit& operator()(const CDCWireHit& wireHit) const
358  {
359  return wireHit;
360  }
361  };
362 
364  std::ostream& operator<<(std::ostream& output, const CDCWireHit& wirehit);
365 
367  bool operator<(const CDCWireHit& wireHit, const CDCHit& hit);
368 
370  bool operator<(const CDCHit& hit, const CDCWireHit& wireHit);;
371 
373  bool operator<(const CDCWireHit& wireHit, const CDCWireSuperLayer& wireSuperLayer);
374 
376  // Same as above but the other way round.
377  bool operator<(const CDCWireSuperLayer& wireSuperLayer, const CDCWireHit& wireHit);
378  }
380 }
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Definition: CDCHit.h:40
Abstract Base class for the ADC count translator.
Base class for translation of Drift Time into Drift Length.
Cell used by the cellular automata.
Definition: AutomatonCell.h:29
Particle trajectory as it is seen in xy projection represented as a circle.
Class representing a hit wire in the central drift chamber.
Definition: CDCWireHit.h:55
double getRefCylindricalR() const
The distance from the beam line at reference position of the underlying wire.
Definition: CDCWireHit.cc:222
const CDCHit * getHit() const
Getter for the CDCHit pointer into the StoreArray.
Definition: CDCWireHit.h:159
static CDC::TDCCountTranslatorBase & getTDCCountTranslator()
Return an instance of the used TDC count translator.
Definition: CDCWireHit.cc:39
friend bool operator<(const CDCWire &wire, const CDCWireHit *wireHit)
Defines CDCWires and CDCWireHits to be coaligned on the wire on which they are based.
Definition: CDCWireHit.h:143
ISuperLayer getISuperLayer() const
Getter for the super layer id.
Definition: CDCWireHit.h:203
double getRefDriftLengthVariance() const
Getter for the variance of the drift length at the reference position of the wire.
Definition: CDCWireHit.h:230
double getRefDriftLength() const
Getter for the drift length at the reference position of the wire.
Definition: CDCWireHit.h:224
bool isAxial() const
Indicator if the underlying wire is axial.
Definition: CDCWireHit.h:197
friend bool operator<(const CDCWireHit &wireHit, const CDCHit &hit)
Defines CDCWireHits and raw CDCHit to be coaligned.
friend bool operator<(const CDCHit &hit, const CDCWireHit &wireHit)
Defines wire hits and raw CDCHit to be coaligned.
double getRefChargeDeposit() const
Getter for the charge due to energy deposit in the drift cell.
Definition: CDCWireHit.h:236
friend bool operator<(const CDCWireHit &wireHit, const CDCWire &wire)
Defines CDCWires and CDCWireHits to be coaligned on the wire on which they are based.
Definition: CDCWireHit.h:121
int m_iSuperCluster
Memory for the super cluster id.
Definition: CDCWireHit.h:335
CDCWireHit()=default
Default constructor for ROOT compatibility.
void setISuperCluster(int iSuperCluster)
Setter for the super cluster id.
Definition: CDCWireHit.h:304
friend bool operator<(const CDCWireHit *wireHit, const CDCWire &wire)
Defines CDCWires and CDCWireHits to be coaligned on the wire on which they are based.
Definition: CDCWireHit.h:135
const CDCHit * m_hit
Memory for the CDCHit pointer.
Definition: CDCWireHit.h:341
static CDC::ADCCountTranslatorBase & getADCCountTranslator()
Return an instance of the used ADC count translator.
Definition: CDCWireHit.cc:45
bool operator==(const CDCWireHit &rhs) const
Equality comparison based on the wire and the hit id.
Definition: CDCWireHit.h:107
static constexpr const double c_simpleDriftLengthVariance
A default value for the drift length variance if no variance from the drift length translation is ava...
Definition: CDCWireHit.h:64
AutomatonCell & getAutomatonCell() const
Mutable getter for the automaton cell.
Definition: CDCWireHit.h:286
bool operator<(const CDCWireHit &rhs) const
Total ordering relation based on the wire and the hit id.
Definition: CDCWireHit.h:113
const Vector3D & getRefPos3D() const
The three dimensional reference position of the underlying wire.
Definition: CDCWireHit.cc:217
Vector2D reconstruct2D(const CDCTrajectory2D &trajectory2D) const
Reconstructs a position of primary ionisation on the drift circle.
Definition: CDCWireHit.cc:166
const CDCWire & attachWire() const
Reestablishes the pointer of the hit to the wire and returns it Since the DataStore only transport th...
Definition: CDCWireHit.cc:159
ILayer getILayer() const
Getter for the layer id.
Definition: CDCWireHit.h:209
WireID m_wireID
Memory for the WireID.
Definition: CDCWireHit.h:317
bool isOnWire(const CDCWire &wire) const
Checks if the wire hit is based on the given wire.
Definition: CDCWireHit.h:242
double m_refDriftLength
Memory for the drift length at the wire reference point.
Definition: CDCWireHit.h:326
const WireID & getWireID() const
Getter for the WireID of the wire the hit is located on.
Definition: CDCWireHit.h:185
Index getStoreIHit() const
Getter for the index of the hit in the StoreArray holding this hit.
Definition: CDCWireHit.cc:207
const Vector2D & getRefPos2D() const
The two dimensional reference position (z=0) of the underlying wire.
Definition: CDCWireHit.cc:212
CDCWire const * m_wire
Memory for the CDCWire pointer - Trailing comment indicates to not stream this member.
Definition: CDCWireHit.h:320
Circle2D conformalTransformed(const Vector2D &relativeTo) const
Applys the conformal transformation to the drift circle this hit represents.
Definition: CDCWireHit.cc:200
friend bool operator<(const CDCWire &wire, const CDCWireHit &wireHit)
Defines CDCWires and CDCWireHits to be coaligned on the wire on which they are based.
Definition: CDCWireHit.h:128
double m_refDriftLengthVariance
Memory for the variance of the drift length at the wire reference point.
Definition: CDCWireHit.h:329
AutomatonCell m_automatonCell
Memory for the automaton cell.
Definition: CDCWireHit.h:323
Vector3D reconstruct3D(const CDCTrajectory2D &trajectory2D, ERightLeft rlInfo, double z=0) const
Attempts to reconstruct a three dimensional position (especially of stereo hits).
Definition: CDCWireHit.cc:181
EStereoKind getStereoKind() const
Getter for the stereo type of the underlying wire.
Definition: CDCWireHit.h:191
int getISuperCluster() const
Getter for the super cluster id.
Definition: CDCWireHit.h:298
const CDCWire & getWire() const
Getter for the CDCWire the hit is located on.
Definition: CDCWireHit.h:168
AutomatonCell * operator->() const
Indirection to the automaton cell for easier access to the flags.
Definition: CDCWireHit.h:292
double getDriftTime() const
Return the drift time measured by the CDC for this hit.
Definition: CDCWireHit.h:310
double m_refChargeDeposit
Memory for the charge induced by the energy deposit in the drift cell.
Definition: CDCWireHit.h:332
double m_refDriftTime
Measured drift time of the CDC hit.
Definition: CDCWireHit.h:338
Class representing a sense wire in the central drift chamber.
Definition: CDCWire.h:58
A two dimensional circle in its natural representation using center and radius as parameters.
Definition: Circle2D.h:26
A two dimensional vector which is equipped with functions for correct handeling of orientation relat...
Definition: Vector2D.h:35
A three dimensional vector.
Definition: Vector3D.h:33
Class to identify a wire inside the CDC.
Definition: WireID.h:34
unsigned short getEWire() const
Getter for encoded wire number.
Definition: WireID.h:154
unsigned short getISuperLayer() const
Getter for Super-Layer.
Definition: WireID.h:130
unsigned short getILayer() const
Getter for layer within the Super-Layer.
Definition: WireID.h:136
std::ostream & operator<<(std::ostream &output, const IntervalOfValidity &iov)
bool operator<(ExpRun a, ExpRun b)
less than for ExpRun
Definition: Splitter.h:74
HepGeom::Vector3D< double > Vector3D
3D Vector
Definition: Cell.h:34
ERightLeft
Enumeration to represent the distinct possibilities of the right left passage.
Definition: ERightLeft.h:25
Abstract base class for different kinds of events.
Tag class to facilitate marking of class as a functor in the sense of this code.
Definition: FunctorTag.h:20
Generic functor to get the wire hit from an object.
Definition: CDCWireHit.h:345
const CDCWireHit & operator()(const T &t) const
Returns the wire hit of an object.
Definition: CDCWireHit.h:351
const CDCWireHit & operator()(const CDCWireHit &wireHit) const
If given a wire hit return it unchanged.
Definition: CDCWireHit.h:357
static bool isAxial(ISuperLayer iSuperLayer)
Returns if the super layer with the given id is axial.
Definition: ISuperLayer.cc:21
static EStereoKind getStereoKind(ISuperLayer iSuperLayer)
Returns the stereo kind of the super layer.
Definition: ISuperLayer.cc:26