CMS 3D CMS Logo

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