Skip to content

BrunoGelli/BGOg4Sim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Geant4 Optical Photon Simulation with ROOT Analysis

This repository contains a Geant4-based simulation for optical photon generation, tracking, and detection in a water Cherenkov detector context. It includes Cherenkov and scintillation photon generation, visualization macros, and a ROOT-based Python waveform builder for analysis.

⚠️ Disclaimer ⚠️

This code was developed quickly based on a prior project, and some files may be unrelated or left over from previous iterations. If anything is unclear or if you plan to use or modify this code for your own project, feel free to contact me for clarification or guidance.

🔧 Project Structure

.
├── src/                  # Colection of Source files
│   └── src/              # Geant4 source files
│   └── include/          # Geant4 headers
│   └── vis.mac           # Visualization setup
│   └── CMakeLists.txt        # Build configuration
│   
├── scripts/                  # Colection of Source files
│   └── photon_histogram_builder.py  # ROOT Python script to build waveforms
│
├── .gitignore
└── README.md             # This file

🛠️ Building the Project

Prerequisites

  • Geant4 (with data sets and visualization options)
  • CMake (≥ 3.16)
  • ROOT (for waveform analysis)
  • Python 3 with ROOT, numpy, and matplotlib for analysis scripts

Build Instructions

mkdir build
cd build
cmake ../src
make

🚀 Running the Simulation

Run a simple test using:

./filtro

Running in non-batch mode may require to compile it with single core run manager. Modify filtro.cc if getting errors.

 G4RunManager* runManager = new G4RunManager;

You can batch run with the following, where N is the PMT to BGO distance (in mm)

./filtro filtro.in N

Running for many events benefit greatly of having multi-core run manager. Modify filtro.cc to use N cores.

G4MTRunManager* runManager = new G4MTRunManager;
runManager->SetNumberOfThreads(N);
runManager->SetVerboseLevel(0);

📈 Waveform Processing

After running the simulation and producing a ROOT output tree:

Make sure you combine all outputs with hadd. Then cleanup removing the unecessary files.

hadd OutPut_merged_0mm.root OutPut_t*.root
rm OutPut_t*.root
rn OutPut.root

Then use the python script to go from the photon arrival histogram to pmt response waveforms:

python photon_histogram_builder.py

This script builds histograms of photon arrival times per event and separates Cherenkov and scintillation contributions. Ita also applies the PMT QE and simulate PMT response.

🧪 ROOT Analysis Tips

From within ROOT, you can explore the output tree using the TBrowser:

TBrowser b;

Or plot Cherenkov/scintillation ratios for triggered events:

tree->Draw("n_cher/n_scint:event", "trigger==1", "COLZ")

🎨 Customization

colors in vis.mac:

  • Optical photons → Green
  • Gammas → Purple
  • Electrons → Red
  • Positrons → Blue
  • Default → Grey

About

A toy Geant4 to simulate the behavior of a gamma interaction with the BGO crystal. A python script is used to simulate the real response of the PMT after observing the BGO photons. The same script outputs this data to a root file in the form of one waveform histogram per event, a structure similar to what ANNIE DAQ will produce

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors