Belle II Software  release-08-01-10
analyze_svd_background.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 import basf2 as b2
13 
14 b2.set_log_level(b2.LogLevel.INFO)
15 # Change this to point to actual locations on your system.
16 input_dir = '/data/belle2/BG/Jun2014/bg_SVD/'
17 output_dir = '/data/belle2/BG/Jun2014/bg_SVD/output/'
18 
19 components = []
20 components.append(('Coulomb_HER', 100))
21 components.append(('Coulomb_LER', 100))
22 components.append(('RBB_HER', 100))
23 components.append(('RBB_LER', 100))
24 components.append(('Touschek_HER', 100))
25 components.append(('Touschek_LER', 100))
26 components.append(('twoPhoton', 200))
27 
28 files = [input_dir + s + '_' + str(t) + 'us.root' for (s, t) in components]
29 
30 svd_branches = ['MCParticles', 'MCParticlesToSVDSimHits',
31  'MCParticlesToSVDTrueHits', 'SVDSimHits', 'SVDTrueHits']
32 
33 input = b2.register_module('RootInput')
34 input.param('inputFileNames', files)
35 # input.param('branchNames', svd_branches)
36 
37 # Histogram manager immediately after master module
38 histo = b2.register_module('HistoManager')
39 # File to save histograms
40 histo.param('histoFileName', output_dir + 'SVDBackgroundHisto.root')
41 
42 # Report progress of processing
43 progress = b2.register_module('Progress')
44 
45 # Load parameters
46 gearbox = b2.register_module('Gearbox')
47 # Create geometry
48 geometry = b2.register_module('Geometry')
49 geometry.param('components', ['SVD'])
50 
51 # SVD digitizer
52 svdDigi = b2.register_module('SVDDigitizer')
53 svdDigi.param('ElectronicEffects', False)
54 
55 # SVD clusterizer
56 # svdClust = register_module('SVDClusterizer')
57 
58 # SVD beam background
59 svdBkg = b2.register_module('SVDBackground')
60 svdBkg.param('componentNames', [s for (s, t) in components])
61 svdBkg.param('componentTimes', [t for (s, t) in components])
62 svdBkg.param('outputDirectory', output_dir)
63 
64 svdBkg.set_log_level(b2.LogLevel.DEBUG)
65 svdBkg.set_debug_level(10)
66 
67 # output - do we want output?
68 output = b2.register_module('RootOutput')
69 output.param('outputFileName', output_dir + 'SVDBackgroundOutput.root')
70 output.param('branchNames', ['SVDEnergyDepositionEvents', 'SVDNeutronFluxEvents'])
71 
72 # Create paths
73 main = b2.create_path()
74 
75 # Add modules to paths
76 main.add_module(input)
77 main.add_module(histo)
78 main.add_module(progress)
79 main.add_module(gearbox)
80 main.add_module(geometry)
81 main.add_module(svdDigi)
82 # main.add_module(svdClust)
83 main.add_module(svdBkg)
84 main.add_module(output)
85 
86 # Process events
87 b2.process(main)
88 
89 # Print statistics
90 print(b2.statistics)