922 {
923 const GeoLogVol* clv = cv->getLogVol();
924 const std::string& vname = clv->getName();
925 ATH_MSG_DEBUG(
name() <<
" building station prototype for " << cv->getLogVol()->getName());
927 MuonStationTypeBuilder::Cache cache{};
928
929 std::unique_ptr<Trk::DetachedTrackingVolume> typeStat{};
930
931 if (vname.substr(0, 4) == "sTGC" || vname.substr(0, 2) == "MM") {
932 std::string sName = vname.substr(vname.find('-') + 1);
934
935 if (vname.substr(0, 4) ==
"sTGC" &&
m_idHelperSvc->issTgc(nswId)) {
937 }
else if (vname.substr(0, 2) ==
"MM" &&
m_idHelperSvc->isMM(nswId)) {
939 }
940 }
941
943 return typeStat;
945 return typeStat;
946 if (!
m_buildCsc && vname.compare(0, 1,
"C") == 0)
947 return typeStat;
948 if (!
m_buildTgc && vname.compare(0, 1,
"T") == 0)
949 return typeStat;
950
951 int etaphi = gmInfo.second;
952 int sign = (etaphi < 0) ? -1 : 1;
953 etaphi =
sign * etaphi;
954 int is_mirr = etaphi / 1000;
955 etaphi = etaphi - is_mirr * 1000;
956 int eta = etaphi / 100;
957 int phi = etaphi -
eta * 100;
960 if (!gmStation) {
962 }
963
964 if (!gmStation) {
965 int etaphi = gmInfo.second;
966 int a_etaphi = static_cast<int>(etaphi / 100000);
967 int sideC =
static_cast<int>(a_etaphi / 10000);
968 a_etaphi -=
sideC * 10000;
969 is_mirr = static_cast<int>(a_etaphi / 1000);
970 a_etaphi -= is_mirr * 1000;
971 eta =
static_cast<int>(a_etaphi / 100);
972 phi = a_etaphi -
eta * 100;
973 if (sideC)
976 }
977
978 std::string stname = (vname.compare(0, 1, "T") == 0) ? vname : (clv->getName()).substr(0, vname.size() - 8);
979
980 if (stname.compare(0, 1,
"B") == 0 &&
eta < 0) {
981 stname = (clv->getName()).substr(0, vname.size() - 8) + "-";
982 }
983 ATH_MSG_VERBOSE(
" new station type " << stname <<
"," << clv->getShape()->type());
985
986 if (stname.compare(0, 2, "CS") == 0 || stname.compare(0, 1, "T") == 0) {
987
988 if (stname.compare(0, 2, "CS") == 0) {
990
992
993 auto layerVec = std ::make_unique<std::vector<Trk::Layer*>>(
Muon::release(layerRepr.second));
994 typeStat = std::make_unique<Trk::DetachedTrackingVolume>(stname, std::move(csc_station),
995 std::move(layerRepr.first), std::move(layerVec));
996 } else {
998
1000
1001 auto layerVec = std ::make_unique<std::vector<Trk::Layer*>>(
Muon::release(layerRepr.second));
1002 typeStat = std::make_unique<Trk::DetachedTrackingVolume>(stname, std::move(tgc_station),
1003 std::move(layerRepr.first), std::move(layerVec));
1004 }
1005
1006 } else {
1007 const GeoShape* shapeS = clv->getShape();
1008 while (shapeS->type() != "Trd") {
1009 if (shapeS->type() == "Shift") {
1010 const GeoShapeShift* shift = dynamic_cast<const GeoShapeShift*>(shapeS);
1011 shapeS = shift->getOp();
1012 } else if (shapeS->type() == "Subtraction") {
1013 const GeoShapeSubtraction* sub = dynamic_cast<const GeoShapeSubtraction*>(shapeS);
1014 shapeS = sub->getOpA();
1015 } else if (shapeS->type() == "Union") {
1016 const GeoShapeUnion* uni = dynamic_cast<const GeoShapeUnion*>(shapeS);
1017 shapeS = uni->getOpA();
1018 } else {
1019 ATH_MSG_WARNING(
"unexpected station shape ? "<< shapeS->type() <<
", station not built");
1020 break;
1021 }
1022 }
1023 const GeoTrd* trd = dynamic_cast<const GeoTrd*>(shapeS);
1024
1025 double halfX1{0.}, halfX2{0.}, halfY1{0.}, halfY2{0.},
halfZ{0.};
1026 if (trd) {
1027
1028 halfX1 = trd->getXHalfLength1();
1029 halfX2 = trd->getXHalfLength2();
1030 halfY1 = trd->getYHalfLength1();
1031 halfY2 = trd->getYHalfLength2();
1032 halfZ = trd->getZHalfLength();
1033
1034
1035 std::unique_ptr<Trk::TrackingVolumeArray> confinedVolumes{};
1036 std::vector<std::unique_ptr<Trk::Layer>> confinedLayers{};
1037 std::unique_ptr<Trk::Volume> envelope;
1038 std::string shape = "Trd";
1039 if (halfX1 == halfX2 && halfY1 == halfY2)
1040 shape = "Box";
1041 if (shape == "Box") {
1042 auto envBounds = std::make_shared<Trk::CuboidVolumeBounds>(halfX1, halfY1, halfZ);
1043
1045 if (!confinedVolumes) {
1047 }
1048
1049 envelope = std::make_unique<Trk::Volume>(nullptr, std::move(envBounds));
1050 } else if (shape == "Trd") {
1051 std::unique_ptr<Trk::TrapezoidVolumeBounds> envBounds{};
1053 if (halfY1 == halfY2) {
1054 envBounds = std::make_unique<Trk::TrapezoidVolumeBounds>(halfX1, halfX2, halfY1, halfZ);
1055 ATH_MSG_VERBOSE(
"CAUTION!!!: this trapezoid volume does not require XY -> YZ switch");
1056 }
1057 if (halfY1 != halfY2 && halfX1 == halfX2) {
1059 envBounds = std::make_unique<Trk::TrapezoidVolumeBounds>(halfY1, halfY2, halfZ, halfX1);
1060 }
1061 if (halfX1 != halfX2 && halfY1 != halfY2) {
1063 }
1064 if (envBounds) {
1065
1067
1068 envelope = std::make_unique<Trk::Volume>(
makeTransform(transf), std::move(envBounds));
1069 }
1070 }
1071
1072 if (envelope) {
1073
1074 std::unique_ptr<Trk::TrackingVolume> newType{};
1075 if (!confinedLayers.empty()) {
1076 auto confinedLayerPtr = std::make_unique<std::vector<Trk::Layer*>>(
Muon::release(confinedLayers));
1077 newType = std::make_unique<Trk::TrackingVolume>(*envelope,
m_muonMaterial, std::move(confinedLayerPtr), stname);
1078 } else {
1079 newType = std::make_unique<Trk::TrackingVolume>(*envelope,
m_muonMaterial,
nullptr, std::move(confinedVolumes), stname);
1080 }
1081
1082
1083
1084 if ((stname.compare(0, 1, "B") == 0 || stname.compare(0, 1, "E") == 0))
1086
1087
1089
1090
1091 auto layerVec = std::make_unique<std::vector<Trk::Layer*>>(
Muon::release(layerRepr.second));
1092 typeStat = std::make_unique<Trk::DetachedTrackingVolume>(stname, std::move(newType),
1093 std::move(layerRepr.first),
1094 std::move(layerVec));
1095 }
1096 }
1097 }
1098
1100
1102 return typeStat;
1103}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
const MuonStation * getMuonStation(const std::string &stName, int eta, int phi) const
Amg::Transform3D getTransform() const
Gaudi::Property< bool > m_buildCsc
Trk::Material m_muonMaterial
the material
Gaudi::Property< bool > m_buildEndcap
void identifyPrototype(Trk::TrackingVolume &station, int eta, int phi, const Amg::Transform3D &transf, const MuonGM::MuonDetectorManager *muonMgr) const
Gaudi::Property< bool > m_buildTgc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Gaudi::Property< bool > m_buildBarrel
Amg::Transform3D getRotateZ3D(double angle)
get a rotation transformation around Z-axis
Amg::Transform3D getRotateY3D(double angle)
get a rotation transformation around Y-axis
double halfZ(const Acts::VolumeBounds &bounds)
Returns the half-Z length for the parsed volume bounds (Trapezoid/ Cuboid)
std::unique_ptr< Amg::Transform3D > makeTransform(const Amg::Transform3D &trf)
std::vector< ObjType * > release(std::vector< std::unique_ptr< ObjType > > &objVec)
unsigned int constexpr sideC