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 from __future__ import print_function
4 
5 from PyCool import cool
6 import ROOT
7 import sys
8 
9 # Make sure the dictionary is loaded.
10 ROOT.LArBadChannel
11 
12 
13 def getMissingFebs(run, tag=None):
14 
15  if tag is None:
16  sys.path.append('/afs/cern.ch/user/a/atlcond/utils/python/')
17  from AtlCoolBKLib import resolveAlias
18  resolver=resolveAlias()
19  tag=resolver.getCurrent().replace("*","ST")
20 
21  retval=[]
22 
23  dbName="COOLOFL_LAR/CONDBR2"
24  fName="/LAR/BadChannelsOfl/MissingFEBs"
25 
26  dbSvc = cool.DatabaseSvcFactory.databaseService()
27  try:
28  db= dbSvc.openDatabase(dbName)
29  except Exception as e:
30  print ("Problems connecting to database:",e)
31  return None
32 
33 
34  print ("getMissingFEBs: Checking tag",tag,"for run",run)
35 
36  if not db.existsFolder(fName):
37  print ("ERROR: Folder",fName,"not found in ",dbName)
38  return None
39 
40  f=db.getFolder(fName)
41  if not f.existsUserTag(tag):
42  try:
43  t=f.resolveTag(tag)
44  except Exception as e:
45  print ("ERROR: Tag",tag,"not defined in folder",fName)
46  print (e)
47  return None
48  else:
49  t=tag
50 
51 
52  cl_LArBadChannelDBTools=ROOT.LArBadChannelDBTools
53  cl_AthenaAttributeList=ROOT.AthenaAttributeList
54  ms=cl_LArBadChannelDBTools.getDefaultMsgStream()
55 
56 
57 
58  ts1=cool.ValidityKey(1+(run<<32))
59  ts2=cool.ValidityKey(((run+1)<<32)-1)
60  itr=f.browseObjects(ts1,ts2,cool.ChannelSelection(0),t)
61  while itr.goToNext():
62  obj=itr.currentRef()
63  pl=obj.payload()
64  #print (obj.since(), obj.until(), pl)
65 
66  al=cl_AthenaAttributeList(pl.attributeList())
67  vect_BadFebEntry=cl_LArBadChannelDBTools.readBadFeb(al,ms)
68 
69  feblist=set()
70  for (id,mf) in vect_BadFebEntry:
71  if not mf.good():
72  feblist.add(id.get_identifier32().get_compact())
73 
74  retval.append((obj.since(), obj.until(),feblist))
75 
76  db.closeDatabase()
77  return retval
78 
79 
80 #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:13