Belle II Software development
create_mcrun.py
1#!/usr/bin/env python3
2
3
10
11# Simple basf2 steering file that creates mc file with PXDSimHits and
12# EventMetaData needed for PXD gain calibration.
13#
14# Note that this script should only be used for runs in phase2 geometry
15# with beams and magnetic field.
16#
17# Note that only SimHits from bg will be produced. A path to the mixer
18# files for phase 2 must be specified. Only use for runs with beam
19# where most clusters are from bg.
20#
21# The command below will create reference mc file for gain calibration
22# for run=3360 in exp=3 being part of the phase2 campaign.
23#
24# basf2 create_mcrun.py -- --tag='Calibration_Offline_Development' --expNo=3 --runNo=3360 --setNo=0
25
26
27import glob
28import basf2 as b2
29
30import argparse
31parser = argparse.ArgumentParser(
32 description="Create SimHits for a run with user specified ExpRun")
33parser.add_argument(
34 '--tag',
35 default='Calibration_Offline_Development',
36 type=str,
37 help='Set name of GT')
38parser.add_argument(
39 '--expNo',
40 default=3,
41 type=int,
42 help='Set experiment number')
43parser.add_argument('--runNo', default=3360, type=int, help='Set run number')
44parser.add_argument(
45 '--setNo',
46 default=0,
47 type=int,
48 help='setnumber for bg simulation')
49parser.add_argument(
50 '--bg',
51 default='/group/belle2/BGFile/OfficialBKG/15thCampaign/phase2',
52 type=str,
53 help='Path to mixer sets')
54parser.add_argument(
55 '--scaleFactor',
56 default=1.0,
57 type=float,
58 help='Scale factor for mixer')
59args = parser.parse_args()
60
61bg = glob.glob(args.bg + '/set' + str(args.setNo) + '/*.root')
62
63
64b2.reset_database()
65b2.use_central_database(args.tag)
66
67main = b2.create_path()
68main.add_module(
69 "EventInfoSetter", expList=[
70 args.expNo], runList=[
71 args.runNo], evtNumList=[1000])
72main.add_module("Gearbox", fileName='geometry/Beast2_phase2.xml')
73main.add_module("Geometry", useDB=False)
74bkgmixer = b2.register_module('BeamBkgMixer')
75bkgmixer.param('backgroundFiles', bg)
76bkgmixer.param('overallScaleFactor', args.scaleFactor)
77main.add_module(bkgmixer)
78output = main.add_module('RootOutput')
79output.param(
80 'outputFileName',
81 f'beam.{args.expNo:0>4}.{args.runNo:0>5}.HLT2.f{args.setNo:0>5}.root')
82output.param('branchNames', ['PXDSimHits', 'EventMetaData'])
83main.add_module("Progress")
84
85b2.process(main)
86print(b2.statistics)