File indexing completed on 2024-11-25 02:29:04
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] geometry0.xml geometryX.xml geometryY.xml
0018
0019 Draws a scatterplot of delta corrections:
0020 X: geometryX - geometry0
0021 Y: geometryY - geometry0
0022
0023 Optionally, corresponding reportX.py and reportY.py could be provided through options
0024 in order to better select chambers for plotting.
0025 """ % vars()
0026
0027 parser = optparse.OptionParser(usage)
0028 parser.add_option("--rx",
0029 help="report.py that corresponds to geometryX.xml",
0030 type="string",
0031 default="None",
0032 dest="rx")
0033 parser.add_option("--ry",
0034 help="report.py that corresponds to geometryY.xml",
0035 type="string",
0036 default="None",
0037 dest="ry")
0038 parser.add_option("-o", "--output",
0039 help="plots' file name. If not give, an automatic file name would be given as corrVsCorr_label_selection.png",
0040 type="string",
0041 default="",
0042 dest="filename")
0043 parser.add_option("-l", "--label",
0044 help="label for an automatic filename",
0045 type="string",
0046 default="",
0047 dest="label")
0048 parser.add_option("-s", "--selection",
0049 help="is one of the following: ALL, DT, CSC, CSCE1, CSCE2",
0050 type="string",
0051 default="ALL",
0052 dest="selection")
0053 parser.add_option("-x", "--xlabel",
0054 help="prefix to add to plots' X axis",
0055 type="string",
0056 default="None",
0057 dest="xlabel")
0058 parser.add_option("-y", "--ylabel",
0059 help="prefix to add to plots' Y axis",
0060 type="string",
0061 default="None",
0062 dest="ylabel")
0063 parser.add_option("-w", "--which",
0064 help="binary mask for which variables to draw, defauls is 110011",
0065 type="string",
0066 default="110011",
0067 dest="which")
0068
0069 options, args = parser.parse_args(sys.argv[1:])
0070
0071 if len(args)!=3: print(usage); sys.exit()
0072
0073
0074
0075
0076 def DT(dt, wheel, station, sector): return dt == "DT"
0077
0078 def CSC(csc, endcap, station, ring, chamber):
0079 if csc != "CSC": return False
0080
0081 if station==1 and ring==4: return False
0082
0083 if station==4 and ring==2 and ( (endcap==1 and (chamber<9 or chamber >13)) or endcap==2 ) : return False
0084
0085 return True
0086
0087 def CSCE1(csc, endcap, station, ring, chamber): return CSC(csc, endcap, station, ring, chamber) and endcap==1
0088
0089 def CSCE2(csc, endcap, station, ring, chamber): return CSC(csc, endcap, station, ring, chamber) and endcap==2
0090
0091
0092
0093
0094 execfile("geometryXMLparser.py")
0095 execfile("plotscripts.py")
0096
0097 ROOT.gROOT.SetBatch(1)
0098
0099 selection = options.selection
0100 if selection == 'ALL': selection = None
0101
0102 rx = ry = None
0103 if options.rx != "None" and options.ry != "None":
0104 execfile(options.rx)
0105 rx = reports
0106 execfile(options.rx)
0107 ry = reports
0108
0109 g0 = MuonGeometry(args[0])
0110 gX = MuonGeometry(args[1])
0111 gY = MuonGeometry(args[2])
0112
0113 if options.which.count('1')>4: c1 = ROOT.TCanvas("c1","c1",1000,800)
0114 else: c1 = ROOT.TCanvas("c1","c1",760,800)
0115
0116 print("corrections2D(reportsX=rx, reportsY=ry, geometry0=g0, geometryX=gX, geometryY=gY, selection=%s, pre_title_x='%s', pre_title_y='%s', which='%s' )" % (
0117 selection, options.xlabel, options.ylabel, options.which ))
0118 eval( "corrections2D(reportsX=rx, reportsY=ry, geometry0=g0, geometryX=gX, geometryY=gY, selection=%s, pre_title_x='%s', pre_title_y='%s', which='%s', canvas=c1 )" % (
0119 selection, options.xlabel, options.ylabel, options.which) )
0120
0121 c1.Update()
0122 if len(options.filename)>0: filename = options.filename
0123 else: filename = "corrVsCorr_"+options.label+"_"+options.selection+".png"
0124 c1.Print(filename)