7 #include <GaudiKernel/SystemOfUnits.h>
13 #include <GeoModelKernel/GeoFullPhysVol.h>
14 #include <GeoModelKernel/GeoPhysVol.h>
15 #include <GeoModelKernel/GeoTrd.h>
16 #include <GeoModelKernel/GeoSimplePolygonBrep.h>
19 #include <GeoModelRead/ReadGeoModel.h>
34 sTgcReadoutGeomTool::sTgcReadoutGeomTool(
const std::string&
type,
35 const std::string&
name,
38 declareInterface<IMuonReadoutGeomTool>(
this);
43 if (shape->typeID() == GeoTrd::getClassTypeID()) {
44 const GeoTrd* trd =
static_cast<const GeoTrd*
>(shape);
45 result.longWidth = trd->getXHalfLength1();
46 result.shortWidth = trd->getXHalfLength2();
47 result.halfHeight = trd->getYHalfLength1();
48 result.thickness = trd->getZHalfLength();
49 }
else if (shape->typeID() == GeoSimplePolygonBrep::getClassTypeID()) {
50 const GeoSimplePolygonBrep* poly =
static_cast<const GeoSimplePolygonBrep*
>(shape);
51 std::vector<Amg::Vector2D> polyEdges =
m_geoUtilTool->polygonEdges(*poly);
53 if (polyEdges.size() == 4) {
57 }
else if (polyEdges.size() == 6) {
65 throw std::runtime_error(
"Invalid shape to extract sTGC parameters");
76 return StatusCode::FAILURE;
93 std::vector<physVolWithTrans> allGasGaps =
m_geoUtilTool->findAllLeafNodesByName(define.
physVol,
"sTgcGas");
94 if (allGasGaps.empty()) {
97 return StatusCode::FAILURE;
106 return StatusCode::FAILURE;
109 const wSTGCTable& paramBook{parBookItr->second};
111 define.
gasTck = paramBook.gasTck;
116 WireDesignPtr wireGroupDesign = std::make_unique<WireGroupDesign>();
122 double firstStripPos = -gapPars.
halfHeight + paramBook.firstStripPitch[
gasGap] - 0.5 * paramBook.stripPitch;
127 unsigned int numWireGroups = paramBook.numWireGroups[
gasGap];
129 double firstWirePos = paramBook.firstWirePos[
gasGap];
135 stripDesign->defineStripLayout(
Amg::Vector2D{firstStripPos, 0.},
136 paramBook.stripPitch, paramBook.stripWidth, paramBook.numStrips);
139 wireGroupDesign->defineDiamond(0.5*paramBook.sPadLength, 0.5*paramBook.lPadLength, gapPars.
halfHeight, paramBook.yCutoutCathode);
140 wireGroupDesign->flipTrapezoid();
141 wireGroupDesign->defineStripLayout(
Amg::Vector2D{firstWirePos, 0.},
145 ATH_MSG_VERBOSE(
"Created new diamond wireGroup design "<<(*wireGroupDesign));
148 padDesign->defineDiamond(0.5*paramBook.sPadLength, 0.5*paramBook.lPadLength, gapPars.
halfHeight, paramBook.yCutoutCathode);
149 padDesign->flipTrapezoid();
155 stripDesign->defineStripLayout(
Amg::Vector2D{firstStripPos, 0.},
156 paramBook.stripPitch, paramBook.stripWidth, paramBook.numStrips);
160 wireGroupDesign->defineTrapezoid(0.5*paramBook.sPadLength, 0.5*paramBook.lPadLength, gapPars.
halfHeight);
161 wireGroupDesign->flipTrapezoid();
162 wireGroupDesign->defineStripLayout(
Amg::Vector2D{firstWirePos, 0.},
169 padDesign->defineTrapezoid(0.5*paramBook.sPadLength, 0.5*paramBook.lPadLength, gapPars.
halfHeight);
170 padDesign->flipTrapezoid();
175 wireGroupDesign->declareGroup(paramBook.firstWireGroupWidth[
gasGap]);
176 for (
uint wireGr=2; wireGr<numWireGroups; wireGr++){
177 wireGroupDesign->declareGroup(paramBook.wireGroupWidth);
179 unsigned int lastWireGroup = (paramBook.numWires[
gasGap] - wireGroupDesign->nAllWires());
180 wireGroupDesign->declareGroup(lastWireGroup);
181 wireGroupDesign->defineWireCutout(paramBook.wireCutout[
gasGap]);
184 double beamlineRadius = (define.
physVol->getAbsoluteTransform() * gapVol.transform).translation().perp();
185 padDesign->defineBeamlineRadius(beamlineRadius);
187 padDesign->definePadRow(paramBook.firstPadPhiDivision[
gasGap],
188 paramBook.numPadPhi[
gasGap],
189 paramBook.anglePadPhi,
190 paramBook.PadPhiShift[
gasGap]);
191 padDesign->definePadColumn(paramBook.firstPadHeight[
gasGap],
192 paramBook.numPadEta[
gasGap],
193 paramBook.padHeight[
gasGap]);
205 stripDesign = (*factoryCache.
stripDesigns.emplace(stripDesign).first);
210 define.
stripLayers.push_back(std::move(stripLayer));
213 wireGroupDesign = (*factoryCache.
wireGroupDesigns.emplace(wireGroupDesign).first);
217 ATH_MSG_VERBOSE(
"Added new diamond wireGroup layer at "<<wireGroupLayer);
221 padDesign = (*factoryCache.
padDesigns.emplace(padDesign).first);
226 define.
padLayers.push_back(std::move(padLayer));
228 return StatusCode::SUCCESS;
236 GeoModelIO::ReadGeoModel* sqliteReader =
m_geoDbTagSvc->getSqliteReader();
238 ATH_MSG_FATAL(
"Error, the tool works exclusively from sqlite geometry inputs");
239 return StatusCode::FAILURE;
248 physNodeMap mapFPV = sqliteReader->getPublishedNodes<std::string, GeoFullPhysVol*>(
"Muon");
249 #ifndef SIMULATIONBASE
253 for (
auto& [
key,
pv] : mapFPV) {
257 std::vector<std::string> key_tokens =
tokenize(
key,
"_");
258 if (key_tokens.size() != 5 ||
259 key_tokens[0].find(
"sTGC") == std::string::npos)
263 const std::string stName = key_tokens[1][1] ==
'L' ?
"STL" :
"STS";
264 const int stEta =
atoi(key_tokens[2]);
265 const int stPhi =
atoi(key_tokens[3]);
266 const int ml =
atoi(key_tokens[4]);
269 #ifndef SIMULATIONBASE
270 define.layerBounds = layerBounds;
273 define.detElId = idHelper.channelID(stName, stEta, stPhi, ml, 1, sTgcIdHelper::sTgcChannelTypes::Strip, 1,
isValid);
276 return StatusCode::FAILURE;
280 define.chambDesign =
"sTGC_" + key_tokens[1];
281 define.alignTransform =
m_geoUtilTool->findAlignableTransform(define.physVol);
284 std::unique_ptr<sTgcReadoutElement> readoutEle = std::make_unique<sTgcReadoutElement>(std::move(define));
285 ATH_CHECK(
mgr.addsTgcReadoutElement(std::move(readoutEle)));
287 return StatusCode::SUCCESS;
293 if (paramTable->size() == 0) {
295 return StatusCode::FAILURE;
298 << paramTable->tagName() <<
"] table with "
299 << paramTable->size() <<
" records");
302 const std::string
key = record-> getString(
"WSTGC_TYPE");
304 parBook.
numStrips = record->getInt(
"nStrips");
305 parBook.
stripPitch = record->getDouble(
"stripPitch");
306 parBook.
stripWidth = record->getDouble(
"stripWidth");
313 parBook.
wirePitch = record->getDouble(
"wirePitch");
314 parBook.
wireWidth = record->getDouble(
"wireWidth");
323 parBook.
anglePadPhi = record->getDouble(
"anglePadPhi");
325 parBook.
lPadLength = record->getDouble(
"lPadWidth");
326 parBook.
sPadLength = record->getDouble(
"sPadWidth");
328 parBook.
yCutout = record->getDouble(
"yCutout");
330 parBook.
gasTck = record->getDouble(
"gasTck");
331 parBook.
lFrameWidth = record->getDouble(
"ylFrame");
332 parBook.
sFrameWidth = record->getDouble(
"ysFrame");
339 <<
" numWires: " << parBook.
numWires
356 <<
" yCutout: " << parBook.
yCutout
358 <<
" gasGapTck: " << parBook.
gasTck
362 return StatusCode::SUCCESS;