Belle II Software development
DownloadableDatabase Class Reference

Public Member Functions

def __init__ (self, command_argument)
 
def set_database (self)
 
def get_all_cuts (self)
 

Protected Attributes

 _database
 the specified databases
 
 _experiment
 the experiment number, default (= latest) is 99999
 
 _run
 the run number, default (= latest) is 99999
 

Detailed Description

Helper class to translate the user-specified database(s) into parameters for basf2

Definition at line 30 of file cli.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  command_argument 
)
Init the stored databases and exp/run from the specified command argument

Definition at line 33 of file cli.py.

33 def __init__(self, command_argument):
34 """Init the stored databases and exp/run from the specified command argument"""
35
36 self._database = []
37
38 self._experiment = 99999
39
40 self._run = 99999
41
42 # If given, use the experiment run from the command_argument
43 split_argument = command_argument.split(":")
44 if len(split_argument) == 2:
45 command_argument, exp_run = split_argument
46
47 if exp_run != "latest":
48 try:
49 self._experiment, self._run = map(int, exp_run.split("/"))
50 except BaseException:
51 raise argparse.ArgumentTypeError(
52 f"Do not understand the exp/run argument '{exp_run}'")
53
54 elif len(split_argument) != 1:
55 raise argparse.ArgumentTypeError(
56 f"Do not understand the database argument '{command_argument}'")
57
58 # Now split up the databases
59 self._database = command_argument.split(",")
60
61 # However make sure we have them in the correct format
62 def normalize(database):
63 # In case a local file is specified we can just use it directly
64 if os.path.exists(database):
65 if os.path.basename(database) != "database.txt":
66 database = os.path.join(database, "database.txt")
67
68 return database
69
70 self._database = list(map(normalize, self._database))
71

Member Function Documentation

◆ get_all_cuts()

def get_all_cuts (   self)
Get all cuts stored in the database(s)
and sort them according to base_identifier, cut_identifier.

Definition at line 94 of file cli.py.

94 def get_all_cuts(self):
95 """
96 Get all cuts stored in the database(s)
97 and sort them according to base_identifier, cut_identifier.
98 """
99 self.set_database()
100
101 all_cuts = db_access.get_all_cuts()
102 all_cuts = sorted(all_cuts,
103 key=lambda cut: (cut["Base Identifier"], cut["Cut Identifier"]))
104 all_cuts = list(map(HashableCut, all_cuts))
105 return all_cuts
106
107

◆ set_database()

def set_database (   self)
Set the basf2 database chain according to the specified databases.
Before that, clean up and invalidate everything from th database.

The distinction between file databases and global databases is done
via the fact of a file/folder with this name exists or not.

Definition at line 72 of file cli.py.

72 def set_database(self):
73 """
74 Set the basf2 database chain according to the specified databases.
75 Before that, clean up and invalidate everything from th database.
76
77 The distinction between file databases and global databases is done
78 via the fact of a file/folder with this name exists or not.
79 """
80 from ROOT import Belle2
82
83 basf2.conditions.override_globaltags()
84
85 for database in self._database:
86 if os.path.exists(database):
87 basf2.conditions.prepend_testing_payloads(database)
88 else:
89 basf2.conditions.prepend_globaltag(database)
90
91 db_access.set_event_number(evt_number=0, run_number=int(self._run),
92 exp_number=int(self._experiment))
93
static DBStore & Instance()
Instance of a singleton DBStore.
Definition: DBStore.cc:28

Member Data Documentation

◆ _database

_database
protected

the specified databases

Definition at line 36 of file cli.py.

◆ _experiment

_experiment
protected

the experiment number, default (= latest) is 99999

Definition at line 38 of file cli.py.

◆ _run

_run
protected

the run number, default (= latest) is 99999

Definition at line 40 of file cli.py.


The documentation for this class was generated from the following file: