ATLAS Offline Software
Functions
python.extractFolderInfo Namespace Reference

Functions

def extractFolderInfo (dbname, globaltag="", checkFolders=[], runnumber=cool.ValidityKeyMax >>32, selection="")
 

Function Documentation

◆ extractFolderInfo()

def python.extractFolderInfo.extractFolderInfo (   dbname,
  globaltag = "",
  checkFolders = [],
  runnumber = cool.ValidityKeyMax>>32,
  selection = "" 
)

Definition at line 7 of file extractFolderInfo.py.

7 def extractFolderInfo(dbname,globaltag="",checkFolders=[],runnumber=cool.ValidityKeyMax>>32,selection=""):
8  dbSvc = cool.DatabaseSvcFactory.databaseService()
9  try:
10  db= dbSvc.openDatabase(dbname)
11  except Exception as e:
12  print ("Problems connecting to database:",e)
13  return None
14 
15  #Set up Channel Selection:
16  sel=None
17  print (selection)
18  ss=selection.split(",")
19  for s in ss:
20  if len(s)==0:continue
21  idx=s.find(":")
22  if idx==-1:
23  c1=cool.ChannelId(int(s))
24  c2=c1
25  else:
26  c1=cool.ChannelId(int(s[:idx]))
27  c2=cool.ChannelId(int(s[1+idx:]))
28  #print ("ExtractFolderInfo: Add channel range",c1,"to",c2)
29  if sel is None:
30  sel=cool.ChannelSelection(c1,c2,cool.ChannelSelection.sinceBeforeChannel)
31  else:
32  sel.addRange(c1,c2)
33 
34  if sel is None:
35  print ("ExtractFolderInfo: No COOL channel selection given, work on all channels")
36  sel=cool.ChannelSelection.all()
37 
38 
39  folderInfoList=list()
40 
41  nodelist=db.listAllNodes()
42  for fn in nodelist:
43  if not db.existsFolder(fn): continue
44  if len(checkFolders):
45  takeFolder=False
46  for cf in checkFolders:
47  if cf[-1] == "/": cf=cf[0:-1]
48  idx=len(cf)
49  pyfn=str(fn)
50  if pyfn.startswith(cf) and (idx>=len(pyfn) or pyfn[idx]=="/"):
51  takeFolder=True
52  break
53  if not takeFolder: continue
54 
55  f=db.getFolder(fn)
56  print ("Analyzing",fn)
57  #Parse Folder description:
58  #Model:
59  #<timeStamp>run-lumi</timeStamp><symlinks>ILArAutoCorr</symlinks><key>LArAutoCorr</key><addrHeader><address_header service_type="71" clid="255786016" /></addrHeader><typeName>LArAutoCorrComplete</typeName> -
60  # Get Type
61  descr=str(f.description())
62  i1=descr.find("<typeName>")+len("<typeName>")
63  i2=descr.find("</typeName>",i1)
64  if (i1==-1 or i2==-1):
65  print ("ERROR could not get typename of object stored in folder",fn)
66  continue
67  typename=descr[i1:i2]
68 
69 
70  i1=descr.find("<key>")+len("<key>")
71  i2=descr.find("</key>",i1)
72  if (i1==-1 or i2==-1):
73  print ("ERROR could not get SG key of object stored in folder",fn)
74  continue
75  key=descr[i1:i2]
76 
77 
78  #Loop over all tags
79 
80  tagList=f.listTags()
81  if len(tagList)==0:
82  tagList=[""]
83  elif len(tagList)>1 and globaltag!="":
84  try:
85  tagList=[f.resolveTag(globaltag)]
86  except Exception:
87  print ("Hierachical tag", globaltag,"not defined in folder",fn)
88  return None
89 
90  for t in tagList:
91  itr=f.findObjects(runnumber<<32,sel,t)
92  minIOV=cool.ValidityKeyMax>>32
93  maxIOV=cool.ValidityKeyMin>>32
94  #Loop over all objects to get IOV
95  while itr.goToNext():
96  obj=itr.currentRef()
97  #payload=obj.payload()
98  since=obj.since()>>32
99  until=obj.until()>>32
100  #print (fn,t,since,until)
101  if minIOV>since: minIOV=since
102  if maxIOV<until: maxIOV=until
103  itr.close()
104 
105  #Form tuple:
106  folderinfo=(str(fn),typename,key,str(t),minIOV,maxIOV)
107  folderInfoList+=[folderinfo]
108 
109  db.closeDatabase()
110  return folderInfoList
111 
112 
113 
114 #x=extractFolderInfo("sqlite://;schema=/scratch/wlampl/DBwrites/Sep13AllCalo_v2/freshConstants.db;dbname=COMP200")
115 
116 #for i in x:
117 # print (i)
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.extractFolderInfo.extractFolderInfo
def extractFolderInfo(dbname, globaltag="", checkFolders=[], runnumber=cool.ValidityKeyMax >>32, selection="")
Definition: extractFolderInfo.py:7
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
str
Definition: BTagTrackIpAccessor.cxx:11