23 using namespace DD4hep;
24 using namespace DD4hep::Alignments;
30 namespace Alignments {
44 {
return a.path() < b.path(); }
47 typedef std::map<unsigned int,size_t>
Keys;
61 if ( det.isValid() ) {
63 unsigned int key = det.
key();
68 entry.
det = det.ptr();
70 detectors.insert(std::make_pair(det, entries.size()));
71 keys.insert(std::make_pair(key, entries.size()));
72 entries.insert(entries.end(), entry);
81 except(
"AlignmentsManager",
"+++ Failed to access manager from LCDD.");
110 TGeoHMatrix& delta_to_world)
const
114 while( par.isValid() ) {
117 AlignContext::Keys::const_iterator i = new_alignments.
keys.find(par.key());
118 if ( i != new_alignments.
keys.end() ) {
121 if ( 0 == e.
valid ) {
122 compute(new_alignments, pool, par);
127 printf(
"Multiply-left ALIGNMENT %s:", det.path().c_str()); delta_to_world.Print();
128 printf(
" with ALIGN(world) %s :", par.path().c_str());
131 delta_to_world.MultiplyLeft(&align.
worldDelta);
133 printf(
" Result :"); delta_to_world.Print();
148 printf(
"Multiply-left ALIGNMENT %s:", det.path().c_str()); delta_to_world.Print();
149 printf(
" with ALIGN(world) %s :", par.path().c_str());
152 delta_to_world.MultiplyLeft(&align.
worldDelta);
154 printf(
" Result :"); delta_to_world.Print();
161 printf(
"Multiply-left ALIGNMENT %s:", det.path().c_str()); delta_to_world.Print();
162 printf(
" with NOMINAL(det) %s :", par.path().c_str());
163 par.nominal().detectorTransformation().Print();
165 delta_to_world.MultiplyLeft(&par.nominal().detectorTransformation());
167 printf(
" Result :"); delta_to_world.Print();
182 pool.compute(deps, &new_alignments);
183 for(
auto i=new_alignments.
entries.begin(); i != new_alignments.
entries.end(); ++i)
184 compute(new_alignments, pool, (*i).det);
185 for(
auto i=new_alignments.
entries.begin(); i != new_alignments.
entries.end(); ++i)
186 compute(new_alignments, pool, (*i).det);
188 std::string prev =
"-----";
189 for(
auto i=new_alignments.
detectors.begin(); i!=new_alignments.
detectors.end(); ++i) {
192 const std::string& p = det.
path();
193 size_t idx = p.find(prev);
198 printout(
s_PRINT,
"Alignment",
"Update top Node: Lvl:%d Key:%08X: %s", det.level(), det.key(), p.c_str());
205 for(
auto i=new_alignments.
detectors.begin(); i != new_alignments.
detectors.end(); ++i) {
222 switch(delta.
flags) {
245 auto k=new_alignments.
keys.find(det.key());
246 bool has_cond = (k != new_alignments.
keys.end());
249 if ( ent && ent->
valid == 1 ) {
250 printout(
DEBUG,
"ComputeAlignment",
"================ IGNORE %s (already valid)",det.path().c_str());
253 if ( ent && ent->
valid == 0 ) {
254 TGeoHMatrix tr_delta;
259 "============================== Compute transformation of %s ============================== ",
267 align.
detectorTrafo = det.nominal().detectorTransformation()*tr_delta;
270 printout(
INFO,
"ComputeAlignment",
"Level:%d Path:%s DetKey:%08X: Cond:%s key:%08X IOV:%s",
271 det.level(), det.path().c_str(), det.key(),
275 printf(
"DetectorTrafo: '%s' -> '%s' ",det.path().c_str(), det.parent().path().c_str());
276 det.nominal().detectorTransformation().Print();
277 printf(
"Delta: '%s' ",det.path().c_str()); tr_delta.Print();
278 printf(
"World-Delta: '%s' ",det.path().c_str()); align.
worldDelta.Print();
279 printf(
"Nominal: '%s' ",det.path().c_str()); det.nominal().worldTransformation().Print();
280 printf(
"Result: '%s' ",det.path().c_str()); align.
worldTrafo.Print();
304 for(
auto c=children.begin(); c!=children.end(); ++c) {
306 compute(new_alignments, pool, child);
Data & data()
Data accessor for the use of decorators.
key_type key() const
Access the hash identifier.
void destroy()
Delete the manager. Be careful: this affects all referencing handles!
Collection of condition dependencies.
The data class behind an alignments handle.
TGeoHMatrix detectorTrafo
Intermediate buffer to store the transformation to the parent detector element.
void deletePtr(T *&p)
Helper to delete objects from heap and reset the pointer. Saves many many lines of code...
void clear()
Clear the dependency container. Destroys the contained stuff.
void newEntry(DetElement det, const Dependency *dep, AlignmentCondition::Object *con)
TGeoHMatrix worldDelta
Delta transformation to the world coordination system.
std::pair< iterator, bool > insert(const Dependencies::value_type &entry)
Mini-container interface: insert element by key.
AlignmentCondition::Object * cond
static void decrement(T *)
Decrement count according to type information.
const char * yes_no(bool value)
Helper function to print booleans in format YES/NO.
Main condition object handle.
virtual ~AlignmentsManagerObject()
Default destructor.
DD4HEP_INSTANTIATE_HANDLE_NAMED(AlignmentsManagerObject)
Out version of the std auto_ptr implementation base either on auto_ptr or unique_ptr.
bool adoptDependency(Dependency *dependency) const
Adopy alignment dependency for later recalculation.
int except(const std::string &src, const std::string &fmt,...)
Calls the display action with ERROR and throws an std::runtime_error exception.
const Dependencies & knownDependencies() const
Access all known dependencies.
T * ptr() const
Access to the held object.
DD4hep::Geometry::DetElement DetElement
Condition dependency definition.
Alignment manager instance to handle alignment dependencies.
Implementation of a named object.
bool operator()(const DetElement &a, const DetElement &b) const
ROOT::Math::RotationZYX RotationZYX
Delta delta
Alignment changes.
std::vector< Entry > Entries
AlignmentsManager::Dependencies Dependencies
TGeoHMatrix * _transform(const Geometry::Transform3D &trans)
Convert a Transform3D object to a TGeoHMatrix
ConditionUpdateContext class used by the derived conditions calculation mechanism.
static PrintLevel s_PRINT
void assign(Implementation *n, const std::string &nam, const std::string &title)
Assign a new named object. Note: object references must be managed by the user.
Dependencies * dependencies
Full list of alignment dependencies.
AlignmentsManagerObject * access() const
Checked object access. Throws invalid handle runtime exception.
void compute(AlignContext &new_alignments, UserPool &pool, DetElement child) const
Compute all alignment conditions of the lower levels.
AlignmentsManagerObject()
Initializing constructor.
Class describing an condition to re-adjust an alignment.
ROOT::Math::XYZVector Position
static void newEntry(const Context ¶meter, DetElement &det, const Dependency *dep, AlignmentCondition &con)
Register new updated derived alignment during the computation step.
void compute(dd4hep_ptr< UserPool > &user_pool) const
Compute all alignment conditions of the internal dependency list.
DetElement detector
Reference to the target's detector element.
const iov_type & iov() const
Access the IOV block.
DetElement parent() const
Access to the detector elements's parent.
static void increment(T *)
Increment count according to type information.
unsigned long long int magic
AlignmentsManager()=default
Default constructor.
ROOT::Math::Translation3D Translation3D
size_t size() const
Mini-container interface: number of entries.
key_type hash
Hashed key representation.
Main handle class to hold an alignment conditions object.
Transform3D trToWorld
Transformation from volume to the world.
std::map< std::string, DetElement > Children
AlignmentsManagerObject * m_element
Single and only data member: Reference to the actual element.
Data class with properties of a detector element.
ConditionKey target
Key to the condition to be updated.
int printout(PrintLevel severity, const char *src, const char *fmt,...)
Calls the display action with a given severity level.
ROOT::Math::Transform3D Transform3D
AlignContext * all_alignments
References to all alignment possibilities known.
void to_world(AlignContext &new_alignments, UserPool &pool, DetElement det, TGeoHMatrix &mat) const
Compute the transformation from the closest detector element of the alignment to the world system...
Derived condition data-object definition.
std::string path
Full path to this detector element. May be invalid.
static void computeDelta(AlignmentCondition cond, TGeoHMatrix &tr_delta)
Compute the alignment delta for one detector element and it's alignment condition.
unsigned long long int magic_word()
Access to the magic word, which is protecting some objects against memory corruptions.
Conditions::ConditionDependency Dependency
std::map< DetElement, size_t, PathOrdering > DetectorMap
TGeoHMatrix worldTrafo
Intermediate buffer to store the transformation to the world coordination system. ...
std::map< unsigned int, size_t > Keys
std::string str() const
Create string representation of the IOV.