ATLAS Offline Software
Loading...
Searching...
No Matches
EventInfoCnvAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6// System include(s):
7#include <memory>
8
9// Gaudi/Athena include(s):
11#include "GaudiKernel/ConcurrencyFlags.h"
12
13// EDM include(s):
14#include "EventInfo/EventInfo.h"
20
21// Local include(s):
22#include "EventInfoCnvAlg.h"
23
24namespace xAODMaker {
25
26 EventInfoCnvAlg::EventInfoCnvAlg( const std::string& name,
27 ISvcLocator* svcLoc )
28 : AthReentrantAlgorithm( name, svcLoc ),
29 m_cnvTool( "xAODMaker::EventInfoCnvTool/EventInfoCnvTool", this ) {
30
31 declareProperty( "AODKey", m_aodKey = "" );
32 declareProperty( "xAODKey", m_xaodKey = "EventInfo" );
33 declareProperty( "PileupKey", m_pileupKey = "PileupEventInfo" );
34 declareProperty( "CnvTool", m_cnvTool );
35 }
36
38
39 // Greet the user:
40 ATH_MSG_INFO( "Initializing " << name() );
41 ATH_MSG_DEBUG( " AOD Key: " << m_aodKey );
42 ATH_MSG_DEBUG( "xAOD Key: " << m_xaodKey.key() );
43
44 // Retrieve the converter tool:
45 CHECK( m_cnvTool.retrieve() );
46
47 CHECK( m_aodKey.initialize(SG::AllowEmpty) );
48 CHECK( m_xaodKey.initialize() );
49 CHECK( m_pileupKey.initialize(SG::AllowEmpty) );
50
51 // Return gracefully:
52 return StatusCode::SUCCESS;
53 }
54
55 StatusCode EventInfoCnvAlg::execute (const EventContext& ctx) const {
56
57 // Check if anything needs to be done:
58 // FIXME: Job configuration should be fixed so we don't need this test.
60 ATH_MSG_WARNING( "xAOD::EventInfo with key \"" << m_xaodKey.key()
61 << "\" is already in StoreGate; "
62 << "EventInfoCnvAlg should not be scheduled.");
63 return StatusCode::SUCCESS;
64 }
65
66 // Retrieve the AOD object:
67 // FIXME: Use a ReadHandle.
68 const EventInfo* aod = nullptr;
69 if( m_aodKey.empty() ) {
70 // If key has not been set, do a keyless retrieve instead.
71 // This is not standard behavior, but is for compatibility
72 // with existing configurations.
73 CHECK( evtStore()->retrieve( aod ) );
74 } else {
76 aod = ei.cptr();
77 }
78
79 // Create the xAOD object(s):
80 auto ei = std::make_unique<xAOD::EventInfo>();
81 auto ei_aux = std::make_unique<xAOD::EventAuxInfo>();
82 ei->setStore (ei_aux.get());
83
84 // Check if this is a PileUpEventInfo object:
85 const PileUpEventInfo* paod =
86 dynamic_cast< const PileUpEventInfo* >( aod );
87 if( paod ) {
88 // Create an EventInfoContainer for the pileup events:
89 auto puei = std::make_unique<xAOD::EventInfoContainer>();
90 auto puei_aux = std::make_unique<xAOD::EventInfoAuxContainer>();
91 puei->setStore (puei_aux.get());
92
93 // Sub-events for the main EventInfo object:
94 std::vector< xAOD::EventInfo::SubEvent > subEvents;
95
96 // A convenience type declaration:
98
99 // Create xAOD::EventInfo objects for each pileup EventInfo object:
100 PileUpEventInfo::SubEvent::const_iterator pu_itr = paod->beginSubEvt();
101 PileUpEventInfo::SubEvent::const_iterator pu_end = paod->endSubEvt();
102 for( ; pu_itr != pu_end; ++pu_itr ) {
103 // Create a new xAOD object:
105 puei->push_back( ei );
106 // Fill it with information:
107 CHECK( m_cnvTool->convert( pu_itr->pSubEvt, ei, true, false, ctx ) );
108 // And now add a sub-event to the temporary list:
110 switch (pu_itr->type()) {
113 break;
116 break;
119 break;
122 break;
125 break;
128 break;
129 default:
130 break;
131 }
132 subEvents.emplace_back( pu_itr->time(),
133 pu_itr->index(),
134 type,
135 EiLink( m_pileupKey.key(),
136 puei->size() -
137 1 ) );
138 }
139
140 // And now update the main EventInfo object with the sub-events:
141 ei->setSubEvents( subEvents );
142
143 // Record PU objects.
145 CHECK( puei_h.record (std::move(puei), std::move(puei_aux)) );
146 }
147
148 // Do the translation:
149 CHECK( m_cnvTool->convert( aod, ei.get(), false, true, ctx ) );
150
151 // Record EI objects.
153 CHECK( ei_h.record (std::move(ei), std::move (ei_aux)) );
154
155 // Return gracefully:
156 return StatusCode::SUCCESS;
157 }
158
159} // namespace xAODMaker
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
This class provides information about an overlaid event.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
An algorithm that can be simultaneously executed in multiple threads.
This class provides information about an overlaid event.
SubEvent::iterator endSubEvt()
SubEvent::iterator beginSubEvt()
const_pointer_type cptr()
Dereference the pointer.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
virtual StatusCode execute(const EventContext &ctx) const override
Function executing the algorithm.
SG::WriteHandleKey< xAOD::EventInfo > m_xaodKey
Key for the output object.
virtual StatusCode initialize() override
Function initialising the algorithm.
EventInfoCnvAlg(const std::string &name, ISvcLocator *svcLoc)
Regular Algorithm constructor.
SG::WriteHandleKey< xAOD::EventInfoContainer > m_pileupKey
For pileup.
ToolHandle< IEventInfoCnvTool > m_cnvTool
Handle to the converter tool.
SG::ReadHandleKey< EventInfo > m_aodKey
Key for the input object If blank, we do a keyless retrieve from SG instead!
PileUpType
Enumerator describing the types of pileup events.
@ HaloGas
Halo-gas non-collision background.
@ HighPtMinimumBias
High pT Minimum bias pileup event.
@ MinimumBias
(Low pT) Minimum bias pileup event
@ ZeroBias
Zero bias pileup event.
@ Signal
The signal event.
@ Cavern
Cavern background pileup event.
@ Unknown
Type not known/specified.
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:114
EventInfo_v1 EventInfo
Definition of the latest event info version.