Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-07 22:33:03

0001 #!/usr/bin/env python3
0002 from math import *
0003 from ROOT import TFile, TObject, TTree
0004 from array import array
0005 from ROOT import gDirectory
0006 import sys
0007 import os
0008 from __future__ import print_function
0009 
0010 def getGTfromDQMFile(DQMfile, RunNumber, globalTagVar):
0011     if not os.path.isfile(DQMfile):#    print "Error: file", DQMfile, "not found, exit" 
0012         sys.exit(0)
0013     thefile = TFile( DQMfile )
0014     globalTagDir = 'DQMData/Run ' + RunNumber + '/Info/Run summary/CMSSWInfo'
0015     if not gDirectory.GetDirectory( globalTagDir ):
0016         #    print "Warning: globalTag not found in DQM file"
0017         sys.exit(0)    
0018     keys = gDirectory.GetDirectory( globalTagDir ).GetListOfKeys()
0019     key = keys[0]
0020     globalTag = ''
0021     while key:
0022         obj = key.ReadObj()
0023         if globalTagVar in obj.GetName():
0024             globalTag = obj.GetName()[len("<"+globalTagVar+">s="):-len("</"+globalTagVar+">")]
0025             break
0026         key = keys.After(key)
0027     if len(globalTag) > 1:
0028         if globalTag.find('::') >= 0: 
0029             print(globalTag[0:globalTag.find('::')])
0030         else:
0031             print(globalTag)
0032     return globalTag
0033