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