Loading [MathJax]/extensions/tex2jax.js
 |
ATLAS Offline Software
|
Algorithm demonstrating reading of HepMC truth, and printing to screen.
More...
#include <HepMCTruthReader.h>
|
| HepMCTruthReader (const std::string &name, ISvcLocator *svcLoc) |
| Regular algorithm constructor. More...
|
|
virtual StatusCode | initialize () |
| Function initialising the algorithm. More...
|
|
virtual StatusCode | execute (const EventContext &ctx) const |
| Function executing the algorithm. More...
|
|
virtual StatusCode | sysInitialize () override |
| Override sysInitialize. More...
|
|
virtual bool | isClonable () const override |
| Specify if the algorithm is clonable. More...
|
|
virtual unsigned int | cardinality () const override |
| Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentrant. More...
|
|
virtual StatusCode | sysExecute (const EventContext &ctx) override |
| Execute an algorithm. More...
|
|
virtual const DataObjIDColl & | extraOutputDeps () const override |
| Return the list of extra output dependencies. More...
|
|
virtual bool | filterPassed (const EventContext &ctx) const |
|
virtual void | setFilterPassed (bool state, const EventContext &ctx) const |
|
ServiceHandle< StoreGateSvc > & | evtStore () |
| The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc . More...
|
|
const ServiceHandle< StoreGateSvc > & | evtStore () const |
| The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc . More...
|
|
const ServiceHandle< StoreGateSvc > & | detStore () const |
| The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc . More...
|
|
virtual StatusCode | sysStart () override |
| Handle START transition. More...
|
|
virtual std::vector< Gaudi::DataHandle * > | inputHandles () const override |
| Return this algorithm's input handles. More...
|
|
virtual std::vector< Gaudi::DataHandle * > | outputHandles () const override |
| Return this algorithm's output handles. More...
|
|
Gaudi::Details::PropertyBase & | declareProperty (Gaudi::Property< T > &t) |
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, SG::VarHandleKey &hndl, const std::string &doc, const SG::VarHandleKeyType &) |
| Declare a new Gaudi property. More...
|
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, SG::VarHandleBase &hndl, const std::string &doc, const SG::VarHandleType &) |
| Declare a new Gaudi property. More...
|
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, SG::VarHandleKeyArray &hndArr, const std::string &doc, const SG::VarHandleKeyArrayType &) |
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, T &property, const std::string &doc, const SG::NotHandleType &) |
| Declare a new Gaudi property. More...
|
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, T &property, const std::string &doc="none") |
| Declare a new Gaudi property. More...
|
|
void | updateVHKA (Gaudi::Details::PropertyBase &) |
|
MsgStream & | msg () const |
|
MsgStream & | msg (const MSG::Level lvl) const |
|
bool | msgLvl (const MSG::Level lvl) const |
|
Algorithm demonstrating reading of HepMC truth, and printing to screen.
- Author
- James Catmore James.nosp@m..Cat.nosp@m.more@.nosp@m.cern.nosp@m..ch
Definition at line 18 of file HepMCTruthReader.h.
◆ StoreGateSvc_t
◆ HepMCTruthReader()
HepMCTruthReader::HepMCTruthReader |
( |
const std::string & |
name, |
|
|
ISvcLocator * |
svcLoc |
|
) |
| |
◆ cardinality()
Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentrant.
Override this to return 0 for reentrant algorithms.
Override this to return 0 for reentrant algorithms.
Definition at line 75 of file AthCommonReentrantAlgorithm.cxx.
◆ declareGaudiProperty() [1/4]
specialization for handling Gaudi::Property<SG::VarHandleKeyArray>
Definition at line 170 of file AthCommonDataStore.h.
175 hndl.documentation());
◆ declareGaudiProperty() [2/4]
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition at line 156 of file AthCommonDataStore.h.
161 hndl.documentation());
◆ declareGaudiProperty() [3/4]
specialization for handling Gaudi::Property<SG::VarHandleBase>
Definition at line 184 of file AthCommonDataStore.h.
189 hndl.documentation());
◆ declareGaudiProperty() [4/4]
◆ declareProperty() [1/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
hndl | Object holding the property value. |
doc | Documentation string for the property. |
This is the version for types that derive from SG::VarHandleBase
. The property value object is put on the input and output lists as appropriate; then we forward to the base class.
Definition at line 245 of file AthCommonDataStore.h.
250 this->declare(hndl.
vhKey());
251 hndl.
vhKey().setOwner(
this);
◆ declareProperty() [2/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
hndl | Object holding the property value. |
doc | Documentation string for the property. |
This is the version for types that derive from SG::VarHandleKey
. The property value object is put on the input and output lists as appropriate; then we forward to the base class.
Definition at line 221 of file AthCommonDataStore.h.
◆ declareProperty() [3/6]
◆ declareProperty() [4/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
property | Object holding the property value. |
doc | Documentation string for the property. |
This is the generic version, for types that do not derive from SG::VarHandleKey
. It just forwards to the base class version of declareProperty
.
Definition at line 333 of file AthCommonDataStore.h.
◆ declareProperty() [5/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
property | Object holding the property value. |
doc | Documentation string for the property. |
This dispatches to either the generic declareProperty
or the one for VarHandle/Key/KeyArray.
Definition at line 352 of file AthCommonDataStore.h.
◆ declareProperty() [6/6]
◆ detStore()
◆ evtStore() [1/2]
◆ evtStore() [2/2]
◆ execute()
StatusCode HepMCTruthReader::execute |
( |
const EventContext & |
ctx | ) |
const |
|
virtual |
Function executing the algorithm.
Definition at line 35 of file HepMCTruthReader.cxx.
40 if (!mcColl.isValid()) {
43 return StatusCode::FAILURE;
48 ATH_MSG_INFO(
"Number of pile-up events in this Athena event: " << mcColl->size()-1);
51 for (
unsigned int cntr = 0; cntr < mcColl->size(); ++cntr) {
52 const HepMC::GenEvent* genEvt = (*mcColl)[cntr];
61 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()
Return the list of extra output dependencies.
This list is extended to include symlinks implied by inheritance relations.
Definition at line 94 of file AthCommonReentrantAlgorithm.cxx.
◆ filterPassed()
◆ initialize()
StatusCode HepMCTruthReader::initialize |
( |
| ) |
|
|
virtual |
Function initialising the algorithm.
Definition at line 25 of file HepMCTruthReader.cxx.
31 return StatusCode::SUCCESS;
◆ 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.
◆ isClonable()
◆ msg() [1/2]
◆ msg() [2/2]
◆ msgLvl()
◆ 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.
◆ printEvent()
void HepMCTruthReader::printEvent |
( |
const HepMC::GenEvent * |
evt, |
|
|
bool |
do4momPtEtaPhi |
|
) |
| |
|
staticprivate |
Definition at line 67 of file HepMCTruthReader.cxx.
68 cout <<
"--------------------------------------------------------------------------------\n";
69 cout <<
"GenEvent: #" <<
"NNN" <<
"\n";
70 cout <<
" Entries this event: " <<
event->vertices_size() <<
" vertices, " <<
event->particles_size() <<
" particles.\n";
71 cout <<
" GenParticle Legend\n";
72 if (do4momPtEtaPhi) cout <<
" Barcode PDG ID ( pt, eta, phi, E ) Stat DecayVtx\n";
73 else cout <<
" Barcode PDG ID ( Px, Py, Pz, E ) Stat DecayVtx\n";
74 cout <<
"--------------------------------------------------------------------------------\n";
78 for (HepMC::GenEvent::vertex_const_iterator iv =
event->vertices_begin(); iv !=
event->vertices_end(); ++iv) {
82 cout <<
"--------------------------------------------------------------------------------\n";
◆ printParticle()
Definition at line 206 of file HepMCTruthReader.cxx.
208 std::ios::fmtflags
f( cout.flags() );
216 cout.setf(std::ios::scientific, std::ios::floatfield);
217 cout.setf(std::ios_base::showpos);
218 if (do4momPtEtaPhi) cout <<
particle->momentum().perp() <<
",";
219 else cout <<
particle->momentum().px() <<
",";
222 if (do4momPtEtaPhi) cout <<
particle->momentum().pseudoRapidity() <<
",";
223 else cout <<
particle->momentum().py() <<
",";
226 if (do4momPtEtaPhi) cout <<
particle->momentum().phi() <<
",";
227 else cout <<
particle->momentum().pz() <<
",";
230 cout <<
particle->momentum().e() <<
" ";
231 cout.setf(std::ios::fmtflags(0), std::ios::floatfield);
232 cout.unsetf(std::ios_base::showpos);
◆ printVertex()
Definition at line 87 of file HepMCTruthReader.cxx.
89 std::ios::fmtflags
f( cout.flags() );
90 cout <<
"GenVertex (" <<
vertex <<
"):";
92 if (
vertex->position().x() != 0.0 &&
vertex->position().y() != 0.0 &&
vertex->position().z() != 0.0) {
101 cout.setf(std::ios::scientific, std::ios::floatfield);
102 cout.setf(std::ios_base::showpos);
103 cout <<
vertex->position().x() <<
",";
106 cout <<
vertex->position().y() <<
",";
109 cout <<
vertex->position().z() <<
",";
112 cout <<
vertex->position().t();
113 cout.setf(std::ios::fmtflags(0), std::ios::floatfield);
114 cout.unsetf(std::ios_base::showpos);
122 cout <<
" (X,cT): 0";
129 if (
vertex->position().x() != 0.0 &&
vertex->position().y() != 0.0 &&
vertex->position().z() != 0.0) {
137 cout.setf(std::ios::scientific, std::ios::floatfield);
138 cout.setf(std::ios_base::showpos);
139 cout <<
vertex->position().x();
142 cout <<
vertex->position().y();
145 cout <<
vertex->position().z();
148 cout <<
vertex->position().t();
149 cout.setf(std::ios::fmtflags(0), std::ios::floatfield);
150 cout.unsetf(std::ios_base::showpos);
164 for (
const auto& iPIn:
vertex->particles_in()) {
165 if ( iPIn ==
vertex->particles_in().front() ) {
168 cout <<
vertex->particles_in().size();
172 for (
const auto& iPOut:
vertex->particles_out()) {
173 if ( iPOut ==
vertex->particles_out().front()) {
176 cout <<
vertex->particles_out().size();
181 for (HepMC::GenVertex::particles_in_const_iterator iPIn =
vertex->particles_in_const_begin();
182 iPIn !=
vertex->particles_in_const_end(); ++iPIn) {
183 if ( iPIn ==
vertex->particles_in_const_begin() ) {
186 cout <<
vertex->particles_in_size();
190 for (HepMC::GenVertex::particles_out_const_iterator iPOut =
vertex->particles_out_const_begin();
191 iPOut !=
vertex->particles_out_const_end(); ++iPOut) {
192 if ( iPOut ==
vertex->particles_out_const_begin() ) {
195 cout <<
vertex->particles_out_size();
◆ renounce()
◆ renounceArray()
◆ setFilterPassed()
◆ sysExecute()
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.
Definition at line 85 of file AthCommonReentrantAlgorithm.cxx.
◆ sysInitialize()
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 InputMakerBase, and HypoBase.
Definition at line 61 of file AthCommonReentrantAlgorithm.cxx.
110 if (
sc.isFailure()) {
118 if ( cs.retrieve().isFailure() ) {
120 return StatusCode::SUCCESS;
122 if (cs->regHandle(
this,*
h).isFailure()) {
123 sc = StatusCode::FAILURE;
124 ATH_MSG_ERROR(
"unable to register WriteCondHandle " <<
h->fullKey()
◆ 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()
◆ m_detStore
◆ m_do4momPtEtaPhi
Gaudi::Property<bool> HepMCTruthReader::m_do4momPtEtaPhi {this, "Do4momPtEtaPhi", false} |
|
private |
Flag to printout in pt,eta,phi instead of px,py,pz.
Definition at line 38 of file HepMCTruthReader.h.
◆ m_evtStore
◆ m_extendedExtraObjects
Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.
Empty if no symlinks were found.
Definition at line 114 of file AthCommonReentrantAlgorithm.h.
◆ m_hepMCContainerKey
Initial value:{
this, "HepMCContainerKey", "GEN_EVENT", "The input McEvenCollection"}
The key of the input HepMC truth container.
Definition at line 34 of file HepMCTruthReader.h.
◆ m_varHandleArraysDeclared
◆ m_vhka
The documentation for this class was generated from the following files:
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
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)
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
const std::string & key() const
Return the StoreGate ID for the referenced object.
static void printParticle(const HepMC::ConstGenParticlePtr &part, bool do4momPtEtaPhi)
virtual void setOwner(IDataHandleHolder *o)=0
An algorithm that can be simultaneously executed in multiple threads.
Gaudi::Property< bool > m_do4momPtEtaPhi
Flag to printout in pt,eta,phi instead of px,py,pz.
virtual const DataObjIDColl & extraOutputDeps() const override
Return the list of extra output dependencies.
static void printEvent(const HepMC::GenEvent *evt, bool do4momPtEtaPhi)
POOL::TEvent event(POOL::TEvent::kClassAccess)
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override
Return this algorithm's output handles.
::StatusCode StatusCode
StatusCode definition for legacy code.
SG::ReadHandleKey< McEventCollection > m_hepMCContainerKey
The key of the input HepMC truth container.
virtual StatusCode sysExecute(const EventContext &ctx) override
Execute an algorithm.
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
virtual void renounce()=0
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
#define ATH_MSG_WARNING(x)
bool isDecayed(const T &p)
Identify if the particle decayed.
static void printVertex(const HepMC::ConstGenVertexPtr &vtx, bool do4momPtEtaPhi)
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
virtual StatusCode sysInitialize() override
Override sysInitialize.
DataObjIDColl m_extendedExtraObjects
Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>