ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
HepMcParticleLink::ExtendedBarCode Class Reference

Persistent representation of a link. More...

#include <HepMcParticleLink.h>

Collaboration diagram for HepMcParticleLink::ExtendedBarCode:

Public Member Functions

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

Static Public Member Functions

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

Static Public Attributes

constexpr static index_type UNDEFINED = ~static_cast<index_type>(0)
 All 1's. Used to represent an undefined index/position. More...
 
constexpr static 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. More...
 
void setUniqueID (barcode_type uid, UniqueIDFlag barcodeFlag)
 Initialize the unique identifier part of the link. More...
 

Private Attributes

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

Static Private Attributes

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

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()

static 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()

static 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!=()

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 }

◆ 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 }

◆ 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 }

◆ 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

constexpr static 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.

◆ 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

constexpr static 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

constexpr static 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

constexpr static 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:
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
EBC_NSUPP
@ EBC_NSUPP
Definition: MagicNumbers.h:30
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
python.ExitCodes.codes
dictionary codes
helper to get a human-readable string
Definition: ExitCodes.py:49
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
EBC_PU_SUPPRESSED
@ EBC_PU_SUPPRESSED
Definition: MagicNumbers.h:29
EBC_UNSUPPRESSED
@ EBC_UNSUPPRESSED
Definition: MagicNumbers.h:28
index_type
unsigned int index_type
Definition: FPGATrackSimSGToRawHitsTool.h:37