Belle II Software release-11-00-00
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/trackingUtilities/eventdata/hits/CDCWireHit.h>
9
10#include <tracking/trackingUtilities/eventdata/trajectories/CDCTrajectory2D.h>
11
12#include <cdc/topology/CDCWireSuperLayer.h>
13#include <cdc/topology/CDCWire.h>
14#include <cdc/topology/EStereoKind.h>
15
16#include <tracking/trackingUtilities/geometry/Circle2D.h>
17#include <tracking/trackingUtilities/geometry/Vector3D.h>
18#include <tracking/trackingUtilities/geometry/Vector2D.h>
19
20#include <tracking/trackingUtilities/numerics/ERightLeft.h>
21#include <tracking/trackingUtilities/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 TrackingUtilities;
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_hit(ptrHit)
59 , m_iHit(ptrHit->getArrayIndex())
61 , m_refDriftLength(driftLength)
62 , m_refDriftLengthVariance(driftLengthVariance)
63 , m_refChargeDeposit(chargeDeposit)
64 , m_refDriftTime(driftTime)
65{
66}
67
68CDCWireHit::CDCWireHit(const CDCHit* const ptrHit,
69 CDC::TDCCountTranslatorBase* ptrTDCCountTranslator,
70 CDC::ADCCountTranslatorBase* ptrADCCountTranslator)
71 : m_wireID(ptrHit->getID())
72 , m_wire(ptrHit ? CDCWire::getInstance(*ptrHit) : nullptr)
73 , m_hit(ptrHit)
74 , m_iHit(ptrHit ? ptrHit->getArrayIndex() : c_InvalidIndex)
76{
77 if (not ptrHit) {
78 B2ERROR("CDCWireHit constructor invoked with nullptr CDCHit");
79 return;
80 }
81 const CDCHit& hit = *ptrHit;
82
83 TDCCountTranslatorBase& tdcCountTranslator =
84 ptrTDCCountTranslator ? *ptrTDCCountTranslator : getTDCCountTranslator();
85 ADCCountTranslatorBase& adcCountTranslator =
86 ptrADCCountTranslator ? *ptrADCCountTranslator : getADCCountTranslator();
87
88 float initialTOFEstimate = 0;
89
90 float refDriftLengthRight = tdcCountTranslator.getDriftLength(hit.getTDCCount(),
91 getWireID(),
92 initialTOFEstimate,
93 false, // bool leftRight
94 getWire().getRefZ());
95
96 float refDriftLengthLeft = tdcCountTranslator.getDriftLength(hit.getTDCCount(),
97 getWireID(),
98 initialTOFEstimate,
99 true, // bool leftRight
100 getWire().getRefZ());
101
102 m_refDriftTime = tdcCountTranslator.getDriftTime(hit.getTDCCount(),
103 getWireID(),
104 initialTOFEstimate,
105 getWire().getRefZ(),
106 hit.getADCCount());
107
108 m_refDriftLength = (refDriftLengthLeft + refDriftLengthRight) / 2.0;
109
111 getWireID(),
112 false, // bool leftRight ?
113 getWire().getRefZ());
114
115 m_refChargeDeposit = adcCountTranslator.getCharge(hit.getADCCount(),
116 getWireID(),
117 false, // bool leftRight
118 getWire().getRefZ(),
119 0); // theta
120}
121
123 const double driftLength,
124 const double driftLengthVariance,
125 const double chargeDeposit)
126 : m_wireID(wireID)
127 , m_wire(CDCWire::getInstance(wireID))
128 , m_hit(nullptr)
129 , m_iHit(c_InvalidIndex)
130 , m_automatonCell(1)
131 , m_refDriftLength(driftLength)
132 , m_refDriftLengthVariance(driftLengthVariance)
133 , m_refChargeDeposit(chargeDeposit)
134{
135}
136
138{
139 return this->getWireID().getEWire() < hit.getID();
140}
141
142bool TrackingUtilities::operator<(const CDCWireHit& wireHit, const CDCWireSuperLayer& wireSuperLayer)
143{
144 return wireHit.getISuperLayer() < wireSuperLayer.getISuperLayer();
145}
146
147bool TrackingUtilities::operator<(const CDCWireSuperLayer& wireSuperLayer, const CDCWireHit& wireHit)
148{
149 return wireSuperLayer.getISuperLayer() < wireHit.getISuperLayer();
150}
151
152bool TrackingUtilities::operator<(const CDCWireHit& wireHit, const CDCHit& hit)
153{
154 return wireHit.getWireID().getEWire() < hit.getID();
155}
156
157bool TrackingUtilities::operator<(const CDCHit& hit, const CDCWireHit& wireHit)
158{
159 return hit.getID() < wireHit.getWireID().getEWire();
160}
161
163{
165 assert(m_wire);
166 return *m_wire;
167}
168
170{
171 const Vector2D& refPos2D = getRefPos2D();
172 Vector2D recoPos2D = trajectory2D.getClosest(refPos2D);
173
174 const Vector2D& wirePos2D = getWire().getRefPos2D();
175 const double driftLength = getRefDriftLength();
176
177 Vector2D disp2D = recoPos2D - wirePos2D;
178
179 // Fix the displacement to lie on the drift circle.
180 disp2D.normalizeTo(driftLength);
181 return wirePos2D + disp2D;
182}
183
185 const ERightLeft rlInfo,
186 const double z) const
187{
188 const EStereoKind stereoType = getStereoKind();
189
190 if (stereoType == EStereoKind::c_StereoV or stereoType == EStereoKind::c_StereoU) {
191 const WireLine& wireLine = getWire().getWireLine();
192 const double signedDriftLength = isValid(rlInfo) ? static_cast<double>(rlInfo) * getRefDriftLength() : 0.0;
193 return trajectory2D.reconstruct3D(wireLine, signedDriftLength, z);
194
195 } else { /*if (stereoType == EStereoKind::c_Axial)*/
196 const Vector2D recoPos2D = reconstruct2D(trajectory2D);
197 // for axial wire we can not determine the z coordinate by looking at the xy projection only
198 // we set it the basic assumption.
199 return Vector3D(recoPos2D, z);
200 }
201}
202
204{
205 Circle2D driftCircle(getRefPos2D() - relativeTo, getRefDriftLength());
206 driftCircle.conformalTransform();
207 return driftCircle;
208}
209
210const ROOT::Math::XYVector& CDCWireHit::getRefPos2D() const
211{
212 return getWire().getRefPos2D();
213}
214
215const ROOT::Math::XYZVector& CDCWireHit::getRefPos3D() const
216{
217 return getWire().getRefPos3D();
218}
219
221{
222 return getWire().getRefCylindricalR();
223}
224
225std::ostream& TrackingUtilities::operator<<(std::ostream& output, const CDCWireHit& wirehit)
226{
227 return output << "CDCWireHit(" << wirehit.getWireID()
228 << ", drift length=" << wirehit.getRefDriftLength() << ")";
229}
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Definition CDCHit.h:40
short getTDCCount() const
Getter for TDC count.
Definition CDCHit.h:219
unsigned short getID() const
Getter for encoded wire number.
Definition CDCHit.h:193
unsigned short getADCCount() const
Getter for integrated charge.
Definition CDCHit.h:230
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.
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:50
double getRefCylindricalR() const
Getter for the cylindrical radius at the wire reference position.
Definition CDCWire.h:252
const ROOT::Math::XYVector & getRefPos2D() const
Getter for the wire reference position for 2D tracking Gives the wire's reference position projected ...
Definition CDCWire.h:221
const ROOT::Math::XYZVector & getRefPos3D() const
Getter for the wire reference position.
Definition CDCWire.h:214
static const CDCWire * getInstance(const WireID &wireID)
Getter from the wireID convenience object. Does not construct a new object.
Definition CDCWire.cc:24
const WireLine & getWireLine() const
Getter for the wire line representation of the wire.
Definition CDCWire.h:180
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.
A three dimensional limited line represented by its closest approach to the z-axes (reference positio...
Definition WireLine.h:33
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 CDC::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:58
double getRefCylindricalR() const
The distance from the beam line at reference position of the underlying wire.
static CDC::TDCCountTranslatorBase & getTDCCountTranslator()
Return an instance of the used TDC count translator.
Definition CDCWireHit.cc:39
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
CDC::ISuperLayer getISuperLayer() const
Getter for the super layer id.
Definition CDCWireHit.h:206
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
const CDCHit * m_hit
Memory for the CDCHit pointer - not streamed (ROOT would deep-copy the pointed object and leak it on ...
Definition CDCWireHit.h:327
static CDC::ADCCountTranslatorBase & getADCCountTranslator()
Return an instance of the used ADC count translator.
Definition CDCWireHit.cc:45
bool operator<(const CDCWireHit &rhs) const
Total ordering relation based on the wire and the hit id.
Definition CDCWireHit.h:116
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
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:336
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:339
AutomatonCell m_automatonCell
Memory for the automaton cell.
Definition CDCWireHit.h:333
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
Index m_iHit
Index of the CDCHit in its StoreArray, so the link survives serialisation.
Definition CDCWireHit.h:330
double m_refChargeDeposit
Memory for the charge induced by the energy deposit in the drift cell.
Definition CDCWireHit.h:342
double m_refDriftTime
Measured drift time of the CDC hit.
Definition CDCWireHit.h:345
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:36
double normalizeTo(const double toLength)
Normalizes the vector to the given length.
Definition Vector2D.h:340
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
int getID(const std::vector< double > &breaks, double t)
get id of the time point t
Definition calibTools.h:60
HepGeom::Vector3D< double > Vector3D
3D Vector
Definition Cell.h:34
EStereoKind
Type for the stereo property of the wire.
Definition EStereoKind.h:20
Abstract base class for different kinds of events.