CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
diffTwoXMLs.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 
3 import sys, ROOT
4 ROOT.gROOT.SetBatch(1)
5 
6 execfile("geometryXMLparser.py")
7 execfile("plotscripts.py")
8 
9 
10 cargs = sys.argv[:]
11 
12 if len(cargs) < 5 or len(cargs) > 7:
13  print "Draws differences between two xml geometries (or between single xml geometry and ideal) for all six variables."
14  print "usage: ./diffTwoXMLs.py label selector geom2.xml geom1.xml report2.py report1.py"
15  print "or ./diffTwoXMLs.py label selector geom2.xml geom1.xml report.py"
16  print "or ./diffTwoXMLs.py label selector geom.xml report.py"
17  print "where selector is one of ALL, DT, CSC, CSCE1, CSCE2"
18  print "The label will be included into the filename as diffTwoXMLs_label_selector.png"
19  print ""
20  print "Special consistency test mode with respect to corrections in the report:"
21  print "If the label starts with \"vsReport_\", the delta corrections from report2 would be substracted from the XML differences."
22  print "Example:"
23  print "./diffTwoXMLs.py diffReport_label selector geom2.xml geom1.xml report.py"
24  sys.exit()
25 
26 
27 def ALL(dt, wheel, station, sector): return True
28 
29 def ALL(csc, endcap, station, ring, chamber): return True
30 
31 def DT(dt, wheel, station, sector): return dt == "DT"
32 def DT_st1(dt, wheel, station, sector): return dt == "DT" and station == 1
33 def DT_st2(dt, wheel, station, sector): return dt == "DT" and station == 2
34 def DT_st3(dt, wheel, station, sector): return dt == "DT" and station == 3
35 def DT_st4(dt, wheel, station, sector): return dt == "DT" and station == 4
36 
37 def CSC(csc, endcap, station, ring, chamber): return csc == "CSC"
38 def CSCE1(csc, endcap, station, ring, chamber): return csc == "CSC" and endcap==1
39 def CSCE2(csc, endcap, station, ring, chamber): return csc == "CSC" and endcap==2
40 
41 
42 label = cargs[1]
43 diffReport = False
44 if label.find("vsReport_") == 0: diffReport = True
45 
46 selection = cargs[2]
47 
48 if len(cargs) == 5:
49  xmlfile2 = cargs[3]
50  reportfile2 = cargs[4]
51  g1 = None
52  r1 = None
53 
54 if len(cargs) == 6:
55  xmlfile2 = cargs[3]
56  xmlfile1 = cargs[4]
57  reportfile2 = cargs[5]
58  g1 = MuonGeometry(xmlfile1)
59  r1 = None
60 
61 if len(cargs) == 7:
62  xmlfile2 = cargs[3]
63  xmlfile1 = cargs[4]
64  reportfile2 = cargs[5]
65  reportfile1 = cargs[6]
66  g1 = MuonGeometry(xmlfile1)
67  execfile(reportfile1)
68  r1 = reports
69 
70 g2 = MuonGeometry(xmlfile2)
71 execfile(reportfile2)
72 r2 = reports
73 
74 c1 = ROOT.TCanvas("c1","c1",1000,600)
75 
76 if not diffReport:
77  # normal XML diff mode
78  ranges = "window=10"
79  #if selection=="DT": ranges = "windows=[25.,5,1.,1.,5.,5.]"
80  eval("DBdiff(g2, g1, r2, r1, %s, selection=%s, phi=False, bins=251)" % (ranges, selection))
81 
82 else:
83  # Special consistency test mode with respect to corrections in the report:
84  ranges = "window=0.02"
85  eval("DBdiff(g2, g1, r2, r1, %s, selection=%s, phi=False, bins=1001, reportdiff=True, inlog=True)" % (ranges, selection))
86 
87 
88 c1.Update()
89 c1.Print("diffTwoXMLs_%s_%s.png" % (label, selection))