|
ATLAS Offline Software
|
Go to the documentation of this file.
17 #include "GaudiKernel/MsgStream.h"
22 std::string CondContBase::s_cleanerSvcName =
"Athena::ConditionsCleanerSvc";
65 if (newRange.
m_range.start().isTimeStamp()) {
69 EventIDBase eid = ctx.eventID();
70 if (ctx.hasExtension()) {
73 if (conditionsRun != EventIDBase::UNDEFNUM) {
74 eid.set_run_number (conditionsRun);
95 if (oldRange.
m_range.stop().isTimeStamp()) {
97 EventIDBase oldId = oldRange.
m_range.stop();
98 EventIDBase newId = newRange.
m_range.start();
99 newRange.
m_range = EventIDRange (EventIDBase (newId.run_number(),
100 newId.event_number(),
102 oldId.time_stamp_ns_offset(),
104 newId.bunch_crossing_id()),
121 if (oldRange.
m_range.start().isTimeStamp()) {
123 EventIDBase oldId = oldRange.
m_range.start();
124 EventIDBase newId = newRange.
m_range.stop();
126 EventIDBase (newId.run_number(),
127 newId.event_number(),
129 oldId.time_stamp_ns_offset(),
131 newId.bunch_crossing_id()));
182 range.m_range = EventIDRange (
range.m_range.start(),
237 return isDuplicate (
code.getCode());
251 return isOverlap (
code.getCode());
265 return isExtended (
code.getCode());
320 size_t CondContBase::trim (
const std::vector<key_type>& runLbnKeys,
const std::vector<key_type>& TSKeys)
334 for (
const typename CondContSet::value_type& ent :
m_condSet.range()) {
340 size_t ntrim=tsmap_nc->trim (TSKeys,
true);
345 size_t outerTrimmed=
m_condSet.trim(runLbnKeys);
349 return nTrimmed+outerTrimmed;
414 std::shared_ptr<CondContSet::IPayloadDeleter> payloadDeleter,
447 CondContSet::payload_unique_ptr
t,
448 const EventContext& ctx )
450 EventIDBase
start =
r.start();
451 EventIDBase
stop =
r.stop();
456 if (
start.run_number() == EventIDBase::UNDEFNUM ||
457 stop.run_number() == EventIDBase::UNDEFNUM)
460 msg << MSG::ERROR <<
"CondContBase::insertBase: "
461 <<
"Run part of range invalid in mixed container."
463 return StatusCode::FAILURE;
469 else if (
start.isTimeStamp() &&
stop.isTimeStamp()) {
475 msg << MSG::ERROR <<
"CondContBase::insertBase: "
476 <<
"Timestamp key used in non-timestamp container."
478 return StatusCode::FAILURE;
485 else if (
start.run_number() != EventIDBase::UNDEFNUM &&
486 stop.run_number() != EventIDBase::UNDEFNUM)
493 msg << MSG::ERROR <<
"CondContBase::insertBase: "
494 <<
"Run/LBN key used in non-Run/LBN container."
496 return StatusCode::FAILURE;
505 msg << MSG::ERROR <<
"CondContBase::insertBase: EventIDRange " <<
r
506 <<
" is neither fully RunEvent nor TimeStamp"
508 return StatusCode::FAILURE;
511 CondContSet::EmplaceResult reslt =
517 if (reslt == CondContSet::EmplaceResult::DUPLICATE)
521 else if (reslt == CondContSet::EmplaceResult::EXTENDED)
525 else if (reslt == CondContSet::EmplaceResult::OVERLAP) {
540 const EventContext& ctx )
544 if (!
t.isRunLumi()) {
546 msg << MSG::ERROR <<
"CondContBase::erase: "
547 <<
"Non-Run/LBN key used in Run/LBN container."
549 return StatusCode::FAILURE;
554 if (!
t.isTimeStamp()) {
556 msg << MSG::ERROR <<
"CondContBase::erase: "
557 <<
"Non-Timestamp key used in timestamp container."
559 return StatusCode::FAILURE;
568 return StatusCode::SUCCESS;
584 const EventContext& ctx )
591 if (!newRange.start().isRunLumi()) {
593 msg << MSG::ERROR <<
"CondContBase::extendLastRange: "
594 <<
"Non-Run/LBN range used in Run/LBN container."
596 return StatusCode::FAILURE;
602 if (!newRange.start().isTimeStamp()) {
604 msg << MSG::ERROR <<
"CondContBase::extendLastRange: "
605 <<
"Non-timestamp range used in timestamp container."
607 return StatusCode::FAILURE;
614 return StatusCode::FAILURE;
621 return StatusCode::SUCCESS;
623 return StatusCode::FAILURE;
638 EventIDRange
const**
r)
const
640 const void*
ptr =
nullptr;
647 msg << MSG::ERROR <<
"CondContBase::findBase: "
648 <<
"Non-Run/LBN key used in Run/LBN container."
657 msg << MSG::ERROR <<
"CondContBase::findBase: "
658 <<
"Non-timestamp key used in timestamp container."
672 if (
it && key < it->
first.m_stop) {
674 *
r = &
it->first.m_range;
717 void CondContBase::setCleanerSvcName (
const std::string&
name)
719 s_cleanerSvcName =
name;
730 msg << MSG::ERROR <<
"CondCont<T>::insert: Not most-derived class; "
731 <<
"CLID used: " << usedCLID
732 <<
"; container CLID: " <<
m_clid
751 return m_id.fullKey();
764 ost <<
"id: " <<
id() <<
" proxy: " <<
proxy() <<
" ["
765 <<
entries() <<
"] entries" << std::endl;
766 forEach ([&] (
const CondContSet::value_type& ent)
767 {
ost << ent.first.m_range <<
" " << ent.second << std::endl; });
774 std::vector<EventIDRange>
777 std::vector<EventIDRange>
r;
780 forEach ([&] (
const CondContSet::value_type& ent)
781 {
r.push_back (ent.first.m_range); });
810 const EventContext& ctx )
813 CondContSet::payload_unique_ptr (
obj,
delfcn()),
828 const EventIDRange*
rp =
nullptr;
844 const EventContext& ctx )
862 const EventContext& ctx )
881 std::shared_ptr<CondContSet::IPayloadDeleter> payloadDeleter,
884 payloadDeleter, capacity)
905 std::shared_ptr<CondContSet::IPayloadDeleter> payloadDeleter,
911 m_payloadDeleter (payloadDeleter)
922 ost <<
"id: " <<
id() <<
" proxy: " <<
proxy() <<
" ["
924 forEach ([&] (
const CondContSet::value_type& ent)
928 if (tsmap->empty()) {
929 ost << ent.first.m_range <<
" (empty tsmap)" << std::endl;
932 for (
const CondContSet::value_type& ent2 : tsmap->range()) {
933 ost << ent2.first.m_range <<
" " << ent2.second << std::endl;
946 forEach ([&] (
const CondContSet::value_type& ent) {
949 nent += tsmap->size();
958 std::vector<EventIDRange>
961 std::vector<EventIDRange>
r;
964 forEach ([&] (
const CondContSet::value_type& ent)
968 for (
const CondContSet::value_type& ent2 : tsmap->range()) {
969 r.push_back (ent2.first.m_range);
998 const EventContext& ctx )
1016 const EventIDRange*
rp =
nullptr;
1034 const EventContext& )
1037 msg << MSG::ERROR <<
"CondContMixedBase::erase: "
1038 <<
"erase() is not implemented for mixed containers."
1040 return StatusCode::FAILURE;
1058 const EventContext& )
1061 msg << MSG::ERROR <<
"CondContMixedBase::extendLastRange: "
1062 <<
"extendLastRange() is not implemented for mixed containers."
1064 return StatusCode::FAILURE;
1085 CondContBase::CondContSet::payload_unique_ptr
t,
1086 const EventContext& ctx )
1089 std::lock_guard<std::mutex> lock (
m_mutex);
1091 const EventIDRange*
range =
nullptr;
1099 if (
r.start().isTimeStamp() ) {
1108 if (
r.start().run_number() !=
range->start().run_number() ||
1109 r.stop().run_number() !=
range->stop().run_number() ||
1110 r.start().lumi_block() !=
range->start().lumi_block() ||
1111 r.stop().lumi_block() !=
range->stop().lumi_block())
1117 bool extended =
false;
1118 if (tsmap->size() == 1) {
1119 CondContSet::const_iterator elt = tsmap->find (start_key);
1121 if (elt->first.m_start == start_key &&
1122 elt->first.m_stop == stop_key)
1141 { EventIDBase
start =
k.m_range.start();
1142 EventIDBase
stop =
k.m_range.stop();
1143 stop.set_run_number(
r.stop().run_number());
1144 stop.set_lumi_block(
r.stop().lumi_block());
1155 msg << MSG::ERROR <<
"CondContMixedBase::insertMixed: "
1156 <<
"Run+lbn part of new range doesn't match existing range, "
1157 <<
"or can't extend. "
1158 <<
"New: " <<
r <<
"; existing: " << *
range
1160 return StatusCode::FAILURE;
1165 auto newmap = std::make_unique<CondContSet>
1167 tsmap = newmap.get();
1169 if (
sc.isFailure()) {
1178 CondContSet::EmplaceResult reslt =
1179 tsmap->emplace (
RangeKey(
r, start_key, stop_key),
1180 std::move(
t),
false, ctx );
1182 if (reslt == CondContSet::EmplaceResult::OVERLAP) {
1188 else if (reslt == CondContSet::EmplaceResult::DUPLICATE)
1192 else if (reslt == CondContSet::EmplaceResult::EXTENDED)
1212 EventIDRange
const**
r)
const
1214 if (!
t.isTimeStamp()) {
1216 msg << MSG::ERROR <<
"CondContMixedBase::findMixed: "
1217 <<
"No valid timestamp in key used with mixed container."
1223 const void*
ptr =
nullptr;
1224 CondContSet::const_iterator
it;
1227 if (!
ptr)
return nullptr;
1231 it = tsmap->find (
key);
1233 if (
it && key < it->
first.m_stop) {
1235 *
r = &
it->first.m_range;
Range object to store in ConcurrentRangeMap.
std::mutex m_mutex
Mutex for insertions.
CondContMixedBase(Athena::IRCUSvc &rcusvc, CLID clid, const DataObjID &id, SG::DataProxy *proxy, std::shared_ptr< CondContSet::IPayloadDeleter > payloadDeleter, size_t capacity)
Internal constructor.
static key_type keyFromTimestamp(const EventIDBase &b)
Make a timestamp key from an EventIDBase.
virtual std::vector< EventIDRange > ranges() const override final
Return all IOV validity ranges defined in this container.
void insertError(CLID usedCLID) const
Helper to report an error due to using a base class for insertion.
Hold mappings of ranges to condition objects.
singleton-like access to IMessageSvc via open function and helper
virtual const char * name() const override
Name of the category.
virtual std::string message(code_t code) const override
Description for code within this category.
@ RUNLBN
Container uses run+lbn keys.
static key_type keyFromRunLBN(const EventIDBase &b)
Make a run+lbn key from an EventIDBase.
EventIDBase::number_type conditionsRun() const
void clear()
Remove all entries in the container.
delete_function * payloadDelfcn() const
Return the payload deletion function for this container.
std::shared_ptr< CondContSet::IPayloadDeleter > m_payloadDeleter
Deletion object for actual payload objects.
virtual StatusCode typelessInsert(const EventIDRange &r, void *obj, const EventContext &ctx=Gaudi::Hive::currentContext()) override final
Insert a new conditions object.
CondContSet::Updater_t Updater_t
KeyType
Type of key used for this container.
void addDep(CondContBase *dep)
Declare another conditions container that depends on this one.
const void * findBase(const EventIDBase &t, EventIDRange const **r) const
Internal lookup function.
KeyType keyType() const
Return the key type for this container.
std::vector< CondContBase * > getDeps()
Return the list of conditions containers that depend on this one.
key_type m_start
Packed start time.
virtual void list(std::ostream &ost) const =0
Dump the container contents for debugging.
DataObjID m_id
CLID+key for this container.
virtual bool range(const EventIDBase &t, EventIDRange &r) const override final
Return the mapped validity range for an IOV time.
IMessageSvc * getMessageSvc(bool quiet=false)
CondContSet::delete_function delete_function
virtual void list(std::ostream &ost) const override final
Dump the container contents for debugging.
virtual size_t trim(const std::vector< key_type > &runLbnKeys, const std::vector< key_type > &TSKeys)
Remove unused entries from the front of the list.
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.
CondContSingleBase(Athena::IRCUSvc &rcusvc, CLID clid, const DataObjID &id, SG::DataProxy *proxy, std::shared_ptr< CondContSet::IPayloadDeleter > payloadDeleter, size_t capacity)
Internal constructor.
StatusCode inserted(const EventContext &ctx)
Tell the cleaner that a new object was added to the container.
StatusCode insertMixed(const EventIDRange &r, CondContBase::CondContSet::payload_unique_ptr t, const EventContext &ctx=Gaudi::Hive::currentContext())
Insert a new conditions object.
virtual void list(std::ostream &ost) const override final
Dump the container contents for debugging.
void stall()
Emit stall instruction for use in a spin loop.
virtual bool range(const EventIDBase &t, EventIDRange &r) const =0
Return the mapped validity range for an IOV time.
virtual StatusCode typelessInsert(const EventIDRange &r, void *obj, const EventContext &ctx=Gaudi::Hive::currentContext()) override final
Insert a new conditions object.
const DataObjID & id() const
Return CLID/key corresponding to this container.
std::pair< const_iterator, bool > insert(const key_type p)
Add an element to the set.
void forEach(const FUNC &func) const
Call func on each entry in the container.
virtual StatusCode erase(const EventIDBase &t, const EventContext &ctx=Gaudi::Hive::currentContext()) override final
Erase the first element not less than t.
Some weak symbol referencing magic...
virtual bool range(const EventIDBase &t, EventIDRange &r) const override final
Return the mapped validity range for an IOV time.
::StatusCode StatusCode
StatusCode definition for legacy code.
Athena::IRCUSvc & m_rcusvc
Need to remember the RCU svc here in order to pass it to the TS maps.
Base class for all conditions containers.
const_iterator end() const
Iterator at the end of the set.
DataProxy provides the registry services for StoreGate.
CLID m_clid
CLID of the most-derived CondCont.
virtual StatusCode extendLastRange(const EventIDRange &newRange, const EventContext &ctx=Gaudi::Hive::currentContext()) override final
Extend the range of the last IOV.
@ TIMESTAMP
Container uses timestamp keys.
Interface for RCU service.
virtual size_t entries() const
Return the number of conditions objects in the container.
key_type m_stop
Packed stop time.
SG::DataProxy * m_proxy
Associated DataProxy.
const_iterator begin() const
Iterator at the start of the set.
uint32_t CLID
The Class ID type.
CxxUtils::ConcurrentRangeMap< RangeKey, key_type, void, Compare, Athena::RCUUpdater > CondContSet
virtual StatusCode erase(const EventIDBase &t, const EventContext &ctx=Gaudi::Hive::currentContext()) override final
Erase the first element not less than t.
int extendRange(RangeKey &range, const RangeKey &newRange) const
Possibly extend an existing range at the end.
@ MIXED
Mixed Run+lbn / timestamp container.
static std::string s_cleanerSvcName ATLAS_THREAD_SAFE
Name of the global conditions cleaner service.
static bool isOverlap(code_t code)
Helper to test whether a code is OVERLAP.
StatusCode extendLastRangeBase(const EventIDRange &newRange, const EventContext &ctx=Gaudi::Hive::currentContext())
Extend the range of the last IOV.
CondContStatusCode
Define extended status codes used by CondCont.
ServiceHandle< Athena::IConditionsCleanerSvc > m_cleanerSvc
Handle to the cleaner service.
std::string title() const
Description of this container to use for MsgStream.
StatusCode::code_t code_t
CondContBase(Athena::IRCUSvc &rcusvc, KeyType keytype, CLID clid, const DataObjID &id, SG::DataProxy *proxy, std::shared_ptr< CondContSet::IPayloadDeleter > payloadDeleter, size_t capacity)
Internal constructor.
void quiescent(const EventContext &ctx=Gaudi::Hive::currentContext())
Mark that this thread is no longer accessing data from this container.
const void * findMixed(const EventIDBase &t, EventIDRange const **r) const
Internal lookup function.
CLID clid() const
Return the CLID of the most-derived CondCont.
StatusCode eraseBase(const EventIDBase &t, const EventContext &ctx=Gaudi::Hive::currentContext())
Erase the first element not less than t.
uint64_t key_type
Type used to store an IOV time internally.
static bool isExtended(code_t code)
Helper to test whether a code is EXTENDED.
void setProxy(SG::DataProxy *)
Set the associated DataProxy.
CondContSet m_condSet
Set of mapped objects.
int overlap(const EventContext &ctx, const RangeKey &oldRange, RangeKey &newRange) const
Test if two ranges overlap, and adjust if needed.
SG::DataProxy * proxy()
Return the associated DataProxy, if any.
StatusCode insertBase(const EventIDRange &r, CondContSet::payload_unique_ptr t, const EventContext &ctx=Gaudi::Hive::currentContext())
Insert a new conditions object.
static bool isDuplicate(code_t code)
Helper to test whether a code is DUPLICATE.
Define macros for attributes used to control the static checker.
virtual bool isSuccess(code_t code) const override
Is code considered success?
virtual StatusCode extendLastRange(const EventIDRange &newRange, const EventContext &ctx=Gaudi::Hive::currentContext()) override final
Extend the range of the last IOV.
virtual size_t entries() const override final
Return the number of conditions objects in the container.
delete_function * delfcn() const
Return the deletion function for this container.
size_t maxSize() const
Return the maximum size of the map.
size_t nInserts() const
Return the number times an item was inserted into the map.
Status code category for ContCont.
virtual std::vector< EventIDRange > ranges() const override final
Return all IOV validity ranges defined in this container.
@ SINGLE
Either TIMESTAMP or RUNLBN, but nothing's been put in the container yet, so we don't know which one.
EventIDRange m_range
Original range object.
std::atomic< KeyType > m_keyType
Key type of this container.
void print() const
Dump the container to cout.