Belle II Software development
writeROICalculationParametersToDB.py
1#!/usr/bin/env python3
2
3
10
11from ROOT import Belle2
12
13
14def writeROICalculationParametersToDB(IoV=(0, 0, 0, 0),
15 toleranceZ: float = 0.5,
16 tolerancePhi: float = 0.15,
17 sigmaSystU: float = 0.02,
18 sigmaSystV: float = 0.0,
19 numSigmaTotU: float = 10,
20 numSigmaTotV: float = 10,
21 maxWidthU: float = 0.5,
22 maxWidthV: float = 0.5,) -> None:
23 """
24 run this script to create db file storing the payload information of the ROICalculationParameters
25 see `tracking/dbobjects/include/ROICalculationParameters.h` for definition of the parameters
26
27 :param IoV: IoV for the parameters
28 :param toleranceZ: Tolerance for finding sensor in Z coordinate (cm)
29 :param m_tolerancePhi: Tolerance for finding sensor in phi coordinate (radians)
30 :param sigmaSystU: Fixed width to add in quadrature to the extrapolation error and obtain the ROI U width
31 :param sigmaSystV: Fixed width to add in quadrature to the extrapolation error and obtain the ROI V width
32 :param numSigmaTotU: Number of sigma (stat+syst) determining the U width of the ROI
33 :param numSigmaTotV: Number of sigma (stat+syst) determining the V width of the ROI
34 :param maxWidthU: Maximum U width of the ROI
35 :param maxWidthV: Maximum V width of the ROI
36 """
37
38 # just a small sanity check (expLow, runLow, expHigh, runHigh)
39 if len(IoV) != 4:
40 return
41
42 # make sure the defined parameters make sense.
43 if toleranceZ <= 0 or tolerancePhi <= 0 or sigmaSystU <= 0 or sigmaSystV <= 0 or \
44 numSigmaTotU <= 0 or numSigmaTotV <= 0 or maxWidthU <= 0 or maxWidthV <= 0:
45 print("Can't use negative parameters for any of the parameters except for disableROIforEveryNth.")
46 print(f"The values set are\n\
47 {toleranceZ=},\n\
48 {tolerancePhi=},\n\
49 {sigmaSystU=},\n\
50 {sigmaSystV=},\n\
51 {numSigmaTotU=},\n\
52 {numSigmaTotV=},\n\
53 {maxWidthU=},\n\
54 {maxWidthV=}")
55 return
56
57 # create the iov
58 b2IoV = Belle2.IntervalOfValidity(*IoV)
59 # and the payload object
61 # then set the parameters it contains
62 dbobj.setToleranceZ(toleranceZ)
63 dbobj.setTolerancePhi(tolerancePhi)
64 dbobj.setSigmaSystU(sigmaSystU)
65 dbobj.setSigmaSystV(sigmaSystV)
66 dbobj.setNumSigmaTotU(numSigmaTotU)
67 dbobj.setNumSigmaTotV(numSigmaTotV)
68 dbobj.setMaxWidthU(maxWidthU)
69 dbobj.setMaxWidthV(maxWidthV)
70
71 # write db object to 'localdb/'
72 Belle2.Database.Instance().storeData("ROICalculationParameters", dbobj, b2IoV)
73
74 print(f"Successfully wrote payload ROI parameters with {IoV=} and parameters\n\
75 {toleranceZ=}, {tolerancePhi=}, {sigmaSystU=}, {sigmaSystV=},\n\
76 {numSigmaTotU=}, {numSigmaTotV=}, {maxWidthU=}, {maxWidthV=}")
77
78
79if __name__ == "__main__":
80 # We want default ROI calculation parameters for experiment 0
81 writeROICalculationParametersToDB((0, 0, 0, -1), 0.5, 0.15, 0.02, 0.02, 10, 10, 0.5, 0.5)
82 # We want default ROI calculation parameters for experiment 1003
83 writeROICalculationParametersToDB((1003, 0, 1003, -1), 0.5, 0.15, 0.02, 0.02, 10, 10, 0.5, 0.5)
84 # We want default ROI calculation parameters for experiment 1004
85 writeROICalculationParametersToDB((1004, 0, 1004, -1), 0.5, 0.15, 0.02, 0.02, 10, 10, 0.5, 0.5)
A class that describes the interval of experiments/runs for which an object in the database is valid.
The payload containing all PXD ROI parameters.
static Database & Instance()
Instance of a singleton Database.
Definition: Database.cc:42