31 declareInterface<ITrackSummaryHelperTool>(
this);
35 ATH_CHECK(m_DetectorManagerKey.initialize());
36 ATH_CHECK(m_extrapolator.retrieve(EnableTool{m_calculateCloseHits && !m_extrapolator.empty()}));
37 ATH_CHECK(m_slExtrapolator.retrieve(EnableTool{m_calculateCloseHits && !m_slExtrapolator.empty()}));
40 return StatusCode::SUCCESS;
45 std::bitset<Trk::numberOfDetectorTypes>& )
const {
50 ATH_MSG_DEBUG(
"Processing rot: " << m_idHelperSvc->toString(
id));
51 if (m_idHelperSvc->isRpc(
id)) {
52 if (m_idHelperSvc->rpcIdHelper().measuresPhi(
id))
56 }
else if (m_idHelperSvc->isCsc(
id)) {
57 if (m_idHelperSvc->cscIdHelper().measuresPhi(
id))
65 }
else if (m_idHelperSvc->isTgc(
id)) {
66 if (m_idHelperSvc->tgcIdHelper().isStrip(
id))
70 }
else if (m_idHelperSvc->isMdt(
id)) {
72 }
else if (m_idHelperSvc->issTgc(
id)) {
73 if (m_idHelperSvc->stgcIdHelper().measuresPhi(
id)) increment(information[
numberOfStgcPhiHits]);
77 }
else if (m_idHelperSvc->isMM(
id)) {
87 std::bitset<Trk::numberOfDetectorTypes>& hitPattern)
const {
89 std::set<Identifier> layIds;
93 ATH_MSG_DEBUG(
"ROT " <<
i <<
"\t LayerId=" << m_idHelperSvc->toString(layId));
97 ATH_MSG_DEBUG(
"Have found hit on new layer. # of layers for this cROT currently=" << layIds.size());
98 analyse(trk, rot, tsos, information, hitPattern);
112 ATH_MSG_WARNING(
"searchForHoles is not implemented in MuonTrackSummaryHelperTool");
116 if (
summary.m_muonTrackSummary) {
117 ATH_MSG_DEBUG(
"TrackSummary already has detailed muon track summary, not adding a new one");
120 const EventContext& ctx = Gaudi::Hive::currentContext();
123 if (MuonDetMgr ==
nullptr) {
124 ATH_MSG_ERROR(
"Null pointer to the read MuonDetectorManager conditions object");
143 for (; tsit != tsit_end; ++tsit) {
153 ATH_MSG_WARNING(
" Hole state without track parameters, cannot identify hole ");
156 if (
pars->associatedSurface().associatedDetectorElement()) {
157 Identifier id =
pars->associatedSurface().associatedDetectorElement()->identify();
158 bool issTgc = m_idHelperSvc->issTgc(
id);
161 Identifier idh =
pars->associatedSurface().associatedDetectorElementIdentifier();
162 if (idh.is_valid()) {
id = idh; }
164 if (!
id.is_valid() || !m_idHelperSvc->isMuon(
id))
continue;
165 Identifier chId = m_idHelperSvc->chamberId(
id);
167 if (issTgc) chId = m_idHelperSvc->detElId(
id);
168 bool isFirst = isFirstProjection(
id);
169 bool isMdt = m_idHelperSvc->isMdt(
id);
172 if (!currentChamberSummary || currentChamberSummary->
m_chId != chId) {
176 if (m_calculateCloseHits && currentChamberSummary && currentChamberPars) {
178 calculateRoadHits(*currentChamberSummary, *currentChamberPars);
182 if (currentChamberSummary && !currentChamberSummary->
isMdt()) { updateHoleContent(*currentChamberSummary); }
184 ATH_MSG_VERBOSE(
" Adding new chamber (holes) " << m_idHelperSvc->toString(
id) <<
" " << *
pars);
187 currentChamberPars =
pars;
191 isFirst ? currentChamberSummary->
m_first : currentChamberSummary->
m_second;
195 if (m_idHelperSvc->measuresPhi(
id)) {
211 if (!meas) {
continue; }
229 bool inBounds =
true;
232 std::set<Identifier> layIds;
233 std::set<Identifier> goodLayIds;
239 if (!m_idHelperSvc->isMuon(
id))
continue;
243 double tol2 = 2 * tol1;
244 if (!pseudo && m_idHelperSvc->isMdt(
id)) tol1 = 5.;
254 }
else if (mmClusterOnTrack) {
261 Identifier layId = m_idHelperSvc->layerId(
id);
262 layIds.insert(layId);
268 goodLayIds.insert(layId);
270 }
else if (m_idHelperSvc->isCsc(
id)) {
274 goodLayIds.insert(layId);
275 }
else if (m_idHelperSvc->isMM(
id)) {
277 goodLayIds.insert(layId);
278 }
else if (m_idHelperSvc->issTgc(
id)) {
280 goodLayIds.insert(layId);
291 std::vector<const Muon::MuonClusterOnTrack*>::const_iterator cl_it = crot->
containedROTs().begin();
292 std::vector<const Muon::MuonClusterOnTrack*>::const_iterator cl_it_end = crot->
containedROTs().end();
293 for (; cl_it != cl_it_end; ++cl_it) {
295 Identifier layId = m_idHelperSvc->layerId((*cl_it)->identify());
296 layIds.insert(layId);
297 if (m_idHelperSvc->isCsc(
id)) {
302 goodLayIds.insert(layId);
310 Identifier chId = m_idHelperSvc->chamberId(
id);
312 bool issTgc = m_idHelperSvc->issTgc(
id);
313 if (issTgc) chId = m_idHelperSvc->detElId(
id);
314 bool isFirst = isFirstProjection(
id);
315 bool isMdt = m_idHelperSvc->isMdt(
id);
319 if (!currentChamberSummary || currentChamberSummary->
m_chId != chId) {
320 if (m_calculateCloseHits && currentChamberSummary && currentChamberPars) {
322 calculateRoadHits(*currentChamberSummary, *currentChamberPars);
326 if (currentChamberSummary && !currentChamberSummary->
isMdt()) { updateHoleContent(*currentChamberSummary); }
331 currentChamberPars =
pars;
335 isFirst ? currentChamberSummary->
m_first : currentChamberSummary->
m_second;
342 double innerRadius = MuonDetMgr->getMdtReadoutElement(
id)->innerTubeRadius();
343 if (rTrack > rDrift && rTrack < innerRadius) {
351 proj.nhits += layIds.size();
352 proj.ngoodHits += goodLayIds.size();
354 if (!inBounds && isMdt)
proj.noutBounds++;
360 if (m_calculateCloseHits && currentChamberSummary && currentChamberPars) {
362 calculateRoadHits(*currentChamberSummary, *currentChamberPars);
366 if (currentChamberSummary && !currentChamberSummary->
isMdt()) { updateHoleContent(*currentChamberSummary); }
368 summary.m_muonTrackSummary.reset(muonTrackSummary);
372 if (m_idHelperSvc->issTgc(chamberHitSummary.
chamberId())) {
376 if (m_idHelperSvc->issTgc(chamberHitSummary.
chamberId()) || m_idHelperSvc->isMM(chamberHitSummary.
chamberId())) {
return; }
378 const EventContext& ctx = Gaudi::Hive::currentContext();
382 ATH_MSG_ERROR(
"Null pointer to the read MuonDetectorManager conditions object");
386 bool isCsc = m_idHelperSvc->isCsc(chamberHitSummary.
chamberId());
387 int neta = isCsc ? 4 : 2;
388 int nphi = isCsc ? 4 : 2;
389 if (m_idHelperSvc->isTgc(chamberHitSummary.
chamberId())) {
392 ATH_MSG_WARNING(
" No detector element found for " << m_idHelperSvc->toStringChamber(chamberHitSummary.
chamberId()));
406 if (nMisEta > 0 && nholes > 0) {
410 if (nMisPhi > 0 && nholes > 0) {
412 if (nholes != nMisPhi) {
414 << neta <<
" phi " << nphi <<
" hits eta "
417 << nMisEta <<
" phi " << nMisPhi <<
" holes eta " << chamberHitSummary.
etaProjection().
nholes <<
" phi "
425 const EventContext& ctx = Gaudi::Hive::currentContext();
426 bool isStraightLine =
false;
427 if (
pars.parameters().rows() < 5) {
428 isStraightLine =
true;
429 }
else if (std::abs(
pars.parameters()[4]) < 1
e-8) {
430 isStraightLine =
true;
433 if (
pars.covariance()) {
435 if (covMat.rows() < 5) {
436 isStraightLine =
true;
439 if (std::abs(covMat(4, 4)) < 1
e-20) isStraightLine =
true;
444 if (m_extrapolator.isEnabled()) extrapolator = m_extrapolator.get();
445 if (isStraightLine && m_slExtrapolator.isEnabled()) {
446 extrapolator = m_slExtrapolator.get();
448 if (!extrapolator)
return;
453 if (!chamberHitSummary.
isMdt())
return;
458 ATH_MSG_DEBUG(
" Retrieval of MdtPrepDataCollection failed!! ");
462 if (isStraightLine) {
463 ATH_MSG_VERBOSE(
"Doing straight line extrapolation to get hits in road");
465 ATH_MSG_VERBOSE(
"Doing curved track extrapolation to get hits in road");
468 std::set<Identifier> addedIds;
472 for (; pit != pit_end; ++pit) {
476 bool isFirst = isFirstProjection(
id);
482 if (
pars.associatedSurface() == surf) {
485 exPars = extrapolator->extrapolateDirectly(ctx,
490 if (isStraightLine) {
491 ATH_MSG_DEBUG(
" Straight line propagation to prd " << m_idHelperSvc->toString(
id) <<
" failed");
493 ATH_MSG_DEBUG(
" Curved track propagation to prd " << m_idHelperSvc->toString(
id) <<
" failed");
504 if (addedIds.count(
id)) {
505 ATH_MSG_DEBUG(
" same tube hit, not adding to close hits in road");
508 if (std::abs(
distance) < m_roadWidth) {
509 ATH_MSG_VERBOSE(
"Hit ID within road: " << m_idHelperSvc->toString(
id) <<
" distance " <<
distance <<
" < " << m_roadWidth);
514 <<
" >= " << m_roadWidth);
519 if (exPars != &
pars)
delete exPars;
528 <<
", setting = 0. (nhits in first projection = "
535 <<
", setting = 0. (nhits in second projection = "
542 if (!m_idHelperSvc->isMdt(
id)) {
return !m_idHelperSvc->measuresPhi(
id); }
543 return m_idHelperSvc->mdtIdHelper().multilayer(
id) == 1;
547 const EventContext& ctx = Gaudi::Hive::currentContext();
550 if (!mdtPrdContainer.
isValid()) {
560 IdentifierHash hash_id;
561 m_idHelperSvc->mdtIdHelper().get_module_hash(chId, hash_id);
563 const auto *coll = mdtPrdContainer->
indexFindPtr(hash_id);
564 if (coll ==
nullptr) {
565 ATH_MSG_DEBUG(
" MdtPrepDataCollection for: " << m_idHelperSvc->toStringChamber(chId) <<
" not found in container ");