131{
133
134 using SingleResult_t = std::tuple<
int,
int,
int,
142 using TrackResult_t = std::vector<SingleResult_t>;
144 constexpr int invalidInteger(-1);
146 const SingleResult_t invalidResult = std::make_tuple(invalidInteger, invalidInteger, invalidInteger,
147 invalidFloat, invalidFloat, invalidFloat, invalidFloat,
148 invalidInteger, invalidInteger, invalidInteger,
149 invalidFloat, invalidFloat, invalidFloat, invalidFloat,
150 invalidFloat, invalidFloat, invalidFloat, invalidFloat,
151 invalidID);
152 bool isUnbiased(true);
153
154 const ElementLink< TrackCollection >& trackLink =
particle.trackLink();
157 std::unique_ptr<const Trk::Track> trackWithHoles(
m_holeSearchTool->getTrackWithHoles(**trackLink));
158 const auto& allTrackStates = *(trackWithHoles->trackStateOnSurfaces());
159 const int numberOfHits(allTrackStates.size());
160 unsigned int trackParametersCounter(numberOfHits);
162 result.reserve(numberOfHits);
164 isUnbiased = true;
165 } else {
166 ATH_MSG_WARNING(
"The updater handle is empty, now using biased estimators");
167 isUnbiased = false;
168 }
169 ATH_MSG_DEBUG(
"Num. track states in track " << ++trackNumber <<
": " << allTrackStates.size());
170
171 for (const auto *const thisTrackState: allTrackStates) {
172
173
174 SingleResult_t thisResult(invalidResult);
175 if (not thisTrackState) {
176 msg(MSG::ERROR) <<
"TSOS is NULL" << (thisTrackState) <<
endmsg;
177 continue;
178 }
179 Identifier surfaceID;
180 const Trk::MeasurementBase* mesb = (thisTrackState)->measurementOnTrack();
181 const Trk::RIO_OnTrack* hit = mesb ? dynamic_cast<const Trk::RIO_OnTrack*>(mesb) : nullptr;
182 if (mesb && !hit) {
183 continue;
184 }
185
188 }
189 else {
190 if (not (thisTrackState)->trackParameters()) {
191 msg(MSG::INFO) <<
"TSOS surface is NULL" <<
endmsg;
192 continue;
193 }
194 surfaceID = (thisTrackState)->trackParameters()->associatedSurface().associatedDetectorElementIdentifier();
195 }
199
200 int measureType = -1;
201 if (isMesb) {
202 measureType = 0;
203 }
204 if (isOutl) {
205 measureType = 1;
206 }
207 if (isHole) {
208 measureType = 2;
209 }
210
211 bool anyHit = isMesb || isOutl || isHole;
212 if (!anyHit) {
213 continue;
214 }
217 int iLayer(invalidInteger);
219 if (not successfulIdentification) {
221 continue;
222 }
224
225 float residualLocX(invalidFloat), pullLocX(invalidFloat);
226 float residualLocY(invalidFloat), pullLocY(invalidFloat);
227 float measurementLocX(invalidFloat), trackParamLocX(invalidFloat), measurementLocCovX(invalidFloat);
228 float measurementLocY(invalidFloat), trackParamLocY(invalidFloat), measurementLocCovY(invalidFloat);
229 float angle(0.), etaloc(0.);
230 int phiWidth(invalidInteger), etaWidth(invalidInteger);
231 std::optional<Trk::ResidualPull> residualPull(std::nullopt);
233 if (biasedTrackParameters) {
235 }
237 if (mesb && biasedTrackParameters) {
239
240 std::unique_ptr<const Trk::TrackParameters> cleanup_trackparam;
243 biasedTrackParameters, mesb, isUnbiased) : biasedTrackParameters;
244
245 if (trackParameters != biasedTrackParameters) {
246 cleanup_trackparam.reset(trackParameters);
247 }
248 if (not trackParameters) {
250 }
251
254
257 if (not residualPull) {
259 continue;
260 }
261
263
264 residualLocX = 1000. * residualPull->residual()[
Trk::loc1];
265 pullLocX = residualPull->pull()[
Trk::loc1];
267 trackParamLocX = trackParameters->parameters()[
Trk::loc1];
269
270 if (residualPull->dimension() > 1) {
271 residualLocY = 1000. * residualPull->residual()[
Trk::loc2];
272 pullLocY = residualPull->pull()[
Trk::loc2];
274 trackParamLocY = trackParameters->parameters()[
Trk::loc2];
276 }
277
278
279 measureType = 4;
280
281 if (hit && isUnbiased) {
282
284 assert(
dynamic_cast <const InDet::SiCluster*
>(hit->
prepRawData())!=
nullptr);
285 const InDet::SiCluster* pCluster =
static_cast <const InDet::SiCluster*
>(hit->
prepRawData());
289
290
292 const InDetDD::SiDetectorElement* element = pCluster->
detectorElement();
296 double trkphicomp = my_track.dot(my_phiax);
297 double trketacomp = my_track.dot(my_etaax);
298 double trknormcomp = my_track.dot(my_normal);
299 double bowphi = std::atan2(trkphicomp,trknormcomp);
300 double boweta = std::atan2(trketacomp,trknormcomp);
301
304
305
307 if(bowphi < -
M_PI/2) bowphi +=
M_PI;
308
309
310
311
312 angle = std::atan(std::tan(bowphi)-readoutside*tanl);
313
314 double thetaloc=-999.;
315 if(boweta > -0.5*
M_PI && boweta <
M_PI/2.) {
316 thetaloc =
M_PI/2.-boweta;
317 }
else if(boweta >
M_PI/2. && boweta <
M_PI) {
318 thetaloc = 1.5*
M_PI-boweta;
319 } else {
320 thetaloc = -0.5*
M_PI-boweta;
321 }
322 etaloc = -1*
log(
tan(thetaloc/2.));
323 }
325 }
326 } else {
327 if (not mesb) {
329 }
330 if (not biasedTrackParameters) {
332 }
333 --trackParametersCounter;
334 }
335 thisResult = std::make_tuple(det,
r, iLayer,
336 residualLocX, pullLocX, residualLocY, pullLocY,
337 phiWidth, etaWidth, measureType,
338 measurementLocX, measurementLocY,
339 trackParamLocX, trackParamLocY,
341 measurementLocCovX, measurementLocCovY,
342 Surface_ID);
343 result.push_back(thisResult);
344 }
345 ATH_MSG_DEBUG(
"Out of " << numberOfHits <<
" hits, " << trackParametersCounter
346 <<
" had track params, and " <<
result.size() <<
" had residuals.");
348 const unsigned int arraySize =
result.size();
349 std::vector<int> result_det;
350 result_det.reserve(arraySize);
351 std::vector<int> result_r;
352 result_r.reserve(arraySize);
353 std::vector<int> result_iLayer;
354 result_iLayer.reserve(arraySize);
355 std::vector<float> result_residualLocX;
356 result_residualLocX.reserve(arraySize);
357 std::vector<float> result_pullLocX;
358 result_pullLocX.reserve(arraySize);
359 std::vector<float> result_residualLocY;
360 result_residualLocY.reserve(arraySize);
361 std::vector<float> result_pullLocY;
362 result_pullLocY.reserve(arraySize);
363 std::vector<int> result_phiWidth;
364 result_phiWidth.reserve(arraySize);
365 std::vector<int> result_etaWidth;
366 result_etaWidth.reserve(arraySize);
367 std::vector<int> result_measureType;
368 result_measureType.reserve(arraySize);
369 std::vector<float> result_measurementLocX;
370 result_measurementLocX.reserve(arraySize);
371 std::vector<float> result_measurementLocY;
372 result_measurementLocY.reserve(arraySize);
373 std::vector<float> result_trackParamLocX;
374 result_trackParamLocX.reserve(arraySize);
375 std::vector<float> result_trackParamLocY;
376 result_trackParamLocY.reserve(arraySize);
377 std::vector<float> result_angle;
378 result_angle.reserve(arraySize);
379 std::vector<float> result_etaloc;
380 result_etaloc.reserve(arraySize);
381 std::vector<float> result_measurementLocCovX;
382 result_measurementLocCovX.reserve(arraySize);
383 std::vector<float> result_measurementLocCovY;
384 result_measurementLocCovY.reserve(arraySize);
385 std::vector<uint64_t> result_surfaceID;
386 result_surfaceID.reserve(arraySize);
387
388 for (const SingleResult_t& single_result : result) {
389 result_det.push_back(std::get<0>(single_result));
390 result_r.push_back(std::get<1>(single_result));
391 result_iLayer.push_back(std::get<2>(single_result));
392 result_residualLocX.push_back(std::get<3>(single_result));
393 result_pullLocX.push_back(std::get<4>(single_result));
394 result_residualLocY.push_back(std::get<5>(single_result));
395 result_pullLocY.push_back(std::get<6>(single_result));
396 result_phiWidth.push_back(std::get<7>(single_result));
397 result_etaWidth.push_back(std::get<8>(single_result));
398 result_measureType.push_back(std::get<9>(single_result));
399 result_measurementLocX.push_back(std::get<10>(single_result));
400 result_measurementLocY.push_back(std::get<11>(single_result));
401 result_trackParamLocX.push_back(std::get<12>(single_result));
402 result_trackParamLocY.push_back(std::get<13>(single_result));
403 result_angle.push_back(std::get<14>(single_result));
404 result_etaloc.push_back(std::get<15>(single_result));
405 result_measurementLocCovX.push_back(std::get<16>(single_result));
406 result_measurementLocCovY.push_back(std::get<17>(single_result));
407 result_surfaceID.push_back(std::get<18>(single_result));
408 }
409
416
422
428
431
433
434 return true;
435 } else {
436
437
438 return true;
439 }
440 } else {
442 }
443 return false;
444}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
double angle(const GeoTrf::Vector2D &a, const GeoTrf::Vector2D &b)
bool isValid() const
Check if the element can be found.
value_type get_compact() const
Get the compact id.
int readoutSide() const
ReadoutSide.
virtual const SiDetectorDesign & design() const override final
access to the local description (inline):
const Amg::Vector3D & etaAxis() const
virtual const Amg::Vector3D & normal() const override final
Get reconstruction local normal axes in global frame.
virtual IdentifierHash identifyHash() const override final
identifier hash (inline)
const Amg::Vector3D & phiAxis() const
bool decideDetectorRegion(const Identifier &id, Subdetector &det, Region &r, int &layer) const
ToolHandle< Trk::ITrackHoleSearchTool > m_holeSearchTool
const Trk::TrackParameters * getUnbiasedTrackParameters(const Trk::TrackParameters *trkParameters, const Trk::MeasurementBase *measurement, bool &isUnbiased) const
ToolHandle< Trk::IResidualPullCalculator > m_residualPullCalculator
ToolHandle< ISiLorentzAngleTool > m_lorentzAngleTool
ToolHandle< Trk::IUpdator > m_updatorHandle
const InDet::SiWidth & width() const
return width class reference
virtual const InDetDD::SiDetectorElement * detectorElement() const override final
return the detector element corresponding to this PRD The pointer will be zero if the det el is not d...
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
virtual const Surface & associatedSurface() const =0
Interface method to get the associated Surface.
const Amg::MatrixX & localCovariance() const
Interface method to get the localError.
virtual const Trk::PrepRawData * prepRawData() const =0
returns the PrepRawData (also known as RIO) object to which this RIO_OnTrack is associated.
@ Biased
RP with track state including the hit.
@ Unbiased
RP with track state that has measurement not included.
const TrkDetElementBase * associatedDetectorElement() const
return associated Detector Element
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
@ Outlier
This TSoS contains an outlier, that is, it contains a MeasurementBase/RIO_OnTrack which was not used ...
@ Hole
A hole on the track - this is defined in the following way.
virtual Identifier identify() const =0
Identifier.
Eigen::Matrix< double, 3, 1 > Vector3D
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
@ loc2
generic first and second local coordinate
ParametersBase< TrackParametersDim, Charged > TrackParameters
constexpr double invalidFloat