Belle II Software development
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 <cdc/topology/EStereoKind.h>
11#include <cdc/topology/ISuperLayer.h>
12#include <cdc/topology/ILayer.h>
13
14#include <tracking/trackingUtilities/ca/AutomatonCell.h>
15
16#include <tracking/trackingUtilities/numerics/ERightLeft.h>
17#include <tracking/trackingUtilities/numerics/Index.h>
18
19#include <tracking/trackingUtilities/utilities/FunctorTag.h>
20
21#include <cdc/dataobjects/WireID.h>
22
23#include <Math/Vector2D.h>
24#include <Math/Vector3D.h>
25
26#include <utility>
27#include <iosfwd>
28#include <cassert>
29
30namespace Belle2 {
35 class CDCHit;
36 namespace CDC {
40 class CDCWire; // IWYU pragma: keep
41 }
42 namespace TrackingUtilities {
43 class CDCTrajectory2D;
44 class Circle2D;
45 class Vector3D;
46 class Vector2D;
47
58 class CDCWireHit {
59 public:
62
65
67 static constexpr const double c_simpleDriftLengthVariance = 0.000169;
68
70 CDCWireHit() = default;
71
83 CDCWireHit(const CDCHit* ptrHit,
84 double driftLength,
85 double driftLengthVariance = c_simpleDriftLengthVariance,
86 double chargeDeposit = 0,
87 double driftTime = 0);
88
99 explicit CDCWireHit(const CDCHit* ptrHit,
100 CDC::TDCCountTranslatorBase* ptrTDCCountTranslator = nullptr,
101 CDC::ADCCountTranslatorBase* ptrADCCountTranslator = nullptr);
102
104 CDCWireHit(const WireID& wireID,
105 double driftLength,
106 double driftLengthVariance = c_simpleDriftLengthVariance,
107 double chargeDeposit = 0);
108
110 bool operator==(const CDCWireHit& rhs) const
111 {
112 return getWireID() == rhs.getWireID() and getRefDriftLength() == rhs.getRefDriftLength();
113 }
114
116 bool operator<(const CDCWireHit& rhs) const
117 {
118 return
119 std::make_pair(getWireID().getEWire(), getRefDriftLength()) <
120 std::make_pair(rhs.getWireID().getEWire(), rhs.getRefDriftLength());
121 }
122
124 friend bool operator<(const CDCWireHit& wireHit, const CDC::CDCWire& wire)
125 {
126 return &wireHit.getWire() < &wire;
127 }
128
130 // Same as above but the other way round.
131 friend bool operator<(const CDC::CDCWire& wire, const CDCWireHit& wireHit)
132 {
133 return &wire < &wireHit.getWire();
134 }
135
137 // Same as above but with CDCWireHit as a pointer.
138 friend bool operator<(const CDCWireHit* wireHit, const CDC::CDCWire& wire)
139 {
140 assert(wireHit);
141 return *wireHit < wire;
142 }
143
145 // Same as above but the other way round and with CDCWireHit as a pointer.
146 friend bool operator<(const CDC::CDCWire& wire, const CDCWireHit* wireHit)
147 {
148 assert(wireHit);
149 return wire < *wireHit;
150 }
151
153 bool operator<(const CDCHit& hit);
154
155 friend bool operator<(const CDCWireHit& wireHit, const CDCHit& hit);
156
158 // Same as above but the other way round.
159 friend bool operator<(const CDCHit& hit, const CDCWireHit& wireHit);
160
162 const CDCHit* getHit() const
163 {
164 return m_hit;
165 }
166
168 Index getStoreIHit() const;
169
171 const CDC::CDCWire& getWire() const
172 {
173 // if (not m_wire) return attachWire();
174 if (not m_wire) return attachWire();
175 return *m_wire;
176 }
177
185 const CDC::CDCWire& attachWire() const;
186
188 const WireID& getWireID() const
189 {
190 return m_wireID;
191 }
192
198
200 bool isAxial() const
201 {
203 }
204
207 {
208 return getWireID().getISuperLayer();
209 }
210
213 {
214 return getWireID().getILayer();
215 }
216
218 const ROOT::Math::XYVector& getRefPos2D() const;
219
221 const ROOT::Math::XYZVector& getRefPos3D() const;
222
224 double getRefCylindricalR() const;
225
227 double getRefDriftLength() const
228 {
229 return m_refDriftLength;
230 }
231
234 {
236 }
237
239 double getRefChargeDeposit() const
240 {
241 return m_refChargeDeposit;
242 }
243
245 bool isOnWire(const CDC::CDCWire& wire) const
246 {
247 return &getWire() == &wire;
248 }
249
259 Vector2D reconstruct2D(const CDCTrajectory2D& trajectory2D) const;
260
274 Vector3D reconstruct3D(const CDCTrajectory2D& trajectory2D, ERightLeft rlInfo, double z = 0) const;
275
286 Circle2D conformalTransformed(const Vector2D& relativeTo) const;
287
290 {
291 return m_automatonCell;
292 }
293
296 {
297 return &m_automatonCell;
298 }
299
302 {
303 return m_iSuperCluster;
304 }
305
307 void setISuperCluster(int iSuperCluster)
308 {
309 m_iSuperCluster = iSuperCluster;
310 }
311
313 double getDriftTime() const
314 {
315 return m_refDriftTime;
316 }
317
318 private:
321
323 mutable CDC::CDCWire const* m_wire = nullptr;
324
326 const CDCHit* m_hit = nullptr;
327
330
333
336
338 double m_refChargeDeposit = 0.0;
339
341 double m_refDriftTime = 0.0f;
342
345 };
346
348 struct GetWireHit {
350 operator FunctorTag();
351
353 template<class T, class SFINAE = decltype(&T::getWireHit)>
354 const CDCWireHit & operator()(const T& t) const
355 {
356 return t.getWireHit();
357 }
358
360 const CDCWireHit& operator()(const CDCWireHit& wireHit) const
361 {
362 return wireHit;
363 }
364 };
365
367 std::ostream& operator<<(std::ostream& output, const CDCWireHit& wirehit);
368
370 bool operator<(const CDCWireHit& wireHit, const CDCHit& hit);
371
373 bool operator<(const CDCHit& hit, const CDCWireHit& wireHit);;
374
376 bool operator<(const CDCWireHit& wireHit, const CDC::CDCWireSuperLayer& wireSuperLayer);
377
379 // Same as above but the other way round.
380 bool operator<(const CDC::CDCWireSuperLayer& wireSuperLayer, const CDCWireHit& wireHit);
381 }
383}
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Definition CDCHit.h:40
CDCWireHit()=default
Default constructor for ROOT compatibility.
Abstract Base class for the ADC count translator.
Class representing a sense wire superlayer in the central drift chamber.
Class representing a sense wire in the central drift chamber.
Definition CDCWire.h:50
Base class for translation of Drift Time into Drift Length.
Cell used by the cellular automata.
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:58
double getRefCylindricalR() const
The distance from the beam line at reference position of the underlying wire.
const CDCHit * getHit() const
Getter for the CDCHit pointer into the StoreArray.
Definition CDCWireHit.h:162
static CDC::TDCCountTranslatorBase & getTDCCountTranslator()
Return an instance of the used TDC count translator.
Definition CDCWireHit.cc:39
double getRefDriftLengthVariance() const
Getter for the variance of the drift length at the reference position of the wire.
Definition CDCWireHit.h:233
double getRefDriftLength() const
Getter for the drift length at the reference position of the wire.
Definition CDCWireHit.h:227
const ROOT::Math::XYVector & getRefPos2D() const
The two dimensional reference position (z=0) of the underlying wire.
const WireID & getWireID() const
Getter for the WireID of the wire the hit is located on.
Definition CDCWireHit.h:188
bool isAxial() const
Indicator if the underlying wire is axial.
Definition CDCWireHit.h:200
friend bool operator<(const CDCWireHit *wireHit, const CDC::CDCWire &wire)
Defines CDCWires and CDCWireHits to be coaligned on the wire on which they are based.
Definition CDCWireHit.h:138
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:239
CDC::ISuperLayer getISuperLayer() const
Getter for the super layer id.
Definition CDCWireHit.h:206
int m_iSuperCluster
Memory for the super cluster id.
Definition CDCWireHit.h:344
AutomatonCell * operator->() const
Indirection to the automaton cell for easier access to the flags.
Definition CDCWireHit.h:295
const ROOT::Math::XYZVector & getRefPos3D() const
The three dimensional reference position of the underlying wire.
CDCWireHit()=default
Default constructor for ROOT compatibility.
const CDC::CDCWire & getWire() const
Getter for the CDCWire the hit is located on.
Definition CDCWireHit.h:171
void setISuperCluster(int iSuperCluster)
Setter for the super cluster id.
Definition CDCWireHit.h:307
AutomatonCell & getAutomatonCell() const
Mutable getter for the automaton cell.
Definition CDCWireHit.h:289
friend bool operator<(const CDC::CDCWire &wire, const CDCWireHit &wireHit)
Defines CDCWires and CDCWireHits to be coaligned on the wire on which they are based.
Definition CDCWireHit.h:131
friend bool operator<(const CDC::CDCWire &wire, const CDCWireHit *wireHit)
Defines CDCWires and CDCWireHits to be coaligned on the wire on which they are based.
Definition CDCWireHit.h:146
const CDCHit * m_hit
Memory for the CDCHit pointer.
Definition CDCWireHit.h:326
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:110
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:67
bool operator<(const CDCWireHit &rhs) const
Total ordering relation based on the wire and the hit id.
Definition CDCWireHit.h:116
friend bool operator<(const CDCWireHit &wireHit, const CDC::CDCWire &wire)
Defines CDCWires and CDCWireHits to be coaligned on the wire on which they are based.
Definition CDCWireHit.h:124
Vector2D reconstruct2D(const CDCTrajectory2D &trajectory2D) const
Reconstructs a position of primary ionisation on the drift circle.
const CDC::CDCWire & attachWire() const
Reestablishes the pointer of the hit to the wire and returns it Since the DataStore only transport th...
WireID m_wireID
Memory for the WireID.
Definition CDCWireHit.h:320
bool isOnWire(const CDC::CDCWire &wire) const
Checks if the wire hit is based on the given wire.
Definition CDCWireHit.h:245
CDC::EStereoKind getStereoKind() const
Getter for the stereo type of the underlying wire.
Definition CDCWireHit.h:194
double m_refDriftLength
Memory for the drift length at the wire reference point.
Definition CDCWireHit.h:332
Index getStoreIHit() const
Getter for the index of the hit in the StoreArray holding this hit.
Circle2D conformalTransformed(const Vector2D &relativeTo) const
Applies the conformal transformation to the drift circle this hit represents.
double m_refDriftLengthVariance
Memory for the variance of the drift length at the wire reference point.
Definition CDCWireHit.h:335
AutomatonCell m_automatonCell
Memory for the automaton cell.
Definition CDCWireHit.h:329
Vector3D reconstruct3D(const CDCTrajectory2D &trajectory2D, ERightLeft rlInfo, double z=0) const
Attempts to reconstruct a three dimensional position (especially of stereo hits).
CDC::CDCWire const * m_wire
Memory for the CDCWire pointer - Trailing comment indicates to not stream this member.
Definition CDCWireHit.h:323
int getISuperCluster() const
Getter for the super cluster id.
Definition CDCWireHit.h:301
double getDriftTime() const
Return the drift time measured by the CDC for this hit.
Definition CDCWireHit.h:313
double m_refChargeDeposit
Memory for the charge induced by the energy deposit in the drift cell.
Definition CDCWireHit.h:338
CDC::ILayer getILayer() const
Getter for the layer id.
Definition CDCWireHit.h:212
double m_refDriftTime
Measured drift time of the CDC hit.
Definition CDCWireHit.h:341
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 handling of orientation relate...
Definition Vector2D.h:36
A three dimensional vector.
Definition Vector3D.h:34
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
signed short ILayer
The type of the layer ids enumerating layers within a superlayer.
Definition ILayer.h:18
EStereoKind
Type for the stereo property of the wire.
Definition EStereoKind.h:20
signed short ISuperLayer
The type of the layer and superlayer ids.
Definition ISuperLayer.h:24
Abstract base class for different kinds of events.
static bool isAxial(ISuperLayer iSuperLayer)
Returns if the super layer with the given id is axial.
static EStereoKind getStereoKind(ISuperLayer iSuperLayer)
Returns the stereo kind of the super layer.
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:348
const CDCWireHit & operator()(const CDCWireHit &wireHit) const
If given a wire hit return it unchanged.
Definition CDCWireHit.h:360
const CDCWireHit & operator()(const T &t) const
Returns the wire hit of an object.
Definition CDCWireHit.h:354