ATLAS Offline Software
extractOFCFlavor.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2 
3 #!/bin/env python
4 from PyCool import cool
5 
7  onlineOFCFolder="/LAR/ElecCalibFlat/OFC"
8 
9  offlineOFCFolders=["/LAR/ElecCalibOfl/OFC/PhysWave/RTM/5samples1phase","/LAR/ElecCalibOfl/OFC/PhysWave/RTM/4samples1phase"]
10 
11 
12  dbSvc = cool.DatabaseSvcFactory.databaseService()
13  try:
14  db= dbSvc.openDatabase("COOLONL_LAR/CONDBR2")
15  except Exception as e:
16  print ("ERROR: Problems connecting to database:",e)
17  return None
18 
19  if db.existsFolder(onlineOFCFolder):
20  try:
21  pFldr=db.getFolder(onlineOFCFolder)
22  currObj=pFldr.findObject(cool.ValidityKeyMax-1,0) #Check only high gain
23  pl=currObj.payload()
24  curr_nsamples=pl["nSamples"]
25  except Exception as e:
26  print ("Failed to extract data from online OFC folder")
27  print (e)
28  curr_nsamples=None
29  pass
30  else:
31  print ("ERROR: Folder",onlineOFCFolder,"doesn't exist!")
32  curr_nsamples=None
33  pass
34 
35  db.closeDatabase()
36 
37  OFCOptions=[]
38 
39  db=dbSvc.openDatabase("COOLOFL_LAR/CONDBR2")
40  #db=dbSvc.openDatabase("sqlite://;schema=freshConstants_ofl.db;dbname=CONDBR2")
41 
42  currentOFCOption=None
43  for offlineOFCFolder in offlineOFCFolders:
44  if db.existsFolder(offlineOFCFolder):
45  try:
46  pFldr=db.getFolder(offlineOFCFolder)
47  ofctaglist=pFldr.listTags()
48  except Exception as e:
49  print ("Failed to extract data from offline database")
50  print (e)
51  pass
52 
53  for t in ofctaglist:
54  if t.find("UPD3")!=-1:
55  OFCOptions+=[(offlineOFCFolder,t),]
56 
57  if curr_nsamples is not None:
58  if offlineOFCFolder.endswith("%isamples1phase" % curr_nsamples):
59  try:
60  currentOFCOption=(offlineOFCFolder,pFldr.resolveTag("LARCALIB-RUN2-00"))
61  except Exception:
62  print ("Could not resolve global tag in folder ",offlineOFCFolder)
63  pass
64  pass
65  pass #end if "%isamples1phase
66  pass #end if curr_nsamples is not None:
67  else:
68  print ("Folder",offlineOFCFolder,"does not exist")
69  pass
70  pass
71 
72 
73  print ("Current number of samples:", curr_nsamples)
74 
75  print ("OFC flavor for production [%s]: " % currentOFCOption[1])
76 
77  if "mu" in currentOFCOption[1]:
78  return 20
79  else:
80  return 0
81 
82 
83 
84 
85 
86 if __name__=="__main__":
87 
88  ofcForOnline=getOFCFlavor()
89  if ofcForOnline is None:
90  print ("Failed to get OFC/Shapes for online database")
91 
92  else:
93  print ("Mu: ",ofcForOnline)
94 
95 
python.extractOFCFlavor.getOFCFlavor
def getOFCFlavor()
Definition: extractOFCFlavor.py:6