Belle II Software development
DriftLengthEstimator Struct Reference

Helper construct implementing the (re)estimation of the drift length for various hit objects. More...

#include <DriftLengthEstimator.h>

Classes

struct  FacetDriftLengthCache
 Memory for the results of a facet drift length update that do not depend on the right left passage hypothesis of the middle hit. More...
 

Public Member Functions

void exposeParameters (ModuleParamList *moduleParamList, const std::string &prefix)
 Add the parameters of the estimator to the module.
 
double updateDriftLength (TrackingUtilities::CDCRecoHit2D &recoHit2D)
 Update the drift length of the reconstructed hit in place.
 
double updateDriftLength (TrackingUtilities::CDCRecoHit3D &recoHit3D, double tanLambda)
 Update the drift length of the reconstructed hit in place.
 
void updateDriftLength (TrackingUtilities::CDCFacet &facet)
 Re-estimate the drift length of all three contained drift circles.
 
void updateDriftLength (TrackingUtilities::CDCFacet &facet, FacetDriftLengthCache &cache)
 Re-estimate the drift lengths like updateDriftLength(facet), sharing the results that do not depend on the middle right left passage hypothesis via the given cache.
 
void updateDriftLength (TrackingUtilities::CDCSegment2D &segment)
 Update the drift length of the contained reconstructed hit in place.
 
void updateDriftLength (TrackingUtilities::CDCSegment3D &segment, double tanLambda)
 Update the drift length of the contained reconstructed hit in place.
 
void updateDriftLength (TrackingUtilities::CDCTrack &track, double tanLambda)
 Update the drift length of the contained reconstructed hit in place.
 

Public Attributes

bool m_param_useAlphaInDriftLength = true
 Parameter : Switch to serve the alpha angle to the drift length translator.
 
double m_param_tofMassScale = NAN
 Parameter : Mass to estimate the velocity in the flight time to the hit.
 

Private Member Functions

CDC::RealisticTDCCountTranslatorgetTDCCountTranslator ()
 Getter for the drift time translator constructing it on first use.
 

Private Attributes

std::shared_ptr< CDC::RealisticTDCCountTranslatorm_tdcCountTranslator
 Drift time translator constructed lazily on first use.
 

Detailed Description

Helper construct implementing the (re)estimation of the drift length for various hit objects.

Definition at line 43 of file DriftLengthEstimator.h.

Member Function Documentation

◆ exposeParameters()

void exposeParameters ( ModuleParamList * moduleParamList,
const std::string & prefix )

Add the parameters of the estimator to the module.

Definition at line 49 of file DriftLengthEstimator.cc.

