-
Notifications
You must be signed in to change notification settings - Fork 26
Description
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.