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