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