diff --git a/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonGeoModelR4/src/sTgcReadoutGeomTool.cxx b/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonGeoModelR4/src/sTgcReadoutGeomTool.cxx index 3608df468a913119c06e71d473c7b0b460d93600..166b7f9c6945ddde08dc39089043ab37c7c974c4 100644 --- a/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonGeoModelR4/src/sTgcReadoutGeomTool.cxx +++ b/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonGeoModelR4/src/sTgcReadoutGeomTool.cxx @@ -291,7 +291,7 @@ StatusCode sTgcReadoutGeomTool::readParameterBook(FactoryCache& cache) { parBook.lFrameWidth = record->getDouble("ylFrame"); parBook.sFrameWidth = record->getDouble("ysFrame"); - ATH_MSG_ALWAYS("Parameters of the chamber " << key << " are: " + ATH_MSG_VERBOSE("Parameters of the chamber " << key << " are: " << " numStrips: " << parBook.numStrips << " stripPitch: " << parBook.stripPitch << " stripWidth: " << parBook.stripWidth diff --git a/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonGeoModelTestR4/src/NSWGeoPlottingAlg.cxx b/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonGeoModelTestR4/src/NSWGeoPlottingAlg.cxx index 1401de17f941105e42a4930a66c4d78764c7bb49..286d55cfef6d4e24bb4e70774b4591e2f203740c 100644 --- a/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonGeoModelTestR4/src/NSWGeoPlottingAlg.cxx +++ b/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonGeoModelTestR4/src/NSWGeoPlottingAlg.cxx @@ -15,6 +15,9 @@ #include "TH2I.h" +using chType = sTgcIdHelper::sTgcChannelTypes; + + namespace MuonGMR4 { NswGeoPlottingAlg::NswGeoPlottingAlg(const std::string& name, ISvcLocator* pSvcLocator) @@ -25,12 +28,12 @@ StatusCode NswGeoPlottingAlg::initialize() { ATH_CHECK(m_geoCtxKey.initialize()); ATH_CHECK(m_idHelperSvc.retrieve()); ATH_CHECK(detStore()->retrieve(m_detMgr)); - ATH_CHECK(initMicroMega()); + ATH_MSG_INFO("Check Acts surface "<<m_testActsSurf); + ATH_CHECK(initMm()); + ATH_CHECK(initStgc()); return StatusCode::SUCCESS; } StatusCode NswGeoPlottingAlg::execute() { - if (m_alg_run) - return StatusCode::SUCCESS; const EventContext& ctx = Gaudi::Hive::currentContext(); SG::ReadHandle<ActsGeometryContext> gctxHandle{m_geoCtxKey, ctx}; ATH_CHECK(gctxHandle.isPresent()); @@ -40,35 +43,95 @@ StatusCode NswGeoPlottingAlg::execute() { for (int gasGap = 1; gasGap <= 4; ++ gasGap) { const IdentifierHash hash = MmReadoutElement::createHash(gasGap, (mm->stationEta() > 0 ? 1 : 2) + 10 * mm->multilayer()); - auto& histo = m_nswActiveAreas[hash]; + auto histo = m_mmActiveAreas[hash]; const StripDesign& design{mm->stripLayer(hash).design()}; + const Acts::Surface& plane{mm->surface(mm->layerHash(hash))}; const double halfY = 2.*design.longHalfHeight(); const double halfX = 2.*design.halfWidth(); - for (double x = -halfX; x <= halfX; x+= 0.25*Gaudi::Units::mm){ - for (double y = -halfY; y<= halfY; y+=0.25*Gaudi::Units::mm) { - Amg::Vector3D locPos{x,y,0}; - if (!design.insideTrapezoid(locPos.block<2,1>(0,0))) continue; - const Amg::Vector3D globPos = mm->localToGlobalTrans(*gctxHandle, mm->layerHash(hash)) * locPos; + for (double x = -halfX; x <= halfX; x+= 1.*Gaudi::Units::mm){ + for (double y = -halfY; y<= halfY; y+=1.*Gaudi::Units::mm) { + const Amg::Vector3D locPos{x,y,0}; + if (!m_testActsSurf && !design.insideTrapezoid(locPos.block<2,1>(0,0))) { + continue; + } else if (m_testActsSurf && !plane.insideBounds(locPos.block<2,1>(0,0))) { + continue; + } + + const Amg::Vector3D globPos = plane.transform(gctxHandle->context()) * locPos; histo->Fill(globPos.x(), globPos.y()); } } + } + } + std::vector<const sTgcReadoutElement*> sTgcs = m_detMgr->getAllsTgcReadoutElements(); + for (const sTgcReadoutElement* sTgc : sTgcs) { + for (int chanType : {chType::Strip, chType::Pad, chType::Wire}){ + for (int gasGap = 1; gasGap <= 4; ++ gasGap) { + const IdentifierHash hash = sTgcReadoutElement::createHash(gasGap, chanType, (sTgc->stationEta() > 0 ? 1 : 2) + + 10 * sTgc->multilayer()); + auto histo = m_stgcActiveAreas[hash]; + + const StripDesign& design{ chanType == chType::Strip? sTgc->stripDesign(hash) : + chanType == chType::Wire ? static_cast<const StripDesign&>(sTgc->wireDesign(hash)) + : static_cast<const StripDesign&>(sTgc->padDesign(hash))}; + const Acts::Surface& plane{sTgc->surface(sTgc->layerHash(hash))}; + const double halfY = 2.*design.longHalfHeight(); + const double halfX = 2.*design.halfWidth(); + for (double x = -halfX; x <= halfX; x+= 1.*Gaudi::Units::mm){ + for (double y = -halfY; y<= halfY; y+=1.*Gaudi::Units::mm) { + const Amg::Vector3D locPos{x,y,0}; + if (!m_testActsSurf && !design.insideTrapezoid(locPos.block<2,1>(0,0))) { + continue; + } else if (m_testActsSurf && !plane.insideBounds(locPos.block<2,1>(0,0))) { + continue; + } + + const Amg::Vector3D globPos = plane.transform(gctxHandle->context()) * locPos; + histo->Fill(globPos.x(), globPos.y()); + } + } + } } } - m_alg_run = true; + + + + return StatusCode::SUCCESS; } -StatusCode NswGeoPlottingAlg::initMicroMega() { +StatusCode NswGeoPlottingAlg::initStgc() { + for (unsigned int ml =1 ; ml <= 2; ++ml) { + for(unsigned int active =1 ; active <= 2; ++active){ + for (int chanType : {chType::Strip, chType::Pad, chType::Wire}){ + for (unsigned int gasGap =1; gasGap <= 4; ++gasGap) { + std::string histoName = "STGC_"+std::string(active == 1? "A" : "C") + "M" + + std::to_string(ml) + "G" + std::to_string(gasGap) + + + (chanType == chType::Strip? "S" : + chanType == chType::Wire ? "W" : "P"); + + auto newHisto = std::make_unique<TH2I>(histoName.c_str(), + "ActiveNSW;x [mm]; y [mm]", 1000, -5001, 5001., 1000, + -5001., 5001.); + m_stgcActiveAreas[sTgcReadoutElement::createHash(gasGap, chanType, active + 10 * ml)] = newHisto.get(); + ATH_CHECK(histSvc()->regHist("/GEOMODELTESTER/ActiveSurfaces/"+ histoName,std::move(newHisto))); + } + } + } + } + return StatusCode::SUCCESS; +} +StatusCode NswGeoPlottingAlg::initMm() { for (unsigned int ml = 1; ml <= 2; ++ml) { for (unsigned int active = 1; active <= 2; ++ active) { for (unsigned int gasGap = 1; gasGap <= 4; ++gasGap) { - std::string histoName = "NSW_"+std::string(active == 1? "A" : "C") + "M" + + std::string histoName = "MM_"+std::string(active == 1? "A" : "C") + "M" + std::to_string(ml) + "G" + std::to_string(gasGap); auto newHisto = std::make_unique<TH2I>(histoName.c_str(), "ActiveNSW;x [mm]; y [mm]", 1000, -5001, 5001., 1000, -5001., 5001.); - m_nswActiveAreas[MmReadoutElement::createHash(gasGap, active + 10 * ml)] = newHisto.get(); + m_mmActiveAreas[MmReadoutElement::createHash(gasGap, active + 10 * ml)] = newHisto.get(); ATH_CHECK(histSvc()->regHist("/GEOMODELTESTER/ActiveSurfaces/"+ histoName,std::move(newHisto))); } } diff --git a/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonGeoModelTestR4/src/NSWGeoPlottingAlg.h b/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonGeoModelTestR4/src/NSWGeoPlottingAlg.h index 950f06822414b4f12f515a076dfb731bb598c0a8..29b733c5f0be2f97a8fbbc7fe948f311a307ac4a 100644 --- a/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonGeoModelTestR4/src/NSWGeoPlottingAlg.h +++ b/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonGeoModelTestR4/src/NSWGeoPlottingAlg.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-204 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration */ #ifndef MUONGEOMODELTESTR4_NSWPLOTTINGALG_H #define MUONGEOMODELTESTR4_NSWPLOTTINGALG_H @@ -27,7 +27,8 @@ class NswGeoPlottingAlg : public AthHistogramAlgorithm { private: int layerId(const Identifier& id) const; - StatusCode initMicroMega(); + StatusCode initMm(); + StatusCode initStgc(); // MuonDetectorManager from the conditions store ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc{this, "IdHelperSvc", @@ -36,10 +37,12 @@ class NswGeoPlottingAlg : public AthHistogramAlgorithm { SG::ReadHandleKey<ActsGeometryContext> m_geoCtxKey{this, "AlignmentKey", "ActsAlignment", "cond handle key"}; const MuonDetectorManager* m_detMgr{nullptr}; - Gaudi::Property<std::string> m_outFile{this, "OutFile", "NSWGeoPlots.root"}; + + Gaudi::Property<bool> m_testActsSurf{this, "TestActsSurface", true}; /// Map showing the active areas of the NSW to show the passivation - std::map<IdentifierHash, TH1*> m_nswActiveAreas{}; - bool m_alg_run{false}; + std::map<IdentifierHash, TH1*> m_mmActiveAreas{}; + std::map<IdentifierHash, TH1*> m_stgcActiveAreas{}; + }; } diff --git a/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MmReadoutElement.cxx b/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MmReadoutElement.cxx index 9c92a74736ebe6bf1dbacd682c64019836ecdabe..95646d02f9620f48083da31037e0994fced3308a 100644 --- a/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MmReadoutElement.cxx +++ b/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MmReadoutElement.cxx @@ -40,7 +40,8 @@ StatusCode MmReadoutElement::initElement() { #ifndef SIMULATIONBASE ATH_CHECK(planeSurfaceFactory(geoTransformHash(), m_pars.layerBounds->make_bounds(m_pars.halfShortWidth, m_pars.halfLongWidth, - m_pars.halfHeight))); + m_pars.halfHeight, + 90.*Gaudi::Units::deg))); #endif for (unsigned int layer = 0; layer < m_pars.layers.size(); ++layer) { IdentifierHash layHash{layer}; @@ -51,9 +52,11 @@ StatusCode MmReadoutElement::initElement() { ATH_CHECK(insertTransform<MmReadoutElement>(layHash)); #ifndef SIMULATIONBASE const StripDesign& design{m_pars.layers[layer]->design()}; + ATH_CHECK(planeSurfaceFactory(layHash, m_pars.layerBounds->make_bounds(design.shortHalfHeight(), - design.longHalfHeight(), - design.halfWidth()))); + design.longHalfHeight(), + design.halfWidth(), + 90.*Gaudi::Units::deg - design.stereoAngle()))); #endif } #ifndef SIMULATIONBASE diff --git a/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/padDesign.cxx b/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/PadDesign.cxx similarity index 100% rename from MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/padDesign.cxx rename to MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/PadDesign.cxx diff --git a/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/TgcReadoutElement.cxx b/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/TgcReadoutElement.cxx index c693be9e940b8b8846ef7dd5b441c7f2faf8d20a..0a12fdac1385ddce566c5733a8a43fdb40b56b72 100644 --- a/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/TgcReadoutElement.cxx +++ b/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/TgcReadoutElement.cxx @@ -62,7 +62,8 @@ StatusCode TgcReadoutElement::initElement() { const StripDesign& layout{wireGangLayout(gap)}; ATH_CHECK(planeSurfaceFactory(layHash, m_pars.layerBounds->make_bounds(layout.shortHalfHeight(), layout.longHalfHeight(), - layout.halfWidth()))); + layout.halfWidth(), + 90.* Gaudi::Units::deg))); #endif } if (numStrips(gap)) { @@ -70,8 +71,7 @@ StatusCode TgcReadoutElement::initElement() { ATH_CHECK(insertTransform<TgcReadoutElement>(layHash)); #ifndef SIMULATIONBASE const StripDesign& layout{stripLayout(gap)}; - /// We probably need a rotated version of these bounds. However, that's not part - /// of Acts yet + /// Strips are rotated bounds ATH_CHECK(planeSurfaceFactory(layHash, m_pars.layerBounds->make_bounds(layout.shortHalfHeight(), layout.longHalfHeight(), layout.halfWidth()))); diff --git a/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/sTgcReadoutElement.cxx b/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/sTgcReadoutElement.cxx index 061577b2d558dcdce63b480208fcdccd136712a1..9c763ae639bfad8cedb298bb8da7087cead2e96e 100644 --- a/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/sTgcReadoutElement.cxx +++ b/MuonSpectrometer/MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/sTgcReadoutElement.cxx @@ -29,6 +29,13 @@ StatusCode sTgcReadoutElement::initElement() { ATH_MSG_DEBUG("Parameter book "<<parameterBook()); ATH_CHECK(createGeoTransform()); +#ifndef SIMULATIONBASE + + ATH_CHECK(planeSurfaceFactory(geoTransformHash(), m_pars.layerBounds->make_bounds(m_pars.sHalfChamberLength, + m_pars.lHalfChamberLength, + m_pars.halfChamberHeight))); +#endif + if (m_pars.stripLayers.empty() || m_pars.wireGroupLayers.empty()) { ATH_MSG_FATAL("The readout element "<<idHelperSvc()->toStringDetEl(identify())<<" doesn't have any layers defined"); return StatusCode::FAILURE; @@ -37,17 +44,34 @@ StatusCode sTgcReadoutElement::initElement() { IdentifierHash layHash{layer}; if (gasGapNumber(m_pars.stripLayers[layer].hash()) != layHash) { ATH_MSG_FATAL("Layer "<<m_pars.stripLayers[layer]<<" has a very strange hash. Expect "<<layer); - return StatusCode::FAILURE; + return StatusCode::FAILURE; } ATH_CHECK(insertTransform<sTgcReadoutElement>(m_pars.stripLayers[layer].hash())); + +#ifndef SIMULATIONBASE + const StripDesign& design{m_pars.stripLayers[layer].design()}; + ATH_CHECK(planeSurfaceFactory(m_pars.stripLayers[layer].hash(), + m_pars.layerBounds->make_bounds(design.shortHalfHeight(), + design.longHalfHeight(), + design.halfWidth(), + 90.*Gaudi::Units::deg))); +#endif + } for (unsigned int layer = 0; layer < m_pars.wireGroupLayers.size(); ++layer) { IdentifierHash layHash{layer}; if (gasGapNumber(m_pars.wireGroupLayers[layer].hash()) != layHash) { ATH_MSG_FATAL("Layer "<<m_pars.wireGroupLayers[layer]<<" has a very strange hash. Expect "<<layer); - return StatusCode::FAILURE; + return StatusCode::FAILURE; } ATH_CHECK(insertTransform<sTgcReadoutElement>(m_pars.wireGroupLayers[layer].hash())); +#ifndef SIMULATIONBASE + const StripDesign& design{m_pars.wireGroupLayers[layer].design()}; + ATH_CHECK(planeSurfaceFactory(m_pars.wireGroupLayers[layer].hash(), + m_pars.layerBounds->make_bounds(design.shortHalfHeight(), + design.longHalfHeight(), + design.halfWidth()))); +#endif } for (unsigned int layer = 0; layer < m_pars.padLayers.size(); ++layer) { IdentifierHash layHash{layer}; @@ -56,10 +80,18 @@ StatusCode sTgcReadoutElement::initElement() { return StatusCode::FAILURE; } ATH_CHECK(insertTransform<sTgcReadoutElement>(m_pars.padLayers[layer].hash())); +#ifndef SIMULATIONBASE + const StripDesign& design{m_pars.padLayers[layer].design()}; + ATH_CHECK(planeSurfaceFactory(m_pars.padLayers[layer].hash(), + m_pars.layerBounds->make_bounds(design.shortHalfHeight(), + design.longHalfHeight(), + design.halfWidth()))); +#endif + } ActsGeometryContext gctx{}; m_gasGapPitch = (center(gctx, createHash(1, sTgcIdHelper::sTgcChannelTypes::Strip, 0)) - - center(gctx, createHash(2, sTgcIdHelper::sTgcChannelTypes::Strip, 0))).mag(); + center(gctx, createHash(2, sTgcIdHelper::sTgcChannelTypes::Strip, 0))).mag(); return StatusCode::SUCCESS; }