FairShip
Loading...
Searching...
No Matches
AddDiMuonDecayChannelsToG4.py
Go to the documentation of this file.
1# SPDX-License-Identifier: LGPL-3.0-or-later
2# SPDX-FileCopyrightText: Copyright CERN for the benefit of the SHiP Collaboration
3
4import ROOT
5
6ROOT.gROOT.ProcessLine('#include "Geant4/G4ParticleTable.hh"')
7ROOT.gROOT.ProcessLine('#include "Geant4/G4DecayTable.hh"')
8ROOT.gROOT.ProcessLine('#include "Geant4/G4PhaseSpaceDecayChannel.hh"')
9
10
11def Initialize(p8):
12 # take decay and branching ratios from Pythia8
13 pt = ROOT.G4ParticleTable.GetParticleTable()
14 for vreso in [223, 333, 113]:
15 particleG4 = pt.FindParticle(vreso)
16 particleP8 = p8.particleData.particleDataEntryPtr(vreso)
17 decayTable = ROOT.G4DecayTable()
18 for i in range(particleP8.sizeChannels()):
19 achannel = particleP8.channel(i)
20 bR = achannel.bRatio()
21 mul = achannel.multiplicity()
22 dl = []
23 for daughter in range(4):
24 if daughter < mul:
25 pid = achannel.product(daughter)
26 dl.append(pt.FindParticle(pid).GetParticleName())
27 else:
28 dl.append(ROOT.G4String(""))
29 mode = ROOT.G4PhaseSpaceDecayChannel(particleG4.GetParticleName(), bR, mul, dl[0], dl[1], dl[2], dl[3])
30 decayTable.Insert(mode)
31 particleG4.SetDecayTable(decayTable)
32 particleG4.DumpTable()