diff --git a/DDCond/include/DDCond/ConditionsSlice.h b/DDCond/include/DDCond/ConditionsSlice.h index b7f3b5bdd3b6a94a3f79b710f7ea75de2a0597e8..3ac855b85da86c427066d8abcb1ae5cb4b92ccdf 100644 --- a/DDCond/include/DDCond/ConditionsSlice.h +++ b/DDCond/include/DDCond/ConditionsSlice.h @@ -81,8 +81,8 @@ namespace dd4hep { iov_pool = s.manager.registerIOV(*iov.iovType,iov.key()); } template <typename T> Inserter(ConditionsSlice& s, const T& data) : slice(s) { - const IOV& iov = s.pool->validity(); - iov_pool = s.manager.registerIOV(*iov.iovType,iov.key()); + const IOV& iov = slice.pool->validity(); + iov_pool = slice.manager.registerIOV(*iov.iovType,iov.key()); std::for_each(std::begin(data), std::end(data), *this); } void operator()(Condition c) const { diff --git a/DDCond/include/DDCond/ConditionsTags.h b/DDCond/include/DDCond/ConditionsTags.h index 754e46fe652c80379c6a9e038bc52ca5b9c63c97..1f8fb68c875375cdd705ae411649f27b51fd6c6b 100644 --- a/DDCond/include/DDCond/ConditionsTags.h +++ b/DDCond/include/DDCond/ConditionsTags.h @@ -50,6 +50,7 @@ namespace dd4hep { UNICODE(mapping); UNICODE(sequence); UNICODE(alignment); + UNICODE(alignment_delta); UNICODE(repository); } // User must ensure there are no clashes. If yes, then the clashing entry is unnecessary. diff --git a/DDCond/src/ConditionsContent.cpp b/DDCond/src/ConditionsContent.cpp index 3e15a1d9f6d2279e6b5b3c82be1ef5dd3ae9fdea..a5f414599a75e893e67396ab1ca3e9c92fa14f40 100644 --- a/DDCond/src/ConditionsContent.cpp +++ b/DDCond/src/ConditionsContent.cpp @@ -98,6 +98,7 @@ bool ConditionsContent::remove(Condition::key_type hash) { pair<Condition::key_type, ConditionsLoadInfo*> ConditionsContent::insertKey(Condition::key_type hash) { auto ret = m_conditions.emplace(hash,(ConditionsLoadInfo*)0); + //printout(DEBUG,"ConditionsContent","++ Insert key: %016X",hash); if ( ret.second ) return pair<Condition::key_type, ConditionsLoadInfo*>(hash,0); return pair<Condition::key_type, ConditionsLoadInfo*>(0,0); } @@ -106,6 +107,7 @@ ConditionsContent::insertKey(Condition::key_type hash) { pair<Condition::key_type, ConditionsLoadInfo*> ConditionsContent::addLocationInfo(Condition::key_type hash, ConditionsLoadInfo* info) { if ( info ) { + //printout(DEBUG,"ConditionsContent","++ Add location key: %016X",hash); auto ret = m_conditions.emplace(hash,info); if ( ret.second ) { info->addRef(); @@ -122,6 +124,7 @@ ConditionsContent::addDependency(ConditionDependency* dep) { auto ret = m_derived.emplace(dep->key(),dep); if ( ret.second ) { + //printout(DEBUG,"ConditionsContent","++ Add dependency key: %016X",dep->key()); dep->addRef(); return *(ret.first); } diff --git a/DDCond/src/ConditionsSlice.cpp b/DDCond/src/ConditionsSlice.cpp index f342cab1992323b6e9f35985248da2614a5f9370..0be5e50293ede27c3fe380fb64a407f5b48c8820 100644 --- a/DDCond/src/ConditionsSlice.cpp +++ b/DDCond/src/ConditionsSlice.cpp @@ -189,4 +189,3 @@ void dd4hep::cond::fill_content(ConditionsManager mgr, ConditionsIOVPool::Elements& pools = iovPool->elements; for_each(begin(pools),end(pools),SliceOper(content)); } - diff --git a/DDCond/src/Type1/Manager_Type1.cpp b/DDCond/src/Type1/Manager_Type1.cpp index f61056e588a2c3d465a746599a63b9e01322647d..3920bd77b621354c25574224d74010ae51bd6d83 100644 --- a/DDCond/src/Type1/Manager_Type1.cpp +++ b/DDCond/src/Type1/Manager_Type1.cpp @@ -246,9 +246,12 @@ bool Manager_Type1::registerUnlocked(ConditionsPool& pool, Condition cond) { cond->iov = pool.iov; cond->setFlag(Condition::ACTIVE); pool.insert(cond); -#if 0 - printout(INFO,"ConditionsMgr","Register condition %016lX %s [%s] IOV:%s", - cond->hash, cond.name(), cond->address.c_str(), pool.iov->str().c_str()); +#if !defined(DD4HEP_MINIMAL_CONDITIONS) + printout(DEBUG,"ConditionsMgr","Register condition %016lX %s [%s] IOV:%s", + cond.key(), cond.name(), cond->address.c_str(), pool.iov->str().c_str()); +#else + printout(DEBUG,"ConditionsMgr","Register condition %016lX %s IOV:%s", + cond.key(), cond.name(), pool.iov->str().c_str()); #endif if ( !m_onRegister.empty() ) { __callListeners(m_onRegister, &ConditionsListener::onRegisterCondition, cond); diff --git a/DDCond/src/plugins/ConditionsRepositoryParser.cpp b/DDCond/src/plugins/ConditionsRepositoryParser.cpp index ee5d27336493dc7f4ded39ed2e5bbae713eb82f1..797a8f27bf21f10d12f66e598aaf8ad1534f6f56 100644 --- a/DDCond/src/plugins/ConditionsRepositoryParser.cpp +++ b/DDCond/src/plugins/ConditionsRepositoryParser.cpp @@ -150,10 +150,10 @@ namespace { string add = xml::DocumentHandler::system_path(e); string cond_nam = det.path()+"#"+nam; Condition cond(cond_nam, typ); - printout(s_parseLevel,"XMLConditions","++ Processing condition tag:%s name:%s type:%s [%s]", - tag.c_str(), nam.c_str(), typ.c_str(), - Path(add).filename().c_str()); - cond->hash = ConditionKey::hashCode(det,cond_nam); + cond->hash = ConditionKey::hashCode(det, nam); + printout(s_parseLevel,"XMLConditions","++ Processing condition tag:%s name:%s type:%s [%s] hash:%016X det:%p", + tag.c_str(), cond.name(), typ.c_str(), + Path(add).filename().c_str(), cond.key(), det.ptr()); #if !defined(DD4HEP_MINIMAL_CONDITIONS) cond->address = add; cond->value = ""; @@ -370,7 +370,7 @@ namespace dd4hep { xml_coll_t(e,_UC(mapping)).for_each(Converter<mapping>(description,param,optional)); xml_coll_t(e,_UC(sequence)).for_each(Converter<sequence>(description,param,optional)); xml_coll_t(e,_UC(pressure)).for_each(Converter<pressure>(description,param,optional)); - xml_coll_t(e,_UC(alignment)).for_each(Converter<alignment>(description,param,optional)); + xml_coll_t(e,_UC(alignment_delta)).for_each(Converter<alignment>(description,param,optional)); xml_coll_t(e,_UC(temperature)).for_each(Converter<temperature>(description,param,optional)); xml_coll_t(e,_UC(detelement)).for_each(Converter<detelement>(description,param,optional)); } diff --git a/DDCond/src/plugins/ConditionsRepositoryWriter.cpp b/DDCond/src/plugins/ConditionsRepositoryWriter.cpp index 79840513eaf616fd615de84ad572a8c2ab515c2e..fb7c395c016e64a97ce3b77a6654916245ff66cd 100644 --- a/DDCond/src/plugins/ConditionsRepositoryWriter.cpp +++ b/DDCond/src/plugins/ConditionsRepositoryWriter.cpp @@ -146,7 +146,7 @@ namespace { }; template <typename T> xml::Element _convert(xml::Element par, Condition c); - + xml::Element make(xml::Element e, Condition c) { char hash[64]; std::string nam = c.name(); @@ -200,7 +200,7 @@ namespace { return temp; } template <> xml::Element _convert<Delta>(xml::Element par, Condition c) { - xml::Element align = make(xml::Element(par.document(),_UC(alignment)),c); + xml::Element align = make(xml::Element(par.document(),_UC(alignment_delta)),c); const Delta& delta = c.get<Delta>(); if ( delta.flags&Delta::HAVE_TRANSLATION ) align.append(_convert(align,delta.translation)); @@ -211,9 +211,16 @@ namespace { return align; } template <> xml::Element _convert<Alignment>(xml::Element par, Condition c) { - xml::Element align = make(xml::Element(par.document(),_UC(alignment)),c); - AlignmentCondition acond = c; - const Delta& delta = acond.data().delta; + char hash[64]; + typedef ConditionKey::KeyMaker KM; + AlignmentCondition acond = c; + KM km(c.key()); + const Delta& delta = acond.data().delta; + xml::Element align(xml::Element(par.document(),_UC(alignment_delta))); + Condition::key_type key = KM(km.values.det_key,align::Keys::deltaKey).hash; + ::snprintf(hash,sizeof(hash),"%llX",key); + align.setAttr(_U(name),align::Keys::deltaName); + align.setAttr(_U(key),hash); if ( delta.flags&Delta::HAVE_TRANSLATION ) align.append(_convert(align,delta.translation)); if ( delta.flags&Delta::HAVE_ROTATION ) @@ -409,8 +416,8 @@ size_t ConditionsXMLRepositoryWriter::collect(xml::Element root, ++m_numConverted; } else if ( cond_delta.isValid() ) { - conditions.append(_convert<Delta>(conditions,cond_delta)); - ++m_numConverted; + //conditions.append(_convert<Delta>(conditions,cond_delta)); + //++m_numConverted; } } for (const auto& i : detector.children()) diff --git a/DDCond/src/plugins/ConditionsUserPool.cpp b/DDCond/src/plugins/ConditionsUserPool.cpp index 1805bf716c0316da23ba4dc02d5c245614152653..23227b1cab4a81ee40f35187e5365300e7c7faec 100644 --- a/DDCond/src/plugins/ConditionsUserPool.cpp +++ b/DDCond/src/plugins/ConditionsUserPool.cpp @@ -244,12 +244,12 @@ template<typename MAPPING> inline bool ConditionsMappedUserPool<MAPPING>::i_insert(Condition::Object* o) { int ret = m_conditions.emplace(o->hash,o).second; if ( flags&PRINT_INSERT ) { - printout(INFO,"UserPool","++ %s condition [%016llX]: %s.", + printout(INFO,"UserPool","++ %s condition [%016llX]: %s [%s].", ret ? "Successfully inserted" : "FAILED to insert", o->hash, -#if defined(DD4HEP_MINIMAL_CONDITIONS) - ""); +#if defined(DD4HEP_CONDITIONS_HAVE_NAME) + o->GetName(), o->GetTitle()); #else - o->name.c_str()); + ""); #endif } return ret; diff --git a/DDCore/include/DD4hep/config.h b/DDCore/include/DD4hep/config.h index 2c0345d8dd259ce5142a67e8e5faf3a75368a1a9..2e7579bdd39907453004c037f233253122b7a097 100644 --- a/DDCore/include/DD4hep/config.h +++ b/DDCore/include/DD4hep/config.h @@ -20,13 +20,13 @@ /// If enabled it overrides DD4HEP_MINIMAL_CONDITIONS and sets it to true /// If enabled it overrides DD4HEP_CONDITIONS_HAVE_NAME and sets it to true #if defined(DD4HEP_DEBUG) -#define DD4HEP_CONDITIONS_DEBUG 1 +#define DD4HEP_CONDITIONS_DEBUG 1 #endif -#if defined(DD4HEP_CONDITIONS_DEBUG) /// Enable flag to store conditions names to keys (needs some support from user code!) #define DD4HEP_CONDITIONS_HAVE_NAME 1 -#else + +#if !defined(DD4HEP_CONDITIONS_DEBUG) /// Enable this if you want to minimize the footprint of conditions #define DD4HEP_MINIMAL_CONDITIONS 1 #endif diff --git a/DDCore/src/AlignmentsCalculator.cpp b/DDCore/src/AlignmentsCalculator.cpp index 5d4325eccb7e6133e67b2aa1a9cf55d0b03d47ce..49af590d1e48f2be31464338a96b4339f77716e1 100644 --- a/DDCore/src/AlignmentsCalculator.cpp +++ b/DDCore/src/AlignmentsCalculator.cpp @@ -130,7 +130,7 @@ Result Calculator::compute(Context& context, Entry& e) const { return result; } AlignmentCondition c = context.mapping.get(det, Keys::alignmentKey); - AlignmentCondition cond = c.isValid() ? c : AlignmentCondition("alignment"); + AlignmentCondition cond = c.isValid() ? c : AlignmentCondition(det.path()+"#alignment"); AlignmentData& align = cond.data(); const Delta* delta = e.delta ? e.delta : &identity_delta; TGeoHMatrix transform_for_delta; @@ -165,6 +165,7 @@ Result Calculator::compute(Context& context, Entry& e) const { // Update mapping if the condition is freshly created if ( !c.isValid() ) { e.created = 1; + cond->flags |= Condition::ALIGNMENT_DERIVED; cond->hash = ConditionKey(e.det,Keys::alignmentKey).hash; context.mapping.insert(e.det, Keys::alignmentKey, cond); } diff --git a/DDCore/src/ConditionsInterna.cpp b/DDCore/src/ConditionsInterna.cpp index eca1e178ed16a25e8ba32fa562af692a8c3a5a54..c7de250d3a62aaf7c4b02aa0ebf448d0ee415c88 100644 --- a/DDCore/src/ConditionsInterna.cpp +++ b/DDCore/src/ConditionsInterna.cpp @@ -20,10 +20,10 @@ using namespace std; using namespace dd4hep; -#if !defined(DD4HEP_CONDITIONS_DEBUG) && defined(DD4HEP_MINIMAL_CONDITIONS) -DD4HEP_INSTANTIATE_HANDLE_UNNAMED(detail::ConditionObject); -#else +#if defined(DD4HEP_CONDITIONS_HAVE_NAME) DD4HEP_INSTANTIATE_HANDLE_NAMED(detail::ConditionObject); +#else +DD4HEP_INSTANTIATE_HANDLE_UNNAMED(detail::ConditionObject); #endif namespace { @@ -44,12 +44,12 @@ detail::ConditionObject::ConditionObject() } /// Standard constructor -#if !defined(DD4HEP_CONDITIONS_DEBUG) && defined(DD4HEP_MINIMAL_CONDITIONS) -detail::ConditionObject::ConditionObject(const string& ,const string& ) - : data() -#else +#if defined(DD4HEP_CONDITIONS_HAVE_NAME) detail::ConditionObject::ConditionObject(const string& nam,const string& tit) : NamedObject(nam, tit), data() +#else +detail::ConditionObject::ConditionObject(const string& ,const string& ) + : data() #endif { InstanceCount::increment(this); diff --git a/examples/AlignDet/CMakeLists.txt b/examples/AlignDet/CMakeLists.txt index 27eb9e128137aca9ccc759c21e17ebf8d70b316d..1c626dea69eb8a1634825876b262609803a2488d 100644 --- a/examples/AlignDet/CMakeLists.txt +++ b/examples/AlignDet/CMakeLists.txt @@ -55,7 +55,7 @@ dd4hep_add_test_reg( AlignDet_Telescope_read_xml EXEC_ARGS geoPluginRun -volmgr -destroy -plugin DD4hep_AlignmentExample_read_xml -input file:${AlignDet_INSTALL}/compact/Telescope.xml -deltas file:${CMAKE_INSTALL_PREFIX}/examples/Conditions/data/repository.xml - REGEX_PASS "20 conditions in slice. \\(T:20,S:20,L:0,C:0,M:0\\) Alignments accessed: 20 \\(A:19,M:0\\) for IOV:run\\(1\\)" + REGEX_PASS "39 conditions in slice. \\(T:20,S:20,L:0,C:0,M:0\\) Alignments accessed: 20 \\(A:19,M:0\\) for IOV:run\\(1\\)" REGEX_FAIL " ERROR ;EXCEPTION;Exception" ) # @@ -115,7 +115,7 @@ dd4hep_add_test_reg( AlignDet_Telescope_readback_xml EXEC_ARGS geoPluginRun -volmgr -destroy -plugin DD4hep_AlignmentExample_read_xml -input file:${AlignDet_INSTALL}/compact/Telescope.xml -deltas file:./new_cond.xml - REGEX_PASS "33 conditions in slice. \\(T:33,S:33,L:0,C:0,M:0\\) Alignments accessed: 20 \\(A:19,M:0\\) for IOV:run\\(1\\)" + REGEX_PASS "52 conditions in slice. \\(T:33,S:33,L:0,C:0,M:0\\) Alignments accessed: 20 \\(A:19,M:0\\) for IOV:run\\(1\\)" REGEX_FAIL " ERROR ;EXCEPTION;Exception" ) # diff --git a/examples/AlignDet/src/AlignmentExample_read_xml.cpp b/examples/AlignDet/src/AlignmentExample_read_xml.cpp index 3a653e774e196abd5b238438eae974f1ed46e0d9..914619471b61a48b7851283f76fc0d99e7c99e3f 100644 --- a/examples/AlignDet/src/AlignmentExample_read_xml.cpp +++ b/examples/AlignDet/src/AlignmentExample_read_xml.cpp @@ -99,7 +99,7 @@ static int alignment_example (Detector& description, int argc, char** argv) { printout(INFO,"Example", "%ld conditions in slice. (T:%ld,S:%ld,L:%ld,C:%ld,M:%ld) " "Alignments accessed: %ld (A:%ld,M:%ld) for IOV:%-12s", - slice->conditions().size(), + slice->pool->size(), cres.total(), cres.selected, cres.loaded, cres.computed, cres.missing, total_accessed, ares.computed, ares.missing, iov_typ->str().c_str()); diff --git a/examples/Conditions/CMakeLists.txt b/examples/Conditions/CMakeLists.txt index ce381820babea441307112080b5a38188063a909..dbc58ed17a07e2346ad7ad3b960ff1d794dd676a 100644 --- a/examples/Conditions/CMakeLists.txt +++ b/examples/Conditions/CMakeLists.txt @@ -54,7 +54,7 @@ dd4hep_add_test_reg( Conditions_Telescope_cond_dump_by_detelement -compact file:${CMAKE_INSTALL_PREFIX}/examples/AlignDet/compact/Telescope.xml -plugin DD4hep_ConditionsXMLRepositoryParser file:${CMAKE_INSTALL_PREFIX}/examples/Conditions/data/repository.xml -plugin DD4hep_DetElementConditionsDump - REGEX_PASS "Path\\:/world/Telescope/module_9#alignment" + REGEX_PASS "Key\\:FA708B8A8CDE3019 Type\\:dd4hep\\:\\:Delta" REGEX_FAIL " ERROR ;EXCEPTION;Exception" ) # diff --git a/examples/Conditions/data/Modules_run-1000...2000.xml b/examples/Conditions/data/Modules_run-1000...2000.xml index 86f0bfea51cf9ec7078893e89ab7b0d1f725b78f..6a24429376665e0944b3ab94cd49e35480cad084 100644 --- a/examples/Conditions/data/Modules_run-1000...2000.xml +++ b/examples/Conditions/data/Modules_run-1000...2000.xml @@ -4,10 +4,10 @@ <conditions> <detelement path="/world/Telescope"> - <alignment> + <alignment_delta> <position x="0" y="0" z="5*cm"/> <rotation x="0" y="0" z="0"/> - </alignment> + </alignment_delta> </detelement> <detelement path="/world/Telescope/module_1"> @@ -26,35 +26,35 @@ </detelement> <detelement path="/world/Telescope/module_6"> - <alignment> + <alignment_delta> <position x="0" y="0" z="290.0*mm"/> <rotation x="0" y="pi/2" z="0"/> - </alignment> + </alignment_delta> </detelement> <detelement path="/world/Telescope/module_7"> - <alignment> + <alignment_delta> <position x="0" y="0" z="290.0*mm"/> <rotation x="0" y="pi/2" z="0"/> - </alignment> + </alignment_delta> </detelement> <detelement path="/world/Telescope/module_8"> - <alignment> + <alignment_delta> <position x="0" y="0" z="290.0*mm"/> <rotation x="0" y="pi/2" z="0"/> - </alignment> + </alignment_delta> </detelement> <!-- --> <detelement path="/world/Telescope/module_9" ref="default_module.xml"> - <alignment> + <alignment_delta> <position x="0" y="0" z="10.0*mm"/> <rotation x="0" y="0" z="0"/> <pivot x="0" y="0" z="0"/> - </alignment> + </alignment_delta> <detelement path="/world/Telescope/module_9/sensor"> - <alignment> + <alignment_delta> <position x="0" y="0" z="10.0*mm"/> <!-- This is a point symmetry of 180 degree. Can be checked with the printer. @@ -62,7 +62,7 @@ --> <rotation x="0" y="0" z="pi"/> <pivot x="0" y="0" z="0"/> - </alignment> + </alignment_delta> </detelement> <!-- -->