diff --git a/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonGeoModelR4/MuonGeoModelR4/ChamberAssembleTool.h b/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonGeoModelR4/MuonGeoModelR4/ChamberAssembleTool.h index 2396cc3a8b3cfd13bd00a5aa9d7285036d7a9ae9..f29ce5a4ba7f9b1ef89bfeca0b18dc6c9ecc1335 100644 --- a/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonGeoModelR4/MuonGeoModelR4/ChamberAssembleTool.h +++ b/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonGeoModelR4/MuonGeoModelR4/ChamberAssembleTool.h @@ -28,10 +28,11 @@ class ChamberAssembleTool : public AthAlgTool, ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc{ this, "IdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; PublicToolHandle<IMuonGeoUtilityTool> m_geoUtilTool{this,"GeoUtilTool", "" }; + }; } - #endif #endif + diff --git a/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonGeoModelR4/src/ChamberAssembleTool.cxx b/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonGeoModelR4/src/ChamberAssembleTool.cxx index ed2c07bc9c39cc67c3e3f55f4bd9e479e404a2c2..2cd118ff12e12f04c56381d3124f133ba95462ce 100644 --- a/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonGeoModelR4/src/ChamberAssembleTool.cxx +++ b/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonGeoModelR4/src/ChamberAssembleTool.cxx @@ -129,10 +129,13 @@ StatusCode ChamberAssembleTool::buildReadOutElements(MuonDetectorManager &mgr) { const Amg::Transform3D axisRotation{Amg::getRotateZ3D(-90. * Gaudi::Units::deg) * Amg::getRotateY3D(-90. * Gaudi::Units::deg)}; + + constexpr double margin = 1.*Gaudi::Units::cm; for (defineArgs& candidate : muonChamberCandidates) { std::vector<Amg::Vector3D> edgePoints{}; std::vector<Identifier> reIds{}; + double minPhi{1.e6}; const Amg::Transform3D toCenter = axisRotation * candidate.readoutEles[0]->globalToLocalTrans(gctx); for (const MuonReadoutElement* re : candidate.readoutEles) { const GeoShape* readOutShape = re->getMaterialGeom()->getLogVol()->getShape(); @@ -151,7 +154,7 @@ StatusCode ChamberAssembleTool::buildReadOutElements(MuonDetectorManager &mgr) { reIds.push_back(re->identify()); } - double minX{1.e6}, minY{1.e6}, minZ{1.e6}, maxX{-1.e6}, maxY{-1.e6}, maxZ{-1.e6}; + double minX{1.e6}, minY{1.e6}, minZ{1.e6}, maxX{-1.e6}, maxY{-1.e6}, maxZ{-1.e6}, maxXNegY{-1.e6};; /// Determine the height and the width of the trapezoidal volume bounds for (const Amg::Vector3D& edge : edgePoints) { @@ -166,14 +169,48 @@ StatusCode ChamberAssembleTool::buildReadOutElements(MuonDetectorManager &mgr) { const double midY = 0.5*(minY + maxY); const double midZ = 0.5*(minZ + maxZ); - candidate.halfY = 0.5*(maxY - minY); - candidate.halfZ = 0.5*(maxZ - minZ); - - candidate.halfXShort = candidate.halfXLong = 0.5*(maxX - minX); - + const double hLengthY = 0.5 * (maxY - minY); + const double hLengthZ = 0.5 * (maxZ - minZ); candidate.centerTrans = axisRotation.inverse() * Amg::Translation3D{midX, midY, midZ}; + for (const Amg::Vector3D &edge : edgePoints) { + // translate the edges to the local frame of the chamber + const Amg::Vector2D &localedge = + (Amg::getTranslate3D(-midX, -midY, -midZ) * edge) + .block<2, 1>(0, 0); + + if (std::abs(localedge.y() + hLengthY) < 15. * Gaudi::Units::cm) { + maxXNegY = std::max(maxXNegY, localedge.x()); + } + } + + const Amg::Vector2D refEdge{maxXNegY, -hLengthY}; + + // find the minimum angle between the edge points to define the + // trapezoidal bounds of the chamber + + for (const Amg::Vector3D &edge : edgePoints) { + const Amg::Vector2D &localedge = + (Amg::getTranslate3D(-midX, -midY, -midZ) * edge) + .block<2, 1>(0, 0); + if (std::abs(localedge.y() - refEdge.y()) < 1.e-10) continue; + + if (localedge.x() > refEdge.x() || + std::abs(localedge.x() - refEdge.x()) < 1.e-10) { + double phi = std::atan2((localedge.y() - refEdge.y()), + (localedge.x() - refEdge.x())); + minPhi = std::min(minPhi, phi); + } + } + + // Define the trapezoidal bounds of the chamber + candidate.halfXShort = maxXNegY + margin; + candidate.halfY = hLengthY + margin; + candidate.halfZ = hLengthZ + margin; + candidate.halfXLong = + candidate.halfXShort + 2 * candidate.halfY / std::tan(minPhi) + margin; + if(msgLvl(MSG::VERBOSE)) { std::stringstream debugStream{}; debugStream<<"minY: "<<minY<<", maxY: "<<maxY<<", minZ: "<<minZ<<", maxZ: "<<maxZ<<" -- "; diff --git a/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonChamber.cxx b/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonChamber.cxx index 2dff8dc5b9f632d3011adf792a22ba670d4ef8e8..bd7bc1dc66ae8ec48a904cfc91292e95f530c632 100644 --- a/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonChamber.cxx +++ b/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonChamber.cxx @@ -81,7 +81,7 @@ std::shared_ptr<Acts::Volume> MuonChamber::boundingVolume(const ActsGeometryCont return std::make_shared<Acts::Volume>(localToGlobalTrans(gctx), bounds()); } std::shared_ptr<Acts::TrapezoidVolumeBounds> MuonChamber::bounds() const { - return std::make_shared<Acts::TrapezoidVolumeBounds>(halfXLong(), halfXShort(), halfY(), halfZ()); + return std::make_shared<Acts::TrapezoidVolumeBounds>(halfXShort(), halfXLong(), halfY(), halfZ()); } std::ostream& operator<<(std::ostream& ostr,