Belle II Software  release-05-02-19
CDCWireHit.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2012 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
11 
12 #include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory2D.h>
13 
14 #include <tracking/trackFindingCDC/topology/CDCWireSuperLayer.h>
15 #include <tracking/trackFindingCDC/topology/CDCWire.h>
16 #include <tracking/trackFindingCDC/topology/EStereoKind.h>
17 
18 #include <tracking/trackFindingCDC/geometry/Circle2D.h>
19 #include <tracking/trackFindingCDC/geometry/Vector3D.h>
20 #include <tracking/trackFindingCDC/geometry/Vector2D.h>
21 
22 #include <tracking/trackFindingCDC/numerics/ERightLeft.h>
23 #include <tracking/trackFindingCDC/numerics/Index.h>
24 
25 #include <cdc/translators/RealisticTDCCountTranslator.h>
26 #include <cdc/translators/LinearGlobalADCCountTranslator.h>
27 
28 #include <cdc/dataobjects/TDCCountTranslatorBase.h>
29 #include <cdc/dataobjects/ADCCountTranslatorBase.h>
30 
31 #include <cdc/dataobjects/CDCHit.h>
32 #include <cdc/dataobjects/WireID.h>
33 #include <framework/logging/Logger.h>
34 
35 #include <ostream>
36 
37 using namespace Belle2;
38 using namespace CDC;
39 using namespace TrackFindingCDC;
40 
42 {
43  static CDC::RealisticTDCCountTranslator s_tdcCountTranslator;
44  return s_tdcCountTranslator;
45 }
46 
48 {
49  static CDC::LinearGlobalADCCountTranslator s_adcCountTranslator;
50  return s_adcCountTranslator;
51 }
52 
53 CDCWireHit::CDCWireHit(const CDCHit* const ptrHit,
54  const double driftLength,
55  const double driftLengthVariance,
56  const double chargeDeposit,
57  const double driftTime)
58  : m_wireID(ptrHit->getID())
59  , m_wire(CDCWire::getInstance(*ptrHit))
60  , m_automatonCell(1)
61  , m_refDriftLength(driftLength)
62  , m_refDriftLengthVariance(driftLengthVariance)
63  , m_refChargeDeposit(chargeDeposit)
64  , m_refDriftTime(driftTime)
65  , m_hit(ptrHit)
66 {
67 }
68 
69 CDCWireHit::CDCWireHit(const CDCHit* const ptrHit,
70  TDCCountTranslatorBase* ptrTDCCountTranslator,
71  ADCCountTranslatorBase* ptrADCCountTranslator)
72  : m_wireID(ptrHit->getID())
73  , m_wire(ptrHit ? CDCWire::getInstance(*ptrHit) : nullptr)
74  , m_automatonCell(1)
75  , m_hit(ptrHit)
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 
122 CDCWireHit::CDCWireHit(const WireID& wireID,
123  const double driftLength,
124  const double driftLengthVariance,
125  const double chargeDeposit)
126  : m_wireID(wireID)
127  , m_wire(CDCWire::getInstance(wireID))
128  , m_automatonCell(1)
129  , m_refDriftLength(driftLength)
130  , m_refDriftLengthVariance(driftLengthVariance)
131  , m_refChargeDeposit(chargeDeposit)
132  , m_hit(nullptr)
133 {
134 }
135 
137 {
138  return this->getWireID().getEWire() < hit.getID();
139 }
140 
141 bool TrackFindingCDC::operator<(const CDCWireHit& wireHit, const CDCWireSuperLayer& wireSuperLayer)
142 {
143  return wireHit.getISuperLayer() < wireSuperLayer.getISuperLayer();
144 }
145 
146 bool TrackFindingCDC::operator<(const CDCWireSuperLayer& wireSuperLayer, const CDCWireHit& wireHit)
147 {
148  return wireSuperLayer.getISuperLayer() < wireHit.getISuperLayer();
149 }
150 
151 bool TrackFindingCDC::operator<(const CDCWireHit& wireHit, const CDCHit& hit)
152 {
153  return wireHit.getWireID().getEWire() < hit.getID();
154 }
155 
156 bool TrackFindingCDC::operator<(const CDCHit& hit, const CDCWireHit& wireHit)
157 {
158  return hit.getID() < wireHit.getWireID().getEWire();
159 }
160 
162 {
164  assert(m_wire);
165  return *m_wire;
166 }
167 
169 {
170  const Vector2D& refPos2D = getRefPos2D();
171  Vector2D recoPos2D = trajectory2D.getClosest(refPos2D);
172 
173  const Vector2D& wirePos2D = getWire().getRefPos2D();
174  const double driftLength = getRefDriftLength();
175 
176  Vector2D disp2D = recoPos2D - wirePos2D;
177 
178  // Fix the displacement to lie on the drift circle.
179  disp2D.normalizeTo(driftLength);
180  return wirePos2D + disp2D;
181 }
182 
184  const ERightLeft rlInfo,
185  const double z) const
186 {
187  const EStereoKind stereoType = getStereoKind();
188 
189  if (stereoType == EStereoKind::c_StereoV or stereoType == EStereoKind::c_StereoU) {
190  const WireLine& wireLine = getWire().getWireLine();
191  const double signedDriftLength = isValid(rlInfo) ? rlInfo * getRefDriftLength() : 0.0;
192  return trajectory2D.reconstruct3D(wireLine, signedDriftLength, z);
193 
194  } else { /*if (stereoType == EStereoKind::c_Axial)*/
195  const Vector2D recoPos2D = reconstruct2D(trajectory2D);
196  // for axial wire we can not determine the z coordinate by looking at the xy projection only
197  // we set it the basic assumption.
198  return Vector3D(recoPos2D, z);
199  }
200 }
201 
203 {
204  Circle2D driftCircle(getRefPos2D() - relativeTo, getRefDriftLength());
205  driftCircle.conformalTransform();
206  return driftCircle;
207 }
208 
210 {
211  return getHit() ? getHit()->getArrayIndex() : c_InvalidIndex;
212 }
213 
215 {
216  return getWire().getRefPos2D();
217 }
218 
220 {
221  return getWire().getRefPos3D();
222 }
223 
225 {
226  return getWire().getRefCylindricalR();
227 }
228 
229 std::ostream& TrackFindingCDC::operator<<(std::ostream& output, const CDCWireHit& wirehit)
230 {
231  return output << "CDCWireHit(" << wirehit.getWireID()
232  << ", drift length=" << wirehit.getRefDriftLength() << ")";
233 }
Belle2::CDC::TDCCountTranslatorBase
Base class for translation of Drift Time into Drift Length.
Definition: TDCCountTranslatorBase.h:36
Belle2::TrackFindingCDC::CDCWireHit::getStereoKind
EStereoKind getStereoKind() const
Getter for the stereo type of the underlying wire.
Definition: CDCWireHit.h:199
Belle2::CDC::ADCCountTranslatorBase::getCharge
virtual float getCharge(unsigned short adcCount=0, const WireID &wireID=WireID(), bool ambiguityDiscrimiator=false, float z=0, float theta=static_cast< float >(TMath::Pi()/2.))=0
Function, for which this actually was meant.
Belle2::WireID
Class to identify a wire inside the CDC.
Definition: WireID.h:44
Belle2::Vector3D
HepGeom::Vector3D< double > Vector3D
3D Vector
Definition: Cell.h:35
Belle2::operator<<
std::ostream & operator<<(std::ostream &output, const IntervalOfValidity &iov)
Definition: IntervalOfValidity.cc:196
Belle2::TrackFindingCDC::CDCWireHit::getWireID
const WireID & getWireID() const
Getter for the WireID of the wire the hit is located on.
Definition: CDCWireHit.h:193
Belle2::TrackFindingCDC::Vector2D::normalizeTo
double normalizeTo(const double toLength)
Normalizes the vector to the given length.
Definition: Vector2D.h:327
Belle2::TrackFindingCDC::Vector2D
A two dimensional vector which is equipped with functions for correct handeling of orientation relat...
Definition: Vector2D.h:37
Belle2::TrackFindingCDC::CDCWireHit::getRefDriftLength
double getRefDriftLength() const
Getter for the drift length at the reference position of the wire.
Definition: CDCWireHit.h:232
Belle2::CDC::RealisticTDCCountTranslator
Translator mirroring the realistic Digitization.
Definition: RealisticTDCCountTranslator.h:36
Belle2::TrackFindingCDC::CDCWireHit::attachWire
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:161
Belle2::CDCHit::getID
unsigned short getID() const
Getter for encoded wire number.
Definition: CDCHit.h:204
Belle2::WireID::getEWire
unsigned short getEWire() const
Getter for encoded wire number.
Definition: WireID.h:164
Belle2::TrackFindingCDC::CDCWire::getRefPos2D
const Vector2D & getRefPos2D() const
Getter for the wire reference position for 2D tracking Gives the wire's reference position projected ...
Definition: CDCWire.h:231
Belle2::CDCHit
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Definition: CDCHit.h:51
Belle2::CDC::LinearGlobalADCCountTranslator
This class simply assumes a linear translation through (0,0)
Definition: LinearGlobalADCCountTranslator.h:31
Belle2::TrackFindingCDC::CDCWireHit::getISuperLayer
ISuperLayer getISuperLayer() const
Getter for the super layer id.
Definition: CDCWireHit.h:211
Belle2::TrackFindingCDC::CDCWire::getRefZ
double getRefZ() const
Getter for the wire reference z coordinate Gives the wire's reference z coordinate.
Definition: CDCWire.h:238
Belle2::getID
int getID(const std::vector< double > &breaks, double t)
get id of the time point t
Definition: calibTools.h:71
Belle2::TrackFindingCDC::CDCWireHit::getRefPos2D
const Vector2D & getRefPos2D() const
The two dimensional reference position (z=0) of the underlying wire.
Definition: CDCWireHit.cc:214
Belle2::TrackFindingCDC::CDCWireHit::getTDCCountTranslator
static CDC::TDCCountTranslatorBase & getTDCCountTranslator()
Return an instance of the used TDC count translator.
Definition: CDCWireHit.cc:41
Belle2::CDC::TDCCountTranslatorBase::getDriftLength
virtual double getDriftLength(unsigned short tdcCount=0, const WireID &wireID=WireID(), double timeOfFlightEstimator=0., bool ambiguityDiscrimiator=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.
Belle2::TrackFindingCDC::CDCWireHit::getHit
const CDCHit * getHit() const
Getter for the CDCHit pointer into the StoreArray.
Definition: CDCWireHit.h:167
Belle2::TrackFindingCDC::Circle2D
A two dimensional circle in its natural representation using center and radius as parameters.
Definition: Circle2D.h:36
Belle2::TrackFindingCDC::CDCWireHit::getStoreIHit
Index getStoreIHit() const
Getter for the index of the hit in the StoreArray holding this hit.
Definition: CDCWireHit.cc:209
Belle2::TrackFindingCDC::CDCWireSuperLayer::getISuperLayer
ISuperLayer getISuperLayer() const
Getter for the super layer id.
Definition: CDCWireSuperLayer.h:82
Belle2::TrackFindingCDC::CDCTrajectory2D::getClosest
Vector2D getClosest(const Vector2D &point) const
Calculates the closest approach on the trajectory to the given point.
Definition: CDCTrajectory2D.cc:173
Belle2::CDC::TDCCountTranslatorBase::getDriftLengthResolution
virtual double getDriftLengthResolution(double driftLength=0., const WireID &wireID=WireID(), bool ambiguityDiscrimiator=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.
Belle2::TrackFindingCDC::CDCTrajectory2D
Particle trajectory as it is seen in xy projection represented as a circle.
Definition: CDCTrajectory2D.h:46
Belle2::TrackFindingCDC::CDCWireHit::CDCWireHit
CDCWireHit()=default
Default constructor for ROOT compatibility.
Belle2::CDC::TDCCountTranslatorBase::getDriftTime
virtual double getDriftTime(unsigned short tdcCount, const WireID &wireID, double timeOfFlightEstimator, double z, unsigned short adcCount)=0
Get Drift time.
Belle2::operator<
bool operator<(ExpRun a, ExpRun b)
less than for ExpRun
Definition: Splitter.h:78
Belle2::TrackFindingCDC::CDCWire::getRefPos3D
const Vector3D & getRefPos3D() const
Getter for the wire reference position.
Definition: CDCWire.h:224
Belle2::TrackFindingCDC::CDCWireHit::m_wire
CDCWire const * m_wire
Memory for the CDCWire pointer - Trailing comment indicates to not stream this member.
Definition: CDCWireHit.h:328
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::WireLine
A three dimensional limited line represented by its closest approach to the z-axes (reference positio...
Definition: WireLine.h:41
Belle2::TrackFindingCDC::Vector3D
A three dimensional vector.
Definition: Vector3D.h:34
Belle2::TrackFindingCDC::CDCWireHit::m_refDriftLengthVariance
double m_refDriftLengthVariance
Memory for the variance of the drift length at the wire reference point.
Definition: CDCWireHit.h:337
Belle2::TrackFindingCDC::CDCTrajectory2D::reconstruct3D
Vector3D reconstruct3D(const WireLine &wireLine, double distance=0.0, double z=0) const
Gives the one three dimensional postions within the CDC closest to the given z where the given drift ...
Definition: CDCTrajectory2D.cc:164
Belle2::TrackFindingCDC::CDCWire::getInstance
static const CDCWire * getInstance(const WireID &wireID)
Getter from the wireID convinience object. Does not construct a new object.
Definition: CDCWire.cc:26
Belle2::TrackFindingCDC::NRightLeft::ERightLeft
ERightLeft
Enumeration to represent the distinct possibilities of the right left passage.
Definition: ERightLeft.h:35
Belle2::TrackFindingCDC::CDCWire::getWireLine
const WireLine & getWireLine() const
Getter for the wire line represenation of the wire.
Definition: CDCWire.h:190
Belle2::RelationsInterface::getArrayIndex
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
Definition: RelationsObject.h:387
Belle2::TrackFindingCDC::CDCWireHit::conformalTransformed
Circle2D conformalTransformed(const Vector2D &relativeTo) const
Applys the conformal transformation to the drift circle this hit represents.
Definition: CDCWireHit.cc:202
Belle2::TrackFindingCDC::CDCWireHit::m_refDriftTime
double m_refDriftTime
Measured drift time of the CDC hit.
Definition: CDCWireHit.h:346
Belle2::TrackFindingCDC::CDCWireHit::getWire
const CDCWire & getWire() const
Getter for the CDCWire the hit is located on.
Definition: CDCWireHit.h:176
Belle2::TrackFindingCDC::CDCWireSuperLayer
Class representating a sense wire superlayer in the central drift chamber.
Definition: CDCWireSuperLayer.h:53
Belle2::CDC::ADCCountTranslatorBase
Abstract Base class for the ADC count translator.
Definition: ADCCountTranslatorBase.h:33
Belle2::TrackFindingCDC::Circle2D::conformalTransform
void conformalTransform()
Transforms the circle to conformal space inplace.
Definition: Circle2D.h:84
Belle2::TrackFindingCDC::CDCWire
Class representing a sense wire in the central drift chamber.
Definition: CDCWire.h:60
Belle2::TrackFindingCDC::CDCWireHit::getRefPos3D
const Vector3D & getRefPos3D() const
The three dimensional reference position of the underlying wire.
Definition: CDCWireHit.cc:219
Belle2::TrackFindingCDC::CDCWireHit
Class representing a hit wire in the central drift chamber.
Definition: CDCWireHit.h:65
Belle2::TrackFindingCDC::CDCWireHit::getADCCountTranslator
static CDC::ADCCountTranslatorBase & getADCCountTranslator()
Return an instance of the used ADC count translator.
Definition: CDCWireHit.cc:47
Belle2::TrackFindingCDC::CDCWireHit::getRefCylindricalR
double getRefCylindricalR() const
The distance from the beam line at reference position of the underlying wire.
Definition: CDCWireHit.cc:224
Belle2::TrackFindingCDC::CDCWireHit::reconstruct2D
Vector2D reconstruct2D(const CDCTrajectory2D &trajectory2D) const
Reconstructs a position of primary ionisation on the drift circle.
Definition: CDCWireHit.cc:168
Belle2::TrackFindingCDC::CDCWireHit::reconstruct3D
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:183
Belle2::TrackFindingCDC::CDCWireHit::operator<
bool operator<(const CDCWireHit &rhs) const
Total ordering relation based on the wire and the hit id.
Definition: CDCWireHit.h:121
Belle2::TrackFindingCDC::CDCWireHit::m_refChargeDeposit
double m_refChargeDeposit
Memory for the charge induced by the energy deposit in the drift cell.
Definition: CDCWireHit.h:340
Belle2::TrackFindingCDC::CDCWireHit::m_refDriftLength
double m_refDriftLength
Memory for the drift length at the wire reference point.
Definition: CDCWireHit.h:334
Belle2::TrackFindingCDC::CDCWireHit::m_wireID
WireID m_wireID
Memory for the WireID.
Definition: CDCWireHit.h:325
Belle2::TrackFindingCDC::CDCWire::getRefCylindricalR
double getRefCylindricalR() const
Getter for the cylindrical radius at the wire reference position.
Definition: CDCWire.h:262