Belle II Software  release-05-01-25
comparePDF.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 # -------------------------------------------------------------------------
5 # Example of using TOPPDFChecker to compare analytic PDF with simulation
6 # Note: time jitters and backgrounds are excluded to compare details easier
7 # -------------------------------------------------------------------------
8 
9 from basf2 import *
10 import os
11 
12 # particle parameters (emitted from IP) - change as you like
13 p = 3 # GeV/c
14 theta = 90 # degrees
15 phi = 20 # degrees
16 pdg = 211 # pion
17 outputFile = 'comparePDF.root' # file to save histograms
18 
19 # Suppress messages and warnings during processing:
20 set_log_level(LogLevel.WARNING)
21 
22 # Create path
23 main = create_path()
24 
25 # Set number of events to generate
26 eventinfosetter = register_module('EventInfoSetter')
27 eventinfosetter.param('evtNumList', [1000])
28 main.add_module(eventinfosetter)
29 
30 # Histogram manager immediately after master module
31 histo = register_module('HistoManager')
32 histo.param('histoFileName', outputFile) # File to save histograms
33 main.add_module(histo)
34 
35 # Gearbox: access to database (xml files)
36 gearbox = register_module('Gearbox')
37 main.add_module(gearbox)
38 
39 # Geometry (only TOP and B-field)
40 geometry = register_module('Geometry')
41 geometry.param('useDB', False)
42 geometry.param('components', ['MagneticField', 'TOP'])
43 main.add_module(geometry)
44 
45 # Particle gun: generate single particle w/ fixed vertex, momentum and kind
46 particlegun = register_module('ParticleGun')
47 particlegun.param('pdgCodes', [pdg])
48 particlegun.param('nTracks', 1)
49 particlegun.param('varyNTracks', False)
50 particlegun.param('momentumGeneration', 'fixed')
51 particlegun.param('momentumParams', [p])
52 particlegun.param('thetaGeneration', 'fixed')
53 particlegun.param('thetaParams', [theta])
54 particlegun.param('phiGeneration', 'fixed')
55 particlegun.param('phiParams', [phi])
56 particlegun.param('vertexGeneration', 'fixed')
57 particlegun.param('xVertexParams', [0])
58 particlegun.param('yVertexParams', [0])
59 particlegun.param('zVertexParams', [0])
60 particlegun.param('independentVertices', False)
61 main.add_module(particlegun)
62 
63 # Simulation
64 simulation = register_module('FullSim')
65 main.add_module(simulation)
66 
67 # TOP digitization: all time jitters turned OFF
68 topdigi = register_module('TOPDigitizer')
69 topdigi.param('useWaveforms', False)
70 topdigi.param('simulateTTS', False)
71 topdigi.param('electronicJitter', 0.0)
72 topdigi.param('timeZeroJitter', 0.0)
73 main.add_module(topdigi)
74 
75 # Dedicated track maker using MC information only
76 trackmaker = register_module('TOPMCTrackMaker')
77 main.add_module(trackmaker)
78 
79 # TOP PDF: time jitters are excluded
80 toppdf = register_module('TOPPDFChecker')
81 main.add_module(toppdf)
82 
83 # Show progress of processing
84 progress = register_module('Progress')
85 main.add_module(progress)
86 
87 # Process events
88 process(main)
89 
90 # Print call statistics
91 print(statistics)