CMS 3D CMS Logo

getGTfromDQMFile_V2.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
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 from __future__ import print_function
9 
10 def getGTfromDQMFile(DQMfile, RunNumber, globalTagVar):
11  if not os.path.isfile(DQMfile):# print "Error: file", DQMfile, "not found, exit"
12  sys.exit(0)
13  thefile = TFile( DQMfile )
14  globalTagDir = 'DQMData/Run ' + RunNumber + '/Info/Run summary/CMSSWInfo'
15  if not gDirectory.GetDirectory( globalTagDir ):
16  # print "Warning: globalTag not found in DQM file"
17  sys.exit(0)
18  keys = gDirectory.GetDirectory( globalTagDir ).GetListOfKeys()
19  key = keys[0]
20  globalTag = ''
21  while key:
22  obj = key.ReadObj()
23  if globalTagVar in obj.GetName():
24  globalTag = obj.GetName()[len("<"+globalTagVar+">s="):-len("</"+globalTagVar+">")]
25  break
26  key = keys.After(key)
27  if len(globalTag) > 1:
28  if globalTag.find('::') >= 0:
29  print(globalTag[0:globalTag.find('::')])
30  else:
31  print(globalTag)
32  return globalTag
33 
getGTfromDQMFile_V2.getGTfromDQMFile
def getGTfromDQMFile(DQMfile, RunNumber, globalTagVar)
Definition: getGTfromDQMFile_V2.py:10
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46