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>
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);
47 result.thickness = poly->getDZ() * Gaudi::Units::mm;
48 if (polyEdges.size() == 4) {
49 result.longWidth = 0.5 * (polyEdges[0].x() - polyEdges[1].
x()) * Gaudi::Units::mm;
50 result.shortWidth = 0.5 * (polyEdges[3].x() - polyEdges[2].
x()) * Gaudi::Units::mm;
51 result.halfHeight = 0.5 * (polyEdges[0].y() - polyEdges[3].
y()) * Gaudi::Units::mm;
52 }
else if (polyEdges.size() == 6) {
53 result.longWidth = 0.5 * (polyEdges[0].x() - polyEdges[1].
x()) * Gaudi::Units::mm;
54 result.shortWidth = 0.5 * (polyEdges[4].x() - polyEdges[3].
x()) * Gaudi::Units::mm;
55 result.halfHeight = 0.5 * (polyEdges[0].y() - polyEdges[4].
y()) * Gaudi::Units::mm;
56 result.yCutOut = (polyEdges[1].y() - polyEdges[2].
y()) * Gaudi::Units::mm;
60 throw std::runtime_error(
"Invalid shape to extract sTGC parameters");
71 return StatusCode::FAILURE;
88 std::vector<physVolWithTrans> allGasGaps =
m_geoUtilTool->findAllLeafNodesByName(define.
physVol,
"sTgcGas");
89 if (allGasGaps.empty()) {
92 return StatusCode::FAILURE;
101 return StatusCode::FAILURE;
104 const wSTGCTable& paramBook{parBookItr->second};
108 unsigned int gasGap{0};
111 WireDesignPtr wireGroupDesign = std::make_unique<WireGroupDesign>();
122 unsigned int numWireGroups = paramBook.
numWireGroups[gasGap];
130 stripDesign->defineStripLayout(
Amg::Vector2D{firstStripPos, 0.},
135 wireGroupDesign->flipTrapezoid();
136 wireGroupDesign->defineStripLayout(
Amg::Vector2D{firstWirePos, 0.},
140 ATH_MSG_VERBOSE(
"Created new diamond wireGroup design "<<(*wireGroupDesign));
144 padDesign->flipTrapezoid();
149 stripDesign->defineStripLayout(
Amg::Vector2D{firstStripPos, 0.},
155 wireGroupDesign->flipTrapezoid();
156 wireGroupDesign->defineStripLayout(
Amg::Vector2D{firstWirePos, 0.},
164 padDesign->flipTrapezoid();
170 for (
uint wireGr=2; wireGr<numWireGroups; wireGr++){
173 unsigned int lastWireGroup = (paramBook.
numWires[gasGap] - wireGroupDesign->nAllWires());
174 wireGroupDesign->declareGroup(lastWireGroup);
175 wireGroupDesign->defineWireCutout(paramBook.
wireCutout[gasGap]);
178 double beamlineRadius = (define.
physVol->getAbsoluteTransform() * gapVol.transform).translation().perp();
179 padDesign->defineBeamlineRadius(beamlineRadius);
199 stripDesign = (*factoryCache.
stripDesigns.emplace(stripDesign).first);
200 wireGroupDesign = (*factoryCache.
wireGroupDesigns.emplace(wireGroupDesign).first);
204 stripDesign, wireGroupDesign,
208 define.
stripLayers.push_back(std::move(stripLayer));
211 padDesign = (*factoryCache.
padDesigns.emplace(padDesign).first);
218 define.
padLayers.push_back(std::move(padLayer));
220 return StatusCode::SUCCESS;
228 GeoModelIO::ReadGeoModel* sqliteReader =
m_geoDbTagSvc->getSqliteReader();
230 ATH_MSG_FATAL(
"Error, the tool works exclusively from sqlite geometry inputs");
231 return StatusCode::FAILURE;
240 physNodeMap mapFPV = sqliteReader->getPublishedNodes<std::string, GeoFullPhysVol*>(
"Muon");
241#ifndef SIMULATIONBASE
242 auto layerBounds = std::make_shared<Acts::SurfaceBoundFactory>();
245 for (
auto& [key, pv] : mapFPV) {
249 std::vector<std::string> key_tokens =
tokenize(key,
"_");
250 if (key_tokens.size() != 5 ||
251 key_tokens[0].find(
"sTGC") == std::string::npos)
255 const std::string stName = key_tokens[1][1] ==
'L' ?
"STL" :
"STS";
256 const int stEta =
atoi(key_tokens[2]);
257 const int stPhi =
atoi(key_tokens[3]);
258 const int ml =
atoi(key_tokens[4]);
261#ifndef SIMULATIONBASE
267 ATH_MSG_FATAL(
"Failed to build a good identifier out of " << key);
268 return StatusCode::FAILURE;
276 std::unique_ptr<sTgcReadoutElement> readoutEle = std::make_unique<sTgcReadoutElement>(std::move(define));
277 ATH_CHECK(mgr.addsTgcReadoutElement(std::move(readoutEle)));
279 return StatusCode::SUCCESS;
285 if (paramTable->
size() == 0) {
287 return StatusCode::FAILURE;
290 << paramTable->
tagName() <<
"] table with "
291 << paramTable->
size() <<
" records");
294 const std::string key = record-> getString(
"WSTGC_TYPE");
296 parBook.
numStrips = record->getInt(
"nStrips");
297 parBook.
stripPitch = record->getDouble(
"stripPitch");
298 parBook.
stripWidth = record->getDouble(
"stripWidth");
305 parBook.
wirePitch = record->getDouble(
"wirePitch");
306 parBook.
wireWidth = record->getDouble(
"wireWidth");
315 parBook.
anglePadPhi = record->getDouble(
"anglePadPhi");
317 parBook.
lPadLength = record->getDouble(
"lPadWidth");
318 parBook.
sPadLength = record->getDouble(
"sPadWidth");
320 parBook.
yCutout = record->getDouble(
"yCutout");
322 parBook.
gasTck = record->getDouble(
"gasTck");
323 parBook.
lFrameWidth = record->getDouble(
"ylFrame");
324 parBook.
sFrameWidth = record->getDouble(
"ysFrame");
326 ATH_MSG_DEBUG(
"Parameters of the chamber " << key <<
" are: "
331 <<
" numWires: " << parBook.
numWires
348 <<
" yCutout: " << parBook.
yCutout
350 <<
" gasGapTck: " << parBook.
gasTck
354 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
Definition of the abstract IRDBAccessSvc interface.
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition of the abstract IRDBRecord interface.
Definition of the abstract IRDBRecordset interface.
std::unique_ptr< IRDBRecord > IRDBRecord_ptr
virtual std::string tagName() const =0
virtual std::string nodeName() const =0
virtual unsigned int size() const =0
The StripLayer interfaces the 2D description of the strip plane layout with the 3D description of the...
void flipPhiRotation()
Flips the phi rotation from 90 -> -90 degrees.
static IdentifierHash createHash(const unsigned gasGap, const unsigned channelType, const unsigned channel, const unsigned wireInGrp=0)
Create a measurement hash from the Identifier fields.
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channelType, int channel) const
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Amg::Transform3D getRotateZ3D(double angle)
get a rotation transformation around Z-axis
Eigen::Matrix< double, 2, 1 > Vector2D
Amg::Transform3D getRotateY3D(double angle)
get a rotation transformation around Y-axis
std::vector< int > tokenizeInt(const std::string &the_str, std::string_view delimiter)
std::vector< std::string > tokenize(const std::string &the_str, std::string_view delimiters)
Splits the string into smaller substrings.
std::vector< double > tokenizeDouble(const std::string &the_str, std::string_view delimiter)
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
The ReadoutGeomCnvAlg converts the Run4 Readout geometry build from the GeoModelXML into the legacy M...
GeoModel::TransientConstSharedPtr< WireGroupDesign > WireDesignPtr
RpcReadoutElement::defineArgs defineArgs
IMuonGeoUtilityTool::physVolWithTrans physVolWithTrans
GeoModel::TransientConstSharedPtr< StripDesign > StripDesignPtr
GeoModel::TransientConstSharedPtr< PadDesign > PadDesignPtr
Identifier detElId
ATLAS identifier.
GeoIntrusivePtr< GeoVFullPhysVol > physVol
Pointer to the underlying physical volume in GeoModel.
const GeoAlignableTransform * alignTransform
Pointer to the alignable transformation.
std::string chambDesign
chamber design name as it's occuring in the parameter book tables E.g. BMS5, RPC10,...
std::shared_ptr< Acts::SurfaceBoundFactory > layerBounds
std::vector< StripLayer > stripLayers
Associated strip & wire layers.
std::vector< StripLayer > padLayers
Associated wire & pad layers.
double yCutout
Diamond cutout height.
double halfChamberHeight
sTGC Chamber Details
double sHalfChamberLength
Length of the chamber on the short side.
unsigned numLayers
Number of gas gap layers.
double halfChamberTck
Thickness of the chamber.
std::vector< double > firstStripPitch
firstStripPitch needed for the globalChannelPosition function
double gasTck
Thickness of the gas gap.
double lHalfChamberLength
Length of the chamber on the long side.