CMS 3D CMS Logo

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