CMS 3D CMS Logo

getDQMSummary.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 import os, sys, re
00003 from ROOT import *
00004 
00005 # DQM Report Summary Parser ---- Yuri Gotra May-30-2008
00006 # getDQMSummary.py ~/3d/DQM_R000043434.root
00007 
00008 
00009 
00010 usage = "usage: %s <DQM_File.root>" %         os.path.basename(sys.argv[0])
00011 
00012 if len(sys.argv) < 2:
00013    print usage
00014    sys.exit(2)
00015 else:
00016    argv = sys.argv
00017    infile = argv[1]
00018    outfile = argv[2]
00019    print argv[1]
00020    f = TFile(infile, 'read')
00021    ff = open(outfile,'w')
00022 
00023 
00024 Detectors = ['Pixel', 'SiStrip', 'EcalBarrel', 'Hcal', 'DT', 'RPC', 'CSC', 'L1TEMU', 'L1T']
00025 
00026 reportSummary = "<reportSummary>"
00027 DQMDataDir = "DQMData"
00028 EventInfoDir = "/Run summary/EventInfo"
00029 ReportSummaryContentsDir = "/Run summary/EventInfo/reportSummaryContents"
00030 summary = std.vector(float)()
00031 reportSummaryContents = std.vector(string)()
00032 f.cd(DQMDataDir)
00033 dirtmp = gDirectory
00034 dirlist = dirtmp.GetListOfKeys()
00035 iter = dirlist.MakeIterator()
00036 key = iter.Next()
00037 td = None
00038 
00039 while key:
00040    td = key.ReadObj()
00041    dirName = td.GetName()
00042    if(re.search('Run (\d+)', dirName)):
00043        rundirname = dirName
00044        break
00045    key = iter.Next()
00046 
00047 def getDQMDetSummaryResult():
00048    reportSummaryDir = DQMDataDir + '/' + rundirname + '/' + subdet + EventInfoDir
00049    f.cd(reportSummaryDir)
00050    reportSummaryDir = gDirectory
00051    dirlist = reportSummaryDir.GetListOfKeys()
00052    iter = dirlist.MakeIterator()
00053    key = iter.Next()
00054    tk = None
00055    while key:
00056        tk = key.ReadObj()
00057        keyName = tk.GetName()
00058        if(re.search(reportSummary, keyName)):
00059            ms = re.split('=', keyName)
00060            m = re.search('-?\d?\.?\d+', ms[1])
00061            detsummary = m.group(0)
00062            break
00063        key = iter.Next()
00064    return detsummary
00065 
00066 def getDQMSegSummaryResult():
00067    SummaryContentsDir = DQMDataDir + '/' + rundirname + '/' + subdet + ReportSummaryContentsDir
00068    f.cd(SummaryContentsDir)
00069    SummaryContentsDir = gDirectory
00070    dirlist = SummaryContentsDir.GetListOfKeys()
00071    iter = dirlist.MakeIterator()
00072    key = iter.Next()
00073    tk = None
00074    while key:
00075        tk = key.ReadObj()
00076        keyName = tk.GetName()
00077        mn = re.search('(<.+?>)', keyName)
00078        if(mn):
00079            reportSummaryContent = mn.group(0)
00080            ms = re.split('=', keyName)
00081            m = re.search('-?\d?\.?\d+', ms[1])
00082            segsummary = m.group(0)
00083            summary.push_back(float(segsummary))
00084            reportSummaryContents.push_back(reportSummaryContent)
00085        key = iter.Next()
00086    return reportSummaryContents, summary
00087 
00088 for subdet in Detectors:
00089    print >>ff, '============================'
00090    print >>ff, rundirname, subdet
00091    getDQMSegSummaryResult()
00092    summary.push_back(float(getDQMDetSummaryResult()))
00093    reportSummaryContents.push_back(reportSummary)
00094    j = 0
00095    for i in summary:
00096        print >> ff, reportSummaryContents[j], int(1000*i)
00097        j = j + 1
00098    summary.clear()
00099    reportSummaryContents.clear()
00100 print >> ff, '============================' 

Generated on Tue Jun 9 17:33:08 2009 for CMSSW by  doxygen 1.5.4