16#include "GeoModelKernel/GeoShape.h"
17#include "GeoModelKernel/GeoVolumeCursor.h"
21 const std::string& t,
const std::string& n,
const IInterface* p)
29 ATH_MSG_INFO(
" option Simplify(Muon)GeometryToLayers no longer maintained ");
32 return StatusCode::SUCCESS;
39 throw std::runtime_error(
"No tree top has been parsed");
45 ATH_MSG_DEBUG(
" obtained " << msTypes.size() <<
" prototypes");
48 for (
auto& [msTV, transforms]: msTypes) {
49 std::string msTypeName = msTV->name();
51 std::unique_ptr<Trk::DetachedTrackingVolume> newStat{msTV->clone(msTypeName, combTr)};
52 mInert.push_back(std::move(newStat));
55 ATH_MSG_DEBUG(
" returns " << mInert.size() <<
" objects (detached volumes)");
66 GeoVolumeCursor vol(
top);
67 while (!vol.atEnd()) {
68 const GeoVPhysVol* cv = vol.getVolume();
69 const GeoLogVol* clv = cv->getLogVol();
70 const std::string_view vname = clv->getName();
71 if (vname.size() > 7 && vname.substr(vname.size() - 7, 7) ==
75 if (vname.substr(0, 3) ==
"BAR" || vname.substr(0, 2) ==
"BT" ||
76 vname.substr(0, 6) ==
"EdgeBT" || vname.substr(0, 6) ==
"HeadBT"){
78 }
else if (vname.substr(0, 3) ==
"ECT") {
80 }
else if (vname.substr(0, 4) ==
"Feet" ||
81 (vname.size() > 7 && (vname.substr(3, 4) ==
"Feet" || vname.substr(4, 4) ==
"Feet"))) {
83 }
else if (vname.substr(0, 4) ==
"Rail") {
85 }
else if (vname.substr(0, 1) ==
"J") {
89 }
else if (vname.substr(0, 3) ==
"NSW" && vname.substr(1, 6) ==
"Spacer") {
91 }
else if (vname.substr(0, 3) ==
"NSW" && vname.substr(1, 2) ==
"Al") {
93 }
else if (vname.substr(0, 3) ==
"NJD"){
95 }
else if (vname.substr(0, 1) ==
"A" && vname.substr(1, 5) ==
"Plate"){
98 }
else if (vname.substr(0, 1) !=
"J") {
108 if (
msg().level() == MSG::VERBOSE)
111 std::vector<std::pair<const GeoVPhysVol*, std::vector<Amg::Transform3D>>> vols;
113 bool simpleTree =
false;
114 if (!cv->getNChildVols()) {
115 if (!
m_gmBrowser.findNamePattern(cv,
"Sensitive")) {
116 std::vector<Amg::Transform3D> volTr;
117 volTr.push_back(vol.getTransform());
118 vols.emplace_back(cv, volTr);
125 for (
auto& [physVol, physVolTrfs]: vols) {
126 std::string protoName(vname);
128 protoName += physVol->getLogVol()->getName();
130 << physVol->getLogVol()->getMaterial()->getName()
131 <<
" x0 " << physVol->getLogVol()->getMaterial()->getRadLength()
132 <<
"," << physVol->getLogVol()->getShape()->type());
135 for (
auto& obj : objs) {
136 if (protoName == obj.first->name()) {
139 obj.second.push_back(vol.getTransform());
141 obj.second.insert(obj.second.end(),
142 std::make_move_iterator(physVolTrfs.begin()),
143 std::make_move_iterator(physVolTrfs.end()));
154 const std::string volName = newType->volumeName();
155 auto typeDet = std::make_unique<Trk::DetachedTrackingVolume>(volName, std::move(newType));
156 objs.emplace_back(std::move(typeDet), std::move(physVolTrfs));
166 for (
auto& obj : objs)
167 count += obj.second.size();
169 ATH_MSG_DEBUG(
" returns " << objs.size()<<
" prototypes, to be cloned into " <<
count <<
" objects");
175 const GeoVPhysVol* pv)
const {
176 const GeoLogVol* lv = pv->getLogVol();
178 << lv->getName() <<
", made of "
179 << lv->getMaterial()->getName() <<
" x0 "
180 << lv->getMaterial()->getRadLength() <<
","
181 << lv->getShape()->type());
187 const GeoVPhysVol* pv)
const {
189 unsigned int nc = pv->getNChildVols();
190 for (
unsigned int ic = 0; ic < nc; ic++) {
193 const GeoVPhysVol* cv = &(*(pv->getChildVol(ic)));
194 const GeoLogVol* clv = cv->getLogVol();
198 << ic <<
":" << clv->getName() <<
", made of "
199 << clv->getMaterial()->getName() <<
" x0 "
200 << clv->getMaterial()->getRadLength() <<
" , "
201 << clv->getShape()->type() <<
"," << transf.translation().x() <<
" "
202 << transf.translation().y() <<
" " << transf.translation().z());
212 std::vector<std::pair<
const GeoVPhysVol*, std::vector<Amg::Transform3D>>>&
215 unsigned int nc = pv->getNChildVols();
217 << pv->getLogVol()->getName() <<
","
218 << pv->getLogVol()->getMaterial()->getName()
219 <<
", looping over " << nc <<
" children");
220 for (
unsigned int ic = 0; ic < nc; ic++) {
222 const GeoVPhysVol* cv = &(*(pv->getChildVol(ic)));
223 const GeoLogVol* clv = cv->getLogVol();
224 if (clv->getMaterial()->getDensity() > 0. &&
227 if (!cv->getNChildVols()) {
229 for (
auto& vol : vols) {
230 if (clv->getName() == vol.first->getLogVol()->getName()) {
231 if (
m_gmBrowser.compareGeoVolumes(cv, vol.first, 1.e-3) !=
234 "INERT name branch matching differences detected "
238 vol.second.push_back(transform * transf);
243 std::vector<Amg::Transform3D> volTr;
244 volTr.push_back(transform * transf);
245 vols.emplace_back(cv, volTr);
247 << clv->getName() <<
","
248 << clv->getMaterial()->getName());
249 if (
msg().level() <= MSG::VERBOSE)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
Gaudi::Property< double > m_blendLimit
std::vector< std::unique_ptr< Trk::DetachedTrackingVolume > > DetachedVolVec
Gaudi::Property< bool > m_simplifyToLayers
Trk::GeoShapeConverter m_geoShapeConverter
shape converter
Trk::VolumeConverter m_volumeConverter
gm->trk volume helper
DetachedVolVec buildDetachedTrackingVolumesImpl(const PVConstLink &treeTop, bool blend) const
Gaudi::Property< bool > m_buildNSWInert
Gaudi::Property< bool > m_simplify
void getObjsForTranslation(const GeoVPhysVol *pv, const Amg::Transform3D &, std::vector< std::pair< const GeoVPhysVol *, std::vector< Amg::Transform3D > > > &vols) const
Method extracting material objects from GeoModel tree.
Gaudi::Property< bool > m_buildShields
Trk::GMTreeBrowser m_gmBrowser
gm tree helper
MuonInertMaterialBuilderImpl(const std::string &, const std::string &, const IInterface *)
Constructor.
Gaudi::Property< bool > m_buildECT
Gaudi::Property< bool > m_buildFeets
DetachedVolumeVecWithTrfs buildDetachedTrackingVolumeTypes(const PVConstLink &top, bool blend) const
virtual StatusCode initialize() override
AlgTool initialize method.
void printInfo(const GeoVPhysVol *pv) const
Dump from GeoModel tree.
void printChildren(const GeoVPhysVol *pv) const
std::vector< std::pair< std::unique_ptr< Trk::DetachedTrackingVolume >, std::vector< Amg::Transform3D > > > DetachedVolumeVecWithTrfs
Method creating material object prototypes.
Gaudi::Property< bool > m_buildSupports
Gaudi::Property< bool > m_buildBT
Gaudi::Property< int > m_buildRails
TrackingVolumeManipulator()
constructor
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
Eigen::Affine3d Transform3D
Ensure that the ATLAS eigen extensions are properly loaded.