13#include "EventInfo/EventInfo.h"
25#include "GaudiKernel/ISvcLocator.h"
26#include "GaudiKernel/IAlgTool.h"
27#include "GaudiKernel/GaudiException.h"
28#include "GaudiKernel/TypeNameString.h"
29#include "GaudiKernel/MsgStream.h"
48 ToolHandleArray<IPileUpXingFolder>::const_iterator
50 while (iXing != iEnd) {
52 if (
msg().level() <= MSG::DEBUG) {
53 msg() << MSG::DEBUG <<
"decodeIntervals: adding IPileUpXingFolder "
57 item(xing.
begin()), endItem(xing.
end());
58 while(item != endItem) {
59 m_ranges[make_pair(item->id(), item->key())]=
61 if (
msg().level() <= MSG::VERBOSE) {
63 <<
"decodeInterval: accepting objects of CLID " << item->id()
64 <<
" key " << item->key() <<
" in the Xing range ["
66 <<
" with cache refresh frequency "
83 m_autoRetrieveTools =
false;
84 m_checkToolDeps =
false;
90 <<
"Could not locate default store"
92 return StatusCode::FAILURE;
97 <<
"Could not locate ITriggerTime tool"
99 return StatusCode::FAILURE;
107 return StatusCode::SUCCESS;
114 const EventContext& ctx = Gaudi::Hive::currentContext();
120 if( xAODEventInfo ) {
121 ATH_MSG_DEBUG(
"Found xAOD::EventInfo="<<xAODEventInfo<<
" SG="<<sg<<
" : "<<*xAODEventInfo);
129 std::lock_guard<std::mutex>
lock (*m_slotMutex);
132 const EventInfo* pEvent = einame.empty()?
136 ATH_MSG_DEBUG(
"Converting (PileUp)EventInfo "<<pEvent<<
" SG="<<sg<<
" to xAOD::EventInfo");
138 std::unique_ptr< xAOD::EventInfo > pxAODEventInfo(
new xAOD::EventInfo() );
140 pxAODEventInfo->setStore( pxAODEventAuxInfo.get() );
141 pxAODEventInfo->setEvtStore( sg );
142 if( !
m_xAODCnvTool->convert( ctx, pEvent, pxAODEventInfo.get(),
true,
false ).isSuccess() ) {
152 puei->setStore( puaux.get() );
155 std::vector< xAOD::EventInfo::SubEvent > subEvents;
158 static const std::map< PileUpEventInfo::SubEvent::pileup_type,
160#define DECLARE_SE_TYPE( TYPE ) \
161 { PileUpTimeEventIndex::TYPE, xAOD::EventInfo::TYPE },
170#undef DECLARE_SE_TYPE
179 const unsigned int countEvents = std::distance(pu_itr,pu_end);
180 ATH_MSG_VERBOSE(
"CHECKING: There are " << countEvents <<
" subevents in this Event." );
181 for( ; pu_itr != pu_end; ++pu_itr ) {
185 if( !
m_xAODCnvTool->convert( ctx, pu_itr->pSubEvt, ei.get(),
true,
false ).isSuccess() ) {
186 ATH_MSG_ERROR(
"Failed to convert EventInfo to xAOD::EventInfo");
192 ei->setEvtStore(tmpSG);
198 puei->push_back( ei.release() );
201 auto typeItr = pileupTypeMap.find( pu_itr->type() );
203 if( typeItr == pileupTypeMap.end() ) {
206 type = typeItr->second;
208 ATH_MSG_VERBOSE(
"PileUpEventInfo: time = " << pu_itr->time() <<
", index = " << pu_itr->index());
212 EiLink(
"PileUpEventInfo", puei->size()-1, sg )));
213 ATH_MSG_VERBOSE(
"PileUpEventInfo: time = " << subEvents.back().time() <<
", index = " << subEvents.back().index());
216 if( subEvents.size() ) {
218 pxAODEventInfo->setSubEvents( subEvents );
221 if( !sg->
record( std::move( puaux ),
"PileUpEventInfoAux." ).isSuccess()
222 || !sg->
record( std::move( puei ),
"PileUpEventInfo" ).isSuccess() ) {
223 ATH_MSG_ERROR(
"Failed to record xAOD::EventInfoContainer in SG");
230 xAODEventInfo = std::launder(pxAODEventInfo.get());
232 const auto ptrVal = pxAODEventInfo.get();
233 if( ! sg->
record( std::move( pxAODEventAuxInfo ),
"EventInfoAux." ).isSuccess()
234 || ! sg->
record( std::move( pxAODEventInfo ),
"EventInfo" ).isSuccess() ) {
235 ATH_MSG_ERROR(
"Failed to record the new xAOD::EventInfo in SG");
236 xAODEventInfo =
nullptr;
238 ATH_MSG_DEBUG(
"Record the new xAOD::EventInfo "<<ptrVal<<
" in SG="<<sg);
242 if( !xAODEventInfo ) {
243 ATH_MSG_DEBUG(
"Could not find EventInfo '" << einame <<
"' in store " << sg->name());
245 return xAODEventInfo;
258 return m_ranges[make_pair(
id, dataKey)].contains(iXing);
266 return (
r.contains(iXing) &&
r.doRefresh(
double(random())*(1./RAND_MAX)));
271 StatusCode
sc(StatusCode::FAILURE);
285 if (proxy &&
doRefresh (item.second,
int(subEv.time()))) {
286 proxy->setObject ((DataObject*)0);
287 if (
msg().level() <= MSG::DEBUG) {
289 <<
"clearDataCachesByFolder: object with clid "
290 << item.first.first <<
" and key " << item.first.second
291 <<
" removed from cache "
292 << pSubEvtSG->name() <<
endmsg;
299 if (
msg().level() <= MSG::VERBOSE) {
300 msg() << MSG::VERBOSE
301 <<
"clearDataCachesByFolder: done with store " << pSubEvtSG->name()
306 sc=StatusCode::SUCCESS;
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define CHECK(...)
Evaluate an expression and check for errors.
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
This class provides general information about an event.
uint32_t CLID
The Class ID type.
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
an interface to SG::Folder with an attached bunch crossing interval
interface to a tool that returns the time offset of the current trigger.
This class provides information about an overlaid event.
the preferred mechanism to access information from the different event stores in a pileup job.
#define DECLARE_SE_TYPE(TYPE)
struct TBPatternUnitContext Unknown
ElementLink implementation for ROOT usage.
This class provides general information about an event.
an interface to SG::Folder with an attached bunch crossing interval
SG::IFolder::const_iterator const_iterator
virtual const_iterator end() const =0
virtual float cacheRefreshFrequency() const =0
controls the rate at which we clear data objs in this folder at the end of event
virtual int firstXing() const =0
virtual int lastXing() const =0
virtual const_iterator begin() const =0
This class provides information about an overlaid event.
SubEvent::iterator endSubEvt()
SubEvent::iterator beginSubEvt()
the active crossing range for a data object (CLID/key combination)
ToolHandle< ITriggerTime > m_pITriggerTime
controls PileUpTimedEventIndex for TimedData returned by retrieveSubEvts
void decodeIntervals()
setup PileUpIntervals
ToolHandleArray< IPileUpXingFolder > m_intervals
bool isLive(const KEY &key, int iXing)
is iXing live for DATA/key?
StatusCode clearDataCaches()
clear bkg event caches from unneeded data objects (as configured using PileUpXingFolder CacheRefreshF...
virtual StatusCode initialize() override
Service initialisation.
StringProperty m_EventInfoKeyName
bool doRefresh(const Range &r, int iXing)
ToolHandle< xAODMaker::IEventInfoCnvTool > m_xAODCnvTool
property: Handle to the EventInfo -> xAOD::EventInfo converter tool
PileUpMergeSvc(const std::string &name, ISvcLocator *svc)
Standard Gaudi Constructor.
ServiceHandle< StoreGateSvc > p_overStore
overlaid SG (default)
const xAOD::EventInfo * getPileUpEvent(StoreGateSvc *sg, const std::string &einame)
get EventInfo from SG, by default using p_overStore
The Athena Transient Store API.
StatusCode record(T *p2BRegistered, const TKEY &key)
Record an object with a key.
const T * tryConstRetrieve() const
void emptyTrash()
throw away bad objects
virtual sgkey_t stringToKey(const std::string &str, CLID clid) override final
Find the key for a string/CLID pair.
virtual SG::DataProxy * proxy_exact(SG::sgkey_t sgkey) const override final
Get proxy given a hashed key+clid.
Class describing the properties of one pileup sub-event.
const std::vector< SubEvent > & subEvents() const
Get the pileup events that were used in the simulation.
PileUpType
Enumerator describing the types of pileup events.
@ Unknown
Type not known/specified.
IProxyDict * proxyDictFromEventContext()
Return the IProxyDict for this thread's current context.
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
EventInfoContainer_v1 EventInfoContainer
Define the latest version of the container.
EventInfo_v1 EventInfo
Definition of the latest event info version.
EventInfoAuxContainer_v1 EventInfoAuxContainer
Define the latest version of the auxiliary container.
EventAuxInfo_v3 EventAuxInfo
Definition of the latest event auxiliary info version.
Some out-of-line helpers for ExtendedEventContext.