ATLAS Offline Software
Loading...
Searching...
No Matches
CountHepMC Class Reference

Count the number of events to pass all algorithms/filters. More...

#include <CountHepMC.h>

Inheritance diagram for CountHepMC:
Collaboration diagram for CountHepMC:

Public Member Functions

 CountHepMC (const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize () override
virtual StatusCode execute (const EventContext &ctx) override
 Execute method.
virtual StatusCode finalize () override
virtual void handle (const Incident &inc) override
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual bool isClonable () const override
 Specify if the algorithm is clonable.
virtual StatusCode sysExecute (const EventContext &ctx) override
 Execute an algorithm.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
virtual bool filterPassed (const EventContext &ctx) const
 Get filter decision:
virtual void setFilterPassed (bool state, const EventContext &ctx) const
 Set filter decision:
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const
Event collection accessors (const and non-const)
HepMC::GenEvent *event ATLAS_NOT_CONST_THREAD_SAFE ()
 Access the current signal event (first in the McEventCollection).
McEventCollection *events ATLAS_NOT_CONST_THREAD_SAFE ()
 Access the current event's McEventCollection.
const HepMC::GenEventevent_const (const EventContext &ctx) const
 Access the current signal event (const).
const McEventCollectionevents_const (const EventContext &ctx) const
 Access the current event's McEventCollection (const).

Protected Member Functions

virtual bool isReEntrant () const override final
 Legacy algorithms are not thread-safe.
void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

ServiceHandle< StoreGateSvcm_metaDataStore
uint64_t m_nPass {0}
uint64_t m_nCount
uint64_t m_firstEv
uint32_t m_newRunNumber
bool m_corHepMC
bool m_corEvtID
bool m_corRunNumber
bool m_copyRunNumber
std::string m_inputKeyName
SG::ReadHandleKey< xAOD::EventInfom_inputEvtInfoKey { this, "InputEventInfo", "TMPEvtInfo", "ReadHandleKey for Input xAOD::EventInfo" }
SG::WriteHandleKey< xAOD::EventInfom_outputEvtInfoKey { this, "OutputEventInfo", "EventInfo", "WriteHandleKey for Output xAOD::EventInfo" }
SG::ReadDecorHandleKey< xAOD::EventInfom_mcWeightsKey {this, "mcEventWeightsKey", m_inputEvtInfoKey, "mcEventWeights", "Decoration for MC Event Weights"}
DataObjIDColl m_extendedExtraObjects
 Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default).
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default).
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Properties

SG::ReadHandleKey< McEventCollectionm_mcevents_const { this, "McEventKey", "GEN_EVENT", "StoreGate key of the MC event collection" }
 Const handle to the MC event collection.
std::string m_mcEventKey {}
 StoreGate key for the MC event collection (defaults to GEN_EVENT).
BooleanProperty m_mkMcEvent {this, "MakeMcEvent", false, "Create a new MC event collection if it doesn't exist"}
 Flag to determine if a new MC event collection should be made if it doesn't exist.

Detailed Description

Count the number of events to pass all algorithms/filters.

CountHepMC counts the number of events to pass algs in the evgen production chain. It signals to the AthenaEventLoopMgr service when the requested number of events are produced.

Definition at line 25 of file CountHepMC.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ CountHepMC()

CountHepMC::CountHepMC ( const std::string & name,
ISvcLocator * pSvcLocator )

Definition at line 30 of file CountHepMC.cxx.

30 :
31 GenBase(name, pSvcLocator)
32{
33 declareProperty("RequestedOutput", m_nCount=5000);
34 declareProperty("FirstEvent", m_firstEv=1);
35 declareProperty("CorrectHepMC", m_corHepMC=false);
36 declareProperty("CorrectEventID", m_corEvtID=false);
37 declareProperty("CorrectRunNumber", m_corRunNumber=false);
38 declareProperty("NewRunNumber", m_newRunNumber=999999);
39 declareProperty("CopyRunNumber", m_copyRunNumber=true);
40 declareProperty("inputKeyName", m_inputKeyName = "GEN_EVENT");
41}
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
bool m_copyRunNumber
Definition CountHepMC.h:50
bool m_corEvtID
Definition CountHepMC.h:48
std::string m_inputKeyName
Definition CountHepMC.h:51
uint32_t m_newRunNumber
Definition CountHepMC.h:45
bool m_corHepMC
Definition CountHepMC.h:47
uint64_t m_nCount
Definition CountHepMC.h:42
bool m_corRunNumber
Definition CountHepMC.h:49
uint64_t m_firstEv
Definition CountHepMC.h:44
GenBase(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition GenBase.cxx:11

Member Function Documentation

◆ ATLAS_NOT_CONST_THREAD_SAFE() [1/2]

McEventCollection *events GenBase::ATLAS_NOT_CONST_THREAD_SAFE ( )
inherited

Access the current event's McEventCollection.

Note
This function will make a new McEventCollection if there is not already a valid one and MakeMcEvent=True.

◆ ATLAS_NOT_CONST_THREAD_SAFE() [2/2]

HepMC::GenEvent *event GenBase::ATLAS_NOT_CONST_THREAD_SAFE ( )
inlineinherited

Access the current signal event (first in the McEventCollection).

Note
This function will make a new McEventCollection if there is not already a valid one and MakeMcEvent=True.

Definition at line 73 of file GenBase.h.

73 {
74 if (events()->empty())
75 ATH_MSG_ERROR("McEventCollection is empty during first event access");
76 return *(events()->begin());
77 }
#define ATH_MSG_ERROR(x)
static const Attributes_t empty

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ event_const()

const HepMC::GenEvent * GenBase::event_const ( const EventContext & ctx) const
inlineinherited

Access the current signal event (const).

Definition at line 80 of file GenBase.h.

80 {
81 const McEventCollection* coll = events_const(ctx);
82 if (coll->empty())
83 ATH_MSG_ERROR("Const McEventCollection is empty during first event access");
84 return *(coll->begin());
85 }
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
bool empty() const noexcept
Returns true if the collection is empty.
const McEventCollection * events_const(const EventContext &ctx) const
Access the current event's McEventCollection (const).
Definition GenBase.h:94

◆ events_const()

const McEventCollection * GenBase::events_const ( const EventContext & ctx) const
inlineinherited

Access the current event's McEventCollection (const).

Definition at line 94 of file GenBase.h.

94 {
95 SG::ReadHandle<McEventCollection> ret = SG::makeHandle(m_mcevents_const, ctx);
96 if (!ret.isValid())
97 ATH_MSG_ERROR("No McEventCollection found in StoreGate with key " << m_mcevents_const.key());
98 return ret.cptr();
99 }
SG::ReadHandleKey< McEventCollection > m_mcevents_const
Const handle to the MC event collection.
Definition GenBase.h:118
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode CountHepMC::execute ( const EventContext & ctx)
overridevirtual

Execute method.

Todo
Replace the old event ?

Reimplemented from GenBase.

Definition at line 64 of file CountHepMC.cxx.

64 {
65
67 m_nPass++;
68 ATH_MSG_DEBUG("Current count = " << m_nPass);
69 ATH_MSG_DEBUG("Options for HepMC event number, EvtID event number, EvtID run number = " << m_corHepMC << ", " << m_corEvtID << ", " << m_corRunNumber );
70 // Fix the event number
71 long long int newnum = m_nPass + m_firstEv - 1;
72 if (newnum<=0){
73 ATH_MSG_ERROR("Event number must be positive-definite; " << newnum << " is not allowed");
74 return StatusCode::FAILURE;
75 }
76
77// Temporary solution to suppress the Warnings from HepMC3 printed for every event.
78// Will be removed when generators authors fix the way they fill the x-section or when we switch to a new HepMC3 version , where the printout is limited.
79 if (m_nPass == 100) {
80 ATH_MSG_INFO("After " << m_nPass << " events we switch off HepMC3 warnings to avoid blowing up logs.");
81 HepMC3::Setup::set_print_warnings(false);
82 }
83 if (m_corHepMC) {
84 std::string key = m_inputKeyName;
85 // retrieve event from Transient Store (Storegate)
86 const McEventCollection* oldmcEvtColl=0;
87 if (evtStore()->retrieve(oldmcEvtColl, key).isSuccess()){
88 McEventCollection* newmcEvtColl = new McEventCollection(*oldmcEvtColl);
89 McEventCollection::iterator evt = newmcEvtColl->begin();
90 HepMC::GenEvent* hepMC = *evt;
91 HepMC::set_ll_event_number(hepMC, newnum);
92 CHECK(evtStore()->overwrite( newmcEvtColl, key));
93 }
94 else{
95 ATH_MSG_ERROR("No McEventCollection object found");
96 return StatusCode::SUCCESS;
97 }
98 }
99
100 xAOD::EventInfo* outputEvtInfo{nullptr};
101 int inpRunNumber{-1};
103 SG::ReadHandle<xAOD::EventInfo> inputEvtInfoHandle(m_inputEvtInfoKey, ctx);
104 SG::WriteHandle<xAOD::EventInfo> outputEvtInfoHandle(m_outputEvtInfoKey, ctx);
105 ATH_CHECK(outputEvtInfoHandle.record(std::make_unique<xAOD::EventInfo>(), std::make_unique<xAOD::EventAuxInfo>()));
106
107 outputEvtInfo = outputEvtInfoHandle.ptr();
108 *outputEvtInfo = *inputEvtInfoHandle;
109
110 // This is sometimes marked as a decoration in the source, meaning
111 // it won't get copied by the assignment above. Make sure it
112 // gets copied.
113 outputEvtInfo->setMCEventWeights (inputEvtInfoHandle->mcEventWeights());
114
115 inpRunNumber = inputEvtInfoHandle->runNumber();
116 if(!m_mcWeightsKey.empty()) {
117 SG::ReadDecorHandle<xAOD::EventInfo,std::vector<float>> mcWeights(m_mcWeightsKey, ctx);
118 outputEvtInfo->setMCEventWeights(mcWeights(0));
119 }
120 }
121
122 if (m_corEvtID) {
123 // Change the EventID in the eventinfo header
124 const EventInfo* pInputEvt(nullptr);
125 if (evtStore()->retrieve(pInputEvt).isSuccess()) {
126 assert(pInputEvt);
127 EventID* eventID = const_cast<EventID*>(pInputEvt->event_ID());
128 eventID->set_event_number(newnum);
129 ATH_MSG_DEBUG("Set new event number in event_ID");
130 } else {
131 ATH_MSG_ERROR("No EventInfo object found");
132 return StatusCode::SUCCESS;
133 }
134
135 outputEvtInfo->setEventNumber(newnum);
136 }
137
138
139 // Copy generation run number into mc channel number
140 if (m_copyRunNumber) {
141 // Legacy Event Info
142 const EventInfo* pInputEvt(nullptr);
143 if (evtStore()->retrieve(pInputEvt).isSuccess()) {
144 assert(pInputEvt);
145
146 unsigned int run_number = pInputEvt->event_ID()->run_number();
147
148 EventType* eventType = const_cast<EventType*>(pInputEvt->event_type());
149 eventType->set_mc_channel_number(run_number);
150 eventType->set_mc_event_number (newnum);
151
152 ATH_MSG_DEBUG("Copied run number into mc channel number: " << run_number);
153 } else {
154 ATH_MSG_ERROR("No EventInfo object found");
155 return StatusCode::FAILURE;
156 }
157
158 // xAOD::EventInfo
159 outputEvtInfo->setMCChannelNumber(inpRunNumber);
160 outputEvtInfo->setMCEventNumber(newnum);
161 outputEvtInfo->setEventNumber(newnum);
162 }
163
164
165 if (m_corRunNumber) {
166 // Change the EventID in the eventinfo header
167 const EventInfo* pInputEvt(nullptr);
168 unsigned int oldRunNumber = 0;
169 if (evtStore()->retrieve(pInputEvt).isSuccess()) {
170 assert(pInputEvt);
171 EventID* eventID = const_cast<EventID*>(pInputEvt->event_ID());
172 oldRunNumber = eventID->run_number();
173 eventID->set_run_number(m_newRunNumber);
174 ATH_MSG_DEBUG("Set new run number in event_ID " << m_newRunNumber);
175
176 // also set the MC channel number
177 EventType* event_type = const_cast<EventType*>(pInputEvt->event_type());
179 ATH_MSG_DEBUG("Set new MC channel number " << event_type->mc_channel_number());
180 } else {
181 ATH_MSG_ERROR("No EventInfo object found");
182 return StatusCode::SUCCESS;
183 }
184
185 oldRunNumber = outputEvtInfo->runNumber();
186 outputEvtInfo->setRunNumber(m_newRunNumber);
187 outputEvtInfo->setMCChannelNumber(m_newRunNumber);
188
189 {
190 // change the channel number where /Generation/Parameters are found
191 auto newChannelNumber =
193 auto oldChannelNumber =
194 static_cast< CondAttrListCollection::ChanNum >(oldRunNumber);
195
196 const char* key = "/Generation/Parameters";
197 const IOVMetaDataContainer * iovContainer = nullptr;
198 if (m_metaDataStore->retrieve(iovContainer, key).isSuccess()
199 && iovContainer) {
200 // get a hold of the payload
201 const IOVPayloadContainer * payloadContainer =
202 iovContainer->payloadContainer();
203
204 // Grab the attribute list
205 for (CondAttrListCollection* collection : *payloadContainer) {
206 for(unsigned int index = 0; index < collection->size(); ++index) {
207 if (collection->chanNum(index) != oldChannelNumber) {
208 ATH_MSG_INFO("Not updating \"" << key << "\" on channel number "
209 << collection->chanNum(index));
210 continue;
211 }
212
213 if (collection->fixChanNum(oldChannelNumber, newChannelNumber))
214 ATH_MSG_INFO("Updated \"" << key << "\" channel number from "
215 << oldChannelNumber << " to " << newChannelNumber);
216 else
217 ATH_MSG_ERROR("Channel number update from " << oldChannelNumber
218 << " to " << newChannelNumber << " on \"" << key
219 << "\" FAILED");
220 }
221 }
222
223 {
224 // Update the MC channel number in the "/TagInfo"
225 const char* key = "/TagInfo";
226 const IOVMetaDataContainer * iovContainer = nullptr;
227 if (m_metaDataStore->retrieve(iovContainer, key).isSuccess()
228 && iovContainer) {
229 // get a hold of the payload
230 const IOVPayloadContainer * payloadContainer =
231 iovContainer->payloadContainer();
232
233 // Grab the attribute list
234 for (CondAttrListCollection* collection : *payloadContainer) {
235 for (auto pair : *collection) {
236 // pair is a pair of Channel number and AttributeList
237 if (pair.second.exists("mc_channel_number")) {
238 try {
239 pair.second["mc_channel_number"].setValue(
240 std::to_string(m_newRunNumber));
241 ATH_MSG_INFO("Updated \"" << key << "\" mc_channel_number"
242 << " to " << m_newRunNumber);
243 } catch (std::exception&) {
244 try {
245 pair.second["mc_channel_number"].setValue(m_newRunNumber);
246 ATH_MSG_INFO("Updated \"" << key << "\" mc_channel_number"
247 << " to " << m_newRunNumber);
248 } catch (std::exception&) {
249 ATH_MSG_ERROR("mc_channel_number update from to "
250 << m_newRunNumber << " on \"" << key
251 << "\" FAILED");
252 }
253 }
254 }
255 }
256 }
257 }
258 }
259 } else {
260 ATH_MSG_INFO("Could not retrieve \"" << key << "\" from MetaDataStore");
261 }
262 }
263 }
264
265
266 if (m_nPass == m_nCount) {
267 ATH_MSG_INFO("Stopping the event processing...." << m_nPass << "/" << m_nCount);
268 // Try the MP ELM first
269 SmartIF<IEventProcessor> apm(serviceLocator()->service("AthMpEvtLoopMgr", /*createIf*/false));
270 if(apm) {
271 ATH_CHECK(apm->stopRun());
272 }
273 else {
274 apm = serviceLocator()->service("AthenaEventLoopMgr", /*createIf*/false);
275 if (apm) {
276 ATH_CHECK(apm->stopRun());
277 }
278 else {
279 ATH_MSG_WARNING("No EventLoop Manager found ");
280 }
281 }
282 }
283
284 return StatusCode::SUCCESS;
285}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
IOVPayloadContainer
ServiceHandle< StoreGateSvc > & evtStore()
SG::ReadDecorHandleKey< xAOD::EventInfo > m_mcWeightsKey
Definition CountHepMC.h:56
SG::ReadHandleKey< xAOD::EventInfo > m_inputEvtInfoKey
Definition CountHepMC.h:53
uint64_t m_nPass
Definition CountHepMC.h:41
ServiceHandle< StoreGateSvc > m_metaDataStore
Definition CountHepMC.h:39
SG::WriteHandleKey< xAOD::EventInfo > m_outputEvtInfoKey
Definition CountHepMC.h:54
DataModel_detail::iterator< DataVector > iterator
Definition DataVector.h:842
void set_mc_channel_number(number_type chan)
Add in the MC generator channel number (aka gen run number).
number_type mc_channel_number() const
Access to the MC generator channel number (was used as run number for generator events).
void set_mc_event_number(uint64_t evt)
Add in the MC generator event number.
const IOVPayloadContainer * payloadContainer() const
Access to payload container.
void setMCEventNumber(uint64_t value)
Set the MC generator's event number.
void setEventNumber(uint64_t value)
Set the current event's event number.
void setMCChannelNumber(uint32_t value)
Set the MC generator's channel number.
void setMCEventWeights(const std::vector< float > &value)
Set the weights of all the MC events used in the simulation.
void setRunNumber(uint32_t value)
Set the current event's run number.
uint32_t runNumber() const
The current event's run number.
str index
Definition DeMoScan.py:362
bool set_ll_event_number(HepMC3::GenEvent *e, long long int num)
Definition GenEvent.h:337
HepMC3::GenEvent GenEvent
Definition GenEvent.h:39
EventInfo_v1 EventInfo
Definition of the latest event info version.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthCommonAlgorithm< Gaudi::Algorithm >::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 89 of file AthCommonAlgorithm.cxx.

