7#include <GaudiKernel/SystemOfUnits.h>
11#include <GeoModelKernel/GeoFullPhysVol.h>
12#include <GeoModelKernel/GeoPhysVol.h>
13#include <GeoModelKernel/GeoTrd.h>
14#include <GeoModelKernel/GeoBox.h>
16#include <GeoModelRead/ReadGeoModel.h>
27# include "Acts/Utilities/BoundFactory.hpp"
40std::unique_ptr<WireGroupDesign>
42 const GeoTrd* gapTrd)
const {
43 if (table.wireGangs.empty()) {
46 const double halfMinX = std::min(gapTrd->getYHalfLength1(), gapTrd->getYHalfLength2());
47 const double halfMaxX = std::max(gapTrd->getYHalfLength1(), gapTrd->getYHalfLength2());
48 const double halfY = gapTrd->getZHalfLength();
49 auto design = std::make_unique<WireGroupDesign>();
50 design->defineTrapezoid(halfMinX, halfMaxX,
halfY);
51 for (
unsigned gang : table.wireGangs) {
52 design->declareGroup(gang);
54 const double wireOffSet = -0.5*table.wirePitch * design->nAllWires();
56 table.wirePitch, 0., table.wireGangs.size());
59std::unique_ptr<RadialStripDesign>
61 const GeoTrd* gapTrd)
const {
62 if (table.bottomStripPos.empty()) {
65 const double halfMinX = std::min(gapTrd->getYHalfLength1(), gapTrd->getYHalfLength2());
66 const double halfMaxX = std::max(gapTrd->getYHalfLength1(), gapTrd->getYHalfLength2());
67 const double halfY = gapTrd->getZHalfLength();
69 auto design = std::make_unique<RadialStripDesign>();
71 design->defineTrapezoid(halfMinX, halfMaxX,
halfY);
73 0.,0.,table.bottomStripPos.size());
74 design->flipTrapezoid();
75 for (
size_t s = 0; s < table.bottomStripPos.size(); ++s) {
76 design->addStrip(table.bottomStripPos.at(s),
77 table.topStripPos.at(s));
89 return StatusCode::FAILURE;
92 if (shape->typeID() != GeoTrd::getClassTypeID()) {
94 <<
" is expected to be a trapezoid "<<
m_geoUtilTool->dumpShape(shape));
95 return StatusCode::FAILURE;
97 const GeoTrd* chambTrd =
static_cast<const GeoTrd*
>(shape);
98 define.
halfWidthShort = std::min(chambTrd->getYHalfLength1(), chambTrd->getYHalfLength2());
99 define.
halfWidthLong = std::max(chambTrd->getYHalfLength1(), chambTrd->getYHalfLength2());
100 define.
halfHeight = chambTrd->getZHalfLength();
103 std::vector<physVolWithTrans> allGasGaps =
m_geoUtilTool->findAllLeafNodesByName(define.
physVol,
"TgcGas");
104 if (allGasGaps.empty()) {
107 return StatusCode::FAILURE;
111 auto assignReadoutLayer = [&define, & gasGap,
this] (
const StripLayerPtr& layerReadout) {
113 return StatusCode::SUCCESS;
115 unsigned layerIdx =
static_cast<unsigned>(layerReadout->hash());
117 ATH_MSG_FATAL(
"The strip index "<<layerIdx<<
" is out of range for gasGap "<<gasGap);
118 return StatusCode::FAILURE;
121 return StatusCode::SUCCESS;
124 const std::string key = std::format(
"{:}_{:}{:}",define.
chambDesign, gasGap+1,
131 <<
" "<<define.
chambDesign<<
", gasGap "<<(gasGap+1));
132 return StatusCode::FAILURE;
134 const GeoShape* gapShape =
m_geoUtilTool->extractShape(pVolTrans.volume);
135 if (gapShape->typeID() != GeoTrd::getClassTypeID()) {
137 return StatusCode::FAILURE;
139 const GeoTrd* gapTrd =
static_cast<const GeoTrd*
>(gapShape);
143 wireDesign = (*factoryCache.
wireLayouts.insert(std::move(wireDesign)).first);
146 radDesign = (*factoryCache.
stripReadouts.insert(std::move(radDesign)).first);
149 if (!wireReadout && wireDesign) {
156 wireReadout = std::make_unique<StripLayer>(factoryCache.
trfNodeMaker.makeTransform(trans),
157 wireDesign, radDesign, layHash);
158 wireReadout->flipPhiRotation();
160 wireReadout = std::make_unique<StripLayer>(factoryCache.
trfNodeMaker.makeTransform(trans),
161 wireDesign, layHash);
165 ATH_CHECK(assignReadoutLayer(wireReadout));
169 return StatusCode::SUCCESS;
175 GeoModelIO::ReadGeoModel* sqliteReader =
m_geoDbTagSvc->getSqliteReader();
177 ATH_MSG_FATAL(
"Error, the tool works exclusively from sqlite geometry inputs");
178 return StatusCode::FAILURE;
184#ifndef SIMULATIONBASE
185 auto layerBounds = std::make_shared<Acts::SurfaceBoundFactory>();
190 physNodeMap mapFPV = sqliteReader->getPublishedNodes<std::string, GeoFullPhysVol*>(
"Muon");
191 for (
auto& [key, pv] : mapFPV) {
195 std::vector<std::string> key_tokens =
tokenize(key,
"_");
196 if (key_tokens.size() < 4 ||
197 !key_tokens[0].starts_with(
"TGC"))
204 ATH_MSG_FATAL(
"Failed to construct the station Identifier from "<<key);
205 return StatusCode::FAILURE;
212#ifndef SIMULATIONBASE
217 std::unique_ptr<TgcReadoutElement> readoutEle = std::make_unique<TgcReadoutElement>(std::move(define));
218 ATH_CHECK(mgr.addTgcReadoutElement(std::move(readoutEle)));
221 return StatusCode::SUCCESS;
225 std::vector<const TgcReadoutElement*> tgcReadOutEles = mgr.getAllTgcReadoutElements();
226 std::unique_ptr<std::vector<int>> tgcSectorMapping = std::make_unique<std::vector<int>>();
227 tgcSectorMapping->resize(
m_idHelperSvc->tgcIdHelper().module_hash_max());
231 int& sectNumb = (*tgcSectorMapping)[
m_idHelperSvc->moduleHash(readoutEle->identify())];
232 sectNumb = sectorMapping.
getSector(readoutEle->center(gctx).phi());
234 ATH_CHECK(detStore()->record(std::move(tgcSectorMapping),
"TGC_SectorMapping"));
235 return StatusCode::SUCCESS;
240 IRDBRecordset_ptr paramTable = accessSvc->getRecordsetPtr(
"TgcSensorLayout",
"");
241 if (paramTable->
size() == 0) {
243 return StatusCode::FAILURE;
246 const std::string chambType = record->getString(
"technology");
247 const int gasGap = record->getInt(
"gasGap");
248 const std::vector<int> wireGangs{
tokenizeInt(record->getString(
"wireGangs"),
",")};
249 const std::vector<double> botStrips =
tokenizeDouble(record->getString(
"bottomStrips"),
",");
250 const std::vector<double> topStrips =
tokenizeDouble(record->getString(
"topStrips"),
",");
251 const std::vector<std::string> sides =
tokenize(record->getString(
"side"),
";");
252 const double wirePitch = record->getDouble(
"wirePitch");
253 for (
const std::string& side : sides) {
254 const std::string key = std::format(
"{:}_{:}{:}", chambType, gasGap, side);
256 parBook.
wireGangs.insert(parBook.
wireGangs.end(), wireGangs.begin(), wireGangs.end());
265 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 unsigned int size() const =0
This is a "hash" representation of an Identifier.
static IdentifierHash constructHash(unsigned measCh, unsigned gasGap, const bool isStrip)
Constructs the Hash out of the Identifier fields (channel, gasGap, isStrip)
int getSector(double phi) const
returns the sector corresponding to the phi position
Identifier elementID(int stationName, int stationEta, int stationPhi) const
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Amg::Transform3D getRotateX3D(double angle)
get a rotation transformation around X-axis
Eigen::Affine3d Transform3D
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...
double halfY(const Acts::VolumeBounds &bounds)
Returns the half-Y length for the parsed volume bounds (Trapezoid/ Cuboid)
GeoModel::TransientConstSharedPtr< WireGroupDesign > WireDesignPtr
RpcReadoutElement::defineArgs defineArgs
IMuonGeoUtilityTool::physVolWithTrans physVolWithTrans
GeoModel::TransientConstSharedPtr< StripLayer > StripLayerPtr
GeoModel::TransientConstSharedPtr< RadialStripDesign > RadialStripDesignPtr
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
double halfWidthLong
Half length of the chamber long edge (Top)
double halfHeight
Half height of the chamber (Top - botom edge)
double halfThickness
Describe the chamber dimensions Half thickness of the chamber.
std::array< StripLayerPtr, 6 > sensorLayouts
We have maximum 3 gasgaps times eta / phi measurement.
double halfWidthShort
Half length of the chamber short edge (Bottom)