DD4hep - The AIDA detector description toolkit for high energy physics experiments
DD4hep  Rev:Unversioneddirectory
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AlignmentData.cpp
Go to the documentation of this file.
1 // $Id$
2 //==========================================================================
3 // AIDA Detector description implementation for LCD
4 //--------------------------------------------------------------------------
5 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
6 // All rights reserved.
7 //
8 // For the licensing terms see $DD4hepINSTALL/LICENSE.
9 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
10 //
11 // Author : M.Frank
12 //
13 //==========================================================================
14 
15 // Framework include files
16 #include "DD4hep/AlignmentData.h"
17 #include "DD4hep/MatrixHelpers.h"
18 #include "DD4hep/InstanceCount.h"
19 #include "DD4hep/Primitives.h"
20 
21 // ROOT include files
22 #include "TGeoMatrix.h"
23 #include <sstream>
24 
25 using namespace std;
26 using namespace DD4hep;
27 using namespace DD4hep::Alignments;
28 
30 Delta::Delta(const Delta& c)
31  : translation(c.translation), pivot(c.pivot), rotation(c.rotation), flags(c.flags)
32 {
33 }
34 
37 }
38 
41  if ( &c != this ) {
42  pivot = c.pivot;
44  rotation = c.rotation;
45  flags = c.flags;
46  }
47  return *this;
48 }
49 
51 void Delta::clear() {
52  flags = 0;
53  pivot = Pivot();
56 }
57 
59 ostream& operator << (ostream& s, const Delta& data) {
60  string res;
61  stringstream str;
62  str << "[" << data.translation << "," << data.rotation << "," << data.pivot << "]";
63  res = str.str();
64  for(size_t i=0; i<res.length(); ++i)
65  if ( res[i]=='\n' ) res[i] = ' ';
66  return s << res;
67 }
68 
71  : flag(0), magic(magic_word())
72 {
74 }
75 
78  : delta(copy.delta), worldTrafo(copy.worldTrafo), worldDelta(copy.worldDelta),
79  detectorTrafo(copy.detectorTrafo),
80  nodes(copy.nodes), trToWorld(copy.trToWorld), detector(copy.detector),
81  placement(copy.placement), flag(copy.flag), magic(magic_word())
82 {
84 }
85 
89 }
90 
93  if ( this != &copy ) {
94  delta = copy.delta;
95  worldTrafo = copy.worldTrafo;
97  nodes = copy.nodes;
98  trToWorld = copy.trToWorld;
99  detector = copy.detector;
100  placement = copy.placement;
101  flag = copy.flag;
102  }
103  return *this;
104 }
105 
107 ostream& operator << (ostream& s, const AlignmentData& data) {
108  stringstream str;
109  str << data.delta;
110  return s << str.str();
111 }
112 
115  Position global;
116  Double_t master_point[3] = { 0, 0, 0 }, local_point[3] = { local.X(), local.Y(), local.Z() };
117  worldTrafo.LocalToMaster(local_point, master_point);
118  global.SetCoordinates(master_point);
119  return global;
120 }
121 
123 void AlignmentData::localToWorld(const Position& local, Position& global) const {
124  Double_t master_point[3] = { 0, 0, 0 }, local_point[3] = { local.X(), local.Y(), local.Z() };
125  worldTrafo.LocalToMaster(local_point, master_point);
126  global.SetCoordinates(master_point);
127 }
128 
130 void AlignmentData::localToWorld(const Double_t local[3], Double_t global[3]) const {
131  worldTrafo.LocalToMaster(local, global);
132 }
133 
136  Position local;
137  // If the path is unknown an exception will be thrown inside worldTransformation() !
138  Double_t master_point[3] = { global.X(), global.Y(), global.Z() }, local_point[3] = { 0, 0, 0 };
139  worldTrafo.MasterToLocal(master_point, local_point);
140  local.SetCoordinates(local_point);
141  return local;
142 }
143 
145 void AlignmentData::worldToLocal(const Position& global, Position& local) const {
146  Double_t master_point[3] = { global.X(), global.Y(), global.Z() }, local_point[3] = { 0, 0, 0 };
147  worldTrafo.MasterToLocal(master_point, local_point);
148  local.SetCoordinates(local_point);
149 }
150 
152 void AlignmentData::worldToLocal(const Double_t global[3], Double_t local[3]) const {
153  worldTrafo.MasterToLocal(global, local);
154 }
155 
158  Position global;
159  Double_t master_point[3] = { 0, 0, 0 }, local_point[3] = { local.X(), local.Y(), local.Z() };
160  detectorTrafo.LocalToMaster(local_point, master_point);
161  global.SetCoordinates(master_point);
162  return global;
163 }
164 
166 void AlignmentData::localToDetector(const Position& local, Position& global) const {
167  Double_t master_point[3] = { 0, 0, 0 }, local_point[3] = { local.X(), local.Y(), local.Z() };
168  detectorTrafo.LocalToMaster(local_point, master_point);
169  global.SetCoordinates(master_point);
170 }
171 
173 void AlignmentData::localToDetector(const Double_t local[3], Double_t global[3]) const {
174  detectorTrafo.LocalToMaster(local, global);
175 }
176 
179  Position local;
180  // If the path is unknown an exception will be thrown inside worldTransformation() !
181  Double_t master_point[3] = { global.X(), global.Y(), global.Z() }, local_point[3] = { 0, 0, 0 };
182  detectorTrafo.MasterToLocal(master_point, local_point);
183  local.SetCoordinates(local_point);
184  return local;
185 }
186 
188 void AlignmentData::detectorToLocal(const Position& global, Position& local) const {
189  // If the path is unknown an exception will be thrown inside worldTransformation() !
190  Double_t master_point[3] = { global.X(), global.Y(), global.Z() }, local_point[3] = { 0, 0, 0 };
191  detectorTrafo.MasterToLocal(master_point, local_point);
192  local.SetCoordinates(local_point);
193 }
194 
196 void AlignmentData::detectorToLocal(const Double_t global[3], Double_t local[3]) const {
197  detectorTrafo.MasterToLocal(global, local);
198 }
199 
202  return detector.nominal();
203 }
204 
205 #include "DD4hep/ToStream.h"
209 
210 #include "DD4hep/BasicGrammar_inl.h"
211 DD4HEP_DEFINE_PARSER_GRAMMAR(Delta,eval_none<Delta>)
BitMask flag
Flag to remember internally calculated quatities.
TGeoHMatrix detectorTrafo
Intermediate buffer to store the transformation to the parent detector element.
std::ostream & operator<<(std::ostream &os, const DetType &t)
Definition: DetType.h:98
void detectorToLocal(const Position &detector, Position &local) const
Transformation from detector element coordinates to the local placed volume coordinates.
static void decrement(T *)
Decrement count according to type information.
void worldToLocal(const Position &global, Position &local) const
Transformation from world coordinates of the local placed volume coordinates.
AlignmentData()
Standard constructor.
void clear()
Reset information to identity.
AlignmentData & operator=(const AlignmentData &copy)
Assignment operator necessary due to copy constructor.
Main handle class to hold an alignment object.
Definition: Alignments.h:65
void copy(Alignment from, Alignment to)
Copy alignment object from source object.
TGeoShape * s
Definition: Volumes.cpp:294
NodeList nodes
The list of TGeoNodes (physical placements)
Alignment nominal() const
Access the ideal/nominal alignment/placement matrix.
DetElement detector
Reference to the next hosting detector element.
ROOT::Math::RotationZYX RotationZYX
Definition: Objects.h:98
Delta delta
Alignment changes.
const Transform3D & localToWorld() const
Access the currently applied alignment/placement matrix.
#define DD4HEP_DEFINE_PARSER_GRAMMAR(x, func)
Class describing an condition to re-adjust an alignment.
Definition: AlignmentData.h:49
ROOT::Math::XYZVector Position
Definition: Objects.h:75
static void increment(T *)
Increment count according to type information.
Definition: InstanceCount.h:98
Transform3D trToWorld
Transformation from volume to the world.
PlacedVolume placement
The subdetector placement corresponding to the actual detector element's volume.
Derived condition data-object definition.
void localToDetector(const Position &local, Position &detector) const
Transformation from local coordinates of the placed volume to the detector system.
int eval_none(T *, const std::string &)
unsigned long long int magic_word()
Access to the magic word, which is protecting some objects against memory corruptions.
Definition: Handle.h:55
TGeoHMatrix worldTrafo
Intermediate buffer to store the transformation to the world coordination system. ...
Delta & operator=(const Delta &c)
Assignment operator.
~Delta()
Default destructor.
#define DD4HEP_DEFINE_CONDITIONS_TYPE_DUMMY(x)
virtual ~AlignmentData()
Default destructor.