|
ATLAS Offline Software
|
Go to the documentation of this file.
12 #include "EventInfo/EventInfo.h"
24 #include "GaudiKernel/ISvcLocator.h"
25 #include "GaudiKernel/IAlgTool.h"
26 #include "GaudiKernel/GaudiException.h"
27 #include "GaudiKernel/TypeNameString.h"
28 #include "GaudiKernel/MsgStream.h"
40 p_overStore(
"StoreGateSvc",
"StoreGateSvc"),
43 m_returnTimedData(true),
44 m_EventInfoKeyName(
"OverlayEvent"),
45 m_xAODCnvTool(
"xAODMaker::EventInfoCnvTool/EventInfoCnvTool", this)
47 declareProperty(
"Intervals",
m_intervals,
"Folders specifying bunch xing intervals for different data objects");
48 declareProperty(
"TriggerTimeTool",
m_pITriggerTime,
"allows to apply a trigger time offset");
50 "determine whether the TimedData returned by retrieveSubEvts have non trivial PileUpTimeEventIndex. May be set to false for overlay with real events ");
58 ToolHandleArray<IPileUpXingFolder>::const_iterator
60 while (iXing != iEnd) {
63 msg() <<
MSG::DEBUG <<
"decodeIntervals: adding IPileUpXingFolder "
68 while(
item != endItem) {
73 <<
"decodeInterval: accepting objects of CLID " <<
item->id()
74 <<
" key " <<
item->key() <<
" in the Xing range ["
76 <<
" with cache refresh frequency "
93 m_autoRetrieveTools =
false;
94 m_checkToolDeps =
false;
100 <<
"Could not locate default store"
102 return StatusCode::FAILURE;
107 <<
"Could not locate ITriggerTime tool"
109 return StatusCode::FAILURE;
117 return StatusCode::SUCCESS;
128 if( xAODEventInfo ) {
129 ATH_MSG_DEBUG(
"Found xAOD::EventInfo="<<xAODEventInfo<<
" SG="<<sg<<
" : "<<*xAODEventInfo);
137 std::lock_guard<std::mutex> lock (*m_slotMutex);
140 const EventInfo* pEvent = einame.empty()?
144 ATH_MSG_DEBUG(
"Converting (PileUp)EventInfo "<<pEvent<<
" SG="<<sg<<
" to xAOD::EventInfo");
146 std::unique_ptr< xAOD::EventInfo > pxAODEventInfo(
new xAOD::EventInfo() );
148 pxAODEventInfo->
setStore( pxAODEventAuxInfo.get() );
149 pxAODEventInfo->setEvtStore( sg );
150 if( !
m_xAODCnvTool->convert( pEvent, pxAODEventInfo.get(),
true,
false ).isSuccess() ) {
160 puei->setStore( puaux.get() );
163 std::vector< xAOD::EventInfo::SubEvent > subEvents;
168 #define DECLARE_SE_TYPE( TYPE ) \
169 { PileUpTimeEventIndex::TYPE, xAOD::EventInfo::TYPE },
178 #undef DECLARE_SE_TYPE
187 const unsigned int countEvents =
std::distance(pu_itr,pu_end);
188 ATH_MSG_VERBOSE(
"CHECKING: There are " << countEvents <<
" subevents in this Event." );
189 for( ; pu_itr != pu_end; ++pu_itr ) {
193 if( !
m_xAODCnvTool->convert( pu_itr->pSubEvt, ei.get(),
true,
false ).isSuccess() ) {
194 ATH_MSG_ERROR(
"Failed to convert EventInfo to xAOD::EventInfo");
200 ei->setEvtStore(tmpSG);
209 auto typeItr = pileupTypeMap.find( pu_itr->type() );
211 if( typeItr == pileupTypeMap.end() ) {
214 type = typeItr->second;
216 ATH_MSG_VERBOSE(
"PileUpEventInfo: time = " << pu_itr->time() <<
", index = " << pu_itr->index());
220 EiLink(
"PileUpEventInfo", puei->
size()-1, sg )));
221 ATH_MSG_VERBOSE(
"PileUpEventInfo: time = " << subEvents.back().time() <<
", index = " << subEvents.back().index());
224 if( subEvents.size() ) {
229 if( !sg->
record( std::move( puaux ),
"PileUpEventInfoAux." ).isSuccess()
230 || !sg->
record( std::move( puei ),
"PileUpEventInfo" ).isSuccess() ) {
231 ATH_MSG_ERROR(
"Failed to record xAOD::EventInfoContainer in SG");
238 xAODEventInfo = std::launder(pxAODEventInfo.get());
240 if( ! sg->
record( std::move( pxAODEventAuxInfo ),
"EventInfoAux." ).isSuccess()
241 || ! sg->
record( std::move( pxAODEventInfo ),
"EventInfo" ).isSuccess() ) {
242 ATH_MSG_ERROR(
"Failed to record the new xAOD::EventInfo in SG");
243 xAODEventInfo =
nullptr;
245 ATH_MSG_DEBUG(
"Record the new xAOD::EventInfo "<<pxAODEventInfo.get()<<
" in SG="<<sg);
249 if( !xAODEventInfo ) {
250 ATH_MSG_DEBUG(
"Could not find EventInfo '" << einame <<
"' in store " << sg->name());
252 return xAODEventInfo;
258 static const InterfaceID IID_IPileUpMergeSvc(9991, 1, 0);
259 return IID_IPileUpMergeSvc;
276 return AthService::queryInterface(riid, ppvInterface);
279 return StatusCode::SUCCESS;
284 return m_ranges[make_pair(
id, dataKey)].contains(iXing);
292 return (
r.contains(iXing) &&
r.doRefresh(
double(random())*(1./RAND_MAX)));
312 proxy->setObject ((DataObject*)0);
315 <<
"clearDataCachesByFolder: object with clid "
316 <<
item.first.first <<
" and key " <<
item.first.second
317 <<
" removed from cache "
318 << pSubEvtSG->name() <<
endmsg;
327 <<
"clearDataCachesByFolder: done with store " << pSubEvtSG->name()
332 sc=StatusCode::SUCCESS;
StatusCode record(T *p2BRegistered, const TKEY &key)
Record an object with a key.
void setSubEvents(const std::vector< SubEvent > &value)
Set the pileup events that were used in the simulation.
static const InterfaceID & interfaceID()
Retrieve interface ID.
This class provides information about an overlaid event. It extends EventInfo with a list of sub-evts...
virtual const_iterator end() const =0
const xAOD::EventInfo * getPileUpEvent(StoreGateSvc *sg, const std::string &einame) const
get EventInfo from SG, by default using p_overStore
Auxiliary information about the event.
PileUpType
Enumerator describing the types of pileup events.
bool isLive(const KEY &key, int iXing)
is iXing live for DATA/key?
bool doRefresh(const Range &r, int iXing)
This class provides general information about an event. It extends EventInfo with a list of sub-evts ...
virtual StatusCode initialize()
Service initialisation.
#define ATH_MSG_VERBOSE(x)
std::string m_EventInfoKeyName
the preferred mechanism to access information from the different event stores in a pileup job.
SubEvent::iterator beginSubEvt()
void emptyTrash()
throw away bad objects
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface)
The Athena Transient Store API.
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
void setStore(const SG::IConstAuxStore *store)
Set the store associated with this object.
ServiceHandle< StoreGateSvc > p_overStore
overlaid SG (default)
@ Unknown
Type not known/specified.
::StatusCode StatusCode
StatusCode definition for legacy code.
an interface to SG::Folder with an attached bunch crossing interval
#define CHECK(...)
Evaluate an expression and check for errors.
virtual const_iterator begin() const =0
AthROOTErrorHandlerSvc * svc
virtual SG::DataProxy * proxy_exact(SG::sgkey_t sgkey) const override final
Get proxy given a hashed key+clid.
uint32_t CLID
The Class ID type.
void decodeIntervals()
setup PileUpIntervals
StatusCode clearDataCaches()
clear bkg event caches from unneeded data objects (as configured using PileUpXingFolder CacheRefreshF...
virtual sgkey_t stringToKey(const std::string &str, CLID clid) override final
Find the key for a string/CLID pair.
ElementLink implementation for ROOT usage.
Auxiliary information about the pileup events.
virtual int firstXing() const =0
ToolHandleArray< IPileUpXingFolder > m_intervals
Property: bunch xing intervals.
SG::IFolder::const_iterator const_iterator
This class provides general information about an event. Event information is provided by the accessor...
value_type push_back(value_type pElem)
Add an element to the end of the collection.
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
const T * tryConstRetrieve() const
Class describing the basic event information.
This class provides information about an overlaid event. It extends EventInfo with a list of sub-evts...
virtual float cacheRefreshFrequency() const =0
controls the rate at which we clear data objs in this folder at the end of event
#define ATH_MSG_WARNING(x)
the preferred mechanism to access information from the different event stores in a pileup job.
PileUpMergeSvc(const std::string &name, ISvcLocator *svc)
Standard Gaudi Constructor.
virtual int lastXing() const =0
an interface to SG::Folder with an attached bunch crossing interval
const std::vector< SubEvent > & subEvents() const
Get the pileup events that were used in the simulation.
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
PileUpTimeEventIndex::PileUpType pileup_type
size_type size() const noexcept
Returns the number of elements in the collection.
#define DECLARE_SE_TYPE(TYPE)
ToolHandle< xAODMaker::IEventInfoCnvTool > m_xAODCnvTool
property: Handle to the EventInfo -> xAOD::EventInfo converter tool
ToolHandle< ITriggerTime > m_pITriggerTime
allows to apply a trigger time offset
Class describing the properties of one pileup sub-event.
SubEvent::iterator endSubEvt()
interface to a tool that returns the time offset of the current trigger. Used by PileUpMergeSvc
the active crossing range for a data object (CLID/key combination)
BooleanProperty m_returnTimedData