CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/Alignment/MuonAlignmentAlgorithms/scripts/reportVsReport.py

Go to the documentation of this file.
00001 #! /usr/bin/env python
00002 
00003 import sys, optparse
00004 
00005 copyargs = sys.argv[:]
00006 
00007 for i in range(len(copyargs)):
00008   if copyargs[i] == "":             copyargs[i] = "\"\""
00009   if copyargs[i].find(" ") != -1:   copyargs[i] = "\"%s\"" % copyargs[i]
00010 commandline = " ".join(copyargs)
00011 print commandline
00012 
00013 prog = sys.argv[0]
00014 
00015 usage = """Usage:
00016 %(prog)s [options] reportX.py reportY.py
00017 
00018 Draws a scatterplot of delta corrections from reportX vs. from reportY.
00019 """ % vars()
00020 
00021 parser = optparse.OptionParser(usage)
00022 parser.add_option("-o", "--output",
00023                   help="plots' file name. If not give, an automatic file name would be given as reportVsReport_label_selection.png",
00024                   type="string",
00025                   default="",
00026                   dest="filename")
00027 parser.add_option("-l", "--label",
00028                   help="label for an automatic filename",
00029                   type="string",
00030                   default="",
00031                   dest="label")
00032 parser.add_option("-s", "--selection",
00033                    help="is one of the following: ALL, DT, CSC, CSCE1, CSCE2",
00034                    type="string",
00035                    default="ALL",
00036                    dest="selection")
00037 parser.add_option("-x", "--xlabel",
00038                    help="prefix to add to plots' X axis",
00039                    type="string",
00040                    default="None",
00041                    dest="xlabel")
00042 parser.add_option("-y", "--ylabel",
00043                    help="prefix to add to plots' Y axis",
00044                    type="string",
00045                    default="None",
00046                    dest="ylabel")
00047 parser.add_option("-w", "--which",
00048                    help="binary mask for which variables to draw, defauls is 110011",
00049                    type="string",
00050                    default="110011",
00051                    dest="which")
00052                    
00053 options, args = parser.parse_args(sys.argv[1:])
00054 
00055 if len(args)!=2:   print usage; sys.exit()
00056 
00057 
00058 ### definitions of selectors:
00059 
00060 def DT(dt, wheel, station, sector): return dt == "DT"
00061 
00062 def CSC(csc, endcap, station, ring, chamber): 
00063   if csc != "CSC": return False
00064   # skip the duplicated ME1/a
00065   if station==1 and ring==4: return False
00066   # skip non-instrumented ME4/2's:
00067   if station==4 and ring==2 and ( (endcap==1 and (chamber<9 or chamber >13)) or endcap==2 ) : return False
00068   return True
00069 
00070 def CSCE1(csc, endcap, station, ring, chamber): return CSC(csc, endcap, station, ring, chamber) and endcap==1
00071 
00072 def CSCE2(csc, endcap, station, ring, chamber): return CSC(csc, endcap, station, ring, chamber) and endcap==2
00073 
00074 
00075 ### main part
00076 
00077 execfile("plotscripts.py")
00078 
00079 ROOT.gROOT.SetBatch(1)
00080 
00081 selection = options.selection
00082 if selection == 'ALL': selection = None
00083 
00084 execfile(args[0])
00085 rx = reports
00086 execfile(args[1])
00087 ry = reports
00088 
00089 if options.which.count('1')>4: c1 = ROOT.TCanvas("c1","c1",1000,800)
00090 else: c1 = ROOT.TCanvas("c1","c1",760,800)
00091 
00092 print "corrections2D(reportsX=rx, reportsY=ry, selection=%s, pre_title_x='%s', pre_title_y='%s', which='%s' )" % ( 
00093       selection, options.xlabel, options.ylabel, options.which )
00094 eval( "corrections2D(reportsX=rx, reportsY=ry, selection=%s, pre_title_x='%s', pre_title_y='%s', which='%s', canvas=c1 )" % ( 
00095       selection, options.xlabel, options.ylabel, options.which) )
00096 
00097 c1.Update()
00098 if len(options.filename)>0: filename = options.filename
00099 else: filename = "reportVsReport_"+options.label+"_"+options.selection+".png"
00100 c1.Print(filename)