11#include <GaudiKernel/IMessageSvc.h>
26#include "Acts/Surfaces/detail/LineHelper.hpp"
30 inline std::vector<std::shared_ptr<unsigned>> matchCountVec(
unsigned n) {
31 std::vector<std::shared_ptr<unsigned>>
out{};
33 for (
unsigned p = 0;
p <
n ;++
p) {
34 out.emplace_back(std::make_shared<unsigned>(0));
43 template<
class MeasType>
54 const MeasType& meas) {
56 if constexpr(std::is_same_v<MeasType, xAOD::MdtDriftCircle>) {
64 template <
typename PrdType>
65 double sensorHalfLength(
const PrdType& prd) {
66 const auto*
re = prd.readoutElement();
67 if constexpr(std::is_same_v<PrdType, xAOD::MdtDriftCircle>) {
68 return 0.5 *
re->activeTubeLength(prd.measurementHash());
69 }
else if constexpr(std::is_same_v<PrdType, xAOD::RpcMeasurement>) {
70 return 0.5*(prd.measuresPhi() ?
re->stripPhiLength() :
re->stripEtaLength());
71 }
else if constexpr(std::is_same_v<PrdType, xAOD::TgcStrip>) {
72 return 0.5 *
re->sensorLayout(prd.layerHash())->design(prd.measuresPhi()).stripLength(prd.channelNumber());
73 }
else if constexpr(std::is_same_v<PrdType, xAOD::MMCluster>) {
74 return 0.5*
re->stripLayer(prd.layerHash()).design().stripLength(prd.channelNumber());
75 }
else if constexpr(std::is_same_v<PrdType, xAOD::sTgcMeasurement>) {
76 return 0.5*
re->stripLayer(prd.layerHash()).design().stripLength(prd.channelNumber());
85 const CovIdx covIdx) {
86 if (
m.numDimensions() == 2) {
87 const unsigned i = (covIdx != CovIdx::etaCov);
88 return m.localCovariance<2>()(i,i);
90 return m.localCovariance<1>()[0];
97bool wildcardMatch(
const std::string_view pattern,
98 const std::string_view value) {
99 std::size_t patternPos = 0;
100 std::size_t valuePos = 0;
101 std::size_t wildcardPos = std::string_view::npos;
102 std::size_t wildcardValuePos = 0;
104 while (valuePos <
value.size()) {
105 if (patternPos <
pattern.size() &&
106 pattern[patternPos] == value[valuePos]) {
109 }
else if (patternPos <
pattern.size() &&
110 pattern[patternPos] ==
'*') {
111 wildcardPos = patternPos++;
112 wildcardValuePos = valuePos;
113 }
else if (wildcardPos != std::string_view::npos) {
114 patternPos = wildcardPos + 1;
115 valuePos = ++wildcardValuePos;
121 while (patternPos <
pattern.size() &&
122 pattern[patternPos] ==
'*') {
125 return patternPos ==
pattern.size();
138 if (
techIdx != other.techIdx) {
139 return static_cast<int>(
techIdx) <
static_cast<int>(other.techIdx);
141 if (
stIdx != other.stIdx) {
142 return static_cast<int>(
stIdx) <
static_cast<int>(other.stIdx);
144 return eta < other.eta;
153 std::lock_guard guard{
m_mutex};
160 if (
sp.measuresEta() &&
sp.measuresPhi()) {
163 stats.measEta +=
sp.measuresEta();
164 stats.measPhi +=
sp.measuresPhi();
169 using KeyVal = std::pair<FieldKey, StatField>;
170 std::vector<KeyVal> sortedstats{};
171 sortedstats.reserve(
m_map.size());
173 for (
const auto & [key, stats] :
m_map){
174 sortedstats.emplace_back(std::make_pair(key, stats));
176 std::stable_sort(sortedstats.begin(), sortedstats.end(), [](
const KeyVal&
a,
const KeyVal&b) {
177 return a.second.allHits() > b.second.allHits();
179 msg<<MSG::ALWAYS<<
"###########################################################################"<<
endmsg;
180 for (
const auto & [key, stats] : sortedstats) {
183 <<
" "<<std::abs(key.eta)<<(key.eta < 0 ?
"A" :
"C")
184 <<
" "<<std::setw(8)<<stats.measEtaPhi
185 <<
" "<<std::setw(8)<<stats.measEta
186 <<
" "<<std::setw(8)<<stats.measPhi<<
endmsg;
188 msg<<MSG::ALWAYS<<
"###########################################################################"<<
endmsg;
196 m_statCounter->dumpStatisics(msgStream());
198 return StatusCode::SUCCESS;
210 m_statCounter = std::make_unique<SpacePointStatistics>(
m_idHelperSvc.get());
223 const auto chambers =
m_detMgr->getAllChambers();
237 ATH_MSG_DEBUG(
"Configured chamber-dependent bucket parameters for " <<
m_bucketParameters.size() <<
" chambers out of " << chambers.size() <<
" the rest has the following default bucket parameters: "
242 return StatusCode::SUCCESS;
248 if (etaHits.empty() || phiHits.empty()) {
253 return ((1.*etaHits.size()) / ((1.*
re->numChannels(etaHits[0]->measurementHash())))) <
m_maxOccTgcEta &&
254 ((1.*phiHits.size()) / ((1.*
re->numChannels(phiHits[0]->measurementHash())))) <
m_maxOccTgcPhi;
259 if (etaHits.empty() || phiHits.empty()) {
273template <
typename PrdType>
277 std::vector<SpacePoint>& outColl)
const {
278 if (prdsToFill.empty()) {
281 const PrdType* refMeas = prdsToFill.front();
282 bool allSpArePhi{
false};
284 const Amg::Transform3D toSectorTrans = toChamberTransform(gctx, sectorTrans, *refMeas);
286 Amg::Vector3D sensorDir{Amg::Vector3D::Zero()}, toNextSen{Amg::Vector3D::Zero()};
288 if constexpr(std::is_same_v<PrdType, xAOD::RpcMeasurement> ||
289 std::is_same_v<PrdType, xAOD::TgcStrip>) {
290 allSpArePhi = refMeas->measuresPhi();
291 const auto& stripLayout = refMeas->readoutElement()->sensorLayout(refMeas->layerHash());
292 const auto& design = stripLayout->design(allSpArePhi);
293 sensorDir = toSectorTrans.linear() * stripLayout->to3D(design.stripDir(), allSpArePhi);
294 toNextSen = toSectorTrans.linear() * stripLayout->to3D(design.stripNormal(), allSpArePhi);
297 }
else if constexpr (std::is_same_v<PrdType, xAOD::sTgcMeasurement>){
298 allSpArePhi = refMeas->channelType() == xAOD::sTgcMeasurement::sTgcChannelTypes::Wire;
299 const auto& stripLayout = refMeas->readoutElement()->stripLayer(refMeas->measurementHash());
300 const auto& design = stripLayout.design(allSpArePhi);
301 sensorDir = toSectorTrans.linear() * stripLayout.to3D(design.stripDir(), allSpArePhi);
302 toNextSen = toSectorTrans.linear() * stripLayout.to3D(design.stripNormal(), allSpArePhi);
304 sensorDir = toSectorTrans.linear().col(
Amg::y);
305 toNextSen = toSectorTrans.linear().col(
Amg::x);
307 outColl.reserve(outColl.size() + prdsToFill.size());
308 for (
const PrdType* prd: prdsToFill) {
309 SpacePoint& newSp = outColl.emplace_back(prd);
310 if constexpr (std::is_same_v<PrdType, xAOD::TgcStrip>) {
312 const auto& stripLayout = refMeas->readoutElement()->sensorLayout(refMeas->layerHash());
314 toNextSen = toSectorTrans.linear() * stripLayout->to3D(radialDesign.stripNormal(prd->channelNumber()), allSpArePhi);
315 sensorDir = toSectorTrans.linear() * stripLayout->to3D(radialDesign.stripDir(prd->channelNumber()), allSpArePhi);
318 newSp.
setPosition(toSectorTrans * prd->localMeasurementPos());
320 auto cov = Acts::filledArray<double,3>(0.);
321 if (prd->numDimensions() == 2) {
322 cov[Acts::toUnderlying(CovIdx::etaCov)] = prd->template localCovariance<2>()(0,0);
323 cov[Acts::toUnderlying(CovIdx::phiCov)] = prd->template localCovariance<2>()(1,1);
326 auto covIdx{Acts::toUnderlying(CovIdx::etaCov)},
327 lenIdx{Acts::toUnderlying(CovIdx::phiCov)};
331 cov[covIdx] = prd->template localCovariance<1>()[0];
332 cov[lenIdx] = Acts::square(sensorHalfLength(*prd));
339template <
typename ContType>
342 std::vector<EtaPhi2DHits<typename ContType::const_value_type>> hitsPerGasGap{};
343 for (
const auto& prd : viewer) {
345 <<
", hash: "<<prd->identifierHash());
347 unsigned gapIdx = prd->gasGap() -1;
348 if constexpr (std::is_same_v<ContType, xAOD::RpcMeasurementContainer>) {
349 gapIdx = prd->readoutElement()->createHash(0, prd->gasGap(), prd->doubletPhi(),
false);
351 if (hitsPerGasGap.size() <= gapIdx) {
352 hitsPerGasGap.resize(gapIdx + 1);
355 if constexpr(std::is_same_v<ContType, xAOD::sTgcMeasContainer>) {
358 }
else if constexpr(!std::is_same_v<ContType, xAOD::MMClusterContainer>) {
360 measPhi = prd->measuresPhi();
363 if (prd->numDimensions() == 2) {
364 hitsPerGasGap[gapIdx][2].push_back(prd);
368 auto& toPush = hitsPerGasGap[gapIdx][measPhi];
369 if (toPush.capacity() == toPush.size()) {
372 toPush.push_back(prd);
374 return hitsPerGasGap;
377template <
typename ContType>
381 const ContType* measurementCont{
nullptr};
383 if (!measurementCont || measurementCont->empty()){
385 return StatusCode::SUCCESS;
394 const Amg::Transform3D sectorTrans = viewer.
at(0)->readoutElement()->msSector()->globalToLocalTransform(*gctx);
396 if constexpr( std::is_same_v<ContType, xAOD::MdtDriftCircleContainer>) {
398 for (
const auto& prd : viewer) {
399 Amg::Transform3D toChamberTrans{toChamberTransform(*gctx, sectorTrans, *prd)};
401 sp.setPosition(toChamberTrans*prd->localMeasurementPos());
402 sp.setDirection(toChamberTrans.linear().col(
Amg::z),
403 toChamberTrans.linear().col(
Amg::y));
404 std::array<double, 3> cov{Acts::filledArray<double,3>(0.)};
405 cov[Acts::toUnderlying(CovIdx::etaCov)] = prd->driftRadiusCov();
406 cov[Acts::toUnderlying(CovIdx::phiCov)] = Acts::square(sensorHalfLength(*prd));
410 sp.setCovariance(std::move(cov));
416 <<
" 1D and "<<two2DHits.size()<<
" 2D hits in chamber "
428 std::vector<std::shared_ptr<unsigned>> etaCounts{matchCountVec(etaHits.size())},
429 phiCounts{matchCountVec(phiHits.size())};
431 pointsInChamb.
etaHits.reserve(pointsInChamb.
etaHits.size() + etaHits.size()*phiHits.size());
433 const auto& firstEta{etaHits.front()};
434 const Amg::Transform3D toSectorTrans = toChamberTransform(*gctx, sectorTrans, *firstEta);
436 Amg::Vector3D toNextDir{Amg::Vector3D::Zero()}, sensorDir{Amg::Vector3D::Zero()};
437 if constexpr (std::is_same_v<xAOD::RpcMeasurementContainer, ContType> ||
438 std::is_same_v<xAOD::TgcStripContainer, ContType>) {
439 const auto& stripLayout = firstEta->readoutElement()->sensorLayout(firstEta->layerHash());
440 const auto& design = stripLayout->design();
441 sensorDir = toSectorTrans.linear() * stripLayout->to3D(design.stripDir(),
false);
442 toNextDir = toSectorTrans.linear() * stripLayout->to3D(design.stripNormal(),
false);
443 }
else if constexpr (std::is_same_v<xAOD::sTgcMeasContainer, ContType>){
444 const auto& stripLayout = firstEta->readoutElement()->stripLayer(firstEta->measurementHash());
445 const auto& design = stripLayout.design(
false);
446 sensorDir = toSectorTrans.linear() * stripLayout.to3D(design.stripDir(),
false);
447 toNextDir = toSectorTrans.linear() * stripLayout.to3D(design.stripNormal(),
false);
450 return StatusCode::FAILURE;
453 using namespace Acts::detail::LineHelper;
454 for (
unsigned etaP = 0; etaP < etaHits.size(); ++etaP) {
456 for (
unsigned phiP = 0; phiP < phiHits.size(); ++ phiP) {
458 if constexpr(std::is_same_v<xAOD::TgcStripContainer, ContType>) {
459 if (!(etaHits[etaP]->bcBitMap() & phiHits[phiP]->bcBitMap())){
462 const auto& stripLay = phiHits[phiP]->readoutElement()->sensorLayout(phiHits[phiP]->layerHash());
464 toNextDir = toSectorTrans.linear() * stripLay->to3D(radialDesign.stripDir(phiHits[phiP]->channelNumber()),
true);
467 SpacePoint& newSp = pointsInChamb.
etaHits.emplace_back(etaHits[etaP], phiHits[phiP]);
470 auto spIsect = lineIntersect(toSectorTrans*etaHits[etaP]->localMeasurementPos(), sensorDir,
471 toSectorTrans*phiHits[phiP]->localMeasurementPos(), toNextDir);
474 auto cov = Acts::filledArray<double, 3>(0.);
475 cov[Acts::toUnderlying(CovIdx::etaCov)] = etaHits[etaP]->template localCovariance<1>()[0];
476 cov[Acts::toUnderlying(CovIdx::phiCov)] = phiHits[phiP]->template localCovariance<1>()[0];
478 if constexpr(std::is_same_v<xAOD::TgcStripContainer, ContType>) {
479 const auto& stripLay = phiHits[phiP]->readoutElement()->sensorLayout(phiHits[phiP]->layerHash());
481 const Amg::Vector2D planePos = stripLay->to2D(toSectorTrans.inverse()*spIsect.position(),
true);
482 cov[Acts::toUnderlying(CovIdx::phiCov)] =
483 Acts::square(radialDesign.stripPitch(phiHits[phiP]->channelNumber(), planePos)) / 12.;
492 }
while (viewer.
next());
493 return StatusCode::SUCCESS;
503 if (!measurementCont || measurementCont->
empty()){
505 return StatusCode::SUCCESS;
510 using namespace Acts::detail::LineHelper;
513 const Amg::Transform3D sectorTrans = viewer.
at(0)->readoutElement()->msSector()->globalToLocalTransform(*gctx);
514 ATH_MSG_DEBUG(__func__<<
"() "<<__LINE__<<
" - Fill space points for multiplet "<<
m_idHelperSvc->toStringDetEl(viewer.
at(0)->identify()));
516 auto& [etaHits, phiHits, two2DHits] = HitColls;
517 std::array<std::vector<std::shared_ptr<unsigned>>, 3> instanceCounts{matchCountVec(etaHits.size()),
518 matchCountVec(phiHits.size()),
519 matchCountVec(two2DHits.size())};
533 auto combineMe = [&](
const std::size_t collIdxA,
534 const std::size_t collIdxB,
537 std::vector<char> combinedFlagsA{}, combinedFlagsB{};
538 std::ranges::transform(instanceCounts[collIdxA], std::back_inserter(combinedFlagsA),
539 [](
const std::shared_ptr<unsigned>& countPtr){
540 return (*countPtr) == 0;
542 std::ranges::transform(instanceCounts[collIdxB], std::back_inserter(combinedFlagsB),
543 [](
const std::shared_ptr<unsigned>& countPtr){
544 return (*countPtr) == 0;
547 const auto& collA = HitColls[collIdxA];
548 const auto& collB = HitColls[collIdxB];
551 if(collA.empty() || collB.empty()) {
552 ATH_MSG_DEBUG(__func__<<
"() "<<__LINE__<<
" - Skipping combination: both collections empty");
558 const Amg::Transform3D toSectorTrans = toChamberTransform(*gctx, sectorTrans, *firstHit);
560 for(std::size_t idxA = 0; idxA < collA.size(); ++idxA) {
562 if(!combinedFlagsA[idxA]) {
564 <<
" has been used in previous iteration");
567 for(std::size_t idxB = 0; idxB < collB.size(); ++idxB) {
568 if(!combinedFlagsB[idxB] || !combFunc(collA[idxA], collB[idxB])){
570 <<
" has been used in previous iteration. Or is incompatible with "
575 ATH_MSG_VERBOSE(__func__<<
"() "<<__LINE__<<
" - Combine sTgc measurements "
577 <<
m_idHelperSvc->toString(collB[idxB]->identify())<<
"with local positions"
578 <<
Amg::toString(collA[idxA]->localMeasurementPos()) <<
" and "
580 <<
" to new space point");
582 SpacePoint& newSp = pointsInChamb.
etaHits.emplace_back(collB[idxB], collA[idxA]);
583 auto crossPoint = lineIntersect<3>(collA[idxA]->localMeasurementPos(),
584 Amg::Vector3D::UnitX(),
585 collB[idxB]->localMeasurementPos(),
586 Amg::Vector3D::UnitY());
588 newSp.
setPosition(toSectorTrans*crossPoint.position());
589 newSp.
setDirection(Amg::Vector3D::UnitX(), Amg::Vector3D::UnitY());
590 auto cov = Acts::filledArray<double, 3>(0.);
591 cov[Acts::toUnderlying(CovIdx::phiCov)] = covElement(*collA[idxA], CovIdx::phiCov);
592 cov[Acts::toUnderlying(CovIdx::etaCov)] = covElement(*collB[idxB], CovIdx::etaCov);
594 newSp.
setInstanceCounts(instanceCounts[collIdxB][idxB], instanceCounts[collIdxA][idxA]);
606 strip->localMeasurementPos().block<2,1>(0,0))){
612 const Acts::Surface& surf = readoutElement->
surface(
strip->layerHash());
613 return surf.insideBounds(crossPoint.block<2,1>(0,0));
622 double padHeight = padDesign.
padHeight();
625 return std::abs(
strip->localMeasurementPos().x() - padCenter.x()) < 0.5*padHeight;
634 auto [
min,
max] = std::ranges::minmax_element(localPadCorners.begin(), localPadCorners.end(),
636 return a.y() < b.y();
643 for(std::size_t collIdx = 0; collIdx < HitColls.size(); ++collIdx){
644 const auto& hits = HitColls[collIdx];
645 std::vector<const xAOD::sTgcMeasurement*> unusedHits{};
646 unusedHits.reserve(hits.size());
648 for(std::size_t idx = 0; idx < hits.size(); ++idx){
649 if((*instanceCounts[collIdx][idx]) == 0){
650 unusedHits.push_back(hits[idx]);
656 }
while (viewer.
next());
657 return StatusCode::SUCCESS;
668 std::unique_ptr<SpacePointContainer> outContainer = std::make_unique<SpacePointContainer>();
670 for (
auto &[chamber, hitsPerChamber] : preSortedContainer){
671 ATH_MSG_DEBUG(
"Fill space points for chamber "<<chamber->identString() <<
" with "<<hitsPerChamber.etaHits.size()
672 <<
" primary and "<<hitsPerChamber.phiHits.size()<<
" phi space points.");
677 ATH_MSG_DEBUG(
"Created a total of "<<outContainer->size()<<
" space points in "<<preSortedContainer.size()<<
" chambers");
681 return StatusCode::SUCCESS;
687 splittedHits.emplace_back();
689 m_statCounter->addToStat(hitsPerChamber.etaHits);
690 m_statCounter->addToStat(hitsPerChamber.phiHits);
694 splittedHits.erase(
std::remove_if(splittedHits.begin(), splittedHits.end(),
696 return bucket.size() <= 1;
697 }), splittedHits.end());
700 std::size_t nBuckets{0};
701 std::size_t nSpacePointsInBuckets{0};
702 std::size_t maxBucketSize{0};
707 if (
msgLvl(MSG::VERBOSE)){
708 std::stringstream spStr{};
709 for (
const std::shared_ptr<SpacePoint>&
sp : bucket){
710 spStr<<
"SpacePoint: PrimaryMeas: " <<(*sp)<<std::endl;
712 ATH_MSG_VERBOSE(
"Created a bucket, printing all spacepoints..."<<std::endl<<spStr.str());
717 nSpacePointsInBuckets += bucket.size();
718 maxBucketSize = std::max(maxBucketSize, bucket.size());
719 finalContainer.
push_back(std::make_unique<SpacePointBucket>(std::move(bucket)));
722 ATH_MSG_DEBUG(
"Created "<<nBuckets<<
" buckets with a total of "<<nSpacePointsInBuckets
723 <<
" space points. Max bucket size: "<<maxBucketSize);
729 auto phiPoint = std::make_shared<SpacePoint>(std::move(
sp));
730 const double dY = std::sqrt(phiPoint->covariance()[Acts::toUnderlying(CovIdx::etaCov)]);
731 const double minY = phiPoint->localPosition().y() - dY;
732 const double maxY = phiPoint->localPosition().y() + dY;
736 if (! (maxY < bucket.coveredMin() || bucket.coveredMax() < minY) ) {
737 bucket.emplace_back(phiPoint);
743 const double firstSpPos,
750 ATH_MSG_DEBUG(
"Splitting bucket based on maxLength. First space point Y=" << firstSpPos
751 <<
" current space point Y =" << spY
756 if (sortedPoints.empty() || sortedPoints.back().empty()) {
760 const double gap = spY - sortedPoints.back().back()->localPosition().y();
764 ATH_MSG_DEBUG(
"Splitting bucket based on gap. Last space point Y=" << sortedPoints.back().back()->localPosition().y()
765 <<
" current space point Y =" << spY
781 overlap.back()->localPosition().y());
787 for (
const std::shared_ptr<SpacePoint>& pointInBucket : overlap | std::views::reverse) {
788 const double overlapPos = pointInBucket->localPosition().y() +
789 std::sqrt(pointInBucket->covariance()[Acts::toUnderlying(CovIdx::etaCov)]);
791 newContainer.insert(newContainer.begin(), pointInBucket);
802 if (spacePoints.empty())
return;
805 std::ranges::sort(spacePoints,
807 return a.localPosition().y() < b.localPosition().y();
810 double firstPointPos = spacePoints.front().localPosition().y();
815 ATH_MSG_DEBUG(
"Distributing "<<spacePoints.size()<<
" primary space points into buckets with parameters: "
823 if (
splitBucket(toSort, firstPointPos, splittedHits, bucketParams)){
824 newBucket(toSort, splittedHits, bucketParams);
825 firstPointPos = splittedHits.back().empty() ? toSort.localPosition().y() : splittedHits.back().front()->localPosition().y();
826 ATH_MSG_VERBOSE(
"New bucket: id " << splittedHits.back().bucketId() <<
" Coverage: " << firstPointPos);
828 std::shared_ptr<SpacePoint> spacePoint = std::make_shared<SpacePoint>(std::move(toSort));
829 splittedHits.back().emplace_back(spacePoint);
833 lastBucket.back()->localPosition().y());
844 ATH_MSG_DEBUG(
"Resolving bucket parameters for chamber "<<chamber->identString());
856 const std::string_view chamberKey,
857 const double defaultValue,
861 if (
const auto exactItr =
patterns.find(chamberKey);
864 .value = exactItr->second,
869 double resolvedValue = defaultValue;
870 std::size_t bestSpecificity = 0;
871 bool matched =
false;
875 for (
const auto& [pattern, value] :
patterns) {
876 if (pattern.find(
'*') == std::string::npos) {
880 if (!wildcardMatch(pattern, chamberKey)) {
885 const std::size_t specificity =
886 std::ranges::count_if(pattern, [](
const char c) {
890 if (!matched || specificity > bestSpecificity) {
891 bestSpecificity = specificity;
892 resolvedValue = value;
898 .value = resolvedValue,
933 .spacePointWindow = hitWindow.
value,
934 .maxBucketLength = maxLength.
value,
935 .spacePointOverlap = overlap.
value
940 "Resolved bucket override for " << chamberKey
941 <<
": maxBucketLength=" << parameters.maxBucketLength
942 << (maxLength.
matched ?
" [override]" :
" [default]")
943 <<
", spacePointWindow=" << parameters.spacePointWindow
944 << (hitWindow.
matched ?
" [override]" :
" [default]")
945 <<
", spacePointOverlap=" << parameters.spacePointOverlap
946 << (overlap.
matched ?
" [override]" :
" [default]"));
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
const ServiceHandle< StoreGateSvc > & detStore() const
bool msgLvl(const MSG::Level lvl) const
value_type push_back(value_type pElem)
Add an element to the end of the collection.
bool empty() const noexcept
Returns true if the collection is empty.
Chamber represent the volume enclosing a muon station.
MuonReadoutElement is an abstract class representing the geometry of a muon detector.
const Acts::Surface & surface() const
Returns the surface associated with the readout element.
const Amg::Transform3D & localToGlobalTransform(const ActsTrk::GeometryContext &ctx) const override final
Returns the transformation from the local coordinate system of the readout element into the global AT...
double padHeight() const
Returns the height of all the pads that are not adjacent to the bottom edge of the trapezoid active a...
const PadDesign & padDesign(const IdentifierHash &measHash) const
Retrieves the readoutElement Layer given the Identifier/Hash.
localCornerArray localPadCorners(const IdentifierHash &measHash) const
bool isEtaZero(const IdentifierHash &measurementHash, const Amg::Vector2D &localPosition) const
: The muon space point bucket represents a collection of points that will bre processed together in t...
void setCoveredRange(double min, double max)
set the range in the precision plane covered by the bucket
void populateChamberLocations()
populate the chamber location list.
void setBucketId(unsigned int id)
sets the Identifier of the MuonSpacePointBucket in context of the associated muonChamber
SpacePointStatistics(const Muon::IMuonIdHelperSvc *idHelperSvc)
Standard constructor.
const Muon::IMuonIdHelperSvc * m_idHelperSvc
void addToStat(const std::vector< SpacePoint > &spacePoints)
Adds the vector of space points to the overall statistics.
void dumpStatisics(MsgStream &msg) const
Print the statistics table of the built space points per category into the log-file / console.
Gaudi::Property< double > m_maxOccRpcEta
BucketParameters m_defaultBucketParameters
Default bucket parameters used if no chamber-specific parameters are found, defaults into m_spacePoin...
Gaudi::Property< double > m_maxOccTgcEta
const MuonGMR4::MuonDetectorManager * m_detMgr
Gaudi::Property< double > m_maxOccTgcPhi
Gaudi::Property< double > m_spacePointWindow
Default space point window size (Max distance between the two eta hits).
Gaudi::Property< bool > m_doStat
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
std::vector< EtaPhi2DHits< T > > EtaPhi2DHitsVec
SG::ReadHandleKey< xAOD::TgcStripContainer > m_tgcKey
bool splitBucket(const SpacePoint &spacePoint, const double firstSpPos, const SpacePointBucketVec &sortedPoints, const BucketParameters &bucketParams) const
Returns whether the space point is beyond the bucket boundary.
void distributePhiPoints(std::vector< SpacePoint > &&spacePoints, SpacePointBucketVec &splittedContainer) const
Distributs the vector phi space points into the buckets.
Gaudi::Property< double > m_maxOccRpcPhi
Gaudi::Property< double > m_maxBucketLength
Default maximum bucket length (the width of the bucket in local y coordinate).
ResolvedParameter resolveParameter(const std::string_view chamberKey, const double defaultValue, const BucketPatternMap &patterns) const
Resolves a specific parameter for a given chamber key, based on the configured patterns.
SG::ReadHandleKey< xAOD::MMClusterContainer > m_mmKey
bool passOccupancy2D(const PrdVec_t< PrdType > &etaHits, const PrdVec_t< PrdType > &phiHits) const
: Check whether the occupancy cuts of hits in a gasGap are surpassed.
std::vector< SpacePointBucket > SpacePointBucketVec
Abrivation of a MuonSapcePoint bucket vector.
void fillUncombinedSpacePoints(const ActsTrk::GeometryContext &gctx, const Amg::Transform3D §orTrans, const PrdVec_t< const PrdType * > &prdsToFill, std::vector< SpacePoint > &outColl) const
Transform the uncombined space prd measurements to space points.
void newBucket(const SpacePoint &refSp, SpacePointBucketVec &sortedPoints, const BucketParameters &bucketParams) const
Closes the current processed bucket and creates a new one.
Gaudi::Property< BucketPatternMap > m_spacePointOverlapPatterns
Chamber-pattern dependent space point overlap.
SG::WriteHandleKey< SpacePointContainer > m_writeKey
StatusCode loadContainerAndSort(const EventContext &ctx, const SG::ReadHandleKey< ContType > &key, PreSortedSpacePointMap &fillContainer) const
Retrieve an uncalibrated measurement container <ContType> and fill the hits into the presorted space ...
SG::ReadHandleKey< xAOD::RpcMeasurementContainer > m_rpcKey
Gaudi::Property< double > m_spacePointOverlap
Default space point overlap (the margin around the edge of the bucket which is also coppied into anot...
StatusCode execute(const EventContext &ctx) const override
std::optional< BucketParameters > resolveBucketParameters(const MuonGMR4::Chamber &chamber) const
Resolves the bucket parameters for a given chamber, based on the chamber key and the configured patte...
std::vector< Prd_t > PrdVec_t
void distributePrimaryPoints(std::vector< SpacePoint > &&spacePoints, SpacePointBucketVec &splittedContainer) const
Distributes the vector of primary eta or eta + phi space points and fills them into the buckets.
StatusCode initialize() override
SG::ReadHandleKey< xAOD::sTgcMeasContainer > m_stgcKey
void distributePointsAndStore(SpacePointsPerChamber &&hitsPerChamber, SpacePointContainer &finalContainer) const
Distribute the premade spacepoints per chamber into their individual SpacePoint buckets.
EtaPhi2DHitsVec< typename ContType::const_value_type > splitHitsPerGasGap(xAOD::ChamberViewer< ContType > &viewer) const
Splits the chamber hits of the viewer per gas gap.
StatusCode finalize() override
########################################## SpacePointMakerAlg #######################################...
const BucketParameters & getBucketParameters(const SpacePoint &spacePoint) const
Returns the bucket parameters for a given space point.
Gaudi::Property< BucketPatternMap > m_maxBucketLengthPatterns
Chamber-pattern dependent maximum bucket length.
std::string chamberConfigKey(const MuonGMR4::Chamber &chamber) const
Returns a string key for a chamber, based on the space point identifier.
Gaudi::Property< BucketPatternMap > m_spacePointWindowPatterns
Chamber-pattern dependent space point window.
std::unordered_map< const MuonGMR4::SpectrometerSector *, SpacePointsPerChamber > PreSortedSpacePointMap
Container abrivation of the presorted space point container per MuonChambers.
Gaudi::Property< unsigned > m_capacityBucket
SG::ReadHandleKey< xAOD::MdtDriftCircleContainer > m_mdtKey
ActsTrk::GeoContextReadKey_t m_geoCtxKey
std::map< std::string, double, std::less<> > BucketPatternMap
std::unordered_map< const MuonGMR4::Chamber *, BucketParameters > m_bucketParameters
Map of bucket parameters for each chamber.
The SpacePointPerLayerSorter sort two given space points by their layer Identifier.
The muon space point is the combination of two uncalibrated measurements one of them measures the eta...
void setDirection(const Amg::Vector3D &sensorDir, const Amg::Vector3D &toNextSensor)
Setter for the direction of the measurement channel in the sector frame.
void setInstanceCounts(std::shared_ptr< unsigned > etaCounts, std::shared_ptr< unsigned > phiCounts)
Set the number of space points built with the same eta / phi prd.
const MuonGMR4::Chamber * chamber() const
: Pointer to the associated chamber
void setCovariance(Cov_t &&cov)
const Amg::Vector3D & localPosition() const
void setPosition(const Amg::Vector3D &pos)
bool measuresEta() const
: Does the space point contain an eta measurement
Interface for Helper service that creates muon Identifiers and can be used to print Identifiers.
Property holding a SG store/key/clid from which a ReadHandle is made.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
const_ref at(const std::size_t idx) const
Returns the i-the measurement from the current chamber.
std::size_t size() const noexcept
Returns how many hits are in the current chamber.
bool next()
Loads the hits from the next chamber.
const MuonGMR4::sTgcReadoutElement * readoutElement() const override final
Retrieve the associated sTgcReadoutElement.
IdentifierHash measurementHash() const override final
Returns the hash of the measurement channel w.r.t ReadoutElement.
Amg::Vector3D localMeasurementPos() const override final
Returns the local measurement position as 3-vector.
std::vector< std::string > patterns
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
This header ties the generic definitions in this package.
DataVector< SpacePointBucket > SpacePointContainer
Abrivation of the space point container type.
const std::string & stName(StIndex index)
convert StIndex into a string
const std::string & technologyName(TechnologyIndex index)
convert LayerIndex into a string
const std::string & chName(ChIndex index)
convert ChIndex into a string
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)
void stable_sort(DataModel_detail::iterator< DVL > beg, DataModel_detail::iterator< DVL > end)
Specialization of stable_sort for DataVector/List.
DataModel_detail::iterator< DVL > remove_if(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end, Predicate pred)
Specialization of remove_if for DataVector/List.
MdtTwinDriftCircle_v1 MdtTwinDriftCircle
sTgcMeasContainer_v1 sTgcMeasContainer
sTgcMeasurement_v1 sTgcMeasurement
Helper struct to define the bucket parameters for a given chamber.
Helper struct to store the resolved bucket parameters for a given chamber.
Helper struct to define the counting categories.
bool operator<(const FieldKey &other) const
################################################################ SpacePointStatistics ###############...
Helper struct to count the space-points in each detector category.
unsigned measEtaPhi
Number of space points measuring eta & phi.
unsigned measEta
Number of space points measuring eta only.
unsigned measPhi
Number of space points measuring phi only.
unsigned allHits() const
Helper method returning the sum of the three space point type counts.
: Helper struct to collect the space point per muon chamber, which are later sorted into the space po...
std::vector< SpacePoint > etaHits
Vector of all hits that contain an eta measurement including the ones which are combined with phi mea...
std::vector< SpacePoint > phiHits
Vector of all space points that are built from single phi hits.