112{
113 const EventContext& ctx = Gaudi::Hive::currentContext();
114
118 : sg->tryConstRetrieve<xAOD::
EventInfo>( einame );
119 if( xAODEventInfo ) {
120 ATH_MSG_DEBUG(
"Found xAOD::EventInfo="<<xAODEventInfo<<
" SG="<<sg<<
" : "<<*xAODEventInfo);
122
124 } else {
125
126
127
128 std::lock_guard<std::mutex>
lock (*m_slotMutex);
129
130
131 const EventInfo* pEvent = einame.empty()?
133 : sg->tryConstRetrieve< ::
EventInfo >( einame );
134 if( pEvent ) {
135 ATH_MSG_DEBUG(
"Converting (PileUp)EventInfo "<<pEvent<<
" SG="<<sg<<
" to xAOD::EventInfo");
136
137 std::unique_ptr< xAOD::EventInfo > pxAODEventInfo(
new xAOD::EventInfo() );
139 pxAODEventInfo->setStore( pxAODEventAuxInfo.get() );
140 pxAODEventInfo->setEvtStore( sg );
141 if( !
m_xAODCnvTool->convert( ctx, pEvent, pxAODEventInfo.get(),
true,
false ).isSuccess() ) {
143 return nullptr;
144 }
145
147 if( pileupEvent ) {
148
151 puei->setStore( puaux.get() );
152
153
154 std::vector< xAOD::EventInfo::SubEvent > subEvents;
155
156
159#define DECLARE_SE_TYPE( TYPE ) \
160 { PileUpTimeEventIndex::TYPE, xAOD::EventInfo::TYPE },
161
168
169#undef DECLARE_SE_TYPE
170 };
171
172
174
175
176 auto pu_itr = pileupEvent->beginSubEvt();
177 auto pu_end = pileupEvent->endSubEvt();
178 const unsigned int countEvents = std::distance(pu_itr,pu_end);
179 ATH_MSG_VERBOSE(
"CHECKING: There are " << countEvents <<
" subevents in this Event." );
180 for( ; pu_itr != pu_end; ++pu_itr ) {
181
183
184 if( !
m_xAODCnvTool->convert( ctx, pu_itr->pSubEvt, ei.get(),
true,
false ).isSuccess() ) {
185 ATH_MSG_ERROR(
"Failed to convert EventInfo to xAOD::EventInfo");
186 continue;
187 }
188
190 if(tmpSG) {
191 ei->setEvtStore(tmpSG);
193 } else {
195 }
196
197 puei->push_back( ei.release() );
198
199
200 auto typeItr = pileupTypeMap.find( pu_itr->type() );
202 if( typeItr == pileupTypeMap.end() ) {
204 } else {
205 type = typeItr->second;
206 }
207 ATH_MSG_VERBOSE(
"PileUpEventInfo: time = " << pu_itr->time() <<
", index = " << pu_itr->index());
208 subEvents.push_back( xAOD::EventInfo::SubEvent( pu_itr->time(),
209 pu_itr->index(),
211 EiLink( "PileUpEventInfo", puei->size()-1, sg )));
212 ATH_MSG_VERBOSE(
"PileUpEventInfo: time = " << subEvents.back().time() <<
", index = " << subEvents.back().index());
213 }
214
215 if( subEvents.size() ) {
216
217 pxAODEventInfo->setSubEvents( subEvents );
218
219
220 if( !sg->
record( std::move( puaux ),
"PileUpEventInfoAux." ).isSuccess()
221 || !sg->
record( std::move( puei ),
"PileUpEventInfo" ).isSuccess() ) {
222 ATH_MSG_ERROR(
"Failed to record xAOD::EventInfoContainer in SG");
223 }
224 }
225 }
226
227
228
229 xAODEventInfo = std::launder(pxAODEventInfo.get());
230
231 const auto ptrVal = pxAODEventInfo.get();
232 if( ! sg->
record( std::move( pxAODEventAuxInfo ),
"EventInfoAux." ).isSuccess()
233 || ! sg->
record( std::move( pxAODEventInfo ),
"EventInfo" ).isSuccess() ) {
234 ATH_MSG_ERROR(
"Failed to record the new xAOD::EventInfo in SG");
235 xAODEventInfo = nullptr;
236 }
237 ATH_MSG_DEBUG(
"Record the new xAOD::EventInfo "<<ptrVal<<
" in SG="<<sg);
238 }
239 }
240
241 if( !xAODEventInfo ) {
242 ATH_MSG_DEBUG(
"Could not find EventInfo '" << einame <<
"' in store " << sg->name());
243 }
244 return xAODEventInfo;
245}
ElementLink()
Default constructor.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(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)
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