Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-03-03 02:23:12

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