CMS 3D CMS Logo

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