Belle II Software  release-05-01-25
EclBackground.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 import os
13 import sys
14 import subprocess
15 from basf2 import *
16 from subprocess import call
17 from reconstruction import add_ecl_modules
18 
19 print('\033[1m') # makes console text bold
20 print('This steering file is an example of how to use the ECLBackgroundModule.')
21 print('')
22 print('There are generally 8 different data sets for each background campaign:')
23 print(' RBB HER')
24 print(' RBB LER')
25 print(' Coulomb HER')
26 print(' Coulomb LER')
27 print(' Touschek HER')
28 print(' Touschek LER')
29 print(' BHWide HER')
30 print(' BHWide LER')
31 print('')
32 print('Each sample usually consists of 1000 files, each representing 1us of time, for a total sample time of 1000us or 1ms.')
33 print("In this example, we will use a subset of 100 files (representing 100us) from the 12th Campaign's RBB HER sample.")
34 print('Samples are generated by Hiro Nakayama-san. Information on them can be found here:')
35 print('https://confluence.desy.de/display/BI/Background+WebHome')
36 print('')
37 
38 # use a subset (100 files) of the 12th Campaign RBB HER sample
39 inputs = '~nakayama/basf2_opt/release_201506_12th/Work_MCgen/output/output_RBB_HER_study_1??.root'
40 
41 # Uncomment if you want the whole dataset. RBB and can be replaced with Coulomb and Touschek, and HER with LER
42 # inputs = "~nakayama/basf2_opt/release_201506_12th/Work_MCgen/output/output_RBB_HER_study_*.root"
43 
44 # the length of time in us each sample file corrosponds to
45 timePerFile = 1
46 
47 # set the sample time based on the number of files that will be opened
48 sampletime = timePerFile * int(subprocess.check_output('ls ' + inputs + ' | wc -l',
49  shell=True))
50 print('The sampletime is ' + str(sampletime) + 'us')
51 
52 # You may want to change this to something more descriptive, eg RBB_HER_100us.root
53 outfile = 'EclBackgroundExample.root'
54 
55 print('The output will written to ' + outfile)
56 print('\033[0m') # turns off bold text
57 
58 # The background module can produce some ARICH plots for shielding studies. To do this, set this to True
59 ARICH = False
60 
61 # Register necessary modules
62 main = create_path()
63 
64 # RootInput takes the Monte Carlo events and fills the datastore, so they can be accessed by other modules
65 simpleinput = register_module('RootInput')
66 simpleinput.param('inputFileNames', inputs)
67 main.add_module(simpleinput)
68 
69 gearbox = register_module('Gearbox')
70 main.add_module(gearbox)
71 
72 # If you want the ARICH plots, you need to load the geometry.
73 if ARICH:
74  geometry = register_module('Geometry')
75  geometry.logging.log_level = LogLevel.WARNING
76  main.add_module(geometry)
77 
78 # The ecl background module is a HistoModule. Any histogram registered in it will be written to file by the HistoManager module
79 histo = register_module('HistoManager') # Histogram Manager
80 histo.param('histoFileName', outfile)
81 main.add_module(histo)
82 
83 # ecl Background study module
84 eclBg = register_module('ECLBackground')
85 eclBg.param('sampleTime', sampletime)
86 eclBg.param('doARICH', ARICH)
87 eclBg.param('crystalsOfInterest', [318, 625, 107]) # If you want the dose for specific crystals, put the cell ID here
88 
89 # Digitization
90 eclDigi = register_module('ECLDigitizer')
91 main.add_module(eclDigi)
92 
93 # ECL reconstruction
94 add_ecl_modules
95 
96 # Background
97 main.add_module(eclBg)
98 
99 # run it
100 process(main)
101 
102 print(statistics)