From 2a842b553eb9f4aea62aa4302e5abeb559cceea8 Mon Sep 17 00:00:00 2001 From: Stefano Rosati <stefano.rosati@cern.ch> Date: Tue, 5 Jan 2021 14:51:14 +0100 Subject: [PATCH] updating MM RIO on traack creator for stereo clusters --- .../src/MMClusterOnTrackCreator.cxx | 117 +++++++++--------- 1 file changed, 60 insertions(+), 57 deletions(-) diff --git a/MuonSpectrometer/MuonReconstruction/MuonRIO_OnTrackCreators/MuonClusterOnTrackCreator/src/MMClusterOnTrackCreator.cxx b/MuonSpectrometer/MuonReconstruction/MuonRIO_OnTrackCreators/MuonClusterOnTrackCreator/src/MMClusterOnTrackCreator.cxx index d812bd04ffa4..6c3a634589fc 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonRIO_OnTrackCreators/MuonClusterOnTrackCreator/src/MMClusterOnTrackCreator.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonRIO_OnTrackCreators/MuonClusterOnTrackCreator/src/MMClusterOnTrackCreator.cxx @@ -27,64 +27,67 @@ StatusCode Muon::MMClusterOnTrackCreator::initialize() { const Muon::MuonClusterOnTrack* Muon::MMClusterOnTrackCreator::createRIO_OnTrack(const Trk::PrepRawData& RIO, - const Amg::Vector3D& GP) const { - MuonClusterOnTrack* MClT = nullptr; - - // check whether PrepRawData has detector element, if not there print warning - const Trk::TrkDetElementBase* EL = RIO.detectorElement(); - if ( !EL ) { - ATH_MSG_WARNING("RIO does not have associated detectorElement!, cannot produce ROT"); - return nullptr; - } - - // MuClusterOnTrack production - // - // in RIO_OnTrack the local param and cov should have the same dimension - Trk::LocalParameters locpar(RIO.localPosition()); - - if (RIO.localCovariance().cols() != RIO.localCovariance().rows()) { - ATH_MSG_FATAL("Rows and colums not equal!"); - } - - if (RIO.localCovariance().cols() > 1) { - ATH_MSG_VERBOSE("Making 2-dim local parameters: " << m_idHelperSvc->toString(RIO.identify())); - } else { - Trk::DefinedParameter radiusPar(RIO.localPosition().x(), Trk::locX); - locpar = Trk::LocalParameters(radiusPar); - ATH_MSG_VERBOSE("Making 1-dim local parameters: " << m_idHelperSvc->toString(RIO.identify())); - } - - Amg::Vector2D lp; - double positionAlongStrip = 0; - - if ( !EL->surface(RIO.identify()).globalToLocal(GP, GP, lp) ) { - Amg::Vector3D lpos = RIO.detectorElement()->surface(RIO.identify()).transform().inverse()*GP; - ATH_MSG_WARNING("Extrapolated GlobalPosition not on detector surface! Distance " << lpos.z()); - lp[Trk::locX] = lpos.x(); - lp[Trk::locY] = lpos.y(); - } - positionAlongStrip = lp[Trk::locY]; - - Amg::MatrixX loce = RIO.localCovariance(); - ATH_MSG_DEBUG("All: new err matrix is " << loce); - - - - - if ( m_idHelperSvc->isMM(RIO.identify()) ) { - // cast to MMPrepData - const MMPrepData* MClus = dynamic_cast<const MMPrepData*> (&RIO); - if (!MClus) { - ATH_MSG_WARNING("RIO not of type MMPrepData, cannot create ROT"); - return nullptr; - } - ATH_MSG_VERBOSE("generating MMClusterOnTrack in MMClusterBuilder"); - MClT = new MMClusterOnTrack(MClus, locpar, loce, positionAlongStrip); - } else { - ATH_MSG_WARNING("MMClusterOnTrackCreator called with an non MM identifier"); - } - + const Amg::Vector3D& GP) const { + + MuonClusterOnTrack* MClT = nullptr; + + if ( !m_idHelperSvc->isMM(RIO.identify()) ) { + ATH_MSG_ERROR("MMClusterOnTrackCreator called with an non MM identifier"); return MClT; + } + + + // check whether PrepRawData has detector element, if not there print warning + const Trk::TrkDetElementBase* EL = RIO.detectorElement(); + if ( !EL ) { + ATH_MSG_WARNING("RIO does not have associated detectorElement!, cannot produce ROT"); + return nullptr; + } + + // MuClusterOnTrack production + // + // in RIO_OnTrack the local param and cov should have the same dimension + Trk::LocalParameters locpar(RIO.localPosition()); + + if (RIO.localCovariance().cols() != RIO.localCovariance().rows()) { + ATH_MSG_FATAL("Rows and colums not equal!"); + } + + if (RIO.localCovariance().cols() > 1) { + ATH_MSG_VERBOSE("Making 2-dim local parameters: " << m_idHelperSvc->toString(RIO.identify())); + } else { + Trk::DefinedParameter radiusPar(RIO.localPosition().x(), Trk::locX); + locpar = Trk::LocalParameters(radiusPar); + ATH_MSG_VERBOSE("Making 1-dim local parameters: " << m_idHelperSvc->toString(RIO.identify())); + } + + Amg::Vector2D lp; + double positionAlongStrip = 0; + + if ( !EL->surface(RIO.identify()).globalToLocal(GP, GP, lp) ) { + Amg::Vector3D lpos = RIO.detectorElement()->surface(RIO.identify()).transform().inverse()*GP; + ATH_MSG_WARNING("Extrapolated GlobalPosition not on detector surface! Distance " << lpos.z()); + lp[Trk::locX] = lpos.x(); + lp[Trk::locY] = lpos.y(); + } + positionAlongStrip = lp[Trk::locY]; + + /// correct the local position based on the stereo angle + if ( m_idHelperSvc->mmIdHelper().isStereo(RIO.identify())) { + const MuonGM::MMReadoutElement* mmEL = dynamic_cast<const MuonGM::MMReadoutElement*>(EL); + double sAngle = mmEL->getDesign(RIO.identify())->sAngle; + locpar[Trk::locX] = locpar[Trk::locX]+positionAlongStrip*tan(sAngle); + } + + Amg::MatrixX loce = RIO.localCovariance(); + ATH_MSG_DEBUG("All: new err matrix is " << loce); + + // cast to MMPrepData + const MMPrepData* MClus = dynamic_cast<const MMPrepData*> (&RIO); + ATH_MSG_VERBOSE("generating MMClusterOnTrack in MMClusterBuilder"); + MClT = new MMClusterOnTrack(MClus, locpar, loce, positionAlongStrip); + + return MClT; } -- GitLab