Belle II Software development
EclBackground.py
1#!/usr/bin/env python3
2
3
10
11"""This steering file is an example of how to use 'ECLBackground' module.
12There are generally 8 different data sets for each background campaign:
13 - RBB HER
14 - RBB LER
15 - Coulomb HER
16 - Coulomb LER
17 - Touschek HER
18 - Touschek LER
19 - BHWide HER
20 - BHWide LER
21
22Each sample usually consists of 1000 files, each representing 1 micro second
23of time, for a total sample time of 1000 micro second (1 ms).
24
25In this example, we will use a subset of 100 files (representing 100 micro second)
26from the 12th Campaign's RBB HER sample.
27
28Samples are generated by Hiro Nakayama-san. Information on them can be
29found here:
30 https://xwiki.desy.de/xwiki/rest/p/078bc
31"""
32
33import subprocess
34import basf2 as b2
35from reconstruction import add_ecl_modules
36
37# Create path. Register necessary modules to this path.
38mainPath = b2.create_path()
39
40"""Use a subset (100 files) of the 12th Campaign RBB HER sample
41
42If you want the whole dataset, uncomment the line after.
43RBB can be replaced with Coulomb and Touschek, and HER with LER.
44"""
45inputs = '~nakayama/basf2_opt/release_201506_12th/Work_MCgen/output/output_RBB_HER_study_1??.root'
46# inputs = '~nakayama/basf2_opt/release_201506_12th/Work_MCgen/output/output_RBB_HER_study_*.root'
47
48# Length of time in us (micro second) each sample file corresponds to
49timePerFile = 1
50
51# Set the sample time based on the number of files that will be opened
52sampletime = timePerFile * int(subprocess.check_output('ls ' + inputs + ' | wc -l',
53 shell=True))
54print('The sampletime is ' + str(sampletime) + 'micro second')
55
56"""You may want to change this to something more descriptive,
57 e.g. 'RBB_HER_100us.root'
58"""
59outputFile = 'EclBackgroundExample.root'
60
61print('The output will written to ' + outputFile)
62
63"""The background module can produce some ARICH plots for
64 shielding studies. To do this, set ARICH to 'True'.
65"""
66ARICH = False
67
68# Register and add 'RootInput' module
69inputFile = b2.register_module('RootInput')
70inputFile.param('inputFileNames', inputs)
71mainPath.add_module(inputFile)
72
73# Register and add 'Gearbox' module
74gearbox = b2.register_module('Gearbox')
75mainPath.add_module(gearbox)
76
77# If you want the ARICH plots, you need to load 'Geometry' module.
78if ARICH:
79 # Register and add 'Geometry' module
80 geometry = b2.register_module('Geometry')
81 geometry.logging.log_level = b2.LogLevel.WARNING
82 mainPath.add_module(geometry)
83
84"""The ECL background module is a HistoModule. Any histogram registered
85 in it will be written to file by the HistoManager module.
86"""
87histoManager = b2.register_module('HistoManager')
88histoManager.param('histoFileName', outputFile)
89mainPath.add_module(histoManager)
90
91"""Register and add 'ECLBackground' module
92
93ECLBackground module:
94 Processes background campaigns and produces histograms.
95 This module requires HistoManager module.
96"""
97eclBackground = b2.register_module('ECLBackground')
98eclBackground.param('sampleTime', sampletime)
99eclBackground.param('doARICH', ARICH)
100# If you want the dose for specific crystals, put the cell ID here.
101eclBackground.param('crystalsOfInterest', [318, 625, 107])
102mainPath.add_module(eclBackground)
103
104# Register and add 'ECLDigitizer' module
105eclDigitizer = b2.register_module('ECLDigitizer')
106mainPath.add_module(eclDigitizer)
107
108# Add the ECL reconstruction modules to the path
109add_ecl_modules(mainPath)
110
111# Process the events and print call statistics
112mainPath.add_module('Progress')
113b2.process(mainPath, calculateStatistics=True)
114print(b2.statistics)