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.
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 fromint.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:
Of course, this conversion might not always be possible, in which case a
NoMatchingIDerror is raised.This could then also replace the converter
BiMapobjects, I think they are not the optimal. Especially thePythia2PDGIDBiMapis 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.