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)
58 , m_refDriftLength(driftLength)
59 , m_refDriftLengthVariance(driftLengthVariance)
60 , m_refChargeDeposit(chargeDeposit)
61 , m_refDriftTime(driftTime)
62{
63}
64
65CDCWireHit::CDCWireHit(const CDCHit* const ptrHit,
66 CDC::TDCCountTranslatorBase* ptrTDCCountTranslator,
67 CDC::ADCCountTranslatorBase* ptrADCCountTranslator)
68 : m_wireID(ptrHit->getID())
69 , m_wire(ptrHit ? CDCWire::getInstance(*ptrHit) : nullptr)
70 , m_hit(ptrHit)
72{
73 if (not ptrHit) {
74 B2ERROR("CDCWireHit constructor invoked with nullptr CDCHit");
75 return;
76 }
77 const CDCHit& hit = *ptrHit;
78
79 TDCCountTranslatorBase& tdcCountTranslator =
80 ptrTDCCountTranslator ? *ptrTDCCountTranslator : getTDCCountTranslator();
81 ADCCountTranslatorBase& adcCountTranslator =
82 ptrADCCountTranslator ? *ptrADCCountTranslator : getADCCountTranslator();
83
84 float initialTOFEstimate = 0;
85
86 float refDriftLengthRight = tdcCountTranslator.getDriftLength(hit.getTDCCount(),
87 getWireID(),
88 initialTOFEstimate,
89 false, // bool leftRight
90 getWire().getRefZ());
91
92 float refDriftLengthLeft = tdcCountTranslator.getDriftLength(hit.getTDCCount(),
93 getWireID(),
94 initialTOFEstimate,
95 true, // bool leftRight
96 getWire().getRefZ());
97
98 m_refDriftTime = tdcCountTranslator.getDriftTime(hit.getTDCCount(),
99 getWireID(),
100 initialTOFEstimate,
101 getWire().getRefZ(),
102 hit.getADCCount());
103
104 m_refDriftLength = (refDriftLengthLeft + refDriftLengthRight) / 2.0;
105
107 getWireID(),
108 false, // bool leftRight ?
109 getWire().getRefZ());
110
111 m_refChargeDeposit = adcCountTranslator.getCharge(hit.getADCCount(),
112 getWireID(),
113 false, // bool leftRight
114 getWire().getRefZ(),
115 0); // theta
116}
117
119 const double driftLength,
120 const double driftLengthVariance,
121 const double chargeDeposit)
122 : m_wireID(wireID)
123 , m_wire(CDCWire::getInstance(wireID))
124 , m_hit(nullptr)
125 , m_automatonCell(1)
126 , m_refDriftLength(driftLength)
127 , m_refDriftLengthVariance(driftLengthVariance)
128 , m_refChargeDeposit(chargeDeposit)
129{
130}
131
133{
134 return this->getWireID().getEWire() < hit.getID();
135}
136
137bool TrackingUtilities::operator<(const CDCWireHit& wireHit, const CDCWireSuperLayer& wireSuperLayer)
138{
139 return wireHit.getISuperLayer() < wireSuperLayer.getISuperLayer();
140}
141
142bool TrackingUtilities::operator<(const CDCWireSuperLayer& wireSuperLayer, const CDCWireHit& wireHit)
143{
144 return wireSuperLayer.getISuperLayer() < wireHit.getISuperLayer();
145}
146
147bool TrackingUtilities::operator<(const CDCWireHit& wireHit, const CDCHit& hit)
148{
149 return wireHit.getWireID().getEWire() < hit.getID();
150}
151
152bool TrackingUtilities::operator<(const CDCHit& hit, const CDCWireHit& wireHit)
153{
154 return hit.getID() < wireHit.getWireID().getEWire();
155}
156
158{
160 assert(m_wire);
161 return *m_wire;
162}
163
164ROOT::Math::XYVector CDCWireHit::reconstruct2D(const CDCTrajectory2D& trajectory2D) const
165{
166 const ROOT::Math::XYVector& refPos2D = getRefPos2D();
167 ROOT::Math::XYVector recoPos2D = trajectory2D.getClosest(refPos2D);
168
169 const ROOT::Math::XYVector& wirePos2D = getWire().getRefPos2D();
170 const double driftLength = getRefDriftLength();
171
172 ROOT::Math::XYVector disp2D = recoPos2D - wirePos2D;
173
174 // Fix the displacement to lie on the drift circle.
175 if (disp2D.R() != 0.0) {
176 disp2D *= (driftLength / disp2D.R());
177 }
178 return wirePos2D + disp2D;
179}
180
181ROOT::Math::XYZVector CDCWireHit::reconstruct3D(const CDCTrajectory2D& trajectory2D,
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 ROOT::Math::XYVector 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 ROOT::Math::XYZVector(recoPos2D.X(), recoPos2D.Y(), z);
197 }
198}
199
200Circle2D CDCWireHit::conformalTransformed(const ROOT::Math::XYVector& relativeTo) const
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
212const ROOT::Math::XYVector& CDCWireHit::getRefPos2D() const
213{
214 return getWire().getRefPos2D();
215}
216
217const ROOT::Math::XYZVector& CDCWireHit::getRefPos3D() const
218{
219 return getWire().getRefPos3D();
220}
221
223{
224 return getWire().getRefCylindricalR();
225}
226
227std::ostream& TrackingUtilities::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
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
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.
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.
const CDCHit * getHit() const
Getter for the CDCHit pointer into the StoreArray.
Definition CDCWireHit.h:160
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.
Definition CDCWireHit.h:324
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:330
Index getStoreIHit() const
Getter for the index of the hit in the StoreArray holding this hit.
double m_refDriftLengthVariance
Memory for the variance of the drift length at the wire reference point.
Definition CDCWireHit.h:333
AutomatonCell m_automatonCell
Memory for the automaton cell.
Definition CDCWireHit.h:327
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
double m_refChargeDeposit
Memory for the charge induced by the energy deposit in the drift cell.
Definition CDCWireHit.h:336
double m_refDriftTime
Measured drift time of the CDC hit.
Definition CDCWireHit.h:339
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.