MPGenbb generator is a module used for generating custom .genbb files, which serve as an input for custom generated events into Falaise simulation module of SuperNEMO collaboration.
The following example shows how to use the module to simply generate a file with momenta of each particle generated using a $2\nu\beta\beta$ decay spectrum provided by R. Dvornicky rebinned using MPRebinSpectra module (MPRebinSpectra.jl)
- Each event is separated by
#
- Each event consists of:
- Header line which has fields:
ID Time nP
(where ID is event ID from 0 to N; Time is starting time; nP is the number of particles within the event) - Particle line with fields:
Type px py pz dt
(where particleType
is 1- gamma, 2- positron, 3-electron;px py pz
are momentum components;dt
is time difference)
- Header line which has fields:
An example event - 2 positrons, starting at Time = 0
, with dt = 0
and momenta px1 = py1 = pz1 = 1, px2 = py2 = pz2 = 1
- is generated as:
0 0 2
2 1 1 1 0
2 2 2 2 0
#
using MPGenbb, DataFrames, CSV
Base.displaysize() = (5, 100) # this line sets display of rows 5 and cols 100
inFile = string("spectrumG0_Rebinned_prec0001.csv")
"spectrumG0_Rebinned_prec0001.csv"
df = CSV.File(inFile) |> DataFrame
614,474 rows × 8 columns
E1 | minE | maxE | minG | maxG | a | b | cdf | |
---|---|---|---|---|---|---|---|---|
Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | |
1 | 0.00093 | 0.0 | 0.00093 | 0.0 | 0.402019 | 432.278 | 0.0 | 1.86939e-7 |
2 | 0.00093 | 0.00093 | 0.01493 | 0.402019 | 0.412043 | 0.716006 | 0.401353 | 5.88537e-6 |
3 | 0.00093 | 0.01493 | 0.02693 | 0.412043 | 0.421358 | 0.776314 | 0.400452 | 1.08858e-5 |
4 | 0.00093 | 0.02693 | 0.04093 | 0.421358 | 0.433615 | 0.875475 | 0.397782 | 1.68706e-5 |
5 | 0.00093 | 0.04093 | 0.05893 | 0.433615 | 0.450447 | 0.93513 | 0.39534 | 2.48272e-5 |
⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ |
const MASS = 0.511 # particle mass in MeV/c²
const PART_TYPE = 3 # particle type: 1- gamma, 2-positron, 3-electron
const OUTFILE = "input_module.genbb" # name of the output file
const PROCESS = "82Se 0νββ - Energy generated via SpectrumG0 - from R. Dvornicky";
NEVENTS = 100 # how many events should be created
100
To save the file use a simple for loop, at each step generate electron energies T
and momentum vectors p1
and p2
(where direction of p1
is random unifrom in sphere and direction of p2
is correlated to p1
).
open(OUTFILE, "w") do file
Threads.@threads for id in 0:NEVENTS-1
T = sample_energies(df)
p1 = get_first_vector(T[1], MASS)
p2 = get_second_vector(T[2], MASS, p1)
if id%10_000 == 0 && id >1
println("generated $id events!")
end
write(file, get_event_string(id, PART_TYPE , p1, p2))
end
end