54{
55 // If we didn't find any symlinks to add, just return the collection
56 // from the base class. Otherwise, return the extended collection.
57 if (!m_extendedExtraObjects.empty()) {
59 }
61}
Common base class for algorithms.

◆ filterPassed()

virtual bool AthCommonAlgorithm< Gaudi::Algorithm >::filterPassed ( const EventContext & ctx) const
inlinevirtualinherited

Get filter decision:

Definition at line 93 of file AthCommonAlgorithm.h.

93 {
94 return execState( ctx ).filterPassed();
95 }
virtual bool filterPassed(const EventContext &ctx) const
Get filter decision:

◆ finalize()

StatusCode CountHepMC::finalize ( )
overridevirtual

Definition at line 288 of file CountHepMC.cxx.

288 {
289 ATH_MSG_INFO("Events passing all checks and written = " << m_nPass);
290 return StatusCode::SUCCESS;
291}

◆ handle()

void CountHepMC::handle ( const Incident & inc)
overridevirtual

Definition at line 293 of file CountHepMC.cxx.

293 {
294 using AfterForkInc = AthenaInterprocess::UpdateAfterFork;
295 if(inc.type()==AfterForkInc::type()) {
296 int nProcs= Gaudi::Concurrency::ConcurrencyFlags::numProcs();
297 const AfterForkInc* afInc = dynamic_cast<const AfterForkInc*>(&inc);
298 if(afInc) {
299 int rem = m_nCount%nProcs;
300 m_nCount = m_nCount/nProcs
301 + (afInc->workerID() <= rem-1 ? 1 : 0);
302 }
303 else {
304 ATH_MSG_ERROR("Failed to dyn-cast the incident to UpdateAfterFork!");
305 throw std::runtime_error("Wrong incident type handled by CountHepMC");
306 }
307 }
308}

