Belle II Software  release-05-01-25
vertexDisplacer.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
18 
19 from basf2 import *
20 from simulation import add_simulation
21 from reconstruction import add_reconstruction, add_mdst_output
22 from ROOT import Belle2
23 import modularAnalysis as ma
24 
25 main = create_path()
26 
27 eventinfosetter = main.add_module("EventInfoSetter", evtNumList=[100], expList=[1003])
28 
29 # Generate decay with your favourite generator, using EvtGen as example
30 # the decay file should include the particle(s) to be displaced
31 dec_file = None
32 if len(sys.argv) > 1:
33  dec_file = os.path.abspath(sys.argv[1])
34  print("using following decay file: " + dec_file)
35 
36 main.add_module('EvtGenInput', ParentParticle='Upsilon(4S)', userDECFile=dec_file)
37 
38 # initialise the displacer module
39 displacer = register_module("GeneratedVertexDisplacer")
40 
41 # list of pdg values for particles to be displaced, here 100
42 displacer.param("pdgVal", (100))
43 
44 # list of lifetimes corresponding to the particles to be displaced, here c*tau = 10cm
45 displacer.param("lifetime", (10))
46 # pass the lifetime in units of [ns]: displacer.param("ctau", False)
47 
48 # specifying exponential decay option
49 displacer.param("lifetimeOption", "exponential")
50 
51 # add displacer module between generator and detector simulation
52 main.add_module(displacer)
53 
54 # print the MC particles for verification
55 ma.printMCParticles(onlyPrimaries=False, maxLevel=-1, path=main)
56 
57 # detector simulation
58 add_simulation(main)
59 
60 # reconstruction
61 add_reconstruction(main)
62 
63 # save to file
64 add_mdst_output(main, filename='displacerOut.root')
65 
66 process(main)