7#include <GaudiKernel/SystemOfUnits.h>
13#include <GeoModelKernel/GeoFullPhysVol.h>
14#include <GeoModelKernel/GeoPhysVol.h>
15#include <GeoModelKernel/GeoTrd.h>
17#include <GeoModelRead/ReadGeoModel.h>
23# include "Acts/Utilities/BoundFactory.hpp"
44 return StatusCode::FAILURE;
48 if (shape->typeID() != GeoTrd::getClassTypeID()) {
50 return StatusCode::FAILURE;
53 const GeoTrd* trapezoid =
static_cast<const GeoTrd*
>(shape);
54 define.
halfThickness = trapezoid->getXHalfLength1() * Gaudi::Units::mm;
55 define.
halfShortWidth = trapezoid->getYHalfLength1() * Gaudi::Units::mm;
56 define.
halfLongWidth = trapezoid->getYHalfLength2() * Gaudi::Units::mm;
57 define.
halfHeight = trapezoid->getZHalfLength() * Gaudi::Units::mm;
66 std::vector<physVolWithTrans> allGasGaps =
m_geoUtilTool->findAllLeafNodesByName(define.
physVol,
"actMicroMegaGas");
67 if (allGasGaps.empty()) {
69 return StatusCode::FAILURE;
79 return StatusCode::FAILURE;
82 const wMMTable& paramBook{parBookItr->second};
86 for (std::size_t gap = 0; gap < allGasGaps.size(); ++gap) {
88 auto& gapVol = allGasGaps[gap];
95 const GeoShape* gapShape =
m_geoUtilTool->extractShape(gapVol.volume);
96 if (gapShape->typeID() != GeoTrd::getClassTypeID()) {
98 return StatusCode::FAILURE;
101 bool isStereo =
static_cast<bool>(paramBook.
stereoAngle.at(gap));
103 const GeoTrd* gapTrd =
static_cast<const GeoTrd*
>(gapShape);
105 double gapHalfHeight = gapTrd->getZHalfLength();
106 double gapHalfShortY = std::min(gapTrd->getYHalfLength1(), gapTrd->getYHalfLength2());
107 double gapHalfLongY = std::max(gapTrd->getYHalfLength1(), gapTrd->getYHalfLength2());
109 double firstStripPos{0.};
110 int firstActiveStrip{0};
116 firstStripPos = -gapHalfHeight + 0.5*paramBook.
stripPitch;
123 stripDesign->defineStripLayout(firstStripPos * Amg::Vector2D::UnitX(),
130 stripDesign->defineTrapezoid(gapHalfShortY, gapHalfLongY, gapHalfHeight, paramBook.
stereoAngle.at(gap));
138 stripDesign = (*factoryCache.
stripDesigns.emplace(stripDesign).first);
139 auto stripLayer = std::make_unique<StripLayer>(factoryCache.
trfNodeMaker.makeTransform(stripLayerRotation),
142 define.
layers.push_back(*factoryCache.
stripLayers.emplace(std::move(stripLayer)).first);
144 return StatusCode::SUCCESS;
151 GeoModelIO::ReadGeoModel* sqliteReader =
m_geoDbTagSvc->getSqliteReader();
153 ATH_MSG_FATAL(
"Error, the tool works exclusively from sqlite geometry inputs");
154 return StatusCode::FAILURE;
164 physNodeMap mapFPV = sqliteReader->getPublishedNodes<std::string, GeoFullPhysVol*>(
"Muon");
165#ifndef SIMULATIONBASE
166 auto layerBounds= std::make_shared<Acts::SurfaceBoundFactory>();
169 for (
auto& [key, pv] : mapFPV) {
173 std::vector<std::string> key_tokens =
tokenize(key,
"_");
175 if (key_tokens[0].
find(
"MM") == std::string::npos){
178 ATH_MSG_DEBUG(
"Retrieving MicroMegas Quadruplet : " << key );
182 define.
detElId = idHelper.
channelID(key_tokens[1][0] ==
'S' ?
"MMS" :
"MML",
183 atoi(key_tokens[2].c_str()),
184 atoi(key_tokens[3].c_str()),
191 ATH_MSG_FATAL(
"Failed to build a good identifier out of " << key);
192 return StatusCode::FAILURE;
197 define.
chambDesign = key_tokens[0]+
"_"+key_tokens[1];
200#ifndef SIMULATIONBASE
203 std::unique_ptr<MmReadoutElement> readoutEle = std::make_unique<MmReadoutElement>(std::move(define));
204 ATH_CHECK(mgr.addMmReadoutElement(std::move(readoutEle)));
206 return StatusCode::SUCCESS;
216 if (paramTable->
size() == 0) {
218 return StatusCode::FAILURE;
221 << paramTable->
tagName() <<
"] table with "
222 << paramTable->
size() <<
" records");
227 const std::string chambType = record->getString(
"WMM_TYPE");
229 parBook.
stripPitch = record->getDouble(
"stripPitch") ;
230 parBook.
stripWidth = record->getDouble(
"stripWidth") ;
247 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
This is a "hash" representation of an Identifier.
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channel) const
std::string find(const std::string &s)
return a remapped string
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Amg::Transform3D getRotateZ3D(double angle)
get a rotation transformation around Z-axis
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
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...
IMuonGeoUtilityTool::physVolWithTrans physVolWithTrans
GeoModel::TransientConstSharedPtr< StripDesign > StripDesignPtr
double halfThickness
Trapezoid dimensions of MicroMegas envelope half-thickness along z-axis.
double halfShortWidth
width of the lower edge
double halfLongWidth
width of the upper edge
std::vector< int > readoutSide
Readout sides.
double halfHeight
length in the radial direction
std::vector< StripLayerPtr > layers
Pointers to the strip layers.
unsigned int nGasGaps
number of gasGaps
std::shared_ptr< Acts::SurfaceBoundFactory > layerBounds
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,...