Skip to content

Idea: Generalize Particle ID Classes and Improve  #427

@The-Ludwig

Description

@The-Ludwig

This idea came up when I worked on implementing Corsika7 IDs (PR #426).

Right now, every MC Particle ID class (PDGID, Geant3ID, PythiaID) is independent from each other, while being very similar in the sense that they inherit from int.
I think it might be useful to define some kind of common behavior of the particle IDs, to streamline the use of other particle IDs, something like:

from abc import ABC, abstractmethod

class ForeignParticleID(ABC, int):
    @abstractmethod
    def to_pdgid(self) -> PDGID:
        pass
    
    @abstractmethod
    def from_pdgid(cls: Self, pdgid: PDGID) -> Self:
        pass

Of course, this conversion might not always be possible, in which case a NoMatchingID error is raised.

This could then also replace the converter BiMap objects, I think they are not the optimal. Especially the Pythia2PDGIDBiMap is funny, since PythiaID and PDGID are the same, if existing. There should be converters which can be customly defined, not relying on a csv file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions