test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
getGTfromDQMFile.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 from math import *
3 from ROOT import TFile, TObject, TTree
4 from array import array
5 from ROOT import gDirectory
6 import sys
7 import os
8 
9 DQMfile = sys.argv[1]
10 RunNumber = sys.argv[2]
11 globalTagVar = sys.argv[3]
12 
13 if not os.path.isfile(DQMfile):
14 # print "Error: file", DQMfile, "not found, exit"
15  sys.exit(0)
16 
17 
18 
19 thefile = TFile( DQMfile )
20 globalTagDir = 'DQMData/Run ' + RunNumber + '/Info/Run summary/CMSSWInfo'
21 
22 if not gDirectory.GetDirectory( globalTagDir ):
23 # print "Warning: globalTag not found in DQM file"
24  sys.exit(0)
25 
26 keys = gDirectory.GetDirectory( globalTagDir ).GetListOfKeys()
27 
28 key = keys[0]
29 globalTag = ''
30 while key:
31  obj = key.ReadObj()
32  if globalTagVar in obj.GetName():
33  globalTag = obj.GetName()[len("<"+globalTagVar+">s="):-len("</"+globalTagVar+">")]
34  break
35  key = keys.After(key)
36 if len(globalTag) > 1:
37  if globalTag.find('::') >= 0:
38  print globalTag[0:globalTag.find('::')]
39  else:
40  print globalTag
41 
42