CMS 3D CMS Logo

corrVsCorr.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] geometry0.xml geometryX.xml geometryY.xml
19 
20 Draws a scatterplot of delta corrections:
21 X: geometryX - geometry0
22 Y: geometryY - geometry0
23 
24 Optionally, corresponding reportX.py and reportY.py could be provided through options
25 in order to better select chambers for plotting.
26 """ % vars()
27 
28 parser = optparse.OptionParser(usage)
29 parser.add_option("--rx",
30  help="report.py that corresponds to geometryX.xml",
31  type="string",
32  default="None",
33  dest="rx")
34 parser.add_option("--ry",
35  help="report.py that corresponds to geometryY.xml",
36  type="string",
37  default="None",
38  dest="ry")
39 parser.add_option("-o", "--output",
40  help="plots' file name. If not give, an automatic file name would be given as corrVsCorr_label_selection.png",
41  type="string",
42  default="",
43  dest="filename")
44 parser.add_option("-l", "--label",
45  help="label for an automatic filename",
46  type="string",
47  default="",
48  dest="label")
49 parser.add_option("-s", "--selection",
50  help="is one of the following: ALL, DT, CSC, CSCE1, CSCE2",
51  type="string",
52  default="ALL",
53  dest="selection")
54 parser.add_option("-x", "--xlabel",
55  help="prefix to add to plots' X axis",
56  type="string",
57  default="None",
58  dest="xlabel")
59 parser.add_option("-y", "--ylabel",
60  help="prefix to add to plots' Y axis",
61  type="string",
62  default="None",
63  dest="ylabel")
64 parser.add_option("-w", "--which",
65  help="binary mask for which variables to draw, defauls is 110011",
66  type="string",
67  default="110011",
68  dest="which")
69 
70 options, args = parser.parse_args(sys.argv[1:])
71 
72 if len(args)!=3: print(usage); sys.exit()
73 
74 
75 ### definitions of selectors:
76 
77 def DT(dt, wheel, station, sector): return dt == "DT"
78 
79 def CSC(csc, endcap, station, ring, chamber):
80  if csc != "CSC": return False
81  # skip the duplicated ME1/a
82  if station==1 and ring==4: return False
83  # skip non-instrumented ME4/2's:
84  if station==4 and ring==2 and ( (endcap==1 and (chamber<9 or chamber >13)) or endcap==2 ) : return False
85  #if ring!=1: return False
86  return True
87 
88 def CSCE1(csc, endcap, station, ring, chamber): return CSC(csc, endcap, station, ring, chamber) and endcap==1
89 
90 def CSCE2(csc, endcap, station, ring, chamber): return CSC(csc, endcap, station, ring, chamber) and endcap==2
91 
92 
93 ### main part
94 
95 execfile("geometryXMLparser.py")
96 execfile("plotscripts.py")
97 
98 ROOT.gROOT.SetBatch(1)
99 
100 selection = options.selection
101 if selection == 'ALL': selection = None
102 
103 rx = ry = None
104 if options.rx != "None" and options.ry != "None":
105  execfile(options.rx)
106  rx = reports
107  execfile(options.rx)
108  ry = reports
109 
110 g0 = MuonGeometry(args[0])
111 gX = MuonGeometry(args[1])
112 gY = MuonGeometry(args[2])
113 
114 if options.which.count('1')>4: c1 = ROOT.TCanvas("c1","c1",1000,800)
115 else: c1 = ROOT.TCanvas("c1","c1",760,800)
116 
117 print("corrections2D(reportsX=rx, reportsY=ry, geometry0=g0, geometryX=gX, geometryY=gY, selection=%s, pre_title_x='%s', pre_title_y='%s', which='%s' )" % (
118  selection, options.xlabel, options.ylabel, options.which ))
119 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 )" % (
120  selection, options.xlabel, options.ylabel, options.which) )
121 
122 c1.Update()
123 if len(options.filename)>0: filename = options.filename
124 else: filename = "corrVsCorr_"+options.label+"_"+options.selection+".png"
125 c1.Print(filename)
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
def DT(dt, wheel, station, sector)
definitions of selectors:
Definition: corrVsCorr.py:77
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def CSCE2(csc, endcap, station, ring, chamber)
Definition: corrVsCorr.py:90
def CSC(csc, endcap, station, ring, chamber)
Definition: corrVsCorr.py:79
def CSCE1(csc, endcap, station, ring, chamber)
Definition: corrVsCorr.py:88