Belle II Software prerelease-11-00-00d
DriftLengthEstimator Struct Reference

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

#include <DriftLengthEstimator.h>

Collaboration diagram for DriftLengthEstimator:

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 45 of file DriftLengthEstimator.cc.

46{
47 moduleParamList->addParameter(prefixed(prefix, "useAlphaInDriftLength"),
49 "Switch to serve the alpha angle to the drift length translator",
51
52 moduleParamList->addParameter(prefixed(prefix, "tofMassScale"),
54 "Mass to estimate the velocity in the flight time to the hit",
56}
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 89 of file DriftLengthEstimator.cc.

90{
91 CDC::RealisticTDCCountTranslator& tdcCountTranslator = getTDCCountTranslator();
92
93 const UncertainParameterLine2D& line = facet.getFitLine();
94 Vector2D flightDirection = line->tangential();
95 Vector2D centralPos2D = line->closest(facet.getMiddleWire().getRefPos2D());
96 double alpha = centralPos2D.angleWith(flightDirection);
98 alpha = 0;
99 }
100
101 auto doUpdate = [&](CDCRLWireHit & rlWireHit, Vector2D recoPos2D) {
102 const CDCWire& wire = rlWireHit.getWire();
103 const CDCHit* hit = rlWireHit.getWireHit().getHit();
104 const bool rl = rlWireHit.getRLInfo() == ERightLeft::c_Right;
105 const double beta = 1;
106 double flightTimeEstimate = FlightTimeEstimator::instance().getFlightTime2D(recoPos2D, alpha, beta);
107 double driftLength = tdcCountTranslator.getDriftLength(hit->getTDCCount(),
108 wire.getWireID(),
109 flightTimeEstimate,
110 rl,
111 wire.getRefZ(),
112 alpha);
113 rlWireHit.setRefDriftLength(driftLength);
114 };
115
116 doUpdate(facet.getStartRLWireHit(), facet.getStartRecoPos2D());
117 doUpdate(facet.getMiddleRLWireHit(), facet.getMiddleRecoPos2D());
118 doUpdate(facet.getEndRLWireHit(), facet.getEndRecoPos2D());
119
120 // More accurate implementation
121 // double startDriftLength = updateDriftLength(facet.getStartRecoHit2D());
122 // facet.getStartRLWireHit().setRefDriftLength(startDriftLength);
123
124 // double middleDriftLength = updateDriftLength(facet.getMiddleRecoHit2D());
125 // facet.getMiddleRLWireHit().setRefDriftLength(middleDriftLength);
126
127 // double endDriftLength = updateDriftLength(facet.getEndRecoHit2D());
128 // facet.getEndRLWireHit().setRefDriftLength(endDriftLength);
129}
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.
virtual double getFlightTime2D(const TrackingUtilities::Vector2D &, double, double=1) const
Default estimator for the flight time.
static const FlightTimeEstimator & instance(std::unique_ptr< FlightTimeEstimator > replacement=nullptr)
Getter for the instance.
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:162
double angleWith(const Vector2D &rhs) const
The angle between this and rhs.
Definition Vector2D.h:224
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 131 of file DriftLengthEstimator.cc.

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

◆ updateDriftLength() [3/7]

double updateDriftLength ( TrackingUtilities::CDCRecoHit2D & recoHit2D)

Update the drift length of the reconstructed hit in place.

Definition at line 58 of file DriftLengthEstimator.cc.

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

◆ updateDriftLength() [4/7]

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

Update the drift length of the reconstructed hit in place.

Definition at line 197 of file DriftLengthEstimator.cc.

199{
200 CDC::RealisticTDCCountTranslator& tdcCountTranslator = getTDCCountTranslator();
201
202 Vector2D flightDirection = recoHit3D.getFlightDirection2D();
203 const Vector3D& recoPos3D = recoHit3D.getRecoPos3D();
204 const Vector2D& recoPos2D = recoPos3D.xy();
205 double alpha = recoPos2D.angleWith(flightDirection);
206 const double beta = 1;
207 double flightTimeEstimate = FlightTimeEstimator::instance().getFlightTime2D(recoPos2D, alpha, beta);
208
209 if (std::isnan(tanLambda)) {
210 tanLambda = recoPos3D.z() / recoPos3D.cylindricalR();
211 }
212 const double theta = M_PI / 2 - std::atan(tanLambda);
213 flightTimeEstimate *= hypot2(1, tanLambda);
214
215 const CDCWire& wire = recoHit3D.getWire();
216 const CDCHit* hit = recoHit3D.getWireHit().getHit();
217 const bool rl = recoHit3D.getRLInfo() == ERightLeft::c_Right;
218 double driftLength =
219 tdcCountTranslator.getDriftLength(hit->getTDCCount(),
220 wire.getWireID(),
221 flightTimeEstimate,
222 rl,
223 recoPos3D.z(),
224 alpha,
225 theta,
226 hit->getADCCount());
227 if (driftLength > -2 and driftLength < 16) {
228 bool snapRecoPos = true;
229 recoHit3D.setRecoDriftLength(driftLength, snapRecoPos);
230 }
231 return driftLength;
232}
unsigned short getADCCount() const
Getter for integrated charge.
Definition CDCHit.h:230
const Vector2D & xy() const
Getter for the xy projected vector ( reference ! )
Definition Vector3D.h:509
double cylindricalR() const
Getter for the cylindrical radius ( xy projected norm )
Definition Vector3D.h:535
double z() const
Getter for the z coordinate.
Definition Vector3D.h:497
HepGeom::Vector3D< double > Vector3D
3D Vector
Definition Cell.h:34

◆ updateDriftLength() [5/7]

void updateDriftLength ( TrackingUtilities::CDCSegment2D & segment)

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

Definition at line 190 of file DriftLengthEstimator.cc.

191{
192 for (CDCRecoHit2D& recoHit2D : segment) {
193 updateDriftLength(recoHit2D);
194 }
195}
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 235 of file DriftLengthEstimator.cc.

237{
238 for (CDCRecoHit3D& recoHit3D : segment3D) {
239 updateDriftLength(recoHit3D, tanLambda);
240 }
241}

◆ updateDriftLength() [7/7]

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

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

Definition at line 243 of file DriftLengthEstimator.cc.

245{
246 for (CDCRecoHit3D& recoHit3D : track) {
247 updateDriftLength(recoHit3D, tanLambda);
248 }
249}

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: