CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/Alignment/MuonAlignmentAlgorithms/scripts/diffTwoXMLs.py

Go to the documentation of this file.
00001 #! /usr/bin/env python
00002 
00003 import sys, ROOT
00004 ROOT.gROOT.SetBatch(1)
00005 
00006 execfile("geometryXMLparser.py")
00007 execfile("plotscripts.py")
00008 
00009 
00010 cargs = sys.argv[:]
00011 
00012 if len(cargs) < 5 or len(cargs) > 7:
00013   print "Draws differences between two xml geometries (or between single xml geometry and ideal) for all six variables."
00014   print "usage: ./diffTwoXMLs.py label selector geom2.xml geom1.xml report2.py report1.py"
00015   print "or     ./diffTwoXMLs.py label selector geom2.xml geom1.xml report.py"
00016   print "or     ./diffTwoXMLs.py label selector geom.xml report.py"
00017   print "where selector is one of ALL, DT, CSC, CSCE1, CSCE2"
00018   print "The label will be included into the filename as diffTwoXMLs_label_selector.png"
00019   print ""
00020   print "Special consistency test mode with respect to corrections in the report:"
00021   print "If the label starts with \"vsReport_\", the delta corrections from report2 would be substracted from the XML differences."
00022   print "Example:"
00023   print "./diffTwoXMLs.py diffReport_label selector geom2.xml geom1.xml report.py"
00024   sys.exit()
00025 
00026 
00027 def ALL(dt, wheel, station, sector): return True
00028 
00029 def ALL(csc, endcap, station, ring, chamber): return True
00030 
00031 def DT(dt, wheel, station, sector): return dt == "DT"
00032 def DT_st1(dt, wheel, station, sector): return dt == "DT" and station == 1
00033 def DT_st2(dt, wheel, station, sector): return dt == "DT" and station == 2
00034 def DT_st3(dt, wheel, station, sector): return dt == "DT" and station == 3
00035 def DT_st4(dt, wheel, station, sector): return dt == "DT" and station == 4
00036 
00037 def CSC(csc, endcap, station, ring, chamber): return csc == "CSC"
00038 def CSCE1(csc, endcap, station, ring, chamber): return csc == "CSC" and endcap==1
00039 def CSCE2(csc, endcap, station, ring, chamber): return csc == "CSC" and endcap==2
00040 
00041 
00042 label = cargs[1]
00043 diffReport = False
00044 if label.find("vsReport_") == 0: diffReport = True
00045 
00046 selection = cargs[2]
00047 
00048 if len(cargs) == 5:
00049   xmlfile2 = cargs[3]
00050   reportfile2 = cargs[4]
00051   g1 = None
00052   r1 = None
00053 
00054 if len(cargs) == 6:
00055   xmlfile2 = cargs[3]
00056   xmlfile1 = cargs[4]
00057   reportfile2 = cargs[5]
00058   g1 = MuonGeometry(xmlfile1)
00059   r1 = None
00060 
00061 if len(cargs) == 7:
00062   xmlfile2 = cargs[3]
00063   xmlfile1 = cargs[4]
00064   reportfile2 = cargs[5]
00065   reportfile1 = cargs[6]
00066   g1 = MuonGeometry(xmlfile1)
00067   execfile(reportfile1)
00068   r1 = reports
00069 
00070 g2 = MuonGeometry(xmlfile2)
00071 execfile(reportfile2)
00072 r2 = reports
00073 
00074 c1 = ROOT.TCanvas("c1","c1",1000,600)
00075 
00076 if not diffReport: 
00077   # normal XML diff mode
00078   ranges = "window=10"
00079   #if selection=="DT": ranges = "windows=[25.,5,1.,1.,5.,5.]"
00080   eval("DBdiff(g2, g1, r2, r1, %s, selection=%s, phi=False, bins=251)" % (ranges, selection))
00081 
00082 else:
00083   # Special consistency test mode with respect to corrections in the report:
00084   ranges = "window=0.02"
00085   eval("DBdiff(g2, g1, r2, r1, %s, selection=%s, phi=False, bins=1001, reportdiff=True, inlog=True)" % (ranges, selection))
00086 
00087 
00088 c1.Update()
00089 c1.Print("diffTwoXMLs_%s_%s.png" % (label, selection))