◆ initialize()

StatusCode CountHepMC::initialize ( )
overridevirtual

Reimplemented from GenBase.

Definition at line 43 of file CountHepMC.cxx.

44{
46
48
50 ATH_CHECK(m_inputEvtInfoKey.initialize());
51 ATH_CHECK(m_outputEvtInfoKey.initialize());
52 if(!m_mcWeightsKey.empty()) ATH_CHECK(m_mcWeightsKey.initialize());
53 }
54
55 if(Gaudi::Concurrency::ConcurrencyFlags::numProcs()>0) {
56 ServiceHandle<IIncidentSvc> incidentSvc("IncidentSvc",name());
57 ATH_CHECK(incidentSvc.retrieve());
58 incidentSvc->addListener(this, AthenaInterprocess::UpdateAfterFork::type());
59 }
60
61 return StatusCode::SUCCESS;
62}
static const std::string & type()
Incident type.
Definition Incidents.h:49
virtual StatusCode initialize() override
Definition GenBase.cxx:17

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ isClonable()

virtual bool AthCommonAlgorithm< Gaudi::Algorithm >::isClonable ( ) const
inlineoverridevirtualinherited

Specify if the algorithm is clonable.

Only relevant for non-reentrant algorithms. Actual number of clones needs to be set via the "Cardinality" property.

Reimplemented in AFP_DigiTop, AlgB, AlgT, BCM_Digitization, CscDigitBuilder, CscDigitToCscRDO, G4AtlasAlg, G4RunAlg, HGTD_Digitization, HiveAlgBase, InDet::GNNSeedingTrackMaker, InDet::SCT_Clusterization, InDet::SiSPGNNTrackMaker, InDet::SiSPSeededTrackFinder, InDet::SiTrackerSpacePointFinder, ISF::SimKernelMT, ITk::StripDigitization, ITkPixelCablingAlg, ITkStripCablingAlg, LArHitEMapMaker, LArTTL1Maker, LUCID_DigiTop, LVL1::L1TopoSimulation, MergeCalibHits, MergeGenericMuonSimHitColl, MergeHijingPars, MergeMcEventCollection, MergeTrackRecordCollection, MergeTruthJets, MergeTruthParticles, MuonDigitizer, PileUpMTAlg, PixelDigitization, RoIBResultToxAOD, SCT_ByteStreamErrorsTestAlg, SCT_CablingCondAlgFromCoraCool, SCT_CablingCondAlgFromText, SCT_ConditionsParameterTestAlg, SCT_ConditionsSummaryTestAlg, SCT_ConfigurationConditionsTestAlg, SCT_Digitization, SCT_FlaggedConditionTestAlg, SCT_LinkMaskingTestAlg, SCT_MajorityConditionsTestAlg, SCT_ModuleVetoTestAlg, SCT_MonitorConditionsTestAlg, SCT_PrepDataToxAOD, SCT_RawDataToxAOD, SCT_ReadCalibChipDataTestAlg, SCT_ReadCalibDataTestAlg, SCT_RODVetoTestAlg, SCT_SensorsTestAlg, SCT_SiliconConditionsTestAlg, SCT_StripVetoTestAlg, SCT_TdaqEnabledTestAlg, SCT_TestCablingAlg, SCTEventFlagWriter, SCTRawDataProvider, SCTSiLorentzAngleTestAlg, SCTSiPropertiesTestAlg, SGInputLoader, Simulation::BeamEffectsAlg, TileHitVecToCnt, TileMuonFitter, TilePulseForTileMuonReceiver, TileRawChannelMaker, TRTDigitization, and ZDC_DigiTop.

Definition at line 68 of file AthCommonAlgorithm.h.

68 {
69 return true;
70 }

◆ isReEntrant()

virtual bool AthAlgorithm::isReEntrant ( ) const
inlinefinaloverrideprotectedvirtualinherited

Legacy algorithms are not thread-safe.

Definition at line 47 of file AthAlgorithm.h.

47{ return false; }

◆ msg()

MsgStream & AthCommonMsg< Gaudi::Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< Gaudi::Algorithm >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ setFilterPassed()

virtual void AthCommonAlgorithm< Gaudi::Algorithm >::setFilterPassed ( bool state,
const EventContext & ctx ) const
inlinevirtualinherited

Set filter decision:

Reimplemented in AthFilterAlgorithm.

Definition at line 99 of file AthCommonAlgorithm.h.

99 {
101 }
virtual void setFilterPassed(bool state, const EventContext &ctx) const
Set filter decision:

◆ sysExecute()

StatusCode AthCommonAlgorithm< Gaudi::Algorithm >::sysExecute ( const EventContext & ctx)
overridevirtualinherited

Execute an algorithm.

We override this in order to work around an issue with the Algorithm base class storing the event context in a member variable that can cause crashes in MT jobs.

Reimplemented in AthAnalysisAlgorithm.

Definition at line 80 of file AthCommonAlgorithm.cxx.

41{
42 return BaseAlg::sysExecute (ctx);
43}

◆ sysInitialize()

StatusCode AthCommonAlgorithm< Gaudi::Algorithm >::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >.

Reimplemented in AthAnalysisAlgorithm, AthFilterAlgorithm, AthHistogramAlgorithm, HypoBase, InputMakerBase, and PyAthena::Alg.

Definition at line 60 of file AthCommonAlgorithm.cxx.

71 {
73
74 if (sc.isFailure()) {
75 return sc;
76 }
77
78 ServiceHandle<ICondSvc> cs("CondSvc",name());
79 for (auto h : outputHandles()) {
80 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
81 // do this inside the loop so we don't create the CondSvc until needed
82 if ( cs.retrieve().isFailure() ) {
83 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
85 }
86 if (cs->regHandle(this,*h).isFailure()) {
88 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
89 << " with CondSvc");
90 }
91 }
92 }
93 return sc;
94}
virtual StatusCode sysInitialize() override
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }

