Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea: Generalize Particle ID Classes and Improve #427

Open
The-Ludwig opened this issue Oct 12, 2022 · 0 comments
Open

Idea: Generalize Particle ID Classes and Improve #427

The-Ludwig opened this issue Oct 12, 2022 · 0 comments

Comments

@The-Ludwig
Copy link
Contributor

The-Ludwig commented Oct 12, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant