ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
ActsFatras::Barcode Class Reference

Particle identifier that encodes additional event information. More...

#include <ActsFatras/EventData/Barcode.hpp>

Public Types

using GenerationId = std::uint8_t
using ParticleId = std::uint32_t
using PrimaryVertexId = std::uint16_t
using SecondaryVertexId = std::uint16_t
using SubParticleId = std::uint32_t

Public Member Functions

constexpr Barcode ()=default
 Empty barcode.
constexpr Barcode (Barcode &&)=default
 Move constructor.
constexpr Barcode (const Barcode &)=default
 Copy constructor.
constexpr std::vector< std::uint32_t > asVector () const
 Export barcode as vector.
constexpr GenerationId generation () const
 Return the generation identifier.
std::size_t hash () const
 Get hash of the barcode.
constexpr bool isValid () const
Barcode makeDescendant (SubParticleId sub=0u) const
 Construct a new barcode representing a descendant particle.
Barcodeoperator= (Barcode &&)=default
 Move assignment operator.
Barcodeoperator= (const Barcode &)=default
 Copy assignment operator.
bool operator== (const Barcode &) const =default
 Compare two barcodes.
constexpr ParticleId particle () const
 Return the particle identifier.
constexpr SubParticleId subParticle () const
 Return the sub-particle identifier.
constexpr Barcode vertexId () const
 Reduce the barcode to the vertex identifier.
constexpr PrimaryVertexId vertexPrimary () const
 Return the primary vertex identifier.
constexpr SecondaryVertexId vertexSecondary () const
 Return the secondary vertex identifier.
constexpr Barcode withData (std::span< std::uint32_t > data)
 Create a new barcode from a vector.
constexpr Barcode withGeneration (GenerationId id) const
 Create a new barcode with a different generation identifier.
constexpr Barcode withoutSubparticle () const
 Reduce the barcode to the particle identifier.
constexpr Barcode withParticle (ParticleId id) const
 Create a new barcode with a different particle identifier.
constexpr Barcode withSubParticle (SubParticleId id) const
 Create a new barcode with a different sub-particle identifier.
constexpr Barcode withVertexPrimary (PrimaryVertexId id) const
 Create a new barcode with a different primary vertex identifier.
constexpr Barcode withVertexSecondary (SecondaryVertexId id) const
 Create a new barcode with a different secondary vertex identifier.

Static Public Member Functions

static constexpr Barcode Invalid ()
static constexpr bool isValid (const Barcode &b)
 Check validity of the barcode.

Detailed Description

Particle identifier that encodes additional event information.

The barcode has to fulfill two separate requirements: be able to act as unique identifier for particles within an event and to encode details on the event structure for fast lookup. Since we only care about tracking here, we need to support two scenarios:

  • Identify which primary/secondary vertex particles belong to. No information on intermediate/unstable/invisible particles needs to be retained. This information is already available in the underlying generator event and should not be duplicated.
  • If (visible) particles convert, decay, or interact with the detector, we need to be able to identify the initial (primary) particle. Typical examples are pion nuclear interactions or electron/gamma conversions.

The vertex information is encoded as two numbers that define the primary and secondary vertex. The primary vertex must be non-zero. Particles with a zero secondary vertex originate directly from the primary vertex.

Within one vertex (primary+secondary) each particle is identified by a particle, generation, and sub-particle number. Particles originating from the vertex must have zero generation and zero sub-particle number; a consequence is that only non-zero generation can have non-zero sub-particle numbers. A non-zero generation indicates that the particle is a descendant of the original particle, e.g. from interactions or decay, while the sub-particle number identifies the descendant particle.

With this encoding, non-primary particles and their primary parent can be easily identified at the expense of not storing the exact decay history.

A barcode with all elements set to zero (the default value) is an invalid value that can be used e.g. to mark missing or unknown particles.

Example

A particle generated in a primary interaction might have the barcode

2|0|14|0|0 -> vertex=2 (primary), particle=14, generation=0, sub=0

A simulation module might generate an interaction and create two new particles. These are descendants of the initial particle and the simulation module can generate the new barcodes directly by increasing the generation number and choosing sub-particle identifiers:

2|0|14|1|0 -> vertex=2 (primary), particle=14, generation=1, sub=0
2|0|14|1|1 -> vertex=2 (primary), particle=14, generation=1, sub=1

If these secondary particles generate further tertiary particles the barcode would be e.g.

2|0|14|2|0 -> vertex=2 (primary), particle=14, generation=2, sub=0

Possible issues

The hierarchical nature of the barcode allows barcode creation without a central service. Since the full history is not stored, generated barcodes for higher-generation particles can overlap when generated by independent interactions. Assuming an initial primary particle with barcode

3|4|5|0|0 -> particle=5

a first interaction might create a secondary particle by increasing the generation number (without destroying the initial particle)

3|4|5|1|0 -> particle=5, generation+=1, first sub-particle

The initial particle gets simulated further and at another step a second interaction also creates a new particle. Since it knows nothing about the previously created particle (no central service), it will generate

3|4|5|1|0 -> particle=5, generation+=1, first sub-particle

which is identical to the previously create barcode. These cases can be easily solved by renumbering the sub-particle identifier within each generation to contain unique values. However, this can only be done when all particles are known.

