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