DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
AlignmentData.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 #ifndef DD4HEP_ALIGNMENTDATA_H
14 #define DD4HEP_ALIGNMENTDATA_H
15 
16 // Framework include files
17 #include <DD4hep/NamedObject.h>
18 #include <DD4hep/DetElement.h>
19 #include <DD4hep/Volumes.h>
20 
21 // ROOT include files
22 #include <TGeoMatrix.h>
23 
25 namespace dd4hep {
26 
27  // Forward declarations
28  class Alignment;
29  class AlignmentCondition;
30 
32 
38  class Delta {
39  public:
44  unsigned int flags = 0;
45 
47  HAVE_NONE = 0,
49  HAVE_ROTATION = 1<<3,
50  HAVE_PIVOT = 1<<4,
51  };
52 
54  Delta() = default;
56  Delta(const Position& tr)
59  Delta(const RotationZYX& rot)
62  Delta(const Position& tr, const RotationZYX& rot)
65  Delta(const Translation3D& piv, const RotationZYX& rot)
66  : pivot(piv), rotation(rot), flags(HAVE_ROTATION|HAVE_PIVOT) {}
68  Delta(const Position& tr, const Translation3D& piv, const RotationZYX& rot)
71  Delta(const Delta& c);
73  ~Delta();
75  Delta& operator=(const Delta& c);
77  void clear();
79  bool checkFlag(unsigned int mask) const { return (flags&mask) == mask; }
81  void setFlag(unsigned int mask) { flags |= mask; }
83  bool hasTranslation() const { return checkFlag(HAVE_TRANSLATION); }
85  bool hasRotation() const { return checkFlag(HAVE_ROTATION); }
87  bool hasPivot() const { return checkFlag(HAVE_PIVOT); }
89  void computeMatrix(TGeoHMatrix& tr_delta) const;
90  };
91 
93 
98  class AlignmentData {
99  public:
101  typedef unsigned int BitMask;
102 
107  HAVE_OTHER = 1<<31
108  };
109  enum DataType {
110  IDEAL = 1<<10,
111  SURVEY = 1<<11,
112  TIME_STAMPED = 1<<12
113  };
114 
118  mutable TGeoHMatrix worldTrafo;
120  mutable TGeoHMatrix detectorTrafo;
122  std::vector<PlacedVolume> nodes;
130  mutable BitMask flag;
132  unsigned int magic;
133 
134  public:
136  AlignmentData();
140  virtual ~AlignmentData();
144  inline AlignmentData& data() { return *this; }
146  Alignment nominal() const;
148  const TGeoHMatrix& worldTransformation() const { return worldTrafo; }
150  const TGeoHMatrix& detectorTransformation() const { return detectorTrafo; }
152  const Transform3D& localToWorld() const { return trToWorld; }
153 
155  void localToWorld(const Position& local, Position& global) const;
158  void localToWorld(const Double_t local[3], Double_t global[3]) const;
160  Position localToWorld(const Position& local) const;
162  Position localToWorld(const Double_t local[3]) const
163  { return localToWorld({local[0],local[1],local[2]}); }
164 
166  void worldToLocal(const Position& global, Position& local) const;
169  void worldToLocal(const Double_t global[3], Double_t local[3]) const;
171  Position worldToLocal(const Position& global) const;
173  Position worldToLocal(const Double_t global[3]) const
174  { return worldToLocal({global[0],global[1],global[2]}); }
175 
177  void localToDetector(const Position& local, Position& detector) const;
180  void localToDetector(const Double_t local[3], Double_t detector[3]) const;
182  Position localToDetector(const Position& local) const;
184  Position localToDetector(const Double_t local[3]) const
185  { return localToDetector({local[0],local[1],local[2]}); }
186 
188  void detectorToLocal(const Position& detector, Position& local) const;
191  void detectorToLocal(const Double_t detector[3], Double_t local[3]) const;
195  Position detectorToLocal(const Double_t det[3]) const
196  { return detectorToLocal({det[0],det[1],det[2]}); }
197  };
198 } /* End namespace dd4hep */
199 std::ostream& operator << (std::ostream& s, const dd4hep::Delta& data);
200 std::ostream& operator << (std::ostream& s, const dd4hep::AlignmentData& data);
201 #endif // DD4HEP_ALIGNMENTDATA_H
dd4hep::AlignmentData::HAVE_WORLD_TRAFO
@ HAVE_WORLD_TRAFO
Definition: AlignmentData.h:105
dd4hep::AlignmentData::nodes
std::vector< PlacedVolume > nodes
The list of TGeoNodes (physical placements)
Definition: AlignmentData.h:122
dd4hep::Delta::HAVE_TRANSLATION
@ HAVE_TRANSLATION
Definition: AlignmentData.h:48
dd4hep::AlignmentData::HAVE_NONE
@ HAVE_NONE
Definition: AlignmentData.h:104
dd4hep::AlignmentData::nominal
Alignment nominal() const
Access the ideal/nominal alignment/placement matrix.
Definition: AlignmentData.cpp:229
Volumes.h
dd4hep::AlignmentData::TIME_STAMPED
@ TIME_STAMPED
Definition: AlignmentData.h:112
dd4hep::Delta::Delta
Delta(const RotationZYX &rot)
Initializing constructor.
Definition: AlignmentData.h:59
dd4hep::Delta::clear
void clear()
Reset information to identity.
Definition: AlignmentData.cpp:52
dd4hep::Delta::HAVE_PIVOT
@ HAVE_PIVOT
Definition: AlignmentData.h:50
dd4hep::PlacedVolume
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:173
dd4hep::AlignmentData::AlignmentData
AlignmentData()
Standard constructor.
Definition: AlignmentData.cpp:99
dd4hep::AlignmentData::placement
PlacedVolume placement
The subdetector placement corresponding to the actual detector element's volume.
Definition: AlignmentData.h:128
dd4hep::Delta::HAVE_ROTATION
@ HAVE_ROTATION
Definition: AlignmentData.h:49
dd4hep::Delta::rotation
RotationZYX rotation
Definition: AlignmentData.h:43
dd4hep::AlignmentData::detector
DetElement detector
Reference to the next hosting detector element.
Definition: AlignmentData.h:126
dd4hep::Delta::Delta
Delta(const Position &tr)
Initializing constructor.
Definition: AlignmentData.h:56
dd4hep::AlignmentData::localToDetector
void localToDetector(const Position &local, Position &detector) const
Transformation from local coordinates of the placed volume to the detector system.
Definition: AlignmentData.cpp:194
dd4hep::AlignmentData::worldToLocal
Position worldToLocal(const Double_t global[3]) const
Transformation from local coordinates of the placed volume to the world system.
Definition: AlignmentData.h:173
dd4hep::Delta::flags
unsigned int flags
Definition: AlignmentData.h:44
dd4hep::Delta::hasRotation
bool hasRotation() const
Access flags: Check if the delta operation contains a rotation.
Definition: AlignmentData.h:85
dd4hep::Delta
Class describing an condition to re-adjust an alignment.
Definition: AlignmentData.h:38
dd4hep::Delta::hasPivot
bool hasPivot() const
Access flags: Check if the delta operation contains a pivot.
Definition: AlignmentData.h:87
dd4hep::Delta::Delta
Delta()=default
Default constructor.
dd4hep::Translation3D
ROOT::Math::Translation3D Translation3D
Definition: Objects.h:119
dd4hep::Delta::setFlag
void setFlag(unsigned int mask)
Check a given flag.
Definition: AlignmentData.h:81
dd4hep::AlignmentData::AlignmentFlags
AlignmentFlags
Definition: AlignmentData.h:103
dd4hep::DetElement
Handle class describing a detector element.
Definition: DetElement.h:188
dd4hep::AlignmentData::magic
unsigned int magic
Magic word to verify object if necessary.
Definition: AlignmentData.h:132
dd4hep::Delta::translation
Position translation
Definition: AlignmentData.h:41
dd4hep::AlignmentData::DataType
DataType
Definition: AlignmentData.h:109
dd4hep::AlignmentData::trToWorld
Transform3D trToWorld
Transformation from volume to the world.
Definition: AlignmentData.h:124
dd4hep::AlignmentData::delta
Delta delta
Alignment changes.
Definition: AlignmentData.h:116
dd4hep::Delta::pivot
Pivot pivot
Definition: AlignmentData.h:42
dd4hep::Delta::computeMatrix
void computeMatrix(TGeoHMatrix &tr_delta) const
Compute the alignment delta for one detector element and its alignment condition.
Definition: AlignmentData.cpp:60
dd4hep::Delta::Delta
Delta(const Position &tr, const RotationZYX &rot)
Initializing constructor.
Definition: AlignmentData.h:62
dd4hep::AlignmentData::flag
BitMask flag
Flag to remember internally calculated quatities.
Definition: AlignmentData.h:130
dd4hep::Alignment
Main handle class to hold an alignment object.
Definition: Alignments.h:115
dd4hep::AlignmentData
Derived condition data-object definition.
Definition: AlignmentData.h:98
dd4hep::AlignmentData::localToWorld
const Transform3D & localToWorld() const
Access the currently applied alignment/placement matrix.
Definition: AlignmentData.h:152
NamedObject.h
dd4hep::AlignmentData::detectorTrafo
TGeoHMatrix detectorTrafo
Intermediate buffer to store the transformation to the parent detector element.
Definition: AlignmentData.h:120
dd4hep::AlignmentData::SURVEY
@ SURVEY
Definition: AlignmentData.h:111
dd4hep::Delta::AlignmentFlags
AlignmentFlags
Definition: AlignmentData.h:46
dd4hep::AlignmentData::BitMask
unsigned int BitMask
Forward declaration of the utility bit mask.
Definition: AlignmentData.h:101
dd4hep::Transform3D
ROOT::Math::Transform3D Transform3D
Definition: Objects.h:117
dd4hep::Delta::hasTranslation
bool hasTranslation() const
Access flags: Check if the delta operation contains a translation.
Definition: AlignmentData.h:83
dd4hep::AlignmentData::worldTrafo
TGeoHMatrix worldTrafo
Intermediate buffer to store the transformation to the world coordination system.
Definition: AlignmentData.h:118
dd4hep::AlignmentData::operator=
AlignmentData & operator=(const AlignmentData &copy)
Assignment operator necessary due to copy constructor.
Definition: AlignmentData.cpp:121
dd4hep::AlignmentData::data
AlignmentData & data()
Data accessor for decorator.
Definition: AlignmentData.h:144
dd4hep::Position
ROOT::Math::XYZVector Position
Definition: Objects.h:81
dd4hep::AlignmentData::localToDetector
Position localToDetector(const Double_t local[3]) const
Transformation from local coordinates of the placed volume to the world system.
Definition: AlignmentData.h:184
dd4hep::AlignmentData::detectorToLocal
void detectorToLocal(const Position &detector, Position &local) const
Transformation from detector element coordinates to the local placed volume coordinates.
Definition: AlignmentData.cpp:216
dd4hep::AlignmentData::IDEAL
@ IDEAL
Definition: AlignmentData.h:110
dd4hep::AlignmentData::HAVE_PARENT_TRAFO
@ HAVE_PARENT_TRAFO
Definition: AlignmentData.h:106
DetElement.h
dd4hep::AlignmentData::detectorToLocal
Position detectorToLocal(const Double_t det[3]) const
Transformation from detector element coordinates to the local placed volume coordinates.
Definition: AlignmentData.h:195
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
det
DetElement::Object * det
Definition: AlignmentsCalculator.cpp:66
dd4hep::Delta::~Delta
~Delta()
Default destructor.
Definition: AlignmentData.cpp:37
dd4hep::AlignmentData::localToWorld
Position localToWorld(const Double_t local[3]) const
Transformation from local coordinates of the placed volume to the world system.
Definition: AlignmentData.h:162
dd4hep::AlignmentData::HAVE_OTHER
@ HAVE_OTHER
Definition: AlignmentData.h:107
dd4hep::AlignmentData::worldTransformation
const TGeoHMatrix & worldTransformation() const
Create cached matrix to transform to world coordinates.
Definition: AlignmentData.h:148
dd4hep::Delta::Delta
Delta(const Position &tr, const Translation3D &piv, const RotationZYX &rot)
Initializing constructor.
Definition: AlignmentData.h:68
dd4hep::detail::tools::copy
void copy(Alignment from, Alignment to)
Copy alignment object from source object.
Definition: AlignmentTools.cpp:43
dd4hep::RotationZYX
ROOT::Math::RotationZYX RotationZYX
Definition: Objects.h:105
dd4hep::AlignmentData::worldToLocal
void worldToLocal(const Position &global, Position &local) const
Transformation from world coordinates of the local placed volume coordinates.
Definition: AlignmentData.cpp:173
dd4hep::Delta::Pivot
Translation3D Pivot
Definition: AlignmentData.h:40
dd4hep::Delta::Delta
Delta(const Translation3D &piv, const RotationZYX &rot)
Initializing constructor.
Definition: AlignmentData.h:65
dd4hep::Delta::HAVE_NONE
@ HAVE_NONE
Definition: AlignmentData.h:47
dd4hep::AlignmentData::detectorTransformation
const TGeoHMatrix & detectorTransformation() const
Access the alignment/placement matrix with respect to the world.
Definition: AlignmentData.h:150
dd4hep::Delta::checkFlag
bool checkFlag(unsigned int mask) const
Check a given flag.
Definition: AlignmentData.h:79
dd4hep::AlignmentData::~AlignmentData
virtual ~AlignmentData()
Default destructor.
Definition: AlignmentData.cpp:116
dd4hep::Delta::operator=
Delta & operator=(const Delta &c)
Assignment operator.
Definition: AlignmentData.cpp:41
operator<<
std::ostream & operator<<(std::ostream &s, const dd4hep::Delta &data)
print alignment delta object
Definition: AlignmentData.cpp:88