CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
reportVsReport.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 
3 import sys, optparse
4 
5 copyargs = sys.argv[:]
6 
7 for i in range(len(copyargs)):
8  if copyargs[i] == "": copyargs[i] = "\"\""
9  if copyargs[i].find(" ") != -1: copyargs[i] = "\"%s\"" % copyargs[i]
10 commandline = " ".join(copyargs)
11 print commandline
12 
13 prog = sys.argv[0]
14 
15 usage = """Usage:
16 %(prog)s [options] reportX.py reportY.py
17 
18 Draws a scatterplot of delta corrections from reportX vs. from reportY.
19 """ % vars()
20 
21 parser = optparse.OptionParser(usage)
22 parser.add_option("-o", "--output",
23  help="plots' file name. If not give, an automatic file name would be given as reportVsReport_label_selection.png",
24  type="string",
25  default="",
26  dest="filename")
27 parser.add_option("-l", "--label",
28  help="label for an automatic filename",
29  type="string",
30  default="",
31  dest="label")
32 parser.add_option("-s", "--selection",
33  help="is one of the following: ALL, DT, CSC, CSCE1, CSCE2",
34  type="string",
35  default="ALL",
36  dest="selection")
37 parser.add_option("-x", "--xlabel",
38  help="prefix to add to plots' X axis",
39  type="string",
40  default="None",
41  dest="xlabel")
42 parser.add_option("-y", "--ylabel",
43  help="prefix to add to plots' Y axis",
44  type="string",
45  default="None",
46  dest="ylabel")
47 parser.add_option("-w", "--which",
48  help="binary mask for which variables to draw, defauls is 110011",
49  type="string",
50  default="110011",
51  dest="which")
52 
53 options, args = parser.parse_args(sys.argv[1:])
54 
55 if len(args)!=2: print usage; sys.exit()
56 
57 
58 ### definitions of selectors:
59 
60 def DT(dt, wheel, station, sector): return dt == "DT"
61 
62 def CSC(csc, endcap, station, ring, chamber):
63  if csc != "CSC": return False
64  # skip the duplicated ME1/a
65  if station==1 and ring==4: return False
66  # skip non-instrumented ME4/2's:
67  if station==4 and ring==2 and ( (endcap==1 and (chamber<9 or chamber >13)) or endcap==2 ) : return False
68  return True
69 
70 def CSCE1(csc, endcap, station, ring, chamber): return CSC(csc, endcap, station, ring, chamber) and endcap==1
71 
72 def CSCE2(csc, endcap, station, ring, chamber): return CSC(csc, endcap, station, ring, chamber) and endcap==2
73 
74 
75 ### main part
76 
77 execfile("plotscripts.py")
78 
79 ROOT.gROOT.SetBatch(1)
80 
81 selection = options.selection
82 if selection == 'ALL': selection = None
83 
84 execfile(args[0])
85 rx = reports
86 execfile(args[1])
87 ry = reports
88 
89 if options.which.count('1')>4: c1 = ROOT.TCanvas("c1","c1",1000,800)
90 else: c1 = ROOT.TCanvas("c1","c1",760,800)
91 
92 print "corrections2D(reportsX=rx, reportsY=ry, selection=%s, pre_title_x='%s', pre_title_y='%s', which='%s' )" % (
93  selection, options.xlabel, options.ylabel, options.which )
94 eval( "corrections2D(reportsX=rx, reportsY=ry, selection=%s, pre_title_x='%s', pre_title_y='%s', which='%s', canvas=c1 )" % (
95  selection, options.xlabel, options.ylabel, options.which) )
96 
97 c1.Update()
98 if len(options.filename)>0: filename = options.filename
99 else: filename = "reportVsReport_"+options.label+"_"+options.selection+".png"
100 c1.Print(filename)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
def DT
definitions of selectors:
static std::string join(char **cmd)
Definition: RemoteFile.cc:18