69 const std::string& name,
70 const IInterface* parent )
71 : base_class(
type, name, parent ) {}
78 renounceArray( handles.
in );
80 renounceArray( handles.
views );
83 if ( handles.
views.empty() ) {
90 return StatusCode::SUCCESS;
100 return StatusCode::SUCCESS;
109 const bool found = std::any_of(m_TrigCompositeContainer.begin(),
110 m_TrigCompositeContainer.end(), [&](
const auto& writeHandleKey) { return writeHandleKey.key() == entry; } );
112 ATH_MSG_ERROR(
"FixLinks contains the entry " << entry <<
", however this is not one of this EDMCreator tool's managed TrigCompositeContainers.");
113 ATH_MSG_ERROR(
"Configure FixLinks to be a sub-set of TrigCompositeContainer");
114 return StatusCode::FAILURE;
118 for (
const auto& writeHandleKey: m_TrigCompositeContainer ) {
119 const bool doFixLinks = std::any_of(
m_fixLinks.begin(),
m_fixLinks.end(), [&](
const std::string& s) { return s == writeHandleKey.key(); } );
134#define INIT(__TYPE) \
135 ATH_CHECK( initHandles( HandlesGroup<__TYPE>( m_##__TYPE, m_##__TYPE##InViews, m_##__TYPE##Views ) ) );
137#define INIT_XAOD(__TYPE, __STORE_TYPE) \
138 ATH_CHECK( initHandles( HandlesGroup<xAOD::__TYPE>( m_##__TYPE, m_##__TYPE##InViews, m_##__TYPE##Views ) ) ); \
139 ATH_CHECK( initAuxKey<xAOD::__STORE_TYPE>( m_##__TYPE.keys() ) );
146 INIT_XAOD( TrigRingerRingsContainer, TrigRingerRingsAuxContainer );
151 INIT_XAOD( TrackParticleContainer, TrackParticleAuxContainer );
154 INIT_XAOD( L2StandAloneMuonContainer, L2StandAloneMuonAuxContainer );
155 INIT_XAOD( L2CombinedMuonContainer, L2CombinedMuonAuxContainer );
156 INIT_XAOD( L2IsoMuonContainer, L2IsoMuonAuxContainer );
158 INIT_XAOD( TauJetContainer, TauJetAuxContainer );
159 INIT_XAOD( DiTauJetContainer, DiTauJetAuxContainer );
160 INIT_XAOD( TauTrackContainer, TauTrackAuxContainer );
162 INIT_XAOD( VertexContainer, VertexAuxContainer );
163 INIT_XAOD( TrigBphysContainer, TrigBphysAuxContainer );
164 INIT_XAOD( BTaggingContainer, BTaggingAuxContainer );
165 INIT_XAOD( BTagVertexContainer, BTagVertexAuxContainer );
167 INIT_XAOD( FlowElementContainer, FlowElementAuxContainer );
169 INIT_XAOD( HIEventShapeContainer, HIEventShapeAuxContainer );
171 INIT_XAOD( AFPSiHitsClusterContainer, AFPSiHitsClusterAuxContainer );
172 INIT_XAOD( AFPTrackContainer, AFPTrackAuxContainer );
173 INIT_XAOD( AFPToFTrackContainer, AFPToFTrackAuxContainer );
174 INIT_XAOD( AFPProtonContainer, AFPProtonAuxContainer );
175 INIT_XAOD( AFPVertexContainer, AFPVertexAuxContainer );
178 INIT_XAOD( eFexEMRoIContainer, eFexEMRoIAuxContainer );
179 INIT_XAOD( eFexTauRoIContainer, eFexTauRoIAuxContainer );
180 INIT_XAOD( jFexTauRoIContainer, jFexTauRoIAuxContainer );
181 INIT_XAOD( jFexFwdElRoIContainer, jFexFwdElRoIAuxContainer );
182 INIT_XAOD( jFexSRJetRoIContainer, jFexSRJetRoIAuxContainer );
183 INIT_XAOD( jFexLRJetRoIContainer, jFexLRJetRoIAuxContainer );
184 INIT_XAOD( jFexMETRoIContainer, jFexMETRoIAuxContainer );
185 INIT_XAOD( jFexSumETRoIContainer, jFexSumETRoIAuxContainer );
186 INIT_XAOD( gFexJetRoIContainer, gFexJetRoIAuxContainer );
187 INIT_XAOD( gFexGlobalRoIContainer, gFexGlobalRoIAuxContainer);
188 INIT_XAOD( MuonRoIContainer, MuonRoIAuxContainer );
193#define INIT_SHALLOW(__TYPE) \
194 ATH_CHECK( m_##__TYPE##ShallowCopy.initialize() ); \
195 renounceArray( m_##__TYPE##ShallowCopy ); \
196 for ( auto k: m_##__TYPE##ShallowCopy ) \
197 m_##__TYPE##ShallowCopyOut.push_back(k.key()); \
198 ATH_CHECK( m_##__TYPE##ShallowCopyOut.initialize() ); \
199 if(m_renounceOutputs) { renounceArray( m_##__TYPE##ShallowCopyOut ); }
206 return StatusCode::SUCCESS;
216 data = std::make_unique<T>();
221 return h.record( std::move(
data ) );
222 return StatusCode::SUCCESS;
226template<
class T,
class STORE>
235 data = std::make_unique<T>();
236 store = std::make_unique<STORE>();
243 return h.record( std::move(
data ), std::move(
store ) );
244 return StatusCode::SUCCESS;
250 EventContext
const&, T & )
const {
252 return StatusCode::FAILURE;
258 EventContext
const& context, T & output )
const {
260 using type_in_container =
typename T::base_value_type;
266 return StatusCode::SUCCESS;
272 ATH_MSG_DEBUG(
"fixLinks: No collections defined for this tool");
273 return StatusCode::SUCCESS;
276 ATH_MSG_DEBUG(
"fixLinks called for " <<
m_fixLinks.size() <<
" of " << m_TrigCompositeContainer.size() <<
" collections");
279 int writeHandleArrayIndex = -1;
285 for (
const auto& writeHandleKey: m_TrigCompositeContainer ) {
287 const bool doFixLinks = std::any_of(
m_fixLinks.begin(),
m_fixLinks.end(), [&](
const std::string& s) { return s == writeHandleKey.key(); } );
288 if ( not doFixLinks ) {
289 ATH_MSG_DEBUG(
"Not requested to fix TrigComposite ElementLinks for " << writeHandleKey.key());
294 ++writeHandleArrayIndex;
296 ATH_MSG_DEBUG(
"Fixing links: confirm collection is there: " << writeHandleKey.key() <<
", write handle array index: " << writeHandleArrayIndex);
298 readHandleKey = writeHandleKey.
key();
300 if ( not readHandle.isValid() ) {
301 ATH_MSG_ERROR(
"Collection is not present. " << readHandleKey.
key() <<
" should have been created by createIfMissing.");
302 return StatusCode::FAILURE;
305 ATH_MSG_DEBUG(
"Collection exists with size " << readHandle->size() <<
" Decision objects" );
314 int decisionObjectIndex = -1;
315 for (
auto inputDecision : *( readHandle.cptr() ) ) {
316 ++decisionObjectIndex;
319 std::vector< SG::sgkey_t > remappedKeys = inputDecision->linkColKeys();
320 std::vector< xAOD::TrigComposite::index_type > remappedIndexes = inputDecision->linkColIndices();
323 size_t const collectionTotal = inputDecision->linkColNames().size();
324 ATH_MSG_DEBUG(
" Decision object #" << decisionObjectIndex <<
" has " << collectionTotal <<
" links");
325 for (
size_t elementLinkIndex = 0; elementLinkIndex < collectionTotal; ++elementLinkIndex ) {
328 std::string
const collectionName = inputDecision->linkColNames().at(elementLinkIndex);
329 SG::sgkey_t const collectionKey = remappedKeys.at(elementLinkIndex);
330 std::string
const keyString = *( evtStore()->keyToString( collectionKey ) );
336 bool isRemapped = evtStore()->tryELRemap( collectionKey, collectionIndex, newKey, newIndex);
339 ATH_MSG_DEBUG(
" Remap link [" << collectionName <<
"] from " << keyString <<
" to " << *( evtStore()->
keyToString( newKey ) ) <<
", from index " << collectionIndex <<
" to index " << newIndex );
340 remappedKeys[ elementLinkIndex ] = newKey;
341 remappedIndexes[ elementLinkIndex ] = newIndex;
345 ATH_MSG_DEBUG(
" StoreGate did not remap link [" << collectionName <<
"] from " << keyString <<
" index " << collectionIndex );
352 keyDecor( *inputDecision ) = remappedKeys;
353 indexDecor( *inputDecision ) = remappedIndexes;
358 return StatusCode::SUCCESS;
362template<
typename T,
typename STORE,
typename G,
typename M>
370 using AuxType = std::conditional_t<std::is_void_v<STORE>, T, STORE>;
375 for (
size_t i = 0; i < handles.
out.size(); ++i) {
379 if ( handles.
views.empty() ) {
383 if ( readHandle.isValid() ) {
385 generator.create(
false,
false);
391 if constexpr (!std::is_void_v<STORE>) {
392 rhkAux = rhk.
key() +
"Aux.";
394 if ( !readAuxHandle.isValid() ) {
403 generator.create(
true,
true);
414 if ( handles.
out.size() == 1 ) {
415 generator.create(
true,
true);
417 const bool doCreate = i == 0 or handles.
out.at(i-1).key() != whk.
key();
418 const bool doRecord = i == handles.
out.size()-1 or handles.
out.at(i+1).key() != whk.
key();
419 ATH_MSG_DEBUG(
"Instructing generator " << (doCreate ?
"to" :
"NOT TO") <<
" create collection and " << (doRecord ?
"to" :
"NOT TO") <<
" record collection in this iteration");
420 generator.create(doCreate, doRecord);
424 ATH_MSG_DEBUG(
"Will be trying to merge from the " << viewsReadHandleKey.
key() <<
" view container into that output");
427 if ( viewsHandle.isValid() ) {
429 ATH_MSG_DEBUG(
"Will be merging from " << viewsHandle->size() <<
" views using in-view key " << inViewReadHandleKey.
key() );
430 ATH_CHECK( (this->*merger)( *viewsHandle, inViewReadHandleKey , context, *generator.data.get() ) );
432 ATH_MSG_DEBUG(
"Views " << viewsReadHandleKey.
key() <<
" are missing. Will leave " << whk.
key() <<
" output collection empty.");
437 const std::string viewsReadHandleKeyProbe = viewsReadHandleKey.
key() +
"_probe";
438 ATH_MSG_VERBOSE(
"Will try to merge from the " << viewsReadHandleKeyProbe <<
" view container into that output");
444 ATH_CHECK(evtStore()->retrieve(viewsContainer_probe, viewsReadHandleKeyProbe));
446 if ( viewsContainer_probe ) {
448 ATH_MSG_DEBUG(
"Will be merging from " << viewsContainer_probe->
size() <<
" probe views using in-view key " << inViewReadHandleKey.
key() );
449 ATH_CHECK( (this->*merger)( *viewsContainer_probe, inViewReadHandleKey , context, *generator.data.get() ) );
451 ATH_MSG_VERBOSE(
"Probe views " << viewsReadHandleKeyProbe <<
" are missing.");
457 ATH_CHECK( generator.record( writeHandle ) );
460 return StatusCode::SUCCESS;
470#define CREATE(__TYPE) \
472 plainGenerator<__TYPE> generator; \
473 ATH_CHECK( (createIfMissing<__TYPE, void>( context, ConstHandlesGroup<__TYPE>( m_##__TYPE, m_##__TYPE##InViews, m_##__TYPE##Views ), generator, &HLTEDMCreator::noMerge<__TYPE>)) ); \
480#define CREATE_XAOD(__TYPE, __STORE_TYPE) \
482 xAODGenerator<xAOD::__TYPE, xAOD::__STORE_TYPE> generator; \
483 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>)) ); \
494 CREATE_XAOD( TrigRingerRingsContainer, TrigRingerRingsAuxContainer );
495 CREATE_XAOD( TrackParticleContainer, TrackParticleAuxContainer );
498 CREATE_XAOD( L2StandAloneMuonContainer, L2StandAloneMuonAuxContainer );
499 CREATE_XAOD( L2CombinedMuonContainer, L2CombinedMuonAuxContainer );
500 CREATE_XAOD( L2IsoMuonContainer, L2IsoMuonAuxContainer );
502 CREATE_XAOD( TauJetContainer, TauJetAuxContainer );
503 CREATE_XAOD( DiTauJetContainer, DiTauJetAuxContainer );
504 CREATE_XAOD( TauTrackContainer, TauTrackAuxContainer );
506 CREATE_XAOD( FlowElementContainer, FlowElementAuxContainer );
509 CREATE_XAOD( TrigBphysContainer, TrigBphysAuxContainer );
510 CREATE_XAOD( BTaggingContainer,BTaggingAuxContainer );
511 CREATE_XAOD( BTagVertexContainer,BTagVertexAuxContainer );
513 CREATE_XAOD( HIEventShapeContainer, HIEventShapeAuxContainer );
515 CREATE_XAOD( AFPSiHitsClusterContainer, AFPSiHitsClusterAuxContainer );
516 CREATE_XAOD( AFPTrackContainer, AFPTrackAuxContainer );
517 CREATE_XAOD( AFPToFTrackContainer, AFPToFTrackAuxContainer );
518 CREATE_XAOD( AFPProtonContainer, AFPProtonAuxContainer );
519 CREATE_XAOD( AFPVertexContainer, AFPVertexAuxContainer );
522 CREATE_XAOD( eFexEMRoIContainer, eFexEMRoIAuxContainer );
523 CREATE_XAOD( eFexTauRoIContainer, eFexTauRoIAuxContainer );
524 CREATE_XAOD( jFexTauRoIContainer, jFexTauRoIAuxContainer );
525 CREATE_XAOD( jFexFwdElRoIContainer, jFexFwdElRoIAuxContainer );
526 CREATE_XAOD( jFexSRJetRoIContainer, jFexSRJetRoIAuxContainer );
527 CREATE_XAOD( jFexLRJetRoIContainer, jFexLRJetRoIAuxContainer );
528 CREATE_XAOD( jFexMETRoIContainer, jFexMETRoIAuxContainer );
529 CREATE_XAOD( jFexSumETRoIContainer, jFexSumETRoIAuxContainer );
530 CREATE_XAOD( gFexJetRoIContainer, gFexJetRoIAuxContainer );
531 CREATE_XAOD( gFexGlobalRoIContainer, gFexGlobalRoIAuxContainer);
532 CREATE_XAOD( MuonRoIContainer, MuonRoIAuxContainer );
540 #define CREATE_SHALLOW(__TYPE) \
542 for ( size_t index = 0; index < m_##__TYPE##ShallowCopy.size(); ++index ){ \
543 auto readHandle = SG::makeHandle<xAOD::__TYPE> ( m_##__TYPE##ShallowCopy[index], context ); \
544 if ( not readHandle.isValid() ) { \
545 ATH_MSG_DEBUG( "Creating missing "#__TYPE"ShallowCopy " << m_##__TYPE##ShallowCopy[index].key() ); \
546 auto writeHandle = SG::makeHandle( m_##__TYPE##ShallowCopyOut[index], context ); \
547 ATH_CHECK( writeHandle.record( std::make_unique<xAOD::__TYPE>(), std::make_unique<xAOD::ShallowAuxContainer>() )); \
549 ATH_MSG_DEBUG( #__TYPE"ShallowCopy " << m_##__TYPE##ShallowCopyOut[index].key() << " present in the event, done nothing"); \
557 #undef CREATE_SHALLOW
563 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#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 TrigComposite 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