CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/DQM/SiStripMonitorClient/scripts/getGTfromDQMFile.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 from math import *
00003 from ROOT import TFile, TObject, TTree
00004 from array import array
00005 from ROOT import gDirectory
00006 import sys
00007 import os
00008 
00009 DQMfile = sys.argv[1]
00010 RunNumber = sys.argv[2]
00011 globalTagVar = sys.argv[3]
00012 
00013 if not os.path.isfile(DQMfile):
00014 #    print "Error: file", DQMfile, "not found, exit" 
00015     sys.exit(0)
00016 
00017 
00018 
00019 thefile = TFile( DQMfile )
00020 globalTagDir = 'DQMData/Run ' + RunNumber + '/Info/Run summary/CMSSWInfo'
00021 
00022 if not gDirectory.GetDirectory( globalTagDir ):
00023 #    print "Warning: globalTag not found in DQM file"
00024     sys.exit(0)    
00025 
00026 keys = gDirectory.GetDirectory( globalTagDir ).GetListOfKeys()
00027 
00028 key = keys[0]
00029 globalTag = ''
00030 while key:
00031     obj = key.ReadObj()
00032     if globalTagVar in obj.GetName():
00033         globalTag = obj.GetName()[len("<"+globalTagVar+">s="):-len("</"+globalTagVar+">")]
00034         break
00035     key = keys.After(key)
00036 
00037 if len(globalTag) > 1:
00038     print globalTag