diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/MuonClusterSegmentFinderTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/MuonClusterSegmentFinderTool.cxx index 669d7d56507475ef2744081ff2291f3debc73e5b..1a73965426b340636e6fe95ada8967c14e84d74a 100755 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/MuonClusterSegmentFinderTool.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/MuonClusterSegmentFinderTool.cxx @@ -92,7 +92,7 @@ MuonClusterSegmentFinderTool::findPrecisionSegments(std::vector<const Muon::Muon std::vector<const Muon::MuonClusterOnTrack*> rioVecPrevious; // find all clusters near the seed and try to fit for (unsigned int i = 0; i < seeds.size(); ++i) { - std::vector<const Muon::MuonClusterOnTrack*> rioVec = getClustersOnSegment(orderedClusters, seeds[i], false); + std::vector<const Muon::MuonClusterOnTrack*> rioVec = getClustersOnSegment(orderedClusters, seeds[i]); // make consistent cut if (belowThreshold(rioVec, 4)) continue; // logic to reduce combinatorics @@ -337,9 +337,8 @@ MuonClusterSegmentFinderTool::find3DSegments(std::vector<const Muon::MuonCluster seed3D = seeds[i]; } - std::vector<const Muon::MuonClusterOnTrack*> phiHits = getClustersOnSegment(orderedClusters, seed3D, true); - std::vector<const Muon::MuonClusterOnTrack*> etaHitsRedone = - getClustersOnSegment(orderedEtaClusters, seed3D, true); + std::vector<const Muon::MuonClusterOnTrack*> phiHits = getClustersOnSegment(orderedClusters, seed3D); + std::vector<const Muon::MuonClusterOnTrack*> etaHits = getClustersOnSegment(orderedEtaClusters, seed3D); if (phiHits.size() < 2) { delete startpar; continue; @@ -364,19 +363,13 @@ MuonClusterSegmentFinderTool::find3DSegments(std::vector<const Muon::MuonCluster // interleave the phi hits std::vector<const Trk::MeasurementBase*> vec2; - std::vector<const Trk::RIO_OnTrack*> etaHits; - for (unsigned int irot = 0; irot < (*sit)->numberOfContainedROTs(); irot++) { - const Trk::RIO_OnTrack* rot = dynamic_cast<const Trk::RIO_OnTrack*>((*sit)->rioOnTrack(irot)); - if (rot) etaHits.push_back(rot); - } - unsigned int netas = etaHits.size(); - ATH_MSG_DEBUG("got " << netas << " eta hits and " << etaHitsRedone.size() << " redone eta hits"); - bool useEtaHitsRedone = false; - if (etaHitsRedone.size() > netas) { - ATH_MSG_VERBOSE(" Found additional eta hits " << etaHitsRedone.size() - netas); - useEtaHitsRedone = true; - } - if (useEtaHitsRedone) netas = etaHitsRedone.size(); + /// here get the new corrected set of eta hits + std::vector< const Muon::MuonClusterOnTrack* > etaHitsCalibrated; + etaHitsCalibrated = getCalibratedClusters(etaHits,seed3D); + + unsigned int netas = etaHitsCalibrated.size(); + ATH_MSG_DEBUG("got " << netas << " eta hits " ); + if (m_ipConstraint) vec2.reserve(phiHits.size() + netas + 1); else @@ -396,22 +389,18 @@ MuonClusterSegmentFinderTool::find3DSegments(std::vector<const Muon::MuonCluster vec2.push_back(pseudoVtx); } unsigned int iEta(0), iPhi(0); - ATH_MSG_VERBOSE("There are " << (*sit)->numberOfContainedROTs() << " & " << phiHits.size() + ATH_MSG_VERBOSE("There are " << etaHitsCalibrated.size() << " & " << phiHits.size() << " eta and phi hits"); while (true) { float phiZ(999999.), etaZ(999999.); if (iPhi < phiHits.size()) phiZ = std::abs(phiHits[iPhi]->globalPosition().z()); - if (iEta < etaHits.size()) etaZ = std::abs(etaHits[iEta]->globalPosition().z()); + if (iEta < etaHitsCalibrated.size()) etaZ = std::abs(etaHitsCalibrated[iEta]->globalPosition().z()); if (phiZ < etaZ) { - vec2.push_back(phiHits[iPhi]); - iPhi++; + vec2.push_back(phiHits[iPhi]); + iPhi++; } else { - if (!useEtaHitsRedone) { - vec2.push_back(etaHits[iEta]); - } else { - vec2.push_back(etaHitsRedone[iEta]); - } - iEta++; + vec2.push_back(etaHitsCalibrated[iEta]); + iEta++; } if (iEta >= netas && iPhi >= phiHits.size()) break; } @@ -645,7 +634,7 @@ MuonClusterSegmentFinderTool::segmentSeed(std::vector<std::vector<const Muon::Mu std::vector<const Muon::MuonClusterOnTrack*> MuonClusterSegmentFinderTool::getClustersOnSegment(std::vector<std::vector<const Muon::MuonClusterOnTrack*> >& clusters, - std::pair<Amg::Vector3D, Amg::Vector3D>& seed, bool tight) const + std::pair<Amg::Vector3D, Amg::Vector3D>& seed) const { ATH_MSG_VERBOSE(" getClustersOnSegment: layers " << clusters.size()); std::vector<const Muon::MuonClusterOnTrack*> rios; @@ -661,7 +650,7 @@ MuonClusterSegmentFinderTool::getClustersOnSegment(std::vector<std::vector<const { double dist = clusterDistanceToSeed(*cit, seed); double error = Amg::error((*cit)->localCovariance(), Trk::locX); - if (!tight && m_idHelperSvc->isMM((*cit)->identify())) error += 15.; + if (m_idHelperSvc->isMM((*cit)->identify()) && m_idHelperSvc->mmIdHelper().isStereo((*cit)->identify()) ) error = 15; ATH_MSG_VERBOSE(" lay " << layer << " dist " << dist << " pull " << dist / error << " cut " << m_maxClustDist << " " << m_idHelperSvc->toString((*cit)->identify())); @@ -1053,4 +1042,49 @@ MuonClusterSegmentFinderTool::belowThreshold(std::vector<const Muon::MuonCluster return false; } + std::vector<const Muon::MuonClusterOnTrack*> + MuonClusterSegmentFinderTool::getCalibratedClusters(std::vector<const Muon::MuonClusterOnTrack*>& clusters, + std::pair<Amg::Vector3D,Amg::Vector3D>& seed) const + { + std::vector<const Muon::MuonClusterOnTrack*> calibratedClusters; + + /// loop on the segment clusters and use the phi of the seed to correct them + std::vector<const Muon::MuonClusterOnTrack*>::const_iterator cit = clusters.begin(); + + for ( ; cit != clusters.end() ; ++cit ) { + const Muon::MuonClusterOnTrack* clus = *cit; + const Muon::MuonClusterOnTrack* newClus; + /// get the intercept of the seed direction with the cluster surface + const Trk::PlaneSurface* surf = dynamic_cast<const Trk::PlaneSurface*> (&clus->associatedSurface()); + if(surf) { + Amg::Vector3D posOnSurf = intersectPlane( *surf, seed.first, seed.second ); + Amg::Vector2D lpos; + surf->globalToLocal(posOnSurf,posOnSurf,lpos); + /// correct the eta position of the MM stereo layers only, based on the + Identifier clus_id = clus->identify(); + if ( m_idHelperSvc->isMM(clus_id) ) { + if ( m_idHelperSvc->mmIdHelper().isStereo(clus_id) ) { + /// build a new MM cluster on track with correct position + newClus = m_mmClusterCreator->createRIO_OnTrack(*(clus->prepRawData()),posOnSurf); + ATH_MSG_VERBOSE("Position before correction: " << clus->globalPosition().x() << " " + << clus->globalPosition().y() << " " << clus->globalPosition().z()); + ATH_MSG_VERBOSE("Position after correction: " << newClus->globalPosition().x() << " " + << newClus->globalPosition().y() << " " << newClus->globalPosition().z()); + } + else { + /// here calibration of the MM eta strip ( all phi-dependent effects ) + newClus = clus; + } + } + else if ( m_idHelperSvc->issTgc(clus->identify()) ) { + /// if it's STGC just copy the cluster -> calibration to be added + newClus = clus; + } + } + calibratedClusters.push_back(newClus); + } + return calibratedClusters; + } + + } // namespace Muon diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/MuonClusterSegmentFinderTool.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/MuonClusterSegmentFinderTool.h index de2e5ab6e710f7adcb8a4c9f4d16117abfd359bc..e9527d0bc6c9dc858340038553e60f1d8f84bfbd 100755 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/MuonClusterSegmentFinderTool.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/MuonClusterSegmentFinderTool.h @@ -23,6 +23,7 @@ #include "TrkPseudoMeasurementOnTrack/PseudoMeasurementOnTrack.h" #include "TrkToolInterfaces/ITrackAmbiguityProcessorTool.h" #include "TrkToolInterfaces/ITrackSummaryTool.h" +#include "MuonRecToolInterfaces/IMuonClusterOnTrackCreator.h" namespace Muon { @@ -84,9 +85,15 @@ class MuonClusterSegmentFinderTool : virtual public IMuonClusterSegmentFinderToo "TrackSummaryTool", "Trk::TrackSummaryTool/MuidTrackSummaryTool", }; + ToolHandle<IMuonClusterOnTrackCreator> m_mmClusterCreator{ + this, + "MMClusterCreator", + "Muon::MMClusterOnTrackCreator/MMClusterOnTrackCreator" + }; bool m_ipConstraint; // use a ip perigee(0,0) constraint in the segment fit double m_maxClustDist; + int m_nOfSeedLayers; public: // find segments given a list of MuonCluster @@ -120,7 +127,10 @@ class MuonClusterSegmentFinderTool : virtual public IMuonClusterSegmentFinderToo // associate clusters to the segment seeds std::vector<const Muon::MuonClusterOnTrack*> getClustersOnSegment( std::vector<std::vector<const Muon::MuonClusterOnTrack*> >& clusters, - std::pair<Amg::Vector3D, Amg::Vector3D>& seed, bool tight) const; + std::pair<Amg::Vector3D, Amg::Vector3D>& seed) const; + //get the clusters after calibration + std::vector< const Muon::MuonClusterOnTrack* > getCalibratedClusters(std::vector<const Muon::MuonClusterOnTrack*>& clusters, + std::pair<Amg::Vector3D,Amg::Vector3D>& seed) const; // distance of cluster to segment seed double clusterDistanceToSeed(const Muon::MuonClusterOnTrack* clust, std::pair<Amg::Vector3D, Amg::Vector3D>& seed) const;