ATLAS Offline Software
Loading...
Searching...
No Matches
HepMcParticleLink::ExtendedBarCode Class Reference

Persistent representation of a link. More...

#include <HepMcParticleLink.h>

Collaboration diagram for HepMcParticleLink::ExtendedBarCode:

Public Member Functions

 ExtendedBarCode ()
 Default constructor.
 ExtendedBarCode (barcode_type uid, index_type eventIndex, PositionFlag isIndexEventPosition=IS_EVENTNUM, UniqueIDFlag isUniqueIDBarcode=IS_ID)
 Constructor.
 ExtendedBarCode (const ExtendedBarCode &rhs)
 Copy constructor.
 ExtendedBarCode (ExtendedBarCode &&rhs) noexcept
 Move constructor.
ExtendedBarCodeoperator= (const ExtendedBarCode &rhs)
 Assignment.
ExtendedBarCodeoperator= (ExtendedBarCode &&rhs) noexcept
 Move Assignment.
barcode_type uid () const
 Unique ID of target variable (0 for a null link).
void uniqueID (barcode_type &id, barcode_type &barcode) const
 Return the GenParticle id/barcode.
void eventIndex (index_type &index, index_type &position) const
 Return the event index/position.
bool linkIsNull () const
 return true if neither barcode nor id are valid
EBC_SUPPRESSED_TRUTH getTruthSuppressionType () const
 Return whether the truth particle has been suppressed.
void setTruthSuppressionType (EBC_SUPPRESSED_TRUTH truthSupp)
 Return whether the truth particle has been suppressed.
char getTruthSuppressionTypeAsChar () const
 Return whether the truth particle has been suppressed, as a char ('a'..'b').
bool operator== (const ExtendedBarCode &rhs) const
 Equality test.
bool operator!= (const ExtendedBarCode &rhs) const
 Inequality test.
bool operator< (const ExtendedBarCode &rhs) const
 Ordering test.
void print (std::ostream &os) const
 Dump in textual format to a stream.
void print (MsgStream &os) const
 Dump in textual format to a MsgStream.
void makeIndex (index_type index, index_type position) const
 Change index from position to number.
void makeID (barcode_type ID, barcode_type barcode) const
 Change m_BC from barcode to ID.

Static Public Member Functions

static char truthSuppressionTypeAsChar (EBC_SUPPRESSED_TRUTH suppEnum)
 Translate truth suppression enum to a char ('a'..'b').
static EBC_SUPPRESSED_TRUTH truthSuppressionTypeFromChar (char suppChar)
 Translate truth suppression char ('a'..'b') to an enum.
static int compareIndex (const HepMcParticleLink &lhs, const HepMcParticleLink &rhs)
 Compare the event index part of two links.
static int compareUniqueID (const HepMcParticleLink &lhs, const HepMcParticleLink &rhs)
 Compare the unique ID part of two links.

Static Public Attributes

static constexpr index_type UNDEFINED = ~static_cast<index_type>(0)
 All 1's. Used to represent an undefined index/position.
static constexpr barcode_type UNDEFINEDBC = ~static_cast<barcode_type>(0)

Private Member Functions

void setIndex (index_type idx, PositionFlag positionFlag)
 Initialize the event index part of the link.
void setUniqueID (barcode_type uid, UniqueIDFlag barcodeFlag)
 Initialize the unique identifier part of the link.

Private Attributes

std::atomic< barcode_typem_BC
 Unique ID of the target particle. 0 means a null link.
std::atomic< index_typem_evtIndex {0}
 Identifies the target GenEvent within the event collection.
EBC_SUPPRESSED_TRUTH m_truthSupp {EBC_UNSUPPRESSED}
 Indicates whether the truth particle has been suppressed.

Static Private Attributes

static constexpr index_type POSITION_MASK = UNDEFINED ^ (UNDEFINED>>1)
 Flag marking that an index refers to an event position.
static constexpr barcode_type BARCODE_MASK = UNDEFINEDBC ^ (UNDEFINEDBC>>1)
 Flag marking that an unique ID refers to a barcode.

Detailed Description

