7 #include <GaudiKernel/SystemOfUnits.h>
13 #include <GeoModelKernel/GeoFullPhysVol.h>
14 #include <GeoModelKernel/GeoPhysVol.h>
15 #include <GeoModelKernel/GeoTrd.h>
17 #include <GeoModelRead/ReadGeoModel.h>
22 #ifndef SIMULATIONBASE
23 # include "Acts/Utilities/BoundFactory.hpp"
40 <<std::endl<<std::endl<<m_geoUtilTool->dumpVolume(define.
physVol->getParent()));
41 const GeoShape* shape = m_geoUtilTool->extractShape(define.
physVol);
44 return StatusCode::FAILURE;
46 ATH_MSG_DEBUG(
"Extracted shape "<<m_geoUtilTool->dumpShape(shape));
48 if (shape->typeID() != GeoTrd::getClassTypeID()) {
49 ATH_MSG_FATAL(__FILE__<<
":"<<__LINE__<<
" expect shape to be a trapezoid but it's "<<m_geoUtilTool->dumpShape(shape));
50 return StatusCode::FAILURE;
53 const GeoTrd* trapezoid =
static_cast<const GeoTrd*
>(shape);
66 std::vector<physVolWithTrans> allGasGaps = m_geoUtilTool->findAllLeafNodesByName(define.
physVol,
"actMicroMegaGas");
67 if (allGasGaps.empty()) {
68 ATH_MSG_FATAL(
"The volume "<<m_idHelperSvc->toStringDetEl(define.
detElId)<<
" does not have any children actMicroMegaGas");
69 return StatusCode::FAILURE;
79 return StatusCode::FAILURE;
82 const wMMTable& paramBook{parBookItr->second};
86 for (std::size_t
gap = 0;
gap < allGasGaps.size(); ++
gap) {
88 auto& gapVol = allGasGaps[
gap];
93 ATH_MSG_DEBUG(
"quadruplet " << define.
chambDesign.substr(6,7) <<
" stereoAngle : " << paramBook.stereoAngle.at(
gap) <<
" totalStrips " << paramBook.totalActiveStrips.at(
gap) <<
" GasGAP POS X : " << posGapI.x() );
95 const GeoShape* gapShape = m_geoUtilTool->extractShape(gapVol.volume);
96 if (gapShape->typeID() != GeoTrd::getClassTypeID()) {
98 return StatusCode::FAILURE;
101 bool isStereo =
static_cast<bool>(paramBook.stereoAngle.at(
gap));
103 const GeoTrd* gapTrd =
static_cast<const GeoTrd*
>(gapShape);
104 ATH_MSG_DEBUG(
"MicroMegas Gas gap dimensions "<<m_geoUtilTool->dumpShape(gapTrd));
105 double gapHalfHeight = gapTrd->getZHalfLength();
106 double gapHalfShortY =
std::min(gapTrd->getYHalfLength1(), gapTrd->getYHalfLength2());
107 double gapHalfLongY =
std::max(gapTrd->getYHalfLength1(), gapTrd->getYHalfLength2());
109 double firstStripPos{0.};
110 int firstActiveStrip{0};
112 firstActiveStrip = paramBook.nMissedBottomStereo + 1;
113 firstStripPos = -gapHalfHeight + (1.*(firstActiveStrip - paramBook.nMissedBottomEta) -0.5)* paramBook.stripPitch;
115 firstActiveStrip = paramBook.nMissedBottomEta + 1;
116 firstStripPos = -gapHalfHeight + 0.5*paramBook.stripPitch;
123 stripDesign->defineStripLayout(firstStripPos * Amg::Vector2D::UnitX(),
124 paramBook.stripPitch,
125 paramBook.stripWidth,
126 paramBook.totalActiveStrips.at(
gap),
130 stripDesign->defineTrapezoid(gapHalfShortY, gapHalfLongY, gapHalfHeight, paramBook.stereoAngle.at(
gap));
138 stripDesign = (*factoryCache.
stripDesigns.emplace(stripDesign).first);
139 auto stripLayer = std::make_unique<StripLayer>(factoryCache.
trfNodeMaker.makeTransform(stripLayerRotation),
141 IdentifierHash{static_cast<unsigned int>(gap)});
142 define.
layers.push_back(*factoryCache.
stripLayers.emplace(std::move(stripLayer)).first);
144 return StatusCode::SUCCESS;
151 GeoModelIO::ReadGeoModel* sqliteReader = m_geoDbTagSvc->getSqliteReader();
153 ATH_MSG_FATAL(
"Error, the tool works exclusively from sqlite geometry inputs");
154 return StatusCode::FAILURE;
161 const MmIdHelper& idHelper{m_idHelperSvc->mmIdHelper()};
164 physNodeMap mapFPV = sqliteReader->getPublishedNodes<std::string, GeoFullPhysVol*>(
"Muon");
165 #ifndef SIMULATIONBASE
166 auto layerBounds= std::make_shared<Acts::SurfaceBoundFactory>();
169 for (
auto& [
key,
pv] : mapFPV) {
173 std::vector<std::string> key_tokens =
tokenize(
key,
"_");
175 if (key_tokens[0].
find(
"MM") == std::string::npos){
182 define.detElId = idHelper.channelID(key_tokens[1][0] ==
'S' ?
"MMS" :
"MML",
183 atoi(key_tokens[2].c_str()),
184 atoi(key_tokens[3].c_str()),
192 return StatusCode::FAILURE;
195 ATH_MSG_DEBUG(
"Key "<<
key<<
" brought us "<<m_idHelperSvc->toStringDetEl(define.detElId));
197 define.chambDesign = key_tokens[0]+
"_"+key_tokens[1];
198 define.alignTransform = m_geoUtilTool->findAlignableTransform(define.physVol);
199 ATH_CHECK(loadDimensions(define, facCache));
200 #ifndef SIMULATIONBASE
201 define.layerBounds = layerBounds;
203 std::unique_ptr<MmReadoutElement> readoutEle = std::make_unique<MmReadoutElement>(std::move(define));
204 ATH_CHECK(
mgr.addMmReadoutElement(std::move(readoutEle)));
206 return StatusCode::SUCCESS;
216 if (paramTable->size() == 0) {
218 return StatusCode::FAILURE;
221 << paramTable->tagName() <<
"] table with "
222 << paramTable->size() <<
" records");
227 const std::string chambType = record->getString(
"WMM_TYPE");
229 parBook.
stripPitch = record->getDouble(
"stripPitch") ;
230 parBook.
stripWidth = record->getDouble(
"stripWidth") ;
247 return StatusCode::SUCCESS;