129{
131
132 using SingleResult_t = std::tuple<
int,
int,
int,
140 using TrackResult_t = std::vector<SingleResult_t>;
142 constexpr int invalidInteger(-1);
144 const SingleResult_t invalidResult = std::make_tuple(invalidInteger, invalidInteger, invalidInteger,
145 invalidFloat, invalidFloat, invalidFloat, invalidFloat,
146 invalidInteger, invalidInteger, invalidInteger,
147 invalidFloat, invalidFloat, invalidFloat, invalidFloat,
148 invalidFloat, invalidFloat, invalidFloat, invalidFloat,
149 invalidID);
150 bool isUnbiased(true);
151
152 const ElementLink< TrackCollection >& trackLink =
particle.trackLink();
155 std::unique_ptr<const Trk::Track> trackWithHoles(
m_holeSearchTool->getTrackWithHoles(**trackLink));
156 const auto& allTrackStates = *(trackWithHoles->trackStateOnSurfaces());
157 const int numberOfHits(allTrackStates.size());
158 unsigned int trackParametersCounter(numberOfHits);
160 result.reserve(numberOfHits);
162 isUnbiased = true;
163 } else {
164 ATH_MSG_WARNING(
"The updater handle is empty, now using biased estimators");
165 isUnbiased = false;
166 }
167 ATH_MSG_DEBUG(
"Num. track states in track " << ++trackNumber <<
": " << allTrackStates.size());
168
169 for (const auto *const thisTrackState: allTrackStates) {
170
171
172 SingleResult_t thisResult(invalidResult);
173 if (not thisTrackState) {
174 msg(MSG::ERROR) <<
"TSOS is NULL" << (thisTrackState) <<
endmsg;
175 continue;
176 }
177 Identifier surfaceID;
178 const Trk::MeasurementBase* mesb = (thisTrackState)->measurementOnTrack();
179 const Trk::RIO_OnTrack* hit = mesb ? dynamic_cast<const Trk::RIO_OnTrack*>(mesb) : nullptr;
180 if (mesb && !hit) {
181 continue;
182 }
183
186 }
187 else {
188 if (not (thisTrackState)->trackParameters()) {
189 msg(MSG::INFO) <<
"TSOS surface is NULL" <<
endmsg;
190 continue;
191 }
192 surfaceID = (thisTrackState)->trackParameters()->associatedSurface().associatedDetectorElementIdentifier();
193 }
197
198 int measureType = -1;
199 if (isMesb) {
200 measureType = 0;
201 }
202 if (isOutl) {
203 measureType = 1;
204 }
205 if (isHole) {
206 measureType = 2;
207 }
208
209 bool anyHit = isMesb || isOutl || isHole;
210 if (!anyHit) {
211 continue;
212 }
215 int iLayer(invalidInteger);
217 if (not successfulIdentification) {
219 continue;
220 }
222
223 float residualLocX(invalidFloat), pullLocX(invalidFloat);
224 float residualLocY(invalidFloat), pullLocY(invalidFloat);
225 float measurementLocX(invalidFloat), trackParamLocX(invalidFloat), measurementLocCovX(invalidFloat);
226 float measurementLocY(invalidFloat), trackParamLocY(invalidFloat), measurementLocCovY(invalidFloat);
227 float angle(0.), etaloc(0.);
228 int phiWidth(invalidInteger), etaWidth(invalidInteger);
229 std::optional<Trk::ResidualPull> residualPull(std::nullopt);
231 if (biasedTrackParameters) {
233 }
235 if (mesb && biasedTrackParameters) {
237
238 std::unique_ptr<const Trk::TrackParameters> cleanup_trackparam;
241 biasedTrackParameters, mesb, isUnbiased) : biasedTrackParameters;
242
243 if (trackParameters != biasedTrackParameters) {
244 cleanup_trackparam.reset(trackParameters);
245 }
246 if (not trackParameters) {
248 }
249
252
255 if (not residualPull) {
257 continue;
258 }
259
261
262 residualLocX = 1000. * residualPull->residual()[
Trk::loc1];
263 pullLocX = residualPull->pull()[
Trk::loc1];
265 trackParamLocX = trackParameters->parameters()[
Trk::loc1];
267
268 if (residualPull->dimension() > 1) {
269 residualLocY = 1000. * residualPull->residual()[
Trk::loc2];
270 pullLocY = residualPull->pull()[
Trk::loc2];
272 trackParamLocY = trackParameters->parameters()[
Trk::loc2];
274 }
275
276
277 measureType = 4;
278
279 if (hit && isUnbiased) {
280
282 assert(
dynamic_cast <const InDet::SiCluster*
>(hit->
prepRawData())!=
nullptr);
283 const InDet::SiCluster* pCluster =
static_cast <const InDet::SiCluster*
>(hit->
prepRawData());
287
288
290 const InDetDD::SiDetectorElement* element = pCluster->
detectorElement();
294 double trkphicomp = my_track.dot(my_phiax);
295 double trketacomp = my_track.dot(my_etaax);
296 double trknormcomp = my_track.dot(my_normal);
297 double bowphi = std::atan2(trkphicomp,trknormcomp);
298 double boweta = std::atan2(trketacomp,trknormcomp);
299
302
303
305 if(bowphi < -
M_PI/2) bowphi +=
M_PI;
306
307
308
309
310 angle = std::atan(std::tan(bowphi)-readoutside*tanl);
311
312 double thetaloc=-999.;
313 if(boweta > -0.5*
M_PI && boweta <
M_PI/2.) {
314 thetaloc =
M_PI/2.-boweta;
315 }
else if(boweta >
M_PI/2. && boweta <
M_PI) {
316 thetaloc = 1.5*
M_PI-boweta;
317 } else {
318 thetaloc = -0.5*
M_PI-boweta;
319 }
320 etaloc = -1*
log(
tan(thetaloc/2.));
321 }
323 }
324 } else {
325 if (not mesb) {
327 }
328 if (not biasedTrackParameters) {
330 }
331 --trackParametersCounter;
332 }
333 thisResult = std::make_tuple(det,
r, iLayer,
334 residualLocX, pullLocX, residualLocY, pullLocY,
335 phiWidth, etaWidth, measureType,
336 measurementLocX, measurementLocY,
337 trackParamLocX, trackParamLocY,
339 measurementLocCovX, measurementLocCovY,
340 Surface_ID);
341 result.push_back(thisResult);
342 }
343 ATH_MSG_DEBUG(
"Out of " << numberOfHits <<
" hits, " << trackParametersCounter
344 <<
" had track params, and " <<
result.size() <<
" had residuals.");
346 const unsigned int arraySize =
result.size();
347 std::vector<int> result_det;
348 result_det.reserve(arraySize);
349 std::vector<int> result_r;
350 result_r.reserve(arraySize);
351 std::vector<int> result_iLayer;
352 result_iLayer.reserve(arraySize);
353 std::vector<float> result_residualLocX;
354 result_residualLocX.reserve(arraySize);
355 std::vector<float> result_pullLocX;
356 result_pullLocX.reserve(arraySize);
357 std::vector<float> result_residualLocY;
358 result_residualLocY.reserve(arraySize);
359 std::vector<float> result_pullLocY;
360 result_pullLocY.reserve(arraySize);
361 std::vector<int> result_phiWidth;
362 result_phiWidth.reserve(arraySize);
363 std::vector<int> result_etaWidth;
364 result_etaWidth.reserve(arraySize);
365 std::vector<int> result_measureType;
366 result_measureType.reserve(arraySize);
367 std::vector<float> result_measurementLocX;
368 result_measurementLocX.reserve(arraySize);
369 std::vector<float> result_measurementLocY;
370 result_measurementLocY.reserve(arraySize);
371 std::vector<float> result_trackParamLocX;
372 result_trackParamLocX.reserve(arraySize);
373 std::vector<float> result_trackParamLocY;
374 result_trackParamLocY.reserve(arraySize);
375 std::vector<float> result_angle;
376 result_angle.reserve(arraySize);
377 std::vector<float> result_etaloc;
378 result_etaloc.reserve(arraySize);
379 std::vector<float> result_measurementLocCovX;
380 result_measurementLocCovX.reserve(arraySize);
381 std::vector<float> result_measurementLocCovY;
382 result_measurementLocCovY.reserve(arraySize);
383 std::vector<uint64_t> result_surfaceID;
384 result_surfaceID.reserve(arraySize);
385
386 for (const SingleResult_t& single_result : result) {
387 result_det.push_back(std::get<0>(single_result));
388 result_r.push_back(std::get<1>(single_result));
389 result_iLayer.push_back(std::get<2>(single_result));
390 result_residualLocX.push_back(std::get<3>(single_result));
391 result_pullLocX.push_back(std::get<4>(single_result));
392 result_residualLocY.push_back(std::get<5>(single_result));
393 result_pullLocY.push_back(std::get<6>(single_result));
394 result_phiWidth.push_back(std::get<7>(single_result));
395 result_etaWidth.push_back(std::get<8>(single_result));
396 result_measureType.push_back(std::get<9>(single_result));
397 result_measurementLocX.push_back(std::get<10>(single_result));
398 result_measurementLocY.push_back(std::get<11>(single_result));
399 result_trackParamLocX.push_back(std::get<12>(single_result));
400 result_trackParamLocY.push_back(std::get<13>(single_result));
401 result_angle.push_back(std::get<14>(single_result));
402 result_etaloc.push_back(std::get<15>(single_result));
403 result_measurementLocCovX.push_back(std::get<16>(single_result));
404 result_measurementLocCovY.push_back(std::get<17>(single_result));
405 result_surfaceID.push_back(std::get<18>(single_result));
406 }
407
414
420
426
429
431
432 return true;
433 } else {
434
435
436 return true;
437 }
438 } else {
440 }
441 return false;
442}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
double angle(const GeoTrf::Vector2D &a, const GeoTrf::Vector2D &b)
bool isValid() const
Test to see if the link can be dereferenced.
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