Persistent representation of a link.

See HepMcParticleLink for details.

Definition at line 93 of file HepMcParticleLink.h.

Constructor & Destructor Documentation

◆ ExtendedBarCode() [1/4]

HepMcParticleLink::ExtendedBarCode::ExtendedBarCode ( )

Default constructor.

Makes a null link (unique ID 0).

◆ ExtendedBarCode() [2/4]

HepMcParticleLink::ExtendedBarCode::ExtendedBarCode ( barcode_type uid,
index_type eventIndex,
PositionFlag isIndexEventPosition = IS_EVENTNUM,
UniqueIDFlag isUniqueIDBarcode = IS_ID )

Constructor.

Parameters
uidUnique ID of target particle.
eventIndexIdentifies 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.
isIndexEventPositionSee eventIndex.

◆ ExtendedBarCode() [3/4]

HepMcParticleLink::ExtendedBarCode::ExtendedBarCode ( const ExtendedBarCode & rhs)

Copy constructor.

(Can't be defaulted due to the atomic member.)

◆ ExtendedBarCode() [4/4]

HepMcParticleLink::ExtendedBarCode::ExtendedBarCode ( ExtendedBarCode && rhs)
noexcept

Move constructor.

(Can't be defaulted due to the atomic member.)

Member Function Documentation

◆ compareIndex()

int HepMcParticleLink::ExtendedBarCode::compareIndex ( const HepMcParticleLink & lhs,
const HepMcParticleLink & rhs )
static

Compare the event index part of two links.

Parameters
lhsFirst link to compare.
rhsSecond link to compare.
Returns
-1, 0, or 1, depending on the result of the comparison.

The event index part of the link can be represented as either an event number or the position within the container. If necessary, the links will be normalized so that they both refer to an event number.

◆ compareUniqueID()

int HepMcParticleLink::ExtendedBarCode::compareUniqueID ( const HepMcParticleLink & lhs,
const HepMcParticleLink & rhs )
static

Compare the unique ID part of two links.

Parameters
lhsFirst link to compare.
rhsSecond link to compare.
Returns
-1, 0, or 1, depending on the result of the comparison.

The unique ID part of the link can be represented as either a barcode or the id. If necessary, the links will be normalized so that they both refer to an id.

◆ eventIndex()

void HepMcParticleLink::ExtendedBarCode::eventIndex ( index_type & index,
index_type & position ) const

Return the event index/position.

Parameters
index[out]Event index (number), or UNDEFINED.
position[out]Event position, or UNDEFINED.

The GenEvent within the McEventCollection is identified either by the GenEvent number or by the position within the collection. This method will return this by setting either index or position; the other one is set to UNDEFINED.

◆ getTruthSuppressionType()

EBC_SUPPRESSED_TRUTH HepMcParticleLink::ExtendedBarCode::getTruthSuppressionType ( ) const
inline

Return whether the truth particle has been suppressed.

Definition at line 182 of file HepMcParticleLink.h.

182{ return m_truthSupp; }

◆ getTruthSuppressionTypeAsChar()

char HepMcParticleLink::ExtendedBarCode::getTruthSuppressionTypeAsChar ( ) const

Return whether the truth particle has been suppressed, as a char ('a'..'b').

◆ linkIsNull()

bool HepMcParticleLink::ExtendedBarCode::linkIsNull ( ) const

return true if neither barcode nor id are valid

◆ makeID()

void HepMcParticleLink::ExtendedBarCode::makeID ( barcode_type ID,
barcode_type barcode ) const

Change m_BC from barcode to ID.

Parameters
IDGenParticle::id value to set.
barcodeexisting barcode value.

If the link is currently referencing a GenParticle with barcode, update it so that it instead references the GenParticle with id value ID.

This may be called concurrently, as long as all such concurrent calls have the same arguments.

◆ makeIndex()

void HepMcParticleLink::ExtendedBarCode::makeIndex ( index_type index,
index_type position ) const

Change index from position to number.

Parameters
indexEvent number to set.
positionExisting event position.

If the link is currently referencing the GenEvent at position, update it so that it instead references the GenEvent with number index.

This may be called concurrently, as long as all such concurrent calls have the same arguments.

◆ operator!=()

bool HepMcParticleLink::ExtendedBarCode::operator!= ( const ExtendedBarCode & rhs) const

Inequality test.

Be aware: if one EBC holds the target GenEvent by number and the other by position, then this will always return true, even if they reference the same GenEvent. To avoid this, use HepMcParticleLink::operator=.

◆ operator<()

bool HepMcParticleLink::ExtendedBarCode::operator< ( const ExtendedBarCode & rhs) const

Ordering test.

Be aware: if one EBC holds the target GenEvent by number and the other by position, then this will not work as expected. To avoid this, use HepMcParticleLink::operator=.

◆ operator=() [1/2]

ExtendedBarCode & HepMcParticleLink::ExtendedBarCode::operator= ( const ExtendedBarCode & rhs)

Assignment.

(Can't be defaulted due to the atomic member.)

◆ operator=() [2/2]

ExtendedBarCode & HepMcParticleLink::ExtendedBarCode::operator= ( ExtendedBarCode && rhs)
noexcept

Move Assignment.

(Can't be defaulted due to the atomic member.)

◆ operator==()

bool HepMcParticleLink::ExtendedBarCode::operator== ( const ExtendedBarCode & rhs) const

Equality test.

Be aware: if one EBC holds the target GenEvent by number and the other by position, then this will always return false, even if they reference the same GenEvent. To avoid this, use HepMcParticleLink::operator=.

◆ print() [1/2]

void HepMcParticleLink::ExtendedBarCode::print ( MsgStream & os) const

Dump in textual format to a MsgStream.

Definition at line 119 of file HepMcParticleLink.cxx.

120{
121 std::ostringstream ss;
122 print (ss);
123 os << ss.str();
124}
static Double_t ss

◆ print() [2/2]

void HepMcParticleLink::ExtendedBarCode::print ( std::ostream & os) const

Dump in textual format to a stream.

Definition at line 88 of file HepMcParticleLink.cxx.

89{
90 os << "Event index " ;
91 index_type event_number, position;
92 eventIndex (event_number, position);
93 if (position != UNDEFINED) {
94 os << position << " (position in collection) ";
95 }
96 else {
97 os << event_number << " (event number) ";
98 }
99 os << ", Unique ID " ;
100 barcode_type particle_id, particle_barcode;
101 uniqueID (particle_id, particle_barcode);
102 if (particle_barcode == 0 && particle_id == 0) {
103 os << " 0 (id/barcode) ";
104 }
105 else if (particle_barcode != UNDEFINEDBC) {
106 os << particle_barcode << " (barcode) ";
107 }
108 else {
109 os << particle_id << " (id) ";
110 }
111 os << ", McEventCollection "
113}

◆ setIndex()

void HepMcParticleLink::ExtendedBarCode::setIndex ( index_type idx,
PositionFlag positionFlag )
private

Initialize the event index part of the link.

Parameters
idxThe index or position.
positionFlagIf IS_POSITION, idx represents a position in the collection; otherwise, it represents an event number.

◆ setTruthSuppressionType()

void HepMcParticleLink::ExtendedBarCode::setTruthSuppressionType ( EBC_SUPPRESSED_TRUTH truthSupp)
inline

Return whether the truth particle has been suppressed.

Definition at line 188 of file HepMcParticleLink.h.

188{ m_truthSupp = truthSupp; }

◆ setUniqueID()

void HepMcParticleLink::ExtendedBarCode::setUniqueID ( barcode_type uid,
UniqueIDFlag barcodeFlag )
private

Initialize the unique identifier part of the link.

Parameters
uidThe id or barcode.
barcodeFlagIf IS_BARCODE, uid represents a GenParticle barcode (deprecated); otherwise, it represents a GenParticle::id().

◆ truthSuppressionTypeAsChar()

char HepMcParticleLink::ExtendedBarCode::truthSuppressionTypeAsChar ( EBC_SUPPRESSED_TRUTH suppEnum)
static

Translate truth suppression enum to a char ('a'..'b').

Definition at line 59 of file HepMcParticleLink.cxx.

60{
61 static const char codes[EBC_NSUPP] = {'a', 'b'};
62 assert (suppEnum < EBC_NSUPP);
63 return codes[suppEnum];
64}
@ EBC_NSUPP
dict codes
helper to get a human-readable string
Definition ExitCodes.py:49

◆ truthSuppressionTypeFromChar()

EBC_SUPPRESSED_TRUTH HepMcParticleLink::ExtendedBarCode::truthSuppressionTypeFromChar ( char suppChar)
static

Translate truth suppression char ('a'..'b') to an enum.

Definition at line 71 of file HepMcParticleLink.cxx.

72{
73 switch (suppChar) {
74 case 'a': return EBC_UNSUPPRESSED;
75 case 'b': return EBC_PU_SUPPRESSED;
76 default:
77 // Should not reach this
78 MsgStream log (Athena::getMessageSvc(), "HepMcParticleLink");
79 log << MSG::ERROR << " Wrong truth Suppression Char (" << std::string(&suppChar,1) << ") set in HepMcParticleLink ExtendedBarCode object !!!" << endmsg;
80 }
81 return EBC_UNSUPPRESSED;
82}
#define endmsg
@ EBC_PU_SUPPRESSED
@ EBC_UNSUPPRESSED
IMessageSvc * getMessageSvc(bool quiet=false)

◆ uid()

barcode_type HepMcParticleLink::ExtendedBarCode::uid ( ) const

Unique ID of target variable (0 for a null link).

◆ uniqueID()

void HepMcParticleLink::ExtendedBarCode::uniqueID ( barcode_type & id,
barcode_type & barcode ) const

Return the GenParticle id/barcode.

Parameters
id[out]GenParticle::id, or UNDEFINEDBC.
barcode[out]barcode (deprecated), or UNDEFINEDBC.

The GenParticle within the GenEvent is identified either by the GenParticle::id or the barcode. This method will return this by setting either id or barcode; the other one is set to UNDEFINEDBC.

Member Data Documentation

◆ BARCODE_MASK

barcode_type HepMcParticleLink::ExtendedBarCode::BARCODE_MASK = UNDEFINEDBC ^ (UNDEFINEDBC>>1)
staticconstexprprivate

Flag marking that an unique ID refers to a barcode.

Definition at line 320 of file HepMcParticleLink.h.

◆ m_BC

std::atomic<barcode_type> HepMcParticleLink::ExtendedBarCode::m_BC
mutableprivate

Unique ID of the target particle. 0 means a null link.

Definition at line 341 of file HepMcParticleLink.h.

◆ m_evtIndex

std::atomic<index_type> HepMcParticleLink::ExtendedBarCode::m_evtIndex {0}
mutableprivate

Identifies the target GenEvent within the event collection.

If the high bit is set, then this (with the high bit clear) is a position within the collection; otherwise, it is the target GenEvent number.

Definition at line 347 of file HepMcParticleLink.h.

347{0};

◆ m_truthSupp

EBC_SUPPRESSED_TRUTH HepMcParticleLink::ExtendedBarCode::m_truthSupp {EBC_UNSUPPRESSED}
private

Indicates whether the truth particle has been suppressed.

Definition at line 350 of file HepMcParticleLink.h.

◆ POSITION_MASK

index_type HepMcParticleLink::ExtendedBarCode::POSITION_MASK = UNDEFINED ^ (UNDEFINED>>1)
staticconstexprprivate

Flag marking that an index refers to an event position.

Definition at line 317 of file HepMcParticleLink.h.

◆ UNDEFINED

index_type HepMcParticleLink::ExtendedBarCode::UNDEFINED = ~static_cast<index_type>(0)
staticconstexpr

All 1's. Used to represent an undefined index/position.

Definition at line 96 of file HepMcParticleLink.h.

◆ UNDEFINEDBC

barcode_type HepMcParticleLink::ExtendedBarCode::UNDEFINEDBC = ~static_cast<barcode_type>(0)
staticconstexpr

Definition at line 97 of file HepMcParticleLink.h.


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