CMS 3D CMS Logo

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