Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-10 22:50:02

0001 #!/usr/bin/env python3
0002 
0003 """
0004 Copied from GEMCode/GEMValidation
0005 """
0006 
0007 from ROOT import *
0008 
0009 import os
0010 import sys
0011 import ROOT
0012 ROOT.gROOT.SetBatch(1)
0013 
0014 import optparse
0015 
0016 range_min =0
0017 range_max =0 
0018 
0019 def draw_col_userRange( target_dir, h, min, max,ext =".png", opt = "colz"):
0020   gStyle.SetOptStat(0)
0021   c = TCanvas(h.GetTitle(),h.GetName(),1600,1600)
0022   c_title = c.GetTitle()
0023   c.Clear()
0024   if not h:
0025     sys.exit('h does not exist')
0026   h.SetLineWidth(2)
0027   h.SetLineColor(kBlue)
0028   h.SetLabelSize(0.02,"Y")
0029   h.SetLabelOffset(0,"Y")
0030   axis_title = h.GetXaxis().GetTitle()
0031   axis_title = axis_title+ "/"+str(h.GetXaxis().GetBinWidth(1))
0032   h.GetXaxis().SetTitle( axis_title)
0033   h.SetAxisRange(float(min),float(max),"X")
0034   h.Draw(opt)
0035   c.SaveAs(target_dir + c_title + ext)
0036   
0037 
0038 def draw_plot( file, tDir,oDir,min,max ) :
0039   c = TCanvas("c","c",600,600)
0040   dqm_file = TFile( file)
0041   d1 = dqm_file.Get(tDir)
0042   key_list =[]
0043 
0044   try :
0045     tlist = d1.GetListOfKeys()
0046   except :
0047     print oDir
0048     if ( oDir.find("Digi") != -1 ):
0049       tDir = "DQMData/Run 1/MuonGEMDigisV/Run summary/GEMDigiTask"
0050       d1 = dqm_file.Get(tDir)
0051       tlist = d1.GetListOfKeys()
0052     else :
0053       print "error"
0054       exit(-1)
0055   for x in tlist :
0056     key_list.append(x.GetName())
0057   for hist in key_list :
0058     if ( hist.find("geo_phi") != -1) :
0059       draw_col_userRange( oDir, d1.Get(hist),min,max)
0060 
0061 if __name__ == '__main__' :
0062   usage = ": %prog [option] DQM_filename.root\negs) ./%prog --min 14.5 --max 15.5 DQM_V0001_R000000001__Global__CMSSW_X_Y_Z__RECO.root"
0063   parser = optparse.OptionParser(usage=usage)
0064   parser.add_option("-o",dest='directory',help='Name of output directory(Default : ./)',default="./")
0065   parser.add_option("--min",dest='range_min',help='Minimum of phi degree',default=14.5)
0066   parser.add_option("--max",dest='range_max',help='Maximum of phi degree',default=15.5)
0067   options, args = parser.parse_args()
0068 
0069   print options.range_min, options.range_max
0070   min = options.range_min
0071   max = options.range_max
0072   if len(sys.argv) ==1 :
0073     parser.print_help()
0074     exit()
0075   # If no argument, default name will be used.
0076   if len(args)==0 :
0077     print "Input file name is None."
0078     print "Use default name."
0079     args.append("DQM_V0001_R000000001__Global__CMSSW_X_Y_Z__RECO.root")
0080 
0081   if len(args) != 1 : 
0082     print "Can not understand input argument"
0083     parser.print_help()
0084   
0085   steps= []
0086   steps.append("GEMDigis")
0087 
0088   for step in steps :
0089     tDir = "DQMData/Run 1/Muon%sV/Run summary/%sTask"%(step,step)
0090     oDir = options.directory
0091     os.system("mkdir -p "+oDir )
0092     draw_plot(args[0],tDir,oDir,min,max)