Different thickness

Hi everyone , I have to simulate a beam against a plate in different cases of 20 different thickness of the plate. Can i make a sort of loop with macros or in detector construction? Or I have to build different files with 20 different thickness in detector construction and compile and run evereyone divided from the others?
Thank you in advance

You can create a messenger, which you can see implemented in the run and event extended examples. The readme describes what is shown in each and the application developers guide shows this too.

1 Like

Expanding on what @ParticleTruthSeeker said: There are several ways I came up with to handle this:

  1. Write a messenger which allows you to change the geometry via macro commands, and run a macro loop. You’d need to write such a messenger for that yourself (look into the examples). This is a very “clean”, but involved solution.

  2. Write a C++ loop in DetectorConstruction and stack several slabs with varying thickness in X direction, then move the gun in X direction with a macro loop. This can be implemented fairly easily, but you have to be careful about scattering particles (false positives?) in your analysis step.

  3. Use a bash loop, and sed, awk or similar tools to change your DetectorConstruction source code, and run multiple compilations and simulations in the loop. I think this is also a clean solution. Also usually t_compile << t_sim, i.e. compile time is very small compared to runtime of a simulation, so the recompiling should take an negligible amount of time.

I prefer option 3 because of its simplicity, but your mileage might vary.

1 Like

Thank you so much, I’ll try these solutions .