ATLAS Offline Software
linkDummyTags.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2 
3 #
4 # File: CaloClusterCorrection/python/linkDummyTags.py
5 # Created: Aug 2010, sss
6 # Purpose:
7 #
8 
9 from __future__ import print_function
10 
11 
12 import CoolConvUtilities.AtlCoolLib as AtlCoolLib
13 import os
14 
15 
16 def get_htags (folder):
17  connstring = 'COOLOFL_CALO/OFLP200'
18  db = AtlCoolLib.indirectOpen (connstring, True, True)
19  parent = os.path.dirname (folder)
20  fs = db.getFolderSet (parent)
21  tags = fs.listTags()
22  subf = db.getFolder (folder)
23  htags = []
24  for t in tags:
25  try:
26  subf.resolveTag(t)
27  except Exception:
28  htags.append (t)
29 
30  tags = subf.listTags()
31  dtag = None
32  for t in tags:
33  if t.endswith ('-dummy'):
34  dtag = t
35  break
36  return (htags, dtag)
37 
38 
39 def link_tag (f, htag, dtag):
40  try:
41  f.findTagRelation(htag)
42  f.deleteTagRelation(htag)
43  except Exception:
44  pass
45  f.createTagRelation (htag, dtag)
46  print ('Linked', htag)
47  return
48 
49 
50 def linkDummy (dbfile, folder):
51  htags, dtag = get_htags (folder)
52 
53  if dbfile.endswith ('.db'):
54  connstring = "sqlite://;schema=%s;dbname=OFLP200" % dbfile
55  else:
56  connstring = dbfile
57  db = AtlCoolLib.indirectOpen(connstring,False,True)
58  f = db.getFolder (folder)
59  for h in htags:
60  link_tag (f, h, dtag)
61 
62 
63 linkDummy ('swcool.db', '/CALO/Ofl/CaloSwClusterCorrections/deadOTXps')
linkDummyTags.get_htags
def get_htags(folder)
Definition: linkDummyTags.py:16
linkDummyTags.link_tag
def link_tag(f, htag, dtag)
Definition: linkDummyTags.py:39
linkDummyTags.linkDummy
def linkDummy(dbfile, folder)
Definition: linkDummyTags.py:50