Belle II Software  release-08-01-10
writeROISimulationParametersToDB.py
1 #!/usr/bin/env python3
2 
3 
10 
11 from ROOT import Belle2
12 
13 
14 def writeROISimulationParametersToDB(IoV=(0, 0, 0, 0),
15  enableROI: bool = True,
16  disableROIforEveryNth: int = -1) -> None:
17  """
18  run this script to create db file storing the payload information of the ROISimulationParameters
19  see `simulation/dbobjects/include/ROISimulationParameters.h` for definition of the parameters
20 
21  :param IoV: IoV for the parameters
22  :param enableROI: Enable ROI finding
23  :param disableROIforEveryNth: Disable ROI selection for every n-th event. -1 means ROI selection is always used if
24  the parameter enableROI is True.
25  """
26 
27  # just a small sanity check (expLow, runLow, expHigh, runHigh)
28  if len(IoV) != 4:
29  return
30 
31  # create the iov
32  b2IoV = Belle2.IntervalOfValidity(*IoV)
33  # and the payload object
35  # then set the parameters it contains
36  dbobj.setROIfinding(enableROI)
37  dbobj.setDisableROIforEveryNth(disableROIforEveryNth)
38 
39  # write db object to 'localdb/'
40  Belle2.Database.Instance().storeData("ROISimulationParameters", dbobj, b2IoV)
41 
42  print(f"Successfully wrote payload ROISimulationParameters with {IoV=} and \n\
43  parameters {enableROI=}, {disableROIforEveryNth=}")
44 
45 
46 if __name__ == "__main__":
47  # We want default ROI selection for experiment 0
48  writeROISimulationParametersToDB((0, 0, 0, -1), True, -1)
49  # We want default ROI selection for experiment 1003
50  writeROISimulationParametersToDB((1003, 0, 1003, -1), False, -1)
51  # We want default ROI selection for experiment 1004
52  writeROISimulationParametersToDB((1004, 0, 1004, -1), False, -1)
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