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>
18 #include <GeoModelRead/ReadGeoModel.h>
24 #ifndef SIMULATIONBASE
25 # include "Acts/Surfaces/TrapezoidBounds.hpp"
37 sTgcReadoutGeomTool::sTgcReadoutGeomTool(
const std::string&
type,
38 const std::string&
name,
44 if (shape->typeID() == GeoTrd::getClassTypeID()) {
45 const GeoTrd* trd =
static_cast<const GeoTrd*
>(shape);
46 result.longWidth = trd->getXHalfLength1();
47 result.shortWidth = trd->getXHalfLength2();
48 result.halfHeight = trd->getYHalfLength1();
49 result.thickness = trd->getZHalfLength();
50 }
else if (shape->typeID() == GeoSimplePolygonBrep::getClassTypeID()) {
51 const GeoSimplePolygonBrep*
poly =
static_cast<const GeoSimplePolygonBrep*
>(shape);
54 if (polyEdges.size() == 4) {
58 }
else if (polyEdges.size() == 6) {
66 throw std::runtime_error(
"Invalid shape to extract sTGC parameters");
77 return StatusCode::FAILURE;
94 std::vector<physVolWithTrans> allGasGaps =
m_geoUtilTool->findAllLeafNodesByName(define.
physVol,
"sTgcGas");
95 if (allGasGaps.empty()) {
98 return StatusCode::FAILURE;
107 return StatusCode::FAILURE;
110 const wSTGCTable& paramBook{parBookItr->second};
112 define.
gasTck = paramBook.gasTck;
117 WireDesignPtr wireGroupDesign = std::make_unique<WireGroupDesign>();
123 double firstStripPos = -gapPars.
halfHeight + paramBook.firstStripPitch[
gasGap] - 0.5 * paramBook.stripPitch;
128 unsigned int numWireGroups = paramBook.numWireGroups[
gasGap];
130 double firstWirePos = paramBook.firstWirePos[
gasGap];
136 stripDesign->defineStripLayout(
Amg::Vector2D{firstStripPos, 0.},
137 paramBook.stripPitch, paramBook.stripWidth, paramBook.numStrips);
140 wireGroupDesign->defineDiamond(0.5*paramBook.sPadLength, 0.5*paramBook.lPadLength, gapPars.
halfHeight, paramBook.yCutoutCathode);
141 wireGroupDesign->flipTrapezoid();
142 wireGroupDesign->defineStripLayout(
Amg::Vector2D{firstWirePos, 0.},
146 ATH_MSG_VERBOSE(
"Created new diamond wireGroup design "<<(*wireGroupDesign));
149 padDesign->defineDiamond(0.5*paramBook.sPadLength, 0.5*paramBook.lPadLength, gapPars.
halfHeight, paramBook.yCutoutCathode);
150 padDesign->flipTrapezoid();
156 stripDesign->defineStripLayout(
Amg::Vector2D{firstStripPos, 0.},
157 paramBook.stripPitch, paramBook.stripWidth, paramBook.numStrips);
161 wireGroupDesign->defineTrapezoid(0.5*paramBook.sPadLength, 0.5*paramBook.lPadLength, gapPars.
halfHeight);
162 wireGroupDesign->flipTrapezoid();
163 wireGroupDesign->defineStripLayout(
Amg::Vector2D{firstWirePos, 0.},
170 padDesign->defineTrapezoid(0.5*paramBook.sPadLength, 0.5*paramBook.lPadLength, gapPars.
halfHeight);
171 padDesign->flipTrapezoid();
176 wireGroupDesign->declareGroup(paramBook.firstWireGroupWidth[
gasGap]);
177 for (
uint wireGr=2; wireGr<numWireGroups; wireGr++){
178 wireGroupDesign->declareGroup(paramBook.wireGroupWidth);
180 unsigned int lastWireGroup = (paramBook.numWires[
gasGap] - wireGroupDesign->nAllWires());
181 wireGroupDesign->declareGroup(lastWireGroup);
182 wireGroupDesign->defineWireCutout(paramBook.wireCutout[
gasGap]);
185 double beamlineRadius = (define.
physVol->getAbsoluteTransform() * gapVol.transform).translation().perp();
186 padDesign->defineBeamlineRadius(beamlineRadius);
188 padDesign->definePadRow(paramBook.firstPadPhiDivision[
gasGap],
189 paramBook.numPadPhi[
gasGap],
190 paramBook.anglePadPhi,
191 paramBook.PadPhiShift[
gasGap]);
192 padDesign->definePadColumn(paramBook.firstPadHeight[
gasGap],
193 paramBook.numPadEta[
gasGap],
194 paramBook.padHeight[
gasGap]);
206 stripDesign = (*factoryCache.
stripDesigns.emplace(stripDesign).first);
211 define.
stripLayers.push_back(std::move(stripLayer));
214 wireGroupDesign = (*factoryCache.
wireGroupDesigns.emplace(wireGroupDesign).first);
218 ATH_MSG_VERBOSE(
"Added new diamond wireGroup layer at "<<wireGroupLayer);
222 padDesign = (*factoryCache.
padDesigns.emplace(padDesign).first);
227 define.
padLayers.push_back(std::move(padLayer));
229 return StatusCode::SUCCESS;
237 GeoModelIO::ReadGeoModel* sqliteReader =
m_geoDbTagSvc->getSqliteReader();
239 ATH_MSG_FATAL(
"Error, the tool works exclusively from sqlite geometry inputs");
240 return StatusCode::FAILURE;
249 physNodeMap mapFPV = sqliteReader->getPublishedNodes<std::string, GeoFullPhysVol*>(
"Muon");
250 #ifndef SIMULATIONBASE
254 for (
auto& [
key,
pv] : mapFPV) {
258 std::vector<std::string> key_tokens =
tokenize(
key,
"_");
259 if (key_tokens.size() != 5 ||
260 key_tokens[0].find(
"sTGC") == std::string::npos)
264 const std::string stName = key_tokens[1][1] ==
'L' ?
"STL" :
"STS";
265 const int stEta =
atoi(key_tokens[2]);
266 const int stPhi =
atoi(key_tokens[3]);
267 const int ml =
atoi(key_tokens[4]);
270 #ifndef SIMULATIONBASE
274 define.detElId = idHelper.channelID(stName, stEta, stPhi, ml, 1, sTgcIdHelper::sTgcChannelTypes::Strip, 1,
isValid);
277 return StatusCode::FAILURE;
281 define.chambDesign =
"sTGC_" + key_tokens[1];
282 define.alignTransform =
m_geoUtilTool->findAlignableTransform(define.physVol);
285 std::unique_ptr<sTgcReadoutElement> readoutEle = std::make_unique<sTgcReadoutElement>(std::move(define));
286 ATH_CHECK(
mgr.addsTgcReadoutElement(std::move(readoutEle)));
288 return StatusCode::SUCCESS;
294 if (paramTable->size() == 0) {
296 return StatusCode::FAILURE;
299 << paramTable->tagName() <<
"] table with "
300 << paramTable->size() <<
" records");
303 const std::string
key = record-> getString(
"WSTGC_TYPE");
305 parBook.
numStrips = record->getInt(
"nStrips");
306 parBook.
stripPitch = record->getDouble(
"stripPitch");
307 parBook.
stripWidth = record->getDouble(
"stripWidth");
314 parBook.
wirePitch = record->getDouble(
"wirePitch");
315 parBook.
wireWidth = record->getDouble(
"wireWidth");
324 parBook.
anglePadPhi = record->getDouble(
"anglePadPhi");
326 parBook.
lPadLength = record->getDouble(
"lPadWidth");
327 parBook.
sPadLength = record->getDouble(
"sPadWidth");
329 parBook.
yCutout = record->getDouble(
"yCutout");
331 parBook.
gasTck = record->getDouble(
"gasTck");
332 parBook.
lFrameWidth = record->getDouble(
"ylFrame");
333 parBook.
sFrameWidth = record->getDouble(
"ysFrame");
340 <<
" numWires: " << parBook.
numWires
357 <<
" yCutout: " << parBook.
yCutout
359 <<
" gasGapTck: " << parBook.
gasTck
363 return StatusCode::SUCCESS;