ATLAS Offline Software
Loading...
Searching...
No Matches
TopLevelPlacements Class Reference

#include <TopLevelPlacements.h>

Collaboration diagram for TopLevelPlacements:

Classes

class  Part

Public Member Functions

 TopLevelPlacements (const IRDBRecordset_ptr &topLevelTable)
 ~TopLevelPlacements ()
bool present (const std::string &partName) const
const GeoTrf::Transform3D & transform (const std::string &partName) const

Private Member Functions

void fillPlacements (const IRDBRecordset_ptr &topLevelTable)
GeoTrf::Transform3D partTransform (const IRDBRecord *record) const
PartgetPart (const std::string &partName) const

Private Attributes

std::map< std::string, Part * > m_parts
bool m_noTopLevelTable

Static Private Attributes

static const GeoTrf::Transform3D s_identityTransform = GeoTrf::Transform3D::Identity()

Detailed Description

Definition at line 17 of file TopLevelPlacements.h.

Constructor & Destructor Documentation

◆ TopLevelPlacements()

TopLevelPlacements::TopLevelPlacements ( const IRDBRecordset_ptr & topLevelTable)

Definition at line 15 of file TopLevelPlacements.cxx.

16 : m_noTopLevelTable(true) {
17 fillPlacements(topLevelTable);
18}
void fillPlacements(const IRDBRecordset_ptr &topLevelTable)

◆ ~TopLevelPlacements()

TopLevelPlacements::~TopLevelPlacements ( )

Definition at line 20 of file TopLevelPlacements.cxx.

20 {
21 std::map<std::string, Part*>::const_iterator iter;
22 for (iter = m_parts.begin(); iter != m_parts.end(); ++iter) delete iter->second;
23}
std::map< std::string, Part * > m_parts

Member Function Documentation

◆ fillPlacements()

void TopLevelPlacements::fillPlacements ( const IRDBRecordset_ptr & topLevelTable)
private

Definition at line 43 of file TopLevelPlacements.cxx.

43 {
44 if (topLevelTable.get() == nullptr) {
45 m_noTopLevelTable = true;
46 return;
47 }
48 m_noTopLevelTable = false;
49 int numParts = topLevelTable->size();
50 for (int i = 0; i < numParts; i++) {
51 const IRDBRecord* record = (*topLevelTable)[i];
52 std::string label = record->getString("LABEL");
53
54 Part* part = new Part;
55 part->label = label;
56 part->transform = partTransform(record);
57
59 }
60}
virtual const std::string & getString(const std::string &fieldName) const =0
Get string field value.
virtual unsigned int size() const =0
GeoTrf::Transform3D partTransform(const IRDBRecord *record) const
std::string label(const std::string &format, int i)
Definition label.h:19

◆ getPart()

TopLevelPlacements::Part * TopLevelPlacements::getPart ( const std::string & partName) const
private

Definition at line 119 of file TopLevelPlacements.cxx.

119 {
120 std::map<std::string, Part*>::const_iterator iter;
121 iter = m_parts.find(partName);
122 if (iter == m_parts.end()) return nullptr;
123
124 return iter->second;
125}

◆ partTransform()

GeoTrf::Transform3D TopLevelPlacements::partTransform ( const IRDBRecord * record) const
private

Definition at line 63 of file TopLevelPlacements.cxx.

63 {
64 double posX = record->getDouble("POSX") * Gaudi::Units::mm;
65 double posY = record->getDouble("POSY") * Gaudi::Units::mm;
66 double posZ = record->getDouble("POSZ") * Gaudi::Units::mm;
67 double rotX = record->getDouble("ROTX") * Gaudi::Units::degree;
68 double rotY = record->getDouble("ROTY") * Gaudi::Units::degree;
69 double rotZ = record->getDouble("ROTZ") * Gaudi::Units::degree;
70 int rotOrder = record->getInt("ROTORDER");
71
72 // Translation part
73 GeoTrf::Translate3D transform(posX, posY, posZ);
74
75 // If rotation is zero return translation
76 if (rotX == 0 && rotY == 0 && rotZ == 0) {
77 return transform;
78 }
79
80 // For rotation have to look at order.
81 // 123 means rotate around X, then Y , then Z.
82 // 312 means rotate around Z, then X , then Y.
83 // etc
84
85 int ixyz1 = rotOrder / 100 - 1;
86 int ixyz2 = (rotOrder % 100) / 10 - 1;
87 int ixyz3 = (rotOrder % 10) - 1;
88
89 if (ixyz1 < 0 || ixyz1 > 2 ||
90 ixyz2 < 0 || ixyz2 > 2 ||
91 ixyz3 < 0 || ixyz3 > 2) {
92 std::cout << "ERROR: Invalid rotation order:" << rotOrder << std::endl;
93 ixyz1 = 0;
94 ixyz2 = 1;
95 ixyz3 = 2;
96 }
97
98 // List of the three transforms
99 GeoTrf::Transform3D* xformList[3] = {
100 nullptr, nullptr, nullptr
101 };
102 if (rotX != 0) xformList[0] = new GeoTrf::RotateX3D(rotX);
103 if (rotY != 0) xformList[1] = new GeoTrf::RotateY3D(rotY);
104 if (rotZ != 0) xformList[2] = new GeoTrf::RotateZ3D(rotZ);
105
106 GeoTrf::Transform3D rotation(GeoTrf::Transform3D::Identity());
107 if (xformList[ixyz1]) rotation = *(xformList[ixyz1]) * rotation;
108 if (xformList[ixyz2]) rotation = *(xformList[ixyz2]) * rotation;
109 if (xformList[ixyz3]) rotation = *(xformList[ixyz3]) * rotation;
110
111 delete xformList[0];
112 delete xformList[1];
113 delete xformList[2];
114
115 return transform * rotation;
116}
virtual int getInt(const std::string &fieldName) const =0
Get int field value.
virtual double getDouble(const std::string &fieldName) const =0
Get double field value.
const GeoTrf::Transform3D & transform(const std::string &partName) const

◆ present()

bool TopLevelPlacements::present ( const std::string & partName) const

Definition at line 35 of file TopLevelPlacements.cxx.

35 {
36 // If no table present assume everything is present.
37 if (m_noTopLevelTable) return true;
38
39 return(getPart(partName) != nullptr);
40}
Part * getPart(const std::string &partName) const

◆ transform()

const GeoTrf::Transform3D & TopLevelPlacements::transform ( const std::string & partName) const

Definition at line 26 of file TopLevelPlacements.cxx.

26 {
27 Part* part = getPart(partName);
28
29 if (part) return part->transform;
30
32}
static const GeoTrf::Transform3D s_identityTransform

Member Data Documentation

◆ m_noTopLevelTable

bool TopLevelPlacements::m_noTopLevelTable
private

Definition at line 42 of file TopLevelPlacements.h.

◆ m_parts

std::map<std::string, Part *> TopLevelPlacements::m_parts
private

Definition at line 41 of file TopLevelPlacements.h.

◆ s_identityTransform

const GeoTrf::Transform3D TopLevelPlacements::s_identityTransform = GeoTrf::Transform3D::Identity()
staticprivate

Definition at line 44 of file TopLevelPlacements.h.


The documentation for this class was generated from the following files: