CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions | Variables
plotscripts Namespace Reference

Classes

class  SawTeethFunction
 

Functions

def addToTestResults
 
def availableCellsCSC
 
def availableCellsDT
 
def bellcurves
 
def clearDDT
 
def corrections2D
 makes a scatterplot of corrections coming either from reports (if xml geometries are None) or from geometryX and geometryY (WRT the common initial geometry0) More...
 
def createPeaksProfile
 
def curvatureDTsummary
 
def curvatureplot
 "param" may be one of "deltax" (Delta x position residuals), "deltadxdz" (Delta (dx/dz) angular residuals), "curverr" (Delta x * d(Delta q/pT)/d(Delta x) = Delta q/pT in the absence of misalignment) More...
 
def DBdiff
 
def DBdiffVersus
 
def DBMC
 
def DBMCVersus
 
def doTests
 
def doTestsForMapPlots
 
def doTestsForReport
 
def getname
 
def getReportByPostalAddress
 
def idToPostalAddress
 
def loadTestResultsMap
 
def mapNameToId
 
def mapplot
 
def mean
 
def nameToId
 
def phiedges2c
 
def philines
 
def plotmedians
 
def polynomials
 
def postalAddressToId
 
def printDeltaTs
 
def rlines
 
def rms
 
def saveTestResultsMap
 
def segdiff
 
def segdiff_xalign
 
def segdiffvsphi
 
def segdiffvsphi_xalign
 
def segdiffvsphicsc
 
def set_palette
 
def setTDRStyle
 
def stationIndex
 
def stdev
 
def testDeltaWithin5Sigma
 
def testEntry
 
def testZeroWithin5Sigma
 
def wheel0only
 
def wheelLetter
 
def wheelm1only
 
def wheelm2only
 Convenience functions. More...
 
def wheelNumber
 
def wheelp1only
 
def wheelp2only
 
def wmean
 
def writeDQMReport
 
def zlines
 

Variables

 CPP_LOADED = False
 
list DQM_SEVERITY
 
dictionary MAP_RESULTS_BINS = {}
 
dictionary MAP_RESULTS_FITSIN = {}
 
dictionary MAP_RESULTS_SAWTOOTH = {}
 
list phiedges
 
list phiedgesCSC18 = [pi/180.*(-5. + 20.*i) for i in range(18)]
 
list phiedgesCSC36 = [pi/180.*(-5. + 10.*i) for i in range(36)]
 sector phi edges in: me11 me12 me13 me14 me21 me22 me31 me32 me41 me42 mb1 mb2 mb3 mb4 index: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 More...
 
 tdrStyle = None
 
dictionary TEST_RESULTS = {}
 

Function Documentation

def plotscripts.addToTestResults (   c,
  res 
)

Definition at line 1032 of file plotscripts.py.

Referenced by doTestsForMapPlots(), and doTestsForReport().

1033 def addToTestResults(c,res):
1034  if len(res)>0:
1035  if TEST_RESULTS.has_key(c): TEST_RESULTS[c].extend(res)
1036  else: TEST_RESULTS[c] = res
1037 
def addToTestResults
def plotscripts.availableCellsCSC (   reports)

Definition at line 965 of file plotscripts.py.

Referenced by doTests().

966 def availableCellsCSC(reports):
967  cscs = []
968  # CSC station
969  for endcap in CSC_TYPES:
970  for station in endcap[2]:
971  cscs.append("%s%s" % (endcap[0], station[1]))
972  # CSC station & ring
973  for endcap in CSC_TYPES:
974  for station in endcap[2]:
975  for ring in station[2]:
976  if ring[1]=="ALL": continue
977  #label = "CSCvsphi_me%s%s%s" % (endcap[1], station[1], ring[1])
978  cscs.append("%s%s/%s" % (endcap[0], station[1],ring[1]))
979  # CSC station and chamber
980  for endcap in CSC_TYPES:
981  for station in endcap[2]:
982  for ring in station[2]:
983  if ring[1]!="ALL": continue
984  for chamber in range(1,ring[2]+1):
985  #label = "CSCvsr_me%s%sch%02d" % (endcap[1], station[1], chamber)
986  cscs.append("%s%s/ALL/%02d" % (endcap[0], station[1],chamber))
987  # CSC station and ALL chambers
988  for endcap in CSC_TYPES:
989  for station in endcap[2]:
990  for ring in station[2]:
991  if ring[1]!="ALL": continue
992  #label = "CSCvsr_me%s%schALL" % (endcap[1], station[1])
993  cscs.append("%s%s/ALL" % (endcap[0], station[1]))
994  # CSC chambers
995  for endcap in CSC_TYPES:
996  for station in endcap[2]:
997  for ring in station[2]:
998  if ring[1]=="ALL": continue
999  for chamber in range(1,ring[2]+1):
1000  # exclude non instrumented ME4/2
1001  if station[1]=="4" and ring[1]=="2":
1002  if endcap[1]=="m": continue
1003  if chamber<9 or chamber>13: continue
1004  schamber = "%02d" % chamber
1005  label = "ME%s%s%s_%s" % (endcap[1], station[1], ring[1], schamber)
1006  if len(reports)==0:
1007  # no reports case: do not include chambers
1008  #cscs.append(endcap[0]+station[1]+'/'+ring[1]+'/'+schamber)
1009  continue
1010  found = False
1011  for r in reports:
1012  if r.name == label:
1013  found = True
1014  break
1015  if not found: continue
1016  if r.status == "TOOFEWHITS" and r.posNum+r.negNum==0: continue
1017  if r.status == "NOFIT": continue
1018  cscs.append(endcap[0]+station[1]+'/'+ring[1]+'/'+schamber)
1019  return cscs
1020 
def availableCellsCSC
Definition: plotscripts.py:965
def plotscripts.availableCellsDT (   reports)

Definition at line 919 of file plotscripts.py.

References wheelLetter().

Referenced by doTests().

920 def availableCellsDT(reports):
921  dts = []
922  # DT wheels
923  for iwheel in DT_TYPES:
924  if iwheel[1]=="ALL": continue
925  dts.append(iwheel[0])
926  # DT wheel & station
927  for wheel in DT_TYPES:
928  if wheel[1]=="ALL": continue
929  for station in wheel[2]:
930  dts.append(wheel[0]+'/'+station[1])
931  # DT station & sector
932  for wheel in DT_TYPES:
933  if wheel[1]!="ALL": continue
934  for station in wheel[2]:
935  for sector in range(1,station[2]+1):
936  ssector = "%02d" % sector
937  dts.append(wheel[0]+'/'+station[1]+'/'+ssector)
938  # DT station & ALL sectors
939  for wheel in DT_TYPES:
940  if wheel[1]!="ALL": continue
941  for station in wheel[2]:
942  dts.append(wheel[0]+'/'+station[1])
943  # DT chambers
944  for wheel in DT_TYPES:
945  if wheel[1]=="ALL": continue
946  for station in wheel[2]:
947  for sector in range(1,station[2]+1):
948  ssector = "%02d" % sector
949  label = "MBwh%sst%ssec%s" % (wheelLetter(int(wheel[1])),station[1],ssector)
950  if len(reports)==0:
951  # no reports case: do not include chambers
952  #dts.append(wheel[0]+'/'+station[1]+'/'+ssector)
953  continue
954  found = False
955  for r in reports:
956  if r.name == label:
957  found = True
958  break
959  if not found: continue
960  if r.status == "TOOFEWHITS" and r.posNum+r.negNum==0: continue
961  if r.status == "NOFIT": continue
962  dts.append(wheel[0]+'/'+station[1]+'/'+ssector)
963  return dts
964 
def wheelLetter
Definition: plotscripts.py:37
def availableCellsDT
Definition: plotscripts.py:919
def plotscripts.bellcurves (   tfile,
  reports,
  name,
  twobin = True,
  suppressblue = False 
)

Definition at line 2053 of file plotscripts.py.

References getname().

Referenced by alignmentValidation.doFitFunctionsPlotsCSC(), and alignmentValidation.doFitFunctionsPlotsDT().

2054 def bellcurves(tfile, reports, name, twobin=True, suppressblue=False):
2055  t1 = time.time()
2056  ddt[0] += 1
2057  tdrStyle.SetOptTitle(1)
2058  tdrStyle.SetTitleBorderSize(1)
2059  tdrStyle.SetTitleFontSize(0.1)
2060  tdrStyle.SetOptStat(0)
2061  tdrStyle.SetHistMinimumZero()
2062 
2063  c1.Clear()
2064  c1.ResetAttPad()
2065 
2066  found = False
2067  for r in reports:
2068  if r.name == name:
2069  found = True
2070  break
2071  if not found: raise Exception, "Not a valid name"
2072  if r.status == "FAIL":
2073  #raise Exception, "Fit failed"
2074  print "Fit failed"
2075  c1.Clear()
2076  return
2077 
2078  Pos = "Pos"; Neg = "Neg"
2079  if not twobin:
2080  Pos = ""; Neg = ""
2081 
2082  pdirPos = "MuonAlignmentFromReference/%s%s" % (name, Pos)
2083  pdirNeg = "MuonAlignmentFromReference/%s%s" % (name, Neg)
2084 
2085  t2 = time.time()
2086  ddt[1] = 1./ddt[0]*((ddt[0]-1)*ddt[1] + t2-t1)
2087 
2088  chamber_x = tfile.Get(pdirPos+"_x")
2089  chamber_x_fit = tfile.Get(pdirPos+"_x_fit")
2090  chamber_y = tfile.Get(pdirPos+"_y")
2091  chamber_y_fit = tfile.Get(pdirPos+"_y_fit")
2092  chamber_dxdz = tfile.Get(pdirPos+"_dxdz")
2093  chamber_dxdz_fit = tfile.Get(pdirPos+"_dxdz_fit")
2094  chamber_dydz = tfile.Get(pdirPos+"_dydz")
2095  chamber_dydz_fit = tfile.Get(pdirPos+"_dydz_fit")
2096  chamber_alphax = tfile.Get(pdirPos+"_alphax")
2097  chamber_alphax_fit = tfile.Get(pdirPos+"_alphax_fit")
2098  chamber_alphay = tfile.Get(pdirPos+"_alphay")
2099  chamber_alphay_fit = tfile.Get(pdirPos+"_alphay_fit")
2100  if twobin:
2101  chamber_x_fit2 = tfile.Get(pdirNeg+"_x_fit")
2102  chamber_y_fit2 = tfile.Get(pdirNeg+"_y_fit")
2103  chamber_dxdz_fit2 = tfile.Get(pdirNeg+"_dxdz_fit")
2104  chamber_dydz_fit2 = tfile.Get(pdirNeg+"_dydz_fit")
2105  chamber_alphax_fit2 = tfile.Get(pdirNeg+"_alphax_fit")
2106  chamber_alphay_fit2 = tfile.Get(pdirNeg+"_alphay_fit")
2107 
2108  if not chamber_x:
2109  chamber_x = tfile.Get(pdirPos+"_residual")
2110  chamber_x_fit = tfile.Get(pdirPos+"_residual_fit")
2111  chamber_dxdz = tfile.Get(pdirPos+"_resslope")
2112  chamber_dxdz_fit = tfile.Get(pdirPos+"_resslope_fit")
2113  chamber_alphax = tfile.Get(pdirPos+"_alpha")
2114  chamber_alphax_fit = tfile.Get(pdirPos+"_alpha_fit")
2115  if twobin:
2116  chamber_x_fit2 = tfile.Get(pdirNeg+"_residual_fit")
2117  chamber_dxdz_fit2 = tfile.Get(pdirNeg+"_resslope_fit")
2118  chamber_alphax_fit2 = tfile.Get(pdirNeg+"_alpha_fit")
2119 
2120  if not chamber_x:
2121  print "Can't find neither "+pdirPos+"_x nor "+pdirPos+"_residual"
2122  return
2123 
2124  t3 = time.time()
2125  ddt[2] = 1./ddt[0]*((ddt[0]-1)*ddt[2] + t3-t2)
2126 
2127  ####
2128  chamber_x.SetAxisRange(-50., 50., "X")
2129  if chamber_x.GetRMS()>15: chamber_x.SetAxisRange(-75., 75., "X")
2130  chamber_dxdz.SetAxisRange(-30., 30., "X")
2131  chamber_alphax.SetAxisRange(-50., 50., "X")
2132  if not not chamber_y:
2133  chamber_y.SetAxisRange(-75., 75., "X")
2134  chamber_dydz.SetAxisRange(-120., 120., "X")
2135  chamber_alphay.SetAxisRange(-120., 120., "X")
2136  chamber_alphay.SetAxisRange(-75., 75., "Y")
2137  ####
2138 
2139  chamber_x.SetXTitle("Local x residual (mm)")
2140  chamber_dxdz.SetXTitle("Local dx/dz residual (mrad)")
2141  chamber_alphax.SetXTitle("Local dx/dz residual (mrad)")
2142  chamber_alphax.SetYTitle("Local x residual (mm)")
2143  if not not chamber_y:
2144  chamber_y.SetXTitle("Local y residual (mm)")
2145  chamber_dydz.SetXTitle("Local dy/dz residual (mrad)")
2146  chamber_alphay.SetXTitle("Local dy/dz residual (mrad)")
2147  chamber_alphay.SetYTitle("Local y residual (mm)")
2148  if name[0:2] == "ME":
2149  chamber_x.SetXTitle("Local r#phi residual (mm)")
2150  chamber_dxdz.SetXTitle("Local d(r#phi)/dz residual (mrad)")
2151  chamber_alphax.SetXTitle("Local d(r#phi)/dz residual (mrad)")
2152  chamber_alphax.SetYTitle("Local r#phi residual (mm)")
2153 
2154  t4 = time.time()
2155  ddt[3] = 1./ddt[0]*((ddt[0]-1)*ddt[3] + t4-t3)
2156 
2157  for h in chamber_x, chamber_dxdz, chamber_alphax, chamber_alphax, \
2158  chamber_y, chamber_dydz, chamber_alphay, chamber_alphay:
2159  if not not h:
2160  h.GetXaxis().CenterTitle()
2161  h.GetYaxis().CenterTitle()
2162  h.GetXaxis().SetLabelSize(0.05)
2163  h.GetYaxis().SetLabelSize(0.05)
2164  h.GetXaxis().SetTitleSize(0.07)
2165  h.GetYaxis().SetTitleSize(0.07)
2166  h.GetXaxis().SetTitleOffset(0.9)
2167  h.GetYaxis().SetTitleOffset(0.9)
2168 
2169  if twobin:
2170  for f in chamber_x_fit2, chamber_y_fit2, chamber_dxdz_fit2, chamber_dydz_fit2, \
2171  chamber_alphax_fit2, chamber_alphay_fit2:
2172  if not not f:
2173  f.SetLineColor(4)
2174  if not twobin:
2175  suppressblue = True
2176 
2177  t5 = time.time()
2178  ddt[4] = 1./ddt[0]*((ddt[0]-1)*ddt[4] + t5-t4)
2179 
2180  global l1, l2, l3, l4
2181  if not not chamber_y:
2182  c1.Clear()
2183  c1.Divide(3, 2)
2184  chamber_x.SetTitle(getname(r))
2185 
2186  c1.GetPad(1).cd()
2187  chamber_x.Draw()
2188  if not suppressblue: chamber_x_fit2.Draw("same")
2189  chamber_x_fit.Draw("same")
2190  l1 = ROOT.TLatex(0.67,0.8,"#splitline{#mu: %0.2f#pm%0.2f}{#sigma: %0.1f#pm%0.1f}" % (
2191  chamber_x_fit.GetParameter(1), chamber_x_fit.GetParError(1),
2192  chamber_x_fit.GetParameter(2), chamber_x_fit.GetParError(2)))
2193  l1.Draw()
2194 
2195  c1.GetPad(2).cd()
2196  chamber_dxdz.Draw()
2197  if not suppressblue: chamber_dxdz_fit2.Draw("same")
2198  chamber_dxdz_fit.Draw("same")
2199  l2 = ROOT.TLatex(0.67,0.8,"#splitline{#mu: %0.2f#pm%0.2f}{#sigma: %0.1f#pm%0.1f}" % (
2200  chamber_dxdz_fit.GetParameter(1), chamber_dxdz_fit.GetParError(1),
2201  chamber_dxdz_fit.GetParameter(2), chamber_dxdz_fit.GetParError(2)))
2202  l2.Draw()
2203 
2204  c1.GetPad(3).cd()
2205  chamber_alphax.Draw("col")
2206  if not suppressblue: chamber_alphax_fit2.Draw("same")
2207  chamber_alphax_fit.Draw("same")
2208 
2209  c1.GetPad(4).cd()
2210  chamber_y.Draw()
2211  if not suppressblue: chamber_y_fit2.Draw("same")
2212  chamber_y_fit.Draw("same")
2213  l3 = ROOT.TLatex(0.67,0.8,"#splitline{#mu: %0.2f#pm%0.2f}{#sigma: %0.1f#pm%0.1f}" % (
2214  chamber_y_fit.GetParameter(1), chamber_y_fit.GetParError(1),
2215  chamber_y_fit.GetParameter(2), chamber_y_fit.GetParError(2)))
2216  l3.Draw()
2217 
2218  c1.GetPad(5).cd()
2219  chamber_dydz.Draw()
2220  if not suppressblue: chamber_dydz_fit2.Draw("same")
2221  chamber_dydz_fit.Draw("same")
2222  l4 = ROOT.TLatex(0.67,0.8,"#splitline{#mu: %0.2f#pm%0.2f}{#sigma: %0.1f#pm%0.1f}" % (
2223  chamber_dydz_fit.GetParameter(1), chamber_dydz_fit.GetParError(1),
2224  chamber_dydz_fit.GetParameter(2), chamber_dydz_fit.GetParError(2)))
2225  l4.Draw()
2226 
2227  for lb in l1,l2,l3,l4:
2228  lb.SetNDC(1)
2229  lb.SetTextColor(ROOT.kRed)
2230 
2231  c1.GetPad(6).cd()
2232  chamber_alphay.Draw("col")
2233  if not suppressblue: chamber_alphay_fit2.Draw("same")
2234  chamber_alphay_fit.Draw("same")
2235 
2236  else:
2237  c1.Clear()
2238  c1.Divide(3, 1)
2239  chamber_x.SetTitle(getname(r))
2240 
2241  c1.GetPad(1).cd()
2242  chamber_x.Draw()
2243  if not suppressblue: chamber_x_fit2.Draw("same")
2244  chamber_x_fit.Draw("same")
2245  l1 = ROOT.TLatex(0.67,0.8,"#splitline{#mu: %0.2f#pm%0.2f}{#sigma: %0.1f#pm%0.1f}" % (
2246  chamber_x_fit.GetParameter(1), chamber_x_fit.GetParError(1),
2247  chamber_x_fit.GetParameter(2), chamber_x_fit.GetParError(2)))
2248  l1.Draw()
2249 
2250  c1.GetPad(2).cd()
2251  chamber_dxdz.Draw()
2252  if not suppressblue: chamber_dxdz_fit2.Draw("same")
2253  chamber_dxdz_fit.Draw("same")
2254  l2 = ROOT.TLatex(0.67,0.8,"#splitline{#mu: %0.2f#pm%0.2f}{#sigma: %0.1f#pm%0.1f}" % (
2255  chamber_dxdz_fit.GetParameter(1), chamber_dxdz_fit.GetParError(1),
2256  chamber_dxdz_fit.GetParameter(2), chamber_dxdz_fit.GetParError(2)))
2257  l2.Draw()
2258 
2259  c1.GetPad(3).cd()
2260  chamber_alphax.Draw("col")
2261  if not suppressblue: chamber_alphax_fit2.Draw("same")
2262  chamber_alphax_fit.Draw("same")
2263 
2264  for lb in l1,l2:
2265  lb.SetNDC(1)
2266  lb.SetTextColor(ROOT.kRed)
2267 
2268  t6 = time.time()
2269  ddt[5] = 1./ddt[0]*((ddt[0]-1)*ddt[5] + t6-t5)
2270  ddt[6] = 1./ddt[0]*((ddt[0]-1)*ddt[6] + t6-t1)
2271 
def plotscripts.clearDDT ( )

Definition at line 2042 of file plotscripts.py.

Referenced by alignmentValidation.doFitFunctionsPlotsCSC(), and alignmentValidation.doFitFunctionsPlotsDT().

2043 def clearDDT():
2044  for i in range(0,15):
2045  ddt[i]=0.
def plotscripts.corrections2D (   reportsX = None,
  reportsY = None,
  geometry0 = None,
  geometryX = None,
  geometryY = None,
  window = 25.,
  selection = None,
  name = "tmp",
  canvas = None,
  pre_title_x = None,
  pre_title_y = None,
  which = "110011" 
)

makes a scatterplot of corrections coming either from reports (if xml geometries are None) or from geometryX and geometryY (WRT the common initial geometry0)

Definition at line 3553 of file plotscripts.py.

References funct.abs(), python.multivaluedict.append(), getReportByPostalAddress(), edm::detail.isnan(), list(), python.multivaluedict.map(), bookConverter.max, corrVsCorr.selection, mathSSE.sqrt(), and archive.zip.

Referenced by segdiffvsphicsc().

3554  which="110011"):
3555 
3556  tdrStyle.SetOptStat(0)
3557  tdrStyle.SetStatW(0.40)
3558 
3559  # determine what are we plotting: report vs report or xml vs xml
3560  mode = None
3561  check_reports = False
3562  if reportsX is not None and reportsY is not None:
3563  mode = "reports"
3564  check_reports = True
3565  if geometry0 is not None and geometryX is not None and geometryY is not None:
3566  mode = "xmls"
3567  if mode is None:
3568  print "Either couple of reports or three geometries have to be given as input. Exiting..."
3569  return
3570 
3571  # setup ranges with the maximum [-window,window] that later will be optimized to [-wnd_adaptive,wnd_adaptive]
3572  wnd = [window]*6
3573  wnd_adaptive = [.1]*6
3574 
3575  global hx, hy, hz, hphix, hphiy, hphiz
3576  bins=2000
3577  hx = ROOT.TH2F("%s_x" % name, "", bins, -wnd[0], wnd[0], bins, -wnd[0], wnd[0])
3578  hy = ROOT.TH2F("%s_y" % name, "", bins, -wnd[1], wnd[1], bins, -wnd[1], wnd[1])
3579  hz = ROOT.TH2F("%s_z" % name, "", bins, -wnd[2], wnd[2], bins, -wnd[2], wnd[2])
3580  hphix = ROOT.TH2F("%s_phix" % name, "", bins, -wnd[3], wnd[3], bins, -wnd[3], wnd[3])
3581  hphiy = ROOT.TH2F("%s_phiy" % name, "", bins, -wnd[4], wnd[4], bins, -wnd[4], wnd[4])
3582  hphiz = ROOT.TH2F("%s_phiz" % name, "", bins, -wnd[5], wnd[5], bins, -wnd[5], wnd[5])
3583  hhh = [hx, hy, hz, hphix, hphiy, hphiz]
3584 
3585  # initialize PCA objects
3586  global pca_x, pca_y, pca_z, pca_phix, pca_phiy, pca_phiz
3587  pca_x = ROOT.TPrincipal(2,"D")
3588  pca_y = ROOT.TPrincipal(2,"D")
3589  pca_z = ROOT.TPrincipal(2,"D")
3590  pca_phix = ROOT.TPrincipal(2,"D")
3591  pca_phiy = ROOT.TPrincipal(2,"D")
3592  pca_phiz = ROOT.TPrincipal(2,"D")
3593  pcas = [pca_x, pca_y, pca_z, pca_phix, pca_phiy, pca_phiz]
3594 
3595  # arrays to later fill graphs with
3596  ax=[]; ay=[]; az=[]; aphix=[]; aphiy=[]; aphiz=[]
3597  aaa = [ax, ay, az, aphix, aphiy, aphiz]
3598 
3599  # list of postal addresses
3600  postal_addresses = []
3601 
3602  # if reports are given, use them to fill addresses and do extra checks
3603  if check_reports:
3604  for r1 in reportsX:
3605  # skip ME1/a
3606  if r1.postal_address[0]=='CSC' and r1.postal_address[2]==1 and r1.postal_address[3]==4: continue
3607  if selection is None or (selection.func_code.co_argcount == len(r1.postal_address) and selection(*r1.postal_address)):
3608  r2 = getReportByPostalAddress(r1.postal_address, reportsY)
3609  if r2 is None:
3610  print "bad r2 in ",r1.postal_address
3611  continue
3612 
3613  if r1.status != "PASS" or r2.status != "PASS":
3614  print "bad status", r1.postal_address, r1.status, r2.status
3615  continue
3616  postal_addresses.append(r1.postal_address)
3617  # otherwise, use chamber addresses from xmls
3618  else:
3619  for key in geometry0.dt.keys():
3620  if len(key)==3 and key in geometryX.dt and key in geometryY.dt:
3621  postal_addresses.append( tuple(['DT'] + list(key)) )
3622  for key in geometry0.csc.keys():
3623  # skip ME1/a
3624  if key[2]==1 and key[3]==4: continue
3625  if len(key)==4 and key in geometryX.csc and key in geometryY.csc:
3626  postal_addresses.append( tuple(['CSC'] + list(key)) )
3627 
3628  # fill the values
3629  for addr in postal_addresses:
3630 
3631  # checks the selection function
3632  if not (selection is None or (selection.func_code.co_argcount == len(addr) and selection(*addr)) ): continue
3633 
3634  factors = [10. * signConventions[addr][0], 10. * signConventions[addr][1], 10. * signConventions[addr][2],
3635  1000., 1000., 1000. ]
3636 
3637  if check_reports:
3638  rX = getReportByPostalAddress(addr, reportsX)
3639  rY = getReportByPostalAddress(addr, reportsY)
3640  deltasX = [rX.deltax, rX.deltay, rX.deltaz, rX.deltaphix, rX.deltaphiy, rX.deltaphiz]
3641  deltasY = [rY.deltax, rY.deltay, rY.deltaz, rY.deltaphix, rY.deltaphiy, rY.deltaphiz]
3642 
3643  if mode == "reports":
3644 
3645  checks = map( lambda d1, d2: d1 is not None and d2 is not None and d1.error is not None \
3646  and d2.error is not None and (d1.error**2 + d2.error**2) > 0. , \
3647  deltasX, deltasY)
3648 
3649  for i in range(len(checks)):
3650  if not checks[i]: continue
3651  fillX = deltasX[i].value * factors[i]
3652  fillY = deltasY[i].value * factors[i]
3653  aaa[i].append([fillX,fillY])
3654  pcas[i].AddRow(array.array('d',[fillX,fillY]))
3655  mx = max(abs(fillX), abs(fillY))
3656  if mx > wnd_adaptive[i]: wnd_adaptive[i] = mx
3657 
3658  if mode == "xmls":
3659 
3660  db0 = dbX = dbY = None
3661  if addr[0] == "DT":
3662  db0, dbX, dbY = geometry0.dt[addr[1:]], geometryX.dt[addr[1:]], geometryY.dt[addr[1:]]
3663  if addr[0] == 'CSC':
3664  db0, dbX, dbY = geometry0.csc[addr[1:]], geometryX.csc[addr[1:]], geometryY.csc[addr[1:]]
3665 
3666  checks = [True]*6
3667  if check_reports:
3668  checks = map( lambda d1, d2: d1 is not None and d2 is not None , deltasX, deltasY)
3669 
3670  gdeltas0 = [db0.x, db0.y, db0.z, db0.phix, db0.phiy, db0.phiz]
3671  gdeltasX = [dbX.x, dbX.y, dbX.z, dbX.phix, dbX.phiy, dbX.phiz]
3672  gdeltasY = [dbY.x, dbY.y, dbY.z, dbY.phix, dbY.phiy, dbY.phiz]
3673 
3674  for i in range(len(checks)):
3675  if not checks[i]: continue
3676  fillX = (gdeltasX[i] - gdeltas0[i]) * factors[i]
3677  fillY = (gdeltasY[i] - gdeltas0[i]) * factors[i]
3678  aaa[i].append([fillX,fillY])
3679  pcas[i].AddRow(array.array('d',[fillX,fillY]))
3680  mx = max(abs(fillX), abs(fillY))
3681  if mx > wnd_adaptive[i]: wnd_adaptive[i] = mx
3682  #if addr[0] == 'CSC' and i==1 and (abs(fillX)>0.01 or abs(fillY)>0.01): print addr, ": hugeCSC i=%d dx=%.03g dy=%.03g"%(i,fillX,fillY)
3683  #if addr[0] == 'CSC' and i==2 and (abs(fillX)>0.02 or abs(fillY)>0.02): print addr, ": hugeCSC i=%d dx=%.03g dy=%.03g"%(i,fillX,fillY)
3684  #if addr[0] == 'CSC' and i==3 and (abs(fillX)>0.05 or abs(fillY)>0.05): print addr, ": hugeCSC i=%d dx=%.03g dy=%.03g"%(i,fillX,fillY)
3685 
3686  if mode == "xmls":
3687  if pre_title_x is None: pre_title_x = "geometry 1 "
3688  if pre_title_y is None: pre_title_y = "geometry 2 "
3689  if mode == "reports":
3690  if pre_title_x is None: pre_title_x = "iteration's "
3691  if pre_title_y is None: pre_title_y = "other iteration's "
3692  tmptitles = ["#Deltax (mm)", "#Deltay (mm)", "#Deltaz (mm)",
3693  "#Delta#phi_{x} (mrad)", "#Delta#phi_{y} (mrad)", "#Delta#phi_{z} (mrad)"]
3694  htitles = []
3695  for t in tmptitles: htitles.append([pre_title_x + t, pre_title_y + t])
3696 
3697  if canvas is not None: c = canvas
3698  else: c = c1
3699  c.Clear()
3700  ndraw = which.count('1')
3701  if ndraw > 4: c.Divide(3, 2)
3702  elif ndraw > 2: c.Divide(2, 2)
3703  elif ndraw > 1: c.Divide(2, 1)
3704 
3705  global lines, graphs, texs
3706  lines = []; graphs = []; texs = []
3707 
3708  ipad = 0
3709  for i in range(6):
3710 
3711  # decode 'which' binary mask
3712  if ( int(which,2) & (1<<i) ) == 0: continue
3713 
3714  ipad += 1
3715  c.GetPad(ipad).cd()
3716  c.GetPad(ipad).SetGridx(1)
3717  c.GetPad(ipad).SetGridy(1)
3718 
3719  wn = 1.08 * wnd_adaptive[i]
3720  hhh[i].GetXaxis().SetRangeUser(-wn, wn)
3721  hhh[i].GetYaxis().SetRangeUser(-wn, wn)
3722  hhh[i].SetXTitle(htitles[i][0])
3723  hhh[i].SetYTitle(htitles[i][1])
3724  hhh[i].GetXaxis().CenterTitle()
3725  hhh[i].GetYaxis().CenterTitle()
3726  hhh[i].Draw()
3727 
3728  if len(aaa[i]) == 0: continue
3729 
3730  a1, a2 = map( lambda x: array.array('d',x), zip(*aaa[i]) )
3731  g = ROOT.TGraph(len(a1), a1, a2)
3732  g.SetMarkerStyle(5)
3733  g.SetMarkerSize(0.3)
3734  g.SetMarkerColor(ROOT.kBlue)
3735  graphs.append(g)
3736 
3737  pcas[i].MakePrincipals()
3738  #pcas[i].Print()
3739  #pcas[i].MakeHistograms()
3740  b = pcas[i].GetEigenVectors()(1,0) / pcas[i].GetEigenVectors()(0,0)
3741  a = pcas[i].GetMeanValues()[1] - b * pcas[i].GetMeanValues()[0]
3742  #print a, b, " ", pcas[i].GetEigenValues()[0], pcas[i].GetEigenValues()[1]
3743 
3744  cov = pcas[i].GetCovarianceMatrix()
3745  r = cov(0,1)/sqrt(cov(1,1)*cov(0,0))
3746  print "r, RMSx, RMSy =", r, g.GetRMS(1), g.GetRMS(2)
3747  texrms = ROOT.TLatex(0.17,0.87, "RMS x,y = %.02g, %.02g" % (g.GetRMS(1),g.GetRMS(2)))
3748  texr = ROOT.TLatex(0.17,0.80, "r = %.02g" % r)
3749  for t in texr, texrms:
3750  t.SetNDC(1)
3751  t.SetTextColor(ROOT.kBlue)
3752  t.SetTextSize(0.053)
3753  t.Draw()
3754  texs.append(t)
3755 
3756  g.Draw("p")
3757 
3758  if not isnan(b):
3759  wn = wnd_adaptive[i]
3760  line = ROOT.TLine(-wn, a - b*wn, wn, a + b*wn)
3761  line.SetLineColor(ROOT.kRed)
3762  line.Draw()
3763  lines.append(line)
3764 
3765  #return hx, hy, hphiy, hphiz, pca_x, pca_y, pca_phiy, pca_phiz
3766  return aaa
selection
main part
Definition: corrVsCorr.py:98
tuple zip
Definition: archive.py:476
bool isnan(float x)
Definition: math.h:13
T sqrt(T t)
Definition: SSEVec.h:48
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def getReportByPostalAddress
Definition: plotscripts.py:468
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
def plotscripts.createPeaksProfile (   the2d,
  rebin = 1 
)

Definition at line 1403 of file plotscripts.py.

References mapplot(), and mathSSE.sqrt().

Referenced by curvatureplot(), and mapplot().

1404 def createPeaksProfile(the2d, rebin=1):
1405  htmp = ROOT.gROOT.FindObject(the2d.GetName()+"_peaks")
1406  if htmp != None: htmp.Delete()
1407 
1408  hpeaks = the2d.ProjectionX(the2d.GetName()+"_peaks")
1409  hpeaks.Reset()
1410  hpeaks.Rebin(rebin)
1411  bad_fit_bins = []
1412  for i in xrange(0, int(the2d.GetNbinsX()), rebin):
1413  tmp = the2d.ProjectionY("tmp", i+1, i + rebin)
1414  nn = tmp.GetEntries()
1415 
1416  drange = tmp.GetRMS()
1417  drange = 2.*drange
1418  fgaus = ROOT.TF1("fgaus","gaus", tmp.GetMean() - drange, tmp.GetMean() + drange)
1419  fgaus.SetParameter(0,nn)
1420  fgaus.SetParameter(1,tmp.GetMean())
1421  fgaus.SetParameter(2,tmp.GetRMS())
1422  #print " ", i, nn, tmp.GetMean() , drange, "[", tmp.GetMean() - drange, tmp.GetMean() + drange, ']'
1423 
1424  fitOk = False
1425  if nn > 10: # good to fit
1426  fr = tmp.Fit("fgaus","RNSQ")
1427  #print " ", fgaus.GetParameter(1), " +- ", fgaus.GetParError(1), " fitres = " , fr.Status() , fr.CovMatrixStatus()
1428  hpeaks.SetBinContent(i/rebin+1, fgaus.GetParameter(1))
1429  hpeaks.SetBinError(i/rebin+1, fgaus.GetParError(1))
1430  if fr.Status()==0 and fr.CovMatrixStatus()==3 : fitOk = True
1431  if not fitOk:
1432  bad_fit_bins.append(i/rebin+1)
1433  if nn > 1. and tmp.GetRMS() > 0: # use mean
1434  hpeaks.SetBinContent(i/rebin+1, tmp.GetMean())
1435  hpeaks.SetBinError(i/rebin+1, ROOT.TMath.StudentQuantile(0.841345,nn) * tmp.GetRMS() / sqrt(nn))
1436  else:
1437  hpeaks.SetBinContent(i/rebin+1, 0.)
1438  hpeaks.SetBinError(i/rebin+1, 0.)
1439  if len(bad_fit_bins): print "createPeaksProfile bad fit bins: ", bad_fit_bins
1440  return hpeaks
1441 
T sqrt(T t)
Definition: SSEVec.h:48
def createPeaksProfile
def plotscripts.curvatureDTsummary (   tfiles,
  window = 15.,
  pdgSfactor = False 
)

Definition at line 1971 of file plotscripts.py.

References python.multivaluedict.append(), curvatureplot(), set_palette(), and mathSSE.sqrt().

1972 def curvatureDTsummary(tfiles, window=15., pdgSfactor=False):
1973  global h, gm2, gm1, gz, gp1, gp2, tlegend
1974 
1975  set_palette("blues")
1976  phis = {-2: [], -1: [], 0: [], 1: [], 2: []}
1977  diffs = {-2: [], -1: [], 0: [], 1: [], 2: []}
1978  differrs = {-2: [], -1: [], 0: [], 1: [], 2: []}
1979  for wheelstr, wheel in ("m2", "-2"), ("m1", "-1"), ("z", "0"), ("p1", "+1"), ("p2", "+2"):
1980  for sector in "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12":
1981  curvatureplot(tfiles, "wheel%s_sector%s" % (wheelstr, sector), "deltax",
1982  title="Wheel %s, sector %s" % (wheel, sector), fitgauss=True, reset_palette=False)
1983  if fitgauss_diff[1] < window:
1984  uncertainty = fitgauss_diff[1]
1985  if pdgSfactor and (fitgauss_chi2/fitgauss_ndf) > 1.: uncertainty *= sqrt(fitgauss_chi2/fitgauss_ndf)
1986 
1987  phis[int(wheel)].append(signConventions["DT", int(wheel), 1, int(sector)][4])
1988  diffs[int(wheel)].append(fitgauss_diff[0])
1989  differrs[int(wheel)].append(uncertainty)
1990 
1991  h = ROOT.TH1F("h", "", 1, -pi, pi)
1992  h.SetAxisRange(-window, window, "Y")
1993  h.SetXTitle("#phi (rad)")
1994  h.SetYTitle("#Deltax(p_{T} #rightarrow #infty) - #Deltax(p_{T} #rightarrow 0) (mm)")
1995  h.GetXaxis().CenterTitle()
1996  h.GetYaxis().CenterTitle()
1997 
1998  gm2 = ROOT.TGraphErrors(len(phis[-2]), array.array("d", phis[-2]), array.array("d", diffs[-2]),
1999  array.array("d", [0.]*len(phis[-2])), array.array("d", differrs[-2]))
2000  gm1 = ROOT.TGraphErrors(len(phis[-1]), array.array("d", phis[-1]), array.array("d", diffs[-1]),
2001  array.array("d", [0.]*len(phis[-1])), array.array("d", differrs[-1]))
2002  gz = ROOT.TGraphErrors(len(phis[0]), array.array("d", phis[0]), array.array("d", diffs[0]),
2003  array.array("d", [0.]*len(phis[0])), array.array("d", differrs[0]))
2004  gp1 = ROOT.TGraphErrors(len(phis[1]), array.array("d", phis[1]), array.array("d", diffs[1]),
2005  array.array("d", [0.]*len(phis[1])), array.array("d", differrs[1]))
2006  gp2 = ROOT.TGraphErrors(len(phis[2]), array.array("d", phis[2]), array.array("d", diffs[2]),
2007  array.array("d", [0.]*len(phis[2])), array.array("d", differrs[2]))
2008 
2009  gm2.SetMarkerStyle(21); gm2.SetMarkerColor(ROOT.kRed); gm2.SetLineColor(ROOT.kRed)
2010  gm1.SetMarkerStyle(22); gm1.SetMarkerColor(ROOT.kBlue); gm1.SetLineColor(ROOT.kBlue)
2011  gz.SetMarkerStyle(3); gz.SetMarkerColor(ROOT.kBlack); gz.SetLineColor(ROOT.kBlack)
2012  gp1.SetMarkerStyle(26); gp1.SetMarkerColor(ROOT.kBlue); gp1.SetLineColor(ROOT.kBlue)
2013  gp2.SetMarkerStyle(25); gp2.SetMarkerColor(ROOT.kRed); gp2.SetLineColor(ROOT.kRed)
2014 
2015  h.Draw()
2016  tlegend = ROOT.TLegend(0.25, 0.2, 0.85, 0.5)
2017  tlegend.SetFillColor(ROOT.kWhite)
2018  tlegend.SetBorderSize(0)
2019  tlegend.AddEntry(gm2, "Wheel -2", "p")
2020  tlegend.AddEntry(gm1, "Wheel -1", "p")
2021  tlegend.AddEntry(gz, "Wheel 0", "p")
2022  tlegend.AddEntry(gp1, "Wheel +1", "p")
2023  tlegend.AddEntry(gp2, "Wheel +2", "p")
2024  tlegend.Draw()
2025 
2026  gm2.Draw("p")
2027  gm1.Draw("p")
2028  gz.Draw("p")
2029  gp1.Draw("p")
2030  gp2.Draw("p")
2031 
def curvatureDTsummary
def curvatureplot
&quot;param&quot; may be one of &quot;deltax&quot; (Delta x position residuals), &quot;deltadxdz&quot; (Delta (dx/dz) angular resid...
T sqrt(T t)
Definition: SSEVec.h:48
def plotscripts.curvatureplot (   tfiles,
  name,
  param,
  mode = "from2d",
  window = 15.,
  widebins = False,
  title = "",
  fitgauss = False,
  fitconst = False,
  fitline = False,
  fitpeaks = True,
  reset_palette = False 
)

"param" may be one of "deltax" (Delta x position residuals), "deltadxdz" (Delta (dx/dz) angular residuals), "curverr" (Delta x * d(Delta q/pT)/d(Delta x) = Delta q/pT in the absence of misalignment)

Definition at line 1804 of file plotscripts.py.

References createPeaksProfile(), set_palette(), and mathSSE.sqrt().

Referenced by curvatureDTsummary(), and alignmentValidation.doCurvaturePlotsDT().

1805 def curvatureplot(tfiles, name, param, mode="from2d", window=15., widebins=False, title="", fitgauss=False, fitconst=False, fitline=False, fitpeaks=True, reset_palette=False):
1806  tdrStyle.SetOptTitle(1)
1807  tdrStyle.SetTitleBorderSize(0)
1808  tdrStyle.SetOptStat(0)
1809  tdrStyle.SetOptFit(0)
1810  tdrStyle.SetTitleFontSize(0.05)
1811 
1812  c1.Clear()
1813  if reset_palette: set_palette("blues")
1814  global hist, histCOPY, hist2d, tline1, tline2, tline3, tline4, tline5
1815 
1816  hdir = "AlignmentMonitorMuonVsCurvature/iter1/"
1817 
1818  if name not in ("all", "top", "bottom"):
1819  hsuffix = "_%s_%s" % (name, param)
1820  prof = tfiles[0].Get(hdir+"tprofile"+hsuffix).Clone("tprofile_"+hsuffix)
1821  hist2d = tfiles[0].Get(hdir+"th2f"+hsuffix).Clone("th2f_"+hsuffix)
1822  for tfile in tfiles[1:]:
1823  prof.Add(tfile.Get(hdir+"tprofile"+hsuffix))
1824  hist2d.Add(tfile.Get(hdir+"th2f"+hsuffix))
1825  else:
1826  prof = None
1827  hist2d = None
1828  for wheel in "m2", "m1", "z", "p1", "p2":
1829  if name == "all": sectors = "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"
1830  elif name == "top": sectors = "01", "02", "03", "04", "05", "06"
1831  elif name == "bottom": sectors = "07", "08", "09", "10", "11", "12"
1832  else: raise Exception
1833 
1834  for sector in sectors:
1835  hsuffix = "_%s_%s" % ("wheel%s_sector%s" % (wheel, sector), param)
1836  for tfile in tfiles:
1837  if prof is None:
1838  prof = tfiles[0].Get(hdir+"tprofile"+hsuffix).Clone("tprofile_"+hsuffix)
1839  hist2d = tfiles[0].Get(hdir+"th2f"+hsuffix).Clone("tprofile_"+hsuffix)
1840  else:
1841  prof.Add(tfile.Get(hdir+"tprofile"+hsuffix))
1842  hist2d.Add(tfile.Get(hdir+"th2f"+hsuffix))
1843 
1844  hist = ROOT.TH1F("hist", "", prof.GetNbinsX(), prof.GetBinLowEdge(1), -prof.GetBinLowEdge(1))
1845  for i in xrange(1, prof.GetNbinsX()+1):
1846  hist.SetBinContent(i, prof.GetBinContent(i))
1847  hist.SetBinError(i, prof.GetBinError(i))
1848 
1849  if mode == "plain":
1850  hist = prof
1851  elif mode == "from2d":
1852  skip = 1
1853  if widebins:
1854  hist.Rebin(5)
1855  skip = 5
1856  htmp = ROOT.gROOT.FindObject("tmp")
1857  if htmp != None: htmp.Delete()
1858 
1859  for i in xrange(0, int(prof.GetNbinsX()), skip):
1860  tmp = hist2d.ProjectionY("tmp", i+1, i + skip)
1861  if tmp.GetEntries() > 1:
1862  hist.SetBinContent(i/skip+1, tmp.GetMean())
1863  hist.SetBinError(i/skip+1, ROOT.TMath.StudentQuantile(0.841345,tmp.GetEntries()) * tmp.GetRMS() / sqrt(tmp.GetEntries()))
1864  #hist.SetBinError(i/skip+1, tmp.GetRMS() / sqrt(tmp.GetEntries()))
1865  else:
1866  #hist.SetBinContent(i/skip+1, 2000.)
1867  #hist.SetBinError(i/skip+1, 1000.)
1868  hist.SetBinContent(i/skip+1, 0.)
1869  hist.SetBinError(i/skip+1, 0.)
1870 
1871  hpeaks = createPeaksProfile(hist2d, skip)
1872 
1873  else:
1874  raise Exception
1875 
1876 
1877  if fitgauss:
1878  f = ROOT.TF1("f", "[0] + [1]*exp(-x**2/2/0.01**2)", hist.GetBinLowEdge(1), -hist.GetBinLowEdge(1))
1879  f.SetParameters(0, 0., 0.01)
1880  if fitpeaks: hpeaks.Fit(f, "q")
1881  else: hist.Fit(f, "q")
1882  f.SetLineColor(ROOT.kRed)
1883  global fitgauss_diff, fitgauss_chi2, fitgauss_ndf
1884 # fitter = ROOT.TVirtualFitter.GetFitter()
1885 # fitgauss_diff = f.GetParameter(0) - f.GetParameter(1), \
1886 # sqrt(f.GetParError(0)**2 + f.GetParError(1)**2 + 2.*fitter.GetCovarianceMatrixElement(0, 1))
1887  fitgauss_diff = f.GetParameter(1), f.GetParError(1)
1888  fitgauss_chi2 = f.GetChisquare()
1889  fitgauss_ndf = f.GetNDF()
1890 
1891  global fitline_intercept, fitline_slope
1892  if fitconst:
1893  f = ROOT.TF1("f", "[0]", hist.GetBinLowEdge(1), -hist.GetBinLowEdge(1))
1894  if fitpeaks: hpeaks.Fit(f, "q")
1895  else: hist.Fit(f, "q")
1896  f.SetLineColor(ROOT.kRed)
1897  fitline_intercept = f.GetParameter(0), f.GetParError(0)
1898 
1899  if fitline:
1900  f = ROOT.TF1("f", "[0] + [1]*x", hist.GetBinLowEdge(1), -hist.GetBinLowEdge(1))
1901  if fitpeaks: hpeaks.Fit(f, "qNE")
1902  else: hist.Fit(f, "qNE")
1903  f.SetLineColor(ROOT.kRed)
1904  global f2, f3
1905  f2 = ROOT.TF1("2", "[0] + [1]*x", hist.GetBinLowEdge(1), -hist.GetBinLowEdge(1))
1906  f3 = ROOT.TF1("2", "[0] + [1]*x", hist.GetBinLowEdge(1), -hist.GetBinLowEdge(1))
1907  f2.SetParameters(f.GetParameter(0), f.GetParameter(1) + f.GetParError(1))
1908  f3.SetParameters(f.GetParameter(0), f.GetParameter(1) - f.GetParError(1))
1909  f2.SetLineColor(ROOT.kRed)
1910  f3.SetLineColor(ROOT.kRed)
1911  f2.SetLineStyle(2)
1912  f3.SetLineStyle(2)
1913  fitline_intercept = f.GetParameter(0), f.GetParError(0)
1914  fitline_slope = f.GetParameter(1), f.GetParError(1)
1915 
1916  hist2d.SetAxisRange(-window, window, "Y")
1917  hist2d.SetMarkerStyle(20)
1918  hist2d.SetMarkerSize(0.75)
1919  hist2d.GetXaxis().CenterTitle()
1920  hist2d.GetYaxis().CenterTitle()
1921  if param == "curverr":
1922  hist2d.GetYaxis().SetTitleOffset(1.35)
1923  else:
1924  hist2d.GetYaxis().SetTitleOffset(0.75)
1925  hist2d.GetXaxis().SetTitleOffset(1.2)
1926  hist2d.GetXaxis().SetTitleSize(0.05)
1927  hist2d.GetYaxis().SetTitleSize(0.05)
1928  hist2d.SetTitle(title)
1929  if param == "pterr": hist2d.SetXTitle("qp_{T} (GeV/c)")
1930  else: hist2d.SetXTitle("q/p_{T} (c/GeV)")
1931  if param == "deltax": hist2d.SetYTitle("#Deltax' (mm)")
1932  if param == "deltadxdz": hist2d.SetYTitle("#Deltadx'/dz (mrad)")
1933  if param == "pterr": hist2d.SetYTitle("#Deltap_{T}/p_{T} (%)")
1934  if param == "curverr": hist2d.SetYTitle("#Deltaq/p_{T} (c/GeV)")
1935  hist2d.Draw("colz")
1936  hist.SetMarkerColor(ROOT.kBlack)
1937  hist.SetLineColor(ROOT.kBlack)
1938  hist.Draw("same")
1939  #histCOPY = hist.Clone()
1940  #histCOPY.SetXTitle("")
1941  #histCOPY.SetYTitle("")
1942 
1943  #if widebins:
1944  # histCOPY.Draw("samee1")
1945  # histCOPY.Draw("sameaxis")
1946  #else:
1947  # histCOPY.Draw("same")
1948  # histCOPY.Draw("sameaxis")
1949 
1950  if fitline:
1951  f.Draw("same")
1952  #f2.Draw("same")
1953  #f3.Draw("same")
1954 
1955  hpeaks.SetMarkerStyle(20)
1956  hpeaks.SetMarkerSize(0.9)
1957  hpeaks.SetMarkerColor(ROOT.kRed)
1958  hpeaks.SetLineColor(ROOT.kRed)
1959  hpeaks.SetLineWidth(2)
1960  #if fitpeaks: hpeaks.Draw("same")
1961  hpeaks.Draw("same")
1962 
1963  #tline1 = ROOT.TLine(hist.GetBinLowEdge(1), -window, hist.GetBinLowEdge(1), window)
1964  #tline2 = ROOT.TLine(hist.GetBinLowEdge(1), window, -hist.GetBinLowEdge(1), window)
1965  #tline3 = ROOT.TLine(-hist.GetBinLowEdge(1), window, -hist.GetBinLowEdge(1), -window)
1966  #tline4 = ROOT.TLine(-hist.GetBinLowEdge(1), -window, hist.GetBinLowEdge(1), -window)
1967  tline5 = ROOT.TLine(-hist.GetBinLowEdge(1), 0., hist.GetBinLowEdge(1), 0.)
1968  tline5.Draw()
1969  #for t in tline1, tline2, tline3, tline4, tline5: t.Draw()
1970 
def curvatureplot
&quot;param&quot; may be one of &quot;deltax&quot; (Delta x position residuals), &quot;deltadxdz&quot; (Delta (dx/dz) angular resid...
T sqrt(T t)
Definition: SSEVec.h:48
def createPeaksProfile
def plotscripts.DBdiff (   database1,
  database2,
  reports1,
  reports2,
  window = 10.,
  windows = None,
  selection = None,
  phi = False,
  color = ROOT.kBlue-8,
  style = 1,
  bins = 50,
  normalized = False,
  getvalues = False,
  name = "tmp",
  canvas = None,
  reportdiff = False,
  inlog = False 
)

Definition at line 485 of file plotscripts.py.

References funct.abs(), python.multivaluedict.append(), getReportByPostalAddress(), bookConverter.max, corrVsCorr.selection, and mathSSE.sqrt().

Referenced by DBMC().

486  style=1, bins=50, normalized=False, getvalues=False, name="tmp", canvas=None, reportdiff=False, inlog=False ):
487 
488  tdrStyle.SetOptStat("emrou")
489  tdrStyle.SetStatW(0.40)
490 
491  wnd = [window]*6
492  if windows is not None:
493  i=0
494  for w in windows:
495  wnd[i] = windows[i]
496  i+=1
497 
498  global hx, hy, hz, hphix, hphiy, hphiz
499 
500  if phi:
501  hx = ROOT.TH1F("%s_phi" % name, "", bins, -wnd[0], wnd[0])
502  else:
503  hx = ROOT.TH1F("%s_x" % name, "", bins, -wnd[0], wnd[0])
504  hy = ROOT.TH1F("%s_y" % name, "", bins, -wnd[1], wnd[1])
505  hz = ROOT.TH1F("%s_z" % name, "", bins, -wnd[2], wnd[2])
506  hphix = ROOT.TH1F("%s_phix" % name, "", bins, -wnd[3], wnd[3])
507  hphiy = ROOT.TH1F("%s_phiy" % name, "", bins, -wnd[4], wnd[4])
508  hphiz = ROOT.TH1F("%s_phiz" % name, "", bins, -wnd[5], wnd[5])
509 
510  for r1 in reports1:
511  if selection is None or (selection.func_code.co_argcount == len(r1.postal_address) and selection(*r1.postal_address)):
512  if reports2 is None:
513  r2 = Report(r1.chamberId, r1.postal_address, r1.name)
514  r2.add_parameters(ValErr(0., 0., 0.), ValErr(0., 0., 0.), ValErr(0., 0., 0.),
515  ValErr(0., 0., 0.), ValErr(0., 0., 0.), ValErr(0., 0., 0.), 0., 0., 0., 0.)
516  else:
517  r2 = getReportByPostalAddress(r1.postal_address, reports2)
518  if r2 is None: continue
519 
520  found = False
521  if r1.postal_address[0] == "DT":
522  if r1.postal_address[1:] in database1.dt:
523  found = True
524  db1 = database1.dt[r1.postal_address[1:]]
525  if database2 is None:
526  db2 = DTAlignable()
527  db2.x = db2.y = db2.z = db2.phix = db2.phiy = db2.phiz = 0.
528  db2.xx = db2.xy = db2.xz = db2.yx = db2.yy = db2.yz = db2.zx = db2.zy = db2.zz = 0.
529  else:
530  db2 = database2.dt[r1.postal_address[1:]]
531 
532  else:
533  # skip ME1/a
534  if r1.postal_address[2]==1 and r1.postal_address[3]==4: continue
535  if r1.postal_address[1:] in database1.csc:
536  found = True
537  db1 = database1.csc[r1.postal_address[1:]]
538  if database2 is None:
539  db2 = CSCAlignable()
540  db2.x = db2.y = db2.z = db2.phix = db2.phiy = db2.phiz = 0.
541  db2.xx = db2.xy = db2.xz = db2.yx = db2.yy = db2.yz = db2.zx = db2.zy = db2.zz = 0.
542  else:
543  db2 = database2.csc[r1.postal_address[1:]]
544 
545  if found and r1.status == "PASS" and r2.status == "PASS":
546  if r1.deltax is not None and r2.deltax is not None and r1.deltax.error is not None and \
547  r2.deltax.error is not None and (r1.deltax.error**2 + r2.deltax.error**2) > 0.:
548  delta = db1.x - db2.x
549  if reportdiff: delta -= r1.deltax.value
550  if normalized:
551  fill = delta/sqrt(r1.deltax.error**2 + r2.deltax.error**2) * signConventions[r1.postal_address][0]
552  else:
553  if phi:
554  fill = delta/signConventions[r1.postal_address][3] * 1000. * signConventions[r1.postal_address][0]
555  else:
556  fill = delta * 10. * signConventions[r1.postal_address][0]
557  hx.Fill(fill)
558  if getvalues not in (False, None):
559  getvalues["x"].append((fill, 10. * sqrt(r1.deltax.error**2 + r2.deltax.error**2)))
560 
561  if r1.deltay is not None and r2.deltay is not None and r1.deltay.error is not None and \
562  r2.deltay.error is not None and (r1.deltay.error**2 + r2.deltay.error**2) > 0.:
563  delta = db1.y - db2.y
564  if reportdiff: delta -= r1.deltay.value
565  if normalized:
566  fill = delta/sqrt(r1.deltay.error**2 + r2.deltay.error**2) * signConventions[r1.postal_address][1]
567  else:
568  fill = delta * 10. * signConventions[r1.postal_address][1]
569  hy.Fill(fill)
570  if getvalues not in (False, None):
571  getvalues["y"].append((fill, 10. * sqrt(r1.deltay.error**2 + r2.deltay.error**2)))
572 
573  if r1.deltaz is not None and r2.deltaz is not None and r1.deltaz.error is not None and \
574  r2.deltaz.error is not None and (r1.deltaz.error**2 + r2.deltaz.error**2) > 0.:
575  delta = db1.z - db2.z
576  if reportdiff: delta -= r1.deltaz.value
577  if normalized:
578  fill = delta/sqrt(r1.deltaz.error**2 + r2.deltaz.error**2) * signConventions[r1.postal_address][2]
579  else:
580  fill = delta * 10. * signConventions[r1.postal_address][2]
581  hz.Fill(fill)
582  if getvalues not in (False, None):
583  getvalues["z"].append((fill, 10. * sqrt(r1.deltaz.error**2 + r2.deltaz.error**2)))
584 
585  if r1.deltaphix is not None and r2.deltaphix is not None and r1.deltaphix.error is not None and \
586  r2.deltaphix.error is not None and (r1.deltaphix.error**2 + r2.deltaphix.error**2) > 0.:
587  delta = db1.phix - db2.phix
588  if reportdiff: delta -= r1.deltaphix.value
589  if normalized:
590  fill = delta/sqrt(r1.deltaphix.error**2 + r2.deltaphix.error**2)
591  else:
592  fill = delta * 1000.
593  hphix.Fill(fill)
594  if getvalues not in (False, None):
595  getvalues["phix"].append((fill, 10. * sqrt(r1.deltaphix.error**2 + r2.deltaphix.error**2)))
596 
597  if r1.deltaphiy is not None and r2.deltaphiy is not None and r1.deltaphiy.error is not None and \
598  r2.deltaphiy.error is not None and (r1.deltaphiy.error**2 + r2.deltaphiy.error**2) > 0.:
599  delta = db1.phiy - db2.phiy
600  if reportdiff:
601  delta -= r1.deltaphiy.value
602  if abs(delta)>0.02/1000: print r1.postal_address, 1000*delta, "=", 1000*db1.phiy - 1000*db2.phiy, "-", 1000*r1.deltaphiy.value, "... ",1000*db1.phiy , 1000*db2.phiy
603  if normalized:
604  fill = delta/sqrt(r1.deltaphiy.error**2 + r2.deltaphiy.error**2)
605  else:
606  fill = delta * 1000.
607  hphiy.Fill(fill)
608  if getvalues not in (False, None):
609  getvalues["phiy"].append((fill, 10. * sqrt(r1.deltaphiy.error**2 + r2.deltaphiy.error**2)))
610 
611  if r1.deltaphiz is not None and r2.deltaphiz is not None and r1.deltaphiz.error is not None and \
612  r2.deltaphiz.error is not None and (r1.deltaphiz.error**2 + r2.deltaphiz.error**2) > 0.:
613  delta = db1.phiz - db2.phiz
614  if reportdiff: delta -= r1.deltaphiz.value
615  if normalized:
616  fill = delta/sqrt(r1.deltaphiz.error**2 + r2.deltaphiz.error**2)
617  else:
618  fill = delta * 1000.
619  hphiz.Fill(fill)
620  if getvalues not in (False, None):
621  getvalues["phiz"].append((fill, 10. * sqrt(r1.deltaphiz.error**2 + r2.deltaphiz.error**2)))
622 
623  if not normalized:
624  if phi:
625  hx.SetXTitle("#delta_{#phi} position (mrad)")
626  else:
627  hx.SetXTitle("#delta_{x'} (mm)")
628  hy.SetXTitle("#delta_{y'} (mm)")
629  hz.SetXTitle("#delta_{z'} (mm)")
630  hphix.SetXTitle("#delta_{#phi_{x}} (mrad)")
631  hphiy.SetXTitle("#delta_{#phi_{y}} (mrad)")
632  hphiz.SetXTitle("#delta_{#phi_{z}} (mrad)")
633  if reportdiff:
634  if phi:
635  hx.SetXTitle("#delta_{#phi}(XML) - #delta_{#phi}(report) position (mrad)")
636  else:
637  hx.SetXTitle("#delta_{x'}(XML) - #delta_{x'}(report) (mm)")
638  hy.SetXTitle("#delta_{y'}(XML) - #delta_{y'}(report) (mm)")
639  hz.SetXTitle("#delta_{z'}(XML) - #delta_{z'}(report) (mm)")
640  hphix.SetXTitle("#delta_{#phi_{x}}(XML) - #delta_{#phi_{x}}(report) (mrad)")
641  hphiy.SetXTitle("#delta_{#phi_{y}}(XML) - #delta_{#phi_{y}}(report) (mrad)")
642  hphiz.SetXTitle("#delta_{#phi_{z}}(XML) - #delta_{#phi_{z}}(report) (mrad)")
643  else:
644  if phi:
645  hx.SetXTitle("#delta_{#phi}/#sigma_{#phi} position")
646  else:
647  hx.SetXTitle("#delta_{x'}/#sigma_{x'}")
648  hy.SetXTitle("#delta_{y'}/#sigma_{y'}")
649  hz.SetXTitle("#delta_{z'}/#sigma_{z'}")
650  hphix.SetXTitle("#delta_{#phi_{x}}/#sigma_{#phi_{x}}")
651  hphiy.SetXTitle("#delta_{#phi_{y}}/#sigma_{#phi_{y}}")
652  hphiz.SetXTitle("#delta_{#phi_{z}}/#sigma_{#phi_{z}}")
653 
654  for h in hx, hy, hz, hphix, hphiy, hphiz:
655  h.GetXaxis().CenterTitle()
656  h.GetYaxis().CenterTitle()
657  h.SetFillColor(color)
658  h.SetLineStyle(style)
659 
660  if canvas is not None: c = canvas
661  else: c = c1
662 
663  if normalized:
664  fx = ROOT.TF1("fx", "%g * exp(-x**2/2.)/sqrt(2.*3.1415926)" % (hx.GetEntries()*2.*window/bins), -window, window)
665  fy = ROOT.TF1("fy", "%g * exp(-x**2/2.)/sqrt(2.*3.1415926)" % (hy.GetEntries()*2.*window/bins), -window, window)
666  fz = ROOT.TF1("fz", "%g * exp(-x**2/2.)/sqrt(2.*3.1415926)" % (hz.GetEntries()*2.*window/bins), -window, window)
667  fphix = ROOT.TF1("fphix", "%g * exp(-x**2/2.)/sqrt(2.*3.1415926)" % (hphix.GetEntries()*2.*window/bins), -window, window)
668  fphiy = ROOT.TF1("fphiy", "%g * exp(-x**2/2.)/sqrt(2.*3.1415926)" % (hphiy.GetEntries()*2.*window/bins), -window, window)
669  fphiz = ROOT.TF1("fphiz", "%g * exp(-x**2/2.)/sqrt(2.*3.1415926)" % (hphiz.GetEntries()*2.*window/bins), -window, window)
670  for f in fx, fy, fz, fphix, fphiy, fphiz:
671  f.SetLineWidth(2)
672  f.SetLineColor(ROOT.kBlue)
673  for h, f in (hx, fx), (hy, fy), (hz, fz), (hphix, fphix), (hphiy, fphiy), (hphiz, fphiz):
674  h.SetAxisRange(0, 1.1*max(h.GetMaximum(), f.GetMaximum()), "Y")
675 
676  c.Clear()
677  c.Divide(3, 2)
678  c.GetPad(1).cd(); hx.Draw(); fx.Draw("same")
679  c.GetPad(2).cd(); hy.Draw(); fy.Draw("same")
680  c.GetPad(3).cd(); hz.Draw(); fz.Draw("same")
681  c.GetPad(4).cd(); hphix.Draw(); fphix.Draw("same")
682  c.GetPad(5).cd(); hphiy.Draw(); fphiy.Draw("same")
683  c.GetPad(6).cd(); hphiz.Draw(); fphiz.Draw("same")
684  return hx, hy, hz, hphix, hphiy, hphiz, fx, fy, fz, fphix, fphiy, fphiz
685  else:
686  nvar = 6
687 
688  c.Clear()
689  if nvar == 4: c.Divide(2, 2)
690  if nvar == 6: c.Divide(3, 2)
691  c.GetPad(1).cd(); hx.Draw()
692  c.GetPad(2).cd(); hy.Draw()
693  if nvar == 4:
694  c.GetPad(3).cd(); hphiy.Draw()
695  c.GetPad(4).cd(); hphiz.Draw()
696  if nvar == 6:
697  c.GetPad(3).cd(); hz.Draw()
698  c.GetPad(4).cd(); hphix.Draw()
699  c.GetPad(5).cd(); hphiy.Draw()
700  c.GetPad(6).cd(); hphiz.Draw()
701 
702  if inlog:
703  if hx.GetEntries()>0: c.GetPad(1).SetLogy(1)
704  if hy.GetEntries()>0: c.GetPad(2).SetLogy(1)
705  if nvar == 4:
706  if hphiy.GetEntries()>0: c.GetPad(3).SetLogy(1)
707  if hphiz.GetEntries()>0: c.GetPad(4).SetLogy(1)
708  if nvar == 6:
709  if hz.GetEntries()>0: c.GetPad(3).SetLogy(1)
710  if hphix.GetEntries()>0: c.GetPad(4).SetLogy(1)
711  if hphiy.GetEntries()>0: c.GetPad(5).SetLogy(1)
712  if hphiz.GetEntries()>0: c.GetPad(6).SetLogy(1)
713 
714  return hx, hy, hz, hphix, hphiy, hphiz
715 
716 
selection
main part
Definition: corrVsCorr.py:98
T sqrt(T t)
Definition: SSEVec.h:48
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def getReportByPostalAddress
Definition: plotscripts.py:468
def plotscripts.DBdiffVersus (   quantity,
  versus,
  database1,
  database2,
  reports1,
  reports2,
  windwselection = None,
  color = ROOT.kBlack 
)

Definition at line 720 of file plotscripts.py.

References corrVsCorr.selection.

Referenced by DBMCVersus().

721 def DBdiffVersus(quantity, versus, database1, database2, reports1, reports2, windwselection=None, color=ROOT.kBlack):
722  tdrStyle.SetOptStat("")
723 
724  domain = []
725  values = []
726  errors = []
727 
728  for r1 in reports1:
729  if selection is None or (selection.func_code.co_argcount == len(r1.postal_address) and selection(*r1.postal_address)):
730  if reports2 is None:
731  r2 = Report(r1.chamberId, r1.postal_address, r1.name)
732  r2.add_parameters(ValErr(0., 0., 0.), ValErr(0., 0., 0.), ValErr(0., 0., 0.),
733  ValErr(0., 0., 0.), ValErr(0., 0., 0.), ValErr(0., 0., 0.), 0., 0., 0.)
734  else:
735  found = False
736  for r2 in reports2:
737  if r1.postal_address == r2.postal_address:
738  found = True
739  break
740  if not found: continue
741 
742  found = False
743  if r1.postal_address[0] == "DT":
744  if r1.postal_address[1:] in database1.dt:
745  found = True
746  db1 = database1.dt[r1.postal_address[1:]]
747  if database2 is None:
748  db2 = DTAlignable()
749  db2.x = db2.y = db2.z = db2.phix = db2.phiy = db2.phiz = 0.
750  db2.xx = db2.xy = db2.xz = db2.yx = db2.yy = db2.yz = db2.zx = db2.zy = db2.zz = 0.
751  else:
752  db2 = database2.dt[r1.postal_address[1:]]
753  else:
754  if r1.postal_address[1:] in database1.csc:
755  found = True
756  db1 = database1.csc[r1.postal_address[1:]]
757  if database2 is None:
758  db2 = CSCAlignable()
759  db2.x = db2.y = db2.z = db2.phix = db2.phiy = db2.phiz = 0.
760  db2.xx = db2.xy = db2.xz = db2.yx = db2.yy = db2.yz = db2.zx = db2.zy = db2.zz = 0.
761  else:
762  db2 = database2.csc[r1.postal_address[1:]]
763 
764  if found and r1.status == "PASS" and r2.status == "PASS":
765  okay = False
766 
767  if quantity == "phi":
768  if r1.deltax is not None and r2.deltax is not None and r1.deltax.error is not None and \
769  r2.deltax.error is not None and (r1.deltax.error**2 + r2.deltax.error**2) > 0.:
770  okay = True
771  values.append((db1.x - db2.x)/
772  signConventions[r1.postal_address][3] * 1000. * signConventions[r1.postal_address][0])
773  errors.append((r1.deltax.error**2 + r2.deltax.error**2)/
774  signConventions[r1.postal_address][3] * 1000. * signConventions[r1.postal_address][0])
775 
776  elif quantity == "x":
777  if r1.deltax is not None and r2.deltax is not None and r1.deltax.error is not None and \
778  r2.deltax.error is not None and (r1.deltax.error**2 + r2.deltax.error**2) > 0.:
779  okay = True
780  values.append((db1.x - db2.x) * 10. * signConventions[r1.postal_address][0])
781  errors.append((r1.deltax.error**2 + r2.deltax.error**2) * 10. * signConventions[r1.postal_address][0])
782 
783  elif quantity == "y":
784  if r1.deltay is not None and r2.deltay is not None and r1.deltay.error is not None and \
785  r2.deltay.error is not None and (r1.deltay.error**2 + r2.deltay.error**2) > 0.:
786  okay = True
787  values.append((db1.y - db2.y) * 10. * signConventions[r1.postal_address][1])
788  errors.append((r1.deltay.error**2 + r2.deltay.error**2) * 10. * signConventions[r1.postal_address][1])
789 
790  elif quantity == "z":
791  if r1.deltaz is not None and r2.deltaz is not None and r1.deltaz.error is not None and \
792  r2.deltaz.error is not None and (r1.deltaz.error**2 + r2.deltaz.error**2) > 0.:
793  okay = True
794  values.append((db1.z - db2.z) * 10. * signConventions[r1.postal_address][2])
795  errors.append((r1.deltaz.error**2 + r2.deltaz.error**2) * 10. * signConventions[r1.postal_address][2])
796 
797  elif quantity == "phix":
798  if r1.deltaphix is not None and r2.deltaphix is not None and r1.deltaphix.error is not None and \
799  r2.deltaphix.error is not None and (r1.deltaphix.error**2 + r2.deltaphix.error**2) > 0.:
800  okay = True
801  values.append((db1.phix - db2.phix) * 1000.)
802  errors.append((r1.deltaphix.error**2 + r2.deltaphix.error**2) * 1000.)
803 
804  elif quantity == "phiy":
805  if r1.deltaphiy is not None and r2.deltaphiy is not None and r1.deltaphiy.error is not None and \
806  r2.deltaphiy.error is not None and (r1.deltaphiy.error**2 + r2.deltaphiy.error**2) > 0.:
807  okay = True
808  values.append((db1.phiy - db2.phiy) * 1000.)
809  errors.append((r1.deltaphiy.error**2 + r2.deltaphiy.error**2) * 1000.)
810 
811  elif quantity == "phiz":
812  if r1.deltaphiz is not None and r2.deltaphiz is not None and r1.deltaphiz.error is not None and \
813  r2.deltaphiz.error is not None and (r1.deltaphiz.error**2 + r2.deltaphiz.error**2) > 0.:
814  okay = True
815  values.append((db1.phiz - db2.phiz) * 1000.)
816  errors.append((r1.deltaphiz.error**2 + r2.deltaphiz.error**2) * 1000.)
817 
818  else: raise Exception
819 
820  if okay:
821  if versus == "r": domain.append(signConventions[r1.postal_address][3])
822  elif versus == "phi": domain.append(signConventions[r1.postal_address][4])
823  elif versus == "z": domain.append(signConventions[r1.postal_address][5])
824  else: raise Exception
825 
826  if versus == "r":
827  bkgndhist = ROOT.TH1F("bkgndhist", "", 100, 0., 800.)
828  bkgndhist.SetXTitle("R (cm)")
829  elif versus == "phi":
830  bkgndhist = ROOT.TH1F("bkgndhist", "", 100, -pi, pi)
831  bkgndhist.SetXTitle("#phi (rad)")
832  elif versus == "z":
833  bkgndhist = ROOT.TH1F("bkgndhist", "", 100, -1100., 1100.)
834  bkgndhist.SetXTitle("z (cm)")
835  bkgndhist.GetXaxis().CenterTitle()
836 
837  bkgndhist.SetAxisRange(-window, window, "Y")
838  if quantity == "phi": bkgndhist.SetYTitle("#delta_{#phi} position (mrad)")
839  elif quantity == "x": bkgndhist.SetYTitle("#delta_{x'} (mm)")
840  elif quantity == "y": bkgndhist.SetYTitle("#delta_{y'} (mm)")
841  elif quantity == "z": bkgndhist.SetYTitle("#delta_{z'} (mm)")
842  elif quantity == "phix": bkgndhist.SetYTitle("#delta_{#phi_{x}} (mrad)")
843  elif quantity == "phiy": bkgndhist.SetYTitle("#delta_{#phi_{y}} (mrad)")
844  elif quantity == "phiz": bkgndhist.SetYTitle("#delta_{#phi_{z}} (mrad)")
845  else: raise Exception
846  bkgndhist.GetYaxis().CenterTitle()
847 
848  if len(domain) == 0:
849  tgraph = ROOT.TGraphErrors(0)
850  else:
851  tgraph = ROOT.TGraphErrors(len(domain), array.array("d", domain), array.array("d", values),
852  array.array("d", [0.]*len(domain)), array.array("d", errors))
853  tgraph.SetMarkerColor(color)
854  tgraph.SetLineColor(color)
855 
856  bkgndhist.Draw()
857  if tgraph.GetN() > 0: tgraph.Draw("p")
858  return bkgndhist, tgraph, domain, values, errors
def DBdiffVersus
Definition: plotscripts.py:720
selection
main part
Definition: corrVsCorr.py:98
def plotscripts.DBMC (   database,
  reports,
  window = 10.,
  windows = None,
  selection = None,
  phi = False,
  color = ROOT.kBlue-8,
  style = 1,
  bins = 50,
  normalized = False,
  getvalues = False,
  name = "",
  canvas = None,
  reportdiff = False,
  inlog = True 
)

Definition at line 478 of file plotscripts.py.

References DBdiff().

Referenced by getReportByPostalAddress().

479  color=ROOT.kBlue-8, style=1, bins=50, normalized=False, getvalues=False, name="", canvas=None, reportdiff=False, inlog=True):
480  return DBdiff(database, None, reports, None, window, windows, selection, phi, color, style, bins, normalized, getvalues,
481  name, canvas, reportdiff, inlog)
482 
def plotscripts.DBMCVersus (   quantity,
  versus,
  database,
  reports,
  window = 10.,
  selection = None,
  color = ROOT.kBlack 
)

Definition at line 717 of file plotscripts.py.

References DBdiffVersus().

718 def DBMCVersus(quantity, versus, database, reports, window=10., selection=None, color=ROOT.kBlack):
719  return DBdiffVersus(quantity, versus, database, None, reports, None, window, selection, color)
def DBdiffVersus
Definition: plotscripts.py:720
def plotscripts.doTests (   reports,
  pic_ids,
  fname_base,
  fname_dqm,
  run_name 
)

Definition at line 1215 of file plotscripts.py.

References availableCellsCSC(), availableCellsDT(), doTestsForMapPlots(), doTestsForReport(), loadTestResultsMap(), plotmedians(), and writeDQMReport().

1216 def doTests(reports, pic_ids, fname_base, fname_dqm, run_name):
1217  # find available baseline
1218  dts = []
1219  cscs = []
1220  if len(reports)>0:
1221  dts = availableCellsDT(reports)
1222  cscs = availableCellsCSC(reports)
1223  elif len(pic_ids)>0:
1224  dts = [id for id in pic_ids if 'MB' in id]
1225  cscs = [id for id in pic_ids if 'ME' in id]
1226  mulist = ['Run: '+run_name,['ALL',['MU']],['DT',dts],['CSC',cscs]]
1227  ff = open(fname_base,mode="w")
1228  print >>ff, "var MU_LIST = ["
1229  json.dump(mulist,ff)
1230  print >>ff, "];"
1231  ff.close()
1232 
1233  doTestsForReport(dts,reports)
1234  doTestsForReport(cscs,reports)
1235 
1236  loadTestResultsMap(run_name)
1237  doTestsForMapPlots(dts)
1238  doTestsForMapPlots(cscs)
1239 
1240  writeDQMReport(fname_dqm, run_name)
1241 
def availableCellsCSC
Definition: plotscripts.py:965
def writeDQMReport
def availableCellsDT
Definition: plotscripts.py:919
def doTestsForMapPlots
def loadTestResultsMap
def doTestsForReport
def plotscripts.doTestsForMapPlots (   cells)

Definition at line 1142 of file plotscripts.py.

References addToTestResults(), join(), python.multivaluedict.map(), testDeltaWithin5Sigma(), testEntry(), and testZeroWithin5Sigma().

Referenced by doTests().

1143 def doTestsForMapPlots(cells):
1144  for c in cells:
1145  res = []
1146 
1147  scope = "zzz"
1148  if c[0:2]=="MB": scope = "DT"
1149  if c[0:2]=="ME": scope = "CSC"
1150  if scope == "zzz":
1151  print "strange cell ID: ", c
1152  return None
1153 
1154  if MAP_RESULTS_FITSIN.has_key(c):
1155  t = MAP_RESULTS_FITSIN[c]
1156  t_a = testZeroWithin5Sigma(t['a'])
1157  t_s = testZeroWithin5Sigma(t['sin'])
1158  t_c = testZeroWithin5Sigma(t['cos'])
1159  if t_a+t_s+t_c >0:
1160  descr = "map fitsin 5 sigma away from 0; pulls : a=%.2f sin=%.2f, cos=%.2f" % (t_a,t_s,t_c)
1161  res.append(testEntry("MAP_FITSIN",scope,descr,"SEVERE"))
1162 
1163  if MAP_RESULTS_SAWTOOTH.has_key(c):
1164  t = MAP_RESULTS_SAWTOOTH[c]
1165 
1166  t_a = testDeltaWithin5Sigma(t['a'],t['da'])
1167  if len(t_a)>0:
1168  descr = "map discontinuities: %s" % ",".join(map(str,t_a))
1169  res.append(testEntry("MAP_DISCONTIN",scope,descr,"SEVERE"))
1170 
1171  t_b = map(testZeroWithin5Sigma, t['b'])
1172  t_bi = []
1173  for i in range(0,len(t_b)):
1174  if t_b[i]>0: t_bi.append(i+1)
1175  if len(t_bi)>0:
1176  descr = "map sawteeth: %s" % ",".join(map(str,t_bi))
1177  res.append(testEntry("MAP_SAWTEETH",scope,descr,"TOLERABLE"))
1178 
1179  addToTestResults(c,res)
1180 
def addToTestResults
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def doTestsForMapPlots
def testZeroWithin5Sigma
def testDeltaWithin5Sigma
def plotscripts.doTestsForReport (   cells,
  reports 
)

Definition at line 1078 of file plotscripts.py.

References addToTestResults(), idToPostalAddress(), and testEntry().

Referenced by doTests().

1079 def doTestsForReport(cells,reports):
1080  for c in cells:
1081  # can a cell be converted to a chamber postal address?
1082  postal_address = idToPostalAddress(c)
1083  if not postal_address: continue
1084 
1085  # is this chamber in _report?
1086  found = False
1087  for r in reports:
1088  if r.postal_address == postal_address:
1089  found = True
1090  break
1091  if not found: continue
1092 
1093  # chamber's tests result
1094  res = []
1095  scope = postal_address[0]
1096 
1097  # noting could be done if fitting fails
1098  if r.status == "FAIL" or r.status == "MINUITFAIL":
1099  res.append(testEntry("FAILURE",scope,r.status+" failure","CRITICAL"))
1100  addToTestResults(c,res)
1101  continue
1102 
1103  # noting could be done if TOOFEWHITS
1104  nseg = r.posNum + r.negNum
1105  if r.status == "TOOFEWHITS" and nseg>0:
1106  res.append(testEntry("LOW_STAT",scope,"low stat, #segments=%d"%nseg,"LOWSTAT"))
1107  addToTestResults(c,res)
1108  continue
1109 
1110  # set shades of light green according to sidma(dx)
1111  sdx = 10.*r.deltax.error
1112  if sdx>0.5:
1113  if sdx<0.75: res.append(testEntry("LOW_STAT_DDX05",scope,"low stat, delta(dx)=%f #segments=%d" % (sdx,nseg),"LOWSTAT05"))
1114  elif sdx<1.: res.append(testEntry("LOW_STAT_DDX075",scope,"low stat, delta(dx)=%f #segments=%d" % (sdx,nseg),"LOWSTAT075"))
1115  else: res.append(testEntry("LOW_STAT_DDX1",scope,"low stat, delta(dx)=%f #segments=%d" % (sdx,nseg),"LOWSTAT1"))
1116 
1117  # check chi2
1118  if r.redchi2 > 20.: #2.5:
1119  res.append(testEntry("BIG_CHI2",scope,"chi2=%f>20" % r.redchi2,"TOLERABLE"))
1120 
1121  # check medians
1122  medx, meddx = 10.*r.median_x, 1000.*r.median_dxdz
1123  #medy, meddy = 10.*r.median_y, 1000.*r.median_dydz
1124  if medx>2: res.append(testEntry("BIG_MED_X",scope,"median dx=%f>2 mm"%medx,"SEVERE"))
1125  #if medy>3: res.append(testEntry("BIG_MED_Y",scope,"median dy=%f>3 mm"%medy,"SEVERE"))
1126  if meddx>2: res.append(testEntry("BIG_MED_DXDZ",scope,"median d(dx/dz)=%f>2 mrad"%meddx,"SEVERE"))
1127  #if meddy>3: res.append(testEntry("BIG_MED_DYDZ",scope,"median d(dy/dz)=%f>3 mrad"%meddy,"SEVERE"))
1128 
1129  # check residuals far from zero
1130  isDTst4 = False
1131  if postal_address[0] == "DT" and postal_address[2]==4: isDTst4 = True
1132  dx, dy, dpy, dpz = 10.*r.deltax.value, 0., 1000.*r.deltaphiy.value, 1000.*r.deltaphiz.value
1133  if not isDTst4: dy = 10.*r.deltay.value
1134  if dx>0.2: res.append(testEntry("BIG_LAST_ITR_DX",scope,"dx=%f>0.2 mm"%dx,"CRITICAL"))
1135  if dy>0.2: res.append(testEntry("BIG_LAST_ITR_DY",scope,"dy=%f>0.2 mm"%dy,"CRITICAL"))
1136  if dpy>0.2: res.append(testEntry("BIG_LAST_ITR_DPHIY",scope,"dphiy=%f>0.2 mrad"%dpy,"CRITICAL"))
1137  if dpz>0.2: res.append(testEntry("BIG_LAST_ITR_DPHIZ",scope,"dphiz=%f>0.2 mrad"%dpz,"CRITICAL"))
1138  #if ddx>0.03: res.append(testEntry("BIG_DX",scope,"dphix=%f>0.03 mrad"%ddx,"CRITICAL"))
1139 
1140  addToTestResults(c,res)
1141 
def idToPostalAddress
Definition: plotscripts.py:861
def addToTestResults
def doTestsForReport
def plotscripts.getname (   r)

Definition at line 2032 of file plotscripts.py.

References funct.abs().

Referenced by bellcurves(), and polynomials().

2033 def getname(r):
2034  if r.postal_address[0] == "DT":
2035  wheel, station, sector = r.postal_address[1:]
2036  return "DT wheel %d, station %d, sector %d" % (wheel, station, sector)
2037  elif r.postal_address[0] == "CSC":
2038  endcap, station, ring, chamber = r.postal_address[1:]
2039  if endcap != 1: station = -1 * abs(station)
2040  return "CSC ME%d/%d chamber %d" % (station, ring, chamber)
2041 
ddt=[0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.]
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def plotscripts.getReportByPostalAddress (   postal_address,
  report 
)

Definition at line 468 of file plotscripts.py.

References DBMC().

Referenced by corrections2D(), and DBdiff().

469 def getReportByPostalAddress(postal_address, report):
470  for r in report:
471  if postal_address == r.postal_address:
472  return r
473  return None
474 
def getReportByPostalAddress
Definition: plotscripts.py:468
def plotscripts.idToPostalAddress (   id)

Definition at line 861 of file plotscripts.py.

Referenced by doTestsForReport(), mapplot(), and stationIndex().

862 def idToPostalAddress(id):
863  # only len==9 ids can correspond to valid postal address
864  if len(id)!=9: return None
865  if id[0:2]=="MB":
866  #print id
867  pa = ("DT", int(id[2:4]), int(id[5]), int(id[7:9]))
868  #print pa
869  if pa[1]<-2 or pa[1]>2: return None
870  if pa[2]>4: return None
871  if pa[3]<1 or pa[3]>14 or (pa[3]==4 and pa[3]>12): return None
872  return pa
873  elif id[0:2]=="ME":
874  if id[2]=="+": ec=1
875  elif id[2]=="-": ec=2
876  else: return None
877  pa = ("CSC", ec, int(id[3]), int(id[5]), int(id[7:9]))
878  if pa[2]<1 or pa[2]>4: return None
879  if pa[3]<1 or pa[3]>4 or (pa[2]>1 and pa[3]>2): return None
880  if pa[4]<1 or pa[4]>36 or (pa[2]>1 and pa[3]==1 and pa[4]>18): return None
881  return pa
882  else: return None
883 
def idToPostalAddress
Definition: plotscripts.py:861
def plotscripts.loadTestResultsMap (   run_name)

Definition at line 1189 of file plotscripts.py.

Referenced by doTests().

1190 def loadTestResultsMap(run_name):
1191  print "tmp_test_results_map__%s.pkl" % run_name, os.access("tmp_test_results_map__%s.pkl" % run_name,os.F_OK)
1192  if not os.access("tmp_test_results_map__%s.pkl" % run_name,os.F_OK): return None
1193  global MAP_RESULTS_FITSIN, MAP_RESULTS_SAWTOOTH
1194  ff = open("tmp_test_results_map__%s.pkl" % run_name, "rb")
1195  MAP_RESULTS_SAWTOOTH = pickle.load(ff)
1196  MAP_RESULTS_FITSIN = pickle.load(ff)
1197  ff.close()
1198  #execfile("tmp_test_results_map__%s.py" % run_name)
1199  #print 'asasas', MAP_RESULTS_FITSIN
1200  return True
def loadTestResultsMap
def plotscripts.mapNameToId (   name)

Definition at line 1761 of file plotscripts.py.

Referenced by mapplot().

1762 def mapNameToId(name):
1763  if "DT" in name:
1764  wh = "-ALL"
1765  if name.find('wh')>1: wh = name[name.find('wh')+2]
1766  if wh == "A": w = "-2"
1767  elif wh == "B": w = "-1"
1768  elif wh == "C": w = "-0"
1769  elif wh == "D": w = "+1"
1770  elif wh == "E": w = "+2"
1771  elif wh == "-ALL": w = "-ALL"
1772  else: return None
1773  station=''
1774  if wh == "-ALL":
1775  if name.find('sec')<0: return None
1776  station = name[name.find('sec')-1]
1777  sector = ''
1778  sector = name[name.find('sec')+3:name.find('sec')+5]
1779  return "MB%s/%s/%s" % (w, station, sector)
1780  if name.find('st')>1: station = name[name.find('st')+2]
1781  else: return None
1782  return "MB%s/%s" % (w, station)
1783  elif "CSC" in name:
1784  p = name.find('me')
1785  if p<0: return None
1786  if name[p+2]=="p": endcap = "+"
1787  elif name[p+2]=="m": endcap = "-"
1788  else: return None
1789  station = name[p+3]
1790  pch = name.find('ch')
1791  if pch<0:
1792  ring = name[p+4]
1793  return "ME%s%s/%s" % (endcap, station, ring)
1794  ring = 'ALL'
1795  chamber = name[pch+2:pch+4]
1796  return "ME%s%s/%s/%s" % (endcap, station, ring, chamber)
1797  return None
1798 
def plotscripts.mapplot (   tfiles,
  name,
  param,
  mode = "from2d",
  window = 10.,
  abscissa = None,
  title = "",
  widebins = False,
  fitsine = False,
  fitline = False,
  reset_palette = False,
  fitsawteeth = False,
  fitpeaks = False,
  peaksbins = 1,
  fixfitpars = {},
  args 
)

Definition at line 1445 of file plotscripts.py.

References funct.abs(), createPeaksProfile(), idToPostalAddress(), mapNameToId(), phiedges2c(), philines(), rlines(), set_palette(), mathSSE.sqrt(), stationIndex(), and zlines().

Referenced by createPeaksProfile(), alignmentValidation.doMapPlotsCSC(), and alignmentValidation.doMapPlotsDT().

1446  widebins=False, fitsine=False, fitline=False, reset_palette=False, fitsawteeth=False, fitpeaks=False, peaksbins=1, fixfitpars={}, **args):
1447  tdrStyle.SetOptTitle(1)
1448  tdrStyle.SetTitleBorderSize(0)
1449  tdrStyle.SetOptStat(0)
1450  #tdrStyle.SetOptStat("emrou")
1451  tdrStyle.SetOptFit(0)
1452  tdrStyle.SetTitleFontSize(0.05)
1453  tdrStyle.SetPadRightMargin(0.1) # to see the pallete labels on the left
1454 
1455  c1.Clear()
1456  c1.ResetAttPad()
1457 
1458  if reset_palette: set_palette("blues")
1459  global hist, hist2d, hist2dweight, tline1, tline2, tline3
1460 
1461  if fitsine or fitsawteeth:
1462  id = mapNameToId(name)
1463  if not id:
1464  print "bad id for ", name
1465  raise Exception
1466 
1467  hdir = "AlignmentMonitorMuonSystemMap1D/iter1/"
1468  hpref= "%s_%s" % (name, param)
1469  hhh = hdir+hpref
1470 
1471  combine_all = False
1472  if "ALL" in name and ("CSCvsr" in name or "DTvsz" in name): combine_all = True
1473 
1474  add1d = ("vsphi" in name) and (param == "x")
1475 
1476  if "h2d" in args:
1477  hist2d = args["h2d"].Clone(hpref+"_2d_")
1478  if "CSC" in name and add1d: hist1d = args["h1d"].Clone(hpref+"_1d_")
1479 
1480  elif combine_all:
1481  nch = 12
1482  if "DT" in name and name[6:9]=='st4': nch = 14
1483  if "CSC" in name: nch = 36
1484  chambers = ["%02d" % ch for ch in range (2,nch+1)]
1485 
1486  ch_hhh = hhh.replace('ALL','01')
1487  ch_hpref = hpref.replace('ALL','01')
1488  hist2d = tfiles[0].Get(ch_hhh+"_2d").Clone(ch_hpref+"_2d_")
1489  if "CSC" in name and add1d: hist1d = tfiles[0].Get(ch_hhh+"_1d").Clone(ch_hpref+"_1d_")
1490 
1491  for ch in chambers:
1492  ch_hhh = hhh.replace('ALL',ch)
1493  ch_hpref = hpref.replace('ALL',ch)
1494  hist2d.Add(tfiles[0].Get(ch_hhh+"_2d"))
1495  if "CSC" in name and add1d: hist1d.Add(tfiles[0].Get(ch_hhh+"_1d"))
1496  for tfile in tfiles[1:]:
1497  hist2d.Add(tfile.Get(ch_hhh+"_2d"))
1498  if "CSC" in name and add1d: hist1d.Add(tfile.Get(ch_hhh+"_1d"))
1499 
1500  else:
1501  hist2d = tfiles[0].Get(hhh+"_2d").Clone(hpref+"_2d_")
1502  if "CSC" in name and add1d: hist1d = tfiles[0].Get(hhh+"_1d").Clone(hpref+"_1d_")
1503  for tfile in tfiles[1:]:
1504  hist2d.Add(tfile.Get(hhh+"_2d"))
1505  if "CSC" in name and add1d: hist1d.Add(tfile.Get(hhh+"_1d"))
1506 
1507 
1508  if mode == "from2d":
1509  the2d = hist2d
1510 
1511  hist = the2d.ProjectionX()
1512  hist.Reset()
1513 
1514  skip = 1
1515  if widebins:
1516  hist.Rebin(10)
1517  skip = 10
1518 
1519  #f = ROOT.TF1("g", "gaus", -40., 40)
1520  for i in xrange(0, int(the2d.GetNbinsX()), skip):
1521  tmp = the2d.ProjectionY("tmp", i+1, i + skip)
1522  if tmp.GetEntries() > 1:
1523  #tmp.Fit("g","LNq")
1524  hist.SetBinContent(i/skip+1, tmp.GetMean())
1525  hist.SetBinError(i/skip+1, ROOT.TMath.StudentQuantile(0.841345,tmp.GetEntries()) * tmp.GetRMS() / sqrt(tmp.GetEntries()))
1526  #hist.SetBinError(i/skip+1, tmp.GetRMS() / sqrt(tmp.GetEntries()))
1527  #hist.SetBinError(i/skip+1, f.GetParameter(2))
1528  else:
1529  #hist.SetBinContent(i/skip+1, 2000.)
1530  #hist.SetBinError(i/skip+1, 1000.)
1531  hist.SetBinContent(i/skip+1, 0.)
1532  hist.SetBinError(i/skip+1, 0.)
1533 
1534  hpeaks = createPeaksProfile(the2d, peaksbins)
1535 
1536  else:
1537  raise Exception
1538 
1539  hist.SetAxisRange(-window, window, "Y")
1540  if abscissa is not None: hist.SetAxisRange(abscissa[0], abscissa[1], "X")
1541  hist.SetMarkerStyle(20)
1542  hist.SetMarkerSize(0.75)
1543  hist.GetXaxis().CenterTitle()
1544  hist.GetYaxis().CenterTitle()
1545  hist.GetYaxis().SetTitleOffset(0.75)
1546  hist.GetXaxis().SetTitleSize(0.05)
1547  hist.GetYaxis().SetTitleSize(0.05)
1548  hist.SetTitle(title)
1549  if "vsphi" in name: hist.SetXTitle("Global #phi position (rad)")
1550  elif "vsz" in name: hist.SetXTitle("Global z position (cm)")
1551  elif "vsr" in name: hist.SetXTitle("Global R position (cm)")
1552  if "DT" in name:
1553  if param == "x": hist.SetYTitle("x' residual (mm)")
1554  if param == "dxdz": hist.SetYTitle("dx'/dz residual (mrad)")
1555  if param == "y": hist.SetYTitle("y' residual (mm)")
1556  if param == "dydz": hist.SetYTitle("dy'/dz residual (mrad)")
1557  if "CSC" in name:
1558  if param == "x": hist.SetYTitle("r#phi residual (mm)")
1559  if param == "dxdz": hist.SetYTitle("d(r#phi)/dz residual (mrad)")
1560  hist.SetMarkerColor(ROOT.kBlack)
1561  hist.SetLineColor(ROOT.kBlack)
1562  hist.Draw()
1563  hist2d.Draw("colzsame")
1564  if widebins: hist.Draw("samee1")
1565  else: hist.Draw("same")
1566 
1567  hpeaks.SetMarkerStyle(20)
1568  hpeaks.SetMarkerSize(0.9)
1569  hpeaks.SetMarkerColor(ROOT.kRed)
1570  hpeaks.SetLineColor(ROOT.kRed)
1571  hpeaks.SetLineWidth(2)
1572  #if fitpeaks: hpeaks.Draw("same")
1573  hpeaks.Draw("same")
1574 
1575  if fitsine and "vsphi" in name:
1576  global fitsine_const, fitsine_sin, fitsine_cos, fitsine_chi2, fitsine_ndf
1577  if 'CSC' in name:
1578  f = ROOT.TF1("f", "[0] + [1]*sin(x) + [2]*cos(x)", -pi/180.*5., pi*(2.-5./180.))
1579  else:
1580  f = ROOT.TF1("f", "[0] + [1]*sin(x) + [2]*cos(x)", -pi, pi)
1581  f.SetLineColor(ROOT.kRed)
1582  f.SetLineWidth(2)
1583  if len(fixfitpars)>0:
1584  for fpar in fixfitpars.keys():
1585  f.FixParameter(fpar, fixfitpars[fpar])
1586  #hist.Fit(f,"N")
1587  if fitpeaks: hpeaks.Fit(f,"NQ")
1588  else: hist.Fit(f,"NEQ")
1589  if len(fixfitpars)>0:
1590  for fpar in fixfitpars.keys():
1591  f.ReleaseParameter(fpar)
1592  fitsine_const = f.GetParameter(0), f.GetParError(0)
1593  fitsine_sin = f.GetParameter(1), f.GetParError(1)
1594  fitsine_cos = f.GetParameter(2), f.GetParError(2)
1595  fitsine_chi2 = f.GetChisquare()
1596  fitsine_ndf = f.GetNDF()
1597  global MAP_RESULTS_FITSIN
1598  # 'phi' coefficienct will be updated further for CSC
1599  MAP_RESULTS_FITSIN[id] = {'a':fitsine_const, 'phi':fitsine_const, 'sin': fitsine_sin, 'cos': fitsine_cos, 'chi2': fitsine_chi2, 'ndf': fitsine_ndf}
1600  f.Draw("same")
1601  global fitsine_ttext, fitsine_etext
1602  text_xposition = -1.
1603  if 'CSC' in name: text_xposition = 2.
1604  fitsine_ttext = ROOT.TLatex(text_xposition, 0.8*window,
1605  "%+.3f %+.3f sin#phi %+.3f cos#phi" % (fitsine_const[0], fitsine_sin[0], fitsine_cos[0]))
1606  fitsine_ttext.SetTextColor(ROOT.kRed)
1607  fitsine_ttext.SetTextSize(0.05)
1608  fitsine_ttext.Draw()
1609  fitsine_etext = ROOT.TLatex(text_xposition, 0.70*window,
1610  " #pm%.3f #pm%.3f #pm%.3f" % (fitsine_const[1], fitsine_sin[1], fitsine_cos[1]))
1611  fitsine_etext.SetTextColor(ROOT.kRed)
1612  fitsine_etext.SetTextSize(0.045)
1613  fitsine_etext.Draw()
1614 
1615  # additional estimate of phiz ring rotation from 1d distribution
1616  if 'CSC' in name and add1d:
1617  # zero-order rough fit to obtain the fitting range:
1618  f0 = ROOT.TF1("f0", "gaus", hist1d.GetBinLowEdge(1), -hist1d.GetBinLowEdge(1))
1619  fit = hist1d.Fit(f0,"NRQ")
1620  rangea, rangeb = hist1d.GetMean() - hist1d.GetRMS(), hist1d.GetMean() + hist1d.GetRMS()
1621  if fit==0: rangea, rangeb = f0.GetParameter(1) - f0.GetParameter(2), f0.GetParameter(1) + f0.GetParameter(2)
1622  #print rangea, rangeb
1623 
1624  # second fit for finding the peak:
1625  f1 = ROOT.TF1("f1", "gaus", rangea, rangeb)
1626  fit = hist1d.Fit(f1,"NRQ")
1627  nn = hist1d.GetEntries()
1628  dphiz, ephiz = 0, 0
1629  if nn>0: dphiz, ephiz = hist1d.GetMean(), ROOT.TMath.StudentQuantile(0.841345,nn) * hist1d.GetRMS() / sqrt(nn)
1630  if fit==0: dphiz, ephiz = f1.GetParameter(1), f1.GetParError(1)
1631  #print dphiz, ephiz
1632  MAP_RESULTS_FITSIN[id]['phi'] = (dphiz, ephiz)
1633 
1634  global ttex_sine_, ttex_sine, ttex_1d_, ttex_1d
1635  postal_address = idToPostalAddress(id+'/01')
1636  ttex_sine_ = ROOT.TLatex(0, 0.8*window,"#Delta#phi_{z}^{sine} (mrad):")
1637  ttex_sine_.SetTextColor(ROOT.kGreen+2); ttex_sine_.SetTextSize(0.04); ttex_sine_.Draw()
1638  ttex_sine = ROOT.TLatex(0, 0.7*window," %+.3f#pm%.3f" %
1639  (-100*fitsine_const[0]/signConventions[postal_address][3],
1640  100*fitsine_const[1]/signConventions[postal_address][3]))
1641  ttex_sine.SetTextColor(ROOT.kGreen+2); ttex_sine.SetTextSize(0.04); ttex_sine.Draw()
1642  ttex_1d_ = ROOT.TLatex(0, 0.6*window,"#Delta#phi_{z}^{phi} (mrad):")
1643  ttex_1d_.SetTextColor(ROOT.kGreen+2); ttex_1d_.SetTextSize(0.04); ttex_1d_.Draw()
1644  ttex_1d = ROOT.TLatex(0, 0.5*window," %+.3f#pm%.3f" % (-dphiz, ephiz))
1645  ttex_1d.SetTextColor(ROOT.kGreen+2); ttex_1d.SetTextSize(0.04); ttex_1d.Draw()
1646  ROOT.gPad.Update()
1647 
1648  if fitline:
1649  f = ROOT.TF1("f", "[0] + [1]*x", -1000., 1000.)
1650  hist2d.Fit(f, "q")
1651  hist2d.GetFunction("f").SetLineColor(ROOT.kRed)
1652  global fitline_const, fitline_linear, fitline_chi2, fitline_ndf
1653  fitline_const = hist2d.GetFunction("f").GetParameter(0), hist2d.GetFunction("f").GetParError(0)
1654  fitline_linear = hist2d.GetFunction("f").GetParameter(1), hist2d.GetFunction("f").GetParError(1)
1655  fitline_chi2 = hist2d.GetFunction("f").GetChisquare()
1656  fitline_ndf = hist2d.GetFunction("f").GetNDF()
1657  hist2d.GetFunction("f").Draw("same")
1658  global fitline_ttext
1659  if "vsz" in name: which = "Z"
1660  elif "vsr" in name: which = "R"
1661  fitline_ttext = ROOT.TText(hist.GetBinCenter(hist.GetNbinsX()/4),
1662  0.8*window, "%.3g %+.3g %s" % (fitline_const[0], fitline_linear[0], which))
1663  fitline_ttext.SetTextColor(ROOT.kRed)
1664  fitline_ttext.Draw()
1665 
1666  ROOT.gPad.RedrawAxis()
1667 
1668  if "vsphi" in name:
1669  if not widebins: philines(name, window, abscissa)
1670  if abscissa is None:
1671  if 'CSC' in name:
1672  tline1 = ROOT.TLine(-pi/180.*5., 0, pi*(2.-5./180.), 0); tline1.Draw()
1673  tline2 = ROOT.TLine(-pi/180.*5., -window, pi*(2.-5./180.), -window); tline2.SetLineWidth(2); tline2.Draw()
1674  tline3 = ROOT.TLine(-pi/180.*5., window, pi*(2.-5./180.), window); tline3.Draw()
1675  else:
1676  tline1 = ROOT.TLine(-pi, 0, pi, 0); tline1.Draw()
1677  tline2 = ROOT.TLine(-pi, -window, pi, -window); tline2.SetLineWidth(2); tline2.Draw()
1678  tline3 = ROOT.TLine(-pi, window, pi, window); tline3.Draw()
1679  else:
1680  tline1 = ROOT.TLine(abscissa[0], 0, abscissa[1], 0); tline1.Draw()
1681  tline2 = ROOT.TLine(abscissa[0], -window, abscissa[1], -window); tline2.SetLineWidth(2); tline2.Draw()
1682  tline3 = ROOT.TLine(abscissa[0], window, abscissa[1], window); tline3.Draw()
1683  elif "vsz" in name:
1684  if not widebins: zlines(window, abscissa)
1685  if abscissa is None:
1686  tline1 = ROOT.TLine(-660, 0, 660, 0); tline1.Draw()
1687  tline2 = ROOT.TLine(-660, -window, 660, -window); tline2.SetLineWidth(2); tline2.Draw()
1688  tline3 = ROOT.TLine(-660, window, 660, window); tline3.Draw()
1689  else:
1690  tline1 = ROOT.TLine(abscissa[0], 0, abscissa[1], 0); tline1.Draw()
1691  tline2 = ROOT.TLine(abscissa[0], -window, abscissa[1], -window); tline2.SetLineWidth(2); tline2.Draw()
1692  tline3 = ROOT.TLine(abscissa[0], window, abscissa[1], window); tline3.Draw()
1693  elif "vsr" in name:
1694  if "mem1" in name or "mep1" in name and not widebins: rlines(1, window, abscissa)
1695  if "mem2" in name or "mep2" in name and not widebins: rlines(2, window, abscissa)
1696  if "mem3" in name or "mep3" in name and not widebins: rlines(3, window, abscissa)
1697  if "mem4" in name or "mep4" in name and not widebins: rlines(4, window, abscissa)
1698  if abscissa is None:
1699  tline1 = ROOT.TLine(100, 0, 700, 0); tline1.Draw()
1700  tline2 = ROOT.TLine(100, -window, 700, -window); tline2.SetLineWidth(2); tline2.Draw()
1701  tline3 = ROOT.TLine(100, window, 700, window); tline3.Draw()
1702  else:
1703  tline1 = ROOT.TLine(abscissa[0], 0, abscissa[1], 0); tline1.Draw()
1704  tline2 = ROOT.TLine(abscissa[0], -window, abscissa[1], -window); tline2.SetLineWidth(2); tline2.Draw()
1705  tline3 = ROOT.TLine(abscissa[0], window, abscissa[1], window); tline3.Draw()
1706 
1707  if "vsphi" in name and fitsawteeth:
1708  global CPP_LOADED
1709  if not CPP_LOADED:
1710  phiedges2c()
1711  ROOT.gROOT.ProcessLine(".L phiedges_fitfunctions.C++")
1712  CPP_LOADED = True
1713  fn={0: ROOT.fitf0,
1714  1: ROOT.fitf2,
1715  2: ROOT.fitf2,
1716  3: ROOT.fitf3,
1717  4: ROOT.fitf4,
1718  5: ROOT.fitf5,
1719  6: ROOT.fitf6,
1720  7: ROOT.fitf7,
1721  8: ROOT.fitf8,
1722  9: ROOT.fitf9,
1723  10: ROOT.fitf10,
1724  11: ROOT.fitf11,
1725  12: ROOT.fitf12,
1726  13: ROOT.fitf13
1727  } [stationIndex(name)]
1728  fn.SetNpx(5000)
1729  fn.SetLineColor(ROOT.kYellow)
1730  hist.Fit(fn,"N")
1731  fn.Draw("same")
1732 
1733  # get properly arranged phi edges
1734  edges = (phiedges[stationIndex(name)])[:]
1735  ed = sorted(edges)
1736  # add some padding to the end
1737  ed.append(pi+abs(ed[0]))
1738 
1739  global sawtooth_a, sawtooth_b
1740  sawtooth_a = []
1741  sawtooth_da = []
1742  sawtooth_b = []
1743  for pr in range(0,fn.GetNpar(),2):
1744  sawtooth_a.append( (fn.GetParameter(pr), fn.GetParError(pr)) )
1745  sawtooth_b.append( (fn.GetParameter(pr+1), fn.GetParError(pr+1)) )
1746  sawtooth_da.append( (fn.Eval(ed[pr/2]+0.01), fn.Eval(ed[pr/2+1]-0.01)) )
1747  global MAP_RESULTS_SAWTOOTH
1748  MAP_RESULTS_SAWTOOTH[id] = {'a': sawtooth_a, 'da': sawtooth_da, 'b': sawtooth_b, 'chi2': fn.GetChisquare(), 'ndf': fn.GetNDF()}
1749 
1750  # fill number of contributiong bins
1751 
1752 
1753  #ROOT.SetOwnership(hist,False)
1754  ROOT.SetOwnership(hist2d,False)
1755  ROOT.SetOwnership(hist,False)
1756  ROOT.SetOwnership(tline1,False)
1757  ROOT.SetOwnership(tline2,False)
1758  ROOT.SetOwnership(tline3,False)
1759  return hist
1760 
def idToPostalAddress
Definition: plotscripts.py:861
T sqrt(T t)
Definition: SSEVec.h:48
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def createPeaksProfile
def stationIndex
Definition: plotscripts.py:353
def plotscripts.mean (   xlist)

Definition at line 53 of file plotscripts.py.

Referenced by segdiffvsphi(), segdiffvsphi_xalign(), and segdiffvsphicsc().

53 
54 def mean(xlist):
55  s, n = 0., 0.
56  for x in xlist:
57  s += x
58  n += 1.
59  return s/n
def plotscripts.nameToId (   name)

Definition at line 896 of file plotscripts.py.

897 def nameToId(name):
898  if name[0:2] == "MB":
899  wh = name[4]
900  if wh == "A": w = "-2"
901  elif wh == "B": w = "-1"
902  elif wh == "C": w = "-0"
903  elif wh == "D": w = "+1"
904  elif wh == "E": w = "+2"
905  else: return ""
906  station = name[7]
907  sector = name[11:13]
908  return "MB%s/%s/%s" % (w, station, sector)
909  elif name[0:2] == "ME":
910  if name[2]=="p": endcap = "+"
911  elif name[2]=="m": endcap = "-"
912  else: return ""
913  station = name[3]
914  ring = name[4]
915  chamber = name[6:8]
916  return "ME%s%s/%s/%s" % (endcap, station, ring, chamber)
917  return None
918 
def plotscripts.phiedges2c ( )

Definition at line 316 of file plotscripts.py.

References join(), and python.multivaluedict.map().

Referenced by mapplot().

317 def phiedges2c():
318  lines = []
319  for ed in phiedges[:]:
320  ed.sort()
321  #print ed
322  ed.extend([999 for n in range(0,37-len(ed))])
323  lines.append('{' + ', '.join(map(str, ed)) + '}')
324  #print lines
325  res = ', '.join(lines)
326  ff = open("phiedges_export.h",mode="w")
327  print>>ff,'double phiedges[14][37] = {' + res + '};'
328  ff.close()
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def plotscripts.philines (   name,
  window,
  abscissa 
)

Definition at line 392 of file plotscripts.py.

References stationIndex(), and archive.zip.

Referenced by mapplot().

393 def philines(name, window, abscissa):
394  global philine_tlines, philine_labels
395  philine_tlines = []
396  edges = phiedges[stationIndex(name)]
397  #print name, len(edges)
398  for phi in edges:
399  if abscissa is None or abscissa[0] < phi < abscissa[1]:
400  philine_tlines.append(ROOT.TLine(phi, -window, phi, window))
401  philine_tlines[-1].SetLineStyle(2)
402  philine_tlines[-1].Draw()
403  if "st" in name: # DT labels
404  philine_labels = []
405  edges = edges[:]
406  edges.sort()
407  if "st4" in name:
408  labels = [" 7", " 8", " 9", "14", "10", "11", "12", " 1", " 2", " 3", "13", " 4", " 5", " 6"]
409  else:
410  labels = [" 8", " 9", "10", "11", "12", " 1", " 2", " 3", " 4", " 5", " 6"]
411  edges = edges[1:]
412  for phi, label in zip(edges, labels):
413  littlebit = 0.
414  if label in (" 7", " 9", "14", "10", "11"): littlebit = 0.05
415  philine_labels.append(ROOT.TText(phi-0.35+littlebit, -0.9*window, label))
416  philine_labels[-1].Draw()
417  philine_labels.append(ROOT.TText(-2.9, -0.75*window, "Sector:"))
418  philine_labels[-1].Draw()
419  if "CSC" in name: # DT labels
420  philine_labels = []
421  edges = edges[:]
422  edges.sort()
423  labels = [" 1", " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "10", "11", "12", "13", "14", "15", "16", "17", "18",
424  "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36"]
425  #else:
426  # labels = [" 8", " 9", "10", "11", "12", " 1", " 2", " 3", " 4", " 5", " 6"]
427  # edges = edges[1:]
428  for phi, label in zip(edges, labels):
429  littlebit = 0.
430  #if label in (" 7", " 9", "14", "10", "11"): littlebit = 0.05
431  philine_labels.append(ROOT.TText(phi+littlebit, -0.9*window, label))
432  philine_labels[-1].SetTextFont(42)
433  philine_labels[-1].SetTextSize(0.028)
434  philine_labels[-1].Draw()
435  philine_labels.append(ROOT.TText(0, -0.78*window, "Chamber:"))
436  philine_labels[-1].SetTextSize(0.035)
437  philine_labels[-1].Draw()
tuple zip
Definition: archive.py:476
def stationIndex
Definition: plotscripts.py:353
def plotscripts.plotmedians (   reports1,
  reports2,
  selection = None,
  binsx = 100,
  windowx = 5.,
  ceilingx = None,
  binsy = 100,
  windowy = 5.,
  ceilingy = None,
  binsdxdz = 100,
  windowdxdz = 5.,
  ceilingdxdz = None,
  binsdydz = 100,
  windowdydz = 5.,
  ceilingdydz = None,
  r1text = " before",
  r2text = " after",
  which = "median" 
)

Definition at line 1246 of file plotscripts.py.

References corrVsCorr.selection.

Referenced by doTests().

1247  r1text=" before", r2text=" after", which="median"):
1248  tdrStyle.SetOptStat("emrou")
1249  tdrStyle.SetStatW(0.40)
1250  tdrStyle.SetStatFontSize(0.05)
1251 
1252  global hmediandxdz_after, hmediandxdz_before, hmediandxdz_beforecopy, \
1253  hmediandydz_after, hmediandydz_before, hmediandydz_beforecopy, \
1254  hmedianx_after, hmedianx_before, hmedianx_beforecopy, \
1255  hmediany_after, hmediany_before, hmediany_beforecopy, tlegend
1256 
1257  hmedianx_before = ROOT.TH1F("hmedianx_before", "", binsx, -windowx, windowx)
1258  hmediany_before = ROOT.TH1F("hmediany_before", "", binsy, -windowy, windowy)
1259  hmediandxdz_before = ROOT.TH1F("hmediandxdz_before", "", binsdxdz, -windowdxdz, windowdxdz)
1260  hmediandydz_before = ROOT.TH1F("hmediandydz_before", "", binsdydz, -windowdydz, windowdydz)
1261  hmedianx_after = ROOT.TH1F("hmedianx_after", "", binsx, -windowx, windowx)
1262  hmediany_after = ROOT.TH1F("hmediany_after", "", binsy, -windowy, windowy)
1263  hmediandxdz_after = ROOT.TH1F("hmediandxdz_after", "", binsdxdz, -windowdxdz, windowdxdz)
1264  hmediandydz_after = ROOT.TH1F("hmediandydz_after", "", binsdydz, -windowdydz, windowdydz)
1265 
1266  if which == "median":
1267  whichx = whichy = whichdxdz = whichdydz = "median"
1268  elif which == "bigmean":
1269  whichx = "mean30"
1270  whichy = "mean30"
1271  whichdxdz = "mean20"
1272  whichdydz = "mean50"
1273  elif which == "mean":
1274  whichx = "mean15"
1275  whichy = "mean15"
1276  whichdxdz = "mean10"
1277  whichdydz = "mean25"
1278  elif which == "bigwmean":
1279  whichx = "wmean30"
1280  whichy = "wmean30"
1281  whichdxdz = "wmean20"
1282  whichdydz = "wmean50"
1283  elif which == "wmean":
1284  whichx = "wmean15"
1285  whichy = "wmean15"
1286  whichdxdz = "wmean10"
1287  whichdydz = "wmean25"
1288  elif which == "bigstdev":
1289  whichx = "stdev30"
1290  whichy = "stdev30"
1291  whichdxdz = "stdev20"
1292  whichdydz = "stdev50"
1293  elif which == "stdev":
1294  whichx = "stdev15"
1295  whichy = "stdev15"
1296  whichdxdz = "stdev10"
1297  whichdydz = "stdev25"
1298  else:
1299  raise Exception, which + " not recognized"
1300 
1301  for r1 in reports1:
1302  if selection is None or (selection.func_code.co_argcount == len(r1.postal_address) and selection(*r1.postal_address)):
1303  found = False
1304  for r2 in reports2:
1305  if r1.postal_address == r2.postal_address:
1306  found = True
1307  break
1308  if not found: continue
1309 
1310  #skip ME1/1a
1311  if r1.postal_address[0]=='CSC':
1312  if r1.postal_address[2]==1 and r1.postal_address[3]==4: continue
1313 
1314  if r1.status == "PASS" and r2.status == "PASS":
1315  hmedianx_before.Fill(10.*eval("r1.%s_x" % whichx))
1316  hmediandxdz_before.Fill(1000.*eval("r1.%s_dxdz" % whichdxdz))
1317  hmedianx_after.Fill(10.*eval("r2.%s_x" % whichx))
1318  hmediandxdz_after.Fill(1000.*eval("r2.%s_dxdz" % whichdxdz))
1319 
1320  if r1.median_y is not None:
1321  hmediany_before.Fill(10.*eval("r1.%s_y" % whichy))
1322  hmediandydz_before.Fill(1000.*eval("r1.%s_dydz" % whichdydz))
1323  hmediany_after.Fill(10.*eval("r2.%s_y" % whichy))
1324  hmediandydz_after.Fill(1000.*eval("r2.%s_dydz" % whichdydz))
1325 
1326  hmedianx_beforecopy = hmedianx_before.Clone()
1327  hmediany_beforecopy = hmediany_before.Clone()
1328  hmediandxdz_beforecopy = hmediandxdz_before.Clone()
1329  hmediandydz_beforecopy = hmediandydz_before.Clone()
1330  hmedianx_beforecopy.SetLineStyle(2)
1331  hmediany_beforecopy.SetLineStyle(2)
1332  hmediandxdz_beforecopy.SetLineStyle(2)
1333  hmediandydz_beforecopy.SetLineStyle(2)
1334 
1335  hmedianx_before.SetFillColor(ROOT.kMagenta+2)
1336  hmediany_before.SetFillColor(ROOT.kMagenta+2)
1337  hmediandxdz_before.SetFillColor(ROOT.kMagenta+2)
1338  hmediandydz_before.SetFillColor(ROOT.kMagenta+2)
1339  hmedianx_after.SetFillColor(ROOT.kYellow)
1340  hmediany_after.SetFillColor(ROOT.kYellow)
1341  hmediandxdz_after.SetFillColor(ROOT.kYellow)
1342  hmediandydz_after.SetFillColor(ROOT.kYellow)
1343 
1344  hmedianx_after.SetXTitle("median(#Deltax) (mm)")
1345  hmediany_after.SetXTitle("median(#Deltay) (mm)")
1346  hmediandxdz_after.SetXTitle("median(#Deltadx/dz) (mrad)")
1347  hmediandydz_after.SetXTitle("median(#Deltadydz) (mrad)")
1348  hmedianx_after.GetXaxis().CenterTitle()
1349  hmediany_after.GetXaxis().CenterTitle()
1350  hmediandxdz_after.GetXaxis().CenterTitle()
1351  hmediandydz_after.GetXaxis().CenterTitle()
1352 
1353  if ceilingx is not None: hmedianx_after.SetAxisRange(0., ceilingx, "Y")
1354  if ceilingy is not None: hmediany_after.SetAxisRange(0., ceilingy, "Y")
1355  if ceilingdxdz is not None: hmediandxdz_after.SetAxisRange(0., ceilingdxdz, "Y")
1356  if ceilingdydz is not None: hmediandydz_after.SetAxisRange(0., ceilingdydz, "Y")
1357 
1358  c1.Clear()
1359  c1.Divide(2, 2)
1360 
1361  c1.GetPad(1).cd()
1362  hmedianx_after.Draw()
1363  hmedianx_before.Draw("same")
1364  hmedianx_after.Draw("same")
1365  hmedianx_beforecopy.Draw("same")
1366  hmedianx_after.Draw("axissame")
1367 
1368  tlegend = ROOT.TLegend(0.17, 0.75-0.05, 0.45+0.05, 0.9)
1369  tlegend.SetFillColor(ROOT.kWhite)
1370  tlegend.SetBorderSize(0)
1371  tlegend.AddEntry(hmedianx_after, r2text, "f")
1372  tlegend.AddEntry(hmedianx_before, r1text, "f")
1373  tlegend.Draw()
1374 
1375  c1.GetPad(2).cd()
1376  hmediandxdz_after.Draw()
1377  hmediandxdz_before.Draw("same")
1378  hmediandxdz_after.Draw("same")
1379  hmediandxdz_beforecopy.Draw("same")
1380  hmediandxdz_after.Draw("axissame")
1381 
1382  c1.GetPad(3).cd()
1383  hmediany_after.Draw()
1384  hmediany_before.Draw("same")
1385  hmediany_after.Draw("same")
1386  hmediany_beforecopy.Draw("same")
1387  hmediany_after.Draw("axissame")
1388 
1389  c1.GetPad(4).cd()
1390  hmediandydz_after.Draw()
1391  hmediandydz_before.Draw("same")
1392  hmediandydz_after.Draw("same")
1393  hmediandydz_beforecopy.Draw("same")
1394  hmediandydz_after.Draw("axissame")
1395 
1396  return hmediandxdz_after, hmediandxdz_before, hmediandxdz_beforecopy, \
1397  hmediandydz_after, hmediandydz_before, hmediandydz_beforecopy, \
1398  hmedianx_after, hmedianx_before, hmedianx_beforecopy, \
1399  hmediany_after, hmediany_before, hmediany_beforecopy, tlegend
1400 
selection
main part
Definition: corrVsCorr.py:98
def plotscripts.polynomials (   tfile,
  reports,
  name,
  twobin = True,
  suppressblue = False 
)

Definition at line 2272 of file plotscripts.py.

References getname().

Referenced by alignmentValidation.doFitFunctionsPlotsCSC(), and alignmentValidation.doFitFunctionsPlotsDT().

2273 def polynomials(tfile, reports, name, twobin=True, suppressblue=False):
2274  t1 = time.time()
2275  ddt[7] += 1
2276  global label1, label2, label3, label4, label5, label6, label7, label8, label9
2277  plotDirectory = "MuonAlignmentFromReference"
2278  tdrStyle.SetOptTitle(1)
2279  tdrStyle.SetTitleBorderSize(1)
2280  tdrStyle.SetTitleFontSize(0.1)
2281  tdrStyle.SetOptStat(0)
2282 
2283  c1.Clear()
2284  c1.ResetAttPad()
2285 
2286  found = False
2287  for r in reports:
2288  if r.name == name:
2289  found = True
2290  break
2291  if not found: raise Exception, "Not a valid name"
2292 
2293  if r.status == "FAIL":
2294  #raise Exception, "Fit failed"
2295  print "Fit failed"
2296  c1.Clear()
2297  return
2298 
2299  Pos = "Pos"; Neg = "Neg"
2300  if not twobin:
2301  Pos = ""; Neg = ""
2302 
2303  pdirPos = "MuonAlignmentFromReference/%s%s" % (name, Pos)
2304  pdirNeg = "MuonAlignmentFromReference/%s%s" % (name, Neg)
2305 
2306  global chamber_x_trackx, chamber_x_trackx_fit, chamber_y_trackx, chamber_y_trackx_fit, \
2307  chamber_dxdz_trackx, chamber_dxdz_trackx_fit, chamber_dydz_trackx, chamber_dydz_trackx_fit, \
2308  chamber_x_trackx_fit2, chamber_y_trackx_fit2, chamber_dxdz_trackx_fit2, chamber_dydz_trackx_fit2
2309  global chamber_x_tracky, chamber_x_tracky_fit, chamber_y_tracky, chamber_y_tracky_fit, \
2310  chamber_dxdz_tracky, chamber_dxdz_tracky_fit, chamber_dydz_tracky, chamber_dydz_tracky_fit, \
2311  chamber_x_tracky_fit2, chamber_y_tracky_fit2, chamber_dxdz_tracky_fit2, chamber_dydz_tracky_fit2
2312  global chamber_x_trackdxdz, chamber_x_trackdxdz_fit, chamber_y_trackdxdz, chamber_y_trackdxdz_fit, \
2313  chamber_dxdz_trackdxdz, chamber_dxdz_trackdxdz_fit, chamber_dydz_trackdxdz, chamber_dydz_trackdxdz_fit, \
2314  chamber_x_trackdxdz_fit2, chamber_y_trackdxdz_fit2, chamber_dxdz_trackdxdz_fit2, chamber_dydz_trackdxdz_fit2
2315  global chamber_x_trackdydz, chamber_x_trackdydz_fit, chamber_y_trackdydz, chamber_y_trackdydz_fit, \
2316  chamber_dxdz_trackdydz, chamber_dxdz_trackdydz_fit, chamber_dydz_trackdydz, chamber_dydz_trackdydz_fit, \
2317  chamber_x_trackdydz_fit2, chamber_y_trackdydz_fit2, chamber_dxdz_trackdydz_fit2, chamber_dydz_trackdydz_fit2
2318 
2319  chamber_x_trackx = tfile.Get(pdirPos+"_x_trackx")
2320  chamber_x_trackx_fit = tfile.Get(pdirPos+"_x_trackx_fitline")
2321  chamber_y_trackx = tfile.Get(pdirPos+"_y_trackx")
2322  chamber_y_trackx_fit = tfile.Get(pdirPos+"_y_trackx_fitline")
2323  chamber_dxdz_trackx = tfile.Get(pdirPos+"_dxdz_trackx")
2324  chamber_dxdz_trackx_fit = tfile.Get(pdirPos+"_dxdz_trackx_fitline")
2325  chamber_dydz_trackx = tfile.Get(pdirPos+"_dydz_trackx")
2326  chamber_dydz_trackx_fit = tfile.Get(pdirPos+"_dydz_trackx_fitline")
2327  chamber_x_trackx_fit2 = tfile.Get(pdirNeg+"_x_trackx_fitline")
2328  chamber_y_trackx_fit2 = tfile.Get(pdirNeg+"_y_trackx_fitline")
2329  chamber_dxdz_trackx_fit2 = tfile.Get(pdirNeg+"_dxdz_trackx_fitline")
2330  chamber_dydz_trackx_fit2 = tfile.Get(pdirNeg+"_dydz_trackx_fitline")
2331 
2332  chamber_x_tracky = tfile.Get(pdirPos+"_x_tracky")
2333  chamber_x_tracky_fit = tfile.Get(pdirPos+"_x_tracky_fitline")
2334  chamber_y_tracky = tfile.Get(pdirPos+"_y_tracky")
2335  chamber_y_tracky_fit = tfile.Get(pdirPos+"_y_tracky_fitline")
2336  chamber_dxdz_tracky = tfile.Get(pdirPos+"_dxdz_tracky")
2337  chamber_dxdz_tracky_fit = tfile.Get(pdirPos+"_dxdz_tracky_fitline")
2338  chamber_dydz_tracky = tfile.Get(pdirPos+"_dydz_tracky")
2339  chamber_dydz_tracky_fit = tfile.Get(pdirPos+"_dydz_tracky_fitline")
2340  chamber_x_tracky_fit2 = tfile.Get(pdirNeg+"_x_tracky_fitline")
2341  chamber_y_tracky_fit2 = tfile.Get(pdirNeg+"_y_tracky_fitline")
2342  chamber_dxdz_tracky_fit2 = tfile.Get(pdirNeg+"_dxdz_tracky_fitline")
2343  chamber_dydz_tracky_fit2 = tfile.Get(pdirNeg+"_dydz_tracky_fitline")
2344 
2345  chamber_x_trackdxdz = tfile.Get(pdirPos+"_x_trackdxdz")
2346  chamber_x_trackdxdz_fit = tfile.Get(pdirPos+"_x_trackdxdz_fitline")
2347  chamber_y_trackdxdz = tfile.Get(pdirPos+"_y_trackdxdz")
2348  chamber_y_trackdxdz_fit = tfile.Get(pdirPos+"_y_trackdxdz_fitline")
2349  chamber_dxdz_trackdxdz = tfile.Get(pdirPos+"_dxdz_trackdxdz")
2350  chamber_dxdz_trackdxdz_fit = tfile.Get(pdirPos+"_dxdz_trackdxdz_fitline")
2351  chamber_dydz_trackdxdz = tfile.Get(pdirPos+"_dydz_trackdxdz")
2352  chamber_dydz_trackdxdz_fit = tfile.Get(pdirPos+"_dydz_trackdxdz_fitline")
2353  chamber_x_trackdxdz_fit2 = tfile.Get(pdirNeg+"_x_trackdxdz_fitline")
2354  chamber_y_trackdxdz_fit2 = tfile.Get(pdirNeg+"_y_trackdxdz_fitline")
2355  chamber_dxdz_trackdxdz_fit2 = tfile.Get(pdirNeg+"_dxdz_trackdxdz_fitline")
2356  chamber_dydz_trackdxdz_fit2 = tfile.Get(pdirNeg+"_dydz_trackdxdz_fitline")
2357 
2358  chamber_x_trackdydz = tfile.Get(pdirPos+"_x_trackdydz")
2359  chamber_x_trackdydz_fit = tfile.Get(pdirPos+"_x_trackdydz_fitline")
2360  chamber_y_trackdydz = tfile.Get(pdirPos+"_y_trackdydz")
2361  chamber_y_trackdydz_fit = tfile.Get(pdirPos+"_y_trackdydz_fitline")
2362  chamber_dxdz_trackdydz = tfile.Get(pdirPos+"_dxdz_trackdydz")
2363  chamber_dxdz_trackdydz_fit = tfile.Get(pdirPos+"_dxdz_trackdydz_fitline")
2364  chamber_dydz_trackdydz = tfile.Get(pdirPos+"_dydz_trackdydz")
2365  chamber_dydz_trackdydz_fit = tfile.Get(pdirPos+"_dydz_trackdydz_fitline")
2366  chamber_x_trackdydz_fit2 = tfile.Get(pdirNeg+"_x_trackdydz_fitline")
2367  chamber_y_trackdydz_fit2 = tfile.Get(pdirNeg+"_y_trackdydz_fitline")
2368  chamber_dxdz_trackdydz_fit2 = tfile.Get(pdirNeg+"_dxdz_trackdydz_fitline")
2369  chamber_dydz_trackdydz_fit2 = tfile.Get(pdirNeg+"_dydz_trackdydz_fitline")
2370 
2371  if not chamber_x_trackx:
2372  chamber_x_trackx = tfile.Get(pdirPos+"_residual_trackx")
2373  chamber_x_trackx_fit = tfile.Get(pdirPos+"_residual_trackx_fitline")
2374  chamber_dxdz_trackx = tfile.Get(pdirPos+"_resslope_trackx")
2375  chamber_dxdz_trackx_fit = tfile.Get(pdirPos+"_resslope_trackx_fitline")
2376  chamber_x_trackx_fit2 = tfile.Get(pdirNeg+"_residual_trackx_fitline")
2377  chamber_dxdz_trackx_fit2 = tfile.Get(pdirNeg+"_resslope_trackx_fitline")
2378 
2379  chamber_x_tracky = tfile.Get(pdirPos+"_residual_tracky")
2380  chamber_x_tracky_fit = tfile.Get(pdirPos+"_residual_tracky_fitline")
2381  chamber_dxdz_tracky = tfile.Get(pdirPos+"_resslope_tracky")
2382  chamber_dxdz_tracky_fit = tfile.Get(pdirPos+"_resslope_tracky_fitline")
2383  chamber_x_tracky_fit2 = tfile.Get(pdirNeg+"_residual_tracky_fitline")
2384  chamber_dxdz_tracky_fit2 = tfile.Get(pdirNeg+"_resslope_tracky_fitline")
2385 
2386  chamber_x_trackdxdz = tfile.Get(pdirPos+"_residual_trackdxdz")
2387  chamber_x_trackdxdz_fit = tfile.Get(pdirPos+"_residual_trackdxdz_fitline")
2388  chamber_dxdz_trackdxdz = tfile.Get(pdirPos+"_resslope_trackdxdz")
2389  chamber_dxdz_trackdxdz_fit = tfile.Get(pdirPos+"_resslope_trackdxdz_fitline")
2390  chamber_x_trackdxdz_fit2 = tfile.Get(pdirNeg+"_residual_trackdxdz_fitline")
2391  chamber_dxdz_trackdxdz_fit2 = tfile.Get(pdirNeg+"_resslope_trackdxdz_fitline")
2392 
2393  chamber_x_trackdydz = tfile.Get(pdirPos+"_residual_trackdydz")
2394  chamber_x_trackdydz_fit = tfile.Get(pdirPos+"_residual_trackdydz_fitline")
2395  chamber_dxdz_trackdydz = tfile.Get(pdirPos+"_resslope_trackdydz")
2396  chamber_dxdz_trackdydz_fit = tfile.Get(pdirPos+"_resslope_trackdydz_fitline")
2397  chamber_x_trackdydz_fit2 = tfile.Get(pdirNeg+"_residual_trackdydz_fitline")
2398  chamber_dxdz_trackdydz_fit2 = tfile.Get(pdirNeg+"_resslope_trackdydz_fitline")
2399 
2400  if not chamber_x_trackx:
2401  print "Can't find neither "+pdirPos+"_residual nor "+pdirPos+"_residual_trackx"
2402  return
2403 
2404  chamber_x_trackx = chamber_x_trackx.Clone()
2405  chamber_dxdz_trackx = chamber_dxdz_trackx.Clone()
2406  chamber_x_tracky = chamber_x_tracky.Clone()
2407  chamber_dxdz_tracky = chamber_dxdz_tracky.Clone()
2408  chamber_x_trackdxdz = chamber_x_trackdxdz.Clone()
2409  chamber_dxdz_trackdxdz = chamber_dxdz_trackdxdz.Clone()
2410  chamber_x_trackdydz = chamber_x_trackdydz.Clone()
2411  chamber_dxdz_trackdydz = chamber_dxdz_trackdydz.Clone()
2412 
2413  if not not chamber_y_trackx:
2414  chamber_y_trackx = chamber_y_trackx.Clone()
2415  chamber_dydz_trackx = chamber_dydz_trackx.Clone()
2416  chamber_y_tracky = chamber_y_tracky.Clone()
2417  chamber_dydz_tracky = chamber_dydz_tracky.Clone()
2418  chamber_y_trackdxdz = chamber_y_trackdxdz.Clone()
2419  chamber_dydz_trackdxdz = chamber_dydz_trackdxdz.Clone()
2420  chamber_y_trackdydz = chamber_y_trackdydz.Clone()
2421  chamber_dydz_trackdydz = chamber_dydz_trackdydz.Clone()
2422 
2423  if not not chamber_y_trackx:
2424  tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_x_trackx")); chamber_x_trackx.Merge(tlist)
2425  tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_dxdz_trackx")); chamber_dxdz_trackx.Merge(tlist)
2426  tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_x_tracky")); chamber_x_tracky.Merge(tlist)
2427  tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_dxdz_tracky")); chamber_dxdz_tracky.Merge(tlist)
2428  tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_x_trackdxdz")); chamber_x_trackdxdz.Merge(tlist)
2429  tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_dxdz_trackdxdz")); chamber_dxdz_trackdxdz.Merge(tlist)
2430  tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_x_trackdydz")); chamber_x_trackdydz.Merge(tlist)
2431  tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_dxdz_trackdydz")); chamber_dxdz_trackdydz.Merge(tlist)
2432  tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_y_trackx")); chamber_y_trackx.Merge(tlist)
2433  tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_dydz_trackx")); chamber_dydz_trackx.Merge(tlist)
2434  tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_y_tracky")); chamber_y_tracky.Merge(tlist)
2435  tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_dydz_tracky")); chamber_dydz_tracky.Merge(tlist)
2436  tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_y_trackdxdz")); chamber_y_trackdxdz.Merge(tlist)
2437  tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_dydz_trackdxdz")); chamber_dydz_trackdxdz.Merge(tlist)
2438  tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_y_trackdydz")); chamber_y_trackdydz.Merge(tlist)
2439  tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_dydz_trackdydz")); chamber_dydz_trackdydz.Merge(tlist)
2440  else:
2441  tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_residual_trackx")); chamber_x_trackx.Merge(tlist)
2442  tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_resslope_trackx")); chamber_dxdz_trackx.Merge(tlist)
2443  tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_residual_tracky")); chamber_x_tracky.Merge(tlist)
2444  tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_resslope_tracky")); chamber_dxdz_tracky.Merge(tlist)
2445  tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_residual_trackdxdz")); chamber_x_trackdxdz.Merge(tlist)
2446  tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_resslope_trackdxdz")); chamber_dxdz_trackdxdz.Merge(tlist)
2447  tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_residual_trackdydz")); chamber_x_trackdydz.Merge(tlist)
2448  tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_resslope_trackdydz")); chamber_dxdz_trackdydz.Merge(tlist)
2449 
2450  rr1=10.
2451  rr2=10.
2452  chamber_x_trackx.SetAxisRange(-rr1, rr1, "Y")
2453  chamber_dxdz_trackx.SetAxisRange(-rr2, rr2, "Y")
2454  chamber_x_tracky.SetAxisRange(-rr1, rr1, "Y")
2455  chamber_dxdz_tracky.SetAxisRange(-rr2, rr2, "Y")
2456  chamber_x_trackdxdz.SetAxisRange(-rr1, rr1, "Y")
2457  chamber_dxdz_trackdxdz.SetAxisRange(-rr2, rr2, "Y")
2458  chamber_x_trackdydz.SetAxisRange(-rr1, rr1, "Y")
2459  chamber_dxdz_trackdydz.SetAxisRange(-rr2, rr2, "Y")
2460 
2461  rr3=10.
2462  if not not chamber_y_trackx:
2463  chamber_y_trackx.SetAxisRange(-rr3, rr3, "Y")
2464  chamber_dydz_trackx.SetAxisRange(-rr3, rr3, "Y")
2465  chamber_y_tracky.SetAxisRange(-rr3, rr3, "Y")
2466  chamber_dydz_tracky.SetAxisRange(-rr3, rr3, "Y")
2467  chamber_y_trackdxdz.SetAxisRange(-rr3, rr3, "Y")
2468  chamber_dydz_trackdxdz.SetAxisRange(-rr3, rr3, "Y")
2469  chamber_y_trackdydz.SetAxisRange(-rr3, rr3, "Y")
2470  chamber_dydz_trackdydz.SetAxisRange(-rr3, rr3, "Y")
2471 
2472  for h in chamber_x_trackx, chamber_y_trackx, chamber_dxdz_trackx, chamber_dydz_trackx, \
2473  chamber_x_tracky, chamber_y_tracky, chamber_dxdz_tracky, chamber_dydz_tracky, \
2474  chamber_x_trackdxdz, chamber_y_trackdxdz, chamber_dxdz_trackdxdz, chamber_dydz_trackdxdz, \
2475  chamber_x_trackdydz, chamber_y_trackdydz, chamber_dxdz_trackdydz, chamber_dydz_trackdydz:
2476  if not not h:
2477  h.SetMarkerStyle(20)
2478  h.SetMarkerSize(0.5)
2479  h.GetXaxis().SetLabelSize(0.12)
2480  h.GetYaxis().SetLabelSize(0.12)
2481  h.GetXaxis().SetNdivisions(505)
2482  h.GetYaxis().SetNdivisions(505)
2483  h.GetXaxis().SetLabelOffset(0.03)
2484  h.GetYaxis().SetLabelOffset(0.03)
2485 
2486  trackdxdz_minimum, trackdxdz_maximum = None, None
2487  for h in chamber_x_trackdxdz, chamber_y_trackdxdz, chamber_dxdz_trackdxdz, chamber_dydz_trackdxdz:
2488  if not not h:
2489  for i in xrange(1, h.GetNbinsX()+1):
2490  if h.GetBinError(i) > 0.01 and h.GetBinContent(i) - h.GetBinError(i) < 10. and \
2491  h.GetBinContent(i) + h.GetBinError(i) > -10.:
2492  if not trackdxdz_minimum or trackdxdz_minimum > h.GetBinCenter(i):
2493  trackdxdz_minimum = h.GetBinCenter(i)
2494  if trackdxdz_maximum < h.GetBinCenter(i):
2495  trackdxdz_maximum = h.GetBinCenter(i)
2496  if not not trackdxdz_minimum and not not trackdxdz_maximum:
2497  for h in chamber_x_trackdxdz, chamber_y_trackdxdz, chamber_dxdz_trackdxdz, chamber_dydz_trackdxdz:
2498  if not not h:
2499  h.SetAxisRange(trackdxdz_minimum, trackdxdz_maximum, "X")
2500 
2501  trackdydz_minimum, trackdydz_maximum = None, None
2502  for h in chamber_x_trackdydz, chamber_y_trackdydz, chamber_dxdz_trackdydz, chamber_dydz_trackdydz:
2503  if not not h:
2504  for i in xrange(1, h.GetNbinsX()+1):
2505  if h.GetBinError(i) > 0.01 and h.GetBinContent(i) - h.GetBinError(i) < 10. and \
2506  h.GetBinContent(i) + h.GetBinError(i) > -10.:
2507  if not trackdydz_minimum or trackdydz_minimum > h.GetBinCenter(i):
2508  trackdydz_minimum = h.GetBinCenter(i)
2509  if trackdydz_maximum < h.GetBinCenter(i):
2510  trackdydz_maximum = h.GetBinCenter(i)
2511  if not not trackdydz_minimum and not not trackdydz_maximum:
2512  for h in chamber_x_trackdydz, chamber_y_trackdydz, chamber_dxdz_trackdydz, chamber_dydz_trackdydz:
2513  if not not h:
2514  h.SetAxisRange(trackdydz_minimum, trackdydz_maximum, "X")
2515 
2516  for f in chamber_x_trackx_fit2, chamber_y_trackx_fit2, chamber_dxdz_trackx_fit2, chamber_dydz_trackx_fit2, \
2517  chamber_x_tracky_fit2, chamber_y_tracky_fit2, chamber_dxdz_tracky_fit2, chamber_dydz_tracky_fit2, \
2518  chamber_x_trackdxdz_fit2, chamber_y_trackdxdz_fit2, chamber_dxdz_trackdxdz_fit2, chamber_dydz_trackdxdz_fit2, \
2519  chamber_x_trackdydz_fit2, chamber_y_trackdydz_fit2, chamber_dxdz_trackdydz_fit2, chamber_dydz_trackdydz_fit2:
2520  if not not f:
2521  f.SetLineColor(4)
2522 
2523  if not not chamber_y_trackx:
2524  c1.Clear()
2525  #c1.Divide(5, 5, 1e-5, 1e-5)
2526  pads = [None]
2527  pads.append(ROOT.TPad("p1" ,"",0.00,0.78,0.07,1.00,0,0,0))
2528  pads.append(ROOT.TPad("p2" ,"",0.07,0.78,0.34,1.00,0,0,0))
2529  pads.append(ROOT.TPad("p3" ,"",0.34,0.78,0.56,1.00,0,0,0))
2530  pads.append(ROOT.TPad("p4" ,"",0.56,0.78,0.78,1.00,0,0,0))
2531  pads.append(ROOT.TPad("p5" ,"",0.78,0.78,1.00,1.00,0,0,0))
2532  pads.append(ROOT.TPad("p6" ,"",0.00,0.56,0.07,0.78,0,0,0))
2533  pads.append(ROOT.TPad("p7" ,"",0.07,0.56,0.34,0.78,0,0,0))
2534  pads.append(ROOT.TPad("p8" ,"",0.34,0.56,0.56,0.78,0,0,0))
2535  pads.append(ROOT.TPad("p9" ,"",0.56,0.56,0.78,0.78,0,0,0))
2536  pads.append(ROOT.TPad("p10","",0.78,0.56,1.00,0.78,0,0,0))
2537  pads.append(ROOT.TPad("p11","",0.00,0.34,0.07,0.56,0,0,0))
2538  pads.append(ROOT.TPad("p12","",0.07,0.34,0.34,0.56,0,0,0))
2539  pads.append(ROOT.TPad("p13","",0.34,0.34,0.56,0.56,0,0,0))
2540  pads.append(ROOT.TPad("p14","",0.56,0.34,0.78,0.56,0,0,0))
2541  pads.append(ROOT.TPad("p15","",0.78,0.34,1.00,0.56,0,0,0))
2542  pads.append(ROOT.TPad("p16","",0.00,0.07,0.07,0.34,0,0,0))
2543  pads.append(ROOT.TPad("p17","",0.07,0.07,0.34,0.34,0,0,0))
2544  pads.append(ROOT.TPad("p18","",0.34,0.07,0.56,0.34,0,0,0))
2545  pads.append(ROOT.TPad("p19","",0.56,0.07,0.78,0.34,0,0,0))
2546  pads.append(ROOT.TPad("p20","",0.78,0.07,1.00,0.34,0,0,0))
2547  pads.append(ROOT.TPad("p21","",0.00,0.00,0.07,0.07,0,0,0))
2548  pads.append(ROOT.TPad("p22","",0.07,0.00,0.34,0.07,0,0,0))
2549  pads.append(ROOT.TPad("p23","",0.34,0.00,0.56,0.07,0,0,0))
2550  pads.append(ROOT.TPad("p24","",0.56,0.00,0.78,0.07,0,0,0))
2551  pads.append(ROOT.TPad("p25","",0.78,0.00,1.00,0.07,0,0,0))
2552  for p in pads:
2553  if not not p:
2554  p.Draw()
2555  ROOT.SetOwnership(p,False)
2556 
2557  label1 = ROOT.TPaveLabel(0, 0, 1, 1, "x residuals (mm)","")
2558  label2 = ROOT.TPaveLabel(0, 0, 1, 1, "y residuals (mm)","")
2559  label3 = ROOT.TPaveLabel(0, 0, 1, 1, "dx/dz residuals (mrad)","")
2560  label4 = ROOT.TPaveLabel(0, 0, 1, 1, "dy/dz residuals (mrad)","")
2561  label5 = ROOT.TPaveLabel(0, 0, 1, 1, "x position (cm)","")
2562  label6 = ROOT.TPaveLabel(0, 0, 1, 1, "y position (cm)","")
2563  label7 = ROOT.TPaveLabel(0, 0, 1, 1, "dx/dz angle (rad)","")
2564  label8 = ROOT.TPaveLabel(0, 0, 1, 1, "dy/dz angle (rad)","")
2565  label9 = ROOT.TPaveLabel(0, 0.85, 1, 1, getname(r),"NDC")
2566 
2567  for l in label1, label2, label3, label4, label5, label6, label7, label8, label9:
2568  l.SetBorderSize(0)
2569  l.SetFillColor(ROOT.kWhite)
2570 
2571  for l in label1, label2, label3, label4:
2572  l.SetTextAngle(90)
2573  l.SetTextSize(0.09)
2574 
2575  #label9.SetTextAngle(30)
2576  label9.SetTextSize(0.59)
2577 
2578  pads[1].cd(); label1.Draw()
2579  pads[6].cd(); label2.Draw()
2580  pads[11].cd(); label3.Draw()
2581  pads[16].cd(); label4.Draw()
2582  pads[22].cd(); label5.Draw()
2583  pads[23].cd(); label6.Draw()
2584  pads[24].cd(); label7.Draw()
2585  pads[25].cd(); label8.Draw()
2586 
2587  pads[2].SetRightMargin(1e-5)
2588  pads[2].SetBottomMargin(1e-5)
2589  pads[2].SetLeftMargin(0.17)
2590  pads[3].SetLeftMargin(1e-5)
2591  pads[3].SetRightMargin(1e-5)
2592  pads[3].SetBottomMargin(1e-5)
2593  pads[4].SetLeftMargin(1e-5)
2594  pads[4].SetRightMargin(1e-5)
2595  pads[4].SetBottomMargin(1e-5)
2596  pads[5].SetLeftMargin(1e-5)
2597  pads[5].SetBottomMargin(1e-5)
2598 
2599  pads[7].SetRightMargin(1e-5)
2600  pads[7].SetBottomMargin(1e-5)
2601  pads[7].SetTopMargin(1e-5)
2602  pads[7].SetLeftMargin(0.17)
2603  pads[8].SetLeftMargin(1e-5)
2604  pads[8].SetRightMargin(1e-5)
2605  pads[8].SetBottomMargin(1e-5)
2606  pads[8].SetTopMargin(1e-5)
2607  pads[9].SetLeftMargin(1e-5)
2608  pads[9].SetRightMargin(1e-5)
2609  pads[9].SetBottomMargin(1e-5)
2610  pads[9].SetTopMargin(1e-5)
2611  pads[10].SetLeftMargin(1e-5)
2612  pads[10].SetBottomMargin(1e-5)
2613  pads[10].SetTopMargin(1e-5)
2614 
2615  pads[12].SetRightMargin(1e-5)
2616  pads[12].SetBottomMargin(1e-5)
2617  pads[12].SetTopMargin(1e-5)
2618  pads[12].SetLeftMargin(0.17)
2619  pads[13].SetLeftMargin(1e-5)
2620  pads[13].SetRightMargin(1e-5)
2621  pads[13].SetBottomMargin(1e-5)
2622  pads[13].SetTopMargin(1e-5)
2623  pads[14].SetLeftMargin(1e-5)
2624  pads[14].SetRightMargin(1e-5)
2625  pads[14].SetBottomMargin(1e-5)
2626  pads[14].SetTopMargin(1e-5)
2627  pads[15].SetLeftMargin(1e-5)
2628  pads[15].SetBottomMargin(1e-5)
2629  pads[15].SetTopMargin(1e-5)
2630 
2631  pads[17].SetRightMargin(1e-5)
2632  pads[17].SetTopMargin(1e-5)
2633  pads[17].SetLeftMargin(0.17)
2634  pads[18].SetLeftMargin(1e-5)
2635  pads[18].SetRightMargin(1e-5)
2636  pads[18].SetTopMargin(1e-5)
2637  pads[19].SetLeftMargin(1e-5)
2638  pads[19].SetRightMargin(1e-5)
2639  pads[19].SetTopMargin(1e-5)
2640  pads[20].SetLeftMargin(1e-5)
2641  pads[20].SetTopMargin(1e-5)
2642 
2643  chamber_x_trackx.GetXaxis().SetLabelColor(ROOT.kWhite)
2644  chamber_x_tracky.GetXaxis().SetLabelColor(ROOT.kWhite)
2645  chamber_x_tracky.GetYaxis().SetLabelColor(ROOT.kWhite)
2646  chamber_x_trackdxdz.GetXaxis().SetLabelColor(ROOT.kWhite)
2647  chamber_x_trackdxdz.GetYaxis().SetLabelColor(ROOT.kWhite)
2648  chamber_x_trackdydz.GetXaxis().SetLabelColor(ROOT.kWhite)
2649  chamber_x_trackdydz.GetYaxis().SetLabelColor(ROOT.kWhite)
2650  chamber_y_trackx.GetXaxis().SetLabelColor(ROOT.kWhite)
2651  chamber_y_tracky.GetXaxis().SetLabelColor(ROOT.kWhite)
2652  chamber_y_tracky.GetYaxis().SetLabelColor(ROOT.kWhite)
2653  chamber_y_trackdxdz.GetXaxis().SetLabelColor(ROOT.kWhite)
2654  chamber_y_trackdxdz.GetYaxis().SetLabelColor(ROOT.kWhite)
2655  chamber_y_trackdydz.GetXaxis().SetLabelColor(ROOT.kWhite)
2656  chamber_y_trackdydz.GetYaxis().SetLabelColor(ROOT.kWhite)
2657  chamber_dxdz_trackx.GetXaxis().SetLabelColor(ROOT.kWhite)
2658  chamber_dxdz_tracky.GetXaxis().SetLabelColor(ROOT.kWhite)
2659  chamber_dxdz_tracky.GetYaxis().SetLabelColor(ROOT.kWhite)
2660  chamber_dxdz_trackdxdz.GetXaxis().SetLabelColor(ROOT.kWhite)
2661  chamber_dxdz_trackdxdz.GetYaxis().SetLabelColor(ROOT.kWhite)
2662  chamber_dxdz_trackdydz.GetXaxis().SetLabelColor(ROOT.kWhite)
2663  chamber_dxdz_trackdydz.GetYaxis().SetLabelColor(ROOT.kWhite)
2664 
2665  # chamber_dydz_trackx
2666  chamber_dydz_tracky.GetYaxis().SetLabelColor(ROOT.kWhite)
2667  chamber_dydz_trackdxdz.GetYaxis().SetLabelColor(ROOT.kWhite)
2668  chamber_dydz_trackdydz.GetYaxis().SetLabelColor(ROOT.kWhite)
2669 
2670  pads[2].cd()
2671  chamber_x_trackx.Draw("e1")
2672  if not suppressblue: chamber_x_trackx_fit2.Draw("samel")
2673  chamber_x_trackx_fit.Draw("samel")
2674  #label99 = ROOT.TPaveLabel(0, 0.8, 1, 1, getname(r),"NDC")
2675  print getname(r)
2676  #label99 = ROOT.TPaveLabel(0, 0.8, 1, 1, "aaa","NDC")
2677  label9.Draw()
2678  #pads[2].Modified()
2679 
2680  pads[3].cd()
2681  chamber_x_tracky.Draw("e1")
2682  if not suppressblue: chamber_x_tracky_fit2.Draw("samel")
2683  chamber_x_tracky_fit.Draw("samel")
2684 
2685  pads[4].cd()
2686  chamber_x_trackdxdz.Draw("e1")
2687  if not suppressblue: chamber_x_trackdxdz_fit2.Draw("samel")
2688  chamber_x_trackdxdz_fit.Draw("samel")
2689 
2690  pads[5].cd()
2691  chamber_x_trackdydz.Draw("e1")
2692  if not suppressblue: chamber_x_trackdydz_fit2.Draw("samel")
2693  chamber_x_trackdydz_fit.Draw("samel")
2694 
2695  pads[7].cd()
2696  chamber_y_trackx.Draw("e1")
2697  if not suppressblue: chamber_y_trackx_fit2.Draw("samel")
2698  chamber_y_trackx_fit.Draw("samel")
2699 
2700  pads[8].cd()
2701  chamber_y_tracky.Draw("e1")
2702  if not suppressblue: chamber_y_tracky_fit2.Draw("samel")
2703  chamber_y_tracky_fit.Draw("samel")
2704 
2705  pads[9].cd()
2706  chamber_y_trackdxdz.Draw("e1")
2707  if not suppressblue: chamber_y_trackdxdz_fit2.Draw("samel")
2708  chamber_y_trackdxdz_fit.Draw("samel")
2709 
2710  pads[10].cd()
2711  chamber_y_trackdydz.Draw("e1")
2712  if not suppressblue: chamber_y_trackdydz_fit2.Draw("samel")
2713  chamber_y_trackdydz_fit.Draw("samel")
2714 
2715  pads[12].cd()
2716  chamber_dxdz_trackx.Draw("e1")
2717  if not suppressblue: chamber_dxdz_trackx_fit2.Draw("samel")
2718  chamber_dxdz_trackx_fit.Draw("samel")
2719 
2720  pads[13].cd()
2721  chamber_dxdz_tracky.Draw("e1")
2722  if not suppressblue: chamber_dxdz_tracky_fit2.Draw("samel")
2723  chamber_dxdz_tracky_fit.Draw("samel")
2724 
2725  pads[14].cd()
2726  chamber_dxdz_trackdxdz.Draw("e1")
2727  if not suppressblue: chamber_dxdz_trackdxdz_fit2.Draw("samel")
2728  chamber_dxdz_trackdxdz_fit.Draw("samel")
2729 
2730  pads[15].cd()
2731  chamber_dxdz_trackdydz.Draw("e1")
2732  if not suppressblue: chamber_dxdz_trackdydz_fit2.Draw("samel")
2733  chamber_dxdz_trackdydz_fit.Draw("samel")
2734 
2735  pads[17].cd()
2736  chamber_dydz_trackx.Draw("e1")
2737  if not suppressblue: chamber_dydz_trackx_fit2.Draw("samel")
2738  chamber_dydz_trackx_fit.Draw("samel")
2739 
2740  pads[18].cd()
2741  chamber_dydz_tracky.Draw("e1")
2742  if not suppressblue: chamber_dydz_tracky_fit2.Draw("samel")
2743  chamber_dydz_tracky_fit.Draw("samel")
2744 
2745  pads[19].cd()
2746  chamber_dydz_trackdxdz.Draw("e1")
2747  if not suppressblue: chamber_dydz_trackdxdz_fit2.Draw("samel")
2748  chamber_dydz_trackdxdz_fit.Draw("samel")
2749 
2750  pads[20].cd()
2751  chamber_dydz_trackdydz.Draw("e1")
2752  if not suppressblue: chamber_dydz_trackdydz_fit2.Draw("samel")
2753  chamber_dydz_trackdydz_fit.Draw("samel")
2754 
2755  else:
2756  c1.Clear()
2757  #c1.Divide(5, 3, 1e-5, 1e-5)
2758  pads = [None]
2759  pads.append(ROOT.TPad("p1" ,"",0.00,0.55,0.07,1.00,0,0,0))
2760  pads.append(ROOT.TPad("p2" ,"",0.07,0.55,0.34,1.00,0,0,0))
2761  pads.append(ROOT.TPad("p3" ,"",0.34,0.55,0.56,1.00,0,0,0))
2762  pads.append(ROOT.TPad("p4" ,"",0.56,0.55,0.78,1.00,0,0,0))
2763  pads.append(ROOT.TPad("p5" ,"",0.78,0.55,1.00,1.00,0,0,0))
2764  pads.append(ROOT.TPad("p6" ,"",0.00,0.1,0.07,0.55,0,0,0))
2765  pads.append(ROOT.TPad("p7" ,"",0.07,0.1,0.34,0.55,0,0,0))
2766  pads.append(ROOT.TPad("p8" ,"",0.34,0.1,0.56,0.55,0,0,0))
2767  pads.append(ROOT.TPad("p9" ,"",0.56,0.1,0.78,0.55,0,0,0))
2768  pads.append(ROOT.TPad("p10","",0.78,0.1,1.00,0.55,0,0,0))
2769  pads.append(ROOT.TPad("p11","",0.00,0.,0.07,0.1,0,0,0))
2770  pads.append(ROOT.TPad("p12","",0.07,0.,0.34,0.1,0,0,0))
2771  pads.append(ROOT.TPad("p13","",0.34,0.,0.56,0.1,0,0,0))
2772  pads.append(ROOT.TPad("p14","",0.56,0.,0.78,0.1,0,0,0))
2773  pads.append(ROOT.TPad("p15","",0.78,0.,1.00,0.1,0,0,0))
2774  for p in pads:
2775  if not not p:
2776  p.Draw()
2777  ROOT.SetOwnership(p,False)
2778 
2779  label1 = ROOT.TPaveLabel(0, 0, 1, 1, "x residuals (mm)")
2780  label2 = ROOT.TPaveLabel(0, 0, 1, 1, "dx/dz residuals (mrad)")
2781  label3 = ROOT.TPaveLabel(0, 0.3, 1, 1, "x position (cm)")
2782  label4 = ROOT.TPaveLabel(0, 0.3, 1, 1, "y position (cm)")
2783  label5 = ROOT.TPaveLabel(0, 0.3, 1, 1, "dx/dz angle (rad)")
2784  label6 = ROOT.TPaveLabel(0, 0.3, 1, 1, "dy/dz angle (rad)")
2785  label9 = ROOT.TPaveLabel(0, 0.85, 1, 1, getname(r),"NDC")
2786 
2787  if name[0:2] == "ME":
2788  label1 = ROOT.TPaveLabel(0, 0, 1, 1, "r#phi residuals (mm)")
2789  label2 = ROOT.TPaveLabel(0, 0, 1, 1, "d(r#phi)/dz residuals (mrad)")
2790 
2791  for l in label1, label2, label3, label4, label5, label6, label9:
2792  l.SetBorderSize(0)
2793  l.SetFillColor(ROOT.kWhite)
2794 
2795  for l in label1, label2:
2796  l.SetTextAngle(90)
2797  l.SetTextSize(0.09)
2798 
2799  #label9.SetTextAngle(30)
2800  label9.SetTextSize(0.29)
2801 
2802  pads[1].cd(); label1.Draw()
2803  pads[6].cd(); label2.Draw()
2804  pads[12].cd(); label3.Draw()
2805  pads[13].cd(); label4.Draw()
2806  pads[14].cd(); label5.Draw()
2807  pads[15].cd(); label6.Draw()
2808  #pads[11].cd(); label9.Draw()
2809 
2810  pads[2].SetRightMargin(1e-5)
2811  pads[2].SetBottomMargin(1e-5)
2812  pads[3].SetLeftMargin(1e-5)
2813  pads[3].SetRightMargin(1e-5)
2814  pads[3].SetBottomMargin(1e-5)
2815  pads[4].SetLeftMargin(1e-5)
2816  pads[4].SetRightMargin(1e-5)
2817  pads[4].SetBottomMargin(1e-5)
2818  pads[5].SetLeftMargin(1e-5)
2819  pads[5].SetBottomMargin(1e-5)
2820 
2821  pads[7].SetRightMargin(1e-5)
2822  pads[7].SetTopMargin(1e-5)
2823  pads[8].SetLeftMargin(1e-5)
2824  pads[8].SetRightMargin(1e-5)
2825  pads[8].SetTopMargin(1e-5)
2826  pads[9].SetLeftMargin(1e-5)
2827  pads[9].SetRightMargin(1e-5)
2828  pads[9].SetTopMargin(1e-5)
2829  pads[10].SetLeftMargin(1e-5)
2830  pads[10].SetTopMargin(1e-5)
2831 
2832  chamber_x_trackx.GetXaxis().SetLabelColor(ROOT.kWhite)
2833  chamber_x_tracky.GetXaxis().SetLabelColor(ROOT.kWhite)
2834  chamber_x_tracky.GetYaxis().SetLabelColor(ROOT.kWhite)
2835  chamber_x_trackdxdz.GetXaxis().SetLabelColor(ROOT.kWhite)
2836  chamber_x_trackdxdz.GetYaxis().SetLabelColor(ROOT.kWhite)
2837  chamber_x_trackdydz.GetXaxis().SetLabelColor(ROOT.kWhite)
2838  chamber_x_trackdydz.GetYaxis().SetLabelColor(ROOT.kWhite)
2839  # chamber_dxdz_trackx
2840  chamber_dxdz_tracky.GetYaxis().SetLabelColor(ROOT.kWhite)
2841  chamber_dxdz_trackdxdz.GetYaxis().SetLabelColor(ROOT.kWhite)
2842  chamber_dxdz_trackdydz.GetYaxis().SetLabelColor(ROOT.kWhite)
2843 
2844  pads[2].cd()
2845  chamber_x_trackx.Draw("e1")
2846  if not suppressblue: chamber_x_trackx_fit2.Draw("samel")
2847  chamber_x_trackx_fit.Draw("samel")
2848  label9.Draw()
2849 
2850  pads[3].cd()
2851  chamber_x_tracky.Draw("e1")
2852  if not suppressblue: chamber_x_tracky_fit2.Draw("samel")
2853  chamber_x_tracky_fit.Draw("samel")
2854 
2855  pads[4].cd()
2856  chamber_x_trackdxdz.Draw("e1")
2857  if not suppressblue: chamber_x_trackdxdz_fit2.Draw("samel")
2858  chamber_x_trackdxdz_fit.Draw("samel")
2859 
2860  pads[5].cd()
2861  chamber_x_trackdydz.Draw("e1")
2862  if not suppressblue: chamber_x_trackdydz_fit2.Draw("samel")
2863  chamber_x_trackdydz_fit.Draw("samel")
2864 
2865  pads[7].cd()
2866  chamber_dxdz_trackx.Draw("e1")
2867  if not suppressblue: chamber_dxdz_trackx_fit2.Draw("samel")
2868  chamber_dxdz_trackx_fit.Draw("samel")
2869 
2870  pads[8].cd()
2871  chamber_dxdz_tracky.Draw("e1")
2872  if not suppressblue: chamber_dxdz_tracky_fit2.Draw("samel")
2873  chamber_dxdz_tracky_fit.Draw("samel")
2874 
2875  pads[9].cd()
2876  chamber_dxdz_trackdxdz.Draw("e1")
2877  if not suppressblue: chamber_dxdz_trackdxdz_fit2.Draw("samel")
2878  chamber_dxdz_trackdxdz_fit.Draw("samel")
2879 
2880  pads[10].cd()
2881  chamber_dxdz_trackdydz.Draw("e1")
2882  if not suppressblue: chamber_dxdz_trackdydz_fit2.Draw("samel")
2883  chamber_dxdz_trackdydz_fit.Draw("samel")
2884 
2885  tn = time.time()
2886  ddt[8] = 1./ddt[7]*((ddt[7]-1)*ddt[8] + tn-t1)
def plotscripts.postalAddressToId (   postal_address)

Definition at line 884 of file plotscripts.py.

References funct.abs().

885 def postalAddressToId(postal_address):
886  if postal_address[0] == "DT":
887  wheel, station, sector = postal_address[1:]
888  w = "%+d"%wheel
889  if w=="+0": w = "-0"
890  return "MB%s/%d/%02d" % (w, station, sector)
891  elif postal_address[0] == "CSC":
892  endcap, station, ring, chamber = postal_address[1:]
893  if endcap != 1: station = -1 * abs(station)
894  return "ME%+d/%d/%02d" % (station, ring, chamber)
895 
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def postalAddressToId
Definition: plotscripts.py:884
def plotscripts.printDeltaTs ( )

Definition at line 2046 of file plotscripts.py.

2047 def printDeltaTs():
2048  n = 0
2049  for t in ddt:
2050  if n==0 or n==7 or n==15: print "%d calls" % t
2051  else: print "%d : %0.3f ms" % (n,t*1000.0)
2052  n += 1
def plotscripts.rlines (   disk,
  window,
  abscissa 
)

Definition at line 455 of file plotscripts.py.

Referenced by mapplot().

456 def rlines(disk, window, abscissa):
457  global rline_tlines
458  rline_tlines = []
459  if disk == 1: rl = [150., 270., 480.]
460  else: rl = [350.]
461  for r in rl:
462  if abscissa is None or abscissa[0] < r < abscissa[1]:
463  rline_tlines.append(ROOT.TLine(r, -window, r, window))
464  rline_tlines[-1].SetLineStyle(2)
465  rline_tlines[-1].Draw()
def plotscripts.rms (   xlist)

Definition at line 60 of file plotscripts.py.

References mathSSE.sqrt().

Referenced by HcalDetDiagLEDMonitor.CheckStatus(), HcalDetDiagPedestalMonitor.CheckStatus(), PFClient_JetRes.createResolutionPlots(), PFClient.createResolutionPlots(), HcalTimeSlewSim.delay(), HcalHitCorrection.delay(), DQMChannel.DQMChannel(), EcalZmassClient.dqmEndJob(), DTTPAnalyzer.endJob(), DTTTrigCorrectionFirst.endJob(), HOCalibAnalyzer.endJob(), ZeeCalibration.endOfJob(), RPCBxTest.endRun(), PedsFullNoiseSummaryFactory.extract(), RPCLinkSynchroHistoMaker.fill(), HcalDetDiagLEDMonitor.fillHistos(), HcalDetDiagPedestalMonitor.fillHistos(), HcalDetDiagLaserMonitor.fillHistos(), HcalDetDiagLaserMonitor.fillProblems(), LA_Filler_Fitter.find_rebin(), HcalDetDiagLaserMonitor.get_ave_rbx(), HcalDetDiagLaserMonitor.get_ave_subdet(), GetMPV(), DTMtimeHandler.getNewObjects(), DTTtrigHandler.getNewObjects(), TMom.getRMS(), EcalBarrelRecHitsMaker.init(), EcalEndcapRecHitsMaker.init(), TMom.init(), HcalDetDiagPedestalMonitor.LoadDataset(), HcalDetDiagLaserMonitor.LoadDataset(), HcalDetDiagLEDMonitor.LoadReference(), HcalDetDiagPedestalMonitor.LoadReference(), HcalDetDiagLaserMonitor.LoadReference(), TPedValues.makePlots(), reco::tau::RecoTauDiscriminantInvariantWidth.operator()(), DQMClientExample.performClient(), PhiBorderFinder.PhiBorderFinder(), cond::PayLoadInspector< DataT >.plot(), SiPixelDetSummary.print(), RPCLinkSynchroStat::SynchroCounts.print(), SiStripDetSummary.print(), SiStripNoises.printSummary(), TH2Analyzer.ProcessSlice(), TH2Analyzer.ProcessSlices(), ecaldqm::PedestalClient.producePlots(), ecaldqm::PresampleClient.producePlots(), ecaldqm::TestPulseClient.producePlots(), ecaldqm::TimingClient.producePlots(), PuppiContainer.puppiWeights(), RBorderFinder.RBorderFinder(), DTSurvey.ReadChambers(), LA_Filler_Fitter.rms_profile(), ecaldqm::LaserWriter.run(), ecaldqm::PedestalWriter.run(), ecaldqm::PresampleWriter.run(), ecaldqm::TestPulseWriter.run(), ecaldqm::TimingWriter.run(), DTTriggerLutTest.runClientDiagnostic(), DTOccupancyTest.runOccupancyTest(), ContentsWithinExpected.runTest(), HcalDetDiagLEDMonitor.SaveReference(), HcalDetDiagPedestalMonitor.SaveReference(), HcalDetDiagLaserMonitor.SaveReference(), HcalDetDiagPedestalData.set_data(), HcalDetDiagLaserData.set_data(), HcalDetDiagLEDData.set_reference(), HcalDetDiagPedestalData.set_reference(), HcalDetDiagLaserData.set_reference(), MonTestPulseDat.setADCRMSG1(), MonPedestalsOnlineDat.setADCRMSG12(), MonTestPulseDat.setADCRMSG12(), MonTestPulseDat.setADCRMSG6(), MonLaserRedDat.setAPDOverPNRMS(), MonLaserBlueDat.setAPDOverPNRMS(), MonLaserGreenDat.setAPDOverPNRMS(), MonLaserIRedDat.setAPDOverPNRMS(), MonLaserIRedDat.setAPDRMS(), MonLaserGreenDat.setAPDRMS(), MonLaserRedDat.setAPDRMS(), MonLaserBlueDat.setAPDRMS(), DCUCapsuleTempRawDat.setCapsuleTempRMS(), MonDelaysTTDat.setDelayRMS(), MonPedestalsDat.setPedRMSG1(), MonPedestalsDat.setPedRMSG12(), MonPedestalsDat.setPedRMSG6(), ITimingDat.setTimingRMS(), MonLed2Dat.setVPTOverPNRMS(), MonLed1Dat.setVPTOverPNRMS(), MonLed2Dat.setVPTRMS(), MonLed1Dat.setVPTRMS(), and ecaldqm::MESetTrend.shift_().

60 
61 def rms(xlist):
62  s2, n = 0., 0.
63  for x in xlist:
64  s2 += x**2
65  n += 1.
66  return sqrt(s2/n)
T sqrt(T t)
Definition: SSEVec.h:48
def plotscripts.saveTestResultsMap (   run_name)

Definition at line 1181 of file plotscripts.py.

Referenced by alignmentValidation.doMapPlotsCSC(), and alignmentValidation.doMapPlotsDT().

1182 def saveTestResultsMap(run_name):
1183  if len(MAP_RESULTS_SAWTOOTH)+len(MAP_RESULTS_FITSIN)==0: return None
1184  ff = open("tmp_test_results_map__%s.pkl" % run_name, "wb")
1185  pickle.dump(MAP_RESULTS_SAWTOOTH, ff)
1186  pickle.dump(MAP_RESULTS_FITSIN, ff)
1187  ff.close()
1188 
def saveTestResultsMap
def plotscripts.segdiff (   tfiles,
  component,
  pair,
  args 
)

Definition at line 2889 of file plotscripts.py.

References funct.abs(), MultipleCompare.Divide(), mathSSE.sqrt(), and wheelLetter().

Referenced by alignmentValidation.doSegDiffPlotsCSC(), alignmentValidation.doSegDiffPlotsDT(), segdiffvsphi(), and segdiffvsphicsc().

2890 def segdiff(tfiles, component, pair, **args):
2891  tdrStyle.SetOptFit(1)
2892  tdrStyle.SetOptTitle(1)
2893  tdrStyle.SetTitleBorderSize(1)
2894  tdrStyle.SetTitleFontSize(0.05)
2895  tdrStyle.SetStatW(0.2)
2896  tdrStyle.SetStatY(0.9)
2897  tdrStyle.SetStatFontSize(0.06)
2898 
2899  if component[0:2] == "dt":
2900  wheel = args["wheel"]
2901  wheelletter = wheelLetter(wheel)
2902  sector = args["sector"]
2903  profname = "%s_%s_%02d_%s" % (component, wheelletter, sector, str(pair))
2904  posname = "pos" + profname
2905  negname = "neg" + profname
2906  #print profname
2907 
2908  station1 = int(str(pair)[0])
2909  station2 = int(str(pair)[1])
2910  phi1 = signConventions["DT", wheel, station1, sector][4]
2911  phi2 = signConventions["DT", wheel, station2, sector][4]
2912  if abs(phi1 - phi2) > 1.:
2913  if phi1 > phi2: phi1 -= 2.*pi
2914  else: phi1 += 2.*pi
2915  phi = (phi1 + phi2) / 2.
2916  while (phi < -pi): phi += 2.*pi
2917  while (phi > pi): phi -= 2.*pi
2918 
2919  elif component[0:3] == "csc":
2920  endcap = args["endcap"]
2921  if endcap=="m":
2922  endcapnum=2
2923  endcapsign="-"
2924  elif endcap=="p":
2925  endcapnum=1
2926  endcapsign="+"
2927  else: raise Exception
2928 
2929  ring = args["ring"]
2930  if ring>2 or ring<1: raise Exception
2931  station1 = int(str(pair)[0])
2932  station2 = int(str(pair)[1])
2933  if ring==1: ringname="inner"
2934  elif ring==2: ringname="outer"
2935  else: raise Exception
2936 
2937  chamber = args["chamber"]
2938  if (ring==1 and chamber>18) or (ring==2 and chamber>36): raise Exception
2939 
2940  profname = "csc%s_%s_%s_%02d_%s" % (ringname,component[4:], endcap, chamber, str(pair))
2941  posname = "pos" + profname
2942  negname = "neg" + profname
2943  #print profname
2944 
2945  station1 = int(str(pair)[0])
2946  station2 = int(str(pair)[1])
2947  phi1 = signConventions["CSC", endcapnum, station1, ring, chamber][4]
2948  phi2 = signConventions["CSC", endcapnum, station2, ring, chamber][4]
2949  if abs(phi1 - phi2) > 1.:
2950  if phi1 > phi2: phi1 -= 2.*pi
2951  else: phi1 += 2.*pi
2952  phi = (phi1 + phi2) / 2.
2953  while (phi < -pi*5./180.): phi += 2.*pi
2954  while (phi > pi*(2.-5./180.)): phi -= 2.*pi
2955 
2956  else: raise Exception
2957 
2958  if "window" in args: window = args["window"]
2959  else: window = 5.
2960 
2961  global tmpprof, tmppos, tmpneg
2962  pdir = "AlignmentMonitorSegmentDifferences/iter1/"
2963  tmpprof = tfiles[0].Get(pdir + profname).Clone()
2964  tmpprof.SetMarkerStyle(8)
2965  tmppos = tfiles[0].Get(pdir + posname).Clone()
2966  tmpneg = tfiles[0].Get(pdir + negname).Clone()
2967  for tfile in tfiles[1:]:
2968  tmpprof.Add(tfile.Get(pdir + profname))
2969  tmppos.Add(tfile.Get(pdir + posname))
2970  tmpneg.Add(tfile.Get(pdir + negname))
2971 
2972  for i in xrange(1, tmpprof.GetNbinsX()+1):
2973  if tmpprof.GetBinError(i) < 1e-5:
2974  tmpprof.SetBinError(i, 100.)
2975  tmpprof.SetAxisRange(-window, window, "Y")
2976 
2977  f = ROOT.TF1("p1", "[0] + [1]*x", tmpprof.GetBinLowEdge(1), -tmpprof.GetBinLowEdge(1))
2978  f.SetParameters((tmppos.GetMean() + tmpneg.GetMean())/2., 0.)
2979 
2980  tmpprof.SetXTitle("q/p_{T} (c/GeV)")
2981  if component == "dt13_resid":
2982  tmpprof.SetYTitle("#Deltax^{local} (mm)")
2983  tmppos.SetXTitle("#Deltax^{local} (mm)")
2984  tmpneg.SetXTitle("#Deltax^{local} (mm)")
2985  f.SetParNames("#Deltax^{local}_{0}", "Slope")
2986  if component == "dt13_slope":
2987  tmpprof.SetYTitle("#Deltadx/dz^{local} (mrad)")
2988  tmppos.SetXTitle("#Deltadx/dz^{local} (mrad)")
2989  tmpneg.SetXTitle("#Deltadx/dz^{local} (mrad)")
2990  f.SetParNames("#Deltadx/dz^{local}_{0}", "Slope")
2991  if component == "dt2_resid":
2992  tmpprof.SetYTitle("#Deltay^{local} (mm)")
2993  tmppos.SetXTitle("#Deltay^{local} (mm)")
2994  tmpneg.SetXTitle("#Deltay^{local} (mm)")
2995  f.SetParNames("#Deltay^{local}_{0}", "Slope")
2996  if component == "dt2_slope":
2997  tmpprof.SetYTitle("#Deltady/dz^{local} (mrad)")
2998  tmppos.SetXTitle("#Deltady/dz^{local} (mrad)")
2999  tmpneg.SetXTitle("#Deltady/dz^{local} (mrad)")
3000  f.SetParNames("#Deltady/dz^{local}_{0}", "Slope")
3001  if component == "csc_resid":
3002  tmpprof.SetXTitle("q/p_{z} (c/GeV)")
3003  tmpprof.SetYTitle("#Delta(r#phi)^{local} (mm)")
3004  tmppos.SetXTitle("#Delta(r#phi)^{local} (mm)")
3005  tmpneg.SetXTitle("#Delta(r#phi)^{local} (mm)")
3006  f.SetParNames("#Delta(r#phi)^{local}_{0}", "Slope")
3007  if component == "csc_slope":
3008  tmpprof.SetXTitle("q/p_{z} (c/GeV)")
3009  tmpprof.SetYTitle("#Deltad(r#phi)/dz^{local} (mrad)")
3010  tmppos.SetXTitle("#Deltad(r#phi)/dz^{local} (mrad)")
3011  tmpneg.SetXTitle("#Deltad(r#phi)/dz^{local} (mrad)")
3012  f.SetParNames("#Deltad(r#phi)/dz^{local}_{0}", "Slope")
3013 
3014  tmpprof.GetXaxis().CenterTitle()
3015  tmpprof.GetYaxis().CenterTitle()
3016  tmppos.GetXaxis().CenterTitle()
3017  tmpneg.GetXaxis().CenterTitle()
3018  if component[0:2] == "dt":
3019  tmpprof.SetTitle("MB%d - MB%d, wheel %d, sector %02d" % (station1, station2, int(wheel), int(sector)))
3020  elif component[0:3] == "csc":
3021  tmpprof.SetTitle("ME%d - ME%d, for ME%s%d/%d/%d" % (station1, station2, endcapsign, station2, ring, chamber))
3022  else: raise Exception
3023 
3024  tmppos.SetTitle("Positive muons")
3025  tmpneg.SetTitle("Negative muons")
3026 
3027  c1.Clear()
3028  c1.Divide(2, 1)
3029  c1.GetPad(1).cd()
3030  fit1 = tmpprof.Fit("p1", "qS")
3031  tmpprof.Draw("e1")
3032  c1.GetPad(2).cd()
3033  c1.GetPad(2).Divide(1, 2)
3034  c1.GetPad(2).GetPad(1).cd()
3035  tmppos.Draw()
3036  f = ROOT.TF1("gausR", "[0]*exp(-(x - [1])**2 / 2. / [2]**2) / sqrt(2.*3.1415926) / [2]",
3037  tmppos.GetMean() - tmppos.GetRMS(), tmppos.GetMean() + tmppos.GetRMS())
3038  f.SetParameters(tmppos.GetEntries() * ((10. - -10.)/100.), tmppos.GetMean(), tmppos.GetRMS())
3039  f.SetParNames("Constant", "Mean", "Sigma")
3040  fit2 = tmppos.Fit("gausR", "qRS")
3041  c1.GetPad(2).GetPad(2).cd()
3042  tmpneg.Draw()
3043  f = ROOT.TF1("gausR", "[0]*exp(-(x - [1])**2 / 2. / [2]**2) / sqrt(2.*3.1415926) / [2]",
3044  tmpneg.GetMean() - tmpneg.GetRMS(), tmpneg.GetMean() + tmpneg.GetRMS())
3045  f.SetParameters(tmpneg.GetEntries() * ((10. - -10.)/100.), tmpneg.GetMean(), tmpneg.GetRMS())
3046  f.SetParNames("Constant", "Mean", "Sigma")
3047  fit3 = tmpneg.Fit("gausR", "qRS")
3048 
3049  fit1ok = fit1.Status()==0 and fit1.CovMatrixStatus()==3
3050  fit2ok = fit2.Status()==0 and fit2.CovMatrixStatus()==3
3051  fit3ok = fit3.Status()==0 and fit3.CovMatrixStatus()==3
3052 
3053  fitresult1 = None, None
3054  if fit1ok:
3055  fitresult1 = tmpprof.GetFunction("p1").GetParameter(0), tmpprof.GetFunction("p1").GetParError(0)
3056  fitresult2 = None, None
3057  if fit2ok and fit3ok:
3058  fitresult2 = (tmppos.GetFunction("gausR").GetParameter(1) + tmpneg.GetFunction("gausR").GetParameter(1)) / 2., \
3059  sqrt(tmppos.GetFunction("gausR").GetParError(1)**2 + tmpneg.GetFunction("gausR").GetParError(1)**2) / 2.
3060  return phi, fitresult1[0], fitresult1[1], fitresult2[0], fitresult2[1], fit1ok, fit2ok, fit3ok
3061 
3062 
def wheelLetter
Definition: plotscripts.py:37
T sqrt(T t)
Definition: SSEVec.h:48
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def plotscripts.segdiff_xalign (   tfiles,
  component,
  args 
)

Definition at line 3065 of file plotscripts.py.

References funct.abs(), and mathSSE.sqrt().

Referenced by alignmentValidation.doSegDiffPlotsDT(), and segdiffvsphi_xalign().

3066 def segdiff_xalign(tfiles, component, **args):
3067  tdrStyle.SetOptFit(1)
3068  tdrStyle.SetOptTitle(1)
3069  tdrStyle.SetTitleBorderSize(1)
3070  tdrStyle.SetTitleFontSize(0.05)
3071  tdrStyle.SetStatW(0.2)
3072  tdrStyle.SetStatY(0.9)
3073  tdrStyle.SetStatFontSize(0.06)
3074 
3075  if component[0:4] == "x_dt":
3076  wheel = int(args["wheel"])
3077  if int(wheel)<0:
3078  wheell = "m%d" % abs(wheel)
3079  endcapsign="-"
3080  else:
3081  wheell = "p%d" % abs(wheel)
3082  endcapsign="+"
3083  station_dt = component[4]
3084  station_csc_1 = args["cscstations"][0]
3085  if station_csc_1=='1': ring_1 = 3
3086  else: ring_1 = 2
3087  sector = args["sector"]
3088  profname = "%s%s_W%sS%02d" % (component, station_csc_1, wheell, sector)
3089  posname_1 = "pos_" + profname
3090  negname_1 = "neg_" + profname
3091  if len(args["cscstations"]) > 1:
3092  station_csc_2 = args["cscstations"][1]
3093  if station_csc_2=='1': ring_2 = 3
3094  else: ring_2 = 2
3095  profname = "%s%s_W%sS%02d" % (component, station_csc_2, wheell, sector)
3096  posname_2 = "pos_" + profname
3097  negname_2 = "neg_" + profname
3098 
3099  phi = signConventions["DT", wheel, int(station_dt), sector][4]
3100  while (phi < -pi): phi += 2.*pi
3101  while (phi > pi): phi -= 2.*pi
3102 
3103  else: raise Exception
3104 
3105  if "window" in args: window = args["window"]
3106  else: window = 5.
3107 
3108  global tmppos, tmpneg, tmppos_2, tmpneg_2
3109  pdir = "AlignmentMonitorSegmentDifferences/iter1/"
3110  tmppos = tfiles[0].Get(pdir + posname_1).Clone()
3111  tmpneg = tfiles[0].Get(pdir + negname_1).Clone()
3112  if len(args["cscstations"]) > 1:
3113  tmppos_2 = tfiles[0].Get(pdir + posname_2).Clone()
3114  tmpneg_2 = tfiles[0].Get(pdir + negname_2).Clone()
3115  tmpneg.Rebin(2); tmppos.Rebin(2)
3116  for tfile in tfiles[1:]:
3117  tmppos.Add(tfile.Get(pdir + posname_1))
3118  tmpneg.Add(tfile.Get(pdir + negname_1))
3119  if len(args["cscstations"]) > 1:
3120  tmppos_2.Add(tfile.Get(pdir + posname_2))
3121  tmpneg_2.Add(tfile.Get(pdir + negname_2))
3122  tmpneg_2.Rebin(2); tmppos_2.Rebin(2)
3123 
3124  result = {}
3125  result["fit_ok"] = False
3126  result["phi"] = phi
3127  ntot = tmppos.GetEntries() + tmpneg.GetEntries()
3128  if ntot == 0:
3129  return result
3130 
3131  tmppos.SetXTitle("#Deltax^{loc}_{MB} - r_{DT}/r_{CSC}#times#Deltax^{loc}_{ME} (mm)")
3132  tmpneg.SetXTitle("#Deltax^{loc}_{MB} - r_{DT}/r_{CSC}#times#Deltax^{loc}_{ME} (mm)")
3133  title1 = "MB(W%+d St%s Sec%d) - ME%s%s/%d" % (wheel, station_dt, int(sector), endcapsign, station_csc_1, ring_1)
3134  tmppos.SetTitle("Positive #mu: %s" % title1);
3135  tmpneg.SetTitle("Negative #mu: %s" % title1);
3136  tmppos.GetXaxis().CenterTitle()
3137  tmpneg.GetXaxis().CenterTitle()
3138  if len(args["cscstations"]) > 1:
3139  tmppos.SetXTitle("#Deltax^{loc}_{DT} - r_{DT}/r_{CSC}#times#Deltax^{loc}_{CSC} (mm)")
3140  tmpneg.SetXTitle("#Deltax^{loc}_{DT} - r_{DT}/r_{CSC}#times#Deltax^{loc}_{CSC} (mm)")
3141  title2 = "MB(W%+d St%s Sec%d) - ME%s%s/%d" % (wheel, station_dt, int(sector), endcapsign, station_csc_2, ring_2)
3142  tmppos_2.SetTitle("Positive #mu: %s" % title2);
3143  tmpneg_2.SetTitle("Negative #mu: %s" % title2);
3144  tmppos_2.GetXaxis().CenterTitle()
3145  tmpneg_2.GetXaxis().CenterTitle()
3146 
3147  c1.Clear()
3148  c1.Divide(2, 2)
3149 
3150  c1.GetPad(1).cd()
3151  tmppos.Draw()
3152  fpos = ROOT.TF1("gpos", "gaus", tmppos.GetMean() - tmppos.GetRMS(), tmppos.GetMean() + tmppos.GetRMS())
3153  fpos.SetParameters(tmppos.GetEntries() * 2.5, tmppos.GetMean(), tmppos.GetRMS())
3154  fit_pos = tmppos.Fit("gpos", "qRS")
3155 
3156  c1.GetPad(3).cd()
3157  tmpneg.Draw()
3158  fneg = ROOT.TF1("gneg", "gaus", tmpneg.GetMean() - tmpneg.GetRMS(), tmpneg.GetMean() + tmpneg.GetRMS())
3159  fneg.SetParameters(tmpneg.GetEntries() * 2.5, tmpneg.GetMean(), tmpneg.GetRMS())
3160  fit_neg = tmpneg.Fit("gneg", "qRS")
3161 
3162  result["fit_ok"] = (fit_pos.Status()==0 and fit_pos.CovMatrixStatus()==3 and fit_neg.Status()==0 and fit_neg.CovMatrixStatus()==3)
3163  result["fit_peak"] = (fpos.GetParameter(1)*tmppos.GetEntries() + fneg.GetParameter(1)*tmpneg.GetEntries()) / ntot
3164  result["fit_peak_error"] = sqrt( (fpos.GetParError(1)*tmppos.GetEntries())**2 + (fneg.GetParError(1)*tmpneg.GetEntries())**2) / ntot
3165 
3166  if len(args["cscstations"]) > 1:
3167  c1.GetPad(2).cd()
3168  tmppos_2.Draw()
3169  fpos_2 = ROOT.TF1("gpos2", "gaus", tmppos_2.GetMean() - tmppos_2.GetRMS(), tmppos_2.GetMean() + tmppos_2.GetRMS())
3170  fpos_2.SetParameters(tmppos_2.GetEntries() * 2.5, tmppos_2.GetMean(), tmppos_2.GetRMS())
3171  fit_pos_2 = tmppos_2.Fit("gpos2", "qRS")
3172 
3173  c1.GetPad(4).cd()
3174  tmpneg_2.Draw()
3175  fneg_2 = ROOT.TF1("gneg2", "gaus", tmpneg_2.GetMean() - tmpneg_2.GetRMS(), tmpneg_2.GetMean() + tmpneg_2.GetRMS())
3176  fneg_2.SetParameters(tmpneg_2.GetEntries() * 2.5, tmpneg_2.GetMean(), tmpneg_2.GetRMS())
3177  fit_neg_2 = tmpneg_2.Fit("gneg2", "qRS")
3178 
3179  result["fit_ok_2"] = (fit_pos_2.Status()==0 and fit_pos_2.CovMatrixStatus()==3 and fit_neg_2.Status()==0 and fit_neg_2.CovMatrixStatus()==3)
3180  ntot = tmppos_2.GetEntries() + tmpneg_2.GetEntries()
3181  result["fit_peak_2"] = (fpos_2.GetParameter(1)*tmppos_2.GetEntries() + fneg_2.GetParameter(1)*tmpneg_2.GetEntries()) / ntot
3182  result["fit_peak_error_2"] = sqrt( (fpos_2.GetParError(1)*tmppos_2.GetEntries())**2 + (fneg_2.GetParError(1)*tmpneg_2.GetEntries())**2) / ntot
3183 
3184  return result
T sqrt(T t)
Definition: SSEVec.h:48
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def segdiff_xalign
def plotscripts.segdiffvsphi (   tfiles,
  reports,
  component,
  wheel,
  window = 5.,
  excludesectors = () 
)

Definition at line 3302 of file plotscripts.py.

References mean(), segdiff(), and stdev().

Referenced by alignmentValidation.doSegDiffPlotsDT().

3303 def segdiffvsphi(tfiles, reports, component, wheel, window=5., excludesectors=()):
3304  tdrStyle.SetOptTitle(1)
3305  tdrStyle.SetTitleBorderSize(1)
3306  tdrStyle.SetTitleFontSize(0.05)
3307 
3308  global htemp, gtemp_12, gtemp2_12, gtemp_23, gtemp2_23, gtemp_34, gtemp2_34, tlegend
3309  htemp = ROOT.TH1F("htemp", "", 1, -pi, pi)
3310  gtemp_12_phi, gtemp_12_val, gtemp_12_err, gtemp_12_val2, gtemp_12_err2 = [], [], [], [], []
3311  gtemp_23_phi, gtemp_23_val, gtemp_23_err, gtemp_23_val2, gtemp_23_err2 = [], [], [], [], []
3312  gtemp_34_phi, gtemp_34_val, gtemp_34_err, gtemp_34_val2, gtemp_34_err2 = [], [], [], [], []
3313  for sector in xrange(1, 12+1):
3314  #print "sect", sector
3315  r1_found, r2_found, r3_found, r4_found = False, False, False, False
3316  for r1 in reports:
3317  if r1.postal_address == ("DT", wheel, 1, sector):
3318  r1_found = True
3319  break
3320  for r2 in reports:
3321  if r2.postal_address == ("DT", wheel, 2, sector):
3322  r2_found = True
3323  break
3324  for r3 in reports:
3325  if r3.postal_address == ("DT", wheel, 3, sector):
3326  r3_found = True
3327  break
3328  for r4 in reports:
3329  if r4.postal_address == ("DT", wheel, 4, sector):
3330  r4_found = True
3331  break
3332  #print "rfounds: ", r1_found, r2_found, r3_found, r4_found
3333 
3334  if sector not in excludesectors:
3335  if r1_found and r2_found and r1.status == "PASS" and r2.status == "PASS":
3336  phi, val, err, val2, err2, fit1, fit2, fit3 = segdiff(tfiles, component, 12, wheel=wheel, sector=sector)
3337  #print "segdif 12", phi, val, err, val2, err2, fit1, fit2, fit3
3338  if fit1 and fit2 and fit3:
3339  gtemp_12_phi.append(phi)
3340  gtemp_12_val.append(val)
3341  gtemp_12_err.append(err)
3342  gtemp_12_val2.append(val2)
3343  gtemp_12_err2.append(err2)
3344  if r2_found and r3_found and r2.status == "PASS" and r3.status == "PASS":
3345  phi, val, err, val2, err2, fit1, fit2, fit3 = segdiff(tfiles, component, 23, wheel=wheel, sector=sector)
3346  #print "segdif 23", phi, val, err, val2, err2, fit1, fit2, fit3
3347  if fit1 and fit2 and fit3:
3348  gtemp_23_phi.append(phi)
3349  gtemp_23_val.append(val)
3350  gtemp_23_err.append(err)
3351  gtemp_23_val2.append(val2)
3352  gtemp_23_err2.append(err2)
3353  if component[:4] == "dt13":
3354  if r3_found and r4_found and r3.status == "PASS" and r4.status == "PASS":
3355  phi, val, err, val2, err2, fit1, fit2, fit3 = segdiff(tfiles, component, 34, wheel=wheel, sector=sector)
3356  #print "segdif 34", phi, val, err, val2, err2, fit1, fit2, fit3
3357  if fit1 and fit2 and fit3:
3358  gtemp_34_phi.append(phi)
3359  gtemp_34_val.append(val)
3360  gtemp_34_err.append(err)
3361  gtemp_34_val2.append(val2)
3362  gtemp_34_err2.append(err2)
3363 
3364  #print "len(gtemp_12_phi) ", len(gtemp_12_phi)
3365  #print "len(gtemp_23_phi) ",len(gtemp_23_phi)
3366  #print "len(gtemp_34_phi) ",len(gtemp_34_phi)
3367  if len(gtemp_12_phi) > 0:
3368  gtemp_12 = ROOT.TGraphErrors(len(gtemp_12_phi), array.array("d", gtemp_12_phi), array.array("d", gtemp_12_val),
3369  array.array("d", [0.] * len(gtemp_12_phi)), array.array("d", gtemp_12_err))
3370  gtemp2_12 = ROOT.TGraphErrors(len(gtemp_12_phi), array.array("d", gtemp_12_phi), array.array("d", gtemp_12_val2),
3371  array.array("d", [0.] * len(gtemp_12_phi)), array.array("d", gtemp_12_err2))
3372  if len(gtemp_23_phi) > 0:
3373  gtemp_23 = ROOT.TGraphErrors(len(gtemp_23_phi), array.array("d", gtemp_23_phi), array.array("d", gtemp_23_val),
3374  array.array("d", [0.] * len(gtemp_23_phi)), array.array("d", gtemp_23_err))
3375  gtemp2_23 = ROOT.TGraphErrors(len(gtemp_23_phi), array.array("d", gtemp_23_phi), array.array("d", gtemp_23_val2),
3376  array.array("d", [0.] * len(gtemp_23_phi)), array.array("d", gtemp_23_err2))
3377  if len(gtemp_34_phi) > 0:
3378  gtemp_34 = ROOT.TGraphErrors(len(gtemp_34_phi), array.array("d", gtemp_34_phi), array.array("d", gtemp_34_val),
3379  array.array("d", [0.] * len(gtemp_34_phi)), array.array("d", gtemp_34_err))
3380  gtemp2_34 = ROOT.TGraphErrors(len(gtemp_34_phi), array.array("d", gtemp_34_phi), array.array("d", gtemp_34_val2),
3381  array.array("d", [0.] * len(gtemp_34_phi)), array.array("d", gtemp_34_err2))
3382 
3383  if len(gtemp_12_phi) > 0:
3384  gtemp_12.SetMarkerStyle(20); gtemp_12.SetMarkerSize(1.);
3385  gtemp_12.SetMarkerColor(ROOT.kBlue); gtemp_12.SetLineColor(ROOT.kBlue)
3386  gtemp2_12.SetMarkerStyle(24); gtemp2_12.SetMarkerSize(1.);
3387  gtemp2_12.SetMarkerColor(ROOT.kBlue); gtemp2_12.SetLineColor(ROOT.kBlue)
3388  if len(gtemp_23_phi) > 0:
3389  gtemp_23.SetMarkerStyle(21); gtemp_23.SetMarkerSize(1.);
3390  gtemp_23.SetMarkerColor(ROOT.kRed); gtemp_23.SetLineColor(ROOT.kRed)
3391  gtemp2_23.SetMarkerStyle(25); gtemp2_23.SetMarkerSize(1.);
3392  gtemp2_23.SetMarkerColor(ROOT.kRed); gtemp2_23.SetLineColor(ROOT.kRed)
3393  if len(gtemp_34_phi) > 0 and component[:4] == "dt13":
3394  gtemp_34.SetMarkerStyle(22); gtemp_34.SetMarkerSize(1.25);
3395  gtemp_34.SetMarkerColor(ROOT.kGreen+2); gtemp_34.SetLineColor(ROOT.kGreen+2)
3396  gtemp2_34.SetMarkerStyle(26); gtemp2_34.SetMarkerSize(1.25);
3397  gtemp2_34.SetMarkerColor(ROOT.kGreen+2); gtemp2_34.SetLineColor(ROOT.kGreen+2)
3398 
3399  if wheel == 0: htemp.SetTitle("Wheel %d" % wheel)
3400  else: htemp.SetTitle("Wheel %+d" % wheel)
3401  htemp.SetAxisRange(-window, window, "Y")
3402  htemp.SetXTitle("Average #phi of pair (rad)")
3403  if component == "dt13_resid": htemp.SetYTitle("#Deltax^{local} (mm)")
3404  if component == "dt13_slope": htemp.SetYTitle("#Deltadx/dz^{local} (mrad)")
3405  if component == "dt2_resid": htemp.SetYTitle("#Deltay^{local} (mm)")
3406  if component == "dt2_slope": htemp.SetYTitle("#Deltady/dz^{local} (mrad)")
3407  htemp.GetXaxis().CenterTitle()
3408  htemp.GetYaxis().CenterTitle()
3409  htemp.GetYaxis().SetTitleOffset(0.75)
3410 
3411  c1.Clear()
3412  htemp.Draw()
3413  if len(gtemp_12_phi) > 0:
3414  gtemp_12.Draw("p")
3415  gtemp2_12.Draw("p")
3416  if len(gtemp_23_phi) > 0:
3417  gtemp_23.Draw("p")
3418  gtemp2_23.Draw("p")
3419  if len(gtemp_34_phi) > 0:
3420  gtemp_34.Draw("p")
3421  gtemp2_34.Draw("p")
3422 
3423  tlegend = ROOT.TLegend(0.5, 0.72, 0.9, 0.92)
3424  tlegend.SetBorderSize(0)
3425  tlegend.SetFillColor(ROOT.kWhite)
3426  if len(gtemp_12_phi) > 0:
3427  tlegend.AddEntry(gtemp_12, "MB1 - MB2 (mean: %4.2f, RMS: %4.2f)" % (mean(gtemp_12_val), stdev(gtemp_12_val)), "pl")
3428  if len(gtemp_23_phi) > 0:
3429  tlegend.AddEntry(gtemp_23, "MB2 - MB3 (mean: %4.2f, RMS: %4.2f)" % (mean(gtemp_23_val), stdev(gtemp_23_val)), "pl")
3430  if len(gtemp_34_phi) > 0:
3431  tlegend.AddEntry(gtemp_34, "MB3 - MB4 (mean: %4.2f, RMS: %4.2f)" % (mean(gtemp_34_val), stdev(gtemp_34_val)), "pl")
3432  if len(gtemp_12_phi) > 0:
3433  tlegend.AddEntry(gtemp_12, "total mean: %4.2f, total RMS: %4.2f" % \
3434  (mean(gtemp_12_val + gtemp_23_val + gtemp_34_val),
3435  stdev(gtemp_12_val + gtemp_23_val + gtemp_34_val)), "")
3436  tlegend.Draw()
3437 
def plotscripts.segdiffvsphi_xalign (   tfiles,
  wheel,
  window = 10. 
)

Definition at line 3187 of file plotscripts.py.

References mean(), segdiff_xalign(), and stdev().

Referenced by alignmentValidation.doSegDiffPlotsDT().

3188 def segdiffvsphi_xalign(tfiles, wheel, window=10.):
3189  tdrStyle.SetOptTitle(1)
3190  tdrStyle.SetTitleBorderSize(1)
3191  tdrStyle.SetTitleFontSize(0.05)
3192 
3193  global htemp, gtemp_12, gtemp_21, gtemp_11, tlegend
3194  htemp = ROOT.TH1F("htemp", "", 1, -pi, pi)
3195  gtemp_11_phi, gtemp_11_val, gtemp_11_err = [], [], []
3196  gtemp_12_phi, gtemp_12_val, gtemp_12_err = [], [], []
3197  gtemp_21_phi, gtemp_21_val, gtemp_21_err = [], [], []
3198  for sector in xrange(1, 12+1):
3199  #print "sect", sector
3200  r1 = segdiff_xalign(tfiles, "x_dt1_csc", wheel=wheel, sector=sector, cscstations = "12")
3201  r2 = segdiff_xalign(tfiles, "x_dt2_csc", wheel=wheel, sector=sector, cscstations = "1")
3202 
3203  if r1["fit_ok"]:
3204  gtemp_11_phi.append(r1["phi"])
3205  gtemp_11_val.append(r1["fit_peak"])
3206  gtemp_11_err.append(r1["fit_peak_error"])
3207  if r1["fit_ok_2"]:
3208  gtemp_12_phi.append(r1["phi"])
3209  gtemp_12_val.append(r1["fit_peak_2"])
3210  gtemp_12_err.append(r1["fit_peak_error_2"])
3211  if r2["fit_ok"]:
3212  gtemp_21_phi.append(r2["phi"])
3213  gtemp_21_val.append(r2["fit_peak"])
3214  gtemp_21_err.append(r2["fit_peak_error"])
3215 
3216  #print "len(gtemp_11_phi) ",len(gtemp_11_phi)
3217  #print "len(gtemp_12_phi) ",len(gtemp_12_phi)
3218  #print "len(gtemp_21_phi) ",len(gtemp_21_phi)
3219  if len(gtemp_11_phi) > 0:
3220  gtemp_11 = ROOT.TGraphErrors(len(gtemp_11_phi), array.array("d", gtemp_11_phi), array.array("d", gtemp_11_val),
3221  array.array("d", [0.] * len(gtemp_11_phi)), array.array("d", gtemp_11_err))
3222  if len(gtemp_12_phi) > 0:
3223  gtemp_12 = ROOT.TGraphErrors(len(gtemp_12_phi), array.array("d", gtemp_12_phi), array.array("d", gtemp_12_val),
3224  array.array("d", [0.] * len(gtemp_12_phi)), array.array("d", gtemp_12_err))
3225  if len(gtemp_11_phi) > 0:
3226  gtemp_21 = ROOT.TGraphErrors(len(gtemp_21_phi), array.array("d", gtemp_21_phi), array.array("d", gtemp_21_val),
3227  array.array("d", [0.] * len(gtemp_21_phi)), array.array("d", gtemp_21_err))
3228 
3229  if len(gtemp_11_phi) > 0:
3230  gtemp_11.SetMarkerStyle(20); gtemp_11.SetMarkerSize(1.5);
3231  gtemp_11.SetMarkerColor(ROOT.kRed); gtemp_11.SetLineColor(ROOT.kRed)
3232  if len(gtemp_12_phi) > 0:
3233  gtemp_12.SetMarkerStyle(22); gtemp_12.SetMarkerSize(1.);
3234  gtemp_12.SetMarkerColor(ROOT.kGreen+2); gtemp_12.SetLineColor(ROOT.kGreen+2)
3235  if len(gtemp_21_phi) > 0:
3236  gtemp_21.SetMarkerStyle(21); gtemp_21.SetMarkerSize(1.5);
3237  gtemp_21.SetMarkerColor(ROOT.kBlue); gtemp_21.SetLineColor(ROOT.kBlue)
3238 
3239  htemp.SetTitle("Wheel %+d" % wheel)
3240  htemp.SetAxisRange(-window, window, "Y")
3241  htemp.SetXTitle("#phi of MB")
3242  htemp.SetYTitle("#Deltax^{loc}_{DT} - r_{DT}/r_{CSC}#times#Deltax^{loc}_{CSC} (mm)")
3243  htemp.GetXaxis().CenterTitle()
3244  htemp.GetYaxis().CenterTitle()
3245  htemp.GetYaxis().SetTitleOffset(0.75)
3246 
3247  c1.Clear()
3248  htemp.Draw()
3249  if len(gtemp_12_phi) > 0:
3250  gtemp_12.Draw("p")
3251  if len(gtemp_21_phi) > 0:
3252  gtemp_21.Draw("p")
3253  if len(gtemp_11_phi) > 0:
3254  gtemp_11.Draw("p")
3255 
3256  tlegend = ROOT.TLegend(0.59, 0.75, 0.99, 0.92)
3257  tlegend.SetBorderSize(0)
3258  tlegend.SetFillColor(ROOT.kWhite)
3259  if len(gtemp_11_phi) > 0:
3260  tlegend.AddEntry(gtemp_11, "MB1 - ME1/3 (mean: %4.2f, RMS: %4.2f)" % (mean(gtemp_11_val), stdev(gtemp_11_val)), "pl")
3261  if len(gtemp_21_phi) > 0:
3262  tlegend.AddEntry(gtemp_21, "MB2 - ME1/3 (mean: %4.2f, RMS: %4.2f)" % (mean(gtemp_21_val), stdev(gtemp_21_val)), "pl")
3263  if len(gtemp_12_phi) > 0:
3264  tlegend.AddEntry(gtemp_12, "MB1 - ME2/2 (mean: %4.2f, RMS: %4.2f)" % (mean(gtemp_12_val), stdev(gtemp_12_val)), "pl")
3265  #if len(gtemp_12_phi) > 0:
3266  # tlegend.AddEntry(gtemp_12, "total mean: %4.2f, total RMS: %4.2f" % \
3267  # (mean(gtemp_11_val + gtemp_12_val + gtemp_21_val),
3268  # stdev(gtemp_11_val + gtemp_12_val + gtemp_21_val)), "")
3269  tlegend.Draw()
3270 
3271  f_11 = ROOT.TF1("f11", "[0] + [1]*sin(x) + [2]*cos(x)", -pi, pi)
3272  f_11.SetLineColor(ROOT.kRed)
3273  f_11.SetLineWidth(2)
3274  f_21 = ROOT.TF1("f21", "[0] + [1]*sin(x) + [2]*cos(x)", -pi, pi)
3275  f_21.SetLineColor(ROOT.kBlue)
3276  f_21.SetLineWidth(2)
3277  if len(gtemp_11_phi) > 0:
3278  gtemp_11.Fit(f_11,"")
3279  if len(gtemp_21_phi) > 0:
3280  gtemp_21.Fit(f_21,"")
3281 
3282  global f_txt,f_11_txt, f_21_txt
3283  f_txt = ROOT.TLatex(-2.9, -0.7*window, "ME1/3 ring corrections equivalents:")
3284  f_txt.SetTextSize(0.028)
3285  f_txt.Draw()
3286  if len(gtemp_11_phi) > 0:
3287  rdt = signConventions[("DT", 2, 1, 1)][3]*10
3288  f_11_txt = ROOT.TLatex(-2.9, -0.8*window, "#Deltax=%.2f#pm%.2f mm #Deltay=%.2f#pm%.2f mm #Delta#phi_{z}=%.2f#pm%.2f mrad" % (
3289  -f_11.GetParameter(1), f_11.GetParError(1), f_11.GetParameter(2), f_11.GetParError(2), -f_11.GetParameter(0)/rdt*1000, f_11.GetParError(0)/rdt*1000))
3290  f_11_txt.SetTextSize(0.028)
3291  f_11_txt.SetTextColor(ROOT.kRed)
3292  f_11_txt.Draw()
3293  if len(gtemp_11_phi) > 0:
3294  rdt = signConventions[("DT", 2, 2, 1)][3]*10
3295  f_21_txt = ROOT.TLatex(-2.9, -0.9*window, "#Deltax=%.2f#pm%.2f mm #Deltay=%.2f#pm%.2f mm #Delta#phi_{z}=%.2f#pm%.2f mrad" % (
3296  -f_21.GetParameter(1), f_21.GetParError(1), f_21.GetParameter(2), f_21.GetParError(2), -f_21.GetParameter(0)/rdt*1000, f_21.GetParError(0)/rdt*1000))
3297  f_21_txt.SetTextSize(0.028)
3298  f_21_txt.SetTextColor(ROOT.kBlue)
3299  f_21_txt.Draw()
def segdiffvsphi_xalign
def segdiff_xalign
def plotscripts.segdiffvsphicsc (   tfiles,
  component,
  pair,
  window = 5.,
  args 
)

Definition at line 3440 of file plotscripts.py.

References corrections2D(), mean(), segdiff(), and stdev().

Referenced by alignmentValidation.doSegDiffPlotsCSC().

3441 def segdiffvsphicsc(tfiles, component, pair, window=5., **args):
3442  tdrStyle.SetOptTitle(1)
3443  tdrStyle.SetTitleBorderSize(1)
3444  tdrStyle.SetTitleFontSize(0.05)
3445 
3446  if not component[0:3] == "csc": Exception
3447 
3448  endcap = args["endcap"]
3449  if endcap=="m":
3450  endcapnum=2
3451  endcapsign="-"
3452  elif endcap=="p":
3453  endcapnum=1
3454  endcapsign="+"
3455  else: raise Exception
3456 
3457  station1 = int(str(pair)[0])
3458  station2 = int(str(pair)[1])
3459  if not station2-station1==1: raise Exception
3460 
3461  rings = [1,2]
3462  if station2==4: rings = [1]
3463 
3464 
3465  global htemp, gtemp_1, gtemp2_1, gtemp_2, gtemp2_2, tlegend
3466  htemp = ROOT.TH1F("htemp", "", 1, -pi*5./180., pi*(2.-5./180.))
3467  gtemp_1_phi, gtemp_1_val, gtemp_1_err, gtemp_1_val2, gtemp_1_err2 = [], [], [], [], []
3468  gtemp_2_phi, gtemp_2_val, gtemp_2_err, gtemp_2_val2, gtemp_2_err2 = [], [], [], [], []
3469 
3470  for ring in rings:
3471  chambers = xrange(1,37)
3472  if ring == 1: chambers = xrange(1,19)
3473 
3474  for chamber in chambers:
3475  phi, val, err, val2, err2, fit1, fit2, fit3 = segdiff(tfiles, component, pair, endcap=endcap, ring=ring, chamber=chamber)
3476  if fit1 and fit2 and fit3:
3477  if ring==1:
3478  gtemp_1_phi.append(phi)
3479  gtemp_1_val.append(val)
3480  gtemp_1_err.append(err)
3481  gtemp_1_val2.append(val2)
3482  gtemp_1_err2.append(err2)
3483  if ring==2:
3484  gtemp_2_phi.append(phi)
3485  gtemp_2_val.append(val)
3486  gtemp_2_err.append(err)
3487  gtemp_2_val2.append(val2)
3488  gtemp_2_err2.append(err2)
3489 
3490  #print "len(gtemp_12_phi) ", len(gtemp_12_phi)
3491  #print "len(gtemp_23_phi) ",len(gtemp_23_phi)
3492  #print "len(gtemp_34_phi) ",len(gtemp_34_phi)
3493  if len(gtemp_1_phi) > 0:
3494  gtemp_1 = ROOT.TGraphErrors(len(gtemp_1_phi), array.array("d", gtemp_1_phi), array.array("d", gtemp_1_val),
3495  array.array("d", [0.] * len(gtemp_1_phi)), array.array("d", gtemp_1_err))
3496  gtemp2_1 = ROOT.TGraphErrors(len(gtemp_1_phi), array.array("d", gtemp_1_phi), array.array("d", gtemp_1_val2),
3497  array.array("d", [0.] * len(gtemp_1_phi)), array.array("d", gtemp_1_err2))
3498  if len(gtemp_2_phi) > 0:
3499  gtemp_2 = ROOT.TGraphErrors(len(gtemp_2_phi), array.array("d", gtemp_2_phi), array.array("d", gtemp_2_val),
3500  array.array("d", [0.] * len(gtemp_2_phi)), array.array("d", gtemp_2_err))
3501  gtemp2_2 = ROOT.TGraphErrors(len(gtemp_2_phi), array.array("d", gtemp_2_phi), array.array("d", gtemp_2_val2),
3502  array.array("d", [0.] * len(gtemp_2_phi)), array.array("d", gtemp_2_err2))
3503 
3504  if len(gtemp_1_phi) > 0:
3505  gtemp_1.SetMarkerStyle(20); gtemp_1.SetMarkerSize(1.);
3506  gtemp_1.SetMarkerColor(ROOT.kBlue); gtemp_1.SetLineColor(ROOT.kBlue)
3507  gtemp2_1.SetMarkerStyle(24); gtemp2_1.SetMarkerSize(1.);
3508  gtemp2_1.SetMarkerColor(ROOT.kBlue); gtemp2_1.SetLineColor(ROOT.kBlue)
3509  if len(gtemp_2_phi) > 0:
3510  gtemp_2.SetMarkerStyle(21); gtemp_2.SetMarkerSize(1.);
3511  gtemp_2.SetMarkerColor(ROOT.kRed); gtemp_2.SetLineColor(ROOT.kRed)
3512  gtemp2_2.SetMarkerStyle(25); gtemp2_2.SetMarkerSize(1.);
3513  gtemp2_2.SetMarkerColor(ROOT.kRed); gtemp2_2.SetLineColor(ROOT.kRed)
3514 
3515  htemp.SetTitle("ME%s%d - ME%s%d" % (endcapsign,station2,endcapsign,station1))
3516  htemp.SetAxisRange(-window, window, "Y")
3517  htemp.SetXTitle("Average #phi of pair (rad)")
3518  if component == "csc_resid": htemp.SetYTitle("#Delta(r#phi)^{local} (mm)")
3519  if component == "csc_slope": htemp.SetYTitle("#Deltad(r#phi)/dz^{local} (mrad)")
3520  htemp.GetXaxis().CenterTitle()
3521  htemp.GetYaxis().CenterTitle()
3522  htemp.GetYaxis().SetTitleOffset(0.75)
3523 
3524  c1.Clear()
3525  htemp.Draw()
3526  if len(gtemp_1_phi) > 0:
3527  gtemp_1.Draw("p")
3528  gtemp2_1.Draw("p")
3529  if len(gtemp_2_phi) > 0:
3530  gtemp_2.Draw("p")
3531  gtemp2_2.Draw("p")
3532 
3533  tlegend = ROOT.TLegend(0.5, 0.72, 0.9, 0.92)
3534  tlegend.SetBorderSize(0)
3535  tlegend.SetFillColor(ROOT.kWhite)
3536  if len(gtemp_1_phi) > 0:
3537  tlegend.AddEntry(gtemp_1, "ring 1 (mean: %4.2f, RMS: %4.2f)" % (mean(gtemp_1_val), stdev(gtemp_1_val)), "pl")
3538  if len(gtemp_2_phi) > 0:
3539  tlegend.AddEntry(gtemp_2, "ring 2 (mean: %4.2f, RMS: %4.2f)" % (mean(gtemp_2_val), stdev(gtemp_2_val)), "pl")
3540  #if len(gtemp_12_phi) > 0:
3541  # tlegend.AddEntry(gtemp_12, "total mean: %4.2f, total RMS: %4.2f" % \
3542  # (mean(gtemp_12_val + gtemp_23_val + gtemp_34_val),
3543  # stdev(gtemp_12_val + gtemp_23_val + gtemp_34_val)), "")
3544  tlegend.Draw()
3545 
3546 
def segdiffvsphicsc
def plotscripts.set_palette (   name = None,
  ncontours = 999 
)
Set a color palette from a given RGB list
stops, red, green and blue should all be lists of the same length
see set_decent_colors for an example

Definition at line 226 of file plotscripts.py.

References python.multivaluedict.map().

Referenced by curvatureDTsummary(), curvatureplot(), and mapplot().

227 def set_palette(name=None, ncontours=999):
228  """Set a color palette from a given RGB list
229  stops, red, green and blue should all be lists of the same length
230  see set_decent_colors for an example"""
231 
232  if name == "halfgray":
233  stops = [0.00, 0.34, 0.61, 0.84, 1.00]
234  red = map(lambda x: 1. - (1.-x)/2., [1.00, 0.84, 0.61, 0.34, 0.00])
235  green = map(lambda x: 1. - (1.-x)/2., [1.00, 0.84, 0.61, 0.34, 0.00])
236  blue = map(lambda x: 1. - (1.-x)/2., [1.00, 0.84, 0.61, 0.34, 0.00])
237  elif name == "gray":
238  stops = [0.00, 0.34, 0.61, 0.84, 1.00]
239  red = [1.00, 0.84, 0.61, 0.34, 0.00]
240  green = [1.00, 0.84, 0.61, 0.34, 0.00]
241  blue = [1.00, 0.84, 0.61, 0.34, 0.00]
242  elif name == "blues":
243  stops = [0.00, 0.34, 0.61, 0.84, 1.00]
244  red = [1.00, 0.84, 0.61, 0.34, 0.00]
245  green = [1.00, 0.84, 0.61, 0.34, 0.00]
246  blue = [1.00, 1.00, 1.00, 1.00, 1.00]
247  elif name == "reds":
248  stops = [0.00, 0.34, 0.61, 0.84, 1.00]
249  red = [1.00, 1.00, 1.00, 1.00, 1.00]
250  green = [1.00, 0.84, 0.61, 0.34, 0.00]
251  blue = [1.00, 0.84, 0.61, 0.34, 0.00]
252  elif name == "antigray":
253  stops = [0.00, 0.34, 0.61, 0.84, 1.00]
254  red = [1.00, 0.84, 0.61, 0.34, 0.00]
255  green = [1.00, 0.84, 0.61, 0.34, 0.00]
256  blue = [1.00, 0.84, 0.61, 0.34, 0.00]
257  red.reverse()
258  green.reverse()
259  blue.reverse()
260  elif name == "fire":
261  stops = [0.00, 0.20, 0.80, 1.00]
262  red = [1.00, 1.00, 1.00, 0.50]
263  green = [1.00, 1.00, 0.00, 0.00]
264  blue = [0.20, 0.00, 0.00, 0.00]
265  elif name == "antifire":
266  stops = [0.00, 0.20, 0.80, 1.00]
267  red = [0.50, 1.00, 1.00, 1.00]
268  green = [0.00, 0.00, 1.00, 1.00]
269  blue = [0.00, 0.00, 0.00, 0.20]
270  else:
271  # default palette, looks cool
272  stops = [0.00, 0.34, 0.61, 0.84, 1.00]
273  red = [0.00, 0.00, 0.87, 1.00, 0.51]
274  green = [0.00, 0.81, 1.00, 0.20, 0.00]
275  blue = [0.51, 1.00, 0.12, 0.00, 0.00]
276 
277  s = array.array('d', stops)
278  r = array.array('d', red)
279  g = array.array('d', green)
280  b = array.array('d', blue)
281 
282  npoints = len(s)
283  ROOT.TColor.CreateGradientColorTable(npoints, s, r, g, b, ncontours)
284  ROOT.gStyle.SetNumberContours(ncontours)
285 
286 set_palette()
def plotscripts.setTDRStyle ( )

Definition at line 87 of file plotscripts.py.

87 
88 def setTDRStyle():
89  global tdrStyle
90  tdrStyle = ROOT.TStyle("tdrStyle","Style for P-TDR")
91 # For the canvas:
92  tdrStyle.SetCanvasBorderMode(0)
93  tdrStyle.SetCanvasColor(ROOT.kWhite)
94  tdrStyle.SetCanvasDefH(600) #Height of canvas
95  tdrStyle.SetCanvasDefW(600) #Width of canvas
96  tdrStyle.SetCanvasDefX(0) #POsition on screen
97  tdrStyle.SetCanvasDefY(0)
98 
99 # For the Pad:
100  tdrStyle.SetPadBorderMode(0)
101  # tdrStyle.SetPadBorderSize(Width_t size = 1)
102  tdrStyle.SetPadColor(ROOT.kWhite)
103  tdrStyle.SetPadGridX(False)
104  tdrStyle.SetPadGridY(False)
105  tdrStyle.SetGridColor(0)
106  tdrStyle.SetGridStyle(3)
107  tdrStyle.SetGridWidth(1)
108 
109 # For the frame:
110  tdrStyle.SetFrameBorderMode(0)
111  tdrStyle.SetFrameBorderSize(1)
112  tdrStyle.SetFrameFillColor(0)
113  tdrStyle.SetFrameFillStyle(0)
114  tdrStyle.SetFrameLineColor(1)
115  tdrStyle.SetFrameLineStyle(1)
116  tdrStyle.SetFrameLineWidth(1)
117 
118 # For the histo:
119  # tdrStyle.SetHistFillColor(1)
120  # tdrStyle.SetHistFillStyle(0)
121  tdrStyle.SetHistLineColor(1)
122  tdrStyle.SetHistLineStyle(0)
123  tdrStyle.SetHistLineWidth(1)
124  # tdrStyle.SetLegoInnerR(Float_t rad = 0.5)
125  # tdrStyle.SetNumberContours(Int_t number = 20)
126 
127  tdrStyle.SetEndErrorSize(2)
128 # tdrStyle.SetErrorMarker(20)
129  tdrStyle.SetErrorX(0.)
130 
131  tdrStyle.SetMarkerStyle(20)
132 
133 #For the fit/function:
134  tdrStyle.SetOptFit(1)
135  tdrStyle.SetFitFormat("5.4g")
136  tdrStyle.SetFuncColor(2)
137  tdrStyle.SetFuncStyle(1)
138  tdrStyle.SetFuncWidth(1)
139 
140 #For the date:
141  tdrStyle.SetOptDate(0)
142  # tdrStyle.SetDateX(Float_t x = 0.01)
143  # tdrStyle.SetDateY(Float_t y = 0.01)
144 
145 # For the statistics box:
146  tdrStyle.SetOptFile(0)
147  tdrStyle.SetOptStat(0) # To display the mean and RMS: SetOptStat("mr")
148  tdrStyle.SetStatColor(ROOT.kWhite)
149  tdrStyle.SetStatFont(42)
150  tdrStyle.SetStatFontSize(0.025)
151  tdrStyle.SetStatTextColor(1)
152  tdrStyle.SetStatFormat("6.4g")
153  tdrStyle.SetStatBorderSize(1)
154  tdrStyle.SetStatH(0.1)
155  tdrStyle.SetStatW(0.15)
156  # tdrStyle.SetStatStyle(Style_t style = 1001)
157  # tdrStyle.SetStatX(Float_t x = 0)
158  # tdrStyle.SetStatY(Float_t y = 0)
159 
160 # Margins:
161  tdrStyle.SetPadTopMargin(0.05)
162  tdrStyle.SetPadBottomMargin(0.13)
163  tdrStyle.SetPadLeftMargin(0.13)
164  tdrStyle.SetPadRightMargin(0.05)
165 
166 # For the Global title:
167  tdrStyle.SetOptTitle(0)
168  tdrStyle.SetTitleFont(42)
169  tdrStyle.SetTitleColor(1)
170  tdrStyle.SetTitleTextColor(1)
171  tdrStyle.SetTitleFillColor(10)
172  tdrStyle.SetTitleFontSize(0.05)
173  # tdrStyle.SetTitleH(0) # Set the height of the title box
174  # tdrStyle.SetTitleW(0) # Set the width of the title box
175  # tdrStyle.SetTitleX(0) # Set the position of the title box
176  # tdrStyle.SetTitleY(0.985) # Set the position of the title box
177  # tdrStyle.SetTitleStyle(Style_t style = 1001)
178  # tdrStyle.SetTitleBorderSize(2)
179 
180 # For the axis titles:
181  tdrStyle.SetTitleColor(1, "XYZ")
182  tdrStyle.SetTitleFont(42, "XYZ")
183  tdrStyle.SetTitleSize(0.06, "XYZ")
184  # tdrStyle.SetTitleXSize(Float_t size = 0.02) # Another way to set the size?
185  # tdrStyle.SetTitleYSize(Float_t size = 0.02)
186  tdrStyle.SetTitleXOffset(0.9)
187  tdrStyle.SetTitleYOffset(1.05)
188  # tdrStyle.SetTitleOffset(1.1, "Y") # Another way to set the Offset
189 
190 # For the axis labels:
191  tdrStyle.SetLabelColor(1, "XYZ")
192  tdrStyle.SetLabelFont(42, "XYZ")
193  tdrStyle.SetLabelOffset(0.007, "XYZ")
194  tdrStyle.SetLabelSize(0.05, "XYZ")
195 
196 # For the axis:
197  tdrStyle.SetAxisColor(1, "XYZ")
198  tdrStyle.SetStripDecimals(True)
199  tdrStyle.SetTickLength(0.03, "XYZ")
200  tdrStyle.SetNdivisions(510, "XYZ")
201  tdrStyle.SetPadTickX(1) # To get tick marks on the opposite side of the frame
202  tdrStyle.SetPadTickY(1)
203 
204 # Change for log plots:
205  tdrStyle.SetOptLogx(0)
206  tdrStyle.SetOptLogy(0)
207  tdrStyle.SetOptLogz(0)
208 
209 # Postscript options:
210  tdrStyle.SetPaperSize(20.,20.)
211  # tdrStyle.SetLineScalePS(Float_t scale = 3)
212  # tdrStyle.SetLineStyleString(Int_t i, const char* text)
213  # tdrStyle.SetHeaderPS(const char* header)
214  # tdrStyle.SetTitlePS(const char* pstitle)
215 
216  # tdrStyle.SetBarOffset(Float_t baroff = 0.5)
217  # tdrStyle.SetBarWidth(Float_t barwidth = 0.5)
218  # tdrStyle.SetPaintTextFormat(const char* format = "g")
219  # tdrStyle.SetPalette(Int_t ncolors = 0, Int_t* colors = 0)
220  # tdrStyle.SetTimeOffset(Double_t toffset)
221  # tdrStyle.SetHistMinimumZero(True)
222 
223  tdrStyle.cd()
224 
225 setTDRStyle()
void setTDRStyle()
Definition: plotscripts.py:87
def plotscripts.stationIndex (   name)

Definition at line 353 of file plotscripts.py.

References idToPostalAddress().

Referenced by MuonIdProducer.fillArbitrationInfo(), mapplot(), and philines().

354 def stationIndex(name):
355  if ("MB" in name or "ME" in name):
356  # assume the name is ID
357  pa = idToPostalAddress(name)
358  if pa is None: return None
359  if pa[0]=="CSC":
360  if pa[2]==1 and pa[3]==1: return 0
361  if pa[2]==1 and pa[3]==2: return 1
362  if pa[2]==1 and pa[3]==3: return 2
363  if pa[2]==1 and pa[3]==4: return 3
364  if pa[2]==2 and pa[3]==1: return 4
365  if pa[2]==2 and pa[3]==2: return 5
366  if pa[2]==3 and pa[3]==1: return 6
367  if pa[2]==3 and pa[3]==2: return 7
368  if pa[2]==4 and pa[3]==1: return 8
369  if pa[2]==4 and pa[3]==2: return 9
370  if pa[0]=="DT":
371  if pa[2]==1: return 10
372  if pa[2]==2: return 11
373  if pa[2]==3: return 12
374  if pa[2]==4: return 13
375  else:
376  if ("mem11" in name or "mep11" in name): return 0
377  if ("mem12" in name or "mep12" in name): return 1
378  if ("mem13" in name or "mep13" in name): return 2
379  if ("mem14" in name or "mep14" in name): return 3
380  if ("mem21" in name or "mep21" in name): return 4
381  if ("mem22" in name or "mep22" in name): return 5
382  if ("mem31" in name or "mep31" in name): return 6
383  if ("mem32" in name or "mep32" in name): return 7
384  if ("mem41" in name or "mep41" in name): return 8
385  if ("mem42" in name or "mep42" in name): return 9
386  if ("st1" in name): return 10
387  if ("st2" in name): return 11
388  if ("st3" in name): return 12
389  if ("st4" in name): return 13
390 
391 
def idToPostalAddress
Definition: plotscripts.py:861
def stationIndex
Definition: plotscripts.py:353
def plotscripts.stdev (   xlist)

Definition at line 67 of file plotscripts.py.

References mathSSE.sqrt().

Referenced by MuonResidualsAngleFitter.fit(), MuonResidualsBfieldAngleFitter.fit(), MuonResidualsPositionFitter.fit(), segdiffvsphi(), segdiffvsphi_xalign(), and segdiffvsphicsc().

67 
68 def stdev(xlist):
69  s, s2, n = 0., 0., 0.
70  for x in xlist:
71  s += x
72  s2 += x**2
73  n += 1.
74  return sqrt(s2/n - (s/n)**2)
T sqrt(T t)
Definition: SSEVec.h:48
def plotscripts.testDeltaWithin5Sigma (   x,
  sx 
)

Definition at line 1052 of file plotscripts.py.

References funct.abs(), and mathSSE.sqrt().

Referenced by doTestsForMapPlots().

1053 def testDeltaWithin5Sigma(x,sx):
1054  n = len(x)
1055  res = []
1056  dr = []
1057  #print x
1058  #print sx
1059  for i in range(1,n+1):
1060  x1 = x[i-1]
1061  sx1 = sx[i-1]
1062  x2 = x[0]
1063  sx2 = sx[0]
1064  if i<n:
1065  x2 = x[i]
1066  sx2 = sx[i]
1067  sig1 = sqrt( (sx1[0]-sx1[1])**2 + x1[1]**2 )
1068  sig2 = sqrt( (sx2[0]-sx2[1])**2 + x2[1]**2 )
1069  df = abs(x1[0]-x2[0]) - 3*( sig1 + sig2 )
1070  #df = abs(sx1[1]-sx2[0]) - 5*(abs(x1[1]) + abs(x2[1]))
1071  #print i, df, '= abs(',sx1[1],'-',sx2[0],')-5*(abs(',x1[1],')+abs(',x2[1],'))'
1072  dr.append(df)
1073  if df > 0: res.append(i)
1074  #print dr
1075  #print res
1076  return res
1077 
T sqrt(T t)
Definition: SSEVec.h:48
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def testDeltaWithin5Sigma
def plotscripts.testEntry (   testID,
  scope,
  descr,
  severity 
)

Definition at line 1038 of file plotscripts.py.

Referenced by doTestsForMapPlots(), and doTestsForReport().

1039 def testEntry(testID,scope,descr,severity):
1040  s = 0
1041  for sev in DQM_SEVERITY:
1042  if sev["name"]==severity: s = sev["idx"]
1043  return {"testID":testID,"scope":scope,"descr":descr,"severity":s}
1044 
def plotscripts.testZeroWithin5Sigma (   x)

Definition at line 1045 of file plotscripts.py.

References funct.abs().

Referenced by doTestsForMapPlots().

1046 def testZeroWithin5Sigma(x):
1047  if abs(x[1])==0.: return 0.
1048  pull = abs(x[0])/abs(x[1])
1049  if pull <= 5: return 0.
1050  else: return pull
1051 
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def testZeroWithin5Sigma
def plotscripts.wheel0only (   dt,
  wheel,
  station,
  sector 
)

Definition at line 33 of file plotscripts.py.

33 
def wheel0only(dt, wheel, station, sector): return dt == "DT" and wheel == 0
def wheel0only
Definition: plotscripts.py:33
def plotscripts.wheelLetter (   wheel)

Definition at line 37 of file plotscripts.py.

Referenced by availableCellsDT(), alignmentValidation.doFitFunctionsPlotsDT(), alignmentValidation.doMapPlotsDT(), and segdiff().

37 
38 def wheelLetter(wheel):
39  if wheel == -2: return "A"
40  elif wheel == -1: return "B"
41  elif wheel == 0: return "C"
42  elif wheel == +1: return "D"
43  elif wheel == +2: return "E"
44  else: raise Exception
def wheelLetter
Definition: plotscripts.py:37
def plotscripts.wheelm1only (   dt,
  wheel,
  station,
  sector 
)

Definition at line 32 of file plotscripts.py.

32 
def wheelm1only(dt, wheel, station, sector): return dt == "DT" and wheel == -1
def wheelm1only
Definition: plotscripts.py:32
def plotscripts.wheelm2only (   dt,
  wheel,
  station,
  sector 
)

Convenience functions.

Definition at line 31 of file plotscripts.py.

31 
def wheelm2only(dt, wheel, station, sector): return dt == "DT" and wheel == -2
def wheelm2only
Convenience functions.
Definition: plotscripts.py:31
def plotscripts.wheelNumber (   wheell)

Definition at line 45 of file plotscripts.py.

Referenced by DTDataIntegrityTest.dqmEndLuminosityBlock().

45 
46 def wheelNumber(wheell):
47  if wheell == "A": return -2
48  elif wheell == "B": return -1
49  elif wheell == "C": return 0
50  elif wheell == "D": return 1
51  elif wheell == "E": return 2
52  else: raise Exception
def wheelNumber
Definition: plotscripts.py:45
def plotscripts.wheelp1only (   dt,
  wheel,
  station,
  sector 
)

Definition at line 34 of file plotscripts.py.

34 
def wheelp1only(dt, wheel, station, sector): return dt == "DT" and wheel == 1
def wheelp1only
Definition: plotscripts.py:34
def plotscripts.wheelp2only (   dt,
  wheel,
  station,
  sector 
)

Definition at line 35 of file plotscripts.py.

35 
36 def wheelp2only(dt, wheel, station, sector): return dt == "DT" and wheel == 2
def wheelp2only
Definition: plotscripts.py:35
def plotscripts.wmean (   xlist)

Definition at line 75 of file plotscripts.py.

References mathSSE.sqrt().

75 
76 def wmean(xlist):
77  s, w = 0., 0.
78  for x, e in xlist:
79  if e > 0.:
80  wi = 1./e**2
81  s += x*wi
82  w += wi
83  return s/w, sqrt(1./w)
T sqrt(T t)
Definition: SSEVec.h:48
def plotscripts.writeDQMReport (   fname_dqm,
  run_name 
)

Definition at line 1201 of file plotscripts.py.

Referenced by doTests().

1202 def writeDQMReport(fname_dqm, run_name):
1203  tests = []
1204  for c in TEST_RESULTS:
1205  tests.append({"objID":c, "name":c, "list":TEST_RESULTS[c]})
1206  lt = time.localtime(time.time())
1207  lts = "%04d-%02d-%02d %02d:%02d:%02d %s" % (lt[0], lt[1], lt[2], lt[3], lt[4], lt[5], time.tzname[1])
1208  dqm_report = {"run":run_name, "genDate": lts, "report":tests}
1209  ff = open(fname_dqm,mode="w")
1210  print >>ff, "var DQM_REPORT = "
1211  json.dump(dqm_report,ff)
1212  #print >>ff, "];"
1213  ff.close()
1214 
def writeDQMReport
def plotscripts.zlines (   window,
  abscissa 
)

Definition at line 438 of file plotscripts.py.

Referenced by mapplot().

439 def zlines(window, abscissa):
440  global zline_tlines
441  zline_tlines = []
442  for z in -401.625, -133.875, 133.875, 401.625:
443  if abscissa is None or abscissa[0] < z < abscissa[1]:
444  zline_tlines.append(ROOT.TLine(z, -window, z, window))
445  zline_tlines[-1].SetLineStyle(2)
446  zline_tlines[-1].Draw()
447  zline_labels = []
448  zline_labels.append(ROOT.TText(-550, -0.9*window, "-2"))
449  zline_labels.append(ROOT.TText(-300, -0.9*window, "-1"))
450  zline_labels.append(ROOT.TText(-10, -0.9*window, "0"))
451  zline_labels.append(ROOT.TText(250, -0.9*window, "+1"))
452  zline_labels.append(ROOT.TText(500, -0.9*window, "+2"))
453  for z in zline_labels: z.Draw()
454  zline_labels.append(ROOT.TText(-600, -0.75*window, "Wheel:")); zline_labels[-1].Draw()

Variable Documentation

plotscripts.CPP_LOADED = False

Definition at line 18 of file plotscripts.py.

list plotscripts.DQM_SEVERITY
Initial value:
1 = [
2  {"idx":0, "name": "NONE", "color": "lightgreen", "hex":"#90EE90"},
3  {"idx":1, "name": "LOWSTAT05", "color": "lightgreen", "hex":"#96D953"},
4  {"idx":2, "name": "LOWSTAT075", "color": "lightgreen", "hex":"#94E26F"},
5  {"idx":3, "name": "LOWSTAT1", "color": "yellowgreen", "hex":"#9ACD32"},
6  {"idx":4, "name": "LOWSTAT", "color": "yellow", "hex":"#FFFF00"},
7  {"idx":5, "name": "TOLERABLE", "color": "lightpink", "hex":"#FFB6C1"},
8  {"idx":6, "name": "SEVERE", "color": "orange", "hex":"#FFA500"},
9  {"idx":7, "name": "CRITICAL", "color": "red", "hex":"#FF0000"}]

Definition at line 1021 of file plotscripts.py.

dictionary plotscripts.MAP_RESULTS_BINS = {}

Definition at line 23 of file plotscripts.py.

dictionary plotscripts.MAP_RESULTS_FITSIN = {}

Definition at line 22 of file plotscripts.py.

dictionary plotscripts.MAP_RESULTS_SAWTOOTH = {}

Definition at line 21 of file plotscripts.py.

list plotscripts.phiedges
Initial value:
1 = [
2  phiedgesCSC36,
3  phiedgesCSC36,
4  phiedgesCSC36,
5  phiedgesCSC36,
6  phiedgesCSC18,
7  phiedgesCSC36,
8  phiedgesCSC18,
9  phiedgesCSC36,
10  phiedgesCSC18,
11  phiedgesCSC36,
12  [0.35228048120123945, 0.87587781482541827, 1.3994776462193192, 1.923076807996136, 2.4466741416203148, 2.970273973014216,
13  -2.7893121723885534, -2.2657148387643748, -1.7421150073704739, -1.2185158455936571, -0.69491851196947851, -0.17131868057557731],
14  [0.22000706229660855, 0.74360690430428489, 1.267204926935573, 1.7908033890915052, 2.3144032310991816, 2.8380012537304697,
15  -2.9215855912931841, -2.3979857492855081, -1.8743877266542202, -1.3507892644982882, -0.82718942249061178, -0.30359139985932365],
16  [0.29751957124275596, 0.82111826253905784, 1.3447162969496083, 1.8683158980376524, 2.3919145893339548, 2.915512623744505,
17  -2.844073082347037, -2.3204743910507353, -1.7968763566401849, -1.2732767555521407, -0.74967806425583894, -0.22608002984528835],
18  [3.0136655290752188, -2.7530905195097337, -2.2922883025568734, -1.9222915077192773, -1.5707963267948966, -1.2193011458705159,
19  -0.84930435103291968, -0.38850213408005951, 0.127927124514574, 0.65152597487624719, 1.1322596819239259, 1.5707963267948966,
20  2.0093329716658674, 2.4900666787135459]]

Definition at line 295 of file plotscripts.py.

list plotscripts.phiedgesCSC18 = [pi/180.*(-5. + 20.*i) for i in range(18)]

Definition at line 294 of file plotscripts.py.

list plotscripts.phiedgesCSC36 = [pi/180.*(-5. + 10.*i) for i in range(36)]

sector phi edges in: me11 me12 me13 me14 me21 me22 me31 me32 me41 me42 mb1 mb2 mb3 mb4 index: 0 1 2 3 4 5 6 7 8 9 10 11 12 13

Definition at line 293 of file plotscripts.py.

plotscripts.tdrStyle = None

Definition at line 86 of file plotscripts.py.

Referenced by LRHelpFunctions.purityPlot(), RecoBTag.setTDRStyle(), LRHelpFunctions.singlePlot(), and RecoBTag.tdrGrid().

dictionary plotscripts.TEST_RESULTS = {}

Definition at line 26 of file plotscripts.py.