AIDASoft / DD4hep

Detector Description Toolkit for High Energy Physics
http://dd4hep.cern.ch
GNU Lesser General Public License v3.0
47 stars 93 forks source link

Adding possibility to use G4ScoringMesh? #1261

Closed atolosadelgado closed 2 months ago

atolosadelgado commented 2 months ago

Dear experts,

The Geant4 Scoring mesh is a feature that can be very useful for quick checks, such as background studies. To enable it, one has to access to the G4ScoringManager pointer after the instantiation of G4(MT)RunManager, as shown here or as follows:

#include "G4ScoringManager.hh"
int main()
{
G4RunManager* runManager = new G4RunManager;
G4ScoringManager* scoringManager = G4ScoringManager::GetScoringManager();
…
}

Then new UI commands will appear, allowing to create and use meshes.

Question: would it be possible to add this feature to ddsim?

Thank you for your time.

Alvaro

MarkusFrankATcernch commented 2 months ago

Is it sufficient to only instantiate this manager? It should be simple to steer this instantiation with an option of the Geant4Kernel object. This I could easily implement.

atolosadelgado commented 2 months ago

I think it is enough to instantiate once after the run manager. I like the idea of making it optional, since it may affect the overall performance.

@MarkusFrankATcernch once you create a working branch, may I have some time to test it before merging it? Just in case I overlooked something...

MarkusFrankATcernch commented 2 months ago

@atolosadelgado Please see here in the HEAD: https://github.com/MarkusFrankATcernch/DD4hep You have to set:

import DDG4

g4 = DDG4.Geant4()
g4.kernel().HaveScoringManager = True
...
atolosadelgado commented 2 months ago

it works, thank you @MarkusFrankATcernch !

And thanks @andresailer for the piece of code to be added in the steering file!

def enable_score_mesh(kernel):
  kernel.HaveScoringManager = 1
  return None

SIM.physics.setupUserPhysics(enable_score_mesh)