GEANT4 simulation of HPGe Clover detector

Leave a comment

I recently go back to GEANT4 simulation. To simulate the gamma spectrum of the high-purity Germanium (HPGe) Clover detector.

The code is in here: https://github.com/goluckyryan/HPGeClover

Here are some visualizations

The simulated setup for the 16N isomer ration determination. The simulation generate all possible gamma ray energy. We can see a lot of 120 keV gamma being stopped by the vacuum pipe.

The simulation for the 16N isomer decay at the center is like

the simulation caught all feature, but the intensity of the double escape peak from the 6130 keV peak is smaller than the experiment. And the peak to Compton scattering background is different.

Since the strength of the escape peaks are very sensitive to the position and geometry of the crystal, the simulation condition need to be adjusted.


Here is the program structure. This is also a generic program structure.

comments or to do for the code

  • is there a way to get number of clover at EventAction ? I tried to use the G4LogicalVolumeStore, but it seems that the detector is constructed after EventAction.
  • is there any way to enable or disable geometry from command ?
  • change clover position from command?
  • set list of gamma energy and distribution from command
  • read file for energy and distribution

Visualization of GEANT4 using VRML

1 Comment

When compiling GEANT4, there are default visualization output. In the past, I used DAWN. DAWN is a static viewer, need to specific view angle, zoom, etc.

Another dynamic viewer is VRML. This is also a built-in visualization output. In the GEANT4 macro,

/vis/open VRML2FILE
/vis/drawVolume
/vis/scene/add/trajectories
/vis/scene/endOfEventAction accumulate

#generate 10 beams
/run/beamOn 10

GEANT4 will output a g4_XX.wrl file. This file can be opened in any Ubuntu by view3dscene

>sudo apt install view3dscene

After installation, run

>view3dscene g4_XX.wrl

Here is the screenshot of the extended example Testem4

Much better than DAWN.

a GEANT4 Simulation

5 Comments

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.

Screenshot from 2016-01-30 00:34:34.png

The histogram for the dE-TOF isScreenshot from 2016-01-29 23:26:34.png

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

Screenshot from 2016-01-29 23:30:38.png

For Mass identification, I follow the paper T. Shimoda et al., Nucl. Instrum. Methods 165, 261 (1979).

Screenshot from 2016-01-30 00:06:02.png

I counted the 20Na from 0.1 billion beam, the cross section is 2.15 barn.

 

GEANT4 installation – Concept

Leave a comment

for the moment, i think GEANT4 is a set of libraries (of physical process, meterial) and a tool (Monte Carlo method).

As you can see, Visualization is not included in GEANT4. I mean, GEANT4 can output some files for other Visualization programs, but those programs have to be install separately.

A complete environment = GEANT4 + Visualization 

//——————– GEANT4 installation

To install GEANT4, you can go to http://geant4.web.cern.ch/ to download to source code.

The installation method can be found in
http://geant4.web.cern.ch/geant4/support/userdocuments.shtml

basically, unzip the source code.

tar -zxvf geant4-source
mkdir geant4-build
cd geant4-build
cmake -DGEANT4_INSTALL_DATA=ON -DGEANT4_USE_NETWORKVRML=ON -DCMAKE_INSTALL_PREFIX=/path/to/geant4-install  geant4-source
make
make install

There are two options, 1 is the GEANT4_INSTALL_DATA, this will download and install the physical process for radiation-matter interaction. 2 is the GEANT4_USE_NETWORKVRML, this will enable network VRML visuallization. This is a local install, all the installed files are located at /path/to/geant4-install. After the installation, better to write this in .bashrc

cd ~/geant4.10.02-install/bin
. geant4.sh
cd ~/

The only difficulty is the CMAKE 3.0 or above. But all errors i met can be easily found in google.

//————— Visualization program.

I skipped the openGL, as it is well known for unfriendly for NVidia display card.

I tried DAWN and freeWRL. DAWN is a static visualization. It read *.prim files and output an *.eps file for fixed angle. freeWRL is a VRML display using java-script, an alternative is openVRML. But I cannot install openVRML.

DAWN can be installed from http://geant4.slac.stanford.edu/Presentations/vis/G4DAWNTutorial/G4DAWNTutorial.html#applicationinstall, I have zero problem.

FreeWRL is a bit tricky. I can only install the 2.3.3.1 version, not earlier, not later. I don’t know why. It require javascript engine, apt-get install libmozjs185-dev. when it said any thing missing, just look for libXXXX.

//——————————– Example.

I took the example form the geant4-source/example/basic/B1, copy it to ~/geant4Works/B1.

mkdir B1-build
cd B1-build
cmake -DGeant4_DIR=/path/to/geant4-install/lib/Geant4-10.2.0  B1
make

to run, you simple ./exampleB1

the macro files are *.mac. vis.mac is visualization macro, and will be called by init_vis.mac. You should go to vis.mac and modify it.

To run,

Idle> /control/execute run1.mac

I modified the last line be /run/beamOn 100, the result is

Screenshot from 2016-01-27 13:46:48.png

you can see there are 100 protons passing through. I don’t understand the example B1, I’m just showing you what is a proper result.


[Update 2024-02-15]

For the GEANT4 11.2.0, the cmake

 cmake -DGEANT4_INSTALL_DATA=On -DCMAKE_INSTALL_PREFIX=/opt/geant4-v11.2.0 -DGEANT4_USE_OPENGL_X11=ON -DGEANT4_USE_QT=ON -DGEANT4_USE_QT_QT6=ON ../geant4-v11.2.0
 make -j6
 sudo make install

The -J6 means using 6 threads to compile. The default installation path is /usr/local/. The above option enables OpenGL for X11 and Qt6 visualization.

after installation, add the following line to ~/.bashrc

 source /usr/local/bin/geant4.sh

For Ubuntu 22.02, openGL is already installed, for Qt6, use

 sudo apt install sudo apt install qt6-base-dev libqt6charts6-dev

To use openGL,

 /vis/open OGL

for Qt

 /vis/open OGLIQt