Belle II Software  release-08-01-10
RemoveTimingCutsFromSectorMap.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 
20 
21 import basf2 as b2
22 import sys
23 
24 # file with the sector map
25 if(len(sys.argv) <= 1):
26  print("Error: you have to specify the file the SectorMap is stored in!")
27  exit(1)
28 sectorMapFile = sys.argv[1]
29 
30 # this should currently be the only setup used in reconstruction
31 setupToRead = "SVDOnlyDefault"
32 # the second parameter is interpreted as setup to read
33 if(len(sys.argv) > 2):
34  setupToRead = sys.argv[2]
35 
36 # read the sectormap from file
37 SMBSM1 = b2.register_module("SectorMapBootstrap")
38 SMBSM1.param("ReadSecMapFromDB", False)
39 SMBSM1.param("ReadSectorMap", True)
40 SMBSM1.param("SectorMapsInputFile", sectorMapFile)
41 SMBSM1.param("SetupToRead", setupToRead)
42 
43 # assumes it is a root file so replace the last 5 letters
44 outputMapFile = sectorMapFile[:-5] + '_timingRemoved.root'
45 # the following setting will make the module write the altered sectormap to a root file
46 SMBSM1.param("SectorMapsOutputFile", outputMapFile)
47 SMBSM1.param("WriteSectorMap", True)
48 
49 
52 
53 # NOTE: the indizes in the example below may have changed if the code changed! So you have to cross check!
54 
55 # three hit filter
56 # (#19 <= DistanceInTime <= #20)
57 SMBSM1.param('threeHitFilterAdjustFunctions', [(19, "-TMath::Infinity()"), (20, "TMath::Infinity()")])
58 # two hit filters:
59 # (#12 <= DistanceInTimeUside <= #13)
60 # (#10 <= DistanceInTimeVside <= #11)
61 SMBSM1.param('twoHitFilterAdjustFunctions', [(12, "-TMath::Infinity()"), (13, "TMath::Infinity()"),
62  (10, "-TMath::Infinity()"), (11, "TMath::Infinity()")])
63 
64 # this will, in addition to other debbugging output, print the original filter ("BEFORE")
65 # and the altered filter ("AFTER") to the screen.
66 # NOTE: there are order of 10th of thousends of filters both for 2-hits and 3-hits. So expect lots of output.
67 # SMBSM1.logging.log_level = LogLevel.DEBUG
68 
69 
70 # needed else no sectormap from DB can be loaded
71 eventinfosetter = b2.register_module('EventInfoSetter')
72 
73 # create path
74 main = b2.create_path()
75 main.add_module(eventinfosetter)
76 main.add_module(SMBSM1)
77 b2.print_path(main)
78 # run path
79 b2.process(main)
80 print(b2.statistics)