Belle II Software  release-05-01-25
beamBkgHitRates_MC.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 import basf2
5 from simulation import add_simulation
6 from pxd import add_pxd_reconstruction
7 from svd import add_svd_reconstruction
8 import os
9 import glob
10 import sys
11 
12 # ---------------------------------------------------------------------------------------
13 # Example of producing summary ntuple of beam background hit rates on MC using BG overlay
14 #
15 # This example is for nominal phase-3.
16 # For phase-2 or early phase-3 one should replace 'expList' with 1002 or 1003, resp.,
17 # and use the corresponding BG overlay samples (e.g. redefine BELLE2_BACKGROUND_DIR)
18 #
19 # usage: basf2 beamBkgHitRates_MC.py
20 # ---------------------------------------------------------------------------------------
21 
22 
23 if 'BELLE2_BACKGROUND_DIR' not in os.environ:
24  B2ERROR('BELLE2_BACKGROUND_DIR variable is not set - it must contain the path to BG overlay samples')
25  sys.exit()
26 
27 # background overlay files
28 bg = glob.glob(os.environ['BELLE2_BACKGROUND_DIR'] + '/*.root')
29 if len(bg) == 0:
30  B2ERROR('No files found in ', os.environ['BELLE2_BACKGROUND_DIR'])
31  sys.exit()
32 
33 # Create path
34 main = basf2.create_path()
35 
36 # Set number of events to generate
37 eventinfosetter = basf2.register_module('EventInfoSetter')
38 eventinfosetter.param({'evtNumList': [1000], 'runList': [0], 'expList': [0]})
39 main.add_module(eventinfosetter)
40 
41 # Simulation
42 add_simulation(main, bkgfiles=bg, bkgOverlay=True)
43 
44 # additional modules, if needed for hit processing
45 main.add_module("ARICHFillHits")
46 main.add_module('TOPChannelMasker')
47 add_pxd_reconstruction(main)
48 add_svd_reconstruction(main)
49 main.add_module('SVDZeroSuppressionEmulator', SNthreshold=5, ShaperDigitsIN='SVDShaperDigitsZS5')
50 
51 # Bkg rate monitor: output to flat ntuple
52 # - all trigger types must be selected since no TRGSummary is given by the simulation
53 main.add_module('BeamBkgHitRateMonitor',
54  trgTypes=[],
55  svdShaperDigitsName='SVDShaperDigitsZS5',
56  outputFileName='beamBkgHitRates_MC.root')
57 
58 # Show progress of processing
59 main.add_module('Progress')
60 
61 # Process events
62 basf2.process(main)
63 
64 # Print call statistics
65 print(basf2.statistics)
basf2.process
def process(path, max_event=0)
Definition: __init__.py:25