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