23 : base_class(
t,
n,
p) {}
35 return StatusCode::SUCCESS;
46 return StatusCode::SUCCESS;
74 RegionMap& regionMap,
bool hasPhiMeasurements )
const
76 if (hasPhiMeasurements)
77 ATH_MSG_DEBUG(
"pattern has phi measurements using extrapolation to determine second coordinate");
89 if (isect.prepRawDataVec().empty())
continue;
92 const Amg::Vector3D patdire = isect.intersectDirection().unit();
99 std::map<int, EtaPhiHits> etaPhiHitsPerChamber;
100 std::set<Identifier> clusterIds;
108 double phiStart = patdire.phi();
111 constexpr
double phiRange2 = 0.25 *
M_PI;
112 double phiOffset = 0.;
114 phiOffset = 2 *
M_PI;
115 else if (phiStart > -phiRange2 && phiStart < phiRange2)
118 if (phiOffset > 1.5 *
M_PI) {
119 if (phiStart < 0) phiStart += phiOffset;
120 if (chPhi < 0) chPhi += phiOffset;
121 }
else if (phiOffset > 0.) {
122 phiStart += phiOffset;
125 double dphi = std::abs(phiStart - chPhi);
128 ATH_MSG_DEBUG(
"Large angular phi difference between pattern and chamber, phi pattern "
134 std::map<Identifier, const MdtPrepData*> idMdtMap{};
142 if (!previousMdt || previousMdt->
tdc() > mdt->
tdc())
147 insertMdt(*mdt, regionMap, patpose, patdire, hasPhiMeasurements);
156 if (!clusterIds.insert(
id).second)
continue;
161 EtaPhiHits& hitsPerChamber = etaPhiHitsPerChamber[colHash];
163 ++hitsPerChamber.
nphi;
165 ++hitsPerChamber.
neta;
167 insertCluster(*clus, regionMap, patpose, patdire, hasPhiMeasurements);
169 for (
const auto& [coll_hash,
hits] : etaPhiHitsPerChamber) {
170 if ((
hits.neta > 0 &&
hits.nphi == 0) || (
hits.nphi > 0 &&
hits.neta == 0)) {
179 if (!clusterIds.insert(rpc_prd->identify()).second)
continue;
180 insertCluster(*rpc_prd, regionMap, patpose, patdire, hasPhiMeasurements);
190 if (!clusterIds.insert(tgc_prd->identify()).second)
continue;
191 insertCluster(*tgc_prd, regionMap, patpose, patdire, hasPhiMeasurements);
197 return StatusCode::SUCCESS;
212 if (hasPhiMeasurements) {
220 double denom = patdire.dot(planenormal);
221 double u = (planenormal.dot(planepostion - patpose)) / (
denom);
233 bool hasPointingPhiStrips =
false;
245 hasPointingPhiStrips =
true;
255 glpos[0] = ilpos.x();
257 if (hasPointingPhiStrips) {
259 glpos[1] = ilpos.y();
261 glpos[1] = ilpos.y();
270 ATH_MSG_VERBOSE(
">>>> extrapolated position far outside volume, dropping hit "
271 <<
m_idHelperSvc->toString(
id) <<
". dist along strip " << dif.mag() <<
" 1/2 strip len "
272 << 0.5 * striplen <<
" dist measurement plane " << (
intersect - piOnPlane).mag());
275 if (dif.mag() > 0.5 * striplen) {
276 Amg::Vector3D newpos = globalpos - dif * (0.5 * striplen / dif.mag());
278 ATH_MSG_VERBOSE(
">>>> extrapolated position outside volume, shifting position "
279 <<
m_idHelperSvc->toString(
id) <<
". position along strip " << dif.mag() <<
" 1/2 tube len "
280 << 0.5 * striplen <<
" dist To strip " << (
intersect - piOnPlane).mag()
281 <<
". dist to newpos " << (newpos - globalpos).mag() <<
" pos " << newpos);
293 Region& region = regionMap[regionId];
314 if (hasPhiMeasurements) {
329 double denom = patdire.dot(planenormal);
330 double u = (planenormal.dot(planepostion - patpose)) / (
denom);
333 Amg::Vector3D lpiOnPlane = amdbToGlobal.inverse() * piOnPlane;
342 if (dif.mag() > 0.5 * tubelen) {
343 Amg::Vector3D newpos = tubePos - dif * (0.5 * tubelen / dif.mag());
345 ATH_MSG_VERBOSE(
">>>> extrapolated position outside volume, shifting position "
346 <<
m_idHelperSvc->toString(
id) <<
". position along strip " << dif.mag() <<
" 1/2 tube len "
347 << 0.5 * tubelen <<
" dist To Wire " << (piOnPlane -
intersect).mag() <<
". dist to newpos "
348 << (newpos - tubePos).mag() <<
" pos " << newpos);
368 if (std::abs(eta) == 8) {
378 if (stName[2] ==
'R') {
396 Region& region = regionMap[regionId];
411 for (
const auto& [detRegionId, chamberData] : regionMap) {
412 ATH_MSG_INFO(
"new region " << detRegionId <<
" trigger " << chamberData.triggerPrds.size() <<
" mdt ch "
413 << chamberData.mdtPrdsPerChamber.size());
414 if (!chamberData.triggerPrds.empty())
ATH_MSG_INFO(
"trigger hits " << chamberData.triggerPrds.size());
416 for (
const auto& [globalPos, prd] : chamberData.triggerPrds) {
419 for (
const auto& [statId, MdtChamHits]: chamberData.mdtPrdsPerChamber) {
420 ATH_MSG_INFO(
"new MDT chamber with " << MdtChamHits.size() <<
" hits");
421 for (
const auto& [globalPos, prd] : MdtChamHits) {
433 for (
const auto& [regionId, regMeasColl] : regionMap) {
435 ROTRegion rotRegion{};
436 rotRegion.regionId = regionId;
437 rotRegion.regionPos = regMeasColl.regionPos;
438 rotRegion.regionDir = regMeasColl.regionDir;
439 for (
const auto& [globalPos, prd] : regMeasColl.triggerPrds) {
440 std::unique_ptr<const MuonClusterOnTrack> cluster{
m_clusterCreator->createRIO_OnTrack(*prd, globalPos)};
441 if (!cluster)
continue;
442 rotRegion.push_back(std::move(cluster));
444 for (
const auto& [regionId, MdtsWithIsect] :regMeasColl.mdtPrdsPerChamber) {
447 for (
const auto& [globalPos, prd] : MdtsWithIsect) {
449 <<
",tdc: "<<prd->tdc()<<
",adc: "<<prd->adc()<<
" at "<<
Amg::toString(globalPos));
455 mdtROTs.push_back(mdt);
457 if (!mdtROTs.empty()) rotRegion.push_back(std::move(mdtROTs));
459 hitsPerRegion.push_back(std::move(rotRegion));
465 const ContType* & cont_ptr)
const {
469 return StatusCode::SUCCESS;
472 if (!readHandle.isValid()) {
474 return StatusCode::FAILURE;
476 cont_ptr = readHandle.cptr();
477 return StatusCode::SUCCESS;