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
Alignments.cpp
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation for LCD
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 
14 // Framework include files
15 #include "DD4hep/AlignmentData.h"
18 
19 // C/C++ include files
20 #include <sstream>
21 
22 using namespace std;
23 using namespace DD4hep::Alignments;
24 
26 namespace DD4hep {
27 
29  namespace Alignments {
30 
31 #if defined(__APPLE__) || defined(__clang__)
32  Alignment::Alignment(const string& nam)
34  { assign(new Interna::AlignmentNamedObject(nam, "alignment"), nam, "alignment"); }
35 
37  AlignmentCondition::AlignmentCondition(const string& nam)
38  { assign(new AlignmentCondition::Object(nam, "alignment"), nam, "alignment"); }
39 #else
40  template <> Alignment::Alignment<AlignmentData>(const string& nam)
42  { assign(new AlignmentData(), nam, "alignment"); }
43 
45  template <> Alignment::Alignment<Interna::AlignmentNamedObject>(const string& nam)
46  { assign(new Interna::AlignmentNamedObject(nam, "alignment"), nam, "alignment"); }
47 
49  template <> AlignmentCondition::AlignmentCondition<Interna::AlignmentConditionObject>(const string& nam)
50  { assign(new Object(nam, "alignment"), nam, "alignment"); }
51 #endif
52  } /* End namespace Aligments */
53 } /* End namespace DD4hep */
54 
55 
57 Alignment::Processor::Processor() {
58 }
59 
61 const TGeoHMatrix& Alignment::worldTransformation() const {
62  return data().worldTransformation();
63 }
64 
66 const TGeoHMatrix& Alignment::detectorTransformation() const {
67  return data().detectorTransformation();
68 }
69 
71 const DD4hep::IOVType& AlignmentCondition::iovType() const {
72  return *(access()->iovType());
73 }
74 
76 const DD4hep::IOV& AlignmentCondition::iov() const {
77  return *(access()->iovData());
78 }
79 
81 AlignmentCondition::key_type AlignmentCondition::key() const {
82  return access()->hash;
83 }
84 
86 AlignmentCondition::Data& AlignmentCondition::data() {
87  Object* o = access();
88  if ( o->alignment_data )
89  return *(o->alignment_data);
90  Conditions::Condition c(*this);
91  o->alignment_data = c.is_bound() ? &c.get<Data>() : &c.bind<Data>();
92  o->alignment_data->condition = c;
93  return *(o->alignment_data);
94 }
95 
97 const AlignmentCondition::Data& AlignmentCondition::data() const {
98  Object* o = access();
99  if ( o->alignment_data )
100  return *(o->alignment_data);
101  Conditions::Condition c(*this);
102  o->alignment_data = c.is_bound() ? &c.get<Data>() : &c.bind<Data>();
103  o->alignment_data->condition = c;
104  return *(o->alignment_data);
105 }
106 
108 bool AlignmentCondition::is_bound() const {
109  return isValid() ? ptr()->data.is_bound() : false;
110 }
111 
113 const TGeoHMatrix& AlignmentCondition::worldTransformation() const {
114  return data().worldTransformation();
115 }
116 
118 const TGeoHMatrix& AlignmentCondition::detectorTransformation() const {
119  return data().detectorTransformation();
120 }
121 
123 Container::Processor::Processor() {
124 }
125 
127 size_t Container::numKeys() const {
128  return access()->keys.size();
129 }
130 
132 const Container::Keys& Container::keys() const {
133  Object* o = ptr();
134  if ( !o ) {
135  invalidHandleError<Container>();
136  }
137  return o->keys;
138 }
139 
141 Alignment Container::get(const string& alignment_key, const iov_type& iov) {
142  Object* o = ptr();
143  if ( o ) {
144  Alignment c = o->get(alignment_key, iov);
145  if ( c.isValid() ) {
146  return c;
147  }
148  invalidHandleError<Alignment>();
149  }
150  invalidHandleError<Container>();
151  return Alignment();
152 }
153 
155 Alignment Container::get(key_type alignment_key, const iov_type& iov) {
156  Object* o = ptr();
157  if ( o ) {
158  Alignment c = o->get(alignment_key, iov);
159  if ( c.isValid() ) {
160  return c;
161  }
162  invalidHandleError<Alignment>();
163  }
164  invalidHandleError<Container>();
165  return Alignment();
166 }
167 
169 Alignment Container::get(const string& alignment_key, const UserPool& pool) {
170  Object* o = ptr();
171  if ( o ) {
172  Alignment c = o->get(alignment_key, pool);
173  if ( c.isValid() ) {
174  return c;
175  }
176  invalidHandleError<Alignment>();
177  }
178  invalidHandleError<Container>();
179  return Alignment();
180 }
181 
183 Alignment Container::get(key_type alignment_key, const UserPool& pool) {
184  Object* o = ptr();
185  if ( o ) {
186  Alignment c = o->get(alignment_key, pool);
187  if ( c.isValid() ) {
188  return c;
189  }
190  invalidHandleError<Alignment>();
191  }
192  invalidHandleError<Container>();
193  return Alignment();
194 }
AlignmentData * alignment_data
Cached pointer to the bound conditions data, since these may be accessed very frequently.
The data class behind an alignments container handle.
The data class behind an alignments handle.
OpaqueData & data() const
Access the IOV block.
Definition: Conditions.cpp:92
Ref_t condition
Reference to the original condition object (May not be present!)
unsigned int key_type
Forward definition of the key type.
Definition: Alignments.h:155
T & bind()
Bind the data of the conditions object to a given format.
bool isValid() const
Check the validity of the object held by the handle.
Definition: Handle.h:124
T & get()
Generic getter. Specify the exact type, not a polymorph type.
bool is_bound() const
Check if object is already bound....
Definition: Conditions.h:189
Main handle class to hold an alignment object.
Definition: Alignments.h:65
Main condition object handle.
Definition: Conditions.h:70
Alignment get(const std::string &alignment_key, const iov_type &iov)
Access to alignment objects by key and IOV.
Alignment::key_type key_type
Forward definition of the key type.
Definition: Alignments.h:227
Class describing the interval of validty.
Definition: IOV.h:59
Class describing the interval of validty type.
Definition: IOV.h:33
bool is_bound() const
Check if object is already bound....
Definition: OpaqueData.h:66
std::map< key_type, key_value > Keys
Definition of the keys.
Definition: Alignments.h:233
Derived condition data-object definition.
Keys keys
Known keys of alignments in this container.