AIDASoft / DD4hep

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

turning on cerenkov radiation #959

Closed saraheno closed 2 years ago

saraheno commented 2 years ago

Hi, This is Sarah Eno, working on dual readout calorimetry. We have actually received some funding, so now we have to decide whether to use the plain GEANT or dd4hep for comparison with our test beam. I am trying to see if I can get my old dd4hep code running, but I see the method to turn on cerenkov radiation has changed since I asked with https://github.com/AIDASoft/DD4hep/issues/811

If I look at the bottom of DDG4/python/DDSim/Helper/Physics.py, I see a function that looks like it is designed to do this now, so one doesn't have to change the code in this file and recompile? But the documentation in the file is terse enough that I do not know where/how to call that function? Can you point me to an example?

Best Sarah Eno

andresailer commented 2 years ago

Hi Sarah, Welcome back! :) Exactly you can now use your own ddsim steering file to enable cerenkov, or other physics plugins.

https://github.com/AIDASoft/DD4hep/blob/30e35fc74c0ec2b0e6fe52ea020cd70bc3ecfbe9/DDG4/python/DDSim/Helper/Physics.py#L147-L164

If you don't have a ddsim steering file yet, create one with ddsim --dumpSteeringFile, Then in this file you can just add the "Example" from the linked code above in this message

def setupCerenkov(kernel):
        from DDG4 import PhysicsList
        seq = kernel.physicsList()
        cerenkov = PhysicsList(kernel, 'Geant4CerenkovPhysics/CerenkovPhys')
        cerenkov.MaxNumPhotonsPerStep = 10
        cerenkov.MaxBetaChangePerStep = 10.0
        cerenkov.TrackSecondariesFirst = True
        cerenkov.VerboseLevel = 2
        cerenkov.enableUI()
        return None

SIM.physics.setupUserPhysics(setupCerenkov)

So, in the steering file, one needs to define a function to setup a specific plugin (e.g., Geant4CerenkovPhysics), and then tell ddsim to call this setupCerenkovfunction when setting up the rest of the physics by calling SIM.physics.setupUpserPhysics(setupCerenkov) in the steeringFile.

saraheno commented 2 years ago

Thanks Andre. This is useful. However, I think I may need a little more help. I am simulating a single bar of PbWO4. My code is at: https://github.com/saraheno/SingleDualCrystal. My steering file is in the compact subdirectory. I run it with

ddsim --steeringFile SCEPCALsteering.py --compact ./DRSingleCrystal.xml --runType batch --part.userParticleHandler='' -G --gun.direction "1 1 0.1" --gun.energy "10*GeV" --gun.particle="e-" --gun.distribution=uniform -N 5 -O out.root

I have a custom SDAction which is found in the src subdirectory DualCrystalCalorimeterSDAction.cpp

but it does not seem to receive any optical photons in this SDAction. are optical photons not allowed in this? If not, how to get access to them? I did look at the example OpticalSurfaces but could not see where the photons were accessed...

andresailer commented 2 years ago

The example was incomplete, and missed another plugin needed for the photons. cf. https://github.com/AIDASoft/DD4hep/issues/811 and references therein

Please see the changes in https://github.com/AIDASoft/DD4hep/pull/961 and adapt accordingly.

saraheno commented 2 years ago

Thanks Andre. When I click on your 961 link, I see the screen grab below. It is very terse, and I cannot figure out from it what to do? ddddd

andresailer commented 2 years ago

Click on "Files changed" to see the changes.