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
AlignmentsInterna.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 includes
15 #include "DD4hep/IOV.h"
16 #include "DD4hep/Handle.inl"
17 
18 #include "DD4hep/World.h"
19 #include "DD4hep/Printout.h"
20 #include "DD4hep/InstanceCount.h"
23 
24 using namespace std;
25 using namespace DD4hep::Alignments;
26 using namespace DD4hep::Alignments::Interna;
27 
32 
34 AlignmentConditionObject::AlignmentConditionObject(const string& nam, const string& tit)
35  : ConditionObject(nam, tit), alignment_data(0)
36 {
39 }
40 
44 }
45 
48  AlignmentCondition a(this);
49  Alignment::Data& d = a.data();
50  d.trToWorld = Transform3D();
51  d.detectorTrafo.Clear();
52  d.worldTrafo.Clear();
53  d.nodes.clear();
55 }
56 
59  : NamedObject(), detector(par), keys()
60 {
62 }
63 
67 }
68 
70 void AlignmentContainer::addKey(const string& key_val) {
72  if ( !keys.insert(make_pair(hash,make_pair(hash,key_val))).second ) {
73  except("AlignmentContainer","++ Key[%08X]: %s already present. "
74  "Duplicate insertions inhibited!",hash, key_val.c_str());
75  }
76 }
77 
79 void AlignmentContainer::addKey(const string& key_val, const string& data_val) {
80  key_type key_hash = Alignment::hashCode(key_val);
81  key_type val_hash = Alignment::hashCode(data_val);
82  if ( !keys.insert(make_pair(key_hash,make_pair(val_hash,data_val))).second ) {
83  except("AlignmentContainer","++ Key[%08X]: %s already present. "
84  "Duplicate insertions inhibited!",key_hash, key_val.c_str());
85  }
86 }
87 
89 Alignment AlignmentContainer::get(const string& key_val, const iov_type& iov) {
90  AlignmentsLoader& loader = detector->world().alignmentsLoader();
92  Keys::const_iterator i=keys.find(hash);
93  if ( i != keys.end() ) {
94  const key_value& k = (*i).second;
95  return loader.get(k.first, iov);
96  }
98  return loader.get(hash, iov);
99 }
100 
103  AlignmentsLoader& loader = detector->world().alignmentsLoader();
104  Keys::const_iterator i=keys.find(hash_key);
105  if ( i != keys.end() ) {
106  const key_value& k = (*i).second;
107  return loader.get(k.first, iov);
108  }
110  return loader.get(hash_key, iov);
111 }
112 
114 Alignment AlignmentContainer::get(const string& key_val, const UserPool& pool) {
115  AlignmentsLoader& loader = detector->world().alignmentsLoader();
116  key_type hash = Alignment::hashCode(key_val);
117  Keys::const_iterator i=keys.find(hash);
118  if ( i != keys.end() ) {
119  const key_value& k = (*i).second;
120  return loader.get(k.first, pool);
121  }
123  return loader.get(hash, pool);
124 }
125 
127 Alignment AlignmentContainer::get(key_type hash_key, const UserPool& pool) {
128  AlignmentsLoader& loader = detector->world().alignmentsLoader();
129  Keys::const_iterator i=keys.find(hash_key);
130  if ( i != keys.end() ) {
131  const key_value& k = (*i).second;
132  return loader.get(k.first, pool);
133  }
135  return loader.get(hash_key, pool);
136 }
137 
140 }
141 
144 }
145 
Data & data()
Data accessor for the use of decorators.
Definition: Alignments.cpp:86
The data class behind an alignments container handle.
The data class behind an alignments handle.
TGeoHMatrix detectorTrafo
Intermediate buffer to store the transformation to the parent detector element.
The data class behind a alignments container handle.
DD4HEP_INSTANTIATE_HANDLE_NAMED(AlignmentConditionObject)
static void decrement(T *)
Decrement count according to type information.
Main handle class to hold an alignment object.
Definition: Alignments.h:65
DD4HEP_INSTANTIATE_HANDLE_UNNAMED(AlignmentData)
NodeList nodes
The list of TGeoNodes (physical placements)
Alignment get(const std::string &alignment_key, const iov_type &iov)
Access to alignment objects by key and IOV.
int except(const std::string &src, const std::string &fmt,...)
Calls the display action with ERROR and throws an std::runtime_error exception.
Definition: Printout.cpp:217
void addKey(const std::string &key_value)
Add a new key to the alignments access map.
Implementation of a named object.
Definition: NamedObject.h:31
Class describing the interval of validty.
Definition: IOV.h:59
virtual ~AlignmentsLoader()
Protected destructor.
DetElement detector
The hosting detector element.
Container::key_value key_value
Forward definition of the mapping type.
static key_type hashCode(const char *value)
Hash code generation from input string.
Definition: Alignments.h:127
unsigned int hash(unsigned int initialSeed, unsigned int eventNumber, unsigned int runNumber)
calculate hash from initialSeed, eventID and runID
AlignmentContainer(Geometry::DetElementObject *parent)
Standard constructor.
static void increment(T *)
Increment count according to type information.
Definition: InstanceCount.h:98
Main handle class to hold an alignment conditions object.
Definition: Alignments.h:142
Container::key_type key_type
Forward defintion of the key type.
Transform3D trToWorld
Transformation from volume to the world.
Data class with properties of a detector element.
ROOT::Math::Transform3D Transform3D
Definition: Objects.h:110
virtual Alignment get(key_type key, const iov_type &iov)=0
Access the alignments loading mechanism.
Derived condition data-object definition.
Keys keys
Known keys of alignments in this container.
TGeoHMatrix worldTrafo
Intermediate buffer to store the transformation to the world coordination system. ...