7 #include <GaudiKernel/SystemOfUnits.h>
12 #include <GeoModelKernel/GeoFullPhysVol.h>
13 #include <GeoModelKernel/GeoPhysVol.h>
14 #include <GeoModelKernel/GeoTrd.h>
15 #include <GeoModelKernel/GeoSimplePolygonBrep.h>
17 #include <GeoModelRead/ReadGeoModel.h>
23 #ifndef SIMULATIONBASE
24 # include "Acts/Utilities/BoundFactory.hpp"
38 if (shape->typeID() == GeoTrd::getClassTypeID()) {
39 const GeoTrd* trd =
static_cast<const GeoTrd*
>(shape);
40 result.longWidth = trd->getXHalfLength1();
41 result.shortWidth = trd->getXHalfLength2();
42 result.halfHeight = trd->getYHalfLength1();
43 result.thickness = trd->getZHalfLength();
44 }
else if (shape->typeID() == GeoSimplePolygonBrep::getClassTypeID()) {
45 const GeoSimplePolygonBrep*
poly =
static_cast<const GeoSimplePolygonBrep*
>(shape);
46 std::vector<Amg::Vector2D> polyEdges = m_geoUtilTool->polygonEdges(*
poly);
48 if (polyEdges.size() == 4) {
52 }
else if (polyEdges.size() == 6) {
60 throw std::runtime_error(
"Invalid shape to extract sTGC parameters");
67 <<std::endl<<std::endl<<m_geoUtilTool->dumpVolume(define.
physVol));
68 const GeoShape* shape = m_geoUtilTool->extractShape(define.
physVol);
71 return StatusCode::FAILURE;
73 ATH_MSG_DEBUG(
"Extracted shape "<<m_geoUtilTool->dumpShape(shape));
75 sTgcShape modPars = extractParameters(shape);
88 std::vector<physVolWithTrans> allGasGaps = m_geoUtilTool->findAllLeafNodesByName(define.
physVol,
"sTgcGas");
89 if (allGasGaps.empty()) {
90 ATH_MSG_FATAL(
"The volume "<<m_idHelperSvc->toStringDetEl(define.
detElId)<<
" does not have any children 'sTgcGas'"
91 <<std::endl<<m_geoUtilTool->dumpVolume(define.
physVol));
92 return StatusCode::FAILURE;
101 return StatusCode::FAILURE;
104 const wSTGCTable& paramBook{parBookItr->second};
106 define.
gasTck = paramBook.gasTck;
111 WireDesignPtr wireGroupDesign = std::make_unique<WireGroupDesign>();
114 sTgcShape gapPars = extractParameters(m_geoUtilTool->extractShape(gapVol.volume));
117 double firstStripPos = -gapPars.
halfHeight + paramBook.firstStripPitch[
gasGap] - 0.5 * paramBook.stripPitch;
122 unsigned int numWireGroups = paramBook.numWireGroups[
gasGap];
124 double firstWirePos = paramBook.firstWirePos[
gasGap];
130 stripDesign->defineStripLayout(
Amg::Vector2D{firstStripPos, 0.},
131 paramBook.stripPitch, paramBook.stripWidth, paramBook.numStrips);
134 wireGroupDesign->defineDiamond(0.5*paramBook.sPadLength, 0.5*paramBook.lPadLength, gapPars.
halfHeight, paramBook.yCutoutCathode);
135 wireGroupDesign->flipTrapezoid();
136 wireGroupDesign->defineStripLayout(
Amg::Vector2D{firstWirePos, 0.},
140 ATH_MSG_VERBOSE(
"Created new diamond wireGroup design "<<(*wireGroupDesign));
143 padDesign->defineDiamond(0.5*paramBook.sPadLength, 0.5*paramBook.lPadLength, gapPars.
halfHeight, paramBook.yCutoutCathode);
144 padDesign->flipTrapezoid();
150 stripDesign->defineStripLayout(
Amg::Vector2D{firstStripPos, 0.},
151 paramBook.stripPitch, paramBook.stripWidth, paramBook.numStrips);
155 wireGroupDesign->defineTrapezoid(0.5*paramBook.sPadLength, 0.5*paramBook.lPadLength, gapPars.
halfHeight);
156 wireGroupDesign->flipTrapezoid();
157 wireGroupDesign->defineStripLayout(
Amg::Vector2D{firstWirePos, 0.},
164 padDesign->defineTrapezoid(0.5*paramBook.sPadLength, 0.5*paramBook.lPadLength, gapPars.
halfHeight);
165 padDesign->flipTrapezoid();
170 wireGroupDesign->declareGroup(paramBook.firstWireGroupWidth[
gasGap]);
171 for (
uint wireGr=2; wireGr<numWireGroups; wireGr++){
172 wireGroupDesign->declareGroup(paramBook.wireGroupWidth);
174 unsigned int lastWireGroup = (paramBook.numWires[
gasGap] - wireGroupDesign->nAllWires());
175 wireGroupDesign->declareGroup(lastWireGroup);
176 wireGroupDesign->defineWireCutout(paramBook.wireCutout[
gasGap]);
179 double beamlineRadius = (define.
physVol->getAbsoluteTransform() * gapVol.transform).translation().perp();
180 padDesign->defineBeamlineRadius(beamlineRadius);
182 padDesign->definePadRow(paramBook.firstPadPhiDivision[
gasGap],
183 paramBook.numPadPhi[
gasGap],
184 paramBook.anglePadPhi,
185 paramBook.PadPhiShift[
gasGap]);
186 padDesign->definePadColumn(paramBook.firstPadHeight[
gasGap],
187 paramBook.numPadEta[
gasGap],
188 paramBook.padHeight[
gasGap]);
200 stripDesign = (*factoryCache.
stripDesigns.emplace(stripDesign).first);
206 define.
stripLayers.push_back(std::move(stripLayer));
209 wireGroupDesign = (*factoryCache.
wireGroupDesigns.emplace(wireGroupDesign).first);
212 wireGroupDesign, sTgcReadoutElement::createHash(
gasGap,
214 ATH_MSG_VERBOSE(
"Added new diamond wireGroup layer at "<<wireGroupLayer);
218 padDesign = (*factoryCache.
padDesigns.emplace(padDesign).first);
221 padDesign, sTgcReadoutElement::createHash(
gasGap,
224 define.
padLayers.push_back(std::move(padLayer));
226 return StatusCode::SUCCESS;
234 GeoModelIO::ReadGeoModel* sqliteReader = m_geoDbTagSvc->getSqliteReader();
236 ATH_MSG_FATAL(
"Error, the tool works exclusively from sqlite geometry inputs");
237 return StatusCode::FAILURE;
243 const sTgcIdHelper& idHelper{m_idHelperSvc->stgcIdHelper()};
246 physNodeMap mapFPV = sqliteReader->getPublishedNodes<std::string, GeoFullPhysVol*>(
"Muon");
247 #ifndef SIMULATIONBASE
248 auto layerBounds = std::make_shared<Acts::SurfaceBoundFactory>();
251 for (
auto& [
key,
pv] : mapFPV) {
255 std::vector<std::string> key_tokens =
tokenize(
key,
"_");
256 if (key_tokens.size() != 5 ||
257 key_tokens[0].find(
"sTGC") == std::string::npos)
261 const std::string
stName = key_tokens[1][1] ==
'L' ?
"STL" :
"STS";
262 const int stEta =
atoi(key_tokens[2]);
263 const int stPhi =
atoi(key_tokens[3]);
264 const int ml =
atoi(key_tokens[4]);
267 #ifndef SIMULATIONBASE
271 define.detElId = idHelper.channelID(
stName, stEta, stPhi, ml, 1, sTgcIdHelper::sTgcChannelTypes::Strip, 1,
isValid);
274 return StatusCode::FAILURE;
278 define.chambDesign =
"sTGC_" + key_tokens[1];
279 define.alignTransform = m_geoUtilTool->findAlignableTransform(define.physVol);
280 ATH_MSG_VERBOSE(
"Key "<<
key<<
" lead to the identifier "<<m_idHelperSvc->toStringDetEl(define.detElId));
281 ATH_CHECK(loadDimensions(define, facCache));
282 std::unique_ptr<sTgcReadoutElement> readoutEle = std::make_unique<sTgcReadoutElement>(std::move(define));
283 ATH_CHECK(
mgr.addsTgcReadoutElement(std::move(readoutEle)));
285 return StatusCode::SUCCESS;
291 if (paramTable->size() == 0) {
293 return StatusCode::FAILURE;
296 << paramTable->tagName() <<
"] table with "
297 << paramTable->size() <<
" records");
300 const std::string
key = record-> getString(
"WSTGC_TYPE");
302 parBook.
numStrips = record->getInt(
"nStrips");
303 parBook.
stripPitch = record->getDouble(
"stripPitch");
304 parBook.
stripWidth = record->getDouble(
"stripWidth");
311 parBook.
wirePitch = record->getDouble(
"wirePitch");
312 parBook.
wireWidth = record->getDouble(
"wireWidth");
321 parBook.
anglePadPhi = record->getDouble(
"anglePadPhi");
323 parBook.
lPadLength = record->getDouble(
"lPadWidth");
324 parBook.
sPadLength = record->getDouble(
"sPadWidth");
326 parBook.
yCutout = record->getDouble(
"yCutout");
328 parBook.
gasTck = record->getDouble(
"gasTck");
329 parBook.
lFrameWidth = record->getDouble(
"ylFrame");
330 parBook.
sFrameWidth = record->getDouble(
"ysFrame");
337 <<
" numWires: " << parBook.
numWires
354 <<
" yCutout: " << parBook.
yCutout
356 <<
" gasGapTck: " << parBook.
gasTck
360 return StatusCode::SUCCESS;