8 #include <GaudiKernel/SystemOfUnits.h>
14 #include <GeoModelKernel/GeoFullPhysVol.h>
15 #include <GeoModelKernel/GeoPhysVol.h>
16 #include <GeoModelKernel/GeoTrd.h>
18 #include <GeoModelRead/ReadGeoModel.h>
22 #ifndef SIMULATIONBASE
23 # include "Acts/Surfaces/TrapezoidBounds.hpp"
36 MmReadoutGeomTool::MmReadoutGeomTool(
const std::string&
type,
37 const std::string&
name,
48 return StatusCode::FAILURE;
52 if (shape->typeID() != GeoTrd::getClassTypeID()) {
54 return StatusCode::FAILURE;
57 const GeoTrd* trapezoid =
static_cast<const GeoTrd*
>(shape);
70 std::vector<physVolWithTrans> allGasGaps =
m_geoUtilTool->findAllLeafNodesByName(define.
physVol,
"actMicroMegaGas");
71 if (allGasGaps.empty()) {
73 return StatusCode::FAILURE;
83 return StatusCode::FAILURE;
86 const wMMTable& paramBook{parBookItr->second};
98 std::sort(allGasGaps.begin(), allGasGaps.end(),
100 const Amg::Vector3D posGapI = gapI.transform.translation();
101 const Amg::Vector3D posGapJ = gapJ.transform.translation();
102 return posGapI.x() < posGapJ.x();
105 for (std::size_t
gap = 0;
gap < allGasGaps.size(); ++
gap) {
107 auto& gapVol = allGasGaps[
gap];
108 const Amg::Vector3D posGapI = gapVol.transform.translation();
112 ATH_MSG_DEBUG(
"quadruplet " << define.
chambDesign.substr(6,7) <<
" stereoAngle : " << paramBook.stereoAngle.at(
gap) <<
" totalStrips " << paramBook.totalActiveStrips.at(
gap) <<
" GasGAP POS X : " << posGapI.x() );
114 const GeoShape* gapShape =
m_geoUtilTool->extractShape(gapVol.volume);
115 if (gapShape->typeID() != GeoTrd::getClassTypeID()) {
117 return StatusCode::FAILURE;
120 bool isStereo =
static_cast<bool>(paramBook.stereoAngle.at(
gap));
122 const GeoTrd* gapTrd =
static_cast<const GeoTrd*
>(gapShape);
124 double gapHalfHeight = gapTrd->getZHalfLength();
125 double gapHalfShortY =
std::min(gapTrd->getYHalfLength1(), gapTrd->getYHalfLength2());
126 double gapHalfLongY =
std::max(gapTrd->getYHalfLength1(), gapTrd->getYHalfLength2());
128 double firstStripPos{0.};
129 int firstActiveStrip{0};
131 firstActiveStrip = paramBook.nMissedBottomStereo + 1;
132 firstStripPos = -gapHalfHeight + (1.*(firstActiveStrip - paramBook.nMissedTopEta) + 2.5)* paramBook.stripPitch;
134 firstActiveStrip = paramBook.nMissedBottomEta + 1;
135 firstStripPos = -gapHalfHeight + 1.5 *paramBook.stripPitch;
145 stripDesign->defineStripLayout(firstStripPos * Amg::Vector2D::UnitX(),
146 paramBook.stripPitch,
147 paramBook.stripWidth,
148 paramBook.totalActiveStrips.at(
gap),
152 stripDesign->defineTrapezoid(gapHalfShortY, gapHalfLongY, gapHalfHeight, paramBook.stereoAngle.at(
gap));
161 stripDesign = (*factoryCache.
stripDesigns.emplace(stripDesign).first);
162 auto stripLayer = std::make_unique<StripLayer>(stripLayerRotation, stripDesign,
163 IdentifierHash{
static_cast<unsigned int>(
gap)});
164 define.
layers.push_back(*factoryCache.
stripLayers.emplace(std::move(stripLayer)).first);
166 return StatusCode::SUCCESS;
173 GeoModelIO::ReadGeoModel* sqliteReader =
m_geoDbTagSvc->getSqliteReader();
175 ATH_MSG_FATAL(
"Error, the tool works exclusively from sqlite geometry inputs");
176 return StatusCode::FAILURE;
186 physNodeMap mapFPV = sqliteReader->getPublishedNodes<std::string, GeoFullPhysVol*>(
"Muon");
187 #ifndef SIMULATIONBASE
191 for (
auto& [
key,
pv] : mapFPV) {
195 std::vector<std::string> key_tokens =
tokenize(
key,
"_");
197 if (key_tokens[0].
find(
"MM") == std::string::npos){
204 define.detElId = idHelper.channelID(key_tokens[1][0] ==
'S' ?
"MMS" :
"MML",
205 atoi(key_tokens[2].c_str()),
206 atoi(key_tokens[3].c_str()),
214 return StatusCode::FAILURE;
219 define.chambDesign = key_tokens[0]+
"_"+key_tokens[1];
220 define.alignTransform =
m_geoUtilTool->findAlignableTransform(define.physVol);
222 #ifndef SIMULATIONBASE
223 define.layerBounds = layerBounds;
225 std::unique_ptr<MmReadoutElement> readoutEle = std::make_unique<MmReadoutElement>(std::move(define));
226 ATH_CHECK(
mgr.addMmReadoutElement(std::move(readoutEle)));
228 return StatusCode::SUCCESS;
238 if (paramTable->size() == 0) {
240 return StatusCode::FAILURE;
243 << paramTable->tagName() <<
"] table with "
244 << paramTable->size() <<
" records");
249 const std::string chambType = record->getString(
"WMM_TYPE");
251 parBook.
stripPitch = record->getDouble(
"stripPitch") ;
252 parBook.
stripWidth = record->getDouble(
"stripWidth") ;
269 return StatusCode::SUCCESS;