Skip to content

Template repository with a basic example for performing simulations in Geant4.

License

Notifications You must be signed in to change notification settings

CIEMAT-Neutrino/SIM_LAB_GEANT4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SIM_LAB_GEANT4

SUMMARY

This is a basic example for performing simulations in Geant4. The world volume is filled with LAr and we place different detectors that can be included with given positions in a .json or manually. The output is a .root file which contains (Photon) NTuple with the position (X,Y,Z) of the photon hit in your detector and the incidence angle (theta, phi).

We have different headers and sources that are included in the main file (box1.cc). Chronologically we have created the files as follows:

1.- Detector construction (construction)

2.- Physics included in the analysis (physics)

3.- Particle gun in action (action)

4.- Particle generator (generator)

5.- Inserting sensitive detector (detector) and we add in construcction.cc the detectors' volumes

6.- Store the information in a .root file (with Ntuples). Defined in run.cc and run.hh. We can see the stored information:

  >> root output.root
  >> new TBrowser()
  >> Hits->Draw("fX:fY", "", "colz") //to see the correlation

7.- Automatizating the code

  • vis.mac for visualization commands -> when creating vis.mac it is not in /build and it is not found, we move all the macro file to the right directory without including absolute paths -> look in CMakeLists.txt

  • run.mac -> change the momentum for each particle creation. Changes in box1.cc to accept command line inputs as files (Execute as: >>./box1 *.mac).

  • *.dat -> store quantum/photon detection efficiencies for the different detectors.

8th: Analysing the Ntuple.root generated with the photons' hits. We create a notebook (Analysis.ipynb) for this purpose and to plot the distributions.

We can send alpha particles (blue), electrons(red) and photons(green) are produced. We would need to include the energy deposition calculation that can be also stored in the NTuple. We want to show Scintillation LAr light (see G4Scintillation)


RUN GEANT4 SIMULATION

🇬4️⃣ 1. SETUP AND COMPILATION

Once you have cloned the repository, you can setup the enviroment with the following commands:

source scripts/setup.sh
./scripts/run_build.sh

Before the compilation occurs you will need to choose a geometry to be used among the displayed options. Then you can run the code.

setup compilation success

⚠️ WARNINGS ⚠️

  • You will need the library Motif for a successful compilation (ask ae_support to install it in you local pcae if you need it)
  • run_build.sh script only runs from main folder (it will ask for your confirmation to continue with the process)
  • You need to choose a geometry (geometries and configs folders 📂) for the compilation. Each change need to be recompiled !!

🆕 Once you have clearly chosen your geometry you can compile with ./scripts/run_build.sh geometry to avoid the second question of the script. build


👾 2. RUN YOUR CHOSEN GEOMETRY

Therer are three options of configuring the geometry that can be run as:

  • option1: no json. Source information in the .mac. Compile to update changes in construction.
./build/box1 configs/option1.mac data/output.root
  • option2: fixed positions given in construcction.cc (sbnd_pds_mapping.json). Source information by .mac
./build/box1 configs/option2.mac data/output.root
  • option3: json including positions for sensors + (.mac) information
./build/box1 configs/option3.json data/output.root

run_option3 output_option3

🗒️ Note: each time you change the geometry you need to recompile the code. Probably the simulation output is big so if you need to run several simulation for optimize the setup it is better to allocate the output in a different folder (i.e. in /pc/choozdsk01/palomare/GEANT4 or /pnfs/ciemat.es/neutrinos/ where you can make your own folder ). Moreover if you need to define a geometry based on different simulations you can check production folder with examples on how to change some parameters with different *.json without compilation and run at the same time with the production/production.sh script.


🧪 3. GEOMETRIES EXAMPLES

You can also find some of the geometries used in the IR02 setups:

  • cajita_xa-hd.mac -> measurements from October 2021 to February 2022 of the X-ARAPUCA DUNE HD (to be run as option1)

  • cajita_xa-sbnd.json -> measurements from Febreuary 2023 to April 2023 of the X-ARAPUCA SBND (to be run as option3). There are two types of files for production (*_prod) and for visualization. Moreover there were two measurements to be made with visible ligth (VIS) and with alpha source (VUV)

  • megacell_v1.json -> measurements of August 2023 of the MeggaCell DUNE-VD (to be run as option3).

  • megacell_v2.json -> measurements from October 2023 of the MeggaCell DUNE-VD (nueva cajita; to be run as option3)

  • megacell_v3.json -> measurements from Dicember 2023 of the MeggaCell DUNE-VD (default)


🪄 4. ANALYSIS: JUPYTER NOTEBOOKS

In the analysis folder you can find some notebooks to analyse the output of the simulation.

  • Analitical computations -> expected shapes of the distributions for the different detectors (first two types of plots only available if save_all = true in detector.cc; third one is based on the accum_hits variable which is what you need to see the expected number of photons in your sensor)
  • Simulation outputs -> PDE, #PE, angular distribution, etc.

If you have chosen to run the simulation with the multithreading option you will have different files you may need to combine before looking at the results. Check this command 😉:

hadd -k COMBINED_ALL_OUTPUTS.root COMMOM_NAME_t*

Visualizing in ROOT

  >> root NTuple1.root

  >> Photons->Show(10)
  ======> EVENT:10
  fEvent          = 125
  fX              = 6.68858
  fY              = 19.8176
  fZ              = -9.35483
  fT              = 0.106023
  fWlen           = 430.053
  >> Photons->Print()
  ******************************************************************************
  *Tree    :Photons   : Photons                                                *
  *Entries :      680 : Total =           50496 bytes  File  Size =      26396 *
  *        :          : Tree compression factor =   1.00                       *
  ******************************************************************************
    ...
  *............................................................................*

  ### GetEntries

  >> Photons->Draw("fY:fX>>PMT","-15<fX && fX<15 && -15<fY && fY<15", "colZ")

  >> Photons->Draw("fZ:fX>>SC","-15<fZ && fZ<15 && -15<fX && fX<15", "colZ")

  >> Photons->Draw("fY:fZ>>SiPMs","", "colZ")
  >> Photons->Draw("fY:fX>>SiPM1","fX>15 && fY<15", "colZ")
  >> Photons->Draw("fY:fX>>SiPM2","fX<-15 && fY<15", "colZ")

  >> #TH1F *PMT= (TH1F*)gDirectory->Get("PMT")

  >> #PMT->GetEntries()

LICENSE

MIT

Authors (alphabetical order, please insert your name here if you contribute to this project)

About

Template repository with a basic example for performing simulations in Geant4.

Resources

License

Stars

Watchers

Forks