Simulation crashes when properties of the world are added

Hello everyone,
I recently started learning how to use GEANT4 and the first application I am trying to develop is rather simple: it consists in having a muon passing through two scintillators, using GEANT 4 v11.0.3.

I have managed to implement everything so far, including the scintillating properties and the muon gun. The code below works perfectly fine, but only if line 22 is commented.

Line 22 simply set the properties of the world, which consists of air. As you can see, the only property I have included is the index of refraction, in order to obtain the propagation of optical photon from the scintillators to the world. However, when this line is included in the code, the simulation freezes. At first I thought it was simply taking time to calculate the trajectories of the photons but even with a very low sicintillation yield (here set to 10 ph./MeV), it still freezes.

I looked in this forum to find a solution to that issue and found this but the problem found in this post is not connected to mine (my energy vector is built from low to high energy, ) and the OpNovice exemple does not seem to differ so significantly from mine to explain the reason why my application is freezing. I have tried to maybe simply define the air material by myself instead of simply extracting it with the nist manager but it doesn’t work either.

I would be very grateful if you could have a quick look at the code and tell me if there is something wrong. I feel like I am missing something completely obvious but can’t say what it is.

Thanks a lot :slight_smile:

I don’t think there’s anything obvious about implementing optical photon transport in GEANT4. It took me a while to find arrive at something that works. I’m including my detector construction class code here and highlighting what I think are the salient parts. I originally had the photon energy and refraction index vectors defined like you but I was told that wasn’t strictly correct.
I also added the SetSpline() method to end of my AddProperty() methods. This is sort of black-boxish for me but it seems to work.
det-contstruction.pdf (52.2 KB)

I hope this helps you out.

Hi Joe,

Thanks a lot for your reply. I had actually checked your code from the post I mentioned to see if I could maybe adapt it to my application. Except for the SetSpline method, I think our codes are quite similar. May I ask you on which version of GEANT4 you are running it? Because if I add SetSpline to my AddProperty line, it tells me that it can’t find it:

error: ‘G4MaterialPropertyVector’ {aka ‘class G4PhysicsFreeVector’} has no member named ‘SetSpline’;

It seem that in version 11, the SetSpline method has been removed. See release note here:

G4PhysicsVector, G4PhysicsTable, G4PhysicsFreeVector: removed obsolete methods SetSpline();

It looks like now, SetSpline is replaced by adding a boolean in the definition of any G4PhysicsFreeVector though.

A roll-back to GEANT4 v10.7, which allowed me to use the SetSpline method as specified in your code, did not solve my issue either.

I am currently using:

Geant4 version Name: geant4-10-07-patch-04 (9-September-2022)
Copyright : Geant4 Collaboration
References : NIM A 506 (2003), 250-303
: IEEE-TNS 53 (2006), 270-278
: NIM A 835 (2016), 186-225

So there is another difference with how I am running my code. Since I am actually interested in Cerenkov photons, I am actually suppressing Scintillation photons in my execution macro.

Macro file for TB1106

Can be run in batch, without graphic

or interactively: Idle> /control/execute TB1106-run.mac

Change the default number of workers (in multi-threading mode)

#/run/numberOfThreads 4

Initialize kernel


/process/optical/processActivation Cerenkov 1


/process/optical/processActivation Scintillation 0
#/process/optical/processActivation OpRayleigh 0
#/process/optical/processActivation OpMieHG 0
#/process/optical/processActivation OpWLS2 0
#/process/optical/processActivation OpWLS 0


/run/printProgress 1000
/control/verbose 2
/run/verbose 1
/event/verbose 0
/tracking/verbose 0

gamma 6 MeV to the direction (0.,-1.,0.)

/gun/particle gamma
/gun/energy 6 MeV

/run/beamOn 100000

Perhaps turning on attenuation in your scintillator volume might help to quench some of the out of control optical photon scattering/propagation that is slowing your code down to a crawl? I have an absorption vector in my detector construction and it’s activated for my H20 fiducial volume where most of my Cerenkov events are created.

not sure if I remember correctly, but you might need to define also ABSLENGTH in addition to RINDEX.
should be a quick test, let me know if that works

I want to thank you both because indeed, adding the attenuation/absorption length of the scintillators made my code work. I can now see some of my photons exiting my scintillators :slight_smile:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.