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>
19 #include <GeoModelRead/ReadGeoModel.h>
25 #ifndef SIMULATIONBASE
26 # include "Acts/Surfaces/TrapezoidBounds.hpp"
38 sTgcReadoutGeomTool::sTgcReadoutGeomTool(
const std::string&
type,
39 const std::string&
name,
45 if (shape->typeID() == GeoTrd::getClassTypeID()) {
46 const GeoTrd* trd =
static_cast<const GeoTrd*
>(shape);
47 result.longWidth = trd->getXHalfLength1();
48 result.shortWidth = trd->getXHalfLength2();
49 result.halfHeight = trd->getYHalfLength1();
50 result.thickness = trd->getZHalfLength();
51 }
else if (shape->typeID() == GeoSimplePolygonBrep::getClassTypeID()) {
52 const GeoSimplePolygonBrep*
poly =
static_cast<const GeoSimplePolygonBrep*
>(shape);
55 if (polyEdges.size() == 4) {
59 }
else if (polyEdges.size() == 6) {
67 throw std::runtime_error(
"Invalid shape to extract sTGC parameters");
78 return StatusCode::FAILURE;
95 std::vector<physVolWithTrans> allGasGaps =
m_geoUtilTool->findAllLeafNodesByName(define.
physVol,
"sTgcGas");
96 if (allGasGaps.empty()) {
99 return StatusCode::FAILURE;
108 return StatusCode::FAILURE;
111 const wSTGCTable& paramBook{parBookItr->second};
113 define.
gasTck = paramBook.gasTck;
118 WireDesignPtr wireGroupDesign = std::make_unique<WireGroupDesign>();
124 double firstStripPos = -gapPars.
halfHeight + paramBook.firstStripPitch[
gasGap] - 0.5 * paramBook.stripPitch;
129 unsigned int numWireGroups = paramBook.numWireGroups[
gasGap];
131 double firstWirePos = paramBook.firstWirePos[
gasGap];
137 stripDesign->defineStripLayout(
Amg::Vector2D{firstStripPos, 0.},
138 paramBook.stripPitch, paramBook.stripWidth, paramBook.numStrips);
141 wireGroupDesign->defineDiamond(0.5*paramBook.sPadLength, 0.5*paramBook.lPadLength, gapPars.
halfHeight, paramBook.yCutoutCathode);
142 wireGroupDesign->flipTrapezoid();
143 wireGroupDesign->defineStripLayout(
Amg::Vector2D{firstWirePos, 0.},
147 ATH_MSG_VERBOSE(
"Created new diamond wireGroup design "<<(*wireGroupDesign));
150 padDesign->defineDiamond(0.5*paramBook.sPadLength, 0.5*paramBook.lPadLength, gapPars.
halfHeight, paramBook.yCutoutCathode);
151 padDesign->flipTrapezoid();
157 stripDesign->defineStripLayout(
Amg::Vector2D{firstStripPos, 0.},
158 paramBook.stripPitch, paramBook.stripWidth, paramBook.numStrips);
162 wireGroupDesign->defineTrapezoid(0.5*paramBook.sPadLength, 0.5*paramBook.lPadLength, gapPars.
halfHeight);
163 wireGroupDesign->flipTrapezoid();
164 wireGroupDesign->defineStripLayout(
Amg::Vector2D{firstWirePos, 0.},
171 padDesign->defineTrapezoid(0.5*paramBook.sPadLength, 0.5*paramBook.lPadLength, gapPars.
halfHeight);
172 padDesign->flipTrapezoid();
177 wireGroupDesign->declareGroup(paramBook.firstWireGroupWidth[
gasGap]);
178 for (
uint wireGr=2; wireGr<numWireGroups; wireGr++){
179 wireGroupDesign->declareGroup(paramBook.wireGroupWidth);
181 unsigned int lastWireGroup = (paramBook.numWires[
gasGap] - wireGroupDesign->nAllWires());
182 wireGroupDesign->declareGroup(lastWireGroup);
183 wireGroupDesign->defineWireCutout(paramBook.wireCutout[
gasGap]);
186 double beamlineRadius = (define.
physVol->getAbsoluteTransform() * gapVol.transform).translation().perp();
187 padDesign->defineBeamlineRadius(beamlineRadius);
189 padDesign->definePadRow(paramBook.firstPadPhiDivision[
gasGap],
190 paramBook.numPadPhi[
gasGap],
191 paramBook.anglePadPhi,
192 paramBook.PadPhiShift[
gasGap]);
193 padDesign->definePadColumn(paramBook.firstPadHeight[
gasGap],
194 paramBook.numPadEta[
gasGap],
195 paramBook.padHeight[
gasGap]);
207 stripDesign = (*factoryCache.
stripDesigns.emplace(stripDesign).first);
212 define.
stripLayers.push_back(std::move(stripLayer));
215 wireGroupDesign = (*factoryCache.
wireGroupDesigns.emplace(wireGroupDesign).first);
219 ATH_MSG_VERBOSE(
"Added new diamond wireGroup layer at "<<wireGroupLayer);
223 padDesign = (*factoryCache.
padDesigns.emplace(padDesign).first);
228 define.
padLayers.push_back(std::move(padLayer));
230 return StatusCode::SUCCESS;
238 GeoModelIO::ReadGeoModel* sqliteReader =
m_geoDbTagSvc->getSqliteReader();
240 ATH_MSG_FATAL(
"Error, the tool works exclusively from sqlite geometry inputs");
241 return StatusCode::FAILURE;
250 physNodeMap mapFPV = sqliteReader->getPublishedNodes<std::string, GeoFullPhysVol*>(
"Muon");
251 #ifndef SIMULATIONBASE
255 for (
auto& [
key,
pv] : mapFPV) {
259 std::vector<std::string> key_tokens =
tokenize(
key,
"_");
260 if (key_tokens.size() != 5 ||
261 key_tokens[0].find(
"sTGC") == std::string::npos)
265 const std::string stName = key_tokens[1][1] ==
'L' ?
"STL" :
"STS";
266 const int stEta =
atoi(key_tokens[2]);
267 const int stPhi =
atoi(key_tokens[3]);
268 const int ml =
atoi(key_tokens[4]);
271 #ifndef SIMULATIONBASE
275 define.detElId = idHelper.channelID(stName, stEta, stPhi, ml, 1, sTgcIdHelper::sTgcChannelTypes::Strip, 1,
isValid);
278 return StatusCode::FAILURE;
282 define.chambDesign =
"sTGC_" + key_tokens[1];
283 define.alignTransform =
m_geoUtilTool->findAlignableTransform(define.physVol);
286 std::unique_ptr<sTgcReadoutElement> readoutEle = std::make_unique<sTgcReadoutElement>(std::move(define));
287 ATH_CHECK(
mgr.addsTgcReadoutElement(std::move(readoutEle)));
289 return StatusCode::SUCCESS;
295 if (paramTable->size() == 0) {
297 return StatusCode::FAILURE;
300 << paramTable->tagName() <<
"] table with "
301 << paramTable->size() <<
" records");
304 const std::string
key = record-> getString(
"WSTGC_TYPE");
306 parBook.
numStrips = record->getInt(
"nStrips");
307 parBook.
stripPitch = record->getDouble(
"stripPitch");
308 parBook.
stripWidth = record->getDouble(
"stripWidth");
315 parBook.
wirePitch = record->getDouble(
"wirePitch");
316 parBook.
wireWidth = record->getDouble(
"wireWidth");
325 parBook.
anglePadPhi = record->getDouble(
"anglePadPhi");
327 parBook.
lPadLength = record->getDouble(
"lPadWidth");
328 parBook.
sPadLength = record->getDouble(
"sPadWidth");
330 parBook.
yCutout = record->getDouble(
"yCutout");
332 parBook.
gasTck = record->getDouble(
"gasTck");
333 parBook.
lFrameWidth = record->getDouble(
"ylFrame");
334 parBook.
sFrameWidth = record->getDouble(
"ysFrame");
341 <<
" numWires: " << parBook.
numWires
358 <<
" yCutout: " << parBook.
yCutout
360 <<
" gasGapTck: " << parBook.
gasTck
364 return StatusCode::SUCCESS;