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