diff --git a/Control/AthenaKernel/AthenaKernel/CondCont.h b/Control/AthenaKernel/AthenaKernel/CondCont.h index f98eb460dfb7355dacb942d7d44e5b4d3b902a7d..b684d4ed28eb3c7c67414eaf4524dedb0feb8942 100644 --- a/Control/AthenaKernel/AthenaKernel/CondCont.h +++ b/Control/AthenaKernel/AthenaKernel/CondCont.h @@ -149,7 +149,14 @@ bool CondCont<T>::insert(const EventIDRange& r, T* t) { std::lock_guard<std::mutex> lock(m_mut); - if (r.start().isRunEvent() && r.stop().isRunEvent()) { + auto isRunLumi = [] (const EventIDBase& id) + { return id.run_number() != EventIDBase::UNDEFNUM && + id.lumi_block() != EventIDBase::UNDEFNUM; }; + + if ((r.start().isRunEvent() && r.stop().isRunEvent()) || + // LBN part of stop() will be UNDEFNUM for an open-ended range. + (isRunLumi(r.start()) && r.stop().run_number() != EventIDBase::UNDEFNUM)) + { m_condSet_RE.emplace( IOVEntryT<T>(t, r) ); } else if (r.start().isTimeStamp() && r.stop().isTimeStamp()) { m_condSet_clock.emplace( IOVEntryT<T>(t,r) ); @@ -165,6 +172,14 @@ bool CondCont<T>::insert(const EventIDRange& r, T* t) { /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +namespace SG { + inline + bool isInRange (const EventIDRange& r, const EventIDBase& id) + { + return !EventIDBaseComp() (id, r.start()) && EventIDBaseComp() (id, r.stop()); + } +} + template <typename T> bool CondCont<T>::valid(const EventIDBase& it) const { typename CondContSet::const_iterator itr; @@ -174,7 +189,7 @@ bool CondCont<T>::valid(const EventIDBase& it) const { if (it.isRunEvent()) { itr = m_condSet_RE.begin(); for (; itr != m_condSet_RE.end(); ++itr) { - if ( itr->range().isInRange( it ) ) { + if ( SG::isInRange (itr->range(), it) ) { return true; } } @@ -182,7 +197,7 @@ bool CondCont<T>::valid(const EventIDBase& it) const { if (it.isTimeStamp()) { itr = m_condSet_clock.begin(); for (; itr != m_condSet_clock.end(); ++itr) { - if ( itr->range().isInRange( it ) ) { + if ( SG::isInRange (itr->range(), it) ) { return true; } } @@ -203,7 +218,7 @@ bool CondCont<T>::find(const EventIDBase& it, T*& t) const { if (it.isRunEvent()) { itr = m_condSet_RE.begin(); for (; itr != m_condSet_RE.end(); ++itr) { - if ( itr->range().isInRange( it ) ) { + if ( SG::isInRange (itr->range(), it) ) { t = itr->objPtr(); return true; } @@ -212,7 +227,7 @@ bool CondCont<T>::find(const EventIDBase& it, T*& t) const { if (it.isTimeStamp()) { itr = m_condSet_clock.begin(); for (; itr != m_condSet_clock.end(); ++itr) { - if ( itr->range().isInRange( it ) ) { + if ( SG::isInRange (itr->range(), it) ) { t = itr->objPtr(); return true; } @@ -234,7 +249,7 @@ bool CondCont<T>::findEntry(const EventIDBase& it, const IOVEntryT<T>*& t) const if (it.isRunEvent()) { itr = m_condSet_RE.begin(); for (; itr != m_condSet_RE.end(); ++itr) { - if ( itr->range().isInRange( it ) ) { + if ( SG::isInRange (itr->range(), it) ) { t = &(*itr); return true; } @@ -243,7 +258,7 @@ bool CondCont<T>::findEntry(const EventIDBase& it, const IOVEntryT<T>*& t) const if (it.isTimeStamp()) { itr = m_condSet_clock.begin(); for (; itr != m_condSet_clock.end(); ++itr) { - if ( itr->range().isInRange( it ) ) { + if ( SG::isInRange (itr->range(), it) ) { t = &(*itr); return true; } @@ -311,7 +326,7 @@ CondCont<T>::range(const EventIDBase& now, EventIDRange& r) const { if (now.isRunEvent()) { itr = m_condSet_RE.begin(); for (; itr != m_condSet_RE.end(); ++itr) { - if ( itr->range().isInRange( now ) ) { + if ( SG::isInRange (itr->range(), now) ) { r = itr->range(); return true; } @@ -320,7 +335,7 @@ CondCont<T>::range(const EventIDBase& now, EventIDRange& r) const { if (now.isTimeStamp()) { itr = m_condSet_clock.begin(); for (; itr != m_condSet_clock.end(); ++itr) { - if ( itr->range().isInRange( now ) ) { + if ( SG::isInRange (itr->range(), now) ) { r = itr->range(); return true; } diff --git a/Control/AthenaKernel/AthenaKernel/IOVEntryT.h b/Control/AthenaKernel/AthenaKernel/IOVEntryT.h index 37d9548b63d7259a294cc97a38b40f6048bdee70..c3552545a1279632f64fd1a6f5f7e320fca7afaa 100644 --- a/Control/AthenaKernel/AthenaKernel/IOVEntryT.h +++ b/Control/AthenaKernel/AthenaKernel/IOVEntryT.h @@ -20,8 +20,27 @@ #include "GaudiKernel/EventIDRange.h" #include <set> -template <typename T> +class EventIDBaseComp +{ +public: + bool operator() (const EventIDBase& e1, const EventIDBase& e2) + { + auto isRunLumi = [] (const EventIDBase& id) + { return id.run_number() != EventIDBase::UNDEFNUM && + id.lumi_block() != EventIDBase::UNDEFNUM; }; + if (isRunLumi(e1) && isRunLumi(e2)) { + unsigned int rn1 = e1.run_number(); + unsigned int rn2 = e2.run_number(); + unsigned int lb1 = e1.lumi_block(); + unsigned int lb2 = e2.lumi_block(); + return (std::tie(rn1, lb1) < + std::tie(rn2, lb2)); + } + return e1 < e2; + } +}; +template <typename T> class IOVEntryT { public: @@ -29,10 +48,10 @@ public: class IOVEntryTStartCritereon { public: bool operator() ( const IOVEntryT<T> &p1, const IOVEntryT<T> &p2 ) const { - return p1.range().start() > p2.range().start(); + return EventIDBaseComp() (p2.range().start(), p1.range().start()); } bool operator() ( const IOVEntryT<T> *p1, const IOVEntryT<T> *p2 ) const { - return p1->range().start() > p2->range().start(); + return EventIDBaseComp() (p2->range().start(), p1->range().start()); } }; @@ -40,10 +59,10 @@ public: class IOVEntryTStopCritereon { public: bool operator() ( const IOVEntryT<T> &p1, const IOVEntryT<T> &p2 ) const { - return p1.range().stop() < p2.range().stop(); + return EventIDBaseComp() (p1.range().stop(), p2.range().stop()); } bool operator() ( const IOVEntryT<T> *p1, const IOVEntryT<T> *p2 ) const { - return p1->range().stop() < p2->range().stop(); + return EventIDBaseComp() (p1->range().stop(), p2->range().stop()); } }; @@ -74,7 +93,7 @@ template <typename T> class IOVEntryComp { public: bool operator() ( const IOVEntryT<T> &p1, const IOVEntryT<T> &p2 ) const { - return p1.range().start() > p2.range().start(); + return EventIDBaseComp() (p2->range().strart(), p1->range().start()); } }; diff --git a/Control/AthenaKernel/src/IOVTime.cxx b/Control/AthenaKernel/src/IOVTime.cxx index 5c11d5a4de4d0912a31c60263f26c4f98842c39a..adb3fc0e61fd9da632164e5e7784281e7267967b 100644 --- a/Control/AthenaKernel/src/IOVTime.cxx +++ b/Control/AthenaKernel/src/IOVTime.cxx @@ -195,13 +195,16 @@ IOVTime::operator std::string () const { IOVTime::operator EventIDBase() const { if (isBoth()) { - return EventIDBase(run(),event(), - timestamp()/1000000000LL,timestamp()%1000000000LL); + return EventIDBase(run(),EventIDBase::UNDEFEVT, + timestamp()/1000000000LL,timestamp()%1000000000LL, + event()); } else if (isTimestamp()) { return EventIDBase(EventIDBase::UNDEFNUM,EventIDBase::UNDEFEVT, timestamp()/1000000000LL,timestamp()%1000000000LL); } else if (isRunEvent()) { - return EventIDBase(run(),event()); + return EventIDBase(run(),EventIDBase::UNDEFEVT, + EventIDBase::UNDEFNUM,0, + event()); } else { return EventIDBase(); }