8#include "GaudiKernel/SystemOfUnits.h"
46 p.zindex <<
" " << p.phiindex <<
" " << p.zindex * 100 + p.phiindex <<
51 int key = p.zindex * 100 + p.phiindex;
56 int key = iz * 100 + iphi;
57 std::pair<AlignPosIterator, AlignPosIterator> ppp =
m_alignpositions.equal_range(key);
58 lastAlignPosInRange = ppp.second;
64 int key = iz * 100 + iphi;
71 int key = iz * 100 + iphi;
91 p.zindex <<
" " << p.phiindex <<
" " << p.zindex * 100 + p.phiindex);
100 int key = iz * 100 + iphi;
115 for (
unsigned int i = 0; i <
m_components.size(); i++) {
121 thick = thick > t->GetThickness(mysql) + t->posz ? thick : t->GetThickness(mysql) + t->posz;
124 double zstart = std::numeric_limits<double>::max();
126 for (
unsigned int i = 0; i <
m_components.size(); i++) {
132 thick = thick > s->GetThickness(mysql) + s->posz ? thick : s->GetThickness(mysql) + s->posz;
133 if (i == 0 || s->posz < zstart)
136 ATH_MSG_VERBOSE(
"Station " <<
m_name <<
" calculating Thinkness = " << thick <<
" and zstart = " << zstart);
139 if (std::abs(zstart) > 0.001) {
140 thick = thick - zstart;
143 " because zstart = " << zstart <<
163 double innerrad = std::numeric_limits<double>::max();
164 double outerrad = 0.;
166 for (
unsigned int i = 0; i <
m_components.size(); i++) {
169 if (tg->
posy < innerrad) {
173 if (tg->
posy + tg->
dy > outerrad) {
174 outerrad = tg->
posy + tg->
dy;
178 len = outerrad - innerrad;
180 double ystart = 999999.;
182 for (
unsigned int i = 0; i <
m_components.size(); i++) {
185 ATH_MSG_ERROR(
"Dynamic cast to StandardComponent failed at line "<<__LINE__);
189 sc->name <<
" posy " <<
sc->posy <<
" dy " <<
sc->dy <<
" len " << len <<
190 " ystart " << ystart);
191 if ((
sc->dy +
sc->posy) > len)
192 len =
sc->dy +
sc->posy;
193 if (i == 0 ||
sc->posy < ystart)
198 if (std::abs(ystart) > 0.001) {
202 ATH_MSG_VERBOSE(
"Station " <<
m_name <<
" redefining len = " << len <<
" because ystart = " << ystart);
211 double ystart = std::numeric_limits<double>::max();
213 for (
unsigned int i = 0; i <
m_components.size(); i++) {
216 ATH_MSG_ERROR(
"Dynamic cast to StandardComponent failed at line "<<__LINE__);
219 if (i == 0 ||
sc->posy < ystart)
228 double maxdxmin = std::numeric_limits<double>::lowest();
231 for (
unsigned int i = 0; i <
m_components.size(); i++) {
232 std::string_view n = std::string_view(
m_components[i]->name).substr(0, 3);
235 std::string_view typetgc = std::string_view(
m_components[i]->name).substr(3, 2);
237 if (typetgc ==
"01" || typetgc ==
"06" || typetgc ==
"12" || typetgc ==
"18" || typetgc ==
"19" || typetgc ==
"20" || typetgc ==
"21") {
254 double tantheta = num != 0 ? num /
m_components[i]->dy : 0;
257 ATH_MSG_ERROR(
"Dynamic cast to StandardComponent failed at line "<<__LINE__);
264 if (maxdxmin < dxmin && (n.substr(0, 2) !=
"LB" ||
m_name[0] ==
'B'))
269 if (
m_name.substr(0, 1) ==
"T")
278 double maxdxmax = std::numeric_limits<double>::lowest();
281 for (
unsigned int i = 0; i <
m_components.size(); i++) {
286 std::string_view n = std::string_view(
m_components[i]->name).substr(0, 3);
289 std::string_view typetgc = std::string_view(
m_components[i]->name).substr(3, 2);
291 if (typetgc ==
"01" || typetgc ==
"06" || typetgc ==
"12" || typetgc ==
"18" || typetgc ==
"19" || typetgc ==
"20" || typetgc ==
"21") {
301 double tantheta = num != 0 ? num /
m_components[i]->dy : 0;
304 ATH_MSG_ERROR(
"Dynamic cast to StandardComponent failed at line "<<__LINE__);
311 if (maxdxmax < dxmax)
316 if (
m_name.compare(0, 1,
"T") == 0)
327 os <<
"Station m_name: " << s.m_name <<
" " << s.m_components.size() << std::endl;
328 for (
unsigned int i = 0; i < s.m_components.size(); i++)
329 os <<
"\t" << s.m_components[i].get() << std::endl;
332 for (k = s.begin(); k != s.end(); ++k)
333 os <<
"\t\t" << (*k).second << std::endl;
336 for (ak = s.abegin(); ak != s.aend(); ++ak)
337 os <<
"\t\t" << (*ak).second << std::endl;
339 os <<
"--------------------------------------------------" << std::endl;
346 ATH_MSG_ERROR(
"Dynamic cast to MDT failed at line "<<__LINE__);
349 double mdthalfpitch = 0.5 * (mdtobj->
pitch);
355 if (c->name.compare(0, 3,
"MDT") != 0)
359 ATH_MSG_ERROR(
"Cannot find MDT definition for component " << c->name);
362 mdthalfpitch = 0.5 * (mdtobj->
pitch);
374 if (amdbVersion > 0 && amdbVersion < 7 &&
m_name[0] !=
'B') {
375 ATH_MSG_DEBUG(
"For AMDB version " << amdbVersion <<
" a left-handed chamber coordinate system was used "
376 <<
" for endcap side A so be very careful.");
380 GeoTrf::Transform3D mirrsym = GeoTrf::Transform3D::Identity();
383 mirrsym = GeoTrf::RotateX3D(180. * Gaudi::Units::deg);
388 GeoTrf::Translate3D AMDBorgTranslation(0, 0, 0);
389 if ((
m_name[0] ==
'B' || p.isBarrelLike) && p.zindex < 0 && (!p.isMirrored) &&
hasMdts()) {
393 ATH_MSG_VERBOSE(
" GetThickness / getAmdbO_thick / GetLength() / getAmdbO_length " <<
404 ATH_MSG_VERBOSE(
" GetThickness / getAmdbO_thick / GetLength() / getAmdbO_length " <<
421 GeoTrf::Transform3D to_tsz = AMDBorgTranslation * mirrsym;
432 GeoTrf::Transform3D nominalTransf = GeoTrf::Transform3D::Identity();
434 GeoTrf::Vector3D
vec;
443 vec.x() = RAD * cos(p.phi * Gaudi::Units::deg);
444 vec.x() =
vec.x() - p.shift * sin((p.phi) * Gaudi::Units::deg);
445 vec.y() = RAD * sin(p.phi * Gaudi::Units::deg);
446 vec.y() =
vec.y() + p.shift * cos((p.phi) * Gaudi::Units::deg);
449 if ((p.isBarrelLike) || (
m_name[0] ==
'B')) {
456 if ((p.isBarrelLike) || (
m_name[0] ==
'B' && p.zindex < 0 &&
hasMdts())) {
458 vec.z() = p.z + halfpitch;
467 GeoTrf::RotateX3D ralpha(p.alpha * Gaudi::Units::deg);
468 GeoTrf::RotateZ3D rbeta(p.beta * Gaudi::Units::deg);
469 GeoTrf::RotateY3D rgamma(p.gamma * Gaudi::Units::deg);
471 ATH_MSG_VERBOSE(
" gamma is not changing sign - original " << p.gamma <<
" new one " << p.gamma <<
472 " alpha / beta " << p.alpha <<
" " << p.beta);
478 GeoTrf::Transform3D abgRot = rgamma * rbeta * ralpha;
480 if (
m_name[0] ==
'B' || p.isBarrelLike) {
482 nominalTransf = GeoTrf::RotateZ3D(p.phi * Gaudi::Units::deg);
496 nominalTransf = GeoTrf::Transform3D(GeoTrf::RotateY3D(-90 * Gaudi::Units::deg) * GeoTrf::RotateX3D(p.phi * Gaudi::Units::deg - 180 * Gaudi::Units::deg));
497 }
else if (p.z < 0) {
498 nominalTransf = GeoTrf::Transform3D(GeoTrf::RotateY3D(-90 * Gaudi::Units::deg) * GeoTrf::RotateX3D(p.phi * Gaudi::Units::deg - 180 * Gaudi::Units::deg) *
499 GeoTrf::RotateZ3D(180 * Gaudi::Units::deg));
501 ATH_MSG_WARNING(
"Problem here p.z, mirrored " << p.z <<
" " << p.isMirrored);
505 return GeoTrf::Translate3D(
vec.x(),
vec.y(),
vec.z()) * nominalTransf * abgRot;
521 if (ap.tras != 0 || ap.trat != 0 || ap.traz != 0 || ap.rots != 0 || ap.rott != 0 || ap.rotz != 0) {
523 << ap.tras <<
" " << ap.traz <<
" " << ap.trat <<
" " << ap.rots <<
" "
524 << ap.rotz <<
" " << ap.rott <<
" isBarrel=" << ap.isBarrel
528 GeoTrf::RotateX3D rott(ap.rott);
529 GeoTrf::RotateZ3D rotz(ap.rotz);
530 GeoTrf::RotateY3D rots(ap.rots);
531 GeoTrf::Transform3D trans = GeoTrf::TranslateY3D(ap.tras) * GeoTrf::TranslateZ3D(ap.traz) * GeoTrf::TranslateX3D(ap.trat);
533 GeoTrf::Transform3D delta = trans * rots * rotz * rott;
535 if (
msgLvl(MSG::VERBOSE)) {
536 msg() << MSG::VERBOSE <<
" delta transform in the tsz frame --------------" <<
endmsg
537 << delta(0, 0) <<
" " << delta(0, 1) <<
" " << delta(0, 2) <<
" " << delta(0, 3) <<
" " <<
endmsg
538 << delta(1, 0) <<
" " << delta(1, 1) <<
" " << delta(1, 2) <<
" " << delta(1, 3) <<
" " <<
endmsg
539 << delta(2, 0) <<
" " << delta(2, 1) <<
" " << delta(2, 2) <<
" " << delta(2, 3) <<
" " <<
endmsg;
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
std::vector< size_t > vec
MsgStream & msg() const
The standard message stream.
bool msgLvl(const MSG::Level lvl) const
Test the output level.
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
void StoreStation(Station *s)
const Technology * GetATechnology(const std::string &name) const
int getNovaReadVersion() const
double GetExtraTopThickness() const
std::vector< std::unique_ptr< Component > > m_components
GeoTrf::Transform3D native_to_tsz_frame(const MYSQL &mysql, const Position &p) const
int CountAlignPos(int iz, int iphi) const
GeoTrf::Transform3D global_to_tsz_frame(const MYSQL &mysql, const Position &p) const
const std::string & GetName() const
double getAmdbOrigine_along_length() const
int GetNrOfComponents() const
void SetAlignPos(const AlignPos &p)
GeoTrf::Transform3D getDeltaTransform_tszFrame(const MYSQL &mysql, const AlignPos &ap) const
void SetCutout(Cutout *c)
AlignPosIterator abegin() const
AlignPosIterator FindAlignPos(int iz, int iphi) const
int GetNrOfCutouts() const
AlignPosIterator aend() const
PositionIterator FindPosition(int iz, int iphi) const
AlignPosIterator getFirstAlignPosInRange(int iz, int iphi, AlignPosIterator &lastAlignPosInRange) const
std::atomic< double > m_amdbOrigine_along_length
PositionIterator end() const
void SetPosition(Position p)
AlignPosMap m_alignpositions
GeoTrf::Transform3D getDeltaTransform(const MYSQL &mysql, const AlignPos &ap, const Position &p) const
GeoTrf::Transform3D getNominalTransform(const MYSQL &mysql, const Position &p) const
double GetThickness(const MYSQL &mysql) const
void SetComponent(Component *c)
GeoTrf::Transform3D tsz_to_global_frame(const MYSQL &mysql, const Position &p) const
GeoTrf::Transform3D tsz_to_native_frame(const MYSQL &mysql, const Position &p) const
double getAmdbOrigine_along_thickness(const MYSQL &mysql) const
PositionIterator begin() const
GeoTrf::Transform3D getAlignedTransform(const MYSQL &mysql, const AlignPos &ap, const Position &p) const
Component * GetComponent(int i) const
double GetExtraBottomThickness() const
std::vector< std::unique_ptr< Cutout > > m_cutouts
Cutout * GetCutout(int i) const
std::atomic< double > m_amdbOrigine_along_thickness
double mdtHalfPitch(const MYSQL &mysql) const
singleton-like access to IMessageSvc via open function and helper
Ensure that the Athena extensions are properly loaded.
std::multimap< int, AlignPos, std::less< int > >::const_iterator AlignPosIterator
std::map< int, Position, std::less< int > >::const_iterator PositionIterator
std::ostream & operator<<(std::ostream &os, const AlignPos &p)