CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/DQM/SiStripMonitorClient/scripts/getGTfromDQMFile.py

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