23 : base_class(
t,
n,
p) {}
35 return StatusCode::SUCCESS;
46 return StatusCode::SUCCESS;
54 using namespace MuonStationIndex;
75 RegionMap& regionMap,
bool hasPhiMeasurements )
const
77 if (hasPhiMeasurements)
78 ATH_MSG_DEBUG(
"pattern has phi measurements using extrapolation to determine second coordinate");
90 if (isect.prepRawDataVec().empty())
continue;
93 const Amg::Vector3D patdire = isect.intersectDirection().unit();
100 std::map<int, EtaPhiHits> etaPhiHitsPerChamber;
101 std::set<Identifier> clusterIds;
109 double phiStart = patdire.phi();
112 constexpr
double phiRange2 = 0.25 *
M_PI;
113 double phiOffset = 0.;
115 phiOffset = 2 *
M_PI;
116 else if (phiStart > -phiRange2 && phiStart < phiRange2)
119 if (phiOffset > 1.5 *
M_PI) {
120 if (phiStart < 0) phiStart += phiOffset;
121 if (chPhi < 0) chPhi += phiOffset;
122 }
else if (phiOffset > 0.) {
123 phiStart += phiOffset;
126 double dphi = std::abs(phiStart - chPhi);
129 ATH_MSG_DEBUG(
"Large angular phi difference between pattern and chamber, phi pattern "
135 std::map<Identifier, const MdtPrepData*> idMdtMap{};
143 if (!previousMdt || previousMdt->
tdc() > mdt->
tdc())
148 insertMdt(*mdt, regionMap, patpose, patdire, hasPhiMeasurements);
157 if (!clusterIds.insert(
id).second)
continue;
162 EtaPhiHits& hitsPerChamber = etaPhiHitsPerChamber[colHash];
164 ++hitsPerChamber.
nphi;
166 ++hitsPerChamber.
neta;
168 insertCluster(*clus, regionMap, patpose, patdire, hasPhiMeasurements);
170 for (
const auto& [coll_hash,
hits] : etaPhiHitsPerChamber) {
171 if ((
hits.neta > 0 &&
hits.nphi == 0) || (
hits.nphi > 0 &&
hits.neta == 0)) {
180 if (!clusterIds.insert(rpc_prd->identify()).second)
continue;
181 insertCluster(*rpc_prd, regionMap, patpose, patdire, hasPhiMeasurements);
191 if (!clusterIds.insert(tgc_prd->identify()).second)
continue;
192 insertCluster(*tgc_prd, regionMap, patpose, patdire, hasPhiMeasurements);
198 return StatusCode::SUCCESS;
213 if (hasPhiMeasurements) {
221 double denom = patdire.dot(planenormal);
222 double u = (planenormal.dot(planepostion - patpose)) / (
denom);
234 bool hasPointingPhiStrips =
false;
246 hasPointingPhiStrips =
true;
256 glpos[0] = ilpos.x();
258 if (hasPointingPhiStrips) {
260 glpos[1] = ilpos.y();
262 glpos[1] = ilpos.y();
271 ATH_MSG_VERBOSE(
">>>> extrapolated position far outside volume, dropping hit "
272 <<
m_idHelperSvc->toString(
id) <<
". dist along strip " << dif.mag() <<
" 1/2 strip len "
273 << 0.5 * striplen <<
" dist measurement plane " << (
intersect - piOnPlane).mag());
276 if (dif.mag() > 0.5 * striplen) {
277 Amg::Vector3D newpos = globalpos - dif * (0.5 * striplen / dif.mag());
279 ATH_MSG_VERBOSE(
">>>> extrapolated position outside volume, shifting position "
280 <<
m_idHelperSvc->toString(
id) <<
". position along strip " << dif.mag() <<
" 1/2 tube len "
281 << 0.5 * striplen <<
" dist To strip " << (
intersect - piOnPlane).mag()
282 <<
". dist to newpos " << (newpos - globalpos).mag() <<
" pos " << newpos);
294 Region& region = regionMap[regionId];
315 if (hasPhiMeasurements) {
330 double denom = patdire.dot(planenormal);
331 double u = (planenormal.dot(planepostion - patpose)) / (
denom);
334 Amg::Vector3D lpiOnPlane = amdbToGlobal.inverse() * piOnPlane;
343 if (dif.mag() > 0.5 * tubelen) {
344 Amg::Vector3D newpos = tubePos - dif * (0.5 * tubelen / dif.mag());
346 ATH_MSG_VERBOSE(
">>>> extrapolated position outside volume, shifting position "
347 <<
m_idHelperSvc->toString(
id) <<
". position along strip " << dif.mag() <<
" 1/2 tube len "
348 << 0.5 * tubelen <<
" dist To Wire " << (piOnPlane -
intersect).mag() <<
". dist to newpos "
349 << (newpos - tubePos).mag() <<
" pos " << newpos);
390 Region& region = regionMap[regionId];
405 for (
const auto& [detRegionId, chamberData] : regionMap) {
406 ATH_MSG_INFO(
"new region " << detRegionId <<
" trigger " << chamberData.triggerPrds.size() <<
" mdt ch "
407 << chamberData.mdtPrdsPerChamber.size());
408 if (!chamberData.triggerPrds.empty())
ATH_MSG_INFO(
"trigger hits " << chamberData.triggerPrds.size());
410 for (
const auto& [globalPos, prd] : chamberData.triggerPrds) {
413 for (
const auto& [statId, MdtChamHits]: chamberData.mdtPrdsPerChamber) {
414 ATH_MSG_INFO(
"new MDT chamber with " << MdtChamHits.size() <<
" hits");
415 for (
const auto& [globalPos, prd] : MdtChamHits) {
427 for (
const auto& [regionId, regMeasColl] : regionMap) {
429 ROTRegion rotRegion{};
430 rotRegion.regionId = regionId;
431 rotRegion.regionPos = regMeasColl.regionPos;
432 rotRegion.regionDir = regMeasColl.regionDir;
433 for (
const auto& [globalPos, prd] : regMeasColl.triggerPrds) {
434 std::unique_ptr<const MuonClusterOnTrack> cluster{
m_clusterCreator->createRIO_OnTrack(*prd, globalPos)};
435 if (!cluster)
continue;
436 rotRegion.push_back(std::move(cluster));
438 for (
const auto& [regionId, MdtsWithIsect] :regMeasColl.mdtPrdsPerChamber) {
441 for (
const auto& [globalPos, prd] : MdtsWithIsect) {
443 <<
",tdc: "<<prd->tdc()<<
",adc: "<<prd->adc()<<
" at "<<
Amg::toString(globalPos));
449 mdtROTs.push_back(mdt);
451 if (!mdtROTs.empty()) rotRegion.push_back(std::move(mdtROTs));
453 hitsPerRegion.push_back(std::move(rotRegion));
459 const ContType* & cont_ptr)
const {
463 return StatusCode::SUCCESS;
466 if (!readHandle.isValid()) {
468 return StatusCode::FAILURE;
470 cont_ptr = readHandle.cptr();
471 return StatusCode::SUCCESS;