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.