Member Typedef Documentation

◆ GenerationId

using ActsFatras::Barcode::GenerationId = std::uint8_t

◆ ParticleId

using ActsFatras::Barcode::ParticleId = std::uint32_t

◆ PrimaryVertexId

using ActsFatras::Barcode::PrimaryVertexId = std::uint16_t

◆ SecondaryVertexId

◆ SubParticleId

using ActsFatras::Barcode::SubParticleId = std::uint32_t

Constructor & Destructor Documentation

◆ Barcode() [1/3]

ActsFatras::Barcode::Barcode ( )
constexprdefault

Empty barcode.

◆ Barcode() [2/3]

ActsFatras::Barcode::Barcode ( const Barcode & )
constexprdefault

Copy constructor.

◆ Barcode() [3/3]

ActsFatras::Barcode::Barcode ( Barcode && )
constexprdefault

Move constructor.

Member Function Documentation

◆ asVector()

std::vector< std::uint32_t > ActsFatras::Barcode::asVector ( ) const
constexpr

Export barcode as vector.

◆ generation()

GenerationId ActsFatras::Barcode::generation ( ) const
constexpr

Return the generation identifier.

Returns
The generation identifier value

◆ hash()

std::size_t ActsFatras::Barcode::hash ( ) const

Get hash of the barcode.

◆ Invalid()

constexpr Barcode ActsFatras::Barcode::Invalid ( )
staticconstexpr

◆ isValid() [1/2]

bool ActsFatras::Barcode::isValid ( ) const
constexpr

◆ isValid() [2/2]

constexpr bool ActsFatras::Barcode::isValid ( const Barcode & b)
staticconstexpr

Check validity of the barcode.

◆ makeDescendant()

Barcode ActsFatras::Barcode::makeDescendant ( SubParticleId sub = 0u) const

Construct a new barcode representing a descendant particle.

Parameters
subsub-particle index of the new barcode.
Returns
New barcode with increased generation and specified sub-particle index

◆ operator=() [1/2]

Barcode & ActsFatras::Barcode::operator= ( Barcode && )
default

Move assignment operator.

Returns
Reference to this barcode after moving

◆ operator=() [2/2]

Barcode & ActsFatras::Barcode::operator= ( const Barcode & )
default

Copy assignment operator.

Returns
Reference to this barcode after copying

◆ operator==()

bool ActsFatras::Barcode::operator== ( const Barcode & ) const
default

Compare two barcodes.

◆ particle()

ParticleId ActsFatras::Barcode::particle ( ) const
constexpr

Return the particle identifier.

Returns
The particle identifier value

◆ subParticle()

SubParticleId ActsFatras::Barcode::subParticle ( ) const
constexpr

Return the sub-particle identifier.

Returns
The sub-particle identifier value

◆ vertexId()

Barcode ActsFatras::Barcode::vertexId ( ) const
constexpr

Reduce the barcode to the vertex identifier.

Returns
Barcode containing only vertex and generation information

◆ vertexPrimary()

PrimaryVertexId ActsFatras::Barcode::vertexPrimary ( ) const
constexpr

Return the primary vertex identifier.

Returns
The primary vertex identifier value

◆ vertexSecondary()

SecondaryVertexId ActsFatras::Barcode::vertexSecondary ( ) const
constexpr

Return the secondary vertex identifier.

Returns
The secondary vertex identifier value

◆ withData()

Barcode ActsFatras::Barcode::withData ( std::span< std::uint32_t > data)
nodiscardconstexpr

Create a new barcode from a vector.

Parameters
dataVector containing exactly 5 elements
Returns
New barcode with data from the vector

◆ withGeneration()

Barcode ActsFatras::Barcode::withGeneration ( GenerationId id) const
nodiscardconstexpr

Create a new barcode with a different generation identifier.

Parameters
idGeneration identifier to set
Returns
New barcode with modified generation identifier

◆ withoutSubparticle()

Barcode ActsFatras::Barcode::withoutSubparticle ( ) const
constexpr

Reduce the barcode to the particle identifier.

◆ withParticle()

Barcode ActsFatras::Barcode::withParticle ( ParticleId id) const
nodiscardconstexpr

Create a new barcode with a different particle identifier.

Parameters
idParticle identifier to set
Returns
New barcode with modified particle identifier

◆ withSubParticle()

Barcode ActsFatras::Barcode::withSubParticle ( SubParticleId id) const
nodiscardconstexpr

Create a new barcode with a different sub-particle identifier.

Parameters
idSub-particle identifier to set
Returns
New barcode with modified sub-particle identifier

◆ withVertexPrimary()

Barcode ActsFatras::Barcode::withVertexPrimary ( PrimaryVertexId id) const
nodiscardconstexpr

Create a new barcode with a different primary vertex identifier.

Parameters
idPrimary vertex identifier to set
Returns
New barcode with modified primary vertex identifier

◆ withVertexSecondary()

Barcode ActsFatras::Barcode::withVertexSecondary ( SecondaryVertexId id) const
nodiscardconstexpr

Create a new barcode with a different secondary vertex identifier.

Parameters
idSecondary vertex identifier to set
Returns
New barcode with modified secondary vertex identifier