Belle II Software development
TestNoiseCalibration.py
1#!/usr/bin/env python3
2
3
10
11"""Test implementation of pure CsI digitization and waveform fit
12
13Input:
14 No file is required
15
16Output:
17 Mdst file
18
19Usage:
20 $ basf2 TestNoiseCalibration.py -- --outputFileName <name>
21 --elecNoise <float> --photoStatResolution <float>
22 [--beamBkgPath <path_to_files>]
23"""
24
25import glob
26import argparse
27import basf2 as b2
28from simulation import add_simulation
29from reconstruction import add_reconstruction
30from mdst import add_mdst_output
31
32
33def argparser():
34
35 parser = argparse.ArgumentParser()
36
37 parser.add_argument('--outputFileName',
38 required=True,
39 help='Output file name')
40
41 parser.add_argument('--elecNoise',
42 type=float,
43 required=True,
44 help='Electronics noise energy equivalent in MeV')
45
46 parser.add_argument('--photoStatResolution',
47 type=float,
48 required=True,
49 help='Sigma for 1 MeV energy deposit')
50
51 parser.add_argument('--beamBkgPath',
52 help='If you want to add beam background, pass this'
53 'option with path to beam background files.')
54 return parser
55
56
57args = argparser().parse_args()
58
59b2.set_log_level(b2.LogLevel.ERROR)
60
61# Create path. Register necessary modules to this path.
62mainPath = b2.create_path()
63
64# Register and add 'EventInfoSetter' module and settings
65eventInfoSetter = b2.register_module('EventInfoSetter')
66eventInfoSetter.param({'evtNumList': [10],
67 'runList': [1],
68 'expList': [0]})
69mainPath.add_module(eventInfoSetter)
70
71if args.beamBkgPath:
72 # Add beam background
73 bgFiles = glob.glob(args.beamBkgPath + '/*.root')
74 # Add simulation
75 add_simulation(mainPath, bkgfiles=bgFiles, components='ECL')
76else:
77 add_simulation(mainPath, components='ECL')
78
79# Add reconstruction
80add_reconstruction(mainPath)
81
82# Register and add 'ECLDigitizerPureCsI' module and settings
83eclDigitizerPureCsI = b2.register_module('ECLDigitizerPureCsI')
84eclDigitizerPureCsI.param('Calibration', 1)
85eclDigitizerPureCsI.param('elecNoise', args.elecNoise)
86eclDigitizerPureCsI.param('photostatresolution',
87 args.photoStatResolution)
88eclDigitizerPureCsI.param('sigmaTrigger', 0)
89eclDigitizerPureCsI.param('LastRing', 12)
90mainPath.add_module(eclDigitizerPureCsI)
91
92# Register and add 'EclCovMatrixNtuple' module and settings
93eclCovMatrixNtuple = b2.register_module('EclCovMatrixNtuple')
94eclCovMatrixNtuple.param('dspArrayName', 'ECLDspsPureCsI')
95eclCovMatrixNtuple.param('digiArrayName', 'ECLDigitsPureCsI')
96eclCovMatrixNtuple.param('outputFileName',
97 args.outputFileName)
98mainPath.add_module(eclCovMatrixNtuple)
99
100add_mdst_output(mainPath, additionalBranches=['ECLDspsPureCsI'])
101
102# Process the events and print call statistics
103mainPath.add_module('Progress')
104b2.process(mainPath)
105print(b2.statistics)