5#ifndef GENERATOROBJECTS_HEPMCPARTICLELINK_H
6#define GENERATOROBJECTS_HEPMCPARTICLELINK_H
19#include "GaudiKernel/MsgStream.h"
20#include "GaudiKernel/EventContext.h"
276 void print(std::ostream& os)
const;
282 void print(MsgStream& os)
const;
341 mutable std::atomic<barcode_type>
m_BC;
401 const EventContext& ctx);
435 const EventContext& ctx);
514 operator bool()
const;
Cached value with atomic update.
std::vector< Identifier > ID
std::ostream & operator<<(std::ostream &os, const HepMcParticleLink &link)
Output operator.
bool operator==(HepMC::ConstGenParticlePtr a, const HepMcParticleLink &b)
Comparison with ConstGenParticlePtr.
Cached value with atomic update.
Persistent representation of a link.
void print(std::ostream &os) const
Dump in textual format to a stream.
void setTruthSuppressionType(EBC_SUPPRESSED_TRUTH truthSupp)
Return whether the truth particle has been suppressed.
ExtendedBarCode(const ExtendedBarCode &rhs)
Copy constructor.
static constexpr index_type POSITION_MASK
Flag marking that an index refers to an event position.
static int compareUniqueID(const HepMcParticleLink &lhs, const HepMcParticleLink &rhs)
Compare the unique ID part of two links.
std::atomic< index_type > m_evtIndex
Identifies the target GenEvent within the event collection.
void setUniqueID(barcode_type uid, UniqueIDFlag barcodeFlag)
Initialize the unique identifier part of the link.
void eventIndex(index_type &index, index_type &position) const
Return the event index/position.
void makeID(barcode_type ID, barcode_type barcode) const
Change m_BC from barcode to ID.
void setIndex(index_type idx, PositionFlag positionFlag)
Initialize the event index part of the link.
static char truthSuppressionTypeAsChar(EBC_SUPPRESSED_TRUTH suppEnum)
Translate truth suppression enum to a char ('a'..'b').
ExtendedBarCode & operator=(const ExtendedBarCode &rhs)
Assignment.
bool operator<(const ExtendedBarCode &rhs) const
Ordering test.
ExtendedBarCode(ExtendedBarCode &&rhs) noexcept
Move constructor.
bool operator!=(const ExtendedBarCode &rhs) const
Inequality test.
static EBC_SUPPRESSED_TRUTH truthSuppressionTypeFromChar(char suppChar)
Translate truth suppression char ('a'..'b') to an enum.
bool operator==(const ExtendedBarCode &rhs) const
Equality test.
char getTruthSuppressionTypeAsChar() const
Return whether the truth particle has been suppressed, as a char ('a'..'b').
barcode_type uid() const
Unique ID of target variable (0 for a null link).
void makeIndex(index_type index, index_type position) const
Change index from position to number.
static constexpr index_type UNDEFINED
All 1's. Used to represent an undefined index/position.
ExtendedBarCode()
Default constructor.
EBC_SUPPRESSED_TRUTH m_truthSupp
Indicates whether the truth particle has been suppressed.
static constexpr barcode_type BARCODE_MASK
Flag marking that an unique ID refers to a barcode.
bool linkIsNull() const
return true if neither barcode nor id are valid
void uniqueID(barcode_type &id, barcode_type &barcode) const
Return the GenParticle id/barcode.
EBC_SUPPRESSED_TRUTH getTruthSuppressionType() const
Return whether the truth particle has been suppressed.
static int compareIndex(const HepMcParticleLink &lhs, const HepMcParticleLink &rhs)
Compare the event index part of two links.
std::atomic< barcode_type > m_BC
Unique ID of the target particle. 0 means a null link.
ExtendedBarCode(barcode_type uid, index_type eventIndex, PositionFlag isIndexEventPosition=IS_EVENTNUM, UniqueIDFlag isUniqueIDBarcode=IS_ID)
Constructor.
static constexpr barcode_type UNDEFINEDBC
a link optimized in size for a GenParticle in a McEventCollection
HepMcParticleLink & operator=(const HepMcParticleLink &rhs)=default
Assignment.
barcode_type compress() const
Hash the 32 bit barcode and 16 bit eventindex into a 32bit int.
HepMC::ConstGenParticlePtr operator->() const
Dereference.
EBC_SUPPRESSED_TRUTH getTruthSuppressionType() const
Return whether the truth particle has been suppressed, as an enum.
void setExtendedBarCode(const ExtendedBarCode &extBarcode)
Alter the persistent part of the link.
int id() const
Return the id of the target particle.
bool linkIsNull() const
return true if neither barcode nor id are valid
const HepMC::GenParticle & operator*() const
Dereference.
friend std::ostream & operator<<(std::ostream &, const HepMcParticleLink &)
Output operator.
HepMcParticleLink(const EventContext &ctx)
Default constructor.
bool isValid() const
Validity check.
HepMcParticleLink & operator=(HepMcParticleLink &&rhs)=default
Move Assignment.
static const McEventCollection * retrieveMcEventCollection(const IProxyDict *sg)
Look up the event collection we're targeting.
HepMcParticleLink(barcode_type uid, uint32_t eventIndex, PositionFlag positionFlag, UniqueIDFlag uniqueIDFlag, const EventContext &ctx)
Constructor.
bool operator!=(const HepMcParticleLink &rhs) const
Inequality comparison.
static SG::DataProxy * find_proxy(const IProxyDict *sg)
Find the proxy for the target event collection.
HepMcParticleLink(const HepMcParticleLink &rhs)=default
Copy constructor.
bool operator!() const
Validity check.
HepMC::ConstGenParticlePtr cptr() const
Dereference.
bool operator<(const HepMcParticleLink &rhs) const
Ordering comparison.
HepMcParticleLink(IProxyDict *sg=nullptr)
Default constructor.
HepMcParticleLink(HepMcParticleLink &&rhs) noexcept=default
Move constructor.
ExtendedBarCode m_extBarcode
Persistent part: barcode and location of target GenEvent.
static std::string getLastEventCollectionName()
Return the most recent SG key used for a particular collection type.
static std::vector< index_type > getEventPositionInCollection(index_type index, const IProxyDict *sg)
Return a vector of the positions in the McEventCollection of the GenEvent(s) with a given event numbe...
char getTruthSuppressionTypeAsChar() const
Return whether the truth particle has been suppressed, as a char ('a'..'b').
HepMC::ConstGenParticlePtr scptr() const
Dereference/smart pointer.
static int getEventNumberAtPosition(index_type position, const IProxyDict *sg)
Return the event number of the GenEvent at the specified position in the McEventCollection.
index_type eventIndex() const
Return the event number of the referenced GenEvent.
static HepMcParticleLink getRedirectedLink(const HepMcParticleLink &particleLink, uint32_t eventIndex, const EventContext &ctx)
Return a HepMcParticleLink pointing at the same particle, but in a different GenEvent.
int barcode() const
Return the barcode of the target particle.
HepMcParticleLink(const HepMC::ConstGenParticlePtr &part, uint32_t eventIndex, PositionFlag positionFlag, const EventContext &ctx)
Constructor.
HepMcParticleLink(barcode_type uid, uint32_t eventIndex, PositionFlag positionFlag, UniqueIDFlag uniqueIDFlag, IProxyDict *sg=SG::CurrentEventStore::store())
Constructor.
IProxyDict * m_store
Pointer to the store containing the event.
bool operator==(const HepMcParticleLink &rhs) const
Equality comparison.
void setTruthSuppressionType(EBC_SUPPRESSED_TRUTH truthSupp)
Return whether the truth particle has been suppressed.
ATH_NO_UNIQUE_ADDRESS CxxUtils::CachedValue< HepMC::ConstGenParticlePtr > m_ptr
Transient part. Pointer to the particle.
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...
static IProxyDict * store()
Fetch the current store.
const GenParticle * ConstGenParticlePtr
Wrapper for C++20 no_unique_address attribute.
#define ATH_NO_UNIQUE_ADDRESS