Base class for common behaviour of MC truth algorithms.
More...
#include <GenBase.h>
Inherits AthAlgorithm.
Inherited by CopyEventWeight, CountHepMC, DumpMC, EvtInclusiveDecay, FillFilterValues, FixHepMC, GenAnalysis, GenFilter, GenModule, HepMCReadFromFile, PrintHijingPars, PrintMC, SimTimeEstimate, TestHepMC, and WriteHepMC.
|
| 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.
|
|
- Todo
- Replace with HepMC units when available
|
| ServiceHandle< IPartPropSvc > | m_ppSvc {this, "PartPropSvc", "PartPropSvc"} |
| | Handle on the particle property service.
|
| SG::ReadHandleKey< McEventCollection > | m_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.
|
Base class for common behaviour of MC truth algorithms.
This class is the base class used to specify the behavior of all MC truth algorithms and is meant to capture the common behavior of these modules. GenBase inherits the AthAlgorithm interface. Event generator interfaces should inherit from the derived GenModule interface, which adds more generation-specific functionality.
The common behavior currently consists of:
- Standard access to the event collection and its first member
- Providing access to the HepPDT ParticleProperties Table
- Including standard HepMC and Athena framework headers and CMT uses
The following virtual methods should be overloaded in the child class:
- Author
- A. Buckley: Creating GenBase from GenModule, Nov 2013.
Definition at line 47 of file GenBase.h.
◆ StoreGateSvc_t
◆ GenBase()
| GenBase::GenBase |
( |
const std::string & | name, |
|
|
ISvcLocator * | pSvcLocator ) |
Constructor.
Definition at line 11 of file GenBase.cxx.
13{
14}
AthAlgorithm()
Default constructor:
◆ ~GenBase()
| virtual GenBase::~GenBase |
( |
| ) |
|
|
inlinevirtual |
Virtual destructor.
Definition at line 57 of file GenBase.h.
◆ ATLAS_NOT_CONST_THREAD_SAFE() [1/2]
| HepMC::GenEvent *event GenBase::ATLAS_NOT_CONST_THREAD_SAFE |
( |
| ) |
|
|
inline |
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 {
78 ATH_MSG_ERROR(
"McEventCollection is empty during first event access");
79 return *(
events()->begin());
80 }
static const Attributes_t empty
◆ ATLAS_NOT_CONST_THREAD_SAFE() [2/2]
◆ cmTomm()
| void GenBase::cmTomm |
( |
HepMC::GenEvent * | evt | ) |
|
|
protected |
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()
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition at line 156 of file AthCommonDataStore.h.
158 {
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
◆ declareProperty()
Definition at line 145 of file AthCommonDataStore.h.
145 {
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
◆ detStore()
◆ event_const()
| const HepMC::GenEvent * GenBase::event_const |
( |
| ) |
const |
|
inline |
Access the current signal event (const)
Definition at line 83 of file GenBase.h.
83 {
85 ATH_MSG_ERROR(
"Const McEventCollection is empty during first event access");
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)
◆ events_const() [1/2]
◆ events_const() [2/2]
Definition at line 99 of file GenBase.h.
99 {
104 }
SG::ReadHandleKey< McEventCollection > m_mcevents_const
Const handle to the MC event collection.
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()
◆ execute()
| virtual StatusCode GenBase::execute |
( |
| ) |
|
|
inlineoverridevirtual |
Reimplemented in CopyEventWeight, CountHepMC, DumpMC, EvtInclusiveDecay, FillFilterValues, FixHepMC, GenAnalysis, GenFilter, GenModule, HepMCReadFromFile, PrintHijingPars, PrintMC, SimTimeEstimate, TestHepMC, and WriteHepMC.
Definition at line 65 of file GenBase.h.
65{ return StatusCode::SUCCESS; }
◆ extraDeps_update_handler()
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
53
56 }
57 return Algorithm::extraOutputDeps();
58}
DataObjIDColl m_extendedExtraObjects
◆ GeVToMeV()
| void GenBase::GeVToMeV |
( |
HepMC::GenEvent * | evt | ) |
|
|
protected |
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}
◆ initialize()
| StatusCode GenBase::initialize |
( |
| ) |
|
|
overridevirtual |
Reimplemented in CopyEventWeight, CountHepMC, DumpMC, EvtInclusiveDecay, FillFilterValues, GenAnalysis, GenFilter, GenModule, HepMCReadFromFile, PrintHijingPars, PrintMC, TestHepMC, and WriteHepMC.
Definition at line 17 of file GenBase.cxx.
17 {
20
21
23 return StatusCode::SUCCESS;
24}
#define ATH_CHECK
Evaluate an expression and check for errors.
std::string m_mcEventKey
StoreGate key for the MC event collection (defaults to GEN_EVENT)
ServiceHandle< IPartPropSvc > m_ppSvc
Handle on the particle property service.
◆ inputHandles()
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 | ) |
|
|
protected |
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 | ) |
|
|
protected |
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()
◆ msgLvl()
| bool AthCommonMsg< Algorithm >::msgLvl |
( |
const MSG::Level | lvl | ) |
const |
|
inlineinherited |
◆ outputHandles()
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 |
|
inline |
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.
◆ particleTable()
| const HepPDT::ParticleDataTable & GenBase::particleTable |
( |
| ) |
const |
|
inline |
Get a particle data table.
Definition at line 118 of file GenBase.h.
◆ partPropSvc()
| const ServiceHandle< IPartPropSvc > GenBase::partPropSvc |
( |
| ) |
const |
|
inline |
Access the particle property service.
Definition at line 113 of file GenBase.h.
◆ pdt()
| const HepPDT::ParticleDataTable & GenBase::pdt |
( |
| ) |
const |
|
inline |
Shorter alias to get a particle data table.
Definition at line 123 of file GenBase.h.
const HepPDT::ParticleDataTable & particleTable() const
Get a particle data table.
◆ renounce()
Definition at line 380 of file AthCommonDataStore.h.
381 {
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()
◆ 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
71 }
72 ServiceHandle<ICondSvc> cs(
"CondSvc",
name());
74 if (
h->isCondition() &&
h->mode() == Gaudi::DataHandle::Writer) {
75
76 if ( cs.retrieve().isFailure() ) {
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 }
88}
#define ATH_MSG_WARNING(x)
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()
Handle START transition.
We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.
◆ updateVHKA()
Definition at line 308 of file AthCommonDataStore.h.
308 {
309
310
313 for (
auto k :
keys) {
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka
◆ m_detStore
◆ m_evtStore
◆ m_extendedExtraObjects
| DataObjIDColl AthAlgorithm::m_extendedExtraObjects |
|
privateinherited |
◆ m_mcEventKey
| std::string GenBase::m_mcEventKey {} |
|
protected |
StoreGate key for the MC event collection (defaults to GEN_EVENT)
Definition at line 137 of file GenBase.h.
◆ m_mcevents_const
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_mkMcEvent
| BooleanProperty GenBase::m_mkMcEvent {this, "MakeMcEvent", false, "Create a new MC event collection if it doesn't exist"} |
|
protected |
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_ppSvc
| ServiceHandle<IPartPropSvc> GenBase::m_ppSvc {this, "PartPropSvc", "PartPropSvc"} |
|
private |
Handle on the particle property service.
Definition at line 160 of file GenBase.h.
160{this, "PartPropSvc", "PartPropSvc"};
◆ m_varHandleArraysDeclared
◆ m_vhka
The documentation for this class was generated from the following files: