diff --git a/DDAlign/include/DDAlign/AlignmentsCalib.h b/DDAlign/include/DDAlign/AlignmentsCalib.h index 9de039399bc4bb6e51ee7fe43ed6b86d5850b9c1..ec236622310c8c619a55c4d5da348cafdb18f91b 100644 --- a/DDAlign/include/DDAlign/AlignmentsCalib.h +++ b/DDAlign/include/DDAlign/AlignmentsCalib.h @@ -71,22 +71,25 @@ namespace DD4hep { Delta delta; Descriptor* source = 0; Descriptor* target = 0; + DetElement detector; + Entry* parent = 0; int dirty = 0; + std::set<Entry*> children; Entry() = default; - Entry(const Entry& c) = default; - Entry(Descriptor* s, Descriptor* d) : delta(), source(s), target(d), dirty(0) {} - Entry(Descriptor* s, Descriptor* d, const Delta& del) : delta(del), source(s), target(d), dirty(0) {} - Entry& operator=(const Entry& c) = default; + Entry(const Entry& c) = delete; + Entry& operator=(const Entry& c) = delete; }; - typedef std::map<key_type,Entry*> UsedConditions; + typedef std::map<key_type,Entry*> UsedConditions; + typedef std::map<key_type,Entry*> UsedEntry; + typedef std::map<DetElement,UsedEntry> UsedDetectors; public: LCDD& lcdd; /// Reference to the alignment manager object Slice& slice; UsedConditions used; + AlignmentsManager alignManager; AlignmentsUpdateCall* derivationCall = 0; - AlignmentsUpdateCall* propagationCall = 0; protected: /// Propagate all Delta parameters to the source conditions @@ -97,7 +100,7 @@ namespace DD4hep { AlignmentsManager::Result computeDependencies(); /// Implementation: Add a new entry to the transaction list - key_type _insert(const std::pair<Condition::key_type,Entry*>& e); + std::pair<key_type,Entry*> _insert(const std::pair<Condition::key_type,Entry*>& e); /// Implementation: Register newly created condition to user-pool, slice and manager Condition _register(Condition cond) const; /// Implementation: Add a new raw(delta)-condition to the transaction stack. @@ -106,7 +109,9 @@ namespace DD4hep { Condition _create_target(DetElement detector, key_type key, const std::string& nam) const; /// Implementation: Add a new entry to the transaction stack. - key_type _use(AlignmentCondition alignment); + std::pair<key_type,Entry*> _use(DetElement detector, AlignmentCondition alignment); + /// Implementation: Add a new entry to the transaction stack. + std::pair<key_type,Entry*> _use(DetElement detector, const std::string& alignment); public: @@ -137,7 +142,7 @@ namespace DD4hep { * * The resulting alignment key is returned to the client. If NULL: Failure */ - key_type use(Alignment alignment); + key_type use(DetElement detector, Alignment alignment); /// (2) Add a new entry to an existing DetElement structure. /** @@ -155,7 +160,7 @@ namespace DD4hep { * * 2) an AlignmentCondition object is added to the * ConditionsManager's repository and the used ConditionsSlice. - * Hereby as a name 'align_name' is used. + * Hereby as a name 'align_name' = 'name'+"/Transformations" is used. * If empty, the default results to: align_name = name+"/Transformations". * * Then for align_name: @@ -173,12 +178,12 @@ namespace DD4hep { * * The resulting alignment key is returned to the client. If NULL: Failure */ - key_type use(DetElement detector, const std::string& name, const std::string& align_name=""); + key_type use(DetElement detector, const std::string& name); /// (3) Add a new entry to an existing DetElement structure. /** * Shortcut call equivalent to: - * key_type use(detector, detector.path()+"#alignment","") + * key_type use(detector, detector.path()+"#alignment") * * The alignment key is returned to the client. If NULL: Failure */ @@ -188,13 +193,16 @@ namespace DD4hep { /** * The alignment key is returned to the client. If NULL: Failure */ - key_type use(const std::string& detector, const std::string& name, const std::string& align_name=""); + key_type use(const std::string& detector, const std::string& name); /// (5) Add a new entry to an existing DetElement structure. /** * The alignment key is returned to the client. If NULL: Failure */ key_type use(const std::string& detector); + + /// Complete the setup procedure + bool start(); /// Set a new delta value in the transaction stack. /** Note: has no effect on the real alignment conditions diff --git a/DDAlign/include/DDAlign/AlignmentsManager.h b/DDAlign/include/DDAlign/AlignmentsManager.h index 2e609a6129e87fc6cd65f1985266afea82592645..764e70d2ae3eb6390372aceb12a71306e1f868e0 100644 --- a/DDAlign/include/DDAlign/AlignmentsManager.h +++ b/DDAlign/include/DDAlign/AlignmentsManager.h @@ -55,7 +55,9 @@ namespace DD4hep { typedef Conditions::ConditionUpdateContext Context; /// Alignments re-use conditions dependency definition from the conditions manager typedef Conditions::ConditionDependency Dependency; - + /// Alignments re-use the dependency collections + typedef Conditions::ConditionsDependencyCollection Dependencies; + /// Result of a computation call to the alignments manager /** * \author M.Frank @@ -102,9 +104,10 @@ namespace DD4hep { void destroy(); /// Compute all alignment conditions of the internal dependency list Result compute(Slice& slice) const; + /// Compute all alignment conditions of the internal dependency list + Result compute(Slice& slice, const Dependencies& dependencies) const; /// Register new updated derived alignment during the computation step static void newEntry(const Context& parameter, - DetElement& det, const Dependency* dep, AlignmentCondition& con); }; @@ -123,6 +126,7 @@ namespace DD4hep { typedef AlignmentsManager::Pool Pool; typedef AlignmentsManager::Slice Slice; typedef AlignmentsManager::Result Result; + typedef AlignmentsManager::Dependencies Dependencies; protected: /// Compute the transformation from the closest detector element of the alignment to the world system @@ -137,6 +141,8 @@ namespace DD4hep { virtual ~AlignmentsManagerObject(); /// Compute all alignment conditions of the internal dependency list Result compute(Slice& slice) const; + /// Compute all alignment conditions of the internal dependency list + Result compute(Slice& slice, const Dependencies& dependencies) const; }; } /* End namespace Geometry */ diff --git a/DDAlign/src/AlignmentsCalib.cpp b/DDAlign/src/AlignmentsCalib.cpp index 07d7dcf74e342431b79e62fa66d0638df572e126..839154cb793bc158ac683e84527c5e6ed03daaf2 100644 --- a/DDAlign/src/AlignmentsCalib.cpp +++ b/DDAlign/src/AlignmentsCalib.cpp @@ -13,6 +13,7 @@ // Framework includes #include "DDAlign/AlignmentsCalib.h" +#include "DDAlign/AlignmentsManager.h" #include "DDAlign/AlignmentsUpdateCall.h" #include "DD4hep/Printout.h" @@ -20,8 +21,10 @@ #include "DD4hep/Alignments.h" #include "DD4hep/DetConditions.h" #include "DD4hep/DetectorTools.h" +#include "DD4hep/DetectorProcessor.h" #include "DDCond/ConditionsPool.h" #include "DDCond/ConditionsSlice.h" +#include "DDCond/ConditionsDependencyCollection.h" #include "DD4hep/objects/AlignmentsInterna.h" using namespace std; @@ -33,12 +36,63 @@ using Conditions::ConditionsPool; using Conditions::ConditionsSlice; using Conditions::ConditionsManager; using Conditions::ConditionDependency; +using Conditions::ConditionsDependencyCollection; +typedef Conditions::ConditionUpdateCall UpdateCall; +// ====================================================================================== +namespace { + struct CalibCallback : public Geometry::DetectorProcessor { + typedef AlignmentsCalib::Entry Entry; + AlignmentsCalib& calib; + Entry& entry; + /// Standard constructor + CalibCallback(AlignmentsCalib& c, Entry& e) : calib(c), entry(e) { } + /// Default destructor + virtual ~CalibCallback() = default; + }; + struct CallbackAttach : public CalibCallback { + /// Standard constructor + CallbackAttach(AlignmentsCalib& c, Entry& e) : CalibCallback(c,e) { } + /// Dump method. + virtual int operator()(DetElement de,int /* level */) { + if ( entry.detector.ptr() != de.ptr() ) { + calib.use(de); + } + return 1; + } + }; + + struct ConnectChildren : public CalibCallback { + /// Standard constructor + ConnectChildren(AlignmentsCalib& c, Entry& e) : CalibCallback(c,e) { } + /// Dump method. + virtual int operator()(DetElement de,int /* level */) { + if ( entry.detector.ptr() == de.parent().ptr() ) { + Entry* child = 0;///TODO + entry.children.insert(child); + } + return 1; + } + }; + + struct Callback_SetDirty : public CalibCallback { + /// Standard constructor + Callback_SetDirty(AlignmentsCalib& c, Entry& e) : CalibCallback(c,e) { } + /// Dump method. + virtual int operator()(DetElement de,int /* level */) { + if ( entry.detector.ptr() == de.ptr() ) { + } + return 1; + } + + }; +} // ====================================================================================== /// Initializing constructor AlignmentsCalib::AlignmentsCalib(LCDD& l, Slice& s) : lcdd(l), slice(s), derivationCall(0) { + alignManager = AlignmentsManager::from(lcdd); } /// Default destructor @@ -46,18 +100,20 @@ AlignmentsCalib::~AlignmentsCalib() { } /// Add a new entry to the transaction list -AlignmentsCalib::key_type AlignmentsCalib::_insert(const pair<Condition::key_type,Entry*>& e) { +pair<AlignmentsCalib::key_type,AlignmentsCalib::Entry*> +AlignmentsCalib::_insert(const pair<Condition::key_type,Entry*>& e) { auto res = used.insert(e); - if ( res.second ) return (*res.first).first; - return 0; + if ( res.second ) return (*res.first); + return make_pair(0,(Entry*)0); } /// Add a new entry to the transaction stack. -AlignmentsCalib::key_type AlignmentsCalib::_use(AlignmentCondition alignment_condition) { +pair<AlignmentsCalib::key_type,AlignmentsCalib::Entry*> +AlignmentsCalib::_use(DetElement detector, AlignmentCondition alignment_condition) { key_type tar_key = alignment_condition.key(); UsedConditions::iterator i = used.find(tar_key); if ( i != used.end() ) { - return (*i).first; + return (*i); } dd4hep_ptr<Entry> entry(new Entry()); @@ -87,20 +143,83 @@ AlignmentsCalib::key_type AlignmentsCalib::_use(AlignmentCondition alignment_con entry->source = (*is).second; /// Check for the derived conditions entry Proxy::const_iterator ip = slice.derived().find(tar_key); - if ( ip == slice.derived().end() ) { - if ( derivationCall ) { - Conditions::DependencyBuilder b(ConditionKey(align_cond.name(),align_cond.key()),derivationCall); - b.add(ConditionKey(src_cond.name(),src_cond.key())); - slice.insert(b.release()); - ip = slice.derived().find(tar_key); + if ( ip == slice.derived().end() && derivationCall ) { + ConditionKey key(align_cond.name(),align_cond.key()); + Conditions::DependencyBuilder b(key,derivationCall,detector); + b.add(ConditionKey(src_cond.name(),src_cond.key())); + slice.insert(b.release()); + ip = slice.derived().find(tar_key); + } + else if ( derivationCall ) { + UpdateCall* call = (*ip).second->dependency->callback; + if ( call ) call->release(); + (*ip).second->dependency->callback = derivationCall->addRef(); + } + else { + except("AlignmentsCalib","++ The dependency rule for [%p] %s cannot be added [no callback].", + (void*)tar_key, align_cond.name()); + } + entry->target = (*ip).second; + entry->detector = detector; + return _insert(make_pair(tar_key,entry.release())); +} + +/// Implementation: Add a new entry to the transaction stack. +pair<AlignmentsCalib::key_type,AlignmentsCalib::Entry*> +AlignmentsCalib::_use(DetElement detector,const string& src_nam) { + UserPool* pool = slice.pool.get(); + string align_nam = "Transformations"; + string tar_nam = src_nam+"/"+align_nam; + key_type tar_key = ConditionKey::hashCode(tar_nam); + key_type src_key = ConditionKey::hashCode(src_nam); + Condition src_cond = pool->get(src_key); + + UsedConditions::iterator i = used.find(tar_key); + if ( i != used.end() ) { + return (*i); + } + + if ( !src_cond.isValid() ) { + /// Try to create a new condition and register it to the conditions manager from the delta value. + src_cond = _create_source(src_key, src_nam); + /// Now check again if we succeeded. + if ( !src_cond.isValid() ) { + except("AlignmentsCalib","++ The SOURCE alignment condition [%p]: %s is invalid.", + (void*)src_key, src_nam.c_str()); } - else { - except("AlignmentsCalib","++ The dependency rule for [%p] %s cannot be added [no callback].", - (void*)tar_key, align_cond.name()); + // Add the conditons keys to the detector element: + Conditions::DetConditions conditions(detector); + Conditions::Container cond_cont = conditions.conditions(); + cond_cont.insertKey(src_nam); + } + + /// This may be the derived condition: check presence + AlignmentCondition align_cond = pool->get(tar_key); + if ( !align_cond.isValid() ) { + /// Try to create a new condition and register it to the conditions manager from the delta value. + align_cond = _create_target(detector, tar_key, tar_nam); + /// Now check again if we succeeded. + if ( !align_cond.isValid() ) { + except("AlignmentsCalib","++ The DERIVED alignment condition [%p]: %s is invalid.", + (void*)tar_key, tar_nam.c_str()); } + // Add the conditons keys to the detector element: + Conditions::DetConditions conditions(detector); + Conditions::Container cond_cont = conditions.conditions(); + cond_cont.insertKey("Alignment", tar_nam); + cond_cont.insertKey(tar_nam); + + // Add the corresponding alignment keys: + DetAlign da(detector); + Alignments::Container align_cont = da.alignments(); + align_cont.insertKey("Alignment",tar_nam); + align_cont.insertKey(tar_nam); } - entry->target = (*ip).second; - return _insert(make_pair(tar_key,entry.release())); + align_cond->source_key = src_key; + + // Now all pre-conditions should be satisfied. + // Add the entry the usual way. This should also check everything again. + return _use(detector, align_cond); } /// Registers a new condition to the conditions manager. Throws exception on failure @@ -131,7 +250,7 @@ Condition AlignmentsCalib::_create_source(key_type key, Condition cond(nam,"alignment"); cond.bind<Delta>(); cond->setFlag(Condition::ALIGNMENT); - cond->validate(); + //cond->validate(); cond->hash = key; return _register(cond); } @@ -145,70 +264,23 @@ Condition AlignmentsCalib::_create_target(DetElement detector, AlignmentData& data = Condition(cond).get<AlignmentData>(); data.detector = detector; cond->setFlag(Condition::ALIGNMENT_DERIVED); - cond->invalidate(); + //cond->invalidate(); cond->hash = key; return _register(cond); } /// (1) Add a new entry to the transaction stack. -AlignmentsCalib::key_type AlignmentsCalib::use(Alignment alignment) { +AlignmentsCalib::key_type AlignmentsCalib::use(DetElement detector, Alignment alignment) { AlignmentCondition cond = alignment.condition(); + detector.access(); // Throw exception if invalid. cond.access(); // Throw exception if invalid. - return _use(cond); + return _use(detector, cond).first; } /// (2) Add a new entry to an existing DetElement structure. -AlignmentsCalib::key_type AlignmentsCalib::use(DetElement detector, - const string& src_nam, - const string& align_nam) -{ - UserPool* pool = slice.pool.get(); - key_type src_key = ConditionKey::hashCode(src_nam); - Condition src_cond = pool->get(src_key); - - if ( !src_cond.isValid() ) { - /// Try to create a new condition and register it to the conditions manager from the delta value. - src_cond = _create_source(src_key, src_nam); - /// Now check again if we succeeded. - if ( !src_cond.isValid() ) { - except("AlignmentsCalib","++ The SOURCE alignment condition [%p]: %s is invalid.", - (void*)src_key, src_nam.c_str()); - } - // Add the conditons keys to the detector element: - Conditions::DetConditions conditions(detector); - Conditions::Container cond_cont = conditions.conditions(); - cond_cont.insertKey(src_nam); - } - - /// This may be the derived condition: check presence - string tar_nam = align_nam.empty() ? src_nam+"/Transformations" : align_nam; - key_type tar_key = ConditionKey::hashCode(tar_nam); - AlignmentCondition align_cond = pool->get(tar_key); - if ( !align_cond.isValid() ) { - /// Try to create a new condition and register it to the conditions manager from the delta value. - align_cond = _create_target(detector, tar_key, tar_nam); - /// Now check again if we succeeded. - if ( !align_cond.isValid() ) { - except("AlignmentsCalib","++ The DERIVED alignment condition [%p]: %s is invalid.", - (void*)tar_key, tar_nam.c_str()); - } - // Add the conditons keys to the detector element: - Conditions::DetConditions conditions(detector); - Conditions::Container cond_cont = conditions.conditions(); - cond_cont.insertKey("Alignment", tar_nam); - cond_cont.insertKey(tar_nam); - - // Add the corresponding alignment keys: - DetAlign da(detector); - Alignments::Container align_cont = da.alignments(); - align_cont.insertKey("Alignment",tar_nam); - align_cont.insertKey(tar_nam); - } - align_cond->source_key = src_key; - - // Now all pre-conditions should be satisfied. - // Add the entry the usual way. This should also check everything again. - return _use(align_cond); +AlignmentsCalib::key_type +AlignmentsCalib::use(DetElement detector,const string& src_nam) { + return _use(detector, src_nam).first; } /// (3) Add a new entry to an existing DetElement structure. @@ -222,12 +294,11 @@ AlignmentsCalib::key_type AlignmentsCalib::use(DetElement detector) { } /// (4) Add a new entry to an existing DetElement structure. -AlignmentsCalib::key_type AlignmentsCalib::use(const std::string& detector, - const string& src_nam, - const string& align_nam) { +AlignmentsCalib::key_type +AlignmentsCalib::use(const std::string& detector, const string& src_nam) { DetElement det(Geometry::DetectorTools::findElement(lcdd,detector)); if ( det.isValid() ) { - return use(det, src_nam, align_nam); + return use(det, src_nam); } invalidHandleError<DetElement>(); return 0; @@ -243,6 +314,28 @@ AlignmentsCalib::key_type AlignmentsCalib::use(const std::string& detector) { return 0; } +/// Update Dependencies between the source conditions and the computations +bool AlignmentsCalib::start() { + UsedConditions temp(used); // Need temporary copy. this->used is not stable! + // As long as we do not add new conditions, the old entries are still valid and present. + for ( const auto& entry : temp ) { + CallbackAttach(*this,*entry.second).process(entry.second->detector,0,true); + } + + // To optimize the lookup we have to enable the parent chain for the entries + for ( auto& ent : used ) { + const DetElement::Object* ptr = ent.second->detector.parent().ptr(); + for ( auto& ee : used ) { + Entry* e = ee.second; + if ( e->detector.ptr() == ptr ) { + e->children.insert(ent.second); + ent.second->parent = e; + } + } + } + return true; +} + /// Clear all delta data in the caches transaction stack. void AlignmentsCalib::clearDeltas() { if ( !used.empty() ) { @@ -280,39 +373,50 @@ bool AlignmentsCalib::setDelta(const ConditionKey& key, const Delta& delta) { /// Propagate all Delta parameters to the source conditions bool AlignmentsCalib::propagateDeltas() { UserPool* pool = slice.pool.get(); - for ( const auto& entry : used ) { - const Entry* e = entry.second; - - /// Invalidate the target condition to trigger the computation. - Condition tar_cond = pool->get(e->target->key.hash); - if ( !tar_cond.isValid() ) { - except("AlignmentsCalib","++ The DERIVED alignment condition [%p]: %s is invalid.", - (void*)e->target->key.hash, e->target->key.name.c_str()); + for ( auto& entry : used ) { + Entry* e = entry.second; + if ( e->dirty ) { + /// Update the source condition with the new delta value + Condition src_cond = pool->get(e->source->key.hash); + if ( !src_cond.isValid() ) { + except("AlignmentsCalib","++ The SOURCE alignment condition [%p]: %s is invalid.", + (void*)e->source->key.hash, e->source->key.name.c_str()); + } + src_cond.get<Delta>() = e->delta; } - tar_cond->invalidate(); - - /// Update the source condition with the new delta value - Condition src_cond = pool->get(e->source->key.hash); - if ( !src_cond.isValid() ) { - except("AlignmentsCalib","++ The SOURCE alignment condition [%p]: %s is invalid.", - (void*)e->source->key.hash, e->source->key.name.c_str()); - } - src_cond.get<Delta>() = e->delta; - src_cond->validate(); } return true; } +void set_children_dirty(AlignmentsCalib::Entry* entry) { + for ( auto& e : entry->children ) { + if ( !e->dirty ) + set_children_dirty(e); + if ( e->dirty ) + printout(INFO,"SetDirty"," detector: %s --> %s",entry->detector.path().c_str(), e->detector.name()); + e->dirty = 1; + } +} + /// Update Dependencies between the source conditions and the computations bool AlignmentsCalib::updateDependencies() { - // As long as we do not add new conditions, the old entries are still valid and present. + // To optimize the lookup we have to enable the parent chain for the entries + for ( auto& e : used ) { + if ( e.second->dirty ) + set_children_dirty(e.second); + } return true; } /// Compute all dependent conditions from the Delta parameters AlignmentsManager::Result AlignmentsCalib::computeDependencies() { - AlignmentsManager mgr; - return mgr.compute(slice); + ConditionsDependencyCollection deps; + for ( auto& e : used ) { + if ( e.second->dirty ) { + deps.insert(e.second->target->dependency); + } + } + return alignManager.compute(slice, deps); } /// Commit all pending transactions. Returns number of altered entries @@ -324,4 +428,3 @@ AlignmentsManager::Result AlignmentsCalib::commit() { } return AlignmentsManager::Result(); } - diff --git a/DDAlign/src/AlignmentsForward.cpp b/DDAlign/src/AlignmentsForward.cpp index c79df3961e801ddce3195ed46a3d4f9f0f27ff01..f6ba2318c293a3c269bf0cef4d2689ab88c8ee3e 100644 --- a/DDAlign/src/AlignmentsForward.cpp +++ b/DDAlign/src/AlignmentsForward.cpp @@ -54,9 +54,9 @@ int AlignmentsForward::processElement(DetElement de) { // It is slow and deprecated. The access using the UserPool directly // is highly favored. // - align.alignments().addKey(k.name); + align.alignments().insertKey(k.name); if ( haveAlias && !alias.empty() ) { - align.alignments().addKey("Alignment",k.name); + align.alignments().insertKey("Alignment",k.name); } // // Now add the dependency to the alignmant manager diff --git a/DDAlign/src/AlignmentsManager.cpp b/DDAlign/src/AlignmentsManager.cpp index 16169a366d19adb4f83e14622e0b9db16302e8a1..f6d5e52dd900799f8402fbdeebc876d1dbfce7e4 100644 --- a/DDAlign/src/AlignmentsManager.cpp +++ b/DDAlign/src/AlignmentsManager.cpp @@ -64,7 +64,8 @@ namespace DD4hep { ~AlignContext() { InstanceCount::decrement(this); } - void newEntry(DetElement det, const Dependency* dep, AlignmentCondition::Object* con) { + void newEntry(const Dependency* dep, AlignmentCondition::Object* con) { + DetElement det = dep->detector; if ( det.isValid() ) { Entry entry; unsigned int key = det.key(); @@ -77,7 +78,9 @@ namespace DD4hep { detectors.insert(std::make_pair(det, entries.size())); keys.insert(std::make_pair(key, entries.size())); entries.insert(entries.end(), entry); + return; } + except("AlignContext","Failed to add entry: invalid detector handle!"); } }; @@ -94,8 +97,8 @@ namespace DD4hep { DD4HEP_INSTANTIATE_HANDLE_NAMED(AlignmentsManagerObject); -static PrintLevel s_PRINT = WARNING; -//static PrintLevel s_PRINT = INFO; +//static PrintLevel s_PRINT = WARNING; +static PrintLevel s_PRINT = INFO; /// Initializing constructor AlignmentsManagerObject::AlignmentsManagerObject() : NamedObject() { @@ -215,25 +218,11 @@ static void computeDelta(AlignmentCondition cond, TGeoHMatrix& tr_delta) { } } -#if 0 /// Compute all alignment conditions of the internal dependency list -AlignmentsManager::Result AlignmentsManagerObject::compute(Pool& pool) const { - return compute(pool, *dependencies); -} -#endif - -/// Compute all alignment conditions of the specified dependency list -AlignmentsManager::Result AlignmentsManagerObject::compute(Slice& slice) const { +AlignmentsManager::Result +AlignmentsManagerObject::compute(Slice& slice, const Dependencies& dependencies) const { Result result; AlignContext new_alignments; - ConditionsDependencyCollection deps; - - for(const auto& d : slice.derived() ) { - ConditionDependency* dep = d.second->dependency; - if ( dep ) { - deps.insert(dep); - } - } new_alignments.entries.reserve(slice.derived().size()); // // This here is the main difference compared to other derived conditions: @@ -245,7 +234,7 @@ AlignmentsManager::Result AlignmentsManagerObject::compute(Slice& slice) const // For this reason also ALL specific update calls must base themself in the // Alignment update callback. // - slice.pool->compute(deps, &new_alignments, true); + slice.pool->compute(dependencies, &new_alignments, true); for(auto i=new_alignments.entries.begin(); i != new_alignments.entries.end(); ++i) { Result r = compute(new_alignments, *slice.pool, (*i).det); result.computed += r.computed; @@ -254,6 +243,19 @@ AlignmentsManager::Result AlignmentsManagerObject::compute(Slice& slice) const return result; } +/// Compute all alignment conditions of the specified dependency list +AlignmentsManager::Result +AlignmentsManagerObject::compute(Slice& slice) const { + ConditionsDependencyCollection deps; + for(const auto& d : slice.derived() ) { + ConditionDependency* dep = d.second->dependency; + if ( dep ) { + deps.insert(dep); + } + } + return compute(slice, deps); +} + /// Compute all alignment conditions of the lower levels AlignmentsManager::Result AlignmentsManagerObject::compute(AlignContext& new_alignments, UserPool& pool, DetElement det) const { @@ -345,36 +347,23 @@ void AlignmentsManager::destroy() { /// Compute all alignment conditions of the internal dependency list AlignmentsManager::Result AlignmentsManager::compute(Slice& slice) const { - Object* o = access(); - return o->compute(slice); -} - -#if 0 -/// Compute all alignment conditions of the specified dependency list -AlignmentsManager::Result AlignmentsManager::compute(Slice& slice, const Dependencies& deps) const { - return access()->compute(*slice.pool, deps); + return access()->compute(slice); } /// Compute all alignment conditions of the internal dependency list -AlignmentsManager::Result AlignmentsManager::compute(Pool& pool) const { - Object* o = access(); - return o->compute(pool, *(o->dependencies)); +AlignmentsManager::Result +AlignmentsManager::compute(Slice& slice, const Dependencies& dependencies) const { + return access()->compute(slice, dependencies); } -/// Compute all alignment conditions of the specified dependency list -AlignmentsManager::Result AlignmentsManager::compute(Pool& pool, const Dependencies& deps) const { - return access()->compute(pool, deps); -} -#endif /// Register new updated derived alignment during the computation step void AlignmentsManager::newEntry(const Context& context, - DetElement& det, const Dependency* dep, AlignmentCondition& con) { // It must be ensured this is a valid object! Check magic word AlignContext* o = static_cast<AlignContext*>(context.parameter); if ( o && o->magic == magic_word() ) { - o->newEntry(det, dep, con.ptr()); + o->newEntry(dep, con.ptr()); return; } } diff --git a/DDAlign/src/AlignmentsUpdateCall.cpp b/DDAlign/src/AlignmentsUpdateCall.cpp index e10fda0d28ea7a485002bb0662dd01c702361f62..1c181e3c7c332ff89757f37066dc664f85b89d90 100644 --- a/DDAlign/src/AlignmentsUpdateCall.cpp +++ b/DDAlign/src/AlignmentsUpdateCall.cpp @@ -64,7 +64,7 @@ AlignmentsUpdateCall::handle(const ConditionKey& key, // are present in a second pass. This is necessary, because the parent information // may actually be supplied also 'later'. // - AlignmentsManager::newEntry(ctxt, data.detector, &ctxt.dependency, target); + AlignmentsManager::newEntry(ctxt, &ctxt.dependency, target); return target; } diff --git a/DDCond/include/DDCond/ConditionsSelectors.h b/DDCond/include/DDCond/ConditionsSelectors.h index 61cb8b08fd32f518f32b85a10debac8aa95d9c6c..ccb394ec2afa20c53eb30d41200a23d270e00d28 100644 --- a/DDCond/include/DDCond/ConditionsSelectors.h +++ b/DDCond/include/DDCond/ConditionsSelectors.h @@ -88,7 +88,7 @@ namespace DD4hep { T& collection; ActiveSelect(T& p) : collection(p) {} bool operator()(object_t* o) const { - if ( (o->flags & cond_t::ACTIVE) ) { + if ( (o->flags & Condition::ACTIVE) ) { collection.insert(collection.end(),o); return true; } diff --git a/DDCond/src/ConditionsDependencyHandler.cpp b/DDCond/src/ConditionsDependencyHandler.cpp index 4f2c5fa59b6f2a48a43c2738da2386b1cf0f101f..77226e634dc6562e609b3f123b46daefb281e58d 100644 --- a/DDCond/src/ConditionsDependencyHandler.cpp +++ b/DDCond/src/ConditionsDependencyHandler.cpp @@ -76,7 +76,7 @@ ConditionsDependencyHandler::do_callback(const ConditionDependency& dep) const if ( obj ) { if ( !obj->hash ) obj->hash = ConditionKey::hashCode(obj->name); cond->setFlag(Condition::DERIVED); - cond->validate(); + //cond->validate(); cond->iov = m_pool.validityPtr(); // Must IMMEDIATELY insert to handle inter-dependencies. ++num_callback; diff --git a/DDCond/src/Type1/Manager_Type1.cpp b/DDCond/src/Type1/Manager_Type1.cpp index e7cc94d03dd26c852f83bff10cc91d429310603f..99a94db9fc8a3d32ff0f5d74b28fab57c8d8e7a1 100644 --- a/DDCond/src/Type1/Manager_Type1.cpp +++ b/DDCond/src/Type1/Manager_Type1.cpp @@ -258,6 +258,7 @@ bool Manager_Type1::registerUnlocked(ConditionsPool* pool, Condition cond) { if ( pool && cond.isValid() ) { cond->pool = pool; cond->iov = pool->iov; + cond->setFlag(Condition::ACTIVE); pool->insert(cond); __callListeners(m_onRegister, &ConditionsListener::onRegisterCondition, cond); return true; diff --git a/DDCond/src/plugins/ConditionsRepositoryParser.cpp b/DDCond/src/plugins/ConditionsRepositoryParser.cpp index 69eb3a8fb7bb384c7601fd1eb939cb0c9a9f94b7..719353b03782099222403b2a0601ea2c9fbd5d8e 100644 --- a/DDCond/src/plugins/ConditionsRepositoryParser.cpp +++ b/DDCond/src/plugins/ConditionsRepositoryParser.cpp @@ -167,11 +167,10 @@ namespace { cond->value = ""; cond->validity = ""; cond->hash = Conditions::ConditionKey::hashCode(cond->name); - cond->setFlag(Condition::ACTIVE); if ( elt.hasAttr(_U(comment)) ) { cond->comment = elt.attr<string>(_U(comment)); } - ConditionsKeyAssign(det).addKey(cond.name());//.addKey(nam,cond.name()); + ConditionsKeyAssign(det).addKey(cond.name()); return cond; } diff --git a/DDCore/include/DD4hep/objects/ConditionsInterna.h b/DDCore/include/DD4hep/objects/ConditionsInterna.h index e30eef9cf539fe72f7d929222a933151007ff63d..f8a356c1262e69784a7df58840820762bef9bd4d 100644 --- a/DDCore/include/DD4hep/objects/ConditionsInterna.h +++ b/DDCore/include/DD4hep/objects/ConditionsInterna.h @@ -145,8 +145,6 @@ namespace DD4hep { void setFlag(mask_type option) { flags |= option; } void unFlag(mask_type option) { flags &= ~option; } bool testFlag(mask_type option) const { return 0 != (flags&option); } - void validate() { setFlag(Condition::ACTIVE); } - void invalidate() { unFlag(Condition::ACTIVE); } }; /// The data class behind a conditions container handle. diff --git a/DDDB/src/CondDB2DDDB.cpp b/DDDB/src/CondDB2DDDB.cpp index 6ff3c1c85d5630bd2ed1d15567fa9c6d6c8e32cc..aef0101725a33f0d144e8036610364c60c0ffad6 100644 --- a/DDDB/src/CondDB2DDDB.cpp +++ b/DDDB/src/CondDB2DDDB.cpp @@ -598,7 +598,6 @@ namespace DD4hep { cond->value = path; // doc->name; cond->validity = ""; cond->hash = Conditions::ConditionKey::hashCode(cond->value); - cond->setFlag(Condition::ACTIVE); if ( element.hasAttr(_U(comment)) ) { cond->comment = element.attr<string>(_U(comment)); } diff --git a/DDEve/src/Display.cpp b/DDEve/src/Display.cpp index 304b1c56da982a359f8a3507dd71969415a50425..34694ed6473959e67f8d690f3dcbec7daa9ab9af 100644 --- a/DDEve/src/Display.cpp +++ b/DDEve/src/Display.cpp @@ -373,7 +373,6 @@ TFile* Display::Open(const char* name) const { /// Consumer event data void Display::OnFileOpen(EventHandler& handler ) { - EventConsumer::OnFileOpen(handler); } /// Consumer event data diff --git a/examples/Conditions/src/ConditionExampleObjects.cpp b/examples/Conditions/src/ConditionExampleObjects.cpp index 5e4cce670d8be49a7718a885155ec26e354a5f2a..6468bef3cc80cf035be60a05e7c102f8b04ba9e5 100644 --- a/examples/Conditions/src/ConditionExampleObjects.cpp +++ b/examples/Conditions/src/ConditionExampleObjects.cpp @@ -184,7 +184,6 @@ template<typename T> Condition ConditionsCreator::make_condition(DetElement de, T& value = cond.bind<T>(); value = val; cond->hash = ConditionKey::hashCode(cond->name); - cond->setFlag(Condition::ACTIVE); if ( slice ) slice->insert(ConditionKey(cond->name,cond->hash),ConditionsSlice::NoLoadInfo()); return cond; }