50{
51 moduleParamList->addParameter(prefixed(prefix, "useAlphaInDriftLength"),
53 "Switch to serve the alpha angle to the drift length translator",
55
56 moduleParamList->addParameter(prefixed(prefix, "tofMassScale"),
58 "Mass to estimate the velocity in the flight time to the hit",
60}
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
double m_param_tofMassScale
Parameter : Mass to estimate the velocity in the flight time to the hit.
bool m_param_useAlphaInDriftLength
Parameter : Switch to serve the alpha angle to the drift length translator.

◆ getTDCCountTranslator()

CDC::RealisticTDCCountTranslator & getTDCCountTranslator ( )
inlineprivate

Getter for the drift time translator constructing it on first use.

The translator cannot be constructed together with the estimator, which usually happens during module construction, since it requires the geometry to be present.

Definition at line 121 of file DriftLengthEstimator.h.

122 {
123 if (not m_tdcCountTranslator) {
124 m_tdcCountTranslator = std::make_shared<CDC::RealisticTDCCountTranslator>();
125 }
126 return *m_tdcCountTranslator;
127 }

◆ updateDriftLength() [1/7]

void updateDriftLength ( TrackingUtilities::CDCFacet & facet)

Re-estimate the drift length of all three contained drift circles.

Using the additional flight direction information the accuracy of the drift length can be increased a lot helping the filters following this step

Definition at line 93 of file DriftLengthEstimator.cc.

94{
95 CDC::RealisticTDCCountTranslator& tdcCountTranslator = getTDCCountTranslator();
96
97 const UncertainParameterLine2D& line = facet.getFitLine();
98 ROOT::Math::XYVector flightDirection = line->tangential();
99 ROOT::Math::XYVector centralPos2D = line->closest(facet.getMiddleWire().getRefPos2D());
100 double alpha = ROOT::Math::VectorUtil::DeltaPhi(centralPos2D, flightDirection);
102 alpha = 0;
103 }
104
105 auto doUpdate = [&](CDCRLWireHit & rlWireHit, ROOT::Math::XYVector recoPos2D) {
106 const CDCWire& wire = rlWireHit.getWire();
107 const CDCHit* hit = rlWireHit.getWireHit().getHit();
108 const bool rl = rlWireHit.getRLInfo() == ERightLeft::c_Right;
109 const double beta = 1;
110 double flightTimeEstimate = FlightTimeEstimator::instance().getFlightTime2D(recoPos2D, alpha, beta);
111 double driftLength = tdcCountTranslator.getDriftLength(hit->getTDCCount(),
112 wire.getWireID(),
113 flightTimeEstimate,
114 rl,
115 wire.getRefZ(),
116 alpha);
117 rlWireHit.setRefDriftLength(driftLength);
118 };
119
120 doUpdate(facet.getStartRLWireHit(), facet.getStartRecoPos2D());
121 doUpdate(facet.getMiddleRLWireHit(), facet.getMiddleRecoPos2D());
122 doUpdate(facet.getEndRLWireHit(), facet.getEndRecoPos2D());
123
124 // More accurate implementation
125 // double startDriftLength = updateDriftLength(facet.getStartRecoHit2D());
126 // facet.getStartRLWireHit().setRefDriftLength(startDriftLength);
127
128 // double middleDriftLength = updateDriftLength(facet.getMiddleRecoHit2D());
129 // facet.getMiddleRLWireHit().setRefDriftLength(middleDriftLength);
130
131 // double endDriftLength = updateDriftLength(facet.getEndRecoHit2D());
132 // facet.getEndRLWireHit().setRefDriftLength(endDriftLength);
133}
short getTDCCount() const
Getter for TDC count.
Definition CDCHit.h:219
const WireID & getWireID() const
Getter for the wire id.
Definition CDCWire.h:114
double getRefZ() const
Getter for the wire reference z coordinate Gives the wire's reference z coordinate.
Definition CDCWire.h:228
double getDriftLength(unsigned short tdcCount, const WireID &wireID=WireID(), double timeOfFlightEstimator=0, bool leftRight=false, double z=0, double alpha=0, double theta=static_cast< double >(TMath::Pi()/2.), unsigned short adcCount=0) override
Get Drift length.
static const FlightTimeEstimator & instance(std::unique_ptr< FlightTimeEstimator > replacement=nullptr)
Getter for the instance.
virtual double getFlightTime2D(const ROOT::Math::XYVector &, double, double=1) const
Default estimator for the flight time.
const CDCWireHit & getWireHit() const
Getter for the wire hit associated with the oriented hit.
void setRefDriftLength(double driftLength)
Setter for the drift length at the reference position of the wire.
const CDC::CDCWire & getWire() const
Getter for the wire the oriented hit associated to.
ERightLeft getRLInfo() const
Getter for the right left passage information.
const CDCHit * getHit() const
Getter for the CDCHit pointer into the StoreArray.
Definition CDCWireHit.h:160
CDC::RealisticTDCCountTranslator & getTDCCountTranslator()
Getter for the drift time translator constructing it on first use.

◆ updateDriftLength() [2/7]

void updateDriftLength ( TrackingUtilities::CDCFacet & facet,
FacetDriftLengthCache & cache )

Re-estimate the drift lengths like updateDriftLength(facet), sharing the results that do not depend on the middle right left passage hypothesis via the given cache.

On the first call the cache is filled from a full update. Subsequent calls must be made with facets that differ from the first one only in the right left passage hypothesis of the middle hit and with unchanged base drift lengths, and only recompute the drift length of the middle hit.

Definition at line 135 of file DriftLengthEstimator.cc.

136{
137 CDC::RealisticTDCCountTranslator& tdcCountTranslator = getTDCCountTranslator();
138
139 auto computeDriftLength = [&](const CDCRLWireHit & rlWireHit, double flightTimeEstimate, double alpha) {
140 const CDCWire& wire = rlWireHit.getWire();
141 const CDCHit* hit = rlWireHit.getWireHit().getHit();
142 const bool rl = rlWireHit.getRLInfo() == ERightLeft::c_Right;
143 return tdcCountTranslator.getDriftLength(hit->getTDCCount(),
144 wire.getWireID(),
145 flightTimeEstimate,
146 rl,
147 wire.getRefZ(),
148 alpha);
149 };
150
151 const double beta = 1;
152 if (not cache.valid) {
153 // Full update like updateDriftLength(facet) filling the cache on the way
154 const UncertainParameterLine2D& line = facet.getFitLine();
155 ROOT::Math::XYVector flightDirection = line->tangential();
156 ROOT::Math::XYVector centralPos2D = line->closest(facet.getMiddleWire().getRefPos2D());
157 double alpha = ROOT::Math::VectorUtil::DeltaPhi(centralPos2D, flightDirection);
159 alpha = 0;
160 }
161
162 double startFlightTime =
163 FlightTimeEstimator::instance().getFlightTime2D(facet.getStartRecoPos2D(), alpha, beta);
164 double startDriftLength = computeDriftLength(facet.getStartRLWireHit(), startFlightTime, alpha);
165 facet.getStartRLWireHit().setRefDriftLength(startDriftLength);
166
167 double middleFlightTime =
168 FlightTimeEstimator::instance().getFlightTime2D(facet.getMiddleRecoPos2D(), alpha, beta);
169 double middleDriftLength = computeDriftLength(facet.getMiddleRLWireHit(), middleFlightTime, alpha);
170 facet.getMiddleRLWireHit().setRefDriftLength(middleDriftLength);
171
172 double endFlightTime =
173 FlightTimeEstimator::instance().getFlightTime2D(facet.getEndRecoPos2D(), alpha, beta);
174 double endDriftLength = computeDriftLength(facet.getEndRLWireHit(), endFlightTime, alpha);
175 facet.getEndRLWireHit().setRefDriftLength(endDriftLength);
176
177 cache.fitLine = line;
178 cache.alpha = alpha;
179 cache.middleFlightTime = middleFlightTime;
180 cache.startDriftLength = startDriftLength;
181 cache.endDriftLength = endDriftLength;
182 cache.valid = true;
183 } else {
184 // Only the middle hit depends on its right left passage hypothesis
185 facet.setFitLine(cache.fitLine);
186 facet.getStartRLWireHit().setRefDriftLength(cache.startDriftLength);
187 double middleDriftLength =
188 computeDriftLength(facet.getMiddleRLWireHit(), cache.middleFlightTime, cache.alpha);
189 facet.getMiddleRLWireHit().setRefDriftLength(middleDriftLength);
190 facet.getEndRLWireHit().setRefDriftLength(cache.endDriftLength);
191 }
192}

◆ updateDriftLength() [3/7]

double updateDriftLength ( TrackingUtilities::CDCRecoHit2D & recoHit2D)

Update the drift length of the reconstructed hit in place.

Definition at line 62 of file DriftLengthEstimator.cc.

63{
64 CDC::RealisticTDCCountTranslator& tdcCountTranslator = getTDCCountTranslator();
65
66 ROOT::Math::XYVector flightDirection = recoHit2D.getFlightDirection2D();
67 ROOT::Math::XYVector recoPos2D = recoHit2D.getRecoPos2D();
68 double alpha = ROOT::Math::VectorUtil::DeltaPhi(recoPos2D, flightDirection);
69 const double beta = 1;
70 double flightTimeEstimate = FlightTimeEstimator::instance().getFlightTime2D(recoPos2D, alpha, beta);
71
72 const CDCWire& wire = recoHit2D.getWire();
73 const CDCHit* hit = recoHit2D.getWireHit().getHit();
74 const bool rl = recoHit2D.getRLInfo() == ERightLeft::c_Right;
75
77 alpha = 0;
78 }
79
80 double driftLength = tdcCountTranslator.getDriftLength(hit->getTDCCount(),
81 wire.getWireID(),
82 flightTimeEstimate,
83 rl,
84 wire.getRefZ(),
85 alpha);
86 if (driftLength > -2 and driftLength < 16) {
87 bool snapRecoPos = true;
88 recoHit2D.setRefDriftLength(driftLength, snapRecoPos);
89 }
90 return driftLength;
91}

◆ updateDriftLength() [4/7]

double updateDriftLength ( TrackingUtilities::CDCRecoHit3D & recoHit3D,
double tanLambda )

Update the drift length of the reconstructed hit in place.

Definition at line 201 of file DriftLengthEstimator.cc.

203{
204 CDC::RealisticTDCCountTranslator& tdcCountTranslator = getTDCCountTranslator();
205
206 ROOT::Math::XYVector flightDirection = recoHit3D.getFlightDirection2D();
207 const ROOT::Math::XYZVector& recoPos3D = recoHit3D.getRecoPos3D();
208 const ROOT::Math::XYVector& recoPos2D = VectorUtil::getXYVector(recoPos3D);
209 double alpha = ROOT::Math::VectorUtil::DeltaPhi(recoPos2D, flightDirection);
210 const double beta = 1;
211 double flightTimeEstimate = FlightTimeEstimator::instance().getFlightTime2D(recoPos2D, alpha, beta);
212
213 if (std::isnan(tanLambda)) {
214 tanLambda = recoPos3D.z() / recoPos3D.Rho();
215 }
216 const double theta = M_PI / 2 - std::atan(tanLambda);
217 flightTimeEstimate *= hypot2(1, tanLambda);
218
219 const CDCWire& wire = recoHit3D.getWire();
220 const CDCHit* hit = recoHit3D.getWireHit().getHit();
221 const bool rl = recoHit3D.getRLInfo() == ERightLeft::c_Right;
222 double driftLength =
223 tdcCountTranslator.getDriftLength(hit->getTDCCount(),
224 wire.getWireID(),
225 flightTimeEstimate,
226 rl,
227 recoPos3D.z(),
228 alpha,
229 theta,
230 hit->getADCCount());
231 if (driftLength > -2 and driftLength < 16) {
232 bool snapRecoPos = true;
233 recoHit3D.setRecoDriftLength(driftLength, snapRecoPos);
234 }
235 return driftLength;
236}
unsigned short getADCCount() const
Getter for integrated charge.
Definition CDCHit.h:230

◆ updateDriftLength() [5/7]

void updateDriftLength ( TrackingUtilities::CDCSegment2D & segment)

Update the drift length of the contained reconstructed hit in place.

Definition at line 194 of file DriftLengthEstimator.cc.

195{
196 for (CDCRecoHit2D& recoHit2D : segment) {
197 updateDriftLength(recoHit2D);
198 }
199}
double updateDriftLength(TrackingUtilities::CDCRecoHit2D &recoHit2D)
Update the drift length of the reconstructed hit in place.

◆ updateDriftLength() [6/7]

void updateDriftLength ( TrackingUtilities::CDCSegment3D & segment,
double tanLambda )

Update the drift length of the contained reconstructed hit in place.

Definition at line 239 of file DriftLengthEstimator.cc.

241{
242 for (CDCRecoHit3D& recoHit3D : segment3D) {
243 updateDriftLength(recoHit3D, tanLambda);
244 }
245}

◆ updateDriftLength() [7/7]

void updateDriftLength ( TrackingUtilities::CDCTrack & track,
double tanLambda )

Update the drift length of the contained reconstructed hit in place.

Definition at line 247 of file DriftLengthEstimator.cc.

249{
250 for (CDCRecoHit3D& recoHit3D : track) {
251 updateDriftLength(recoHit3D, tanLambda);
252 }
253}

Member Data Documentation

◆ m_param_tofMassScale

double m_param_tofMassScale = NAN

Parameter : Mass to estimate the velocity in the flight time to the hit.

Definition at line 112 of file DriftLengthEstimator.h.

◆ m_param_useAlphaInDriftLength

bool m_param_useAlphaInDriftLength = true

Parameter : Switch to serve the alpha angle to the drift length translator.

Definition at line 109 of file DriftLengthEstimator.h.

◆ m_tdcCountTranslator

std::shared_ptr<CDC::RealisticTDCCountTranslator> m_tdcCountTranslator
private

Drift time translator constructed lazily on first use.

Definition at line 130 of file DriftLengthEstimator.h.


The documentation for this struct was generated from the following files: