ATLAS Offline Software
|
a link optimized in size for a GenParticle in a McEventCollection More...
#include <HepMcParticleLink.h>
Classes | |
class | ExtendedBarCode |
Persistent representation of a link. More... | |
Public Types | |
enum | PositionFlag { IS_EVENTNUM = 0, IS_POSITION = 1 } |
enum | UniqueIDFlag { IS_ID = 0, IS_BARCODE = 1 } |
typedef uint32_t | barcode_type |
typedef uint32_t | index_type |
ParticleLink-specific methods. | |
IProxyDict * | m_store |
Pointer to the store containing the event. More... | |
ATH_NO_UNIQUE_ADDRESS CxxUtils::CachedValue< HepMC::ConstGenParticlePtr > | m_ptr |
Transient part. Pointer to the particle. More... | |
ExtendedBarCode | m_extBarcode |
Persistent part: barcode and location of target GenEvent. More... | |
int | barcode () const |
Return the barcode of the target particle. More... | |
int | id () const |
Return the id of the target particle. More... | |
index_type | eventIndex () const |
Return the event number of the referenced GenEvent. More... | |
index_type | getEventPositionInCollection (const IProxyDict *sg) const |
Return the position in the McEventCollection of the GenEvent pointed to by this HepMcParticleLink. More... | |
EBC_SUPPRESSED_TRUTH | getTruthSuppressionType () const |
Return whether the truth particle has been suppressed, as an enum. More... | |
void | setTruthSuppressionType (EBC_SUPPRESSED_TRUTH truthSupp) |
Return whether the truth particle has been suppressed. More... | |
char | getTruthSuppressionTypeAsChar () const |
Return whether the truth particle has been suppressed, as a char ('a'..'b'). More... | |
barcode_type | compress () const |
Hash the 32 bit barcode and 16 bit eventindex into a 32bit int. More... | |
void | setExtendedBarCode (const ExtendedBarCode &extBarcode) |
Alter the persistent part of the link. More... | |
static int | getEventNumberAtPosition (index_type position, const IProxyDict *sg) |
Return the event number of the GenEvent at the specified position in the McEventCollection. More... | |
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 number. More... | |
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. More... | |
std::ostream & | operator<< (std::ostream &, const HepMcParticleLink &) |
Output operator. More... | |
MsgStream & | operator<< (MsgStream &, const HepMcParticleLink &) |
Output operator. More... | |
static const McEventCollection * | retrieveMcEventCollection (const IProxyDict *sg) |
Look up the event collection we're targeting. More... | |
static SG::DataProxy * | find_proxy (const IProxyDict *sg) |
Find the proxy for the target event collection. More... | |
static std::string | getLastEventCollectionName () |
Return the most recent SG key used for a particular collection type. More... | |
a link optimized in size for a GenParticle in a McEventCollection
A link is defined by three items:
There is a list of StoreGate keys for the McEventCollection (see the initialization of s_keys
). When we want to dereference the link, we try to look up each possible key in turn until we find one that works. (The position of that key in the list is then remembered as a hint for where to start searching next time.)
The particular GenEvent within the collection can be represented as either an event number (as returned by GenEvent::event_number()) or by a position within the collection. Which case is desired is indicated by the value of the isIndexEventPosition argument to the constructors (defaulting to the event number case). In order to convert between these, we need to retrieve the McEventCollection from the store, but we don't have the store pointer once the link has been dereferenced. Therefore, when a position-based link is dereferenced, it is automatically changed to be event-number-based. This also happens when a link is constructed with an explicit ConstGenParticlePtr and a position-based GenEvent.
As a special case, a GenEvent number of 0 is interpreted as the first GenEvent in the collection.
The particle within the GenEvent is represented by a unique ID. A unique ID of 0 implies a null link.
In order to dereference a link, we need to reference a particular event store. By default, the current store (as defined by SG::CurrentEventStore::store()) is stored when the link is constructed; however, an explicit IProxyDict* or EventContext may also be specified.
Definition at line 71 of file HepMcParticleLink.h.
typedef uint32_t HepMcParticleLink::barcode_type |
Definition at line 74 of file HepMcParticleLink.h.
typedef uint32_t HepMcParticleLink::index_type |
Definition at line 75 of file HepMcParticleLink.h.
Enumerator | |
---|---|
IS_EVENTNUM | |
IS_POSITION |
Definition at line 78 of file HepMcParticleLink.h.
Enumerator | |
---|---|
IS_ID | |
IS_BARCODE |
Definition at line 83 of file HepMcParticleLink.h.
HepMcParticleLink::HepMcParticleLink | ( | IProxyDict * | sg = nullptr | ) |
Default constructor.
Makes a null link.
sg | Optional specification of a specific store to reference. |
HepMcParticleLink::HepMcParticleLink | ( | const EventContext & | ctx | ) |
HepMcParticleLink::HepMcParticleLink | ( | barcode_type | uid, |
uint32_t | eventIndex, | ||
PositionFlag | positionFlag, | ||
UniqueIDFlag | uniqueIDFlag, | ||
IProxyDict * | sg = SG::CurrentEventStore::store() |
||
) |
Constructor.
uid | Unique ID of the target particle. 0 means a null link. |
eventIndex | Identifies the target GenEvent in a McEventCollection, as either the event number if isIndexEventPosition is IS_EVENTNUM, or the position in the container if isIndexEventPosition is IS_POSITION. 0 always means the first event in the collection. |
positionFlag | See eventIndex . |
sg | Optional specification of a specific store to reference. |
HepMcParticleLink::HepMcParticleLink | ( | barcode_type | uid, |
uint32_t | eventIndex, | ||
PositionFlag | positionFlag, | ||
UniqueIDFlag | uniqueIDFlag, | ||
const EventContext & | ctx | ||
) |
Constructor.
uid | Unique ID of the target particle. 0 means a null link. |
eventIndex | Identifies the target GenEvent in a McEventCollection, as either the event number if isIndexEventPosition is IS_EVENTNUM, or the position in the container if isIndexEventPosition is IS_POSITION. 0 always means the first event in the collection. |
positionFlag | See eventIndex . |
ctx | Context of the store to reference. |
HepMcParticleLink::HepMcParticleLink | ( | const HepMC::ConstGenParticlePtr & | part, |
uint32_t | eventIndex, | ||
PositionFlag | positionFlag, | ||
IProxyDict * | sg = SG::CurrentEventStore::store() |
||
) |
Constructor.
p | Particle to reference. |
eventIndex | Identifies the target GenEvent in a McEventCollection, as either the event number if isIndexEventPosition is IS_EVENTNUM, or the position in the container if isIndexEventPosition is IS_POSITION. 0 always means the first event in the collection. |
positionFlag | See eventIndex . |
sg | Optional specification of a specific store to reference. |
Definition at line 143 of file HepMcParticleLink.cxx.
HepMcParticleLink::HepMcParticleLink | ( | const HepMC::ConstGenParticlePtr & | part, |
uint32_t | eventIndex, | ||
PositionFlag | positionFlag, | ||
const EventContext & | ctx | ||
) |
Constructor.
p | Particle to reference. |
eventIndex | Identifies the target GenEvent in a McEventCollection, as either the event number if isIndexEventPosition is IS_EVENTNUM, or the position in the container if isIndexEventPosition is IS_POSITION. 0 always means the first event in the collection. |
positionFlag | See eventIndex . |
ctx | Context of the store to reference. |
|
default |
Copy constructor.
|
defaultnoexcept |
Move constructor.
int HepMcParticleLink::barcode | ( | ) | const |
Return the barcode of the target particle.
0 for a null link. FIXME: return type.
Definition at line 318 of file HepMcParticleLink.cxx.
barcode_type HepMcParticleLink::compress | ( | ) | const |
Hash the 32 bit barcode and 16 bit eventindex into a 32bit int.
HepMC::ConstGenParticlePtr HepMcParticleLink::cptr | ( | ) | const |
Dereference.
Definition at line 177 of file HepMcParticleLink.cxx.
HepMcParticleLink::index_type HepMcParticleLink::eventIndex | ( | ) | const |
Return the event number of the referenced GenEvent.
0 means the first GenEvent in the collection.
Definition at line 345 of file HepMcParticleLink.cxx.
|
staticprivate |
Find the proxy for the target event collection.
sg | Target event store. May return nullptr if the collection is not found. |
Definition at line 516 of file HepMcParticleLink.cxx.
|
static |
Return the event number of the GenEvent at the specified position in the McEventCollection.
position | in the McEventCollection |
sg | Target event store. Returns -999 when position is larger than the McEventCollection size |
Definition at line 443 of file HepMcParticleLink.cxx.
HepMcParticleLink::index_type HepMcParticleLink::getEventPositionInCollection | ( | const IProxyDict * | sg | ) | const |
Return the position in the McEventCollection of the GenEvent pointed to by this HepMcParticleLink.
Return the position in the McEventCollection of the (first) GenEvent with a given event number.
sg | Target event store. FIXME - need to be able to flag when no event with the appropriate event_number was found. |
Definition at line 399 of file HepMcParticleLink.cxx.
|
static |
Return a vector of the positions in the McEventCollection of the GenEvent(s) with a given event number.
Return the position in the McEventCollection of the (first) GenEvent with a given event number.
index | the event number of the required GenEvent |
sg | Target event store. Returns a vector containing only ExtendedBarCode::UNDEFINED FIXME when no event with the appropriate event_number was found. (Multiple entries in the vector is technically a bug, but can't be fixed until the HepMC3 migration.) |
Definition at line 420 of file HepMcParticleLink.cxx.
|
staticprivate |
|
static |
Return a HepMcParticleLink pointing at the same particle, but in a different GenEvent.
particleLink | the current HepMcParticleLink |
eventIndex | the event number (unless zero) of the GenEvent which the redirected HepMcParticleLink should point at |
Definition at line 465 of file HepMcParticleLink.cxx.
EBC_SUPPRESSED_TRUTH HepMcParticleLink::getTruthSuppressionType | ( | ) | const |
Return whether the truth particle has been suppressed, as an enum.
char HepMcParticleLink::getTruthSuppressionTypeAsChar | ( | ) | const |
Return whether the truth particle has been suppressed, as a char ('a'..'b').
int HepMcParticleLink::id | ( | ) | const |
Return the id of the target particle.
Return the id of the referenced GenParticle.
0 for a null link.
Definition at line 291 of file HepMcParticleLink.cxx.
bool HepMcParticleLink::isValid | ( | ) | const |
Validity check.
Dereference and check for null.
bool HepMcParticleLink::linkIsNull | ( | ) | const |
return true if neither barcode nor id are valid
Definition at line 169 of file HepMcParticleLink.cxx.
HepMcParticleLink::operator bool | ( | ) | const |
Validity check.
Dereference and check for null.
HepMcParticleLink::operator HepMC::ConstGenParticlePtr | ( | ) | const |
Dereference.
bool HepMcParticleLink::operator! | ( | ) | const |
Validity check.
Dereference and check for null.
bool HepMcParticleLink::operator!= | ( | const HepMcParticleLink & | rhs | ) | const |
Inequality comparison.
const HepMC::GenParticle& HepMcParticleLink::operator* | ( | ) | const |
Dereference.
HepMC::ConstGenParticlePtr HepMcParticleLink::operator-> | ( | ) | const |
Dereference.
bool HepMcParticleLink::operator< | ( | const HepMcParticleLink & | rhs | ) | const |
Ordering comparison.
|
default |
Assignment.
|
default |
Move Assignment.
bool HepMcParticleLink::operator== | ( | const HepMcParticleLink & | rhs | ) | const |
Equality comparison.
|
staticprivate |
Look up the event collection we're targeting.
sg | Target event store. May return nullptr if the collection is not found. |
Definition at line 497 of file HepMcParticleLink.cxx.
|
inline |
void HepMcParticleLink::setExtendedBarCode | ( | const ExtendedBarCode & | extBarcode | ) |
void HepMcParticleLink::setTruthSuppressionType | ( | EBC_SUPPRESSED_TRUTH | truthSupp | ) |
Return whether the truth particle has been suppressed.
|
friend |
Output operator.
os | MsgStream to which to output. |
link | Link to dump. |
Definition at line 592 of file HepMcParticleLink.cxx.
|
friend |
Output operator.
os | Stream to which to output. |
link | Link to dump. |
Definition at line 579 of file HepMcParticleLink.cxx.
|
private |
Persistent part: barcode and location of target GenEvent.
Definition at line 680 of file HepMcParticleLink.h.
|
private |
Transient part. Pointer to the particle.
Definition at line 676 of file HepMcParticleLink.h.
|
private |
Pointer to the store containing the event.
Definition at line 668 of file HepMcParticleLink.h.