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