SND@LHC Software
Loading...
Searching...
No Matches
getconditions_condDB.py
Go to the documentation of this file.
7from __future__ import print_function, division
8from factory import APIFactory
9import datetime, sys
10
11
12from builtins import range
13import operator
14from argparse import ArgumentParser
15from array import array
16import os,ROOT, getopt
17
18level=0
19try:
20 opts, args = getopt.getopt(sys.argv[1:], "l:s:",[])
21except getopt.GetoptError:
22 # print help information and exit:
23 print(' enter -l: level or -s: subdetector')
24 sys.exit()
25
26for o, a in opts:
27 if o in ("-l",):
28 level = int(a)
29 if o in ("-s",):
30 sd = str(a)
31
32# Instantiate an API factory
33api_factory = APIFactory()
34# Call construct_DB_API to get an CDB API instance, the path must lead to a valid config.yml file containing the database configuration
35
36conditionsDB = api_factory.construct_DB_API("/home/eric/snd-soft-23april-2021/sndsw/conditionsDatabase/config.yml")
37
38detector=""
39count=0
40
41def showdetectors(detector,count,level):
42 #print ("showdetectors called. count=",count," level=",level)
43 # Show all detector names in the database:
44 result = conditionsDB.list_detectors(detector)
45 if len(result) > 0:
46 if detector=="":
47 print ("snd subdetectors:",result)
48 else:
49 print ("subdetectors inside",detector," :",result)
50 if count < level:
51 count+=1
52 for j in range(len(result)):
53 showdetectors(result[j],count,level)
54 else:
55 print ("No more subdetectors below subdetector/channel:",detector)
56 #print ("count=",count,"All subdetectors listed up to level",level,".")
57 return
58
59#showdetectors(detector,count,level)
60result = conditionsDB.get_conditions(sd)
61print ("Conditions of subdetector ",sd," are ",result)
62sys.exit()
This class creates an instance of the specified database API.
Definition factory.py:15