The GEANT4 program structure was borrow from the example B5. I found that the most confusing part is the Action. Before that, let me start with the main().
GEANT4 is a set of library and toolkit, so, to use it, basically, you add a alot GEANT4 header files on your c++ programs. And, every c++ program started with main(). I write the tree diagram for my simplified exampleB5,
main() +- DetectorConstruction.hh +- Construct() +- HodoscopeSD.hh // SD = sensitive detector +- HodoscopeHit.hh //information for a hit +- ProcessHits() //save the hit information +- ConstructSDandField() //define which solid is SD +- ConstructMaterials() //define material +- PhysicsList.hh // use FTFP_BERT, a default physics for high energy physics +- ActionInitialization.hh +- PrimaryGeneratorAction.hh // define the particle gun +- RunAction.hh // define what to do when a Run start, like define root tree +- Analysis.h // call for g4root.h +- EventAction.hh //fill the tree and show some information during an event
A GEANT4 program contains 3 parts: Detector Construction, Physics, and Action. The detector construction is very straight forward. GEANT4 manual is very good place to start. The physics is a kind of mystery for me. The Action part can be complicated, because there could be many things to do, like getting the 2ndary beam, the particle type, the reaction channel, energy deposit, etc…
Anyway, I managed to do a simple scattering simulation, 6Li(2mm) + 22Ne(60A MeV) scattering in vacuum. A 100 events were drawn. The detector is a 2 layers plastic hodoscope, 1 mm for dE detector, 5 mm for E detector. I generated 1 million events. The default color code is Blue for positive charge, Green for neutral, Red for negative charge. So, the green rays could be gamma or neutron. The red rays could be positron, because it passed through the dE detector.
The histogram for the dE-TOF is
We can see a tiny spot on (3.15,140), this is the elastics scattered beam, which is 20Ne. We can see 11 loci, started from Na on the top, to H at the very bottom.
The histogram of dE-E
For Mass identification, I follow the paper T. Shimoda et al., Nucl. Instrum. Methods 165, 261 (1979).
I counted the 20Na from 0.1 billion beam, the cross section is 2.15 barn.
Linh
Apr 27, 2016 @ 05:27:40
Dear GoLuckyRyan,
I’m a student. I have an exercise that it looks like your post. Could you help me?
GoLuckyRyan
Apr 27, 2016 @ 14:23:41
Hi, Linh, yes, how can I help you?
Linh
Apr 27, 2016 @ 15:13:00
Could you discuss with me by email. I want to know about the physicslist and how to export root in your simulation.
Kübra Üstün
Mar 18, 2021 @ 08:10:10
Hello, I am trying to create histograms too(using g4root), but I can’t seem to create advanced ones like yours. Right now I can only show one thing in a histogram. How did you make the dE-TOF one? I want to create a histogram that shows energy of secondary particles, but I want to know which ones were created how (for example Scintilation) and show them with different colours. Can you help?
GoLuckyRyan
Mar 18, 2021 @ 15:57:23
Hi, I lost the code so I am not sure how exactly I did that. But you can look at the GEAN4 example B5 (https://geant4-userdoc.web.cern.ch/Doxygen/examples_doc/html/ExampleB5.html), remove those structure or detector you don’t need. In the example, there is a plastic hodoscope. So, from there, I hope you can do what you want.