Belle II Software development
CDCWireHit.cc
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#include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
9
10#include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory2D.h>
11
12#include <tracking/trackFindingCDC/topology/CDCWireSuperLayer.h>
13#include <tracking/trackFindingCDC/topology/CDCWire.h>
14#include <tracking/trackFindingCDC/topology/EStereoKind.h>
15
16#include <tracking/trackFindingCDC/geometry/Circle2D.h>
17#include <tracking/trackFindingCDC/geometry/Vector3D.h>
18#include <tracking/trackFindingCDC/geometry/Vector2D.h>
19
20#include <tracking/trackFindingCDC/numerics/ERightLeft.h>
21#include <tracking/trackFindingCDC/numerics/Index.h>
22
23#include <cdc/translators/RealisticTDCCountTranslator.h>
24#include <cdc/translators/LinearGlobalADCCountTranslator.h>
25
26#include <cdc/translators/TDCCountTranslatorBase.h>
27#include <cdc/translators/ADCCountTranslatorBase.h>
28
29#include <cdc/dataobjects/CDCHit.h>
30#include <cdc/dataobjects/WireID.h>
31#include <framework/logging/Logger.h>
32
33#include <ostream>
34
35using namespace Belle2;
36using namespace CDC;
37using namespace TrackFindingCDC;
38
40{
41 static CDC::RealisticTDCCountTranslator s_tdcCountTranslator;
42 return s_tdcCountTranslator;
43}
44
46{
47 static CDC::LinearGlobalADCCountTranslator s_adcCountTranslator;
48 return s_adcCountTranslator;
49}
50
51CDCWireHit::CDCWireHit(const CDCHit* const ptrHit,
52 const double driftLength,
53 const double driftLengthVariance,
54 const double chargeDeposit,
55 const double driftTime)
56 : m_wireID(ptrHit->getID())
57 , m_wire(CDCWire::getInstance(*ptrHit))
58 , m_automatonCell(1)
59 , m_refDriftLength(driftLength)
60 , m_refDriftLengthVariance(driftLengthVariance)
61 , m_refChargeDeposit(chargeDeposit)
62 , m_refDriftTime(driftTime)
63 , m_hit(ptrHit)
64{
65}
66
67CDCWireHit::CDCWireHit(const CDCHit* const ptrHit,
68 CDC::TDCCountTranslatorBase* ptrTDCCountTranslator,
69 CDC::ADCCountTranslatorBase* ptrADCCountTranslator)
70 : m_wireID(ptrHit->getID())
71 , m_wire(ptrHit ? CDCWire::getInstance(*ptrHit) : nullptr)
72 , m_automatonCell(1)
73 , m_hit(ptrHit)
74{
75 if (not ptrHit) {
76 B2ERROR("CDCWireHit constructor invoked with nullptr CDCHit");
77 return;
78 }
79 const CDCHit& hit = *ptrHit;
80
81 TDCCountTranslatorBase& tdcCountTranslator =
82 ptrTDCCountTranslator ? *ptrTDCCountTranslator : getTDCCountTranslator();
83 ADCCountTranslatorBase& adcCountTranslator =
84 ptrADCCountTranslator ? *ptrADCCountTranslator : getADCCountTranslator();
85
86 float initialTOFEstimate = 0;
87
88 float refDriftLengthRight = tdcCountTranslator.getDriftLength(hit.getTDCCount(),
89 getWireID(),
90 initialTOFEstimate,
91 false, // bool leftRight
92 getWire().getRefZ());
93
94 float refDriftLengthLeft = tdcCountTranslator.getDriftLength(hit.getTDCCount(),
95 getWireID(),
96 initialTOFEstimate,
97 true, // bool leftRight
98 getWire().getRefZ());
99
100 m_refDriftTime = tdcCountTranslator.getDriftTime(hit.getTDCCount(),
101 getWireID(),
102 initialTOFEstimate,
103 getWire().getRefZ(),
104 hit.getADCCount());
105
106 m_refDriftLength = (refDriftLengthLeft + refDriftLengthRight) / 2.0;
107
109 getWireID(),
110 false, // bool leftRight ?
111 getWire().getRefZ());
112
113 m_refChargeDeposit = adcCountTranslator.getCharge(hit.getADCCount(),
114 getWireID(),
115 false, // bool leftRight
116 getWire().getRefZ(),
117 0); // theta
118}
119
121 const double driftLength,
122 const double driftLengthVariance,
123 const double chargeDeposit)
124 : m_wireID(wireID)
125 , m_wire(CDCWire::getInstance(wireID))
126 , m_automatonCell(1)
127 , m_refDriftLength(driftLength)
128 , m_refDriftLengthVariance(driftLengthVariance)
129 , m_refChargeDeposit(chargeDeposit)
130 , m_hit(nullptr)
131{
132}
133
135{
136 return this->getWireID().getEWire() < hit.getID();
137}
138
139bool TrackFindingCDC::operator<(const CDCWireHit& wireHit, const CDCWireSuperLayer& wireSuperLayer)
140{
141 return wireHit.getISuperLayer() < wireSuperLayer.getISuperLayer();
142}
143
144bool TrackFindingCDC::operator<(const CDCWireSuperLayer& wireSuperLayer, const CDCWireHit& wireHit)
145{
146 return wireSuperLayer.getISuperLayer() < wireHit.getISuperLayer();
147}
148
149bool TrackFindingCDC::operator<(const CDCWireHit& wireHit, const CDCHit& hit)
150{
151 return wireHit.getWireID().getEWire() < hit.getID();
152}
153
154bool TrackFindingCDC::operator<(const CDCHit& hit, const CDCWireHit& wireHit)
155{
156 return hit.getID() < wireHit.getWireID().getEWire();
157}
158
160{
162 assert(m_wire);
163 return *m_wire;
164}
165
167{
168 const Vector2D& refPos2D = getRefPos2D();
169 Vector2D recoPos2D = trajectory2D.getClosest(refPos2D);
170
171 const Vector2D& wirePos2D = getWire().getRefPos2D();
172 const double driftLength = getRefDriftLength();
173
174 Vector2D disp2D = recoPos2D - wirePos2D;
175
176 // Fix the displacement to lie on the drift circle.
177 disp2D.normalizeTo(driftLength);
178 return wirePos2D + disp2D;
179}
180
182 const ERightLeft rlInfo,
183 const double z) const
184{
185 const EStereoKind stereoType = getStereoKind();
186
187 if (stereoType == EStereoKind::c_StereoV or stereoType == EStereoKind::c_StereoU) {
188 const WireLine& wireLine = getWire().getWireLine();
189 const double signedDriftLength = isValid(rlInfo) ? static_cast<double>(rlInfo) * getRefDriftLength() : 0.0;
190 return trajectory2D.reconstruct3D(wireLine, signedDriftLength, z);
191
192 } else { /*if (stereoType == EStereoKind::c_Axial)*/
193 const Vector2D recoPos2D = reconstruct2D(trajectory2D);
194 // for axial wire we can not determine the z coordinate by looking at the xy projection only
195 // we set it the basic assumption.
196 return Vector3D(recoPos2D, z);
197 }
198}
199
201{
202 Circle2D driftCircle(getRefPos2D() - relativeTo, getRefDriftLength());
203 driftCircle.conformalTransform();
204 return driftCircle;
205}
206
208{
209 return getHit() ? getHit()->getArrayIndex() : c_InvalidIndex;
210}
211
213{
214 return getWire().getRefPos2D();
215}
216
218{
219 return getWire().getRefPos3D();
220}
221
223{
224 return getWire().getRefCylindricalR();
225}
226
227std::ostream& TrackFindingCDC::operator<<(std::ostream& output, const CDCWireHit& wirehit)
228{
229 return output << "CDCWireHit(" << wirehit.getWireID()
230 << ", drift length=" << wirehit.getRefDriftLength() << ")";
231}
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Definition: CDCHit.h:40
unsigned short getID() const
Getter for encoded wire number.
Definition: CDCHit.h:193
Abstract Base class for the ADC count translator.
virtual float getCharge(unsigned short adcCount=0, const WireID &wireID=WireID(), bool ambiguityDiscriminator=false, float z=0, float theta=static_cast< float >(TMath::Pi()/2.))=0
Function, for which this actually was meant.
This class simply assumes a linear translation through (0,0)
Translator mirroring the realistic Digitization.
Base class for translation of Drift Time into Drift Length.
virtual double getDriftLength(unsigned short tdcCount=0, const WireID &wireID=WireID(), double timeOfFlightEstimator=0., bool ambiguityDiscriminator=false, double z=0, double alpha=0, double theta=static_cast< double >(TMath::Pi()/2.), unsigned short adcCount=0)=0
Function for getting a drift length estimation.
virtual double getDriftLengthResolution(double driftLength=0., const WireID &wireID=WireID(), bool ambiguityDiscriminator=false, double z=0, double alpha=0, double theta=static_cast< double >(TMath::Pi()/2.))=0
Uncertainty corresponding to drift length from getDriftLength of this class.
virtual double getDriftTime(unsigned short tdcCount, const WireID &wireID, double timeOfFlightEstimator, double z, unsigned short adcCount)=0
Get Drift time.
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
Particle trajectory as it is seen in xy projection represented as a circle.
Vector2D getClosest(const Vector2D &point) const
Calculates the closest approach on the trajectory to the given point.
Vector3D reconstruct3D(const WireLine &wireLine, double distance=0.0, double z=0) const
Gives the one three dimensional positions within the CDC closest to the given z where the given drift...
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
ISuperLayer getISuperLayer() const
Getter for the super layer id.
Definition: CDCWireHit.h:203
double getRefDriftLength() const
Getter for the drift length at the reference position of the wire.
Definition: CDCWireHit.h:224
const WireID & getWireID() const
Getter for the WireID of the wire the hit is located on.
Definition: CDCWireHit.h:185
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
CDCWireHit()=default
Default constructor for ROOT compatibility.
const CDCWire & getWire() const
Getter for the CDCWire the hit is located on.
Definition: CDCWireHit.h:168
static CDC::ADCCountTranslatorBase & getADCCountTranslator()
Return an instance of the used ADC count translator.
Definition: CDCWireHit.cc:45
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
WireID m_wireID
Memory for the WireID.
Definition: CDCWireHit.h:317
double m_refDriftLength
Memory for the drift length at the wire reference point.
Definition: CDCWireHit.h:326
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
Applies the conformal transformation to the drift circle this hit represents.
Definition: CDCWireHit.cc:200
double m_refDriftLengthVariance
Memory for the variance of the drift length at the wire reference point.
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).
Definition: CDCWireHit.cc:181
EStereoKind getStereoKind() const
Getter for the stereo type of the underlying wire.
Definition: CDCWireHit.h:191
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 superlayer in the central drift chamber.
ISuperLayer getISuperLayer() const
Getter for the super layer id.
Class representing a sense wire in the central drift chamber.
Definition: CDCWire.h:58
double getRefCylindricalR() const
Getter for the cylindrical radius at the wire reference position.
Definition: CDCWire.h:260
static const CDCWire * getInstance(const WireID &wireID)
Getter from the wireID convenience object. Does not construct a new object.
Definition: CDCWire.cc:24
const Vector3D & getRefPos3D() const
Getter for the wire reference position.
Definition: CDCWire.h:222
const Vector2D & getRefPos2D() const
Getter for the wire reference position for 2D tracking Gives the wire's reference position projected ...
Definition: CDCWire.h:229
double getRefZ() const
Getter for the wire reference z coordinate Gives the wire's reference z coordinate.
Definition: CDCWire.h:236
const WireLine & getWireLine() const
Getter for the wire line representation of the wire.
Definition: CDCWire.h:188
A two dimensional circle in its natural representation using center and radius as parameters.
Definition: Circle2D.h:26
void conformalTransform()
Transforms the circle to conformal space inplace.
Definition: Circle2D.h:74
A two dimensional vector which is equipped with functions for correct handling of orientation relate...
Definition: Vector2D.h:32
double normalizeTo(const double toLength)
Normalizes the vector to the given length.
Definition: Vector2D.h:313
A three dimensional vector.
Definition: Vector3D.h:33
A three dimensional limited line represented by its closest approach to the z-axes (reference positio...
Definition: WireLine.h:31
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
int getID(const std::vector< double > &breaks, double t)
get id of the time point t
Definition: calibTools.h:60
ERightLeft
Enumeration to represent the distinct possibilities of the right left passage.
Definition: ERightLeft.h:25
Abstract base class for different kinds of events.