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
AlignmentTools.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/IOV.h"
17 #include "DD4hep/Printout.h"
18 #include "DD4hep/MatrixHelpers.h"
19 #include "DD4hep/AlignmentTools.h"
20 #include "DD4hep/DetectorTools.h"
22 
23 // ROOT include files
24 #include "TGeoMatrix.h"
25 
30 namespace DetectorTools = DD4hep::Geometry::DetectorTools;
32 
35  Alignment::Object* f = from.ptr();
36  Alignment::Object* t = to.ptr();
37  if ( t != f ) {
38  t->flag = f->flag;
40  t->worldTrafo = f->worldTrafo;
41  t->trToWorld = f->trToWorld;
42  t->detector = f->detector;
43  t->placement = f->placement;
44  t->nodes = f->nodes;
45  t->delta = f->delta;
46  t->magic = f->magic;
47  }
48 }
49 
52  Alignment::Object* a = alignment.ptr();
53  MaskManipulator mask(a->flag);
54  DetElement parent = a->detector.parent();
55  if ( parent.isValid() ) {
57  DetectorTools::placementPath(parent, a->detector, path);
58  for (size_t i = 0, n=path.size(); n>0 && i < n-1; ++i) {
59  const PlacedVolume& p = path[i];
60  a->detectorTrafo.MultiplyLeft(p->GetMatrix());
61  a->nodes.push_back(p);
62  }
63  a->worldTrafo = parent.nominal()->worldTrafo;
64  a->worldTrafo.MultiplyLeft(&a->detectorTrafo);
66  a->placement = a->detector.placement();
67  mask.clear();
68  mask.set(AlignmentData::HAVE_PARENT_TRAFO);
69  mask.set(AlignmentData::HAVE_WORLD_TRAFO);
70  mask.set(AlignmentData::IDEAL);
71  }
72 }
73 
76  const Alignment::NodeList& node_list)
77 {
78  Alignment::Object* a = alignment.ptr();
79  MaskManipulator mask(a->flag);
80  a->nodes = node_list;
81  for (size_t i = a->nodes.size(); i > 1; --i) { // Omit the placement of the parent DetElement
82  TGeoMatrix* m = a->nodes[i - 1]->GetMatrix();
83  a->worldTrafo.MultiplyLeft(m);
84  }
85  DetElement::Object* det = a->detector.ptr();
86  if ( !a->nodes.empty() ) {
87  a->detectorTrafo = a->worldTrafo;
88  a->detectorTrafo.MultiplyLeft(a->nodes[0]->GetMatrix());
89  a->placement = node_list.back();
90  }
91  else {
92  a->placement = det->placement;
93  }
94  a->worldTrafo.MultiplyLeft(&(a->detector.nominal()->worldTrafo));
96  mask.set(AlignmentData::IDEAL);
97 }
98 
99 
102 {
103  Alignment::Object* a = alignment.ptr();
104  DetElement parent = a->detector.parent();
105  MaskManipulator mask(a->flag);
106 
107  if ( parent.isValid() ) {
109  DetectorTools::placementPath(parent, a->detector, path);
110 
111  // TODO: need to take survey corrections into account!
112 
113  for (size_t i = 0, n=path.size(); n>0 && i < n-1; ++i) {
114  const PlacedVolume& p = path[i];
115  a->detectorTrafo.MultiplyLeft(p->GetMatrix());
116  }
117  a->worldTrafo = parent.survey()->worldTrafo;
118  a->worldTrafo.MultiplyLeft(&a->detectorTrafo);
120  a->placement = a->detector.placement();
121  }
122  mask.set(AlignmentData::SURVEY);
123  //mask.clear(AlignmentData::INVALID|AlignmentData::DIRTY);
124  //mask.set(AlignmentData::VALID|AlignmentData::IDEAL);
125 }
BitMask flag
Flag to remember internally calculated quatities.
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:135
TGeoHMatrix detectorTrafo
Intermediate buffer to store the transformation to the parent detector element.
PlacedVolume placement
The subdetector placement corresponding to the actual detector element's volume.
Main handle class to hold an alignment object.
Definition: Alignments.h:65
void computeIdeal(Alignment alignment)
Compute the ideal/nominal to-world transformation from the detector element placement.
void copy(Alignment from, Alignment to)
Copy alignment object from source object.
NodeList nodes
The list of TGeoNodes (physical placements)
T * ptr() const
Access to the held object.
Definition: Handle.h:149
DD4hep::Geometry::DetElement DetElement
DetElement detector
Reference to the next hosting detector element.
unsigned int magic
Magic word to verify object if necessary.
std::vector< PlacedVolume > PlacementPath
Definition: DetectorTools.h:41
std::string placementPath(DetElement element)
Assemble the placement path from a given detector element to the world volume.
Delta delta
Alignment changes.
TGeoHMatrix * _transform(const Geometry::Transform3D &trans)
Convert a Transform3D object to a TGeoHMatrix
std::vector< PlacedVolume > NodeList
Forward definition of the nodelist leading to the world.
Definition: Alignments.h:90
AlignmentData::MaskManipulator MaskManipulator
Transform3D trToWorld
Transformation from volume to the world.
Data class with properties of a detector element.
PlacedVolume placement
The subdetector placement corresponding to the actual detector element's volume.
Derived condition data-object definition.
TGeoShape TGeoMedium * m
Definition: Volumes.cpp:294
TGeoHMatrix worldTrafo
Intermediate buffer to store the transformation to the world coordination system. ...
void computeSurvey(Alignment alignment)
Compute the survey to-world transformation.