A general purpose Geant4-based application that requires no knowledge of C++

Hi, Is it possible to make a general purpose Geant4 based application / computer program able to do simulations in medical physics, particle physics, nuclear physics, space science and so on that doesn´t require a posterior knowledge / coding (after the creation of this application) of C++?; In other words, is it possible to transform all the Geant4 code into a single, fully interactive, executable computer program (with an interactive user interface and all the necessary buttons and menus)?. If so, how long would it take to do something like that?; If it’s not possible, what would the reasons be?. What would be the advantages and disadvantages of such an application?. Thanks

This sounds like a really excellent topic for you to research yourself. What programming languages are used in scientific computing? Why? What would you need to develop instead of a programming language to provide the same level of flexibility?

2 Likes

Thanks for your reply. Regarding your questions:

  1. What programming languages are used in scientific computing?, Answer: I only know C++; On the other hand, I read on the internet that programming languages used in scientific computing are: Python, R, Fortran, C / C++, Julia and Matlab.

    2.Why?, Answer: I read the following on internet:
    a. Pyhton: I t has an easy to read and simple syntax; It has a huge ecosystem of specialized scientific libraries

    b. R: Initially, this was used by statisticians and scientists to get statistical models

    c. Fortran: high performance for classical numerical computing; it was the first programming language designed specifically engineers and scientists.

    d. C / C++: C++ can create almost any type of program / application. It is widely used in scientific computing due to its high performance; C++ is a very versatile language that can be useful for small projects as well as enormous applications / programs.

    e. Julia: It’s used in scientific computing because it combines the ease of use of Python / R with the speed of C / C++

    f. Matlab: It’s a software that can do numerical calculations, data analysis and information visualization.

3.What would you need to develop instead of a programming language to provide the same level of flexibility?, Answer: I just wanted to know if it´s currently possible to create / produce a single Geant4 executable file that is a a fully interactive program (with a Geant4 User Interface) and that includes all the Geant4 C++ code; but, on the condition that after creating this executable file there is no need to program / code in C++; I think there is currently an example of this type of application I´m referring to, probably GAMOS (Geant4 based Architecture for Medicine Oriented Simulations), but I´m not sure if it´s a general purpose Geant4 based application. Thanks

In short, this is always going to be a “yes, but..” answer. I think that’s what @mkelsey is getting at with

What would you need to develop instead of a programming language to provide the same level of flexibility?

Ok, thanks for your reply. I would like to see a future Geant4 version / release that contains everything (all the physics and all the C++ programming) in a single executable file (.exe file), In what year could a Geant4 release like this be released?; I would also like a release like this to be released because it would make Geant4 much easier to use because of with just one Geant4 executable file we could do whatever we want and it would no longer be necessary to learn C++. I think it would be a good idea to do something like that.

  1. Please read the Physics section of the Application Developers’ Guide to see all of the different options and physics lists that are possible, including all of the C++ based customization that is possible. Which physics list would you recommend be forced on everyone, and why?

  2. The geometry could be done by forcing everyone to use GDML. That in turn would require that all users install XercesC on their system, along with Geant4.

  3. Which primary generator would you propose to use? GPS? That’s fine, but it doesn’t provide all of the generality of writing your own source. If a user needs a Mei & Hime cosmogenic distribution, would you propose that we include that code in your “single executable?” What about users who need to use something like Genie or Marley to generate neutrino events?

  4. How would you propose supporting the experiment-specific digitization (detector response) code in your “single executable”?

  5. How would you handle producing output data files? There are macro commands to support scorers, but how would you propose creating arbitrary column-based N-tuples for output? Would you develop a new Messenger layer for G4analysis?

I would encourage you to make a fork of the Geant4 repository, and see how far you can get developing something like this. You might also want to do some in depth study of existing utilities like TOPAS and GAMOS, to see what they offer and how it works.

3 Likes

You cannot simulate everything at the same time with three bodies let alone the entirety of those disciplines at the same time. At some point you would have to make some compromise for ease of use which is simply inescapable. And who or what would choose where the compromises are?

Even on a more abstract level you listed no less than 7 different languages, 6 of which have claimed, at some point to be the absolute most generalizable. Why are there so many of those?

2 Likes

I am not sure if I fully understood the topic here. But, from what I got, at least I go with @bmorgan and @jrellin: it’s always a “yes, but…” since you always have to make some trade-offs regarding outcomes and “computer power”. Comprising the whole Geant4 capabilities in a single executable is crazy.

But, regarding the “doesn´t require a posterior knowledge / coding (after the creation of this application) of C++” part, as @mkelsey mentioned, have you heard about TOPAS MC [https://www.topasmc.org/\\]? It is a Geant4-based toolkit that is somehow easier to implement for beginner users, and it doesn’t require C++ knowledge (to some extent).

In our group, we had, a few years ago, a summer internship project to develop a Graphical User Interface to automate the usage of TOPAS simulations [https://www.lip.pt/files/training/papers/2023/pdf/2023-PAPER-155-9.pdf\].

Thank you for all the information. Regarding your questions:

1.Which physics list would you recommend be forced on everyone, and why?, Answer: I would like to see a Geant4 executable file with a user interface that includes buttons and menus allowing users to select the physics list(s) one want, in other words, being able to select (while the Geant4 executable file is running) the physics list(s) one wants from all the possible physics lists in Geant4.

3.Which primary generator would you propose to use? GPS?, Answer: I would propose creating / make an executable Geant4 file / application that allows to select the primary generator one want; it could be a basic primary generator or it could be a GPS (General Particle Source), or it could be something that is neither a basic primary generator nor GPS.

If a user needs a Mei & Hime cosmogenic distribution, would you propose that we include that code in your “single executable?, Answer: I would simply like it to be possible to specify (while the Geant4 executable is running) the spatial distribution of the primary particles in the Geant4 executable by means of a user interface

What about users who need to use something like Genie or Marley to generate neutrino events?, Answer: I would like to see a Geant4 executable file that includes Geant4, Genie and Marley, but I think that would be asking too much, so, I think in this case the most convenient thing would be to use either only Geant4 or only Genie or only Marley or use 2 or 3 of these programs at the same time.
4.How would you propose supporting the experiment-specific digitization (detector response) code in your “single executable”?, Answer: I don´t know the answer to this question , what would you propose?

5.How would you handle producing output data files? There are macro commands to support scorers, but how would you propose creating arbitrary column-based N-tuples for output? Would you develop a new Messenger layer for G4analysis?, Answer: I think this depends on the experiment, and consequently, on the simulation being done, Or am I wrong?. Thanks

Thanks for your reply. I think what you are saying makes sense because if a general purpose Geant4 based application were possible it would already be available, and it isn´t; or perhaps it´s because there probably isn´t a person dedicated to research in all five of these disciplines (particle physics, nuclear physics, medical physics, space science and accelerator science), for this reason I think there isn´t a general purpose Geant4 based application.

Why are there so many of those?, Answer: I don´t know why there are so many languages with those characteristics, What would your answer be?

Thank you for all the information. I took a look at the paper you mentioned; I consider the TOPAS Automator an interesting topic.

Regarding your question: Have you heard about TOPAS MC?, I had never heard of TOPAS MC

On the other hand, I think I’d like to see something like that with regards to the Geant4 toolkit, in other words, I would like a Geant4 Automator to be created / included in a future Geant4 release; Do you think a Geant4 Automator (taking into account the entire Geant4 toolkit) could be created / produced in the near future? Why yes? or Why not? What would be the advantages of a Geant4 Automator? Do you think that if a Geant4 Automator is ever created it will make Geant4 much easier to use? Why? Do you think it would be convenient to create a Geant4 Automator? Why?.

For the physics lists themselves, that is potentially possible, and if fact you’ll find examples that do this via UI commands. What happens when those lists don’t provide the physics you need? How would you design a UI to build up a physics list from scratch? This is probably the most amenable to a GUI/config file solution, but it’s still not a small task.

Without coding, how do you specify something that is neither GPS nor ParticleGun?

As above, how would you bring this capability in to the general purpose application without coding?

Yep, experiment/setup dependent. Sometimes ensemble data will be fine, sometimes you want event-by-event data, sometimes you need deeply nested, event dependent data structures.

Rather than asking one person, why not ask the world? Try asking “why are there so many programming languages” to your favourite search engine. I don’t say that harshly, I say it because it will give you far more varied opinions and reasons from not just scientific computing but from computer science, web programming, and application development as well. This will also cover the history of their development, why they’ve been adopted where, and criticisms/praise as well.

2 Likes

I would like to see a Geant4 executable file with a user interface that includes buttons and menus allowing users to select the physics list(s) one want, in other words, being able to select (while the Geant4 executable file is running) the physics list(s) one wants from all the possible physics lists in Geant4.

It sounds like you dont want to do coding but instead you want a GUI where you can click stuff and expect things to happen the way you want them.
I can understand where your frustration is coming from since learning Geant4 and making progress with your projects depends on your C++ knowledge/skill.

In my sandbox-simulation, i have this block of code, which enables me to change the physics list with just on click by commenting in-and-out lines, which is basically what you are asking for.
It’s beginner friendly but it was just my way of getting into Geant4. I did the same for a custom physics list and for basic geometries, then Sensitive Detectors and Primitive Scorers.
Just gathering code snippets from the Geant4-examples and combining them until i had what i wanted.

  // G4VModularPhysicsList\* physicsList = new QBBC;
  // G4VModularPhysicsList\* physicsList = new FTF_BIC;
  // G4VModularPhysicsList\* physicsList = new FTFP_INCLXX;;
  // G4VModularPhysicsList\* physicsList = new FTFP_BERT;
  // G4VModularPhysicsList\* physicsList = new FTFQGSP_BERT;
  // G4VModularPhysicsList\* physicsList = new QGSP_BIC;
  G4VModularPhysicsList\* physicsList = new QGSP_BIC_AllHP;  
  //G4VModularPhysicsList\* physicsList = new QGSP_INCLXX;
  // G4VModularPhysicsList\* physicsList = new QGSP_BERT;
  // G4VModularPhysicsList\* physicsList = new QGSP_FTFP_BERT;
  runManager->SetUserInitialization(physicsList);

I think instead of asking for a unified-Geant4-executable-GUI-thingy one should/could ask for more beginner friendly low-level tutorials for Geant4 or evaluate why existing tutorials dont work.

There are Geant4-Schools, there are the official examples, some people make youtube-videos, etc.. but they are all around the place and they do things differently.

1 Like

Thank you for your reply.

What happens when those lists don’t provide the physics you need?. Answer: I think in this case, what one can do is to code in C++ the physics one want to include in the Geant4 simulation, right?

How would you design a UI to build up a physics list from scratch?. Answer: Coding in C++, right?

Without coding, how do you specify something that is neither GPS nor ParticleGun?. Answer: I have been thinking about it for a while, and I think the only way to do something like that is by coding in C++, right?

how would you bring this capability in to the general purpose application without coding?. Answer: Again, I think the only option is to code in C++

Thank you for all the information. In addition to what you mention in the last 2 paragraphs of your post, I think it would be good for some Geant4 users if long-term (for several months or several years) in-person or online Geant4 courses were offered, something like a training course that could be basic/beginner, intermediate, or advanced, depending on each user’s needs. Another thing that would be convenient for some Geant4 users, I think, would be the possibility of having Geant4 classes / advisors / tutoring through in-person or online meetings (one or 2 hours a week for some months or years, for example). Another thing that might be useful is to provide many Hands-On Tutorials / Courses (like SLAC Geant4 turorial Hands On, on the internet), that is, theorical and practical / Hands-On Courses / Tutorials in which Geant4 students / learners are tasked with learning concepts related to Geant4 and do various exercises.

Exactly. So given that the general purpose application is already built, how do you get that code into it? It is possible, see for example FullSimLight, but you end up with something not much different to writing from scratch, especially as the complexity of what you want to do increases.

These do happen, see for example the Events page on our website and in particular, go through the “Past Events” to see the typical range offered (The CERN intro/advanced course are probably closest).

Ok thanks. So given that the general purpose application is already built, how do you get that code into it?. Answer: Based on what you are saying, get code (written in C++) into an executable file isn´t very convenient / advisable, right?

So, one can say that general purpose Geant4 based applications can be made, but one will always have to code in C++ to include updates or new things or fix things and consequently produce new executable files or general purpose Geant4 based applications, right?.

Right. You’ve gotten to the point we were trying to make at the start; very good!

1 Like

Ok, thanks. I think I understand things better now.