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/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
18#include <tracking/trackingUtilities/numerics/ERightLeft.h>
19#include <tracking/trackingUtilities/numerics/Index.h>
20
21#include <cdc/translators/RealisticTDCCountTranslator.h>
22#include <cdc/translators/LinearGlobalADCCountTranslator.h>
23
24#include <cdc/translators/TDCCountTranslatorBase.h>
25#include <cdc/translators/ADCCountTranslatorBase.h>
26
27#include <cdc/dataobjects/CDCHit.h>
28#include <cdc/dataobjects/WireID.h>
29#include <framework/logging/Logger.h>
30
31#include <ostream>
32
33using namespace Belle2;
34using namespace CDC;
35using namespace TrackingUtilities;
36
38{
39 static CDC::RealisticTDCCountTranslator s_tdcCountTranslator;
40 return s_tdcCountTranslator;
41}
42
44{
45 static CDC::LinearGlobalADCCountTranslator s_adcCountTranslator;
46 return s_adcCountTranslator;
47}
48
49CDCWireHit::CDCWireHit(const CDCHit* const ptrHit,
50 const double driftLength,
51 const double driftLengthVariance,
52 const double chargeDeposit,
53 const double driftTime)
54 : m_wireID(ptrHit->getID())
55 , m_wire(CDCWire::getInstance(*ptrHit))
56 , m_hit(ptrHit)
57 , m_iHit(ptrHit->getArrayIndex())
59 , m_refDriftLength(driftLength)
60 , m_refDriftLengthVariance(driftLengthVariance)
61 , m_refChargeDeposit(chargeDeposit)
62 , m_refDriftTime(driftTime)
63{
64}
65
66CDCWireHit::CDCWireHit(const CDCHit* const ptrHit,
67 CDC::TDCCountTranslatorBase* ptrTDCCountTranslator,
68 CDC::ADCCountTranslatorBase* ptrADCCountTranslator)
69 : m_wireID(ptrHit->getID())
70 , m_wire(ptrHit ? CDCWire::getInstance(*ptrHit) : nullptr)
71 , m_hit(ptrHit)
72 , m_iHit(ptrHit ? ptrHit->getArrayIndex() : c_InvalidIndex)
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_hit(nullptr)
127 , m_iHit(c_InvalidIndex)
128 , m_automatonCell(1)
129 , m_refDriftLength(driftLength)
130 , m_refDriftLengthVariance(driftLengthVariance)
131 , m_refChargeDeposit(chargeDeposit)
132{
133}
134
136{
137 return this->getWireID().getEWire() < hit.getID();
138}
139
140bool TrackingUtilities::operator<(const CDCWireHit& wireHit, const CDCWireSuperLayer& wireSuperLayer)
141{
142 return wireHit.getISuperLayer() < wireSuperLayer.getISuperLayer();
143}
144
145bool TrackingUtilities::operator<(const CDCWireSuperLayer& wireSuperLayer, const CDCWireHit& wireHit)
146{
147 return wireSuperLayer.getISuperLayer() < wireHit.getISuperLayer();
148}
149
150bool TrackingUtilities::operator<(const CDCWireHit& wireHit, const CDCHit& hit)
151{
152 return wireHit.getWireID().getEWire() < hit.getID();
153}
154
155bool TrackingUtilities::operator<(const CDCHit& hit, const CDCWireHit& wireHit)
156{
157 return hit.getID() < wireHit.getWireID().getEWire();
158}
159
161{
163 assert(m_wire);
164 return *m_wire;
165}
166
167ROOT::Math::XYVector CDCWireHit::reconstruct2D(const CDCTrajectory2D& trajectory2D) const
168{
169 const ROOT::Math::XYVector& refPos2D = getRefPos2D();
170 ROOT::Math::XYVector recoPos2D = trajectory2D.getClosest(refPos2D);
171
172 const ROOT::Math::XYVector& wirePos2D = getWire().getRefPos2D();
173 const double driftLength = getRefDriftLength();
174
175 ROOT::Math::XYVector disp2D = recoPos2D - wirePos2D;
176
177 // Fix the displacement to lie on the drift circle.
178 if (disp2D.R() != 0.0) {
179 disp2D *= (driftLength / disp2D.R());
180 }
181 return wirePos2D + disp2D;
182}
183
184ROOT::Math::XYZVector CDCWireHit::reconstruct3D(const CDCTrajectory2D& trajectory2D,
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 ROOT::Math::XYVector 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 ROOT::Math::XYZVector(recoPos2D.X(), recoPos2D.Y(), z);
200 }
201}
202
203Circle2D CDCWireHit::conformalTransformed(const ROOT::Math::XYVector& relativeTo) const
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.
ROOT::Math::XYVector getClosest(const ROOT::Math::XYVector &point) const
Calculates the closest approach on the trajectory to the given point.
ROOT::Math::XYZVector 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:56
double getRefCylindricalR() const
The distance from the beam line at reference position of the underlying wire.
Circle2D conformalTransformed(const ROOT::Math::XYVector &relativeTo) const
Applies the conformal transformation to the drift circle this hit represents.
static CDC::TDCCountTranslatorBase & getTDCCountTranslator()
Return an instance of the used TDC count translator.
Definition CDCWireHit.cc:37
double getRefDriftLength() const
Getter for the drift length at the reference position of the wire.
Definition CDCWireHit.h:225
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:186
CDC::ISuperLayer getISuperLayer() const
Getter for the super layer id.
Definition CDCWireHit.h:204
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:169
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:325
static CDC::ADCCountTranslatorBase & getADCCountTranslator()
Return an instance of the used ADC count translator.
Definition CDCWireHit.cc:43
bool operator<(const CDCWireHit &rhs) const
Total ordering relation based on the wire and the hit id.
Definition CDCWireHit.h:114
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:318
CDC::EStereoKind getStereoKind() const
Getter for the stereo type of the underlying wire.
Definition CDCWireHit.h:192
double m_refDriftLength
Memory for the drift length at the wire reference point.
Definition CDCWireHit.h:334
double m_refDriftLengthVariance
Memory for the variance of the drift length at the wire reference point.
Definition CDCWireHit.h:337
AutomatonCell m_automatonCell
Memory for the automaton cell.
Definition CDCWireHit.h:331
ROOT::Math::XYZVector reconstruct3D(const CDCTrajectory2D &trajectory2D, ERightLeft rlInfo, double z=0) const
Attempts to reconstruct a three dimensional position (especially of stereo hits).
ROOT::Math::XYVector reconstruct2D(const CDCTrajectory2D &trajectory2D) const
Reconstructs a position of primary ionisation on the drift circle.
CDC::CDCWire const * m_wire
Memory for the CDCWire pointer - Trailing comment indicates to not stream this member.
Definition CDCWireHit.h:321
Index m_iHit
Index of the CDCHit in its StoreArray, so the link survives serialisation.
Definition CDCWireHit.h:328
double m_refChargeDeposit
Memory for the charge induced by the energy deposit in the drift cell.
Definition CDCWireHit.h:340
double m_refDriftTime
Measured drift time of the CDC hit.
Definition CDCWireHit.h:343
A two dimensional circle in its natural representation using center and radius as parameters.
Definition Circle2D.h:32
void conformalTransform()
Transforms the circle to conformal space inplace.
Definition Circle2D.h:80
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
EStereoKind
Type for the stereo property of the wire.
Definition EStereoKind.h:20
Abstract base class for different kinds of events.