Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:47

0001 #! /usr/bin/env python3
0002 
0003 from __future__ import print_function
0004 from builtins import range
0005 import sys, optparse
0006 
0007 copyargs = sys.argv[:]
0008 
0009 for i in range(len(copyargs)):
0010   if copyargs[i] == "":             copyargs[i] = "\"\""
0011   if copyargs[i].find(" ") != -1:   copyargs[i] = "\"%s\"" % copyargs[i]
0012 commandline = " ".join(copyargs)
0013 print(commandline)
0014 
0015 prog = sys.argv[0]
0016 
0017 usage = """Usage:
0018 %(prog)s [options] reportX.py reportY.py
0019 
0020 Draws a scatterplot of delta corrections from reportX vs. from reportY.
0021 """ % vars()
0022 
0023 parser = optparse.OptionParser(usage)
0024 parser.add_option("-o", "--output",
0025                   help="plots' file name. If not give, an automatic file name would be given as reportVsReport_label_selection.png",
0026                   type="string",
0027                   default="",
0028                   dest="filename")
0029 parser.add_option("-l", "--label",
0030                   help="label for an automatic filename",
0031                   type="string",
0032                   default="",
0033                   dest="label")
0034 parser.add_option("-s", "--selection",
0035                    help="is one of the following: ALL, DT, CSC, CSCE1, CSCE2",
0036                    type="string",
0037                    default="ALL",
0038                    dest="selection")
0039 parser.add_option("-x", "--xlabel",
0040                    help="prefix to add to plots' X axis",
0041                    type="string",
0042                    default="None",
0043                    dest="xlabel")
0044 parser.add_option("-y", "--ylabel",
0045                    help="prefix to add to plots' Y axis",
0046                    type="string",
0047                    default="None",
0048                    dest="ylabel")
0049 parser.add_option("-w", "--which",
0050                    help="binary mask for which variables to draw, defauls is 110011",
0051                    type="string",
0052                    default="110011",
0053                    dest="which")
0054                    
0055 options, args = parser.parse_args(sys.argv[1:])
0056 
0057 if len(args)!=2:   print(usage); sys.exit()
0058 
0059 
0060 ### definitions of selectors:
0061 
0062 def DT(dt, wheel, station, sector): return dt == "DT"
0063 
0064 def CSC(csc, endcap, station, ring, chamber): 
0065   if csc != "CSC": return False
0066   # skip the duplicated ME1/a
0067   if station==1 and ring==4: return False
0068   # skip non-instrumented ME4/2's:
0069   if station==4 and ring==2 and ( (endcap==1 and (chamber<9 or chamber >13)) or endcap==2 ) : return False
0070   return True
0071 
0072 def CSCE1(csc, endcap, station, ring, chamber): return CSC(csc, endcap, station, ring, chamber) and endcap==1
0073 
0074 def CSCE2(csc, endcap, station, ring, chamber): return CSC(csc, endcap, station, ring, chamber) and endcap==2
0075 
0076 
0077 ### main part
0078 
0079 execfile("plotscripts.py")
0080 
0081 ROOT.gROOT.SetBatch(1)
0082 
0083 selection = options.selection
0084 if selection == 'ALL': selection = None
0085 
0086 execfile(args[0])
0087 rx = reports
0088 execfile(args[1])
0089 ry = reports
0090 
0091 if options.which.count('1')>4: c1 = ROOT.TCanvas("c1","c1",1000,800)
0092 else: c1 = ROOT.TCanvas("c1","c1",760,800)
0093 
0094 print("corrections2D(reportsX=rx, reportsY=ry, selection=%s, pre_title_x='%s', pre_title_y='%s', which='%s' )" % ( 
0095       selection, options.xlabel, options.ylabel, options.which ))
0096 eval( "corrections2D(reportsX=rx, reportsY=ry, selection=%s, pre_title_x='%s', pre_title_y='%s', which='%s', canvas=c1 )" % ( 
0097       selection, options.xlabel, options.ylabel, options.which) )
0098 
0099 c1.Update()
0100 if len(options.filename)>0: filename = options.filename
0101 else: filename = "reportVsReport_"+options.label+"_"+options.selection+".png"
0102 c1.Print(filename)