Belle II Software  release-08-01-10
AlterVXDTF2FilterCuts.py
1 #!/usr/bin/env python3
2 
3 
10 
11 
17 
18 import basf2 as b2
19 
20 
21 # The SectorMapBootstrap module will take care for the alterations.
22 # So create one for this example which will read the current sectormap from the
23 # database, alters some parameters, and writes the altered sectormap to a root
24 # file. The sectormap in the root file then can be compared to the original sectormap (also
25 # in a root file). If you want to read a sectormap from a root file please change
26 # the parameters accordingly.
27 SMBSM1 = b2.register_module("SectorMapBootstrap")
28 SMBSM1.param("ReadSecMapFromDB", True)
29 SMBSM1.param("ReadSectorMap", False)
30 SMBSM1.param("SectorMapsInputFile", "SVDSectorMap_v000.root")
31 SMBSM1.param("SetupToRead", "SVDOnlyDefault")
32 
33 # the following setting will make the module write the altered sectormap to a root file
34 SMBSM1.param("SectorMapsOutputFile", "testMap.root")
35 SMBSM1.param("WriteSectorMap", True)
36 
37 
40 
41 # To change cutvalues of filters you have to provide a list (int, string) to the SectorMapBootstrap module which
42 # tells it which variables in the filters to change and how. The int is the index of the cut value you want to change
43 # and the string is a descriptor for a TF1 root function.
44 # The index you can find out by looking into the documentation for the SectorMapBootstrap module ( basf2 -m SectorMapBootstrap ).
45 # For the descriptor of the function one can use any regex which works with a TF1. The assumption
46 # is that "x" is the current cut value and "[0]" (0th parameter) is the FullSecID the filter is attached
47 # to. Examples for functions are (they dont make sense): "sin(x)", "12", "x + [0]", ...
48 
49 # NOTE: the indizes in the example below may have changed if the code changed! So you have to cross check!
50 
51 # Some example alterations for the two hit filters:
52 # - set min max of DistanceInTimeUside to +/- inf (index 12 min, index 13 max)
53 # - Distance1DZ; shift min by -4 (index 4), shift max by +4 (index 5)
54 SMBSM1.param("twoHitFilterAdjustFunctions", [(12, "-TMath::Infinity()"), (13, "TMath::Infinity()"), (4, "x-4"), (5, "x+4")])
55 
56 # Some example alterations of the three hit filters:
57 # - set CircleRadius low bound to 0 (index 0), shift upper bound by +3 (index 1)
58 # - set CosAngleXY low bound to the FullSecID of the static sector it is attached to (index 15)
59 SMBSM1.param("threeHitFilterAdjustFunctions", [(0, "0"), (1, "x+3"), (15, "[0]")])
60 
61 # this will, in addition to other debbugging output, print the original filter ("BEFORE")
62 # and the altered filter ("AFTER") to the screen.
63 # NOTE: there are order of 10th of thousends of filters both for 2-hits and 3-hits. So expect lots of output.
64 SMBSM1.logging.log_level = b2.LogLevel.DEBUG
65 
66 
67 # needed else no sectormap from DB can be loaded
68 eventinfosetter = b2.register_module('EventInfoSetter')
69 
70 # create path
71 main = b2.create_path()
72 main.add_module(eventinfosetter)
73 main.add_module(SMBSM1)
74 b2.print_path(main)
75 # run path
76 b2.process(main)
77 print(b2.statistics)