How to remove msc from EmPhysics_opt4

Hello Geant4 experts:

I am trying to simulate proton beam inject water with and without lateral scattering, and I would like to control the multiple Coulomb scattering (MCS) and nuclear scattering (NS) process. I use the G4EmStandardPhysics_option4 as the EM physics, but I want to remove the “msc” process assigned on G4Proton. Any idea how to implement this?

Thanks in advance.

Two ways :
1- after initialization : /process/inactivate msc
2- copy G4EmStandardPhysics_option4 in your application → MyEmStandardPhysics
and do not register Multiple Scattering

Attached, a macro for TestEm1, to be run interactively.

saluta.mac.txt (323 Bytes)

Thank you maire, it works. But still a little problem.

In my “init.mac” I have:

#### init.mac ######
# the initialization commands
/control/verbose 0
/run/verbose 1

# set number of threads
/run/numberOfThreads 4

# Initialize kernel
/run/initialize

# Load General Particle Source Set
/control/execute gps.mac

# Load Setting of visualization
/control/execute vis.mac

# set scoring
/control/execute score.mac
#/control/execute score2.mac

Then I do the running work in “run.in”:

#### run.in ###################
/gps/ene/mono 150 MeV

/process/inactivate msc proton
/process/inactivate hadElastic proton   # MCS off, NS off
/run/beamOn 100000
/score/dumpQuantityToFile doseBoxMesh primEdep  waterPrimEdep150MeV_MCSOFF_NSOFF.csv

/process/activate msc proton
/process/inactivate hadElastic proton   # MCS on, NS off
/run/beamOn 100000
/score/dumpQuantityToFile doseBoxMesh primEdep  waterPrimEdep150MeV_MCSON_NSOFF.csv

/process/activate msc proton
/process/activate hadElastic proton   # MCS on, NS on
/run/beamOn 100000
/score/dumpQuantityToFile doseBoxMesh primEdep  waterPrimEdep150MeV_MCSON_NSON.csv

If I directly execute the init.mac and run.in, then the program just crashed with “Segmentation fault (core dumped)”, I guess this is a memory error when referring to an empty or illegal pointer.

If I start the program with init.mac, and I do a run/beamOn manually on the terminal, then I execute the run.in, IT WORKS FINE!!

I don’t understand. Do you have any idea?

Hello,
My guess would be that doseBoxMesh (or something else entirely) is never ‘hit’ accident with "a run/beamOn’ and therefore you never notice a problem.

Maybe you are initializing something ‘correctly’ in your EndOfRunAction that should be moved to BeginOfRunAction?.

Also, it is almost impossible to debug something with just the statement “just crashed”. Please try to run your application with a debugger to get more insight into the issue.

Hello pico,
I use gdb to run the program, find that if I load score.mac and use /process/inactivate msc, then the program crashed with:

Thread 1 "G4Water" received signal SIGSEGV, Segmentation fault.
0x00007ffff0981a79 in G4ProcessManager::CreateGPILvectors() ()
   from /usr/local/lib/libG4processes.so

The content of score.mac is following:

# define scoring mesh
/score/create/boxMesh doseBoxMesh
/score/mesh/boxSize 10. 10. 15. cm
/score/mesh/nBin 1 1 3000
/score/mesh/translate/xyz 0. 0. 0. cm

### define scorer and filter ###
# total Ddep
/score/quantity/doseDeposit totalDdep Gy

# Done
/score/close doseBoxMesh

if I execute a ‘run/beamOn’ after execution of score.mac and before ‘/process/inactivate xxx’, then the crash does not happened.

Are there any inconsistent between Scoring method and process control?

** In my RunAction there is a filter definition in the constructor and the begin and end of RunAction are empty.

Sorry @Saluta,

I’m swamped with teaching. Since you got a workaround I place this down in my priority list. I’ll come back to it if this is still bothering you next week.

Cheers,

Hello Saluta,
Have your problem solved? Recently I encountered the same problem when using ‘/process/inactivate …’ and boxMesh Scoring at the same time. Also, I found it is OK for Geant4.10.07.p02, but it appeared when the same application transfered to Geant4.11.0.2.
Hope to hear from you, thank you in advance.