13 #include "Identifier/Identifier.h"
23 #include "GaudiKernel/EventContext.h"
26 #include <initializer_list>
29 template<
class Indexable,
class IntegerArray>
31 setTheseElements(Indexable& container,
33 const typename Indexable::value_type& toValue)
36 container[
idx] = toValue;
40 template<
class Indexable>
42 setTheseElements(Indexable& container,
43 const std::initializer_list<size_t>&
indices,
44 const typename Indexable::value_type& toValue)
47 container[
idx] = toValue;
58 declareInterface<ITrackSummaryTool>(
this);
67 if (m_idTool.empty() && m_muonTool.empty()) {
68 ATH_MSG_WARNING(
"Could get neither InDetHelperTool nor MuonHelperTool.");
70 if (not m_idTool.empty()) {
73 if (not m_muonTool.empty()) {
82 return StatusCode::SUCCESS;
97 const EventContext& ctx,
99 bool suppress_hole_search)
const
101 track.setTrackSummary(createSummary(ctx,
103 m_doHolesInDet & !suppress_hole_search,
104 m_doHolesMuon & !suppress_hole_search));
111 std::unique_ptr<Trk::TrackSummary>
115 return createSummary(
116 ctx,
track, m_doHolesInDet, m_doHolesMuon);
124 std::unique_ptr<Trk::TrackSummary>
128 return createSummary(ctx,
track,
false,
false);
135 std::unique_ptr<Trk::TrackSummary>
139 bool doHolesMuon)
const
141 std::unique_ptr<Trk::TrackSummary>
ts;
143 if (
track.trackSummary() !=
nullptr) {
144 ts = std::make_unique<Trk::TrackSummary>(*(
track.trackSummary()));
146 ts = std::make_unique<Trk::TrackSummary>();
164 bool doHolesMuon)
const
167 std::vector<int>& information =
ts.m_information;
168 information.resize(
std::min(information.size(),
171 constexpr
int toZero{ 0 };
172 if (!m_idTool.empty()) {
175 constexpr
size_t numberOfPixelCounters{ 8 };
176 constexpr std::array<size_t, numberOfPixelCounters> atPixelIndices{
186 setTheseElements(information, atPixelIndices, toZero);
191 constexpr
size_t numberOfSctOrTrtCounters{ 9 };
192 constexpr std::array<size_t, numberOfSctOrTrtCounters> atSctOrTrtIndices{
203 setTheseElements(information, atSctOrTrtIndices, toZero);
206 if (!m_muonTool.empty()) {
208 constexpr
size_t numberOfMuonRelatedCounters{ 15 };
209 constexpr std::array<size_t, numberOfMuonRelatedCounters> atMuonIndices{
220 constexpr
size_t numberOfNswRelatedCounters{ 6 };
221 constexpr std::array<size_t, numberOfNswRelatedCounters> atNswIndices{
225 setTheseElements(information, atMuonIndices, toZero);
226 setTheseElements(information, atNswIndices, toZero);
230 std::bitset<numberOfDetectorTypes> hitPattern;
231 if (
track.trackStateOnSurfaces()) {
233 processTrackStates(ctx,
235 track.trackStateOnSurfaces(),
242 <<
track.info().dumpInfo()
243 <<
"). This should never happen! ");
245 ts.m_idHitPattern = hitPattern.to_ulong();
256 if ((doHolesInDet || doHolesMuon) &&
257 (!holeSearchDone || m_alwaysRecomputeHoles.value())) {
263 searchHolesStepWise(
track, information, doHolesInDet, doHolesMuon);
267 if (m_addMuonDetailedSummary && !m_muonTool.empty()) {
268 m_muonTool->addDetailedTrackSummary(ctx,
track,
ts);
277 const EventContext& ctx,
280 std::vector<int>& information,
281 std::bitset<numberOfDetectorTypes>& hitPattern,
283 bool doHolesMuon)
const
290 for (;
it != itEnd; ++
it) {
291 const auto& trackState = **
it;
292 const auto isMeasurement =
295 if (isMeasurement or isOutlier) {
298 ATH_MSG_WARNING(
"measurementOnTrack == null for a TrackStateOnSurface "
299 "of type Measurement or Outlier");
305 ctx,
track, measurement, *
it, information, hitPattern);
310 if (
const auto& pFitQuality{ trackState.fitQualityOnSurface() };
311 pFitQuality and pFitQuality.numberDoF() > 0) {
313 if (
const auto& chiSq{ pFitQuality.chiSquared() };
318 const float chi2add = chiSq / pFitQuality.numberDoF();
320 chi2Sum2 += chi2add * chi2add;
326 trackState.trackParameters()) {
330 if (trackState.trackParameters()
331 ->associatedSurface()
332 .associatedDetectorElement() !=
nullptr) {
333 const Identifier&
id = trackState.trackParameters()
334 ->associatedSurface()
335 .associatedDetectorElementIdentifier();
336 if (!doHolesInDet && m_detID->is_pixel(
id))
338 if (!doHolesInDet && m_detID->is_sct(
id))
340 if (!doHolesMuon && m_detID->is_mdt(
id))
348 if (cntAddChi2 > 0) {
349 const auto inverseCount{ 1. / cntAddChi2 };
350 varChi2 = (chi2Sum2 - (chi2Sum * chi2Sum * inverseCount)) * inverseCount;
352 if (varChi2 > 0 && varChi2 < 1.e13)
363 const EventContext& ctx,
367 std::vector<int>& information,
368 std::bitset<numberOfDetectorTypes>& hitPattern)
const
378 if (
tool ==
nullptr) {
382 ctx,
track, rot, tsos, information, hitPattern);
395 if (
tool ==
nullptr) {
399 ctx,
track, compROT, tsos, information, hitPattern);
408 if (m_detID->is_indet(
id)) {
409 if (!m_idTool.empty()) {
413 }
else if (m_detID->is_muon(
id)) {
414 if (!m_muonTool.empty()) {
417 ATH_MSG_WARNING(
"getTool: Identifier is from Muon but have no Muon tool");
420 "getTool: Identifier is of unknown type! id: " <<
id.getString());
427 std::vector<int>& information,
429 bool doHolesMuon)
const
431 ATH_MSG_VERBOSE(
"Entering Trk::TrackSummaryTool::searchHolesStepWise");
433 if (
track.trackStateOnSurfaces() ==
nullptr) {
434 constexpr
int toMinusOne{ -1 };
452 setTheseElements(information, atIndices, toMinusOne);
456 constexpr
int toZero{ 0 };
469 if (!m_muonTool.empty() && doHolesMuon) {
473 constexpr
size_t numberOfRelatedMuonCounters{ 10 };
474 constexpr std::array<size_t, numberOfRelatedMuonCounters> atMuonIndices{
487 setTheseElements(information, atMuonIndices, toZero);