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