113{
114 const EventContext& ctx = Gaudi::Hive::currentContext();
115
119 : sg->tryConstRetrieve<xAOD::
EventInfo>( einame );
120 if( xAODEventInfo ) {
121 ATH_MSG_DEBUG(
"Found xAOD::EventInfo="<<xAODEventInfo<<
" SG="<<sg<<
" : "<<*xAODEventInfo);
123
125 } else {
126
127
128
129 std::lock_guard<std::mutex>
lock (*m_slotMutex);
130
131
132 const EventInfo* pEvent = einame.empty()?
134 : sg->tryConstRetrieve< ::
EventInfo >( einame );
135 if( pEvent ) {
136 ATH_MSG_DEBUG(
"Converting (PileUp)EventInfo "<<pEvent<<
" SG="<<sg<<
" to xAOD::EventInfo");
137
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() ) {
144 return nullptr;
145 }
146
148 if( pileupEvent ) {
149
152 puei->setStore( puaux.get() );
153
154
155 std::vector< xAOD::EventInfo::SubEvent > subEvents;
156
157
160#define DECLARE_SE_TYPE( TYPE ) \
161 { PileUpTimeEventIndex::TYPE, xAOD::EventInfo::TYPE },
162
169
170#undef DECLARE_SE_TYPE
171 };
172
173
175
176
177 auto pu_itr = pileupEvent->beginSubEvt();
178 auto pu_end = pileupEvent->endSubEvt();
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 ) {
182
184
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");
187 continue;
188 }
189
191 if(tmpSG) {
192 ei->setEvtStore(tmpSG);
194 } else {
196 }
197
198 puei->push_back( ei.release() );
199
200
201 auto typeItr = pileupTypeMap.find( pu_itr->type() );
203 if( typeItr == pileupTypeMap.end() ) {
205 } else {
206 type = typeItr->second;
207 }
208 ATH_MSG_VERBOSE(
"PileUpEventInfo: time = " << pu_itr->time() <<
", index = " << pu_itr->index());
209 subEvents.push_back( xAOD::EventInfo::SubEvent( pu_itr->time(),
210 pu_itr->index(),
212 EiLink( "PileUpEventInfo", puei->size()-1, sg )));
213 ATH_MSG_VERBOSE(
"PileUpEventInfo: time = " << subEvents.back().time() <<
", index = " << subEvents.back().index());
214 }
215
216 if( subEvents.size() ) {
217
218 pxAODEventInfo->setSubEvents( subEvents );
219
220
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");
224 }
225 }
226 }
227
228
229
230 xAODEventInfo = std::launder(pxAODEventInfo.get());
231
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;
237 }
238 ATH_MSG_DEBUG(
"Record the new xAOD::EventInfo "<<ptrVal<<
" in SG="<<sg);
239 }
240 }
241
242 if( !xAODEventInfo ) {
243 ATH_MSG_DEBUG(
"Could not find EventInfo '" << einame <<
"' in store " << sg->name());
244 }
245 return xAODEventInfo;
246}
ElementLink()
Default constructor.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Old Athena::TPCnvVers::Old PileUpEventInfo
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
#define DECLARE_SE_TYPE(TYPE)
struct TBPatternUnitContext Unknown
ToolHandle< xAODMaker::IEventInfoCnvTool > m_xAODCnvTool
property: Handle to the EventInfo -> xAOD::EventInfo converter tool
StatusCode record(T *p2BRegistered, const TKEY &key)
Record an object with a key.
const T * tryConstRetrieve() const
PileUpType
Enumerator describing the types of pileup events.
@ Unknown
Type not known/specified.
EventInfoContainer_v1 EventInfoContainer
Define the latest version of the container.
EventInfoAuxContainer_v1 EventInfoAuxContainer
Define the latest version of the auxiliary container.
EventAuxInfo_v3 EventAuxInfo
Definition of the latest event auxiliary info version.
PileUpTimeEventIndex::PileUpType pileup_type