Skip to content

Make user particle handler extensible #1443

@murnanedaniel

Description

@murnanedaniel

It is noted in the library that the ParticleHandler is not extensible currently:

def setupUserParticleHandler(self, part, kernel, DDG4):
"""Create the UserParticleHandler and configure it.
FIXME: this is not extensible at the moment

I am trying to add a more truth-heavy handler here: Geant4FullTruthParticleHandler, which then needs to be handled by the python handler. Currently my solution is here:

if self.userParticleHandler not in ["Geant4TCUserParticleHandler", "Geant4TVUserParticleHandler", "Geant4FullTruthParticleHandler"]:
      logger.error("unknown UserParticleHandler: %r" % self.userParticleHandler)
      exit(1)

    if self.userParticleHandler in ["Geant4TCUserParticleHandler", "Geant4FullTruthParticleHandler"]:
      user = DDG4.Action(kernel, "%s/UserParticleHandler" % self.userParticleHandler)
      try:
        user.TrackingVolume_Zmax = DDG4.tracker_region_zmax
        user.TrackingVolume_Rmax = DDG4.tracker_region_rmax
etc.

But this is clunky. I would be very happy to tweak the handler to be extensible, if someone could describe what is in mind for this?

I guess the particle handler could be defined as a config, e.g.

sim.part.userParticleHandler = {"handler": "Geant4TCUserParticleHandler", "user.TrackingVolume_Zmax": "DDG4.tracker_region_zmax", etc.}

Although this is still not completely extensible.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions