Loading [MathJax]/extensions/tex2jax.js
 |
ATLAS Offline Software
|
Go to the documentation of this file.
8 #include "GaudiKernel/IEventProcessor.h"
9 #include "GaudiKernel/IAlgManager.h"
10 #include "GaudiKernel/IOpaqueAddress.h"
11 #include "GaudiKernel/IProperty.h"
12 #include "GaudiKernel/ClassID.h"
13 #include "GaudiKernel/IClassIDSvc.h"
14 #include "GaudiKernel/IIncidentSvc.h"
15 #include "GaudiKernel/ConcurrencyFlags.h"
17 #include "EventInfo/EventInfo.h"
55 if(Gaudi::Concurrency::ConcurrencyFlags::numProcs()>0) {
61 return StatusCode::SUCCESS;
73 ATH_MSG_ERROR(
"Event number must be positive-definite; " << newnum <<
" is not allowed");
74 return StatusCode::FAILURE;
78 constexpr
long long int max32 =
std::pow(2, 31) - 1;
80 if (newnum >= max32) {
81 ATH_MSG_ERROR(
"Event number " << newnum <<
" exceeds 32bit limit. In HepMC2 it is not allowed.");
82 return StatusCode::FAILURE;
88 ATH_MSG_INFO(
"After " <<
m_nPass <<
" events we switch off HepMC3 warnings to avoid blowing up logs.");
89 HepMC3::Setup::set_print_warnings(
false);
100 HepMC::GenEvent* hepMC = *
evt;
106 return StatusCode::SUCCESS;
111 int inpRunNumber{-1};
115 ATH_CHECK(outputEvtInfoHandle.
record(std::make_unique<xAOD::EventInfo>(), std::make_unique<xAOD::EventAuxInfo>()));
117 outputEvtInfo = outputEvtInfoHandle.
ptr();
118 *outputEvtInfo = *inputEvtInfoHandle;
125 inpRunNumber = inputEvtInfoHandle->
runNumber();
128 outputEvtInfo->setMCEventWeights(mcWeights(0));
138 eventID->set_event_number(newnum);
142 return StatusCode::SUCCESS;
145 outputEvtInfo->setEventNumber(newnum);
165 return StatusCode::FAILURE;
169 outputEvtInfo->setMCChannelNumber(inpRunNumber);
170 outputEvtInfo->setMCEventNumber(newnum);
171 outputEvtInfo->setEventNumber(newnum);
178 unsigned int oldRunNumber = 0;
182 oldRunNumber = eventID->run_number();
192 return StatusCode::SUCCESS;
195 oldRunNumber = outputEvtInfo->runNumber();
201 auto newChannelNumber =
203 auto oldChannelNumber =
206 const char*
key =
"/Generation/Parameters";
217 if (collection->chanNum(
index) != oldChannelNumber) {
219 << collection->chanNum(
index));
223 if (collection->fixChanNum(oldChannelNumber, newChannelNumber))
225 << oldChannelNumber <<
" to " << newChannelNumber);
227 ATH_MSG_ERROR(
"Channel number update from " << oldChannelNumber
228 <<
" to " << newChannelNumber <<
" on \"" <<
key
235 const char*
key =
"/TagInfo";
245 for (
auto pair : *collection) {
247 if (pair.second.exists(
"mc_channel_number")) {
249 pair.second[
"mc_channel_number"].setValue(
270 ATH_MSG_INFO(
"Could not retrieve \"" <<
key <<
"\" from MetaDataStore");
279 SmartIF<IEventProcessor> apm(serviceLocator()->service(
"AthMpEvtLoopMgr",
false));
284 apm = serviceLocator()->service(
"AthenaEventLoopMgr",
false);
294 return StatusCode::SUCCESS;
300 return StatusCode::SUCCESS;
306 int nProcs= Gaudi::Concurrency::ConcurrencyFlags::numProcs();
307 const AfterForkInc* afInc =
dynamic_cast<const AfterForkInc*
>(&inc);
311 + (afInc->workerID() <= rem-1 ? 1 : 0);
314 ATH_MSG_ERROR(
"Failed to dyn-cast the incident to UpdateAfterFork!");
315 throw std::runtime_error(
"Wrong incident type handled by CountHepMC");
def retrieve(aClass, aKey=None)
This class is a container for the payload of conditions data. It is intended to be used to store cond...
bool set_ll_event_number(HepMC::GenEvent *e, long long int num)
SG::WriteHandleKey< xAOD::EventInfo > m_outputEvtInfoKey
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
const std::vector< float > & mcEventWeights() const
The weights of all the MC events used in the simulation.
std::string m_inputKeyName
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
void set_mc_channel_number(number_type chan)
Add in the MC generator channel number (aka gen run number)
This class represents the "type of event" where the type is given by one or more "characteristics".
virtual void handle(const Incident &inc) override
CountHepMC(const std::string &name, ISvcLocator *pSvcLocator)
This class provides general information about an event. It extends EventInfo with a list of sub-evts ...
This class is a collection of AttributeLists where each one is associated with a channel number....
uint32_t runNumber() const
The current event's run number.
number_type mc_channel_number() const
Access to the MC generator channel number (was used as run number for generator events)
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode execute() override
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
virtual StatusCode initialize() override
Base class for common behaviour of MC truth algorithms.
Handle class for reading a decoration on an object.
(Non-const) Iterator class for DataVector/DataList.
::StatusCode StatusCode
StatusCode definition for legacy code.
pointer_type ptr()
Dereference the pointer.
EventID * event_ID()
the unique identification of the event.
#define CHECK(...)
Evaluate an expression and check for errors.
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
This class is a container for the payload of conditions data. It is intended to be used to store cond...
std::string to_string(const DetectorType &type)
Helpers for checking error return status codes and reporting errors.
This class provides general information about an event. Event information is provided by the accessor...
static const std::string & type()
Incident type.
Class describing the basic event information.
SG::ReadDecorHandleKey< xAOD::EventInfo > m_mcWeightsKey
void set_mc_event_number(uint64_t evt)
Add in the MC generator event number.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
#define ATH_MSG_WARNING(x)
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Handle class for reading a decoration on an object.
SG::ReadHandleKey< xAOD::EventInfo > m_inputEvtInfoKey
ServiceHandle< StoreGateSvc > m_metaDataStore
virtual StatusCode finalize() override
constexpr int pow(int base, int exp) noexcept
virtual StatusCode initialize() override
EventType * event_type()
the type of the event, e.g. simulation, testbeam, etc
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
void setMCEventWeights(const std::vector< float > &value)
Set the weights of all the MC events used in the simulation.