ATLAS Offline Software
Classes | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
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 }

◆ ~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 }

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 
58  m_parts[label] = part;
59  }
60 }

◆ 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 }

◆ 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 }

◆ 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 
31  return s_identityTransform;
32 }

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:
IRDBRecord::getInt
virtual int getInt(const std::string &fieldName) const =0
Get int field value.
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
TopLevelPlacements::transform
const GeoTrf::Transform3D & transform(const std::string &partName) const
Definition: TopLevelPlacements.cxx:26
TopLevelPlacements::m_parts
std::map< std::string, Part * > m_parts
Definition: TopLevelPlacements.h:41
PlotCalibFromCool.label
label
Definition: PlotCalibFromCool.py:78
IRDBRecord::getString
virtual const std::string & getString(const std::string &fieldName) const =0
Get string field value.
beamspotman.posX
posX
Definition: beamspotman.py:1624
TopLevelPlacements::s_identityTransform
static const GeoTrf::Transform3D s_identityTransform
Definition: TopLevelPlacements.h:44
TopLevelPlacements::partTransform
GeoTrf::Transform3D partTransform(const IRDBRecord *record) const
Definition: TopLevelPlacements.cxx:63
TopLevelPlacements::m_noTopLevelTable
bool m_noTopLevelTable
Definition: TopLevelPlacements.h:42
lumiFormat.i
int i
Definition: lumiFormat.py:92
beamspotman.posZ
posZ
Definition: beamspotman.py:1624
xAOD::rotation
rotation
Definition: TrackSurface_v1.cxx:15
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
beamspotman.posY
posY
Definition: beamspotman.py:1624
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
TopLevelPlacements::fillPlacements
void fillPlacements(const IRDBRecordset_ptr &topLevelTable)
Definition: TopLevelPlacements.cxx:43
IRDBRecord
IRDBRecord is one record in the IRDBRecordset object.
Definition: IRDBRecord.h:27
TopLevelPlacements::getPart
Part * getPart(const std::string &partName) const
Definition: TopLevelPlacements.cxx:119
DetType::Part
Part
Definition: DetType.h:14
IRDBRecord::getDouble
virtual double getDouble(const std::string &fieldName) const =0
Get double field value.
python.SystemOfUnits.degree
tuple degree
Definition: SystemOfUnits.py:106