Member Data Documentation

◆ m_copyRunNumber

bool CountHepMC::m_copyRunNumber
private

Definition at line 50 of file CountHepMC.h.

◆ m_corEvtID

bool CountHepMC::m_corEvtID
private

Definition at line 48 of file CountHepMC.h.

◆ m_corHepMC

bool CountHepMC::m_corHepMC
private

Definition at line 47 of file CountHepMC.h.

◆ m_corRunNumber

bool CountHepMC::m_corRunNumber
private

Definition at line 49 of file CountHepMC.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default).

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default).

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthCommonAlgorithm< Gaudi::Algorithm >::m_extendedExtraObjects
privateinherited

Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.

Empty if no symlinks were found.

Definition at line 108 of file AthCommonAlgorithm.h.

◆ m_firstEv

uint64_t CountHepMC::m_firstEv
private

Definition at line 44 of file CountHepMC.h.

◆ m_inputEvtInfoKey

SG::ReadHandleKey<xAOD::EventInfo> CountHepMC::m_inputEvtInfoKey { this, "InputEventInfo", "TMPEvtInfo", "ReadHandleKey for Input xAOD::EventInfo" }
private

Definition at line 53 of file CountHepMC.h.

53{ this, "InputEventInfo", "TMPEvtInfo", "ReadHandleKey for Input xAOD::EventInfo" };

◆ m_inputKeyName

std::string CountHepMC::m_inputKeyName
private

Definition at line 51 of file CountHepMC.h.

◆ m_mcEventKey

std::string GenBase::m_mcEventKey {}
protectedinherited

StoreGate key for the MC event collection (defaults to GEN_EVENT).

Definition at line 109 of file GenBase.h.

109{};

◆ m_mcevents_const

SG::ReadHandleKey<McEventCollection> GenBase::m_mcevents_const { this, "McEventKey", "GEN_EVENT", "StoreGate key of the MC event collection" }
privateinherited

Const handle to the MC event collection.

Definition at line 118 of file GenBase.h.

118{ this, "McEventKey", "GEN_EVENT", "StoreGate key of the MC event collection" };

◆ m_mcWeightsKey

SG::ReadDecorHandleKey<xAOD::EventInfo> CountHepMC::m_mcWeightsKey {this, "mcEventWeightsKey", m_inputEvtInfoKey, "mcEventWeights", "Decoration for MC Event Weights"}
private

Definition at line 56 of file CountHepMC.h.

56{this, "mcEventWeightsKey", m_inputEvtInfoKey, "mcEventWeights", "Decoration for MC Event Weights"};

◆ m_metaDataStore

ServiceHandle< StoreGateSvc > CountHepMC::m_metaDataStore
private
Initial value:
{
"StoreGateSvc/MetaDataStore", name()}

Definition at line 39 of file CountHepMC.h.

39 {
40 "StoreGateSvc/MetaDataStore", name()};

◆ m_mkMcEvent

BooleanProperty GenBase::m_mkMcEvent {this, "MakeMcEvent", false, "Create a new MC event collection if it doesn't exist"}
protectedinherited

Flag to determine if a new MC event collection should be made if it doesn't exist.

Definition at line 111 of file GenBase.h.

111{this, "MakeMcEvent", false, "Create a new MC event collection if it doesn't exist"};

◆ m_nCount

uint64_t CountHepMC::m_nCount
private

Definition at line 42 of file CountHepMC.h.

◆ m_newRunNumber

uint32_t CountHepMC::m_newRunNumber
private

Definition at line 45 of file CountHepMC.h.

◆ m_nPass

uint64_t CountHepMC::m_nPass {0}
private

Definition at line 41 of file CountHepMC.h.

41{0};

◆ m_outputEvtInfoKey

SG::WriteHandleKey<xAOD::EventInfo> CountHepMC::m_outputEvtInfoKey { this, "OutputEventInfo", "EventInfo", "WriteHandleKey for Output xAOD::EventInfo" }
private

Definition at line 54 of file CountHepMC.h.

54{ this, "OutputEventInfo", "EventInfo", "WriteHandleKey for Output xAOD::EventInfo" };

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: