Beginner at geant4

The error says there is something wrong with the material of your (logic) world but the code for the world definition looks fine to me…?!

I think it’s the line

G4Material *worldMat = nist->FindOrBuildMaterial("G4_Air");

as the key for the material is “G4_AIR”. So worldMat gets set to nullptr and hence the error. A full list of builtin material definitions and the keys to pass to FindOrBuildMaterial can be found in the Appendices of the Application Developer Guide

1 Like

now what should i do?
its difficult for me how to resolve it?

I guess @bmorgan highlighted that the material has to be written as “G4_AIR” and not as “G4_air”.

I’ve to admit I didn’t notice that.

1 Like

Yes, I should have made that clearer, the line should be

G4Material *worldMat = nist->FindOrBuildMaterial("G4_AIR");


sir i need this type of geometery but after removing the error which you have mentioned G4_AIR but i could not get required light shower .After removing error i got geometery which which consist of only one beam.
i attach below an other geometery which i got.

I think there is no way around following the well-written instructions in this post: Beginner at geant4 - #2 by John_McFee

Well, but this means it is working in general now.
What you’re describing now is a specific issue as there is no shower produced. We would need further information for this to resolve, especially the code.
Out of the blue I assume the box the beam passes through has no material so it also consists of air? Could you check that? And also show us the code?

I agree with weller, at this point you need more knowledge on C++ or Geant4 in general or else you will come back to this thread at every error.

As for your specific problem, it looks like you are generating a proton, is that what you intend? Do you expect a 100 GeV proton to interact with your material? Did you define your material correctly? You say you expect a light shower, did you implement optical photons in your physics list? (if that is what you want?).

There are a number of reasons why you are not getting what you expect, and you first must understand what you want to do and how you can do it using Geant4

construction.cc (1.7 KB)
this is file where i put code for light shower

sir i follow this tutorial but i do not know where i do mistake , geant4 can not show the light shower

The code you’re looking for is shown in the video, you basically “only” have to copy that.
I did the same tutorial and I also stumbled over a lot of issues but most of them were mistakes on my side and some solutions you can find in the comments of the tutorial.

Hello
I downloaded Geant 4.10.7 Vesrion. I created a build and install directory. My question is: could you give me the commands to install and build, then run this code?

For future reference, please start new threads rather than reviving an old one/or interjecting your own question!

All the information on installing Geant4 can be found in the Installation Guide, which is part of the documentation listed on the Geant4 website