68 const std::string& name,
69 const IInterface* parent )
70 : base_class(
type, name, parent ) {}
77 renounceArray( handles.
in );
79 renounceArray( handles.
views );
82 if ( handles.
views.empty() ) {
89 return StatusCode::SUCCESS;
99 return StatusCode::SUCCESS;
108 const bool found = std::any_of(m_TrigCompositeContainer.begin(),
109 m_TrigCompositeContainer.end(), [&](
const auto& writeHandleKey) { return writeHandleKey.key() == entry; } );
111 ATH_MSG_ERROR(
"FixLinks contains the entry " << entry <<
", however this is not one of this EDMCreator tool's managed TrigCompositeContainers.");
112 ATH_MSG_ERROR(
"Configure FixLinks to be a sub-set of TrigCompositeContainer");
113 return StatusCode::FAILURE;
117 for (
const auto& writeHandleKey: m_TrigCompositeContainer ) {
118 const bool doFixLinks = std::any_of(
m_fixLinks.begin(),
m_fixLinks.end(), [&](
const std::string& s) { return s == writeHandleKey.key(); } );
133#define INIT(__TYPE) \
134 ATH_CHECK( initHandles( HandlesGroup<__TYPE>( m_##__TYPE, m_##__TYPE##InViews, m_##__TYPE##Views ) ) );
136#define INIT_XAOD(__TYPE, __STORE_TYPE) \
137 ATH_CHECK( initHandles( HandlesGroup<xAOD::__TYPE>( m_##__TYPE, m_##__TYPE##InViews, m_##__TYPE##Views ) ) ); \
138 ATH_CHECK( initAuxKey<xAOD::__STORE_TYPE>( m_##__TYPE.keys() ) );
141 INIT_XAOD( TrigCompositeContainer, TrigCompositeAuxContainer );
145 INIT_XAOD( TrigRingerRingsContainer, TrigRingerRingsAuxContainer );
150 INIT_XAOD( TrackParticleContainer, TrackParticleAuxContainer );
153 INIT_XAOD( L2StandAloneMuonContainer, L2StandAloneMuonAuxContainer );
154 INIT_XAOD( L2CombinedMuonContainer, L2CombinedMuonAuxContainer );
155 INIT_XAOD( L2IsoMuonContainer, L2IsoMuonAuxContainer );
157 INIT_XAOD( TauJetContainer, TauJetAuxContainer );
158 INIT_XAOD( DiTauJetContainer, DiTauJetAuxContainer );
159 INIT_XAOD( TauTrackContainer, TauTrackAuxContainer );
161 INIT_XAOD( VertexContainer, VertexAuxContainer );
162 INIT_XAOD( TrigBphysContainer, TrigBphysAuxContainer );
163 INIT_XAOD( BTaggingContainer, BTaggingAuxContainer );
164 INIT_XAOD( BTagVertexContainer, BTagVertexAuxContainer );
166 INIT_XAOD( FlowElementContainer, FlowElementAuxContainer );
168 INIT_XAOD( HIEventShapeContainer, HIEventShapeAuxContainer );
170 INIT_XAOD( AFPSiHitsClusterContainer, AFPSiHitsClusterAuxContainer );
171 INIT_XAOD( AFPTrackContainer, AFPTrackAuxContainer );
172 INIT_XAOD( AFPToFTrackContainer, AFPToFTrackAuxContainer );
173 INIT_XAOD( AFPProtonContainer, AFPProtonAuxContainer );
174 INIT_XAOD( AFPVertexContainer, AFPVertexAuxContainer );
177 INIT_XAOD( eFexEMRoIContainer, eFexEMRoIAuxContainer );
178 INIT_XAOD( eFexTauRoIContainer, eFexTauRoIAuxContainer );
179 INIT_XAOD( jFexTauRoIContainer, jFexTauRoIAuxContainer );
180 INIT_XAOD( jFexFwdElRoIContainer, jFexFwdElRoIAuxContainer );
181 INIT_XAOD( jFexSRJetRoIContainer, jFexSRJetRoIAuxContainer );
182 INIT_XAOD( jFexLRJetRoIContainer, jFexLRJetRoIAuxContainer );
183 INIT_XAOD( jFexMETRoIContainer, jFexMETRoIAuxContainer );
184 INIT_XAOD( jFexSumETRoIContainer, jFexSumETRoIAuxContainer );
185 INIT_XAOD( gFexJetRoIContainer, gFexJetRoIAuxContainer );
186 INIT_XAOD( gFexGlobalRoIContainer, gFexGlobalRoIAuxContainer);
187 INIT_XAOD( MuonRoIContainer, MuonRoIAuxContainer );
192#define INIT_SHALLOW(__TYPE) \
193 ATH_CHECK( m_##__TYPE##ShallowCopy.initialize() ); \
194 renounceArray( m_##__TYPE##ShallowCopy ); \
195 for ( auto k: m_##__TYPE##ShallowCopy ) \
196 m_##__TYPE##ShallowCopyOut.push_back(k.key()); \
197 ATH_CHECK( m_##__TYPE##ShallowCopyOut.initialize() ); \
198 if(m_renounceOutputs) { renounceArray( m_##__TYPE##ShallowCopyOut ); }
205 return StatusCode::SUCCESS;
215 data = std::make_unique<T>();
220 return h.record( std::move(
data ) );
221 return StatusCode::SUCCESS;
225template<
class T,
class STORE>
234 data = std::make_unique<T>();
235 store = std::make_unique<STORE>();
242 return h.record( std::move(
data ), std::move(
store ) );
243 return StatusCode::SUCCESS;
249 EventContext
const&, T & )
const {
251 return StatusCode::FAILURE;
257 EventContext
const& context, T & output )
const {
259 using type_in_container =
typename T::base_value_type;
265 return StatusCode::SUCCESS;
271 ATH_MSG_DEBUG(
"fixLinks: No collections defined for this tool");
272 return StatusCode::SUCCESS;
275 ATH_MSG_DEBUG(
"fixLinks called for " <<
m_fixLinks.size() <<
" of " << m_TrigCompositeContainer.size() <<
" collections");
278 int writeHandleArrayIndex = -1;
284 for (
const auto& writeHandleKey: m_TrigCompositeContainer ) {
286 const bool doFixLinks = std::any_of(
m_fixLinks.begin(),
m_fixLinks.end(), [&](
const std::string& s) { return s == writeHandleKey.key(); } );
287 if ( not doFixLinks ) {
288 ATH_MSG_DEBUG(
"Not requested to fix TrigComposite ElementLinks for " << writeHandleKey.key());
293 ++writeHandleArrayIndex;
295 ATH_MSG_DEBUG(
"Fixing links: confirm collection is there: " << writeHandleKey.key() <<
", write handle array index: " << writeHandleArrayIndex);
297 readHandleKey = writeHandleKey.
key();
299 if ( not readHandle.isValid() ) {
300 ATH_MSG_ERROR(
"Collection is not present. " << readHandleKey.
key() <<
" should have been created by createIfMissing.");
301 return StatusCode::FAILURE;
304 ATH_MSG_DEBUG(
"Collection exists with size " << readHandle->size() <<
" Decision objects" );
313 int decisionObjectIndex = -1;
314 for (
auto inputDecision : *( readHandle.cptr() ) ) {
315 ++decisionObjectIndex;
318 std::vector< SG::sgkey_t > remappedKeys = inputDecision->linkColKeys();
319 std::vector< xAOD::TrigComposite::index_type > remappedIndexes = inputDecision->linkColIndices();
322 size_t const collectionTotal = inputDecision->linkColNames().size();
323 ATH_MSG_DEBUG(
" Decision object #" << decisionObjectIndex <<
" has " << collectionTotal <<
" links");
324 for (
size_t elementLinkIndex = 0; elementLinkIndex < collectionTotal; ++elementLinkIndex ) {
327 std::string
const collectionName = inputDecision->linkColNames().at(elementLinkIndex);
328 SG::sgkey_t const collectionKey = remappedKeys.at(elementLinkIndex);
329 std::string
const keyString = *( evtStore()->keyToString( collectionKey ) );
335 bool isRemapped = evtStore()->tryELRemap( collectionKey, collectionIndex, newKey, newIndex);
338 ATH_MSG_DEBUG(
" Remap link [" << collectionName <<
"] from " << keyString <<
" to " << *( evtStore()->
keyToString( newKey ) ) <<
", from index " << collectionIndex <<
" to index " << newIndex );
339 remappedKeys[ elementLinkIndex ] = newKey;
340 remappedIndexes[ elementLinkIndex ] = newIndex;
344 ATH_MSG_DEBUG(
" StoreGate did not remap link [" << collectionName <<
"] from " << keyString <<
" index " << collectionIndex );
351 keyDecor( *inputDecision ) = std::move(remappedKeys);
352 indexDecor( *inputDecision ) = std::move(remappedIndexes);
357 return StatusCode::SUCCESS;
361template<
typename T,
typename STORE,
typename G,
typename M>
369 using AuxType = std::conditional_t<std::is_void_v<STORE>, T, STORE>;
374 for (
size_t i = 0; i < handles.
out.size(); ++i) {
378 if ( handles.
views.empty() ) {
382 if ( readHandle.isValid() ) {
384 generator.create(
false,
false);
390 if constexpr (!std::is_void_v<STORE>) {
391 rhkAux = rhk.
key() +
"Aux.";
393 if ( !readAuxHandle.isValid() ) {
402 generator.create(
true,
true);
413 if ( handles.
out.size() == 1 ) {
414 generator.create(
true,
true);
416 const bool doCreate = i == 0 or handles.
out.at(i-1).key() != whk.
key();
417 const bool doRecord = i == handles.
out.size()-1 or handles.
out.at(i+1).key() != whk.
key();
418 ATH_MSG_DEBUG(
"Instructing generator " << (doCreate ?
"to" :
"NOT TO") <<
" create collection and " << (doRecord ?
"to" :
"NOT TO") <<
" record collection in this iteration");
419 generator.create(doCreate, doRecord);
423 ATH_MSG_DEBUG(
"Will be trying to merge from the " << viewsReadHandleKey.
key() <<
" view container into that output");
426 if ( viewsHandle.isValid() ) {
428 ATH_MSG_DEBUG(
"Will be merging from " << viewsHandle->size() <<
" views using in-view key " << inViewReadHandleKey.
key() );
429 ATH_CHECK( (this->*merger)( *viewsHandle, inViewReadHandleKey , context, *generator.data.get() ) );
431 ATH_MSG_DEBUG(
"Views " << viewsReadHandleKey.
key() <<
" are missing. Will leave " << whk.
key() <<
" output collection empty.");
436 const std::string viewsReadHandleKeyProbe = viewsReadHandleKey.
key() +
"_probe";
437 ATH_MSG_VERBOSE(
"Will try to merge from the " << viewsReadHandleKeyProbe <<
" view container into that output");
443 ATH_CHECK(evtStore()->retrieve(viewsContainer_probe, viewsReadHandleKeyProbe));
445 if ( viewsContainer_probe ) {
447 ATH_MSG_DEBUG(
"Will be merging from " << viewsContainer_probe->
size() <<
" probe views using in-view key " << inViewReadHandleKey.
key() );
448 ATH_CHECK( (this->*merger)( *viewsContainer_probe, inViewReadHandleKey , context, *generator.data.get() ) );
450 ATH_MSG_VERBOSE(
"Probe views " << viewsReadHandleKeyProbe <<
" are missing.");
456 ATH_CHECK( generator.record( writeHandle ) );
459 return StatusCode::SUCCESS;
469#define CREATE(__TYPE) \
471 plainGenerator<__TYPE> generator; \
472 ATH_CHECK( (createIfMissing<__TYPE, void>( context, ConstHandlesGroup<__TYPE>( m_##__TYPE, m_##__TYPE##InViews, m_##__TYPE##Views ), generator, &HLTEDMCreator::noMerge<__TYPE>)) ); \
479#define CREATE_XAOD(__TYPE, __STORE_TYPE) \
481 xAODGenerator<xAOD::__TYPE, xAOD::__STORE_TYPE> generator; \
482 ATH_CHECK( (createIfMissing<xAOD::__TYPE, xAOD::__STORE_TYPE>( context, ConstHandlesGroup<xAOD::__TYPE>( m_##__TYPE, m_##__TYPE##InViews, m_##__TYPE##Views ), generator, &HLTEDMCreator::viewsMerge<xAOD::__TYPE>)) ); \
486 CREATE_XAOD( TrigCompositeContainer, TrigCompositeAuxContainer );
493 CREATE_XAOD( TrigRingerRingsContainer, TrigRingerRingsAuxContainer );
494 CREATE_XAOD( TrackParticleContainer, TrackParticleAuxContainer );
497 CREATE_XAOD( L2StandAloneMuonContainer, L2StandAloneMuonAuxContainer );
498 CREATE_XAOD( L2CombinedMuonContainer, L2CombinedMuonAuxContainer );
499 CREATE_XAOD( L2IsoMuonContainer, L2IsoMuonAuxContainer );
501 CREATE_XAOD( TauJetContainer, TauJetAuxContainer );
502 CREATE_XAOD( DiTauJetContainer, DiTauJetAuxContainer );
503 CREATE_XAOD( TauTrackContainer, TauTrackAuxContainer );
505 CREATE_XAOD( FlowElementContainer, FlowElementAuxContainer );
508 CREATE_XAOD( TrigBphysContainer, TrigBphysAuxContainer );
509 CREATE_XAOD( BTaggingContainer,BTaggingAuxContainer );
510 CREATE_XAOD( BTagVertexContainer,BTagVertexAuxContainer );
512 CREATE_XAOD( HIEventShapeContainer, HIEventShapeAuxContainer );
514 CREATE_XAOD( AFPSiHitsClusterContainer, AFPSiHitsClusterAuxContainer );
515 CREATE_XAOD( AFPTrackContainer, AFPTrackAuxContainer );
516 CREATE_XAOD( AFPToFTrackContainer, AFPToFTrackAuxContainer );
517 CREATE_XAOD( AFPProtonContainer, AFPProtonAuxContainer );
518 CREATE_XAOD( AFPVertexContainer, AFPVertexAuxContainer );
521 CREATE_XAOD( eFexEMRoIContainer, eFexEMRoIAuxContainer );
522 CREATE_XAOD( eFexTauRoIContainer, eFexTauRoIAuxContainer );
523 CREATE_XAOD( jFexTauRoIContainer, jFexTauRoIAuxContainer );
524 CREATE_XAOD( jFexFwdElRoIContainer, jFexFwdElRoIAuxContainer );
525 CREATE_XAOD( jFexSRJetRoIContainer, jFexSRJetRoIAuxContainer );
526 CREATE_XAOD( jFexLRJetRoIContainer, jFexLRJetRoIAuxContainer );
527 CREATE_XAOD( jFexMETRoIContainer, jFexMETRoIAuxContainer );
528 CREATE_XAOD( jFexSumETRoIContainer, jFexSumETRoIAuxContainer );
529 CREATE_XAOD( gFexJetRoIContainer, gFexJetRoIAuxContainer );
530 CREATE_XAOD( gFexGlobalRoIContainer, gFexGlobalRoIAuxContainer);
531 CREATE_XAOD( MuonRoIContainer, MuonRoIAuxContainer );
539 #define CREATE_SHALLOW(__TYPE) \
541 for ( size_t index = 0; index < m_##__TYPE##ShallowCopy.size(); ++index ){ \
542 auto readHandle = SG::makeHandle<xAOD::__TYPE> ( m_##__TYPE##ShallowCopy[index], context ); \
543 if ( not readHandle.isValid() ) { \
544 ATH_MSG_DEBUG( "Creating missing "#__TYPE"ShallowCopy " << m_##__TYPE##ShallowCopy[index].key() ); \
545 auto writeHandle = SG::makeHandle( m_##__TYPE##ShallowCopyOut[index], context ); \
546 ATH_CHECK( writeHandle.record( std::make_unique<xAOD::__TYPE>(), std::make_unique<xAOD::ShallowAuxContainer>() )); \
548 ATH_MSG_DEBUG( #__TYPE"ShallowCopy " << m_##__TYPE##ShallowCopyOut[index].key() << " present in the event, done nothing"); \
556 #undef CREATE_SHALLOW
562 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define CREATE_SHALLOW(__TYPE)
#define INIT_XAOD(__TYPE, __STORE_TYPE)
#define INIT_SHALLOW(__TYPE)
#define CREATE_XAOD(__TYPE, __STORE_TYPE)
Handle class for adding a decoration to an object.
const std::string * keyToString(sgkey_t key) const
Find the string corresponding to a given key.
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
DataVector< SG::View > ViewContainer
View container for recording in StoreGate.
Header file for AthHistogramAlgorithm.
Storable container for CaloCluster.
size_type size() const noexcept
Returns the number of elements in the collection.
Class to define the ElectronContainer.
StatusCode createIfMissing(const EventContext &context, const ConstHandlesGroup< T > &handles, G &generator, M merger) const
Gaudi::Property< bool > m_dumpSGAfter
Gaudi::Property< bool > m_renounceOutputs
StatusCode initAuxKey(const std::vector< SG::VarHandleKey * > &keys)
Register AuxStore keys for the given keys.
virtual StatusCode initialize() override
StatusCode viewsMerge(ViewContainer const &views, const SG::ReadHandleKey< T > &inViewKey, EventContext const &context, T &output) const
StatusCode initHandles(const HandlesGroup< T > &handles)
Init related handles.
SG::WriteDecorHandleKeyArray< xAOD::TrigCompositeContainer, std::vector< SG::sgkey_t > > m_remapLinkColKeys
SG::WriteDecorHandleKeyArray< xAOD::TrigCompositeContainer, std::vector< xAOD::TrigComposite::index_type > > m_remapLinkColIndices
Gaudi::Property< bool > m_dumpSGBefore
Gaudi::Property< std::vector< std::string > > m_fixLinks
virtual StatusCode createOutput(const EventContext &context) const override
StatusCode fixLinks(EventContext const &context) const
StatusCode noMerge(ViewContainer const &views, const SG::ReadHandleKey< T > &inViewKey, EventContext const &context, T &output) const
Class to define the PhotonContainer.
Property holding a SG store/key/clid from which a ReadHandle is made.
A property holding a SG store/key/clid from which a VarHandle is made.
const std::string & key() const
Return the StoreGate ID for the referenced object.
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Handle class for adding a decoration to an object.
Property holding a SG store/key/clid from which a WriteHandle is made.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
The Athena Transient Store API.
Container from TrigCaloCluster type objects.
Container from TrigEMCluster type objects.
File: TrigElectronContainer.h.
File: TrigPhotonContainer.h.
StatusCode mergeViewCollection(ViewContainer const &viewVector, SG::ReadHandleKey< T > const &queryKey, EventContext const &sourceContext, T &outputData)
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
const SG::WriteHandleKeyArray< T > & out
const SG::ReadHandleKeyArray< T > & in
const SG::ReadHandleKeyArray< ViewContainer > & views
SG::ReadHandleKeyArray< ViewContainer > & views
SG::WriteHandleKeyArray< T > & out
SG::ReadHandleKeyArray< T > & in
std::unique_ptr< T > data
StatusCode record(SG::WriteHandle< T > &h)
void create(bool create, bool record)
void create(bool create, bool record)
std::unique_ptr< STORE > store
StatusCode record(SG::WriteHandle< T > &h)
std::unique_ptr< T > data