22 #include "TGeoMatrix.h"
23 #include "TGeoManager.h"
27 using namespace DD4hep;
28 using namespace DD4hep::Alignments;
34 throw runtime_error(
"DD4hep: Attempt to access invalid alignment object. [Invalid Handle]");
41 GlobalAlignment::GlobalAlignment() :
Handle<TGeoPhysicalNode>() {
52 m_element =
new TGeoPhysicalNode(path.c_str());
65 CheckHandle verify_handle(*
this);
66 return ptr()->GetLevel();
71 CheckHandle verify_handle(*
this);
72 return PlacedVolume(
ptr()->GetNode(0));
77 CheckHandle verify_handle(*
this);
78 PlacedVolume pv = PlacedVolume(
ptr()->GetNode(level));
79 if ( pv.isValid() )
return pv;
80 throw runtime_error(
"DD4hep: The object chain of "+
string(
placement().
name())+
81 " is too short. [Invalid index]");
86 CheckHandle verify_handle(*
this);
87 Int_t ind =
ptr()->GetLevel()-level_up;
89 return PlacedVolume(
ptr()->GetMother(level_up));
91 throw runtime_error(
"DD4hep: This object "+
string(
placement().
name())+
" has not enough mothers. [Invalid index]");
96 CheckHandle verify_handle(*
this);
102 CheckHandle verify_handle(*
this);
104 TGeoHMatrix*
m =
ptr()->GetMatrix(level);
105 m->LocalToMaster((Double_t*)&localPoint,(Double_t*)&result);
111 CheckHandle verify_handle(*
this);
113 TGeoHMatrix*
m =
ptr()->GetMatrix(level);
114 m->MasterToLocal((Double_t*)&globalPoint,(Double_t*)&result);
120 CheckHandle verify_handle(*
this);
126 CheckHandle verify_handle(*
this);
133 CheckHandle verify_handle(*
this);
134 TGeoPhysicalNode* n =
ptr();
136 TGeoHMatrix mat(n->GetOriginalMatrix()->Inverse());
137 mat.Multiply(n->GetNode()->GetMatrix());
144 CheckHandle verify_handle(*
this);
145 TGeoPhysicalNode* n =
ptr();
147 TGeoHMatrix mat(n->GetNode()->GetMatrix()->Inverse());
148 mat.Multiply(n->GetOriginalMatrix());
Transform3D toMother(int level=-1) const
Access the currently applied alignment/placement matrix with respect to mother volume.
Transform3D delta() const
Access the currently applied correction matrix (delta) (mother to daughter)
const char * name() const
Access the object name (or "" if not supported by the object)
bool isValid() const
Check the validity of the object held by the handle.
Transform3D toGlobal(int level=-1) const
Access the currently applied alignment/placement matrix with respect to the world.
Transform3D nominal() const
Access the currently applied alignment/placement matrix (mother to daughter)
Main handle class to hold a TGeo alignment object of type TGeoPhysicalNode.
int numNodes() const
Number of nodes in this branch (=depth of the placement hierarchy from the top level volume) ...
PlacedVolume motherPlacement(int level_up=1) const
Access the placement of the mother of this node.
T * ptr() const
Access to the held object.
Transform3D invDelta() const
Access the inverse of the currently applied correction matrix (delta) (mother to daughter) ...
TGeoHMatrix * _transform(const Geometry::Transform3D &trans)
Convert a Transform3D object to a TGeoHMatrix
Geometry::Position Position
GlobalAlignment()
Default constructor.
Geometry::Transform3D Transform3D
PlacedVolume placement() const
Access the placement of this node.
Handle: a templated class like a shared pointer, which allows specialized access to tgeometry objects...
GlobalAlignment & operator=(const GlobalAlignment &c)
Assignment operator.
Position globalToLocal(const Position &globalPoint, int level=-1) const
Transform a point from global coordinates to local coordinates of a given level.
PlacedVolume nodePlacement(int level=-1) const
Access the placement of a node in the chain of placements for this branch.
TGeoPhysicalNode * m_element
Single and only data member: Reference to the actual element.