ATLAS Offline Software
getMissingFebs.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2 
3 
4 from PyCool import cool
5 import ROOT
6 import sys
7 
8 # Make sure the dictionary is loaded.
9 ROOT.LArBadChannel
10 
11 
12 def getMissingFebs(run, tag=None):
13 
14  if tag is None:
15  sys.path.append('/afs/cern.ch/user/a/atlcond/utils/python/')
16  from AtlCoolBKLib import resolveAlias
17  resolver=resolveAlias()
18  tag=resolver.getCurrent().replace("*","ST")
19 
20  retval=[]
21 
22  dbName="COOLOFL_LAR/CONDBR2"
23  fName="/LAR/BadChannelsOfl/MissingFEBs"
24 
25  dbSvc = cool.DatabaseSvcFactory.databaseService()
26  try:
27  db= dbSvc.openDatabase(dbName)
28  except Exception as e:
29  print ("Problems connecting to database:",e)
30  return None
31 
32 
33  print ("getMissingFEBs: Checking tag",tag,"for run",run)
34 
35  if not db.existsFolder(fName):
36  print ("ERROR: Folder",fName,"not found in ",dbName)
37  return None
38 
39  f=db.getFolder(fName)
40  if not f.existsUserTag(tag):
41  try:
42  t=f.resolveTag(tag)
43  except Exception as e:
44  print ("ERROR: Tag",tag,"not defined in folder",fName)
45  print (e)
46  return None
47  else:
48  t=tag
49 
50 
51  cl_LArBadChannelDBTools=ROOT.LArBadChannelDBTools
52  cl_AthenaAttributeList=ROOT.AthenaAttributeList
53  ms=cl_LArBadChannelDBTools.getDefaultMsgStream()
54 
55 
56 
57  ts1=cool.ValidityKey(1+(run<<32))
58  ts2=cool.ValidityKey(((run+1)<<32)-1)
59  itr=f.browseObjects(ts1,ts2,cool.ChannelSelection(0),t)
60  while itr.goToNext():
61  obj=itr.currentRef()
62  pl=obj.payload()
63  #print (obj.since(), obj.until(), pl)
64 
65  al=cl_AthenaAttributeList(pl.attributeList())
66  vect_BadFebEntry=cl_LArBadChannelDBTools.readBadFeb(al,ms)
67 
68  feblist=set()
69  for (id,mf) in vect_BadFebEntry:
70  if not mf.good():
71  feblist.add(id.get_identifier32().get_compact())
72 
73  retval.append((obj.since(), obj.until(),feblist))
74 
75  db.closeDatabase()
76  return retval
77 
78 
79 #print (getMissingFebs(201489,"COMCOND-BLKPA-006-03"))
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
python.getMissingFebs.getMissingFebs
def getMissingFebs(run, tag=None)
Definition: getMissingFebs.py:12