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