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 () override
virtual StatusCode finalize () override
virtual void handle (const Incident &inc) override
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
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::GenEvent * event_const () const
 Access the current signal event (const)
const McEventCollectionevents_const () const
 Access the current event's McEventCollection (const)
const McEventCollectionevents_const (const EventContext &ctx) const
Particle data accessors
const ServiceHandle< IPartPropSvc > partPropSvc () const
 Access the particle property service.
const HepPDT::ParticleDataTable & particleTable () const
 Get a particle data table.
const HepPDT::ParticleDataTable & pdt () const
 Shorter alias to get a particle data table.
const HepPDT::ParticleData * particleData (int pid) const
 Access an element in the particle data table.

Protected Member Functions

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.

Protected Attributes

Properties
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.

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
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

Utility event-mangling functions

Todo
Replace with HepMC units when available
ServiceHandle< IPartPropSvc > m_ppSvc {this, "PartPropSvc", "PartPropSvc"}
 Handle on the particle property service.
SG::ReadHandleKey< McEventCollectionm_mcevents_const { this, "McEventKey", "GEN_EVENT", "StoreGate key of the MC event collection" }
 Const handle to the MC event collection.
void GeVToMeV (HepMC::GenEvent *evt)
 Scale event energies/momenta by x 1000.
void MeVToGeV (HepMC::GenEvent *evt)
 Scale event energies/momenta by x 1/1000.
void cmTomm (HepMC::GenEvent *evt)
 Scale event lengths by x 10.
void mmTocm (HepMC::GenEvent *evt)
 Scale event lengths by x 1/10.

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< 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]

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 76 of file GenBase.h.

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

◆ ATLAS_NOT_CONST_THREAD_SAFE() [2/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.

◆ cmTomm()

void GenBase::cmTomm ( HepMC::GenEvent * evt)
protectedinherited

Scale event lengths by x 10.

Definition at line 78 of file GenBase.cxx.

78 {
79 for (HepMC::GenEvent::vertex_iterator vtx = evt->vertices_begin(); vtx != evt->vertices_end(); ++vtx) {
80 const HepMC::FourVector fv((*vtx)->position().x() * 10,
81 (*vtx)->position().y() * 10,
82 (*vtx)->position().z() * 10,
83 (*vtx)->position().t() * 10);
84 (*vtx)->set_position(fv);
85 }
86}

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< 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< 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< 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
inlineinherited

Access the current signal event (const)

Definition at line 83 of file GenBase.h.

83 {
84 if (events_const()->empty())
85 ATH_MSG_ERROR("Const McEventCollection is empty during first event access");
86 return *(events_const()->begin());
87 }
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
const McEventCollection * events_const() const
Access the current event's McEventCollection (const)
Definition GenBase.h:96

◆ events_const() [1/2]

const McEventCollection * GenBase::events_const ( ) const
inlineinherited

Access the current event's McEventCollection (const)

Definition at line 96 of file GenBase.h.

96 {
97 return events_const( getContext() );
98 }

◆ events_const() [2/2]

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

Definition at line 99 of file GenBase.h.

99 {
100 SG::ReadHandle<McEventCollection> ret = SG::makeHandle(m_mcevents_const, ctx);
101 if (!ret.isValid())
102 ATH_MSG_ERROR("No McEventCollection found in StoreGate with key " << m_mcevents_const.key());
103 return ret.cptr();
104 }
SG::ReadHandleKey< McEventCollection > m_mcevents_const
Const handle to the MC event collection.
Definition GenBase.h:163
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< 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 ( )
overridevirtual
Todo
Replace the old event ?

crash the run if event number gets above 32bit int.

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#ifndef HEPMC3
79 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;
83 }
84#else
85// Temporary solution to suppress the Warnings from HepMC3 printed for every event.
86// 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.
87 if (m_nPass == 100) {
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);
90 }
91#endif
92
93 if (m_corHepMC) {
94 std::string key = m_inputKeyName;
95 // retrieve event from Transient Store (Storegate)
96 const McEventCollection* oldmcEvtColl=0;
97 if (evtStore()->retrieve(oldmcEvtColl, key).isSuccess()){
98 McEventCollection* newmcEvtColl = new McEventCollection(*oldmcEvtColl);
99 McEventCollection::iterator evt = newmcEvtColl->begin();
100 HepMC::GenEvent* hepMC = *evt;
101 HepMC::set_ll_event_number(hepMC, newnum);
102 CHECK(evtStore()->overwrite( newmcEvtColl, key));
103 }
104 else{
105 ATH_MSG_ERROR("No McEventCollection object found");
106 return StatusCode::SUCCESS;
107 }
108 }
109
110 xAOD::EventInfo* outputEvtInfo{nullptr};
111 int inpRunNumber{-1};
113 SG::ReadHandle<xAOD::EventInfo> inputEvtInfoHandle(m_inputEvtInfoKey);
114 SG::WriteHandle<xAOD::EventInfo> outputEvtInfoHandle(m_outputEvtInfoKey);
115 ATH_CHECK(outputEvtInfoHandle.record(std::make_unique<xAOD::EventInfo>(), std::make_unique<xAOD::EventAuxInfo>()));
116
117 outputEvtInfo = outputEvtInfoHandle.ptr();
118 *outputEvtInfo = *inputEvtInfoHandle;
119
120 // This is sometimes marked as a decoration in the source, meaning
121 // it won't get copied by the assignment above. Make sure it
122 // gets copied.
123 outputEvtInfo->setMCEventWeights (inputEvtInfoHandle->mcEventWeights());
124
125 inpRunNumber = inputEvtInfoHandle->runNumber();
126 if(!m_mcWeightsKey.empty()) {
127 SG::ReadDecorHandle<xAOD::EventInfo,std::vector<float>> mcWeights(m_mcWeightsKey);
128 outputEvtInfo->setMCEventWeights(mcWeights(0));
129 }
130 }
131
132 if (m_corEvtID) {
133 // Change the EventID in the eventinfo header
134 const EventInfo* pInputEvt(nullptr);
135 if (evtStore()->retrieve(pInputEvt).isSuccess()) {
136 assert(pInputEvt);
137 EventID* eventID = const_cast<EventID*>(pInputEvt->event_ID());
138 eventID->set_event_number(newnum);
139 ATH_MSG_DEBUG("Set new event number in event_ID");
140 } else {
141 ATH_MSG_ERROR("No EventInfo object found");
142 return StatusCode::SUCCESS;
143 }
144
145 outputEvtInfo->setEventNumber(newnum);
146 }
147
148
149 // Copy generation run number into mc channel number
150 if (m_copyRunNumber) {
151 // Legacy Event Info
152 const EventInfo* pInputEvt(nullptr);
153 if (evtStore()->retrieve(pInputEvt).isSuccess()) {
154 assert(pInputEvt);
155
156 unsigned int run_number = pInputEvt->event_ID()->run_number();
157
158 EventType* eventType = const_cast<EventType*>(pInputEvt->event_type());
159 eventType->set_mc_channel_number(run_number);
160 eventType->set_mc_event_number (newnum);
161
162 ATH_MSG_DEBUG("Copied run number into mc channel number: " << run_number);
163 } else {
164 ATH_MSG_ERROR("No EventInfo object found");
165 return StatusCode::FAILURE;
166 }
167
168 // xAOD::EventInfo
169 outputEvtInfo->setMCChannelNumber(inpRunNumber);
170 outputEvtInfo->setMCEventNumber(newnum);
171 outputEvtInfo->setEventNumber(newnum);
172 }
173
174
175 if (m_corRunNumber) {
176 // Change the EventID in the eventinfo header
177 const EventInfo* pInputEvt(nullptr);
178 unsigned int oldRunNumber = 0;
179 if (evtStore()->retrieve(pInputEvt).isSuccess()) {
180 assert(pInputEvt);
181 EventID* eventID = const_cast<EventID*>(pInputEvt->event_ID());
182 oldRunNumber = eventID->run_number();
183 eventID->set_run_number(m_newRunNumber);
184 ATH_MSG_DEBUG("Set new run number in event_ID " << m_newRunNumber);
185
186 // also set the MC channel number
187 EventType* event_type = const_cast<EventType*>(pInputEvt->event_type());
189 ATH_MSG_DEBUG("Set new MC channel number " << event_type->mc_channel_number());
190 } else {
191 ATH_MSG_ERROR("No EventInfo object found");
192 return StatusCode::SUCCESS;
193 }
194
195 oldRunNumber = outputEvtInfo->runNumber();
196 outputEvtInfo->setRunNumber(m_newRunNumber);
197 outputEvtInfo->setMCChannelNumber(m_newRunNumber);
198
199 {
200 // change the channel number where /Generation/Parameters are found
201 auto newChannelNumber =
203 auto oldChannelNumber =
204 static_cast< CondAttrListCollection::ChanNum >(oldRunNumber);
205
206 const char* key = "/Generation/Parameters";
207 const IOVMetaDataContainer * iovContainer = nullptr;
208 if (m_metaDataStore->retrieve(iovContainer, key).isSuccess()
209 && iovContainer) {
210 // get a hold of the payload
211 const IOVPayloadContainer * payloadContainer =
212 iovContainer->payloadContainer();
213
214 // Grab the attribute list
215 for (CondAttrListCollection* collection : *payloadContainer) {
216 for(unsigned int index = 0; index < collection->size(); ++index) {
217 if (collection->chanNum(index) != oldChannelNumber) {
218 ATH_MSG_INFO("Not updating \"" << key << "\" on channel number "
219 << collection->chanNum(index));
220 continue;
221 }
222
223 if (collection->fixChanNum(oldChannelNumber, newChannelNumber))
224 ATH_MSG_INFO("Updated \"" << key << "\" channel number from "
225 << oldChannelNumber << " to " << newChannelNumber);
226 else
227 ATH_MSG_ERROR("Channel number update from " << oldChannelNumber
228 << " to " << newChannelNumber << " on \"" << key
229 << "\" FAILED");
230 }
231 }
232
233 {
234 // Update the MC channel number in the "/TagInfo"
235 const char* key = "/TagInfo";
236 const IOVMetaDataContainer * iovContainer = nullptr;
237 if (m_metaDataStore->retrieve(iovContainer, key).isSuccess()
238 && iovContainer) {
239 // get a hold of the payload
240 const IOVPayloadContainer * payloadContainer =
241 iovContainer->payloadContainer();
242
243 // Grab the attribute list
244 for (CondAttrListCollection* collection : *payloadContainer) {
245 for (auto pair : *collection) {
246 // pair is a pair of Channel number and AttributeList
247 if (pair.second.exists("mc_channel_number")) {
248 try {
249 pair.second["mc_channel_number"].setValue(
250 std::to_string(m_newRunNumber));
251 ATH_MSG_INFO("Updated \"" << key << "\" mc_channel_number"
252 << " to " << m_newRunNumber);
253 } catch (std::exception&) {
254 try {
255 pair.second["mc_channel_number"].setValue(m_newRunNumber);
256 ATH_MSG_INFO("Updated \"" << key << "\" mc_channel_number"
257 << " to " << m_newRunNumber);
258 } catch (std::exception&) {
259 ATH_MSG_ERROR("mc_channel_number update from to "
260 << m_newRunNumber << " on \"" << key
261 << "\" FAILED");
262 }
263 }
264 }
265 }
266 }
267 }
268 }
269 } else {
270 ATH_MSG_INFO("Could not retrieve \"" << key << "\" from MetaDataStore");
271 }
272 }
273 }
274
275
276 if (m_nPass == m_nCount) {
277 ATH_MSG_INFO("Stopping the event processing...." << m_nPass << "/" << m_nCount);
278 // Try the MP ELM first
279 SmartIF<IEventProcessor> apm(serviceLocator()->service("AthMpEvtLoopMgr", /*createIf*/false));
280 if(apm) {
281 ATH_CHECK(apm->stopRun());
282 }
283 else {
284 apm = serviceLocator()->service("AthenaEventLoopMgr", /*createIf*/false);
285 if (apm) {
286 ATH_CHECK(apm->stopRun());
287 }
288 else {
289 ATH_MSG_WARNING("No EventLoop Manager found ");
290 }
291 }
292 }
293
294 return StatusCode::SUCCESS;
295}
#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
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(HepMC::GenEvent *e, long long int num)
Definition GenEvent.h:614
retrieve(aClass, aKey=None)
Definition PyKernel.py:110
EventInfo_v1 EventInfo
Definition of the latest event info version.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< 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 & AthAlgorithm::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

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

Definition at line 50 of file AthAlgorithm.cxx.

51{
52 // If we didn't find any symlinks to add, just return the collection
53 // from the base class. Otherwise, return the extended collection.
54 if (!m_extendedExtraObjects.empty()) {
56 }
57 return Algorithm::extraOutputDeps();
58}
DataObjIDColl m_extendedExtraObjects

◆ finalize()

StatusCode CountHepMC::finalize ( )
overridevirtual

Definition at line 298 of file CountHepMC.cxx.

298 {
299 ATH_MSG_INFO("Events passing all checks and written = " << m_nPass);
300 return StatusCode::SUCCESS;
301}

◆ GeVToMeV()

void GenBase::GeVToMeV ( HepMC::GenEvent * evt)
protectedinherited

Scale event energies/momenta by x 1000.

Todo
Add HepMC units awareness and do it differently when HepMC provides this functionality directly (and reference-based FourVector accessors)

Definition at line 58 of file GenBase.cxx.

58 {
59 for (HepMC::GenEvent::particle_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p) {
60 const HepMC::FourVector fv((*p)->momentum().px() * 1000,
61 (*p)->momentum().py() * 1000,
62 (*p)->momentum().pz() * 1000,
63 (*p)->momentum().e() * 1000);
64 (*p)->set_momentum(fv);
65 (*p)->set_generated_mass(1000 * (*p)->generated_mass());
66 }
67}

◆ handle()

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

Definition at line 303 of file CountHepMC.cxx.

303 {
304 using AfterForkInc = AthenaInterprocess::UpdateAfterFork;
305 if(inc.type()==AfterForkInc::type()) {
306 int nProcs= Gaudi::Concurrency::ConcurrencyFlags::numProcs();
307 const AfterForkInc* afInc = dynamic_cast<const AfterForkInc*>(&inc);
308 if(afInc) {
309 int rem = m_nCount%nProcs;
310 m_nCount = m_nCount/nProcs
311 + (afInc->workerID() <= rem-1 ? 1 : 0);
312 }
313 else {
314 ATH_MSG_ERROR("Failed to dyn-cast the incident to UpdateAfterFork!");
315 throw std::runtime_error("Wrong incident type handled by CountHepMC");
316 }
317 }
318}

◆ 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< 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.

◆ MeVToGeV()

void GenBase::MeVToGeV ( HepMC::GenEvent * evt)
protectedinherited

Scale event energies/momenta by x 1/1000.

Definition at line 68 of file GenBase.cxx.

68 {
69 for (HepMC::GenEvent::particle_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p) {
70 const HepMC::FourVector fv((*p)->momentum().px() / 1000,
71 (*p)->momentum().py() / 1000,
72 (*p)->momentum().pz() / 1000,
73 (*p)->momentum().e() / 1000);
74 (*p)->set_momentum(fv);
75 (*p)->set_generated_mass((*p)->generated_mass() / 1000);
76 }
77}

◆ mmTocm()

void GenBase::mmTocm ( HepMC::GenEvent * evt)
protectedinherited

Scale event lengths by x 1/10.

Definition at line 87 of file GenBase.cxx.

87 {
88 for (HepMC::GenEvent::vertex_iterator vtx = evt->vertices_begin(); vtx != evt->vertices_end(); ++vtx) {
89 const HepMC::FourVector fv((*vtx)->position().x() / 10,
90 (*vtx)->position().y() / 10,
91 (*vtx)->position().z() / 10,
92 (*vtx)->position().t() / 10);
93 (*vtx)->set_position(fv);
94 }
95}

◆ msg()

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

Definition at line 24 of file AthCommonMsg.h.

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

◆ msgLvl()

bool AthCommonMsg< 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< 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.

◆ particleData()

const HepPDT::ParticleData * GenBase::particleData ( int pid) const
inlineinherited

Access an element in the particle data table.

Definition at line 126 of file GenBase.h.

126 {
127 return pdt().particle(HepPDT::ParticleID(std::abs(pid)));
128 }
const HepPDT::ParticleDataTable & pdt() const
Shorter alias to get a particle data table.
Definition GenBase.h:123

◆ particleTable()

const HepPDT::ParticleDataTable & GenBase::particleTable ( ) const
inlineinherited

Get a particle data table.

Definition at line 118 of file GenBase.h.

118 {
119 return *(m_ppSvc->PDT());
120 }
ServiceHandle< IPartPropSvc > m_ppSvc
Handle on the particle property service.
Definition GenBase.h:160

◆ partPropSvc()

const ServiceHandle< IPartPropSvc > GenBase::partPropSvc ( ) const
inlineinherited

Access the particle property service.

Definition at line 113 of file GenBase.h.

113 {
114 return m_ppSvc;
115 }

◆ pdt()

const HepPDT::ParticleDataTable & GenBase::pdt ( ) const
inlineinherited

Shorter alias to get a particle data table.

Definition at line 123 of file GenBase.h.

123{ return particleTable(); }
const HepPDT::ParticleDataTable & particleTable() const
Get a particle data table.
Definition GenBase.h:118

◆ 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< 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< Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

StatusCode AthAlgorithm::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< Algorithm > >.

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

Definition at line 66 of file AthAlgorithm.cxx.

66 {
68
69 if (sc.isFailure()) {
70 return sc;
71 }
72 ServiceHandle<ICondSvc> cs("CondSvc",name());
73 for (auto h : outputHandles()) {
74 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
75 // do this inside the loop so we don't create the CondSvc until needed
76 if ( cs.retrieve().isFailure() ) {
77 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
78 return StatusCode::SUCCESS;
79 }
80 if (cs->regHandle(this,*h).isFailure()) {
81 sc = StatusCode::FAILURE;
82 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
83 << " with CondSvc");
84 }
85 }
86 }
87 return sc;
88}
static Double_t sc
virtual StatusCode sysInitialize() override
Override sysInitialize.
AthCommonDataStore(const std::string &name, T... args)
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< 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< 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 }
std::vector< SG::VarHandleKeyArray * > m_vhka

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< 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< Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthAlgorithm::m_extendedExtraObjects
privateinherited

Definition at line 79 of file AthAlgorithm.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 137 of file GenBase.h.

137{};

◆ 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 163 of file GenBase.h.

163{ 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 139 of file GenBase.h.

139{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_ppSvc

ServiceHandle<IPartPropSvc> GenBase::m_ppSvc {this, "PartPropSvc", "PartPropSvc"}
privateinherited

Handle on the particle property service.

Definition at line 160 of file GenBase.h.

160{this, "PartPropSvc", "PartPropSvc"};

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.


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