def plotscripts::addToTestResults | ( | c, | |
res | |||
) |
Definition at line 1032 of file plotscripts.py.
def plotscripts::availableCellsCSC | ( | reports | ) |
Definition at line 965 of file plotscripts.py.
00966 : 00967 cscs = [] 00968 # CSC station 00969 for endcap in CSC_TYPES: 00970 for station in endcap[2]: 00971 cscs.append("%s%s" % (endcap[0], station[1])) 00972 # CSC station & ring 00973 for endcap in CSC_TYPES: 00974 for station in endcap[2]: 00975 for ring in station[2]: 00976 if ring[1]=="ALL": continue 00977 #label = "CSCvsphi_me%s%s%s" % (endcap[1], station[1], ring[1]) 00978 cscs.append("%s%s/%s" % (endcap[0], station[1],ring[1])) 00979 # CSC station and chamber 00980 for endcap in CSC_TYPES: 00981 for station in endcap[2]: 00982 for ring in station[2]: 00983 if ring[1]!="ALL": continue 00984 for chamber in range(1,ring[2]+1): 00985 #label = "CSCvsr_me%s%sch%02d" % (endcap[1], station[1], chamber) 00986 cscs.append("%s%s/ALL/%02d" % (endcap[0], station[1],chamber)) 00987 # CSC station and ALL chambers 00988 for endcap in CSC_TYPES: 00989 for station in endcap[2]: 00990 for ring in station[2]: 00991 if ring[1]!="ALL": continue 00992 #label = "CSCvsr_me%s%schALL" % (endcap[1], station[1]) 00993 cscs.append("%s%s/ALL" % (endcap[0], station[1])) 00994 # CSC chambers 00995 for endcap in CSC_TYPES: 00996 for station in endcap[2]: 00997 for ring in station[2]: 00998 if ring[1]=="ALL": continue 00999 for chamber in range(1,ring[2]+1): 01000 # exclude non instrumented ME4/2 01001 if station[1]=="4" and ring[1]=="2": 01002 if endcap[1]=="m": continue 01003 if chamber<9 or chamber>13: continue 01004 schamber = "%02d" % chamber 01005 label = "ME%s%s%s_%s" % (endcap[1], station[1], ring[1], schamber) 01006 if len(reports)==0: 01007 # no reports case: do not include chambers 01008 #cscs.append(endcap[0]+station[1]+'/'+ring[1]+'/'+schamber) 01009 continue 01010 found = False 01011 for r in reports: 01012 if r.name == label: 01013 found = True 01014 break 01015 if not found: continue 01016 if r.status == "TOOFEWHITS" and r.posNum+r.negNum==0: continue 01017 if r.status == "NOFIT": continue 01018 cscs.append(endcap[0]+station[1]+'/'+ring[1]+'/'+schamber) 01019 return cscs 01020
def plotscripts::availableCellsDT | ( | reports | ) |
Definition at line 919 of file plotscripts.py.
00920 : 00921 dts = [] 00922 # DT wheels 00923 for iwheel in DT_TYPES: 00924 if iwheel[1]=="ALL": continue 00925 dts.append(iwheel[0]) 00926 # DT wheel & station 00927 for wheel in DT_TYPES: 00928 if wheel[1]=="ALL": continue 00929 for station in wheel[2]: 00930 dts.append(wheel[0]+'/'+station[1]) 00931 # DT station & sector 00932 for wheel in DT_TYPES: 00933 if wheel[1]!="ALL": continue 00934 for station in wheel[2]: 00935 for sector in range(1,station[2]+1): 00936 ssector = "%02d" % sector 00937 dts.append(wheel[0]+'/'+station[1]+'/'+ssector) 00938 # DT station & ALL sectors 00939 for wheel in DT_TYPES: 00940 if wheel[1]!="ALL": continue 00941 for station in wheel[2]: 00942 dts.append(wheel[0]+'/'+station[1]) 00943 # DT chambers 00944 for wheel in DT_TYPES: 00945 if wheel[1]=="ALL": continue 00946 for station in wheel[2]: 00947 for sector in range(1,station[2]+1): 00948 ssector = "%02d" % sector 00949 label = "MBwh%sst%ssec%s" % (wheelLetter(int(wheel[1])),station[1],ssector) 00950 if len(reports)==0: 00951 # no reports case: do not include chambers 00952 #dts.append(wheel[0]+'/'+station[1]+'/'+ssector) 00953 continue 00954 found = False 00955 for r in reports: 00956 if r.name == label: 00957 found = True 00958 break 00959 if not found: continue 00960 if r.status == "TOOFEWHITS" and r.posNum+r.negNum==0: continue 00961 if r.status == "NOFIT": continue 00962 dts.append(wheel[0]+'/'+station[1]+'/'+ssector) 00963 return dts 00964
def plotscripts::bellcurves | ( | tfile, | |
reports, | |||
name, | |||
twobin = True , |
|||
suppressblue = False |
|||
) |
Definition at line 2053 of file plotscripts.py.
02054 : 02055 t1 = time.time() 02056 ddt[0] += 1 02057 tdrStyle.SetOptTitle(1) 02058 tdrStyle.SetTitleBorderSize(1) 02059 tdrStyle.SetTitleFontSize(0.1) 02060 tdrStyle.SetOptStat(0) 02061 tdrStyle.SetHistMinimumZero() 02062 02063 c1.Clear() 02064 c1.ResetAttPad() 02065 02066 found = False 02067 for r in reports: 02068 if r.name == name: 02069 found = True 02070 break 02071 if not found: raise Exception, "Not a valid name" 02072 if r.status == "FAIL": 02073 #raise Exception, "Fit failed" 02074 print "Fit failed" 02075 c1.Clear() 02076 return 02077 02078 Pos = "Pos"; Neg = "Neg" 02079 if not twobin: 02080 Pos = ""; Neg = "" 02081 02082 pdirPos = "MuonAlignmentFromReference/%s%s" % (name, Pos) 02083 pdirNeg = "MuonAlignmentFromReference/%s%s" % (name, Neg) 02084 02085 t2 = time.time() 02086 ddt[1] = 1./ddt[0]*((ddt[0]-1)*ddt[1] + t2-t1) 02087 02088 chamber_x = tfile.Get(pdirPos+"_x") 02089 chamber_x_fit = tfile.Get(pdirPos+"_x_fit") 02090 chamber_y = tfile.Get(pdirPos+"_y") 02091 chamber_y_fit = tfile.Get(pdirPos+"_y_fit") 02092 chamber_dxdz = tfile.Get(pdirPos+"_dxdz") 02093 chamber_dxdz_fit = tfile.Get(pdirPos+"_dxdz_fit") 02094 chamber_dydz = tfile.Get(pdirPos+"_dydz") 02095 chamber_dydz_fit = tfile.Get(pdirPos+"_dydz_fit") 02096 chamber_alphax = tfile.Get(pdirPos+"_alphax") 02097 chamber_alphax_fit = tfile.Get(pdirPos+"_alphax_fit") 02098 chamber_alphay = tfile.Get(pdirPos+"_alphay") 02099 chamber_alphay_fit = tfile.Get(pdirPos+"_alphay_fit") 02100 if twobin: 02101 chamber_x_fit2 = tfile.Get(pdirNeg+"_x_fit") 02102 chamber_y_fit2 = tfile.Get(pdirNeg+"_y_fit") 02103 chamber_dxdz_fit2 = tfile.Get(pdirNeg+"_dxdz_fit") 02104 chamber_dydz_fit2 = tfile.Get(pdirNeg+"_dydz_fit") 02105 chamber_alphax_fit2 = tfile.Get(pdirNeg+"_alphax_fit") 02106 chamber_alphay_fit2 = tfile.Get(pdirNeg+"_alphay_fit") 02107 02108 if not chamber_x: 02109 chamber_x = tfile.Get(pdirPos+"_residual") 02110 chamber_x_fit = tfile.Get(pdirPos+"_residual_fit") 02111 chamber_dxdz = tfile.Get(pdirPos+"_resslope") 02112 chamber_dxdz_fit = tfile.Get(pdirPos+"_resslope_fit") 02113 chamber_alphax = tfile.Get(pdirPos+"_alpha") 02114 chamber_alphax_fit = tfile.Get(pdirPos+"_alpha_fit") 02115 if twobin: 02116 chamber_x_fit2 = tfile.Get(pdirNeg+"_residual_fit") 02117 chamber_dxdz_fit2 = tfile.Get(pdirNeg+"_resslope_fit") 02118 chamber_alphax_fit2 = tfile.Get(pdirNeg+"_alpha_fit") 02119 02120 if not chamber_x: 02121 print "Can't find neither "+pdirPos+"_x nor "+pdirPos+"_residual" 02122 return 02123 02124 t3 = time.time() 02125 ddt[2] = 1./ddt[0]*((ddt[0]-1)*ddt[2] + t3-t2) 02126 02127 #### 02128 chamber_x.SetAxisRange(-50., 50., "X") 02129 if chamber_x.GetRMS()>15: chamber_x.SetAxisRange(-75., 75., "X") 02130 chamber_dxdz.SetAxisRange(-30., 30., "X") 02131 chamber_alphax.SetAxisRange(-50., 50., "X") 02132 if not not chamber_y: 02133 chamber_y.SetAxisRange(-75., 75., "X") 02134 chamber_dydz.SetAxisRange(-120., 120., "X") 02135 chamber_alphay.SetAxisRange(-120., 120., "X") 02136 chamber_alphay.SetAxisRange(-75., 75., "Y") 02137 #### 02138 02139 chamber_x.SetXTitle("Local x residual (mm)") 02140 chamber_dxdz.SetXTitle("Local dx/dz residual (mrad)") 02141 chamber_alphax.SetXTitle("Local dx/dz residual (mrad)") 02142 chamber_alphax.SetYTitle("Local x residual (mm)") 02143 if not not chamber_y: 02144 chamber_y.SetXTitle("Local y residual (mm)") 02145 chamber_dydz.SetXTitle("Local dy/dz residual (mrad)") 02146 chamber_alphay.SetXTitle("Local dy/dz residual (mrad)") 02147 chamber_alphay.SetYTitle("Local y residual (mm)") 02148 if name[0:2] == "ME": 02149 chamber_x.SetXTitle("Local r#phi residual (mm)") 02150 chamber_dxdz.SetXTitle("Local d(r#phi)/dz residual (mrad)") 02151 chamber_alphax.SetXTitle("Local d(r#phi)/dz residual (mrad)") 02152 chamber_alphax.SetYTitle("Local r#phi residual (mm)") 02153 02154 t4 = time.time() 02155 ddt[3] = 1./ddt[0]*((ddt[0]-1)*ddt[3] + t4-t3) 02156 02157 for h in chamber_x, chamber_dxdz, chamber_alphax, chamber_alphax, \ 02158 chamber_y, chamber_dydz, chamber_alphay, chamber_alphay: 02159 if not not h: 02160 h.GetXaxis().CenterTitle() 02161 h.GetYaxis().CenterTitle() 02162 h.GetXaxis().SetLabelSize(0.05) 02163 h.GetYaxis().SetLabelSize(0.05) 02164 h.GetXaxis().SetTitleSize(0.07) 02165 h.GetYaxis().SetTitleSize(0.07) 02166 h.GetXaxis().SetTitleOffset(0.9) 02167 h.GetYaxis().SetTitleOffset(0.9) 02168 02169 if twobin: 02170 for f in chamber_x_fit2, chamber_y_fit2, chamber_dxdz_fit2, chamber_dydz_fit2, \ 02171 chamber_alphax_fit2, chamber_alphay_fit2: 02172 if not not f: 02173 f.SetLineColor(4) 02174 if not twobin: 02175 suppressblue = True 02176 02177 t5 = time.time() 02178 ddt[4] = 1./ddt[0]*((ddt[0]-1)*ddt[4] + t5-t4) 02179 02180 global l1, l2, l3, l4 02181 if not not chamber_y: 02182 c1.Clear() 02183 c1.Divide(3, 2) 02184 chamber_x.SetTitle(getname(r)) 02185 02186 c1.GetPad(1).cd() 02187 chamber_x.Draw() 02188 if not suppressblue: chamber_x_fit2.Draw("same") 02189 chamber_x_fit.Draw("same") 02190 l1 = ROOT.TLatex(0.67,0.8,"#splitline{#mu: %0.2f#pm%0.2f}{#sigma: %0.1f#pm%0.1f}" % ( 02191 chamber_x_fit.GetParameter(1), chamber_x_fit.GetParError(1), 02192 chamber_x_fit.GetParameter(2), chamber_x_fit.GetParError(2))) 02193 l1.Draw() 02194 02195 c1.GetPad(2).cd() 02196 chamber_dxdz.Draw() 02197 if not suppressblue: chamber_dxdz_fit2.Draw("same") 02198 chamber_dxdz_fit.Draw("same") 02199 l2 = ROOT.TLatex(0.67,0.8,"#splitline{#mu: %0.2f#pm%0.2f}{#sigma: %0.1f#pm%0.1f}" % ( 02200 chamber_dxdz_fit.GetParameter(1), chamber_dxdz_fit.GetParError(1), 02201 chamber_dxdz_fit.GetParameter(2), chamber_dxdz_fit.GetParError(2))) 02202 l2.Draw() 02203 02204 c1.GetPad(3).cd() 02205 chamber_alphax.Draw("col") 02206 if not suppressblue: chamber_alphax_fit2.Draw("same") 02207 chamber_alphax_fit.Draw("same") 02208 02209 c1.GetPad(4).cd() 02210 chamber_y.Draw() 02211 if not suppressblue: chamber_y_fit2.Draw("same") 02212 chamber_y_fit.Draw("same") 02213 l3 = ROOT.TLatex(0.67,0.8,"#splitline{#mu: %0.2f#pm%0.2f}{#sigma: %0.1f#pm%0.1f}" % ( 02214 chamber_y_fit.GetParameter(1), chamber_y_fit.GetParError(1), 02215 chamber_y_fit.GetParameter(2), chamber_y_fit.GetParError(2))) 02216 l3.Draw() 02217 02218 c1.GetPad(5).cd() 02219 chamber_dydz.Draw() 02220 if not suppressblue: chamber_dydz_fit2.Draw("same") 02221 chamber_dydz_fit.Draw("same") 02222 l4 = ROOT.TLatex(0.67,0.8,"#splitline{#mu: %0.2f#pm%0.2f}{#sigma: %0.1f#pm%0.1f}" % ( 02223 chamber_dydz_fit.GetParameter(1), chamber_dydz_fit.GetParError(1), 02224 chamber_dydz_fit.GetParameter(2), chamber_dydz_fit.GetParError(2))) 02225 l4.Draw() 02226 02227 for lb in l1,l2,l3,l4: 02228 lb.SetNDC(1) 02229 lb.SetTextColor(ROOT.kRed) 02230 02231 c1.GetPad(6).cd() 02232 chamber_alphay.Draw("col") 02233 if not suppressblue: chamber_alphay_fit2.Draw("same") 02234 chamber_alphay_fit.Draw("same") 02235 02236 else: 02237 c1.Clear() 02238 c1.Divide(3, 1) 02239 chamber_x.SetTitle(getname(r)) 02240 02241 c1.GetPad(1).cd() 02242 chamber_x.Draw() 02243 if not suppressblue: chamber_x_fit2.Draw("same") 02244 chamber_x_fit.Draw("same") 02245 l1 = ROOT.TLatex(0.67,0.8,"#splitline{#mu: %0.2f#pm%0.2f}{#sigma: %0.1f#pm%0.1f}" % ( 02246 chamber_x_fit.GetParameter(1), chamber_x_fit.GetParError(1), 02247 chamber_x_fit.GetParameter(2), chamber_x_fit.GetParError(2))) 02248 l1.Draw() 02249 02250 c1.GetPad(2).cd() 02251 chamber_dxdz.Draw() 02252 if not suppressblue: chamber_dxdz_fit2.Draw("same") 02253 chamber_dxdz_fit.Draw("same") 02254 l2 = ROOT.TLatex(0.67,0.8,"#splitline{#mu: %0.2f#pm%0.2f}{#sigma: %0.1f#pm%0.1f}" % ( 02255 chamber_dxdz_fit.GetParameter(1), chamber_dxdz_fit.GetParError(1), 02256 chamber_dxdz_fit.GetParameter(2), chamber_dxdz_fit.GetParError(2))) 02257 l2.Draw() 02258 02259 c1.GetPad(3).cd() 02260 chamber_alphax.Draw("col") 02261 if not suppressblue: chamber_alphax_fit2.Draw("same") 02262 chamber_alphax_fit.Draw("same") 02263 02264 for lb in l1,l2: 02265 lb.SetNDC(1) 02266 lb.SetTextColor(ROOT.kRed) 02267 02268 t6 = time.time() 02269 ddt[5] = 1./ddt[0]*((ddt[0]-1)*ddt[5] + t6-t5) 02270 ddt[6] = 1./ddt[0]*((ddt[0]-1)*ddt[6] + t6-t1) 02271
def plotscripts::clearDDT | ( | ) |
Definition at line 2042 of file plotscripts.py.
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 3551 of file plotscripts.py.
03554 : 03555 03556 tdrStyle.SetOptStat(0) 03557 tdrStyle.SetStatW(0.40) 03558 03559 # determine what are we plotting: report vs report or xml vs xml 03560 mode = None 03561 check_reports = False 03562 if reportsX is not None and reportsY is not None: 03563 mode = "reports" 03564 check_reports = True 03565 if geometry0 is not None and geometryX is not None and geometryY is not None: 03566 mode = "xmls" 03567 if mode is None: 03568 print "Either couple of reports or three geometries have to be given as input. Exiting..." 03569 return 03570 03571 # setup ranges with the maximum [-window,window] that later will be optimized to [-wnd_adaptive,wnd_adaptive] 03572 wnd = [window]*6 03573 wnd_adaptive = [.1]*6 03574 03575 global hx, hy, hz, hphix, hphiy, hphiz 03576 bins=2000 03577 hx = ROOT.TH2F("%s_x" % name, "", bins, -wnd[0], wnd[0], bins, -wnd[0], wnd[0]) 03578 hy = ROOT.TH2F("%s_y" % name, "", bins, -wnd[1], wnd[1], bins, -wnd[1], wnd[1]) 03579 hz = ROOT.TH2F("%s_z" % name, "", bins, -wnd[2], wnd[2], bins, -wnd[2], wnd[2]) 03580 hphix = ROOT.TH2F("%s_phix" % name, "", bins, -wnd[3], wnd[3], bins, -wnd[3], wnd[3]) 03581 hphiy = ROOT.TH2F("%s_phiy" % name, "", bins, -wnd[4], wnd[4], bins, -wnd[4], wnd[4]) 03582 hphiz = ROOT.TH2F("%s_phiz" % name, "", bins, -wnd[5], wnd[5], bins, -wnd[5], wnd[5]) 03583 hhh = [hx, hy, hz, hphix, hphiy, hphiz] 03584 03585 # initialize PCA objects 03586 global pca_x, pca_y, pca_z, pca_phix, pca_phiy, pca_phiz 03587 pca_x = ROOT.TPrincipal(2,"D") 03588 pca_y = ROOT.TPrincipal(2,"D") 03589 pca_z = ROOT.TPrincipal(2,"D") 03590 pca_phix = ROOT.TPrincipal(2,"D") 03591 pca_phiy = ROOT.TPrincipal(2,"D") 03592 pca_phiz = ROOT.TPrincipal(2,"D") 03593 pcas = [pca_x, pca_y, pca_z, pca_phix, pca_phiy, pca_phiz] 03594 03595 # arrays to later fill graphs with 03596 ax=[]; ay=[]; az=[]; aphix=[]; aphiy=[]; aphiz=[] 03597 aaa = [ax, ay, az, aphix, aphiy, aphiz] 03598 03599 # list of postal addresses 03600 postal_addresses = [] 03601 03602 # if reports are given, use them to fill addresses and do extra checks 03603 if check_reports: 03604 for r1 in reportsX: 03605 # skip ME1/a 03606 if r1.postal_address[0]=='CSC' and r1.postal_address[2]==1 and r1.postal_address[3]==4: continue 03607 if selection is None or (selection.func_code.co_argcount == len(r1.postal_address) and selection(*r1.postal_address)): 03608 r2 = getReportByPostalAddress(r1.postal_address, reportsY) 03609 if r2 is None: 03610 print "bad r2 in ",r1.postal_address 03611 continue 03612 03613 if r1.status != "PASS" or r2.status != "PASS": 03614 print "bad status", r1.postal_address, r1.status, r2.status 03615 continue 03616 postal_addresses.append(r1.postal_address) 03617 # otherwise, use chamber addresses from xmls 03618 else: 03619 for key in geometry0.dt.keys(): 03620 if len(key)==3 and key in geometryX.dt and key in geometryY.dt: 03621 postal_addresses.append( tuple(['DT'] + list(key)) ) 03622 for key in geometry0.csc.keys(): 03623 # skip ME1/a 03624 if key[2]==1 and key[3]==4: continue 03625 if len(key)==4 and key in geometryX.csc and key in geometryY.csc: 03626 postal_addresses.append( tuple(['CSC'] + list(key)) ) 03627 03628 # fill the values 03629 for addr in postal_addresses: 03630 03631 # checks the selection function 03632 if not (selection is None or (selection.func_code.co_argcount == len(addr) and selection(*addr)) ): continue 03633 03634 factors = [10. * signConventions[addr][0], 10. * signConventions[addr][1], 10. * signConventions[addr][2], 03635 1000., 1000., 1000. ] 03636 03637 if check_reports: 03638 rX = getReportByPostalAddress(addr, reportsX) 03639 rY = getReportByPostalAddress(addr, reportsY) 03640 deltasX = [rX.deltax, rX.deltay, rX.deltaz, rX.deltaphix, rX.deltaphiy, rX.deltaphiz] 03641 deltasY = [rY.deltax, rY.deltay, rY.deltaz, rY.deltaphix, rY.deltaphiy, rY.deltaphiz] 03642 03643 if mode == "reports": 03644 03645 checks = map( lambda d1, d2: d1 is not None and d2 is not None and d1.error is not None \ 03646 and d2.error is not None and (d1.error**2 + d2.error**2) > 0. , \ 03647 deltasX, deltasY) 03648 03649 for i in range(len(checks)): 03650 if not checks[i]: continue 03651 fillX = deltasX[i].value * factors[i] 03652 fillY = deltasY[i].value * factors[i] 03653 aaa[i].append([fillX,fillY]) 03654 pcas[i].AddRow(array.array('d',[fillX,fillY])) 03655 mx = max(abs(fillX), abs(fillY)) 03656 if mx > wnd_adaptive[i]: wnd_adaptive[i] = mx 03657 03658 if mode == "xmls": 03659 03660 db0 = dbX = dbY = None 03661 if addr[0] == "DT": 03662 db0, dbX, dbY = geometry0.dt[addr[1:]], geometryX.dt[addr[1:]], geometryY.dt[addr[1:]] 03663 if addr[0] == 'CSC': 03664 db0, dbX, dbY = geometry0.csc[addr[1:]], geometryX.csc[addr[1:]], geometryY.csc[addr[1:]] 03665 03666 checks = [True]*6 03667 if check_reports: 03668 checks = map( lambda d1, d2: d1 is not None and d2 is not None , deltasX, deltasY) 03669 03670 gdeltas0 = [db0.x, db0.y, db0.z, db0.phix, db0.phiy, db0.phiz] 03671 gdeltasX = [dbX.x, dbX.y, dbX.z, dbX.phix, dbX.phiy, dbX.phiz] 03672 gdeltasY = [dbY.x, dbY.y, dbY.z, dbY.phix, dbY.phiy, dbY.phiz] 03673 03674 for i in range(len(checks)): 03675 if not checks[i]: continue 03676 fillX = (gdeltasX[i] - gdeltas0[i]) * factors[i] 03677 fillY = (gdeltasY[i] - gdeltas0[i]) * factors[i] 03678 aaa[i].append([fillX,fillY]) 03679 pcas[i].AddRow(array.array('d',[fillX,fillY])) 03680 mx = max(abs(fillX), abs(fillY)) 03681 if mx > wnd_adaptive[i]: wnd_adaptive[i] = mx 03682 #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) 03683 #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) 03684 #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) 03685 03686 if mode == "xmls": 03687 if pre_title_x is None: pre_title_x = "geometry 1 " 03688 if pre_title_y is None: pre_title_y = "geometry 2 " 03689 if mode == "reports": 03690 if pre_title_x is None: pre_title_x = "iteration's " 03691 if pre_title_y is None: pre_title_y = "other iteration's " 03692 tmptitles = ["#Deltax (mm)", "#Deltay (mm)", "#Deltaz (mm)", 03693 "#Delta#phi_{x} (mrad)", "#Delta#phi_{y} (mrad)", "#Delta#phi_{z} (mrad)"] 03694 htitles = [] 03695 for t in tmptitles: htitles.append([pre_title_x + t, pre_title_y + t]) 03696 03697 if canvas is not None: c = canvas 03698 else: c = c1 03699 c.Clear() 03700 ndraw = which.count('1') 03701 if ndraw > 4: c.Divide(3, 2) 03702 elif ndraw > 2: c.Divide(2, 2) 03703 elif ndraw > 1: c.Divide(2, 1) 03704 03705 global lines, graphs, texs 03706 lines = []; graphs = []; texs = [] 03707 03708 ipad = 0 03709 for i in range(6): 03710 03711 # decode 'which' binary mask 03712 if ( int(which,2) & (1<<i) ) == 0: continue 03713 03714 ipad += 1 03715 c.GetPad(ipad).cd() 03716 c.GetPad(ipad).SetGridx(1) 03717 c.GetPad(ipad).SetGridy(1) 03718 03719 wn = 1.08 * wnd_adaptive[i] 03720 hhh[i].GetXaxis().SetRangeUser(-wn, wn) 03721 hhh[i].GetYaxis().SetRangeUser(-wn, wn) 03722 hhh[i].SetXTitle(htitles[i][0]) 03723 hhh[i].SetYTitle(htitles[i][1]) 03724 hhh[i].GetXaxis().CenterTitle() 03725 hhh[i].GetYaxis().CenterTitle() 03726 hhh[i].Draw() 03727 03728 if len(aaa[i]) == 0: continue 03729 03730 a1, a2 = map( lambda x: array.array('d',x), zip(*aaa[i]) ) 03731 g = ROOT.TGraph(len(a1), a1, a2) 03732 g.SetMarkerStyle(5) 03733 g.SetMarkerSize(0.3) 03734 g.SetMarkerColor(ROOT.kBlue) 03735 graphs.append(g) 03736 03737 pcas[i].MakePrincipals() 03738 #pcas[i].Print() 03739 #pcas[i].MakeHistograms() 03740 b = pcas[i].GetEigenVectors()(1,0) / pcas[i].GetEigenVectors()(0,0) 03741 a = pcas[i].GetMeanValues()[1] - b * pcas[i].GetMeanValues()[0] 03742 #print a, b, " ", pcas[i].GetEigenValues()[0], pcas[i].GetEigenValues()[1] 03743 03744 cov = pcas[i].GetCovarianceMatrix() 03745 r = cov(0,1)/sqrt(cov(1,1)*cov(0,0)) 03746 print "r, RMSx, RMSy =", r, g.GetRMS(1), g.GetRMS(2) 03747 texrms = ROOT.TLatex(0.17,0.87, "RMS x,y = %.02g, %.02g" % (g.GetRMS(1),g.GetRMS(2))) 03748 texr = ROOT.TLatex(0.17,0.80, "r = %.02g" % r) 03749 for t in texr, texrms: 03750 t.SetNDC(1) 03751 t.SetTextColor(ROOT.kBlue) 03752 t.SetTextSize(0.053) 03753 t.Draw() 03754 texs.append(t) 03755 03756 g.Draw("p") 03757 03758 if not isnan(b): 03759 wn = wnd_adaptive[i] 03760 line = ROOT.TLine(-wn, a - b*wn, wn, a + b*wn) 03761 line.SetLineColor(ROOT.kRed) 03762 line.Draw() 03763 lines.append(line) 03764 03765 #return hx, hy, hphiy, hphiz, pca_x, pca_y, pca_phiy, pca_phiz 03766 return aaa
def plotscripts::createPeaksProfile | ( | the2d, | |
rebin = 1 |
|||
) |
Definition at line 1403 of file plotscripts.py.
01404 : 01405 htmp = ROOT.gROOT.FindObject(the2d.GetName()+"_peaks") 01406 if htmp != None: htmp.Delete() 01407 01408 hpeaks = the2d.ProjectionX(the2d.GetName()+"_peaks") 01409 hpeaks.Reset() 01410 hpeaks.Rebin(rebin) 01411 bad_fit_bins = [] 01412 for i in xrange(0, int(the2d.GetNbinsX()), rebin): 01413 tmp = the2d.ProjectionY("tmp", i+1, i + rebin) 01414 nn = tmp.GetEntries() 01415 01416 drange = tmp.GetRMS() 01417 drange = 2.*drange 01418 fgaus = ROOT.TF1("fgaus","gaus", tmp.GetMean() - drange, tmp.GetMean() + drange) 01419 fgaus.SetParameter(0,nn) 01420 fgaus.SetParameter(1,tmp.GetMean()) 01421 fgaus.SetParameter(2,tmp.GetRMS()) 01422 #print " ", i, nn, tmp.GetMean() , drange, "[", tmp.GetMean() - drange, tmp.GetMean() + drange, ']' 01423 01424 fitOk = False 01425 if nn > 10: # good to fit 01426 fr = tmp.Fit("fgaus","RNSQ") 01427 #print " ", fgaus.GetParameter(1), " +- ", fgaus.GetParError(1), " fitres = " , fr.Status() , fr.CovMatrixStatus() 01428 hpeaks.SetBinContent(i/rebin+1, fgaus.GetParameter(1)) 01429 hpeaks.SetBinError(i/rebin+1, fgaus.GetParError(1)) 01430 if fr.Status()==0 and fr.CovMatrixStatus()==3 : fitOk = True 01431 if not fitOk: 01432 bad_fit_bins.append(i/rebin+1) 01433 if nn > 1. and tmp.GetRMS() > 0: # use mean 01434 hpeaks.SetBinContent(i/rebin+1, tmp.GetMean()) 01435 hpeaks.SetBinError(i/rebin+1, ROOT.TMath.StudentQuantile(0.841345,nn) * tmp.GetRMS() / sqrt(nn)) 01436 else: 01437 hpeaks.SetBinContent(i/rebin+1, 0.) 01438 hpeaks.SetBinError(i/rebin+1, 0.) 01439 if len(bad_fit_bins): print "createPeaksProfile bad fit bins: ", bad_fit_bins 01440 return hpeaks 01441
def plotscripts::curvatureDTsummary | ( | tfiles, | |
window = 15. , |
|||
pdgSfactor = False |
|||
) |
Definition at line 1971 of file plotscripts.py.
01972 : 01973 global h, gm2, gm1, gz, gp1, gp2, tlegend 01974 01975 set_palette("blues") 01976 phis = {-2: [], -1: [], 0: [], 1: [], 2: []} 01977 diffs = {-2: [], -1: [], 0: [], 1: [], 2: []} 01978 differrs = {-2: [], -1: [], 0: [], 1: [], 2: []} 01979 for wheelstr, wheel in ("m2", "-2"), ("m1", "-1"), ("z", "0"), ("p1", "+1"), ("p2", "+2"): 01980 for sector in "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12": 01981 curvatureplot(tfiles, "wheel%s_sector%s" % (wheelstr, sector), "deltax", 01982 title="Wheel %s, sector %s" % (wheel, sector), fitgauss=True, reset_palette=False) 01983 if fitgauss_diff[1] < window: 01984 uncertainty = fitgauss_diff[1] 01985 if pdgSfactor and (fitgauss_chi2/fitgauss_ndf) > 1.: uncertainty *= sqrt(fitgauss_chi2/fitgauss_ndf) 01986 01987 phis[int(wheel)].append(signConventions["DT", int(wheel), 1, int(sector)][4]) 01988 diffs[int(wheel)].append(fitgauss_diff[0]) 01989 differrs[int(wheel)].append(uncertainty) 01990 01991 h = ROOT.TH1F("h", "", 1, -pi, pi) 01992 h.SetAxisRange(-window, window, "Y") 01993 h.SetXTitle("#phi (rad)") 01994 h.SetYTitle("#Deltax(p_{T} #rightarrow #infty) - #Deltax(p_{T} #rightarrow 0) (mm)") 01995 h.GetXaxis().CenterTitle() 01996 h.GetYaxis().CenterTitle() 01997 01998 gm2 = ROOT.TGraphErrors(len(phis[-2]), array.array("d", phis[-2]), array.array("d", diffs[-2]), 01999 array.array("d", [0.]*len(phis[-2])), array.array("d", differrs[-2])) 02000 gm1 = ROOT.TGraphErrors(len(phis[-1]), array.array("d", phis[-1]), array.array("d", diffs[-1]), 02001 array.array("d", [0.]*len(phis[-1])), array.array("d", differrs[-1])) 02002 gz = ROOT.TGraphErrors(len(phis[0]), array.array("d", phis[0]), array.array("d", diffs[0]), 02003 array.array("d", [0.]*len(phis[0])), array.array("d", differrs[0])) 02004 gp1 = ROOT.TGraphErrors(len(phis[1]), array.array("d", phis[1]), array.array("d", diffs[1]), 02005 array.array("d", [0.]*len(phis[1])), array.array("d", differrs[1])) 02006 gp2 = ROOT.TGraphErrors(len(phis[2]), array.array("d", phis[2]), array.array("d", diffs[2]), 02007 array.array("d", [0.]*len(phis[2])), array.array("d", differrs[2])) 02008 02009 gm2.SetMarkerStyle(21); gm2.SetMarkerColor(ROOT.kRed); gm2.SetLineColor(ROOT.kRed) 02010 gm1.SetMarkerStyle(22); gm1.SetMarkerColor(ROOT.kBlue); gm1.SetLineColor(ROOT.kBlue) 02011 gz.SetMarkerStyle(3); gz.SetMarkerColor(ROOT.kBlack); gz.SetLineColor(ROOT.kBlack) 02012 gp1.SetMarkerStyle(26); gp1.SetMarkerColor(ROOT.kBlue); gp1.SetLineColor(ROOT.kBlue) 02013 gp2.SetMarkerStyle(25); gp2.SetMarkerColor(ROOT.kRed); gp2.SetLineColor(ROOT.kRed) 02014 02015 h.Draw() 02016 tlegend = ROOT.TLegend(0.25, 0.2, 0.85, 0.5) 02017 tlegend.SetFillColor(ROOT.kWhite) 02018 tlegend.SetBorderSize(0) 02019 tlegend.AddEntry(gm2, "Wheel -2", "p") 02020 tlegend.AddEntry(gm1, "Wheel -1", "p") 02021 tlegend.AddEntry(gz, "Wheel 0", "p") 02022 tlegend.AddEntry(gp1, "Wheel +1", "p") 02023 tlegend.AddEntry(gp2, "Wheel +2", "p") 02024 tlegend.Draw() 02025 02026 gm2.Draw("p") 02027 gm1.Draw("p") 02028 gz.Draw("p") 02029 gp1.Draw("p") 02030 gp2.Draw("p") 02031
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.
01805 : 01806 tdrStyle.SetOptTitle(1) 01807 tdrStyle.SetTitleBorderSize(0) 01808 tdrStyle.SetOptStat(0) 01809 tdrStyle.SetOptFit(0) 01810 tdrStyle.SetTitleFontSize(0.05) 01811 01812 c1.Clear() 01813 if reset_palette: set_palette("blues") 01814 global hist, histCOPY, hist2d, tline1, tline2, tline3, tline4, tline5 01815 01816 hdir = "AlignmentMonitorMuonVsCurvature/iter1/" 01817 01818 if name not in ("all", "top", "bottom"): 01819 hsuffix = "_%s_%s" % (name, param) 01820 prof = tfiles[0].Get(hdir+"tprofile"+hsuffix).Clone("tprofile_"+hsuffix) 01821 hist2d = tfiles[0].Get(hdir+"th2f"+hsuffix).Clone("th2f_"+hsuffix) 01822 for tfile in tfiles[1:]: 01823 prof.Add(tfile.Get(hdir+"tprofile"+hsuffix)) 01824 hist2d.Add(tfile.Get(hdir+"th2f"+hsuffix)) 01825 else: 01826 prof = None 01827 hist2d = None 01828 for wheel in "m2", "m1", "z", "p1", "p2": 01829 if name == "all": sectors = "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" 01830 elif name == "top": sectors = "01", "02", "03", "04", "05", "06" 01831 elif name == "bottom": sectors = "07", "08", "09", "10", "11", "12" 01832 else: raise Exception 01833 01834 for sector in sectors: 01835 hsuffix = "_%s_%s" % ("wheel%s_sector%s" % (wheel, sector), param) 01836 for tfile in tfiles: 01837 if prof is None: 01838 prof = tfiles[0].Get(hdir+"tprofile"+hsuffix).Clone("tprofile_"+hsuffix) 01839 hist2d = tfiles[0].Get(hdir+"th2f"+hsuffix).Clone("tprofile_"+hsuffix) 01840 else: 01841 prof.Add(tfile.Get(hdir+"tprofile"+hsuffix)) 01842 hist2d.Add(tfile.Get(hdir+"th2f"+hsuffix)) 01843 01844 hist = ROOT.TH1F("hist", "", prof.GetNbinsX(), prof.GetBinLowEdge(1), -prof.GetBinLowEdge(1)) 01845 for i in xrange(1, prof.GetNbinsX()+1): 01846 hist.SetBinContent(i, prof.GetBinContent(i)) 01847 hist.SetBinError(i, prof.GetBinError(i)) 01848 01849 if mode == "plain": 01850 hist = prof 01851 elif mode == "from2d": 01852 skip = 1 01853 if widebins: 01854 hist.Rebin(5) 01855 skip = 5 01856 htmp = ROOT.gROOT.FindObject("tmp") 01857 if htmp != None: htmp.Delete() 01858 01859 for i in xrange(0, int(prof.GetNbinsX()), skip): 01860 tmp = hist2d.ProjectionY("tmp", i+1, i + skip) 01861 if tmp.GetEntries() > 1: 01862 hist.SetBinContent(i/skip+1, tmp.GetMean()) 01863 hist.SetBinError(i/skip+1, ROOT.TMath.StudentQuantile(0.841345,tmp.GetEntries()) * tmp.GetRMS() / sqrt(tmp.GetEntries())) 01864 #hist.SetBinError(i/skip+1, tmp.GetRMS() / sqrt(tmp.GetEntries())) 01865 else: 01866 #hist.SetBinContent(i/skip+1, 2000.) 01867 #hist.SetBinError(i/skip+1, 1000.) 01868 hist.SetBinContent(i/skip+1, 0.) 01869 hist.SetBinError(i/skip+1, 0.) 01870 01871 hpeaks = createPeaksProfile(hist2d, skip) 01872 01873 else: 01874 raise Exception 01875 01876 01877 if fitgauss: 01878 f = ROOT.TF1("f", "[0] + [1]*exp(-x**2/2/0.01**2)", hist.GetBinLowEdge(1), -hist.GetBinLowEdge(1)) 01879 f.SetParameters(0, 0., 0.01) 01880 if fitpeaks: hpeaks.Fit(f, "q") 01881 else: hist.Fit(f, "q") 01882 f.SetLineColor(ROOT.kRed) 01883 global fitgauss_diff, fitgauss_chi2, fitgauss_ndf 01884 # fitter = ROOT.TVirtualFitter.GetFitter() 01885 # fitgauss_diff = f.GetParameter(0) - f.GetParameter(1), \ 01886 # sqrt(f.GetParError(0)**2 + f.GetParError(1)**2 + 2.*fitter.GetCovarianceMatrixElement(0, 1)) 01887 fitgauss_diff = f.GetParameter(1), f.GetParError(1) 01888 fitgauss_chi2 = f.GetChisquare() 01889 fitgauss_ndf = f.GetNDF() 01890 01891 global fitline_intercept, fitline_slope 01892 if fitconst: 01893 f = ROOT.TF1("f", "[0]", hist.GetBinLowEdge(1), -hist.GetBinLowEdge(1)) 01894 if fitpeaks: hpeaks.Fit(f, "q") 01895 else: hist.Fit(f, "q") 01896 f.SetLineColor(ROOT.kRed) 01897 fitline_intercept = f.GetParameter(0), f.GetParError(0) 01898 01899 if fitline: 01900 f = ROOT.TF1("f", "[0] + [1]*x", hist.GetBinLowEdge(1), -hist.GetBinLowEdge(1)) 01901 if fitpeaks: hpeaks.Fit(f, "qNE") 01902 else: hist.Fit(f, "qNE") 01903 f.SetLineColor(ROOT.kRed) 01904 global f2, f3 01905 f2 = ROOT.TF1("2", "[0] + [1]*x", hist.GetBinLowEdge(1), -hist.GetBinLowEdge(1)) 01906 f3 = ROOT.TF1("2", "[0] + [1]*x", hist.GetBinLowEdge(1), -hist.GetBinLowEdge(1)) 01907 f2.SetParameters(f.GetParameter(0), f.GetParameter(1) + f.GetParError(1)) 01908 f3.SetParameters(f.GetParameter(0), f.GetParameter(1) - f.GetParError(1)) 01909 f2.SetLineColor(ROOT.kRed) 01910 f3.SetLineColor(ROOT.kRed) 01911 f2.SetLineStyle(2) 01912 f3.SetLineStyle(2) 01913 fitline_intercept = f.GetParameter(0), f.GetParError(0) 01914 fitline_slope = f.GetParameter(1), f.GetParError(1) 01915 01916 hist2d.SetAxisRange(-window, window, "Y") 01917 hist2d.SetMarkerStyle(20) 01918 hist2d.SetMarkerSize(0.75) 01919 hist2d.GetXaxis().CenterTitle() 01920 hist2d.GetYaxis().CenterTitle() 01921 if param == "curverr": 01922 hist2d.GetYaxis().SetTitleOffset(1.35) 01923 else: 01924 hist2d.GetYaxis().SetTitleOffset(0.75) 01925 hist2d.GetXaxis().SetTitleOffset(1.2) 01926 hist2d.GetXaxis().SetTitleSize(0.05) 01927 hist2d.GetYaxis().SetTitleSize(0.05) 01928 hist2d.SetTitle(title) 01929 if param == "pterr": hist2d.SetXTitle("qp_{T} (GeV/c)") 01930 else: hist2d.SetXTitle("q/p_{T} (c/GeV)") 01931 if param == "deltax": hist2d.SetYTitle("#Deltax' (mm)") 01932 if param == "deltadxdz": hist2d.SetYTitle("#Deltadx'/dz (mrad)") 01933 if param == "pterr": hist2d.SetYTitle("#Deltap_{T}/p_{T} (%)") 01934 if param == "curverr": hist2d.SetYTitle("#Deltaq/p_{T} (c/GeV)") 01935 hist2d.Draw("colz") 01936 hist.SetMarkerColor(ROOT.kBlack) 01937 hist.SetLineColor(ROOT.kBlack) 01938 hist.Draw("same") 01939 #histCOPY = hist.Clone() 01940 #histCOPY.SetXTitle("") 01941 #histCOPY.SetYTitle("") 01942 01943 #if widebins: 01944 # histCOPY.Draw("samee1") 01945 # histCOPY.Draw("sameaxis") 01946 #else: 01947 # histCOPY.Draw("same") 01948 # histCOPY.Draw("sameaxis") 01949 01950 if fitline: 01951 f.Draw("same") 01952 #f2.Draw("same") 01953 #f3.Draw("same") 01954 01955 hpeaks.SetMarkerStyle(20) 01956 hpeaks.SetMarkerSize(0.9) 01957 hpeaks.SetMarkerColor(ROOT.kRed) 01958 hpeaks.SetLineColor(ROOT.kRed) 01959 hpeaks.SetLineWidth(2) 01960 #if fitpeaks: hpeaks.Draw("same") 01961 hpeaks.Draw("same") 01962 01963 #tline1 = ROOT.TLine(hist.GetBinLowEdge(1), -window, hist.GetBinLowEdge(1), window) 01964 #tline2 = ROOT.TLine(hist.GetBinLowEdge(1), window, -hist.GetBinLowEdge(1), window) 01965 #tline3 = ROOT.TLine(-hist.GetBinLowEdge(1), window, -hist.GetBinLowEdge(1), -window) 01966 #tline4 = ROOT.TLine(-hist.GetBinLowEdge(1), -window, hist.GetBinLowEdge(1), -window) 01967 tline5 = ROOT.TLine(-hist.GetBinLowEdge(1), 0., hist.GetBinLowEdge(1), 0.) 01968 tline5.Draw() 01969 #for t in tline1, tline2, tline3, tline4, tline5: t.Draw() 01970
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 483 of file plotscripts.py.
00486 : 00487 00488 tdrStyle.SetOptStat("emrou") 00489 tdrStyle.SetStatW(0.40) 00490 00491 wnd = [window]*6 00492 if windows is not None: 00493 i=0 00494 for w in windows: 00495 wnd[i] = windows[i] 00496 i+=1 00497 00498 global hx, hy, hz, hphix, hphiy, hphiz 00499 00500 if phi: 00501 hx = ROOT.TH1F("%s_phi" % name, "", bins, -wnd[0], wnd[0]) 00502 else: 00503 hx = ROOT.TH1F("%s_x" % name, "", bins, -wnd[0], wnd[0]) 00504 hy = ROOT.TH1F("%s_y" % name, "", bins, -wnd[1], wnd[1]) 00505 hz = ROOT.TH1F("%s_z" % name, "", bins, -wnd[2], wnd[2]) 00506 hphix = ROOT.TH1F("%s_phix" % name, "", bins, -wnd[3], wnd[3]) 00507 hphiy = ROOT.TH1F("%s_phiy" % name, "", bins, -wnd[4], wnd[4]) 00508 hphiz = ROOT.TH1F("%s_phiz" % name, "", bins, -wnd[5], wnd[5]) 00509 00510 for r1 in reports1: 00511 if selection is None or (selection.func_code.co_argcount == len(r1.postal_address) and selection(*r1.postal_address)): 00512 if reports2 is None: 00513 r2 = Report(r1.chamberId, r1.postal_address, r1.name) 00514 r2.add_parameters(ValErr(0., 0., 0.), ValErr(0., 0., 0.), ValErr(0., 0., 0.), 00515 ValErr(0., 0., 0.), ValErr(0., 0., 0.), ValErr(0., 0., 0.), 0., 0., 0., 0.) 00516 else: 00517 r2 = getReportByPostalAddress(r1.postal_address, reports2) 00518 if r2 is None: continue 00519 00520 found = False 00521 if r1.postal_address[0] == "DT": 00522 if r1.postal_address[1:] in database1.dt: 00523 found = True 00524 db1 = database1.dt[r1.postal_address[1:]] 00525 if database2 is None: 00526 db2 = DTAlignable() 00527 db2.x = db2.y = db2.z = db2.phix = db2.phiy = db2.phiz = 0. 00528 db2.xx = db2.xy = db2.xz = db2.yx = db2.yy = db2.yz = db2.zx = db2.zy = db2.zz = 0. 00529 else: 00530 db2 = database2.dt[r1.postal_address[1:]] 00531 00532 else: 00533 # skip ME1/a 00534 if r1.postal_address[2]==1 and r1.postal_address[3]==4: continue 00535 if r1.postal_address[1:] in database1.csc: 00536 found = True 00537 db1 = database1.csc[r1.postal_address[1:]] 00538 if database2 is None: 00539 db2 = CSCAlignable() 00540 db2.x = db2.y = db2.z = db2.phix = db2.phiy = db2.phiz = 0. 00541 db2.xx = db2.xy = db2.xz = db2.yx = db2.yy = db2.yz = db2.zx = db2.zy = db2.zz = 0. 00542 else: 00543 db2 = database2.csc[r1.postal_address[1:]] 00544 00545 if found and r1.status == "PASS" and r2.status == "PASS": 00546 if r1.deltax is not None and r2.deltax is not None and r1.deltax.error is not None and \ 00547 r2.deltax.error is not None and (r1.deltax.error**2 + r2.deltax.error**2) > 0.: 00548 delta = db1.x - db2.x 00549 if reportdiff: delta -= r1.deltax.value 00550 if normalized: 00551 fill = delta/sqrt(r1.deltax.error**2 + r2.deltax.error**2) * signConventions[r1.postal_address][0] 00552 else: 00553 if phi: 00554 fill = delta/signConventions[r1.postal_address][3] * 1000. * signConventions[r1.postal_address][0] 00555 else: 00556 fill = delta * 10. * signConventions[r1.postal_address][0] 00557 hx.Fill(fill) 00558 if getvalues not in (False, None): 00559 getvalues["x"].append((fill, 10. * sqrt(r1.deltax.error**2 + r2.deltax.error**2))) 00560 00561 if r1.deltay is not None and r2.deltay is not None and r1.deltay.error is not None and \ 00562 r2.deltay.error is not None and (r1.deltay.error**2 + r2.deltay.error**2) > 0.: 00563 delta = db1.y - db2.y 00564 if reportdiff: delta -= r1.deltay.value 00565 if normalized: 00566 fill = delta/sqrt(r1.deltay.error**2 + r2.deltay.error**2) * signConventions[r1.postal_address][1] 00567 else: 00568 fill = delta * 10. * signConventions[r1.postal_address][1] 00569 hy.Fill(fill) 00570 if getvalues not in (False, None): 00571 getvalues["y"].append((fill, 10. * sqrt(r1.deltay.error**2 + r2.deltay.error**2))) 00572 00573 if r1.deltaz is not None and r2.deltaz is not None and r1.deltaz.error is not None and \ 00574 r2.deltaz.error is not None and (r1.deltaz.error**2 + r2.deltaz.error**2) > 0.: 00575 delta = db1.z - db2.z 00576 if reportdiff: delta -= r1.deltaz.value 00577 if normalized: 00578 fill = delta/sqrt(r1.deltaz.error**2 + r2.deltaz.error**2) * signConventions[r1.postal_address][2] 00579 else: 00580 fill = delta * 10. * signConventions[r1.postal_address][2] 00581 hz.Fill(fill) 00582 if getvalues not in (False, None): 00583 getvalues["z"].append((fill, 10. * sqrt(r1.deltaz.error**2 + r2.deltaz.error**2))) 00584 00585 if r1.deltaphix is not None and r2.deltaphix is not None and r1.deltaphix.error is not None and \ 00586 r2.deltaphix.error is not None and (r1.deltaphix.error**2 + r2.deltaphix.error**2) > 0.: 00587 delta = db1.phix - db2.phix 00588 if reportdiff: delta -= r1.deltaphix.value 00589 if normalized: 00590 fill = delta/sqrt(r1.deltaphix.error**2 + r2.deltaphix.error**2) 00591 else: 00592 fill = delta * 1000. 00593 hphix.Fill(fill) 00594 if getvalues not in (False, None): 00595 getvalues["phix"].append((fill, 10. * sqrt(r1.deltaphix.error**2 + r2.deltaphix.error**2))) 00596 00597 if r1.deltaphiy is not None and r2.deltaphiy is not None and r1.deltaphiy.error is not None and \ 00598 r2.deltaphiy.error is not None and (r1.deltaphiy.error**2 + r2.deltaphiy.error**2) > 0.: 00599 delta = db1.phiy - db2.phiy 00600 if reportdiff: 00601 delta -= r1.deltaphiy.value 00602 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 00603 if normalized: 00604 fill = delta/sqrt(r1.deltaphiy.error**2 + r2.deltaphiy.error**2) 00605 else: 00606 fill = delta * 1000. 00607 hphiy.Fill(fill) 00608 if getvalues not in (False, None): 00609 getvalues["phiy"].append((fill, 10. * sqrt(r1.deltaphiy.error**2 + r2.deltaphiy.error**2))) 00610 00611 if r1.deltaphiz is not None and r2.deltaphiz is not None and r1.deltaphiz.error is not None and \ 00612 r2.deltaphiz.error is not None and (r1.deltaphiz.error**2 + r2.deltaphiz.error**2) > 0.: 00613 delta = db1.phiz - db2.phiz 00614 if reportdiff: delta -= r1.deltaphiz.value 00615 if normalized: 00616 fill = delta/sqrt(r1.deltaphiz.error**2 + r2.deltaphiz.error**2) 00617 else: 00618 fill = delta * 1000. 00619 hphiz.Fill(fill) 00620 if getvalues not in (False, None): 00621 getvalues["phiz"].append((fill, 10. * sqrt(r1.deltaphiz.error**2 + r2.deltaphiz.error**2))) 00622 00623 if not normalized: 00624 if phi: 00625 hx.SetXTitle("#delta_{#phi} position (mrad)") 00626 else: 00627 hx.SetXTitle("#delta_{x'} (mm)") 00628 hy.SetXTitle("#delta_{y'} (mm)") 00629 hz.SetXTitle("#delta_{z'} (mm)") 00630 hphix.SetXTitle("#delta_{#phi_{x}} (mrad)") 00631 hphiy.SetXTitle("#delta_{#phi_{y}} (mrad)") 00632 hphiz.SetXTitle("#delta_{#phi_{z}} (mrad)") 00633 if reportdiff: 00634 if phi: 00635 hx.SetXTitle("#delta_{#phi}(XML) - #delta_{#phi}(report) position (mrad)") 00636 else: 00637 hx.SetXTitle("#delta_{x'}(XML) - #delta_{x'}(report) (mm)") 00638 hy.SetXTitle("#delta_{y'}(XML) - #delta_{y'}(report) (mm)") 00639 hz.SetXTitle("#delta_{z'}(XML) - #delta_{z'}(report) (mm)") 00640 hphix.SetXTitle("#delta_{#phi_{x}}(XML) - #delta_{#phi_{x}}(report) (mrad)") 00641 hphiy.SetXTitle("#delta_{#phi_{y}}(XML) - #delta_{#phi_{y}}(report) (mrad)") 00642 hphiz.SetXTitle("#delta_{#phi_{z}}(XML) - #delta_{#phi_{z}}(report) (mrad)") 00643 else: 00644 if phi: 00645 hx.SetXTitle("#delta_{#phi}/#sigma_{#phi} position") 00646 else: 00647 hx.SetXTitle("#delta_{x'}/#sigma_{x'}") 00648 hy.SetXTitle("#delta_{y'}/#sigma_{y'}") 00649 hz.SetXTitle("#delta_{z'}/#sigma_{z'}") 00650 hphix.SetXTitle("#delta_{#phi_{x}}/#sigma_{#phi_{x}}") 00651 hphiy.SetXTitle("#delta_{#phi_{y}}/#sigma_{#phi_{y}}") 00652 hphiz.SetXTitle("#delta_{#phi_{z}}/#sigma_{#phi_{z}}") 00653 00654 for h in hx, hy, hz, hphix, hphiy, hphiz: 00655 h.GetXaxis().CenterTitle() 00656 h.GetYaxis().CenterTitle() 00657 h.SetFillColor(color) 00658 h.SetLineStyle(style) 00659 00660 if canvas is not None: c = canvas 00661 else: c = c1 00662 00663 if normalized: 00664 fx = ROOT.TF1("fx", "%g * exp(-x**2/2.)/sqrt(2.*3.1415926)" % (hx.GetEntries()*2.*window/bins), -window, window) 00665 fy = ROOT.TF1("fy", "%g * exp(-x**2/2.)/sqrt(2.*3.1415926)" % (hy.GetEntries()*2.*window/bins), -window, window) 00666 fz = ROOT.TF1("fz", "%g * exp(-x**2/2.)/sqrt(2.*3.1415926)" % (hz.GetEntries()*2.*window/bins), -window, window) 00667 fphix = ROOT.TF1("fphix", "%g * exp(-x**2/2.)/sqrt(2.*3.1415926)" % (hphix.GetEntries()*2.*window/bins), -window, window) 00668 fphiy = ROOT.TF1("fphiy", "%g * exp(-x**2/2.)/sqrt(2.*3.1415926)" % (hphiy.GetEntries()*2.*window/bins), -window, window) 00669 fphiz = ROOT.TF1("fphiz", "%g * exp(-x**2/2.)/sqrt(2.*3.1415926)" % (hphiz.GetEntries()*2.*window/bins), -window, window) 00670 for f in fx, fy, fz, fphix, fphiy, fphiz: 00671 f.SetLineWidth(2) 00672 f.SetLineColor(ROOT.kBlue) 00673 for h, f in (hx, fx), (hy, fy), (hz, fz), (hphix, fphix), (hphiy, fphiy), (hphiz, fphiz): 00674 h.SetAxisRange(0, 1.1*max(h.GetMaximum(), f.GetMaximum()), "Y") 00675 00676 c.Clear() 00677 c.Divide(3, 2) 00678 c.GetPad(1).cd(); hx.Draw(); fx.Draw("same") 00679 c.GetPad(2).cd(); hy.Draw(); fy.Draw("same") 00680 c.GetPad(3).cd(); hz.Draw(); fz.Draw("same") 00681 c.GetPad(4).cd(); hphix.Draw(); fphix.Draw("same") 00682 c.GetPad(5).cd(); hphiy.Draw(); fphiy.Draw("same") 00683 c.GetPad(6).cd(); hphiz.Draw(); fphiz.Draw("same") 00684 return hx, hy, hz, hphix, hphiy, hphiz, fx, fy, fz, fphix, fphiy, fphiz 00685 else: 00686 nvar = 6 00687 00688 c.Clear() 00689 if nvar == 4: c.Divide(2, 2) 00690 if nvar == 6: c.Divide(3, 2) 00691 c.GetPad(1).cd(); hx.Draw() 00692 c.GetPad(2).cd(); hy.Draw() 00693 if nvar == 4: 00694 c.GetPad(3).cd(); hphiy.Draw() 00695 c.GetPad(4).cd(); hphiz.Draw() 00696 if nvar == 6: 00697 c.GetPad(3).cd(); hz.Draw() 00698 c.GetPad(4).cd(); hphix.Draw() 00699 c.GetPad(5).cd(); hphiy.Draw() 00700 c.GetPad(6).cd(); hphiz.Draw() 00701 00702 if inlog: 00703 if hx.GetEntries()>0: c.GetPad(1).SetLogy(1) 00704 if hy.GetEntries()>0: c.GetPad(2).SetLogy(1) 00705 if nvar == 4: 00706 if hphiy.GetEntries()>0: c.GetPad(3).SetLogy(1) 00707 if hphiz.GetEntries()>0: c.GetPad(4).SetLogy(1) 00708 if nvar == 6: 00709 if hz.GetEntries()>0: c.GetPad(3).SetLogy(1) 00710 if hphix.GetEntries()>0: c.GetPad(4).SetLogy(1) 00711 if hphiy.GetEntries()>0: c.GetPad(5).SetLogy(1) 00712 if hphiz.GetEntries()>0: c.GetPad(6).SetLogy(1) 00713 00714 return hx, hy, hz, hphix, hphiy, hphiz 00715 00716
def plotscripts::DBdiffVersus | ( | quantity, | |
versus, | |||
database1, | |||
database2, | |||
reports1, | |||
reports2, | |||
windwselection = None , |
|||
color = ROOT.kBlack |
|||
) |
Definition at line 720 of file plotscripts.py.
00721 : 00722 tdrStyle.SetOptStat("") 00723 00724 domain = [] 00725 values = [] 00726 errors = [] 00727 00728 for r1 in reports1: 00729 if selection is None or (selection.func_code.co_argcount == len(r1.postal_address) and selection(*r1.postal_address)): 00730 if reports2 is None: 00731 r2 = Report(r1.chamberId, r1.postal_address, r1.name) 00732 r2.add_parameters(ValErr(0., 0., 0.), ValErr(0., 0., 0.), ValErr(0., 0., 0.), 00733 ValErr(0., 0., 0.), ValErr(0., 0., 0.), ValErr(0., 0., 0.), 0., 0., 0.) 00734 else: 00735 found = False 00736 for r2 in reports2: 00737 if r1.postal_address == r2.postal_address: 00738 found = True 00739 break 00740 if not found: continue 00741 00742 found = False 00743 if r1.postal_address[0] == "DT": 00744 if r1.postal_address[1:] in database1.dt: 00745 found = True 00746 db1 = database1.dt[r1.postal_address[1:]] 00747 if database2 is None: 00748 db2 = DTAlignable() 00749 db2.x = db2.y = db2.z = db2.phix = db2.phiy = db2.phiz = 0. 00750 db2.xx = db2.xy = db2.xz = db2.yx = db2.yy = db2.yz = db2.zx = db2.zy = db2.zz = 0. 00751 else: 00752 db2 = database2.dt[r1.postal_address[1:]] 00753 else: 00754 if r1.postal_address[1:] in database1.csc: 00755 found = True 00756 db1 = database1.csc[r1.postal_address[1:]] 00757 if database2 is None: 00758 db2 = CSCAlignable() 00759 db2.x = db2.y = db2.z = db2.phix = db2.phiy = db2.phiz = 0. 00760 db2.xx = db2.xy = db2.xz = db2.yx = db2.yy = db2.yz = db2.zx = db2.zy = db2.zz = 0. 00761 else: 00762 db2 = database2.csc[r1.postal_address[1:]] 00763 00764 if found and r1.status == "PASS" and r2.status == "PASS": 00765 okay = False 00766 00767 if quantity == "phi": 00768 if r1.deltax is not None and r2.deltax is not None and r1.deltax.error is not None and \ 00769 r2.deltax.error is not None and (r1.deltax.error**2 + r2.deltax.error**2) > 0.: 00770 okay = True 00771 values.append((db1.x - db2.x)/ 00772 signConventions[r1.postal_address][3] * 1000. * signConventions[r1.postal_address][0]) 00773 errors.append((r1.deltax.error**2 + r2.deltax.error**2)/ 00774 signConventions[r1.postal_address][3] * 1000. * signConventions[r1.postal_address][0]) 00775 00776 elif quantity == "x": 00777 if r1.deltax is not None and r2.deltax is not None and r1.deltax.error is not None and \ 00778 r2.deltax.error is not None and (r1.deltax.error**2 + r2.deltax.error**2) > 0.: 00779 okay = True 00780 values.append((db1.x - db2.x) * 10. * signConventions[r1.postal_address][0]) 00781 errors.append((r1.deltax.error**2 + r2.deltax.error**2) * 10. * signConventions[r1.postal_address][0]) 00782 00783 elif quantity == "y": 00784 if r1.deltay is not None and r2.deltay is not None and r1.deltay.error is not None and \ 00785 r2.deltay.error is not None and (r1.deltay.error**2 + r2.deltay.error**2) > 0.: 00786 okay = True 00787 values.append((db1.y - db2.y) * 10. * signConventions[r1.postal_address][1]) 00788 errors.append((r1.deltay.error**2 + r2.deltay.error**2) * 10. * signConventions[r1.postal_address][1]) 00789 00790 elif quantity == "z": 00791 if r1.deltaz is not None and r2.deltaz is not None and r1.deltaz.error is not None and \ 00792 r2.deltaz.error is not None and (r1.deltaz.error**2 + r2.deltaz.error**2) > 0.: 00793 okay = True 00794 values.append((db1.z - db2.z) * 10. * signConventions[r1.postal_address][2]) 00795 errors.append((r1.deltaz.error**2 + r2.deltaz.error**2) * 10. * signConventions[r1.postal_address][2]) 00796 00797 elif quantity == "phix": 00798 if r1.deltaphix is not None and r2.deltaphix is not None and r1.deltaphix.error is not None and \ 00799 r2.deltaphix.error is not None and (r1.deltaphix.error**2 + r2.deltaphix.error**2) > 0.: 00800 okay = True 00801 values.append((db1.phix - db2.phix) * 1000.) 00802 errors.append((r1.deltaphix.error**2 + r2.deltaphix.error**2) * 1000.) 00803 00804 elif quantity == "phiy": 00805 if r1.deltaphiy is not None and r2.deltaphiy is not None and r1.deltaphiy.error is not None and \ 00806 r2.deltaphiy.error is not None and (r1.deltaphiy.error**2 + r2.deltaphiy.error**2) > 0.: 00807 okay = True 00808 values.append((db1.phiy - db2.phiy) * 1000.) 00809 errors.append((r1.deltaphiy.error**2 + r2.deltaphiy.error**2) * 1000.) 00810 00811 elif quantity == "phiz": 00812 if r1.deltaphiz is not None and r2.deltaphiz is not None and r1.deltaphiz.error is not None and \ 00813 r2.deltaphiz.error is not None and (r1.deltaphiz.error**2 + r2.deltaphiz.error**2) > 0.: 00814 okay = True 00815 values.append((db1.phiz - db2.phiz) * 1000.) 00816 errors.append((r1.deltaphiz.error**2 + r2.deltaphiz.error**2) * 1000.) 00817 00818 else: raise Exception 00819 00820 if okay: 00821 if versus == "r": domain.append(signConventions[r1.postal_address][3]) 00822 elif versus == "phi": domain.append(signConventions[r1.postal_address][4]) 00823 elif versus == "z": domain.append(signConventions[r1.postal_address][5]) 00824 else: raise Exception 00825 00826 if versus == "r": 00827 bkgndhist = ROOT.TH1F("bkgndhist", "", 100, 0., 800.) 00828 bkgndhist.SetXTitle("R (cm)") 00829 elif versus == "phi": 00830 bkgndhist = ROOT.TH1F("bkgndhist", "", 100, -pi, pi) 00831 bkgndhist.SetXTitle("#phi (rad)") 00832 elif versus == "z": 00833 bkgndhist = ROOT.TH1F("bkgndhist", "", 100, -1100., 1100.) 00834 bkgndhist.SetXTitle("z (cm)") 00835 bkgndhist.GetXaxis().CenterTitle() 00836 00837 bkgndhist.SetAxisRange(-window, window, "Y") 00838 if quantity == "phi": bkgndhist.SetYTitle("#delta_{#phi} position (mrad)") 00839 elif quantity == "x": bkgndhist.SetYTitle("#delta_{x'} (mm)") 00840 elif quantity == "y": bkgndhist.SetYTitle("#delta_{y'} (mm)") 00841 elif quantity == "z": bkgndhist.SetYTitle("#delta_{z'} (mm)") 00842 elif quantity == "phix": bkgndhist.SetYTitle("#delta_{#phi_{x}} (mrad)") 00843 elif quantity == "phiy": bkgndhist.SetYTitle("#delta_{#phi_{y}} (mrad)") 00844 elif quantity == "phiz": bkgndhist.SetYTitle("#delta_{#phi_{z}} (mrad)") 00845 else: raise Exception 00846 bkgndhist.GetYaxis().CenterTitle() 00847 00848 if len(domain) == 0: 00849 tgraph = ROOT.TGraphErrors(0) 00850 else: 00851 tgraph = ROOT.TGraphErrors(len(domain), array.array("d", domain), array.array("d", values), 00852 array.array("d", [0.]*len(domain)), array.array("d", errors)) 00853 tgraph.SetMarkerColor(color) 00854 tgraph.SetLineColor(color) 00855 00856 bkgndhist.Draw() 00857 if tgraph.GetN() > 0: tgraph.Draw("p") 00858 return bkgndhist, tgraph, domain, values, errors
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 477 of file plotscripts.py.
def plotscripts::DBMCVersus | ( | quantity, | |
versus, | |||
database, | |||
reports, | |||
window = 10. , |
|||
selection = None , |
|||
color = ROOT.kBlack |
|||
) |
Definition at line 717 of file plotscripts.py.
def plotscripts::doTests | ( | reports, | |
pic_ids, | |||
fname_base, | |||
fname_dqm, | |||
run_name | |||
) |
Definition at line 1215 of file plotscripts.py.
01216 : 01217 # find available baseline 01218 dts = [] 01219 cscs = [] 01220 if len(reports)>0: 01221 dts = availableCellsDT(reports) 01222 cscs = availableCellsCSC(reports) 01223 elif len(pic_ids)>0: 01224 dts = [id for id in pic_ids if 'MB' in id] 01225 cscs = [id for id in pic_ids if 'ME' in id] 01226 mulist = ['Run: '+run_name,['ALL',['MU']],['DT',dts],['CSC',cscs]] 01227 ff = open(fname_base,mode="w") 01228 print >>ff, "var MU_LIST = [" 01229 json.dump(mulist,ff) 01230 print >>ff, "];" 01231 ff.close() 01232 01233 doTestsForReport(dts,reports) 01234 doTestsForReport(cscs,reports) 01235 01236 loadTestResultsMap(run_name) 01237 doTestsForMapPlots(dts) 01238 doTestsForMapPlots(cscs) 01239 01240 writeDQMReport(fname_dqm, run_name) 01241
def plotscripts::doTestsForMapPlots | ( | cells | ) |
Definition at line 1142 of file plotscripts.py.
01143 : 01144 for c in cells: 01145 res = [] 01146 01147 scope = "zzz" 01148 if c[0:2]=="MB": scope = "DT" 01149 if c[0:2]=="ME": scope = "CSC" 01150 if scope == "zzz": 01151 print "strange cell ID: ", c 01152 return None 01153 01154 if MAP_RESULTS_FITSIN.has_key(c): 01155 t = MAP_RESULTS_FITSIN[c] 01156 t_a = testZeroWithin5Sigma(t['a']) 01157 t_s = testZeroWithin5Sigma(t['sin']) 01158 t_c = testZeroWithin5Sigma(t['cos']) 01159 if t_a+t_s+t_c >0: 01160 descr = "map fitsin 5 sigma away from 0; pulls : a=%.2f sin=%.2f, cos=%.2f" % (t_a,t_s,t_c) 01161 res.append(testEntry("MAP_FITSIN",scope,descr,"SEVERE")) 01162 01163 if MAP_RESULTS_SAWTOOTH.has_key(c): 01164 t = MAP_RESULTS_SAWTOOTH[c] 01165 01166 t_a = testDeltaWithin5Sigma(t['a'],t['da']) 01167 if len(t_a)>0: 01168 descr = "map discontinuities: %s" % ",".join(map(str,t_a)) 01169 res.append(testEntry("MAP_DISCONTIN",scope,descr,"SEVERE")) 01170 01171 t_b = map(testZeroWithin5Sigma, t['b']) 01172 t_bi = [] 01173 for i in range(0,len(t_b)): 01174 if t_b[i]>0: t_bi.append(i+1) 01175 if len(t_bi)>0: 01176 descr = "map sawteeth: %s" % ",".join(map(str,t_bi)) 01177 res.append(testEntry("MAP_SAWTEETH",scope,descr,"TOLERABLE")) 01178 01179 addToTestResults(c,res) 01180
def plotscripts::doTestsForReport | ( | cells, | |
reports | |||
) |
Definition at line 1078 of file plotscripts.py.
01079 : 01080 for c in cells: 01081 # can a cell be converted to a chamber postal address? 01082 postal_address = idToPostalAddress(c) 01083 if not postal_address: continue 01084 01085 # is this chamber in _report? 01086 found = False 01087 for r in reports: 01088 if r.postal_address == postal_address: 01089 found = True 01090 break 01091 if not found: continue 01092 01093 # chamber's tests result 01094 res = [] 01095 scope = postal_address[0] 01096 01097 # noting could be done if fitting fails 01098 if r.status == "FAIL" or r.status == "MINUITFAIL": 01099 res.append(testEntry("FAILURE",scope,r.status+" failure","CRITICAL")) 01100 addToTestResults(c,res) 01101 continue 01102 01103 # noting could be done if TOOFEWHITS 01104 nseg = r.posNum + r.negNum 01105 if r.status == "TOOFEWHITS" and nseg>0: 01106 res.append(testEntry("LOW_STAT",scope,"low stat, #segments=%d"%nseg,"LOWSTAT")) 01107 addToTestResults(c,res) 01108 continue 01109 01110 # set shades of light green according to sidma(dx) 01111 sdx = 10.*r.deltax.error 01112 if sdx>0.5: 01113 if sdx<0.75: res.append(testEntry("LOW_STAT_DDX05",scope,"low stat, delta(dx)=%f #segments=%d" % (sdx,nseg),"LOWSTAT05")) 01114 elif sdx<1.: res.append(testEntry("LOW_STAT_DDX075",scope,"low stat, delta(dx)=%f #segments=%d" % (sdx,nseg),"LOWSTAT075")) 01115 else: res.append(testEntry("LOW_STAT_DDX1",scope,"low stat, delta(dx)=%f #segments=%d" % (sdx,nseg),"LOWSTAT1")) 01116 01117 # check chi2 01118 if r.redchi2 > 20.: #2.5: 01119 res.append(testEntry("BIG_CHI2",scope,"chi2=%f>20" % r.redchi2,"TOLERABLE")) 01120 01121 # check medians 01122 medx, meddx = 10.*r.median_x, 1000.*r.median_dxdz 01123 #medy, meddy = 10.*r.median_y, 1000.*r.median_dydz 01124 if medx>2: res.append(testEntry("BIG_MED_X",scope,"median dx=%f>2 mm"%medx,"SEVERE")) 01125 #if medy>3: res.append(testEntry("BIG_MED_Y",scope,"median dy=%f>3 mm"%medy,"SEVERE")) 01126 if meddx>2: res.append(testEntry("BIG_MED_DXDZ",scope,"median d(dx/dz)=%f>2 mrad"%meddx,"SEVERE")) 01127 #if meddy>3: res.append(testEntry("BIG_MED_DYDZ",scope,"median d(dy/dz)=%f>3 mrad"%meddy,"SEVERE")) 01128 01129 # check residuals far from zero 01130 isDTst4 = False 01131 if postal_address[0] == "DT" and postal_address[2]==4: isDTst4 = True 01132 dx, dy, dpy, dpz = 10.*r.deltax.value, 0., 1000.*r.deltaphiy.value, 1000.*r.deltaphiz.value 01133 if not isDTst4: dy = 10.*r.deltay.value 01134 if dx>0.2: res.append(testEntry("BIG_LAST_ITR_DX",scope,"dx=%f>0.2 mm"%dx,"CRITICAL")) 01135 if dy>0.2: res.append(testEntry("BIG_LAST_ITR_DY",scope,"dy=%f>0.2 mm"%dy,"CRITICAL")) 01136 if dpy>0.2: res.append(testEntry("BIG_LAST_ITR_DPHIY",scope,"dphiy=%f>0.2 mrad"%dpy,"CRITICAL")) 01137 if dpz>0.2: res.append(testEntry("BIG_LAST_ITR_DPHIZ",scope,"dphiz=%f>0.2 mrad"%dpz,"CRITICAL")) 01138 #if ddx>0.03: res.append(testEntry("BIG_DX",scope,"dphix=%f>0.03 mrad"%ddx,"CRITICAL")) 01139 01140 addToTestResults(c,res) 01141
def plotscripts::getname | ( | r | ) |
Definition at line 2032 of file plotscripts.py.
02033 : 02034 if r.postal_address[0] == "DT": 02035 wheel, station, sector = r.postal_address[1:] 02036 return "DT wheel %d, station %d, sector %d" % (wheel, station, sector) 02037 elif r.postal_address[0] == "CSC": 02038 endcap, station, ring, chamber = r.postal_address[1:] 02039 if endcap != 1: station = -1 * abs(station) 02040 return "CSC ME%d/%d chamber %d" % (station, ring, chamber) 02041 ddt=[0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.]
def plotscripts::getReportByPostalAddress | ( | postal_address, | |
report | |||
) |
Definition at line 468 of file plotscripts.py.
def plotscripts::idToPostalAddress | ( | id | ) |
Definition at line 861 of file plotscripts.py.
00862 : 00863 # only len==9 ids can correspond to valid postal address 00864 if len(id)!=9: return None 00865 if id[0:2]=="MB": 00866 #print id 00867 pa = ("DT", int(id[2:4]), int(id[5]), int(id[7:9])) 00868 #print pa 00869 if pa[1]<-2 or pa[1]>2: return None 00870 if pa[2]>4: return None 00871 if pa[3]<1 or pa[3]>14 or (pa[3]==4 and pa[3]>12): return None 00872 return pa 00873 elif id[0:2]=="ME": 00874 if id[2]=="+": ec=1 00875 elif id[2]=="-": ec=2 00876 else: return None 00877 pa = ("CSC", ec, int(id[3]), int(id[5]), int(id[7:9])) 00878 if pa[2]<1 or pa[2]>4: return None 00879 if pa[3]<1 or pa[3]>4 or (pa[2]>1 and pa[3]>2): return None 00880 if pa[4]<1 or pa[4]>36 or (pa[2]>1 and pa[3]==1 and pa[4]>18): return None 00881 return pa 00882 else: return None 00883
def plotscripts::loadTestResultsMap | ( | run_name | ) |
Definition at line 1189 of file plotscripts.py.
01190 : 01191 print "tmp_test_results_map__%s.pkl" % run_name, os.access("tmp_test_results_map__%s.pkl" % run_name,os.F_OK) 01192 if not os.access("tmp_test_results_map__%s.pkl" % run_name,os.F_OK): return None 01193 global MAP_RESULTS_FITSIN, MAP_RESULTS_SAWTOOTH 01194 ff = open("tmp_test_results_map__%s.pkl" % run_name, "rb") 01195 MAP_RESULTS_SAWTOOTH = pickle.load(ff) 01196 MAP_RESULTS_FITSIN = pickle.load(ff) 01197 ff.close() 01198 #execfile("tmp_test_results_map__%s.py" % run_name) 01199 #print 'asasas', MAP_RESULTS_FITSIN 01200 return True
def plotscripts::mapNameToId | ( | name | ) |
Definition at line 1761 of file plotscripts.py.
01762 : 01763 if "DT" in name: 01764 wh = "-ALL" 01765 if name.find('wh')>1: wh = name[name.find('wh')+2] 01766 if wh == "A": w = "-2" 01767 elif wh == "B": w = "-1" 01768 elif wh == "C": w = "-0" 01769 elif wh == "D": w = "+1" 01770 elif wh == "E": w = "+2" 01771 elif wh == "-ALL": w = "-ALL" 01772 else: return None 01773 station='' 01774 if wh == "-ALL": 01775 if name.find('sec')<0: return None 01776 station = name[name.find('sec')-1] 01777 sector = '' 01778 sector = name[name.find('sec')+3:name.find('sec')+5] 01779 return "MB%s/%s/%s" % (w, station, sector) 01780 if name.find('st')>1: station = name[name.find('st')+2] 01781 else: return None 01782 return "MB%s/%s" % (w, station) 01783 elif "CSC" in name: 01784 p = name.find('me') 01785 if p<0: return None 01786 if name[p+2]=="p": endcap = "+" 01787 elif name[p+2]=="m": endcap = "-" 01788 else: return None 01789 station = name[p+3] 01790 pch = name.find('ch') 01791 if pch<0: 01792 ring = name[p+4] 01793 return "ME%s%s/%s" % (endcap, station, ring) 01794 ring = 'ALL' 01795 chamber = name[pch+2:pch+4] 01796 return "ME%s%s/%s/%s" % (endcap, station, ring, chamber) 01797 return None 01798
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 1444 of file plotscripts.py.
01445 {}, **args): 01446 tdrStyle.SetOptTitle(1) 01447 tdrStyle.SetTitleBorderSize(0) 01448 tdrStyle.SetOptStat(0) 01449 #tdrStyle.SetOptStat("emrou") 01450 tdrStyle.SetOptFit(0) 01451 tdrStyle.SetTitleFontSize(0.05) 01452 tdrStyle.SetPadRightMargin(0.1) # to see the pallete labels on the left 01453 01454 c1.Clear() 01455 c1.ResetAttPad() 01456 01457 if reset_palette: set_palette("blues") 01458 global hist, hist2d, hist2dweight, tline1, tline2, tline3 01459 01460 if fitsine or fitsawteeth: 01461 id = mapNameToId(name) 01462 if not id: 01463 print "bad id for ", name 01464 raise Exception 01465 01466 hdir = "AlignmentMonitorMuonSystemMap1D/iter1/" 01467 hpref= "%s_%s" % (name, param) 01468 hhh = hdir+hpref 01469 01470 combine_all = False 01471 if "ALL" in name and ("CSCvsr" in name or "DTvsz" in name): combine_all = True 01472 01473 add1d = ("vsphi" in name) and (param == "x") 01474 01475 if "h2d" in args: 01476 hist2d = args["h2d"].Clone(hpref+"_2d_") 01477 if "CSC" in name and add1d: hist1d = args["h1d"].Clone(hpref+"_1d_") 01478 01479 elif combine_all: 01480 nch = 12 01481 if "DT" in name and name[6:9]=='st4': nch = 14 01482 if "CSC" in name: nch = 36 01483 chambers = ["%02d" % ch for ch in range (2,nch+1)] 01484 01485 ch_hhh = hhh.replace('ALL','01') 01486 ch_hpref = hpref.replace('ALL','01') 01487 hist2d = tfiles[0].Get(ch_hhh+"_2d").Clone(ch_hpref+"_2d_") 01488 if "CSC" in name and add1d: hist1d = tfiles[0].Get(ch_hhh+"_1d").Clone(ch_hpref+"_1d_") 01489 01490 for ch in chambers: 01491 ch_hhh = hhh.replace('ALL',ch) 01492 ch_hpref = hpref.replace('ALL',ch) 01493 hist2d.Add(tfiles[0].Get(ch_hhh+"_2d")) 01494 if "CSC" in name and add1d: hist1d.Add(tfiles[0].Get(ch_hhh+"_1d")) 01495 for tfile in tfiles[1:]: 01496 hist2d.Add(tfile.Get(ch_hhh+"_2d")) 01497 if "CSC" in name and add1d: hist1d.Add(tfile.Get(ch_hhh+"_1d")) 01498 01499 else: 01500 hist2d = tfiles[0].Get(hhh+"_2d").Clone(hpref+"_2d_") 01501 if "CSC" in name and add1d: hist1d = tfiles[0].Get(hhh+"_1d").Clone(hpref+"_1d_") 01502 for tfile in tfiles[1:]: 01503 hist2d.Add(tfile.Get(hhh+"_2d")) 01504 if "CSC" in name and add1d: hist1d.Add(tfile.Get(hhh+"_1d")) 01505 01506 01507 if mode == "from2d": 01508 the2d = hist2d 01509 01510 hist = the2d.ProjectionX() 01511 hist.Reset() 01512 01513 skip = 1 01514 if widebins: 01515 hist.Rebin(10) 01516 skip = 10 01517 01518 #f = ROOT.TF1("g", "gaus", -40., 40) 01519 for i in xrange(0, int(the2d.GetNbinsX()), skip): 01520 tmp = the2d.ProjectionY("tmp", i+1, i + skip) 01521 if tmp.GetEntries() > 1: 01522 #tmp.Fit("g","LNq") 01523 hist.SetBinContent(i/skip+1, tmp.GetMean()) 01524 hist.SetBinError(i/skip+1, ROOT.TMath.StudentQuantile(0.841345,tmp.GetEntries()) * tmp.GetRMS() / sqrt(tmp.GetEntries())) 01525 #hist.SetBinError(i/skip+1, tmp.GetRMS() / sqrt(tmp.GetEntries())) 01526 #hist.SetBinError(i/skip+1, f.GetParameter(2)) 01527 else: 01528 #hist.SetBinContent(i/skip+1, 2000.) 01529 #hist.SetBinError(i/skip+1, 1000.) 01530 hist.SetBinContent(i/skip+1, 0.) 01531 hist.SetBinError(i/skip+1, 0.) 01532 01533 hpeaks = createPeaksProfile(the2d, peaksbins) 01534 01535 else: 01536 raise Exception 01537 01538 hist.SetAxisRange(-window, window, "Y") 01539 if abscissa is not None: hist.SetAxisRange(abscissa[0], abscissa[1], "X") 01540 hist.SetMarkerStyle(20) 01541 hist.SetMarkerSize(0.75) 01542 hist.GetXaxis().CenterTitle() 01543 hist.GetYaxis().CenterTitle() 01544 hist.GetYaxis().SetTitleOffset(0.75) 01545 hist.GetXaxis().SetTitleSize(0.05) 01546 hist.GetYaxis().SetTitleSize(0.05) 01547 hist.SetTitle(title) 01548 if "vsphi" in name: hist.SetXTitle("Global #phi position (rad)") 01549 elif "vsz" in name: hist.SetXTitle("Global z position (cm)") 01550 elif "vsr" in name: hist.SetXTitle("Global R position (cm)") 01551 if "DT" in name: 01552 if param == "x": hist.SetYTitle("x' residual (mm)") 01553 if param == "dxdz": hist.SetYTitle("dx'/dz residual (mrad)") 01554 if param == "y": hist.SetYTitle("y' residual (mm)") 01555 if param == "dydz": hist.SetYTitle("dy'/dz residual (mrad)") 01556 if "CSC" in name: 01557 if param == "x": hist.SetYTitle("r#phi residual (mm)") 01558 if param == "dxdz": hist.SetYTitle("d(r#phi)/dz residual (mrad)") 01559 hist.SetMarkerColor(ROOT.kBlack) 01560 hist.SetLineColor(ROOT.kBlack) 01561 hist.Draw() 01562 hist2d.Draw("colzsame") 01563 if widebins: hist.Draw("samee1") 01564 else: hist.Draw("same") 01565 01566 hpeaks.SetMarkerStyle(20) 01567 hpeaks.SetMarkerSize(0.9) 01568 hpeaks.SetMarkerColor(ROOT.kRed) 01569 hpeaks.SetLineColor(ROOT.kRed) 01570 hpeaks.SetLineWidth(2) 01571 #if fitpeaks: hpeaks.Draw("same") 01572 hpeaks.Draw("same") 01573 01574 if fitsine and "vsphi" in name: 01575 global fitsine_const, fitsine_sin, fitsine_cos, fitsine_chi2, fitsine_ndf 01576 if 'CSC' in name: 01577 f = ROOT.TF1("f", "[0] + [1]*sin(x) + [2]*cos(x)", -pi/180.*5., pi*(2.-5./180.)) 01578 else: 01579 f = ROOT.TF1("f", "[0] + [1]*sin(x) + [2]*cos(x)", -pi, pi) 01580 f.SetLineColor(ROOT.kRed) 01581 f.SetLineWidth(2) 01582 if len(fixfitpars)>0: 01583 for fpar in fixfitpars.keys(): 01584 f.FixParameter(fpar, fixfitpars[fpar]) 01585 #hist.Fit(f,"N") 01586 if fitpeaks: hpeaks.Fit(f,"NQ") 01587 else: hist.Fit(f,"NEQ") 01588 if len(fixfitpars)>0: 01589 for fpar in fixfitpars.keys(): 01590 f.ReleaseParameter(fpar) 01591 fitsine_const = f.GetParameter(0), f.GetParError(0) 01592 fitsine_sin = f.GetParameter(1), f.GetParError(1) 01593 fitsine_cos = f.GetParameter(2), f.GetParError(2) 01594 fitsine_chi2 = f.GetChisquare() 01595 fitsine_ndf = f.GetNDF() 01596 global MAP_RESULTS_FITSIN 01597 # 'phi' coefficienct will be updated further for CSC 01598 MAP_RESULTS_FITSIN[id] = {'a':fitsine_const, 'phi':fitsine_const, 'sin': fitsine_sin, 'cos': fitsine_cos, 'chi2': fitsine_chi2, 'ndf': fitsine_ndf} 01599 f.Draw("same") 01600 global fitsine_ttext, fitsine_etext 01601 text_xposition = -1. 01602 if 'CSC' in name: text_xposition = 2. 01603 fitsine_ttext = ROOT.TLatex(text_xposition, 0.8*window, 01604 "%+.3f %+.3f sin#phi %+.3f cos#phi" % (fitsine_const[0], fitsine_sin[0], fitsine_cos[0])) 01605 fitsine_ttext.SetTextColor(ROOT.kRed) 01606 fitsine_ttext.SetTextSize(0.05) 01607 fitsine_ttext.Draw() 01608 fitsine_etext = ROOT.TLatex(text_xposition, 0.70*window, 01609 " #pm%.3f #pm%.3f #pm%.3f" % (fitsine_const[1], fitsine_sin[1], fitsine_cos[1])) 01610 fitsine_etext.SetTextColor(ROOT.kRed) 01611 fitsine_etext.SetTextSize(0.045) 01612 fitsine_etext.Draw() 01613 01614 # additional estimate of phiz ring rotation from 1d distribution 01615 if 'CSC' in name and add1d: 01616 # zero-order rough fit to obtain the fitting range: 01617 f0 = ROOT.TF1("f0", "gaus", hist1d.GetBinLowEdge(1), -hist1d.GetBinLowEdge(1)) 01618 fit = hist1d.Fit(f0,"NRQ") 01619 rangea, rangeb = hist1d.GetMean() - hist1d.GetRMS(), hist1d.GetMean() + hist1d.GetRMS() 01620 if fit==0: rangea, rangeb = f0.GetParameter(1) - f0.GetParameter(2), f0.GetParameter(1) + f0.GetParameter(2) 01621 #print rangea, rangeb 01622 01623 # second fit for finding the peak: 01624 f1 = ROOT.TF1("f1", "gaus", rangea, rangeb) 01625 fit = hist1d.Fit(f1,"NRQ") 01626 nn = hist1d.GetEntries() 01627 dphiz, ephiz = 0, 0 01628 if nn>0: dphiz, ephiz = hist1d.GetMean(), ROOT.TMath.StudentQuantile(0.841345,nn) * hist1d.GetRMS() / sqrt(nn) 01629 if fit==0: dphiz, ephiz = f1.GetParameter(1), f1.GetParError(1) 01630 #print dphiz, ephiz 01631 MAP_RESULTS_FITSIN[id]['phi'] = (dphiz, ephiz) 01632 01633 global ttex_sine_, ttex_sine, ttex_1d_, ttex_1d 01634 postal_address = idToPostalAddress(id+'/01') 01635 ttex_sine_ = ROOT.TLatex(0, 0.8*window,"#Delta#phi_{z}^{sine} (mrad):") 01636 ttex_sine_.SetTextColor(ROOT.kGreen+2); ttex_sine_.SetTextSize(0.04); ttex_sine_.Draw() 01637 ttex_sine = ROOT.TLatex(0, 0.7*window," %+.3f#pm%.3f" % 01638 (-100*fitsine_const[0]/signConventions[postal_address][3], 01639 100*fitsine_const[1]/signConventions[postal_address][3])) 01640 ttex_sine.SetTextColor(ROOT.kGreen+2); ttex_sine.SetTextSize(0.04); ttex_sine.Draw() 01641 ttex_1d_ = ROOT.TLatex(0, 0.6*window,"#Delta#phi_{z}^{phi} (mrad):") 01642 ttex_1d_.SetTextColor(ROOT.kGreen+2); ttex_1d_.SetTextSize(0.04); ttex_1d_.Draw() 01643 ttex_1d = ROOT.TLatex(0, 0.5*window," %+.3f#pm%.3f" % (-dphiz, ephiz)) 01644 ttex_1d.SetTextColor(ROOT.kGreen+2); ttex_1d.SetTextSize(0.04); ttex_1d.Draw() 01645 ROOT.gPad.Update() 01646 01647 if fitline: 01648 f = ROOT.TF1("f", "[0] + [1]*x", -1000., 1000.) 01649 hist2d.Fit(f, "q") 01650 hist2d.GetFunction("f").SetLineColor(ROOT.kRed) 01651 global fitline_const, fitline_linear, fitline_chi2, fitline_ndf 01652 fitline_const = hist2d.GetFunction("f").GetParameter(0), hist2d.GetFunction("f").GetParError(0) 01653 fitline_linear = hist2d.GetFunction("f").GetParameter(1), hist2d.GetFunction("f").GetParError(1) 01654 fitline_chi2 = hist2d.GetFunction("f").GetChisquare() 01655 fitline_ndf = hist2d.GetFunction("f").GetNDF() 01656 hist2d.GetFunction("f").Draw("same") 01657 global fitline_ttext 01658 if "vsz" in name: which = "Z" 01659 elif "vsr" in name: which = "R" 01660 fitline_ttext = ROOT.TText(hist.GetBinCenter(hist.GetNbinsX()/4), 01661 0.8*window, "%.3g %+.3g %s" % (fitline_const[0], fitline_linear[0], which)) 01662 fitline_ttext.SetTextColor(ROOT.kRed) 01663 fitline_ttext.Draw() 01664 01665 ROOT.gPad.RedrawAxis() 01666 01667 if "vsphi" in name: 01668 if not widebins: philines(name, window, abscissa) 01669 if abscissa is None: 01670 if 'CSC' in name: 01671 tline1 = ROOT.TLine(-pi/180.*5., 0, pi*(2.-5./180.), 0); tline1.Draw() 01672 tline2 = ROOT.TLine(-pi/180.*5., -window, pi*(2.-5./180.), -window); tline2.SetLineWidth(2); tline2.Draw() 01673 tline3 = ROOT.TLine(-pi/180.*5., window, pi*(2.-5./180.), window); tline3.Draw() 01674 else: 01675 tline1 = ROOT.TLine(-pi, 0, pi, 0); tline1.Draw() 01676 tline2 = ROOT.TLine(-pi, -window, pi, -window); tline2.SetLineWidth(2); tline2.Draw() 01677 tline3 = ROOT.TLine(-pi, window, pi, window); tline3.Draw() 01678 else: 01679 tline1 = ROOT.TLine(abscissa[0], 0, abscissa[1], 0); tline1.Draw() 01680 tline2 = ROOT.TLine(abscissa[0], -window, abscissa[1], -window); tline2.SetLineWidth(2); tline2.Draw() 01681 tline3 = ROOT.TLine(abscissa[0], window, abscissa[1], window); tline3.Draw() 01682 elif "vsz" in name: 01683 if not widebins: zlines(window, abscissa) 01684 if abscissa is None: 01685 tline1 = ROOT.TLine(-660, 0, 660, 0); tline1.Draw() 01686 tline2 = ROOT.TLine(-660, -window, 660, -window); tline2.SetLineWidth(2); tline2.Draw() 01687 tline3 = ROOT.TLine(-660, window, 660, window); tline3.Draw() 01688 else: 01689 tline1 = ROOT.TLine(abscissa[0], 0, abscissa[1], 0); tline1.Draw() 01690 tline2 = ROOT.TLine(abscissa[0], -window, abscissa[1], -window); tline2.SetLineWidth(2); tline2.Draw() 01691 tline3 = ROOT.TLine(abscissa[0], window, abscissa[1], window); tline3.Draw() 01692 elif "vsr" in name: 01693 if "mem1" in name or "mep1" in name and not widebins: rlines(1, window, abscissa) 01694 if "mem2" in name or "mep2" in name and not widebins: rlines(2, window, abscissa) 01695 if "mem3" in name or "mep3" in name and not widebins: rlines(3, window, abscissa) 01696 if "mem4" in name or "mep4" in name and not widebins: rlines(4, window, abscissa) 01697 if abscissa is None: 01698 tline1 = ROOT.TLine(100, 0, 700, 0); tline1.Draw() 01699 tline2 = ROOT.TLine(100, -window, 700, -window); tline2.SetLineWidth(2); tline2.Draw() 01700 tline3 = ROOT.TLine(100, window, 700, window); tline3.Draw() 01701 else: 01702 tline1 = ROOT.TLine(abscissa[0], 0, abscissa[1], 0); tline1.Draw() 01703 tline2 = ROOT.TLine(abscissa[0], -window, abscissa[1], -window); tline2.SetLineWidth(2); tline2.Draw() 01704 tline3 = ROOT.TLine(abscissa[0], window, abscissa[1], window); tline3.Draw() 01705 01706 if "vsphi" in name and fitsawteeth: 01707 global CPP_LOADED 01708 if not CPP_LOADED: 01709 phiedges2c() 01710 ROOT.gROOT.ProcessLine(".L phiedges_fitfunctions.C++") 01711 CPP_LOADED = True 01712 fn={0: ROOT.fitf0, 01713 1: ROOT.fitf2, 01714 2: ROOT.fitf2, 01715 3: ROOT.fitf3, 01716 4: ROOT.fitf4, 01717 5: ROOT.fitf5, 01718 6: ROOT.fitf6, 01719 7: ROOT.fitf7, 01720 8: ROOT.fitf8, 01721 9: ROOT.fitf9, 01722 10: ROOT.fitf10, 01723 11: ROOT.fitf11, 01724 12: ROOT.fitf12, 01725 13: ROOT.fitf13 01726 } [stationIndex(name)] 01727 fn.SetNpx(5000) 01728 fn.SetLineColor(ROOT.kYellow) 01729 hist.Fit(fn,"N") 01730 fn.Draw("same") 01731 01732 # get properly arranged phi edges 01733 edges = (phiedges[stationIndex(name)])[:] 01734 ed = sorted(edges) 01735 # add some padding to the end 01736 ed.append(pi+abs(ed[0])) 01737 01738 global sawtooth_a, sawtooth_b 01739 sawtooth_a = [] 01740 sawtooth_da = [] 01741 sawtooth_b = [] 01742 for pr in range(0,fn.GetNpar(),2): 01743 sawtooth_a.append( (fn.GetParameter(pr), fn.GetParError(pr)) ) 01744 sawtooth_b.append( (fn.GetParameter(pr+1), fn.GetParError(pr+1)) ) 01745 sawtooth_da.append( (fn.Eval(ed[pr/2]+0.01), fn.Eval(ed[pr/2+1]-0.01)) ) 01746 global MAP_RESULTS_SAWTOOTH 01747 MAP_RESULTS_SAWTOOTH[id] = {'a': sawtooth_a, 'da': sawtooth_da, 'b': sawtooth_b, 'chi2': fn.GetChisquare(), 'ndf': fn.GetNDF()} 01748 01749 # fill number of contributiong bins 01750 01751 01752 #ROOT.SetOwnership(hist,False) 01753 ROOT.SetOwnership(hist2d,False) 01754 ROOT.SetOwnership(hist,False) 01755 ROOT.SetOwnership(tline1,False) 01756 ROOT.SetOwnership(tline2,False) 01757 ROOT.SetOwnership(tline3,False) 01758 return hist 01759 01760
def plotscripts::mean | ( | xlist | ) |
Definition at line 53 of file plotscripts.py.
def plotscripts::nameToId | ( | name | ) |
Definition at line 896 of file plotscripts.py.
00897 : 00898 if name[0:2] == "MB": 00899 wh = name[4] 00900 if wh == "A": w = "-2" 00901 elif wh == "B": w = "-1" 00902 elif wh == "C": w = "-0" 00903 elif wh == "D": w = "+1" 00904 elif wh == "E": w = "+2" 00905 else: return "" 00906 station = name[7] 00907 sector = name[11:13] 00908 return "MB%s/%s/%s" % (w, station, sector) 00909 elif name[0:2] == "ME": 00910 if name[2]=="p": endcap = "+" 00911 elif name[2]=="m": endcap = "-" 00912 else: return "" 00913 station = name[3] 00914 ring = name[4] 00915 chamber = name[6:8] 00916 return "ME%s%s/%s/%s" % (endcap, station, ring, chamber) 00917 return None 00918
def plotscripts::phiedges2c | ( | ) |
Definition at line 316 of file plotscripts.py.
00317 : 00318 lines = [] 00319 for ed in phiedges[:]: 00320 ed.sort() 00321 #print ed 00322 ed.extend([999 for n in range(0,37-len(ed))]) 00323 lines.append('{' + ', '.join(map(str, ed)) + '}') 00324 #print lines 00325 res = ', '.join(lines) 00326 ff = open("phiedges_export.h",mode="w") 00327 print>>ff,'double phiedges[14][37] = {' + res + '};' 00328 ff.close()
def plotscripts::philines | ( | name, | |
window, | |||
abscissa | |||
) |
Definition at line 392 of file plotscripts.py.
00393 : 00394 global philine_tlines, philine_labels 00395 philine_tlines = [] 00396 edges = phiedges[stationIndex(name)] 00397 #print name, len(edges) 00398 for phi in edges: 00399 if abscissa is None or abscissa[0] < phi < abscissa[1]: 00400 philine_tlines.append(ROOT.TLine(phi, -window, phi, window)) 00401 philine_tlines[-1].SetLineStyle(2) 00402 philine_tlines[-1].Draw() 00403 if "st" in name: # DT labels 00404 philine_labels = [] 00405 edges = edges[:] 00406 edges.sort() 00407 if "st4" in name: 00408 labels = [" 7", " 8", " 9", "14", "10", "11", "12", " 1", " 2", " 3", "13", " 4", " 5", " 6"] 00409 else: 00410 labels = [" 8", " 9", "10", "11", "12", " 1", " 2", " 3", " 4", " 5", " 6"] 00411 edges = edges[1:] 00412 for phi, label in zip(edges, labels): 00413 littlebit = 0. 00414 if label in (" 7", " 9", "14", "10", "11"): littlebit = 0.05 00415 philine_labels.append(ROOT.TText(phi-0.35+littlebit, -0.9*window, label)) 00416 philine_labels[-1].Draw() 00417 philine_labels.append(ROOT.TText(-2.9, -0.75*window, "Sector:")) 00418 philine_labels[-1].Draw() 00419 if "CSC" in name: # DT labels 00420 philine_labels = [] 00421 edges = edges[:] 00422 edges.sort() 00423 labels = [" 1", " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "10", "11", "12", "13", "14", "15", "16", "17", "18", 00424 "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36"] 00425 #else: 00426 # labels = [" 8", " 9", "10", "11", "12", " 1", " 2", " 3", " 4", " 5", " 6"] 00427 # edges = edges[1:] 00428 for phi, label in zip(edges, labels): 00429 littlebit = 0. 00430 #if label in (" 7", " 9", "14", "10", "11"): littlebit = 0.05 00431 philine_labels.append(ROOT.TText(phi+littlebit, -0.9*window, label)) 00432 philine_labels[-1].SetTextFont(42) 00433 philine_labels[-1].SetTextSize(0.028) 00434 philine_labels[-1].Draw() 00435 philine_labels.append(ROOT.TText(0, -0.78*window, "Chamber:")) 00436 philine_labels[-1].SetTextSize(0.035) 00437 philine_labels[-1].Draw()
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 1244 of file plotscripts.py.
01247 : 01248 tdrStyle.SetOptStat("emrou") 01249 tdrStyle.SetStatW(0.40) 01250 tdrStyle.SetStatFontSize(0.05) 01251 01252 global hmediandxdz_after, hmediandxdz_before, hmediandxdz_beforecopy, \ 01253 hmediandydz_after, hmediandydz_before, hmediandydz_beforecopy, \ 01254 hmedianx_after, hmedianx_before, hmedianx_beforecopy, \ 01255 hmediany_after, hmediany_before, hmediany_beforecopy, tlegend 01256 01257 hmedianx_before = ROOT.TH1F("hmedianx_before", "", binsx, -windowx, windowx) 01258 hmediany_before = ROOT.TH1F("hmediany_before", "", binsy, -windowy, windowy) 01259 hmediandxdz_before = ROOT.TH1F("hmediandxdz_before", "", binsdxdz, -windowdxdz, windowdxdz) 01260 hmediandydz_before = ROOT.TH1F("hmediandydz_before", "", binsdydz, -windowdydz, windowdydz) 01261 hmedianx_after = ROOT.TH1F("hmedianx_after", "", binsx, -windowx, windowx) 01262 hmediany_after = ROOT.TH1F("hmediany_after", "", binsy, -windowy, windowy) 01263 hmediandxdz_after = ROOT.TH1F("hmediandxdz_after", "", binsdxdz, -windowdxdz, windowdxdz) 01264 hmediandydz_after = ROOT.TH1F("hmediandydz_after", "", binsdydz, -windowdydz, windowdydz) 01265 01266 if which == "median": 01267 whichx = whichy = whichdxdz = whichdydz = "median" 01268 elif which == "bigmean": 01269 whichx = "mean30" 01270 whichy = "mean30" 01271 whichdxdz = "mean20" 01272 whichdydz = "mean50" 01273 elif which == "mean": 01274 whichx = "mean15" 01275 whichy = "mean15" 01276 whichdxdz = "mean10" 01277 whichdydz = "mean25" 01278 elif which == "bigwmean": 01279 whichx = "wmean30" 01280 whichy = "wmean30" 01281 whichdxdz = "wmean20" 01282 whichdydz = "wmean50" 01283 elif which == "wmean": 01284 whichx = "wmean15" 01285 whichy = "wmean15" 01286 whichdxdz = "wmean10" 01287 whichdydz = "wmean25" 01288 elif which == "bigstdev": 01289 whichx = "stdev30" 01290 whichy = "stdev30" 01291 whichdxdz = "stdev20" 01292 whichdydz = "stdev50" 01293 elif which == "stdev": 01294 whichx = "stdev15" 01295 whichy = "stdev15" 01296 whichdxdz = "stdev10" 01297 whichdydz = "stdev25" 01298 else: 01299 raise Exception, which + " not recognized" 01300 01301 for r1 in reports1: 01302 if selection is None or (selection.func_code.co_argcount == len(r1.postal_address) and selection(*r1.postal_address)): 01303 found = False 01304 for r2 in reports2: 01305 if r1.postal_address == r2.postal_address: 01306 found = True 01307 break 01308 if not found: continue 01309 01310 #skip ME1/1a 01311 if r1.postal_address[0]=='CSC': 01312 if r1.postal_address[2]==1 and r1.postal_address[3]==4: continue 01313 01314 if r1.status == "PASS" and r2.status == "PASS": 01315 hmedianx_before.Fill(10.*eval("r1.%s_x" % whichx)) 01316 hmediandxdz_before.Fill(1000.*eval("r1.%s_dxdz" % whichdxdz)) 01317 hmedianx_after.Fill(10.*eval("r2.%s_x" % whichx)) 01318 hmediandxdz_after.Fill(1000.*eval("r2.%s_dxdz" % whichdxdz)) 01319 01320 if r1.median_y is not None: 01321 hmediany_before.Fill(10.*eval("r1.%s_y" % whichy)) 01322 hmediandydz_before.Fill(1000.*eval("r1.%s_dydz" % whichdydz)) 01323 hmediany_after.Fill(10.*eval("r2.%s_y" % whichy)) 01324 hmediandydz_after.Fill(1000.*eval("r2.%s_dydz" % whichdydz)) 01325 01326 hmedianx_beforecopy = hmedianx_before.Clone() 01327 hmediany_beforecopy = hmediany_before.Clone() 01328 hmediandxdz_beforecopy = hmediandxdz_before.Clone() 01329 hmediandydz_beforecopy = hmediandydz_before.Clone() 01330 hmedianx_beforecopy.SetLineStyle(2) 01331 hmediany_beforecopy.SetLineStyle(2) 01332 hmediandxdz_beforecopy.SetLineStyle(2) 01333 hmediandydz_beforecopy.SetLineStyle(2) 01334 01335 hmedianx_before.SetFillColor(ROOT.kMagenta+2) 01336 hmediany_before.SetFillColor(ROOT.kMagenta+2) 01337 hmediandxdz_before.SetFillColor(ROOT.kMagenta+2) 01338 hmediandydz_before.SetFillColor(ROOT.kMagenta+2) 01339 hmedianx_after.SetFillColor(ROOT.kYellow) 01340 hmediany_after.SetFillColor(ROOT.kYellow) 01341 hmediandxdz_after.SetFillColor(ROOT.kYellow) 01342 hmediandydz_after.SetFillColor(ROOT.kYellow) 01343 01344 hmedianx_after.SetXTitle("median(#Deltax) (mm)") 01345 hmediany_after.SetXTitle("median(#Deltay) (mm)") 01346 hmediandxdz_after.SetXTitle("median(#Deltadx/dz) (mrad)") 01347 hmediandydz_after.SetXTitle("median(#Deltadydz) (mrad)") 01348 hmedianx_after.GetXaxis().CenterTitle() 01349 hmediany_after.GetXaxis().CenterTitle() 01350 hmediandxdz_after.GetXaxis().CenterTitle() 01351 hmediandydz_after.GetXaxis().CenterTitle() 01352 01353 if ceilingx is not None: hmedianx_after.SetAxisRange(0., ceilingx, "Y") 01354 if ceilingy is not None: hmediany_after.SetAxisRange(0., ceilingy, "Y") 01355 if ceilingdxdz is not None: hmediandxdz_after.SetAxisRange(0., ceilingdxdz, "Y") 01356 if ceilingdydz is not None: hmediandydz_after.SetAxisRange(0., ceilingdydz, "Y") 01357 01358 c1.Clear() 01359 c1.Divide(2, 2) 01360 01361 c1.GetPad(1).cd() 01362 hmedianx_after.Draw() 01363 hmedianx_before.Draw("same") 01364 hmedianx_after.Draw("same") 01365 hmedianx_beforecopy.Draw("same") 01366 hmedianx_after.Draw("axissame") 01367 01368 tlegend = ROOT.TLegend(0.17, 0.75-0.05, 0.45+0.05, 0.9) 01369 tlegend.SetFillColor(ROOT.kWhite) 01370 tlegend.SetBorderSize(0) 01371 tlegend.AddEntry(hmedianx_after, r2text, "f") 01372 tlegend.AddEntry(hmedianx_before, r1text, "f") 01373 tlegend.Draw() 01374 01375 c1.GetPad(2).cd() 01376 hmediandxdz_after.Draw() 01377 hmediandxdz_before.Draw("same") 01378 hmediandxdz_after.Draw("same") 01379 hmediandxdz_beforecopy.Draw("same") 01380 hmediandxdz_after.Draw("axissame") 01381 01382 c1.GetPad(3).cd() 01383 hmediany_after.Draw() 01384 hmediany_before.Draw("same") 01385 hmediany_after.Draw("same") 01386 hmediany_beforecopy.Draw("same") 01387 hmediany_after.Draw("axissame") 01388 01389 c1.GetPad(4).cd() 01390 hmediandydz_after.Draw() 01391 hmediandydz_before.Draw("same") 01392 hmediandydz_after.Draw("same") 01393 hmediandydz_beforecopy.Draw("same") 01394 hmediandydz_after.Draw("axissame") 01395 01396 return hmediandxdz_after, hmediandxdz_before, hmediandxdz_beforecopy, \ 01397 hmediandydz_after, hmediandydz_before, hmediandydz_beforecopy, \ 01398 hmedianx_after, hmedianx_before, hmedianx_beforecopy, \ 01399 hmediany_after, hmediany_before, hmediany_beforecopy, tlegend 01400
def plotscripts::polynomials | ( | tfile, | |
reports, | |||
name, | |||
twobin = True , |
|||
suppressblue = False |
|||
) |
Definition at line 2272 of file plotscripts.py.
02273 : 02274 t1 = time.time() 02275 ddt[7] += 1 02276 global label1, label2, label3, label4, label5, label6, label7, label8, label9 02277 plotDirectory = "MuonAlignmentFromReference" 02278 tdrStyle.SetOptTitle(1) 02279 tdrStyle.SetTitleBorderSize(1) 02280 tdrStyle.SetTitleFontSize(0.1) 02281 tdrStyle.SetOptStat(0) 02282 02283 c1.Clear() 02284 c1.ResetAttPad() 02285 02286 found = False 02287 for r in reports: 02288 if r.name == name: 02289 found = True 02290 break 02291 if not found: raise Exception, "Not a valid name" 02292 02293 if r.status == "FAIL": 02294 #raise Exception, "Fit failed" 02295 print "Fit failed" 02296 c1.Clear() 02297 return 02298 02299 Pos = "Pos"; Neg = "Neg" 02300 if not twobin: 02301 Pos = ""; Neg = "" 02302 02303 pdirPos = "MuonAlignmentFromReference/%s%s" % (name, Pos) 02304 pdirNeg = "MuonAlignmentFromReference/%s%s" % (name, Neg) 02305 02306 global chamber_x_trackx, chamber_x_trackx_fit, chamber_y_trackx, chamber_y_trackx_fit, \ 02307 chamber_dxdz_trackx, chamber_dxdz_trackx_fit, chamber_dydz_trackx, chamber_dydz_trackx_fit, \ 02308 chamber_x_trackx_fit2, chamber_y_trackx_fit2, chamber_dxdz_trackx_fit2, chamber_dydz_trackx_fit2 02309 global chamber_x_tracky, chamber_x_tracky_fit, chamber_y_tracky, chamber_y_tracky_fit, \ 02310 chamber_dxdz_tracky, chamber_dxdz_tracky_fit, chamber_dydz_tracky, chamber_dydz_tracky_fit, \ 02311 chamber_x_tracky_fit2, chamber_y_tracky_fit2, chamber_dxdz_tracky_fit2, chamber_dydz_tracky_fit2 02312 global chamber_x_trackdxdz, chamber_x_trackdxdz_fit, chamber_y_trackdxdz, chamber_y_trackdxdz_fit, \ 02313 chamber_dxdz_trackdxdz, chamber_dxdz_trackdxdz_fit, chamber_dydz_trackdxdz, chamber_dydz_trackdxdz_fit, \ 02314 chamber_x_trackdxdz_fit2, chamber_y_trackdxdz_fit2, chamber_dxdz_trackdxdz_fit2, chamber_dydz_trackdxdz_fit2 02315 global chamber_x_trackdydz, chamber_x_trackdydz_fit, chamber_y_trackdydz, chamber_y_trackdydz_fit, \ 02316 chamber_dxdz_trackdydz, chamber_dxdz_trackdydz_fit, chamber_dydz_trackdydz, chamber_dydz_trackdydz_fit, \ 02317 chamber_x_trackdydz_fit2, chamber_y_trackdydz_fit2, chamber_dxdz_trackdydz_fit2, chamber_dydz_trackdydz_fit2 02318 02319 chamber_x_trackx = tfile.Get(pdirPos+"_x_trackx") 02320 chamber_x_trackx_fit = tfile.Get(pdirPos+"_x_trackx_fitline") 02321 chamber_y_trackx = tfile.Get(pdirPos+"_y_trackx") 02322 chamber_y_trackx_fit = tfile.Get(pdirPos+"_y_trackx_fitline") 02323 chamber_dxdz_trackx = tfile.Get(pdirPos+"_dxdz_trackx") 02324 chamber_dxdz_trackx_fit = tfile.Get(pdirPos+"_dxdz_trackx_fitline") 02325 chamber_dydz_trackx = tfile.Get(pdirPos+"_dydz_trackx") 02326 chamber_dydz_trackx_fit = tfile.Get(pdirPos+"_dydz_trackx_fitline") 02327 chamber_x_trackx_fit2 = tfile.Get(pdirNeg+"_x_trackx_fitline") 02328 chamber_y_trackx_fit2 = tfile.Get(pdirNeg+"_y_trackx_fitline") 02329 chamber_dxdz_trackx_fit2 = tfile.Get(pdirNeg+"_dxdz_trackx_fitline") 02330 chamber_dydz_trackx_fit2 = tfile.Get(pdirNeg+"_dydz_trackx_fitline") 02331 02332 chamber_x_tracky = tfile.Get(pdirPos+"_x_tracky") 02333 chamber_x_tracky_fit = tfile.Get(pdirPos+"_x_tracky_fitline") 02334 chamber_y_tracky = tfile.Get(pdirPos+"_y_tracky") 02335 chamber_y_tracky_fit = tfile.Get(pdirPos+"_y_tracky_fitline") 02336 chamber_dxdz_tracky = tfile.Get(pdirPos+"_dxdz_tracky") 02337 chamber_dxdz_tracky_fit = tfile.Get(pdirPos+"_dxdz_tracky_fitline") 02338 chamber_dydz_tracky = tfile.Get(pdirPos+"_dydz_tracky") 02339 chamber_dydz_tracky_fit = tfile.Get(pdirPos+"_dydz_tracky_fitline") 02340 chamber_x_tracky_fit2 = tfile.Get(pdirNeg+"_x_tracky_fitline") 02341 chamber_y_tracky_fit2 = tfile.Get(pdirNeg+"_y_tracky_fitline") 02342 chamber_dxdz_tracky_fit2 = tfile.Get(pdirNeg+"_dxdz_tracky_fitline") 02343 chamber_dydz_tracky_fit2 = tfile.Get(pdirNeg+"_dydz_tracky_fitline") 02344 02345 chamber_x_trackdxdz = tfile.Get(pdirPos+"_x_trackdxdz") 02346 chamber_x_trackdxdz_fit = tfile.Get(pdirPos+"_x_trackdxdz_fitline") 02347 chamber_y_trackdxdz = tfile.Get(pdirPos+"_y_trackdxdz") 02348 chamber_y_trackdxdz_fit = tfile.Get(pdirPos+"_y_trackdxdz_fitline") 02349 chamber_dxdz_trackdxdz = tfile.Get(pdirPos+"_dxdz_trackdxdz") 02350 chamber_dxdz_trackdxdz_fit = tfile.Get(pdirPos+"_dxdz_trackdxdz_fitline") 02351 chamber_dydz_trackdxdz = tfile.Get(pdirPos+"_dydz_trackdxdz") 02352 chamber_dydz_trackdxdz_fit = tfile.Get(pdirPos+"_dydz_trackdxdz_fitline") 02353 chamber_x_trackdxdz_fit2 = tfile.Get(pdirNeg+"_x_trackdxdz_fitline") 02354 chamber_y_trackdxdz_fit2 = tfile.Get(pdirNeg+"_y_trackdxdz_fitline") 02355 chamber_dxdz_trackdxdz_fit2 = tfile.Get(pdirNeg+"_dxdz_trackdxdz_fitline") 02356 chamber_dydz_trackdxdz_fit2 = tfile.Get(pdirNeg+"_dydz_trackdxdz_fitline") 02357 02358 chamber_x_trackdydz = tfile.Get(pdirPos+"_x_trackdydz") 02359 chamber_x_trackdydz_fit = tfile.Get(pdirPos+"_x_trackdydz_fitline") 02360 chamber_y_trackdydz = tfile.Get(pdirPos+"_y_trackdydz") 02361 chamber_y_trackdydz_fit = tfile.Get(pdirPos+"_y_trackdydz_fitline") 02362 chamber_dxdz_trackdydz = tfile.Get(pdirPos+"_dxdz_trackdydz") 02363 chamber_dxdz_trackdydz_fit = tfile.Get(pdirPos+"_dxdz_trackdydz_fitline") 02364 chamber_dydz_trackdydz = tfile.Get(pdirPos+"_dydz_trackdydz") 02365 chamber_dydz_trackdydz_fit = tfile.Get(pdirPos+"_dydz_trackdydz_fitline") 02366 chamber_x_trackdydz_fit2 = tfile.Get(pdirNeg+"_x_trackdydz_fitline") 02367 chamber_y_trackdydz_fit2 = tfile.Get(pdirNeg+"_y_trackdydz_fitline") 02368 chamber_dxdz_trackdydz_fit2 = tfile.Get(pdirNeg+"_dxdz_trackdydz_fitline") 02369 chamber_dydz_trackdydz_fit2 = tfile.Get(pdirNeg+"_dydz_trackdydz_fitline") 02370 02371 if not chamber_x_trackx: 02372 chamber_x_trackx = tfile.Get(pdirPos+"_residual_trackx") 02373 chamber_x_trackx_fit = tfile.Get(pdirPos+"_residual_trackx_fitline") 02374 chamber_dxdz_trackx = tfile.Get(pdirPos+"_resslope_trackx") 02375 chamber_dxdz_trackx_fit = tfile.Get(pdirPos+"_resslope_trackx_fitline") 02376 chamber_x_trackx_fit2 = tfile.Get(pdirNeg+"_residual_trackx_fitline") 02377 chamber_dxdz_trackx_fit2 = tfile.Get(pdirNeg+"_resslope_trackx_fitline") 02378 02379 chamber_x_tracky = tfile.Get(pdirPos+"_residual_tracky") 02380 chamber_x_tracky_fit = tfile.Get(pdirPos+"_residual_tracky_fitline") 02381 chamber_dxdz_tracky = tfile.Get(pdirPos+"_resslope_tracky") 02382 chamber_dxdz_tracky_fit = tfile.Get(pdirPos+"_resslope_tracky_fitline") 02383 chamber_x_tracky_fit2 = tfile.Get(pdirNeg+"_residual_tracky_fitline") 02384 chamber_dxdz_tracky_fit2 = tfile.Get(pdirNeg+"_resslope_tracky_fitline") 02385 02386 chamber_x_trackdxdz = tfile.Get(pdirPos+"_residual_trackdxdz") 02387 chamber_x_trackdxdz_fit = tfile.Get(pdirPos+"_residual_trackdxdz_fitline") 02388 chamber_dxdz_trackdxdz = tfile.Get(pdirPos+"_resslope_trackdxdz") 02389 chamber_dxdz_trackdxdz_fit = tfile.Get(pdirPos+"_resslope_trackdxdz_fitline") 02390 chamber_x_trackdxdz_fit2 = tfile.Get(pdirNeg+"_residual_trackdxdz_fitline") 02391 chamber_dxdz_trackdxdz_fit2 = tfile.Get(pdirNeg+"_resslope_trackdxdz_fitline") 02392 02393 chamber_x_trackdydz = tfile.Get(pdirPos+"_residual_trackdydz") 02394 chamber_x_trackdydz_fit = tfile.Get(pdirPos+"_residual_trackdydz_fitline") 02395 chamber_dxdz_trackdydz = tfile.Get(pdirPos+"_resslope_trackdydz") 02396 chamber_dxdz_trackdydz_fit = tfile.Get(pdirPos+"_resslope_trackdydz_fitline") 02397 chamber_x_trackdydz_fit2 = tfile.Get(pdirNeg+"_residual_trackdydz_fitline") 02398 chamber_dxdz_trackdydz_fit2 = tfile.Get(pdirNeg+"_resslope_trackdydz_fitline") 02399 02400 if not chamber_x_trackx: 02401 print "Can't find neither "+pdirPos+"_residual nor "+pdirPos+"_residual_trackx" 02402 return 02403 02404 chamber_x_trackx = chamber_x_trackx.Clone() 02405 chamber_dxdz_trackx = chamber_dxdz_trackx.Clone() 02406 chamber_x_tracky = chamber_x_tracky.Clone() 02407 chamber_dxdz_tracky = chamber_dxdz_tracky.Clone() 02408 chamber_x_trackdxdz = chamber_x_trackdxdz.Clone() 02409 chamber_dxdz_trackdxdz = chamber_dxdz_trackdxdz.Clone() 02410 chamber_x_trackdydz = chamber_x_trackdydz.Clone() 02411 chamber_dxdz_trackdydz = chamber_dxdz_trackdydz.Clone() 02412 02413 if not not chamber_y_trackx: 02414 chamber_y_trackx = chamber_y_trackx.Clone() 02415 chamber_dydz_trackx = chamber_dydz_trackx.Clone() 02416 chamber_y_tracky = chamber_y_tracky.Clone() 02417 chamber_dydz_tracky = chamber_dydz_tracky.Clone() 02418 chamber_y_trackdxdz = chamber_y_trackdxdz.Clone() 02419 chamber_dydz_trackdxdz = chamber_dydz_trackdxdz.Clone() 02420 chamber_y_trackdydz = chamber_y_trackdydz.Clone() 02421 chamber_dydz_trackdydz = chamber_dydz_trackdydz.Clone() 02422 02423 if not not chamber_y_trackx: 02424 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_x_trackx")); chamber_x_trackx.Merge(tlist) 02425 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_dxdz_trackx")); chamber_dxdz_trackx.Merge(tlist) 02426 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_x_tracky")); chamber_x_tracky.Merge(tlist) 02427 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_dxdz_tracky")); chamber_dxdz_tracky.Merge(tlist) 02428 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_x_trackdxdz")); chamber_x_trackdxdz.Merge(tlist) 02429 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_dxdz_trackdxdz")); chamber_dxdz_trackdxdz.Merge(tlist) 02430 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_x_trackdydz")); chamber_x_trackdydz.Merge(tlist) 02431 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_dxdz_trackdydz")); chamber_dxdz_trackdydz.Merge(tlist) 02432 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_y_trackx")); chamber_y_trackx.Merge(tlist) 02433 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_dydz_trackx")); chamber_dydz_trackx.Merge(tlist) 02434 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_y_tracky")); chamber_y_tracky.Merge(tlist) 02435 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_dydz_tracky")); chamber_dydz_tracky.Merge(tlist) 02436 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_y_trackdxdz")); chamber_y_trackdxdz.Merge(tlist) 02437 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_dydz_trackdxdz")); chamber_dydz_trackdxdz.Merge(tlist) 02438 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_y_trackdydz")); chamber_y_trackdydz.Merge(tlist) 02439 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_dydz_trackdydz")); chamber_dydz_trackdydz.Merge(tlist) 02440 else: 02441 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_residual_trackx")); chamber_x_trackx.Merge(tlist) 02442 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_resslope_trackx")); chamber_dxdz_trackx.Merge(tlist) 02443 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_residual_tracky")); chamber_x_tracky.Merge(tlist) 02444 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_resslope_tracky")); chamber_dxdz_tracky.Merge(tlist) 02445 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_residual_trackdxdz")); chamber_x_trackdxdz.Merge(tlist) 02446 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_resslope_trackdxdz")); chamber_dxdz_trackdxdz.Merge(tlist) 02447 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_residual_trackdydz")); chamber_x_trackdydz.Merge(tlist) 02448 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+"_resslope_trackdydz")); chamber_dxdz_trackdydz.Merge(tlist) 02449 02450 rr1=10. 02451 rr2=10. 02452 chamber_x_trackx.SetAxisRange(-rr1, rr1, "Y") 02453 chamber_dxdz_trackx.SetAxisRange(-rr2, rr2, "Y") 02454 chamber_x_tracky.SetAxisRange(-rr1, rr1, "Y") 02455 chamber_dxdz_tracky.SetAxisRange(-rr2, rr2, "Y") 02456 chamber_x_trackdxdz.SetAxisRange(-rr1, rr1, "Y") 02457 chamber_dxdz_trackdxdz.SetAxisRange(-rr2, rr2, "Y") 02458 chamber_x_trackdydz.SetAxisRange(-rr1, rr1, "Y") 02459 chamber_dxdz_trackdydz.SetAxisRange(-rr2, rr2, "Y") 02460 02461 rr3=10. 02462 if not not chamber_y_trackx: 02463 chamber_y_trackx.SetAxisRange(-rr3, rr3, "Y") 02464 chamber_dydz_trackx.SetAxisRange(-rr3, rr3, "Y") 02465 chamber_y_tracky.SetAxisRange(-rr3, rr3, "Y") 02466 chamber_dydz_tracky.SetAxisRange(-rr3, rr3, "Y") 02467 chamber_y_trackdxdz.SetAxisRange(-rr3, rr3, "Y") 02468 chamber_dydz_trackdxdz.SetAxisRange(-rr3, rr3, "Y") 02469 chamber_y_trackdydz.SetAxisRange(-rr3, rr3, "Y") 02470 chamber_dydz_trackdydz.SetAxisRange(-rr3, rr3, "Y") 02471 02472 for h in chamber_x_trackx, chamber_y_trackx, chamber_dxdz_trackx, chamber_dydz_trackx, \ 02473 chamber_x_tracky, chamber_y_tracky, chamber_dxdz_tracky, chamber_dydz_tracky, \ 02474 chamber_x_trackdxdz, chamber_y_trackdxdz, chamber_dxdz_trackdxdz, chamber_dydz_trackdxdz, \ 02475 chamber_x_trackdydz, chamber_y_trackdydz, chamber_dxdz_trackdydz, chamber_dydz_trackdydz: 02476 if not not h: 02477 h.SetMarkerStyle(20) 02478 h.SetMarkerSize(0.5) 02479 h.GetXaxis().SetLabelSize(0.12) 02480 h.GetYaxis().SetLabelSize(0.12) 02481 h.GetXaxis().SetNdivisions(505) 02482 h.GetYaxis().SetNdivisions(505) 02483 h.GetXaxis().SetLabelOffset(0.03) 02484 h.GetYaxis().SetLabelOffset(0.03) 02485 02486 trackdxdz_minimum, trackdxdz_maximum = None, None 02487 for h in chamber_x_trackdxdz, chamber_y_trackdxdz, chamber_dxdz_trackdxdz, chamber_dydz_trackdxdz: 02488 if not not h: 02489 for i in xrange(1, h.GetNbinsX()+1): 02490 if h.GetBinError(i) > 0.01 and h.GetBinContent(i) - h.GetBinError(i) < 10. and \ 02491 h.GetBinContent(i) + h.GetBinError(i) > -10.: 02492 if not trackdxdz_minimum or trackdxdz_minimum > h.GetBinCenter(i): 02493 trackdxdz_minimum = h.GetBinCenter(i) 02494 if trackdxdz_maximum < h.GetBinCenter(i): 02495 trackdxdz_maximum = h.GetBinCenter(i) 02496 if not not trackdxdz_minimum and not not trackdxdz_maximum: 02497 for h in chamber_x_trackdxdz, chamber_y_trackdxdz, chamber_dxdz_trackdxdz, chamber_dydz_trackdxdz: 02498 if not not h: 02499 h.SetAxisRange(trackdxdz_minimum, trackdxdz_maximum, "X") 02500 02501 trackdydz_minimum, trackdydz_maximum = None, None 02502 for h in chamber_x_trackdydz, chamber_y_trackdydz, chamber_dxdz_trackdydz, chamber_dydz_trackdydz: 02503 if not not h: 02504 for i in xrange(1, h.GetNbinsX()+1): 02505 if h.GetBinError(i) > 0.01 and h.GetBinContent(i) - h.GetBinError(i) < 10. and \ 02506 h.GetBinContent(i) + h.GetBinError(i) > -10.: 02507 if not trackdydz_minimum or trackdydz_minimum > h.GetBinCenter(i): 02508 trackdydz_minimum = h.GetBinCenter(i) 02509 if trackdydz_maximum < h.GetBinCenter(i): 02510 trackdydz_maximum = h.GetBinCenter(i) 02511 if not not trackdydz_minimum and not not trackdydz_maximum: 02512 for h in chamber_x_trackdydz, chamber_y_trackdydz, chamber_dxdz_trackdydz, chamber_dydz_trackdydz: 02513 if not not h: 02514 h.SetAxisRange(trackdydz_minimum, trackdydz_maximum, "X") 02515 02516 for f in chamber_x_trackx_fit2, chamber_y_trackx_fit2, chamber_dxdz_trackx_fit2, chamber_dydz_trackx_fit2, \ 02517 chamber_x_tracky_fit2, chamber_y_tracky_fit2, chamber_dxdz_tracky_fit2, chamber_dydz_tracky_fit2, \ 02518 chamber_x_trackdxdz_fit2, chamber_y_trackdxdz_fit2, chamber_dxdz_trackdxdz_fit2, chamber_dydz_trackdxdz_fit2, \ 02519 chamber_x_trackdydz_fit2, chamber_y_trackdydz_fit2, chamber_dxdz_trackdydz_fit2, chamber_dydz_trackdydz_fit2: 02520 if not not f: 02521 f.SetLineColor(4) 02522 02523 if not not chamber_y_trackx: 02524 c1.Clear() 02525 #c1.Divide(5, 5, 1e-5, 1e-5) 02526 pads = [None] 02527 pads.append(ROOT.TPad("p1" ,"",0.00,0.78,0.07,1.00,0,0,0)) 02528 pads.append(ROOT.TPad("p2" ,"",0.07,0.78,0.34,1.00,0,0,0)) 02529 pads.append(ROOT.TPad("p3" ,"",0.34,0.78,0.56,1.00,0,0,0)) 02530 pads.append(ROOT.TPad("p4" ,"",0.56,0.78,0.78,1.00,0,0,0)) 02531 pads.append(ROOT.TPad("p5" ,"",0.78,0.78,1.00,1.00,0,0,0)) 02532 pads.append(ROOT.TPad("p6" ,"",0.00,0.56,0.07,0.78,0,0,0)) 02533 pads.append(ROOT.TPad("p7" ,"",0.07,0.56,0.34,0.78,0,0,0)) 02534 pads.append(ROOT.TPad("p8" ,"",0.34,0.56,0.56,0.78,0,0,0)) 02535 pads.append(ROOT.TPad("p9" ,"",0.56,0.56,0.78,0.78,0,0,0)) 02536 pads.append(ROOT.TPad("p10","",0.78,0.56,1.00,0.78,0,0,0)) 02537 pads.append(ROOT.TPad("p11","",0.00,0.34,0.07,0.56,0,0,0)) 02538 pads.append(ROOT.TPad("p12","",0.07,0.34,0.34,0.56,0,0,0)) 02539 pads.append(ROOT.TPad("p13","",0.34,0.34,0.56,0.56,0,0,0)) 02540 pads.append(ROOT.TPad("p14","",0.56,0.34,0.78,0.56,0,0,0)) 02541 pads.append(ROOT.TPad("p15","",0.78,0.34,1.00,0.56,0,0,0)) 02542 pads.append(ROOT.TPad("p16","",0.00,0.07,0.07,0.34,0,0,0)) 02543 pads.append(ROOT.TPad("p17","",0.07,0.07,0.34,0.34,0,0,0)) 02544 pads.append(ROOT.TPad("p18","",0.34,0.07,0.56,0.34,0,0,0)) 02545 pads.append(ROOT.TPad("p19","",0.56,0.07,0.78,0.34,0,0,0)) 02546 pads.append(ROOT.TPad("p20","",0.78,0.07,1.00,0.34,0,0,0)) 02547 pads.append(ROOT.TPad("p21","",0.00,0.00,0.07,0.07,0,0,0)) 02548 pads.append(ROOT.TPad("p22","",0.07,0.00,0.34,0.07,0,0,0)) 02549 pads.append(ROOT.TPad("p23","",0.34,0.00,0.56,0.07,0,0,0)) 02550 pads.append(ROOT.TPad("p24","",0.56,0.00,0.78,0.07,0,0,0)) 02551 pads.append(ROOT.TPad("p25","",0.78,0.00,1.00,0.07,0,0,0)) 02552 for p in pads: 02553 if not not p: 02554 p.Draw() 02555 ROOT.SetOwnership(p,False) 02556 02557 label1 = ROOT.TPaveLabel(0, 0, 1, 1, "x residuals (mm)","") 02558 label2 = ROOT.TPaveLabel(0, 0, 1, 1, "y residuals (mm)","") 02559 label3 = ROOT.TPaveLabel(0, 0, 1, 1, "dx/dz residuals (mrad)","") 02560 label4 = ROOT.TPaveLabel(0, 0, 1, 1, "dy/dz residuals (mrad)","") 02561 label5 = ROOT.TPaveLabel(0, 0, 1, 1, "x position (cm)","") 02562 label6 = ROOT.TPaveLabel(0, 0, 1, 1, "y position (cm)","") 02563 label7 = ROOT.TPaveLabel(0, 0, 1, 1, "dx/dz angle (rad)","") 02564 label8 = ROOT.TPaveLabel(0, 0, 1, 1, "dy/dz angle (rad)","") 02565 label9 = ROOT.TPaveLabel(0, 0.85, 1, 1, getname(r),"NDC") 02566 02567 for l in label1, label2, label3, label4, label5, label6, label7, label8, label9: 02568 l.SetBorderSize(0) 02569 l.SetFillColor(ROOT.kWhite) 02570 02571 for l in label1, label2, label3, label4: 02572 l.SetTextAngle(90) 02573 l.SetTextSize(0.09) 02574 02575 #label9.SetTextAngle(30) 02576 label9.SetTextSize(0.59) 02577 02578 pads[1].cd(); label1.Draw() 02579 pads[6].cd(); label2.Draw() 02580 pads[11].cd(); label3.Draw() 02581 pads[16].cd(); label4.Draw() 02582 pads[22].cd(); label5.Draw() 02583 pads[23].cd(); label6.Draw() 02584 pads[24].cd(); label7.Draw() 02585 pads[25].cd(); label8.Draw() 02586 02587 pads[2].SetRightMargin(1e-5) 02588 pads[2].SetBottomMargin(1e-5) 02589 pads[2].SetLeftMargin(0.17) 02590 pads[3].SetLeftMargin(1e-5) 02591 pads[3].SetRightMargin(1e-5) 02592 pads[3].SetBottomMargin(1e-5) 02593 pads[4].SetLeftMargin(1e-5) 02594 pads[4].SetRightMargin(1e-5) 02595 pads[4].SetBottomMargin(1e-5) 02596 pads[5].SetLeftMargin(1e-5) 02597 pads[5].SetBottomMargin(1e-5) 02598 02599 pads[7].SetRightMargin(1e-5) 02600 pads[7].SetBottomMargin(1e-5) 02601 pads[7].SetTopMargin(1e-5) 02602 pads[7].SetLeftMargin(0.17) 02603 pads[8].SetLeftMargin(1e-5) 02604 pads[8].SetRightMargin(1e-5) 02605 pads[8].SetBottomMargin(1e-5) 02606 pads[8].SetTopMargin(1e-5) 02607 pads[9].SetLeftMargin(1e-5) 02608 pads[9].SetRightMargin(1e-5) 02609 pads[9].SetBottomMargin(1e-5) 02610 pads[9].SetTopMargin(1e-5) 02611 pads[10].SetLeftMargin(1e-5) 02612 pads[10].SetBottomMargin(1e-5) 02613 pads[10].SetTopMargin(1e-5) 02614 02615 pads[12].SetRightMargin(1e-5) 02616 pads[12].SetBottomMargin(1e-5) 02617 pads[12].SetTopMargin(1e-5) 02618 pads[12].SetLeftMargin(0.17) 02619 pads[13].SetLeftMargin(1e-5) 02620 pads[13].SetRightMargin(1e-5) 02621 pads[13].SetBottomMargin(1e-5) 02622 pads[13].SetTopMargin(1e-5) 02623 pads[14].SetLeftMargin(1e-5) 02624 pads[14].SetRightMargin(1e-5) 02625 pads[14].SetBottomMargin(1e-5) 02626 pads[14].SetTopMargin(1e-5) 02627 pads[15].SetLeftMargin(1e-5) 02628 pads[15].SetBottomMargin(1e-5) 02629 pads[15].SetTopMargin(1e-5) 02630 02631 pads[17].SetRightMargin(1e-5) 02632 pads[17].SetTopMargin(1e-5) 02633 pads[17].SetLeftMargin(0.17) 02634 pads[18].SetLeftMargin(1e-5) 02635 pads[18].SetRightMargin(1e-5) 02636 pads[18].SetTopMargin(1e-5) 02637 pads[19].SetLeftMargin(1e-5) 02638 pads[19].SetRightMargin(1e-5) 02639 pads[19].SetTopMargin(1e-5) 02640 pads[20].SetLeftMargin(1e-5) 02641 pads[20].SetTopMargin(1e-5) 02642 02643 chamber_x_trackx.GetXaxis().SetLabelColor(ROOT.kWhite) 02644 chamber_x_tracky.GetXaxis().SetLabelColor(ROOT.kWhite) 02645 chamber_x_tracky.GetYaxis().SetLabelColor(ROOT.kWhite) 02646 chamber_x_trackdxdz.GetXaxis().SetLabelColor(ROOT.kWhite) 02647 chamber_x_trackdxdz.GetYaxis().SetLabelColor(ROOT.kWhite) 02648 chamber_x_trackdydz.GetXaxis().SetLabelColor(ROOT.kWhite) 02649 chamber_x_trackdydz.GetYaxis().SetLabelColor(ROOT.kWhite) 02650 chamber_y_trackx.GetXaxis().SetLabelColor(ROOT.kWhite) 02651 chamber_y_tracky.GetXaxis().SetLabelColor(ROOT.kWhite) 02652 chamber_y_tracky.GetYaxis().SetLabelColor(ROOT.kWhite) 02653 chamber_y_trackdxdz.GetXaxis().SetLabelColor(ROOT.kWhite) 02654 chamber_y_trackdxdz.GetYaxis().SetLabelColor(ROOT.kWhite) 02655 chamber_y_trackdydz.GetXaxis().SetLabelColor(ROOT.kWhite) 02656 chamber_y_trackdydz.GetYaxis().SetLabelColor(ROOT.kWhite) 02657 chamber_dxdz_trackx.GetXaxis().SetLabelColor(ROOT.kWhite) 02658 chamber_dxdz_tracky.GetXaxis().SetLabelColor(ROOT.kWhite) 02659 chamber_dxdz_tracky.GetYaxis().SetLabelColor(ROOT.kWhite) 02660 chamber_dxdz_trackdxdz.GetXaxis().SetLabelColor(ROOT.kWhite) 02661 chamber_dxdz_trackdxdz.GetYaxis().SetLabelColor(ROOT.kWhite) 02662 chamber_dxdz_trackdydz.GetXaxis().SetLabelColor(ROOT.kWhite) 02663 chamber_dxdz_trackdydz.GetYaxis().SetLabelColor(ROOT.kWhite) 02664 02665 # chamber_dydz_trackx 02666 chamber_dydz_tracky.GetYaxis().SetLabelColor(ROOT.kWhite) 02667 chamber_dydz_trackdxdz.GetYaxis().SetLabelColor(ROOT.kWhite) 02668 chamber_dydz_trackdydz.GetYaxis().SetLabelColor(ROOT.kWhite) 02669 02670 pads[2].cd() 02671 chamber_x_trackx.Draw("e1") 02672 if not suppressblue: chamber_x_trackx_fit2.Draw("samel") 02673 chamber_x_trackx_fit.Draw("samel") 02674 #label99 = ROOT.TPaveLabel(0, 0.8, 1, 1, getname(r),"NDC") 02675 print getname(r) 02676 #label99 = ROOT.TPaveLabel(0, 0.8, 1, 1, "aaa","NDC") 02677 label9.Draw() 02678 #pads[2].Modified() 02679 02680 pads[3].cd() 02681 chamber_x_tracky.Draw("e1") 02682 if not suppressblue: chamber_x_tracky_fit2.Draw("samel") 02683 chamber_x_tracky_fit.Draw("samel") 02684 02685 pads[4].cd() 02686 chamber_x_trackdxdz.Draw("e1") 02687 if not suppressblue: chamber_x_trackdxdz_fit2.Draw("samel") 02688 chamber_x_trackdxdz_fit.Draw("samel") 02689 02690 pads[5].cd() 02691 chamber_x_trackdydz.Draw("e1") 02692 if not suppressblue: chamber_x_trackdydz_fit2.Draw("samel") 02693 chamber_x_trackdydz_fit.Draw("samel") 02694 02695 pads[7].cd() 02696 chamber_y_trackx.Draw("e1") 02697 if not suppressblue: chamber_y_trackx_fit2.Draw("samel") 02698 chamber_y_trackx_fit.Draw("samel") 02699 02700 pads[8].cd() 02701 chamber_y_tracky.Draw("e1") 02702 if not suppressblue: chamber_y_tracky_fit2.Draw("samel") 02703 chamber_y_tracky_fit.Draw("samel") 02704 02705 pads[9].cd() 02706 chamber_y_trackdxdz.Draw("e1") 02707 if not suppressblue: chamber_y_trackdxdz_fit2.Draw("samel") 02708 chamber_y_trackdxdz_fit.Draw("samel") 02709 02710 pads[10].cd() 02711 chamber_y_trackdydz.Draw("e1") 02712 if not suppressblue: chamber_y_trackdydz_fit2.Draw("samel") 02713 chamber_y_trackdydz_fit.Draw("samel") 02714 02715 pads[12].cd() 02716 chamber_dxdz_trackx.Draw("e1") 02717 if not suppressblue: chamber_dxdz_trackx_fit2.Draw("samel") 02718 chamber_dxdz_trackx_fit.Draw("samel") 02719 02720 pads[13].cd() 02721 chamber_dxdz_tracky.Draw("e1") 02722 if not suppressblue: chamber_dxdz_tracky_fit2.Draw("samel") 02723 chamber_dxdz_tracky_fit.Draw("samel") 02724 02725 pads[14].cd() 02726 chamber_dxdz_trackdxdz.Draw("e1") 02727 if not suppressblue: chamber_dxdz_trackdxdz_fit2.Draw("samel") 02728 chamber_dxdz_trackdxdz_fit.Draw("samel") 02729 02730 pads[15].cd() 02731 chamber_dxdz_trackdydz.Draw("e1") 02732 if not suppressblue: chamber_dxdz_trackdydz_fit2.Draw("samel") 02733 chamber_dxdz_trackdydz_fit.Draw("samel") 02734 02735 pads[17].cd() 02736 chamber_dydz_trackx.Draw("e1") 02737 if not suppressblue: chamber_dydz_trackx_fit2.Draw("samel") 02738 chamber_dydz_trackx_fit.Draw("samel") 02739 02740 pads[18].cd() 02741 chamber_dydz_tracky.Draw("e1") 02742 if not suppressblue: chamber_dydz_tracky_fit2.Draw("samel") 02743 chamber_dydz_tracky_fit.Draw("samel") 02744 02745 pads[19].cd() 02746 chamber_dydz_trackdxdz.Draw("e1") 02747 if not suppressblue: chamber_dydz_trackdxdz_fit2.Draw("samel") 02748 chamber_dydz_trackdxdz_fit.Draw("samel") 02749 02750 pads[20].cd() 02751 chamber_dydz_trackdydz.Draw("e1") 02752 if not suppressblue: chamber_dydz_trackdydz_fit2.Draw("samel") 02753 chamber_dydz_trackdydz_fit.Draw("samel") 02754 02755 else: 02756 c1.Clear() 02757 #c1.Divide(5, 3, 1e-5, 1e-5) 02758 pads = [None] 02759 pads.append(ROOT.TPad("p1" ,"",0.00,0.55,0.07,1.00,0,0,0)) 02760 pads.append(ROOT.TPad("p2" ,"",0.07,0.55,0.34,1.00,0,0,0)) 02761 pads.append(ROOT.TPad("p3" ,"",0.34,0.55,0.56,1.00,0,0,0)) 02762 pads.append(ROOT.TPad("p4" ,"",0.56,0.55,0.78,1.00,0,0,0)) 02763 pads.append(ROOT.TPad("p5" ,"",0.78,0.55,1.00,1.00,0,0,0)) 02764 pads.append(ROOT.TPad("p6" ,"",0.00,0.1,0.07,0.55,0,0,0)) 02765 pads.append(ROOT.TPad("p7" ,"",0.07,0.1,0.34,0.55,0,0,0)) 02766 pads.append(ROOT.TPad("p8" ,"",0.34,0.1,0.56,0.55,0,0,0)) 02767 pads.append(ROOT.TPad("p9" ,"",0.56,0.1,0.78,0.55,0,0,0)) 02768 pads.append(ROOT.TPad("p10","",0.78,0.1,1.00,0.55,0,0,0)) 02769 pads.append(ROOT.TPad("p11","",0.00,0.,0.07,0.1,0,0,0)) 02770 pads.append(ROOT.TPad("p12","",0.07,0.,0.34,0.1,0,0,0)) 02771 pads.append(ROOT.TPad("p13","",0.34,0.,0.56,0.1,0,0,0)) 02772 pads.append(ROOT.TPad("p14","",0.56,0.,0.78,0.1,0,0,0)) 02773 pads.append(ROOT.TPad("p15","",0.78,0.,1.00,0.1,0,0,0)) 02774 for p in pads: 02775 if not not p: 02776 p.Draw() 02777 ROOT.SetOwnership(p,False) 02778 02779 label1 = ROOT.TPaveLabel(0, 0, 1, 1, "x residuals (mm)") 02780 label2 = ROOT.TPaveLabel(0, 0, 1, 1, "dx/dz residuals (mrad)") 02781 label3 = ROOT.TPaveLabel(0, 0.3, 1, 1, "x position (cm)") 02782 label4 = ROOT.TPaveLabel(0, 0.3, 1, 1, "y position (cm)") 02783 label5 = ROOT.TPaveLabel(0, 0.3, 1, 1, "dx/dz angle (rad)") 02784 label6 = ROOT.TPaveLabel(0, 0.3, 1, 1, "dy/dz angle (rad)") 02785 label9 = ROOT.TPaveLabel(0, 0.85, 1, 1, getname(r),"NDC") 02786 02787 if name[0:2] == "ME": 02788 label1 = ROOT.TPaveLabel(0, 0, 1, 1, "r#phi residuals (mm)") 02789 label2 = ROOT.TPaveLabel(0, 0, 1, 1, "d(r#phi)/dz residuals (mrad)") 02790 02791 for l in label1, label2, label3, label4, label5, label6, label9: 02792 l.SetBorderSize(0) 02793 l.SetFillColor(ROOT.kWhite) 02794 02795 for l in label1, label2: 02796 l.SetTextAngle(90) 02797 l.SetTextSize(0.09) 02798 02799 #label9.SetTextAngle(30) 02800 label9.SetTextSize(0.29) 02801 02802 pads[1].cd(); label1.Draw() 02803 pads[6].cd(); label2.Draw() 02804 pads[12].cd(); label3.Draw() 02805 pads[13].cd(); label4.Draw() 02806 pads[14].cd(); label5.Draw() 02807 pads[15].cd(); label6.Draw() 02808 #pads[11].cd(); label9.Draw() 02809 02810 pads[2].SetRightMargin(1e-5) 02811 pads[2].SetBottomMargin(1e-5) 02812 pads[3].SetLeftMargin(1e-5) 02813 pads[3].SetRightMargin(1e-5) 02814 pads[3].SetBottomMargin(1e-5) 02815 pads[4].SetLeftMargin(1e-5) 02816 pads[4].SetRightMargin(1e-5) 02817 pads[4].SetBottomMargin(1e-5) 02818 pads[5].SetLeftMargin(1e-5) 02819 pads[5].SetBottomMargin(1e-5) 02820 02821 pads[7].SetRightMargin(1e-5) 02822 pads[7].SetTopMargin(1e-5) 02823 pads[8].SetLeftMargin(1e-5) 02824 pads[8].SetRightMargin(1e-5) 02825 pads[8].SetTopMargin(1e-5) 02826 pads[9].SetLeftMargin(1e-5) 02827 pads[9].SetRightMargin(1e-5) 02828 pads[9].SetTopMargin(1e-5) 02829 pads[10].SetLeftMargin(1e-5) 02830 pads[10].SetTopMargin(1e-5) 02831 02832 chamber_x_trackx.GetXaxis().SetLabelColor(ROOT.kWhite) 02833 chamber_x_tracky.GetXaxis().SetLabelColor(ROOT.kWhite) 02834 chamber_x_tracky.GetYaxis().SetLabelColor(ROOT.kWhite) 02835 chamber_x_trackdxdz.GetXaxis().SetLabelColor(ROOT.kWhite) 02836 chamber_x_trackdxdz.GetYaxis().SetLabelColor(ROOT.kWhite) 02837 chamber_x_trackdydz.GetXaxis().SetLabelColor(ROOT.kWhite) 02838 chamber_x_trackdydz.GetYaxis().SetLabelColor(ROOT.kWhite) 02839 # chamber_dxdz_trackx 02840 chamber_dxdz_tracky.GetYaxis().SetLabelColor(ROOT.kWhite) 02841 chamber_dxdz_trackdxdz.GetYaxis().SetLabelColor(ROOT.kWhite) 02842 chamber_dxdz_trackdydz.GetYaxis().SetLabelColor(ROOT.kWhite) 02843 02844 pads[2].cd() 02845 chamber_x_trackx.Draw("e1") 02846 if not suppressblue: chamber_x_trackx_fit2.Draw("samel") 02847 chamber_x_trackx_fit.Draw("samel") 02848 label9.Draw() 02849 02850 pads[3].cd() 02851 chamber_x_tracky.Draw("e1") 02852 if not suppressblue: chamber_x_tracky_fit2.Draw("samel") 02853 chamber_x_tracky_fit.Draw("samel") 02854 02855 pads[4].cd() 02856 chamber_x_trackdxdz.Draw("e1") 02857 if not suppressblue: chamber_x_trackdxdz_fit2.Draw("samel") 02858 chamber_x_trackdxdz_fit.Draw("samel") 02859 02860 pads[5].cd() 02861 chamber_x_trackdydz.Draw("e1") 02862 if not suppressblue: chamber_x_trackdydz_fit2.Draw("samel") 02863 chamber_x_trackdydz_fit.Draw("samel") 02864 02865 pads[7].cd() 02866 chamber_dxdz_trackx.Draw("e1") 02867 if not suppressblue: chamber_dxdz_trackx_fit2.Draw("samel") 02868 chamber_dxdz_trackx_fit.Draw("samel") 02869 02870 pads[8].cd() 02871 chamber_dxdz_tracky.Draw("e1") 02872 if not suppressblue: chamber_dxdz_tracky_fit2.Draw("samel") 02873 chamber_dxdz_tracky_fit.Draw("samel") 02874 02875 pads[9].cd() 02876 chamber_dxdz_trackdxdz.Draw("e1") 02877 if not suppressblue: chamber_dxdz_trackdxdz_fit2.Draw("samel") 02878 chamber_dxdz_trackdxdz_fit.Draw("samel") 02879 02880 pads[10].cd() 02881 chamber_dxdz_trackdydz.Draw("e1") 02882 if not suppressblue: chamber_dxdz_trackdydz_fit2.Draw("samel") 02883 chamber_dxdz_trackdydz_fit.Draw("samel") 02884 02885 tn = time.time() 02886 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.
00885 : 00886 if postal_address[0] == "DT": 00887 wheel, station, sector = postal_address[1:] 00888 w = "%+d"%wheel 00889 if w=="+0": w = "-0" 00890 return "MB%s/%d/%02d" % (w, station, sector) 00891 elif postal_address[0] == "CSC": 00892 endcap, station, ring, chamber = postal_address[1:] 00893 if endcap != 1: station = -1 * abs(station) 00894 return "ME%+d/%d/%02d" % (station, ring, chamber) 00895
def plotscripts::printDeltaTs | ( | ) |
Definition at line 2046 of file plotscripts.py.
def plotscripts::rlines | ( | disk, | |
window, | |||
abscissa | |||
) |
Definition at line 455 of file plotscripts.py.
00456 : 00457 global rline_tlines 00458 rline_tlines = [] 00459 if disk == 1: rl = [150., 270., 480.] 00460 else: rl = [350.] 00461 for r in rl: 00462 if abscissa is None or abscissa[0] < r < abscissa[1]: 00463 rline_tlines.append(ROOT.TLine(r, -window, r, window)) 00464 rline_tlines[-1].SetLineStyle(2) 00465 rline_tlines[-1].Draw()
def plotscripts::rms | ( | xlist | ) |
Definition at line 60 of file plotscripts.py.
Referenced by HcalDetDiagLEDMonitor::CheckStatus(), HcalDetDiagPedestalMonitor::CheckStatus(), PFClient::createResolutionPlots(), HcalHitCorrection::delay(), HcalTimeSlewSim::delay(), DQMChannel::DQMChannel(), HFLightCalRand::endJob(), DTTPAnalyzer::endJob(), HOCalibAnalyzer::endJob(), DTTTrigCorrectionFirst::endJob(), SiStripCMMonitorPlugin::endJob(), HFLightCal::endJob(), ZeeCalibration::endOfJob(), RPCBxTest::endRun(), EcalZmassClient::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(), EcalEndcapRecHitsMaker::init(), EcalBarrelRecHitsMaker::init(), TMom::init(), HcalDetDiagLaserMonitor::LoadDataset(), HcalDetDiagPedestalMonitor::LoadDataset(), HcalDetDiagLEDMonitor::LoadReference(), HcalDetDiagLaserMonitor::LoadReference(), HcalDetDiagPedestalMonitor::LoadReference(), TPedValues::makePlots(), reco::tau::RecoTauDiscriminantInvariantWidth::operator()(), DQMClientExample::performClient(), PhiBorderFinder::PhiBorderFinder(), cond::PayLoadInspector< DataT >::plot(), SiStripDetSummary::print(), SiPixelDetSummary::print(), RPCLinkSynchroStat::SynchroCounts::print(), SiStripNoises::printSummary(), TH2Analyzer::ProcessSlice(), TH2Analyzer::ProcessSlices(), ecaldqm::TimingClient::producePlots(), ecaldqm::PresampleClient::producePlots(), RBorderFinder::RBorderFinder(), DTSurvey::ReadChambers(), LA_Filler_Fitter::rms_profile(), DTTriggerLutTest::runClientDiagnostic(), DTOccupancyTest::runOccupancyTest(), ContentsWithinExpected::runTest(), HcalDetDiagPedestalMonitor::SaveReference(), HcalDetDiagLEDMonitor::SaveReference(), HcalDetDiagLaserMonitor::SaveReference(), HcalDetDiagPedestalData::set_data(), HcalDetDiagLaserData::set_data(), HcalDetDiagPedestalData::set_reference(), HcalDetDiagLEDData::set_reference(), HcalDetDiagLaserData::set_reference(), MonTestPulseDat::setADCRMSG1(), MonPedestalsOnlineDat::setADCRMSG12(), MonTestPulseDat::setADCRMSG12(), MonTestPulseDat::setADCRMSG6(), MonLaserRedDat::setAPDOverPNRMS(), MonLaserBlueDat::setAPDOverPNRMS(), MonLaserGreenDat::setAPDOverPNRMS(), MonLaserIRedDat::setAPDOverPNRMS(), MonLaserIRedDat::setAPDRMS(), MonLaserBlueDat::setAPDRMS(), MonLaserRedDat::setAPDRMS(), MonLaserGreenDat::setAPDRMS(), DCUCapsuleTempRawDat::setCapsuleTempRMS(), MonDelaysTTDat::setDelayRMS(), MonPedestalsDat::setPedRMSG1(), MonPedestalsDat::setPedRMSG12(), MonPedestalsDat::setPedRMSG6(), ITimingDat::setTimingRMS(), MonLed2Dat::setVPTOverPNRMS(), MonLed1Dat::setVPTOverPNRMS(), MonLed1Dat::setVPTRMS(), MonLed2Dat::setVPTRMS(), and ecaldqm::MESetTrend::shift_().
def plotscripts::saveTestResultsMap | ( | run_name | ) |
Definition at line 1181 of file plotscripts.py.
def plotscripts::segdiff | ( | tfiles, | |
component, | |||
pair, | |||
args | |||
) |
Definition at line 2889 of file plotscripts.py.
02890 : 02891 tdrStyle.SetOptFit(1) 02892 tdrStyle.SetOptTitle(1) 02893 tdrStyle.SetTitleBorderSize(1) 02894 tdrStyle.SetTitleFontSize(0.05) 02895 tdrStyle.SetStatW(0.2) 02896 tdrStyle.SetStatY(0.9) 02897 tdrStyle.SetStatFontSize(0.06) 02898 02899 if component[0:2] == "dt": 02900 wheel = args["wheel"] 02901 wheelletter = wheelLetter(wheel) 02902 sector = args["sector"] 02903 profname = "%s_%s_%02d_%s" % (component, wheelletter, sector, str(pair)) 02904 posname = "pos" + profname 02905 negname = "neg" + profname 02906 #print profname 02907 02908 station1 = int(str(pair)[0]) 02909 station2 = int(str(pair)[1]) 02910 phi1 = signConventions["DT", wheel, station1, sector][4] 02911 phi2 = signConventions["DT", wheel, station2, sector][4] 02912 if abs(phi1 - phi2) > 1.: 02913 if phi1 > phi2: phi1 -= 2.*pi 02914 else: phi1 += 2.*pi 02915 phi = (phi1 + phi2) / 2. 02916 while (phi < -pi): phi += 2.*pi 02917 while (phi > pi): phi -= 2.*pi 02918 02919 elif component[0:3] == "csc": 02920 endcap = args["endcap"] 02921 if endcap=="m": 02922 endcapnum=2 02923 endcapsign="-" 02924 elif endcap=="p": 02925 endcapnum=1 02926 endcapsign="+" 02927 else: raise Exception 02928 02929 ring = args["ring"] 02930 if ring>2 or ring<1: raise Exception 02931 station1 = int(str(pair)[0]) 02932 station2 = int(str(pair)[1]) 02933 if ring==1: ringname="inner" 02934 elif ring==2: ringname="outer" 02935 else: raise Exception 02936 02937 chamber = args["chamber"] 02938 if (ring==1 and chamber>18) or (ring==2 and chamber>36): raise Exception 02939 02940 profname = "csc%s_%s_%s_%02d_%s" % (ringname,component[4:], endcap, chamber, str(pair)) 02941 posname = "pos" + profname 02942 negname = "neg" + profname 02943 #print profname 02944 02945 station1 = int(str(pair)[0]) 02946 station2 = int(str(pair)[1]) 02947 phi1 = signConventions["CSC", endcapnum, station1, ring, chamber][4] 02948 phi2 = signConventions["CSC", endcapnum, station2, ring, chamber][4] 02949 if abs(phi1 - phi2) > 1.: 02950 if phi1 > phi2: phi1 -= 2.*pi 02951 else: phi1 += 2.*pi 02952 phi = (phi1 + phi2) / 2. 02953 while (phi < -pi*5./180.): phi += 2.*pi 02954 while (phi > pi*(2.-5./180.)): phi -= 2.*pi 02955 02956 else: raise Exception 02957 02958 if "window" in args: window = args["window"] 02959 else: window = 5. 02960 02961 global tmpprof, tmppos, tmpneg 02962 pdir = "AlignmentMonitorSegmentDifferences/iter1/" 02963 tmpprof = tfiles[0].Get(pdir + profname).Clone() 02964 tmpprof.SetMarkerStyle(8) 02965 tmppos = tfiles[0].Get(pdir + posname).Clone() 02966 tmpneg = tfiles[0].Get(pdir + negname).Clone() 02967 for tfile in tfiles[1:]: 02968 tmpprof.Add(tfile.Get(pdir + profname)) 02969 tmppos.Add(tfile.Get(pdir + posname)) 02970 tmpneg.Add(tfile.Get(pdir + negname)) 02971 02972 for i in xrange(1, tmpprof.GetNbinsX()+1): 02973 if tmpprof.GetBinError(i) < 1e-5: 02974 tmpprof.SetBinError(i, 100.) 02975 tmpprof.SetAxisRange(-window, window, "Y") 02976 02977 f = ROOT.TF1("p1", "[0] + [1]*x", tmpprof.GetBinLowEdge(1), -tmpprof.GetBinLowEdge(1)) 02978 f.SetParameters((tmppos.GetMean() + tmpneg.GetMean())/2., 0.) 02979 02980 tmpprof.SetXTitle("q/p_{T} (c/GeV)") 02981 if component == "dt13_resid": 02982 tmpprof.SetYTitle("#Deltax^{local} (mm)") 02983 tmppos.SetXTitle("#Deltax^{local} (mm)") 02984 tmpneg.SetXTitle("#Deltax^{local} (mm)") 02985 f.SetParNames("#Deltax^{local}_{0}", "Slope") 02986 if component == "dt13_slope": 02987 tmpprof.SetYTitle("#Deltadx/dz^{local} (mrad)") 02988 tmppos.SetXTitle("#Deltadx/dz^{local} (mrad)") 02989 tmpneg.SetXTitle("#Deltadx/dz^{local} (mrad)") 02990 f.SetParNames("#Deltadx/dz^{local}_{0}", "Slope") 02991 if component == "dt2_resid": 02992 tmpprof.SetYTitle("#Deltay^{local} (mm)") 02993 tmppos.SetXTitle("#Deltay^{local} (mm)") 02994 tmpneg.SetXTitle("#Deltay^{local} (mm)") 02995 f.SetParNames("#Deltay^{local}_{0}", "Slope") 02996 if component == "dt2_slope": 02997 tmpprof.SetYTitle("#Deltady/dz^{local} (mrad)") 02998 tmppos.SetXTitle("#Deltady/dz^{local} (mrad)") 02999 tmpneg.SetXTitle("#Deltady/dz^{local} (mrad)") 03000 f.SetParNames("#Deltady/dz^{local}_{0}", "Slope") 03001 if component == "csc_resid": 03002 tmpprof.SetXTitle("q/p_{z} (c/GeV)") 03003 tmpprof.SetYTitle("#Delta(r#phi)^{local} (mm)") 03004 tmppos.SetXTitle("#Delta(r#phi)^{local} (mm)") 03005 tmpneg.SetXTitle("#Delta(r#phi)^{local} (mm)") 03006 f.SetParNames("#Delta(r#phi)^{local}_{0}", "Slope") 03007 if component == "csc_slope": 03008 tmpprof.SetXTitle("q/p_{z} (c/GeV)") 03009 tmpprof.SetYTitle("#Deltad(r#phi)/dz^{local} (mrad)") 03010 tmppos.SetXTitle("#Deltad(r#phi)/dz^{local} (mrad)") 03011 tmpneg.SetXTitle("#Deltad(r#phi)/dz^{local} (mrad)") 03012 f.SetParNames("#Deltad(r#phi)/dz^{local}_{0}", "Slope") 03013 03014 tmpprof.GetXaxis().CenterTitle() 03015 tmpprof.GetYaxis().CenterTitle() 03016 tmppos.GetXaxis().CenterTitle() 03017 tmpneg.GetXaxis().CenterTitle() 03018 if component[0:2] == "dt": 03019 tmpprof.SetTitle("MB%d - MB%d, wheel %d, sector %02d" % (station1, station2, int(wheel), int(sector))) 03020 elif component[0:3] == "csc": 03021 tmpprof.SetTitle("ME%d - ME%d, for ME%s%d/%d/%d" % (station1, station2, endcapsign, station2, ring, chamber)) 03022 else: raise Exception 03023 03024 tmppos.SetTitle("Positive muons") 03025 tmpneg.SetTitle("Negative muons") 03026 03027 c1.Clear() 03028 c1.Divide(2, 1) 03029 c1.GetPad(1).cd() 03030 fit1 = tmpprof.Fit("p1", "qS") 03031 tmpprof.Draw("e1") 03032 c1.GetPad(2).cd() 03033 c1.GetPad(2).Divide(1, 2) 03034 c1.GetPad(2).GetPad(1).cd() 03035 tmppos.Draw() 03036 f = ROOT.TF1("gausR", "[0]*exp(-(x - [1])**2 / 2. / [2]**2) / sqrt(2.*3.1415926) / [2]", 03037 tmppos.GetMean() - tmppos.GetRMS(), tmppos.GetMean() + tmppos.GetRMS()) 03038 f.SetParameters(tmppos.GetEntries() * ((10. - -10.)/100.), tmppos.GetMean(), tmppos.GetRMS()) 03039 f.SetParNames("Constant", "Mean", "Sigma") 03040 fit2 = tmppos.Fit("gausR", "qRS") 03041 c1.GetPad(2).GetPad(2).cd() 03042 tmpneg.Draw() 03043 f = ROOT.TF1("gausR", "[0]*exp(-(x - [1])**2 / 2. / [2]**2) / sqrt(2.*3.1415926) / [2]", 03044 tmpneg.GetMean() - tmpneg.GetRMS(), tmpneg.GetMean() + tmpneg.GetRMS()) 03045 f.SetParameters(tmpneg.GetEntries() * ((10. - -10.)/100.), tmpneg.GetMean(), tmpneg.GetRMS()) 03046 f.SetParNames("Constant", "Mean", "Sigma") 03047 fit3 = tmpneg.Fit("gausR", "qRS") 03048 03049 fit1ok = fit1.Status()==0 and fit1.CovMatrixStatus()==3 03050 fit2ok = fit2.Status()==0 and fit2.CovMatrixStatus()==3 03051 fit3ok = fit3.Status()==0 and fit3.CovMatrixStatus()==3 03052 03053 fitresult1 = None, None 03054 if fit1ok: 03055 fitresult1 = tmpprof.GetFunction("p1").GetParameter(0), tmpprof.GetFunction("p1").GetParError(0) 03056 fitresult2 = None, None 03057 if fit2ok and fit3ok: 03058 fitresult2 = (tmppos.GetFunction("gausR").GetParameter(1) + tmpneg.GetFunction("gausR").GetParameter(1)) / 2., \ 03059 sqrt(tmppos.GetFunction("gausR").GetParError(1)**2 + tmpneg.GetFunction("gausR").GetParError(1)**2) / 2. 03060 return phi, fitresult1[0], fitresult1[1], fitresult2[0], fitresult2[1], fit1ok, fit2ok, fit3ok 03061 03062
def plotscripts::segdiff_xalign | ( | tfiles, | |
component, | |||
args | |||
) |
Definition at line 3065 of file plotscripts.py.
03066 : 03067 tdrStyle.SetOptFit(1) 03068 tdrStyle.SetOptTitle(1) 03069 tdrStyle.SetTitleBorderSize(1) 03070 tdrStyle.SetTitleFontSize(0.05) 03071 tdrStyle.SetStatW(0.2) 03072 tdrStyle.SetStatY(0.9) 03073 tdrStyle.SetStatFontSize(0.06) 03074 03075 if component[0:4] == "x_dt": 03076 wheel = int(args["wheel"]) 03077 if int(wheel)<0: 03078 wheell = "m%d" % abs(wheel) 03079 endcapsign="-" 03080 else: 03081 wheell = "p%d" % abs(wheel) 03082 endcapsign="+" 03083 station_dt = component[4] 03084 station_csc_1 = args["cscstations"][0] 03085 if station_csc_1=='1': ring_1 = 3 03086 else: ring_1 = 2 03087 sector = args["sector"] 03088 profname = "%s%s_W%sS%02d" % (component, station_csc_1, wheell, sector) 03089 posname_1 = "pos_" + profname 03090 negname_1 = "neg_" + profname 03091 if len(args["cscstations"]) > 1: 03092 station_csc_2 = args["cscstations"][1] 03093 if station_csc_2=='1': ring_2 = 3 03094 else: ring_2 = 2 03095 profname = "%s%s_W%sS%02d" % (component, station_csc_2, wheell, sector) 03096 posname_2 = "pos_" + profname 03097 negname_2 = "neg_" + profname 03098 03099 phi = signConventions["DT", wheel, int(station_dt), sector][4] 03100 while (phi < -pi): phi += 2.*pi 03101 while (phi > pi): phi -= 2.*pi 03102 03103 else: raise Exception 03104 03105 if "window" in args: window = args["window"] 03106 else: window = 5. 03107 03108 global tmppos, tmpneg, tmppos_2, tmpneg_2 03109 pdir = "AlignmentMonitorSegmentDifferences/iter1/" 03110 tmppos = tfiles[0].Get(pdir + posname_1).Clone() 03111 tmpneg = tfiles[0].Get(pdir + negname_1).Clone() 03112 if len(args["cscstations"]) > 1: 03113 tmppos_2 = tfiles[0].Get(pdir + posname_2).Clone() 03114 tmpneg_2 = tfiles[0].Get(pdir + negname_2).Clone() 03115 tmpneg.Rebin(2); tmppos.Rebin(2) 03116 for tfile in tfiles[1:]: 03117 tmppos.Add(tfile.Get(pdir + posname_1)) 03118 tmpneg.Add(tfile.Get(pdir + negname_1)) 03119 if len(args["cscstations"]) > 1: 03120 tmppos_2.Add(tfile.Get(pdir + posname_2)) 03121 tmpneg_2.Add(tfile.Get(pdir + negname_2)) 03122 tmpneg_2.Rebin(2); tmppos_2.Rebin(2) 03123 03124 result = {} 03125 result["fit_ok"] = False 03126 result["phi"] = phi 03127 ntot = tmppos.GetEntries() + tmpneg.GetEntries() 03128 if ntot == 0: 03129 return result 03130 03131 tmppos.SetXTitle("#Deltax^{loc}_{MB} - r_{DT}/r_{CSC}#times#Deltax^{loc}_{ME} (mm)") 03132 tmpneg.SetXTitle("#Deltax^{loc}_{MB} - r_{DT}/r_{CSC}#times#Deltax^{loc}_{ME} (mm)") 03133 title1 = "MB(W%+d St%s Sec%d) - ME%s%s/%d" % (wheel, station_dt, int(sector), endcapsign, station_csc_1, ring_1) 03134 tmppos.SetTitle("Positive #mu: %s" % title1); 03135 tmpneg.SetTitle("Negative #mu: %s" % title1); 03136 tmppos.GetXaxis().CenterTitle() 03137 tmpneg.GetXaxis().CenterTitle() 03138 if len(args["cscstations"]) > 1: 03139 tmppos.SetXTitle("#Deltax^{loc}_{DT} - r_{DT}/r_{CSC}#times#Deltax^{loc}_{CSC} (mm)") 03140 tmpneg.SetXTitle("#Deltax^{loc}_{DT} - r_{DT}/r_{CSC}#times#Deltax^{loc}_{CSC} (mm)") 03141 title2 = "MB(W%+d St%s Sec%d) - ME%s%s/%d" % (wheel, station_dt, int(sector), endcapsign, station_csc_2, ring_2) 03142 tmppos_2.SetTitle("Positive #mu: %s" % title2); 03143 tmpneg_2.SetTitle("Negative #mu: %s" % title2); 03144 tmppos_2.GetXaxis().CenterTitle() 03145 tmpneg_2.GetXaxis().CenterTitle() 03146 03147 c1.Clear() 03148 c1.Divide(2, 2) 03149 03150 c1.GetPad(1).cd() 03151 tmppos.Draw() 03152 fpos = ROOT.TF1("gpos", "gaus", tmppos.GetMean() - tmppos.GetRMS(), tmppos.GetMean() + tmppos.GetRMS()) 03153 fpos.SetParameters(tmppos.GetEntries() * 2.5, tmppos.GetMean(), tmppos.GetRMS()) 03154 fit_pos = tmppos.Fit("gpos", "qRS") 03155 03156 c1.GetPad(3).cd() 03157 tmpneg.Draw() 03158 fneg = ROOT.TF1("gneg", "gaus", tmpneg.GetMean() - tmpneg.GetRMS(), tmpneg.GetMean() + tmpneg.GetRMS()) 03159 fneg.SetParameters(tmpneg.GetEntries() * 2.5, tmpneg.GetMean(), tmpneg.GetRMS()) 03160 fit_neg = tmpneg.Fit("gneg", "qRS") 03161 03162 result["fit_ok"] = (fit_pos.Status()==0 and fit_pos.CovMatrixStatus()==3 and fit_neg.Status()==0 and fit_neg.CovMatrixStatus()==3) 03163 result["fit_peak"] = (fpos.GetParameter(1)*tmppos.GetEntries() + fneg.GetParameter(1)*tmpneg.GetEntries()) / ntot 03164 result["fit_peak_error"] = sqrt( (fpos.GetParError(1)*tmppos.GetEntries())**2 + (fneg.GetParError(1)*tmpneg.GetEntries())**2) / ntot 03165 03166 if len(args["cscstations"]) > 1: 03167 c1.GetPad(2).cd() 03168 tmppos_2.Draw() 03169 fpos_2 = ROOT.TF1("gpos2", "gaus", tmppos_2.GetMean() - tmppos_2.GetRMS(), tmppos_2.GetMean() + tmppos_2.GetRMS()) 03170 fpos_2.SetParameters(tmppos_2.GetEntries() * 2.5, tmppos_2.GetMean(), tmppos_2.GetRMS()) 03171 fit_pos_2 = tmppos_2.Fit("gpos2", "qRS") 03172 03173 c1.GetPad(4).cd() 03174 tmpneg_2.Draw() 03175 fneg_2 = ROOT.TF1("gneg2", "gaus", tmpneg_2.GetMean() - tmpneg_2.GetRMS(), tmpneg_2.GetMean() + tmpneg_2.GetRMS()) 03176 fneg_2.SetParameters(tmpneg_2.GetEntries() * 2.5, tmpneg_2.GetMean(), tmpneg_2.GetRMS()) 03177 fit_neg_2 = tmpneg_2.Fit("gneg2", "qRS") 03178 03179 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) 03180 ntot = tmppos_2.GetEntries() + tmpneg_2.GetEntries() 03181 result["fit_peak_2"] = (fpos_2.GetParameter(1)*tmppos_2.GetEntries() + fneg_2.GetParameter(1)*tmpneg_2.GetEntries()) / ntot 03182 result["fit_peak_error_2"] = sqrt( (fpos_2.GetParError(1)*tmppos_2.GetEntries())**2 + (fneg_2.GetParError(1)*tmpneg_2.GetEntries())**2) / ntot 03183 03184 return result
def plotscripts::segdiffvsphi | ( | tfiles, | |
reports, | |||
component, | |||
wheel, | |||
window = 5. , |
|||
excludesectors = () |
|||
) |
Definition at line 3302 of file plotscripts.py.
03303 : 03304 tdrStyle.SetOptTitle(1) 03305 tdrStyle.SetTitleBorderSize(1) 03306 tdrStyle.SetTitleFontSize(0.05) 03307 03308 global htemp, gtemp_12, gtemp2_12, gtemp_23, gtemp2_23, gtemp_34, gtemp2_34, tlegend 03309 htemp = ROOT.TH1F("htemp", "", 1, -pi, pi) 03310 gtemp_12_phi, gtemp_12_val, gtemp_12_err, gtemp_12_val2, gtemp_12_err2 = [], [], [], [], [] 03311 gtemp_23_phi, gtemp_23_val, gtemp_23_err, gtemp_23_val2, gtemp_23_err2 = [], [], [], [], [] 03312 gtemp_34_phi, gtemp_34_val, gtemp_34_err, gtemp_34_val2, gtemp_34_err2 = [], [], [], [], [] 03313 for sector in xrange(1, 12+1): 03314 #print "sect", sector 03315 r1_found, r2_found, r3_found, r4_found = False, False, False, False 03316 for r1 in reports: 03317 if r1.postal_address == ("DT", wheel, 1, sector): 03318 r1_found = True 03319 break 03320 for r2 in reports: 03321 if r2.postal_address == ("DT", wheel, 2, sector): 03322 r2_found = True 03323 break 03324 for r3 in reports: 03325 if r3.postal_address == ("DT", wheel, 3, sector): 03326 r3_found = True 03327 break 03328 for r4 in reports: 03329 if r4.postal_address == ("DT", wheel, 4, sector): 03330 r4_found = True 03331 break 03332 #print "rfounds: ", r1_found, r2_found, r3_found, r4_found 03333 03334 if sector not in excludesectors: 03335 if r1_found and r2_found and r1.status == "PASS" and r2.status == "PASS": 03336 phi, val, err, val2, err2, fit1, fit2, fit3 = segdiff(tfiles, component, 12, wheel=wheel, sector=sector) 03337 #print "segdif 12", phi, val, err, val2, err2, fit1, fit2, fit3 03338 if fit1 and fit2 and fit3: 03339 gtemp_12_phi.append(phi) 03340 gtemp_12_val.append(val) 03341 gtemp_12_err.append(err) 03342 gtemp_12_val2.append(val2) 03343 gtemp_12_err2.append(err2) 03344 if r2_found and r3_found and r2.status == "PASS" and r3.status == "PASS": 03345 phi, val, err, val2, err2, fit1, fit2, fit3 = segdiff(tfiles, component, 23, wheel=wheel, sector=sector) 03346 #print "segdif 23", phi, val, err, val2, err2, fit1, fit2, fit3 03347 if fit1 and fit2 and fit3: 03348 gtemp_23_phi.append(phi) 03349 gtemp_23_val.append(val) 03350 gtemp_23_err.append(err) 03351 gtemp_23_val2.append(val2) 03352 gtemp_23_err2.append(err2) 03353 if component[:4] == "dt13": 03354 if r3_found and r4_found and r3.status == "PASS" and r4.status == "PASS": 03355 phi, val, err, val2, err2, fit1, fit2, fit3 = segdiff(tfiles, component, 34, wheel=wheel, sector=sector) 03356 #print "segdif 34", phi, val, err, val2, err2, fit1, fit2, fit3 03357 if fit1 and fit2 and fit3: 03358 gtemp_34_phi.append(phi) 03359 gtemp_34_val.append(val) 03360 gtemp_34_err.append(err) 03361 gtemp_34_val2.append(val2) 03362 gtemp_34_err2.append(err2) 03363 03364 #print "len(gtemp_12_phi) ", len(gtemp_12_phi) 03365 #print "len(gtemp_23_phi) ",len(gtemp_23_phi) 03366 #print "len(gtemp_34_phi) ",len(gtemp_34_phi) 03367 if len(gtemp_12_phi) > 0: 03368 gtemp_12 = ROOT.TGraphErrors(len(gtemp_12_phi), array.array("d", gtemp_12_phi), array.array("d", gtemp_12_val), 03369 array.array("d", [0.] * len(gtemp_12_phi)), array.array("d", gtemp_12_err)) 03370 gtemp2_12 = ROOT.TGraphErrors(len(gtemp_12_phi), array.array("d", gtemp_12_phi), array.array("d", gtemp_12_val2), 03371 array.array("d", [0.] * len(gtemp_12_phi)), array.array("d", gtemp_12_err2)) 03372 if len(gtemp_23_phi) > 0: 03373 gtemp_23 = ROOT.TGraphErrors(len(gtemp_23_phi), array.array("d", gtemp_23_phi), array.array("d", gtemp_23_val), 03374 array.array("d", [0.] * len(gtemp_23_phi)), array.array("d", gtemp_23_err)) 03375 gtemp2_23 = ROOT.TGraphErrors(len(gtemp_23_phi), array.array("d", gtemp_23_phi), array.array("d", gtemp_23_val2), 03376 array.array("d", [0.] * len(gtemp_23_phi)), array.array("d", gtemp_23_err2)) 03377 if len(gtemp_34_phi) > 0: 03378 gtemp_34 = ROOT.TGraphErrors(len(gtemp_34_phi), array.array("d", gtemp_34_phi), array.array("d", gtemp_34_val), 03379 array.array("d", [0.] * len(gtemp_34_phi)), array.array("d", gtemp_34_err)) 03380 gtemp2_34 = ROOT.TGraphErrors(len(gtemp_34_phi), array.array("d", gtemp_34_phi), array.array("d", gtemp_34_val2), 03381 array.array("d", [0.] * len(gtemp_34_phi)), array.array("d", gtemp_34_err2)) 03382 03383 if len(gtemp_12_phi) > 0: 03384 gtemp_12.SetMarkerStyle(20); gtemp_12.SetMarkerSize(1.); 03385 gtemp_12.SetMarkerColor(ROOT.kBlue); gtemp_12.SetLineColor(ROOT.kBlue) 03386 gtemp2_12.SetMarkerStyle(24); gtemp2_12.SetMarkerSize(1.); 03387 gtemp2_12.SetMarkerColor(ROOT.kBlue); gtemp2_12.SetLineColor(ROOT.kBlue) 03388 if len(gtemp_23_phi) > 0: 03389 gtemp_23.SetMarkerStyle(21); gtemp_23.SetMarkerSize(1.); 03390 gtemp_23.SetMarkerColor(ROOT.kRed); gtemp_23.SetLineColor(ROOT.kRed) 03391 gtemp2_23.SetMarkerStyle(25); gtemp2_23.SetMarkerSize(1.); 03392 gtemp2_23.SetMarkerColor(ROOT.kRed); gtemp2_23.SetLineColor(ROOT.kRed) 03393 if len(gtemp_34_phi) > 0 and component[:4] == "dt13": 03394 gtemp_34.SetMarkerStyle(22); gtemp_34.SetMarkerSize(1.25); 03395 gtemp_34.SetMarkerColor(ROOT.kGreen+2); gtemp_34.SetLineColor(ROOT.kGreen+2) 03396 gtemp2_34.SetMarkerStyle(26); gtemp2_34.SetMarkerSize(1.25); 03397 gtemp2_34.SetMarkerColor(ROOT.kGreen+2); gtemp2_34.SetLineColor(ROOT.kGreen+2) 03398 03399 if wheel == 0: htemp.SetTitle("Wheel %d" % wheel) 03400 else: htemp.SetTitle("Wheel %+d" % wheel) 03401 htemp.SetAxisRange(-window, window, "Y") 03402 htemp.SetXTitle("Average #phi of pair (rad)") 03403 if component == "dt13_resid": htemp.SetYTitle("#Deltax^{local} (mm)") 03404 if component == "dt13_slope": htemp.SetYTitle("#Deltadx/dz^{local} (mrad)") 03405 if component == "dt2_resid": htemp.SetYTitle("#Deltay^{local} (mm)") 03406 if component == "dt2_slope": htemp.SetYTitle("#Deltady/dz^{local} (mrad)") 03407 htemp.GetXaxis().CenterTitle() 03408 htemp.GetYaxis().CenterTitle() 03409 htemp.GetYaxis().SetTitleOffset(0.75) 03410 03411 c1.Clear() 03412 htemp.Draw() 03413 if len(gtemp_12_phi) > 0: 03414 gtemp_12.Draw("p") 03415 gtemp2_12.Draw("p") 03416 if len(gtemp_23_phi) > 0: 03417 gtemp_23.Draw("p") 03418 gtemp2_23.Draw("p") 03419 if len(gtemp_34_phi) > 0: 03420 gtemp_34.Draw("p") 03421 gtemp2_34.Draw("p") 03422 03423 tlegend = ROOT.TLegend(0.5, 0.72, 0.9, 0.92) 03424 tlegend.SetBorderSize(0) 03425 tlegend.SetFillColor(ROOT.kWhite) 03426 if len(gtemp_12_phi) > 0: 03427 tlegend.AddEntry(gtemp_12, "MB1 - MB2 (mean: %4.2f, RMS: %4.2f)" % (mean(gtemp_12_val), stdev(gtemp_12_val)), "pl") 03428 if len(gtemp_23_phi) > 0: 03429 tlegend.AddEntry(gtemp_23, "MB2 - MB3 (mean: %4.2f, RMS: %4.2f)" % (mean(gtemp_23_val), stdev(gtemp_23_val)), "pl") 03430 if len(gtemp_34_phi) > 0: 03431 tlegend.AddEntry(gtemp_34, "MB3 - MB4 (mean: %4.2f, RMS: %4.2f)" % (mean(gtemp_34_val), stdev(gtemp_34_val)), "pl") 03432 if len(gtemp_12_phi) > 0: 03433 tlegend.AddEntry(gtemp_12, "total mean: %4.2f, total RMS: %4.2f" % \ 03434 (mean(gtemp_12_val + gtemp_23_val + gtemp_34_val), 03435 stdev(gtemp_12_val + gtemp_23_val + gtemp_34_val)), "") 03436 tlegend.Draw() 03437
def plotscripts::segdiffvsphi_xalign | ( | tfiles, | |
wheel, | |||
window = 10. |
|||
) |
Definition at line 3187 of file plotscripts.py.
03188 : 03189 tdrStyle.SetOptTitle(1) 03190 tdrStyle.SetTitleBorderSize(1) 03191 tdrStyle.SetTitleFontSize(0.05) 03192 03193 global htemp, gtemp_12, gtemp_21, gtemp_11, tlegend 03194 htemp = ROOT.TH1F("htemp", "", 1, -pi, pi) 03195 gtemp_11_phi, gtemp_11_val, gtemp_11_err = [], [], [] 03196 gtemp_12_phi, gtemp_12_val, gtemp_12_err = [], [], [] 03197 gtemp_21_phi, gtemp_21_val, gtemp_21_err = [], [], [] 03198 for sector in xrange(1, 12+1): 03199 #print "sect", sector 03200 r1 = segdiff_xalign(tfiles, "x_dt1_csc", wheel=wheel, sector=sector, cscstations = "12") 03201 r2 = segdiff_xalign(tfiles, "x_dt2_csc", wheel=wheel, sector=sector, cscstations = "1") 03202 03203 if r1["fit_ok"]: 03204 gtemp_11_phi.append(r1["phi"]) 03205 gtemp_11_val.append(r1["fit_peak"]) 03206 gtemp_11_err.append(r1["fit_peak_error"]) 03207 if r1["fit_ok_2"]: 03208 gtemp_12_phi.append(r1["phi"]) 03209 gtemp_12_val.append(r1["fit_peak_2"]) 03210 gtemp_12_err.append(r1["fit_peak_error_2"]) 03211 if r2["fit_ok"]: 03212 gtemp_21_phi.append(r2["phi"]) 03213 gtemp_21_val.append(r2["fit_peak"]) 03214 gtemp_21_err.append(r2["fit_peak_error"]) 03215 03216 #print "len(gtemp_11_phi) ",len(gtemp_11_phi) 03217 #print "len(gtemp_12_phi) ",len(gtemp_12_phi) 03218 #print "len(gtemp_21_phi) ",len(gtemp_21_phi) 03219 if len(gtemp_11_phi) > 0: 03220 gtemp_11 = ROOT.TGraphErrors(len(gtemp_11_phi), array.array("d", gtemp_11_phi), array.array("d", gtemp_11_val), 03221 array.array("d", [0.] * len(gtemp_11_phi)), array.array("d", gtemp_11_err)) 03222 if len(gtemp_12_phi) > 0: 03223 gtemp_12 = ROOT.TGraphErrors(len(gtemp_12_phi), array.array("d", gtemp_12_phi), array.array("d", gtemp_12_val), 03224 array.array("d", [0.] * len(gtemp_12_phi)), array.array("d", gtemp_12_err)) 03225 if len(gtemp_11_phi) > 0: 03226 gtemp_21 = ROOT.TGraphErrors(len(gtemp_21_phi), array.array("d", gtemp_21_phi), array.array("d", gtemp_21_val), 03227 array.array("d", [0.] * len(gtemp_21_phi)), array.array("d", gtemp_21_err)) 03228 03229 if len(gtemp_11_phi) > 0: 03230 gtemp_11.SetMarkerStyle(20); gtemp_11.SetMarkerSize(1.5); 03231 gtemp_11.SetMarkerColor(ROOT.kRed); gtemp_11.SetLineColor(ROOT.kRed) 03232 if len(gtemp_12_phi) > 0: 03233 gtemp_12.SetMarkerStyle(22); gtemp_12.SetMarkerSize(1.); 03234 gtemp_12.SetMarkerColor(ROOT.kGreen+2); gtemp_12.SetLineColor(ROOT.kGreen+2) 03235 if len(gtemp_21_phi) > 0: 03236 gtemp_21.SetMarkerStyle(21); gtemp_21.SetMarkerSize(1.5); 03237 gtemp_21.SetMarkerColor(ROOT.kBlue); gtemp_21.SetLineColor(ROOT.kBlue) 03238 03239 htemp.SetTitle("Wheel %+d" % wheel) 03240 htemp.SetAxisRange(-window, window, "Y") 03241 htemp.SetXTitle("#phi of MB") 03242 htemp.SetYTitle("#Deltax^{loc}_{DT} - r_{DT}/r_{CSC}#times#Deltax^{loc}_{CSC} (mm)") 03243 htemp.GetXaxis().CenterTitle() 03244 htemp.GetYaxis().CenterTitle() 03245 htemp.GetYaxis().SetTitleOffset(0.75) 03246 03247 c1.Clear() 03248 htemp.Draw() 03249 if len(gtemp_12_phi) > 0: 03250 gtemp_12.Draw("p") 03251 if len(gtemp_21_phi) > 0: 03252 gtemp_21.Draw("p") 03253 if len(gtemp_11_phi) > 0: 03254 gtemp_11.Draw("p") 03255 03256 tlegend = ROOT.TLegend(0.59, 0.75, 0.99, 0.92) 03257 tlegend.SetBorderSize(0) 03258 tlegend.SetFillColor(ROOT.kWhite) 03259 if len(gtemp_11_phi) > 0: 03260 tlegend.AddEntry(gtemp_11, "MB1 - ME1/3 (mean: %4.2f, RMS: %4.2f)" % (mean(gtemp_11_val), stdev(gtemp_11_val)), "pl") 03261 if len(gtemp_21_phi) > 0: 03262 tlegend.AddEntry(gtemp_21, "MB2 - ME1/3 (mean: %4.2f, RMS: %4.2f)" % (mean(gtemp_21_val), stdev(gtemp_21_val)), "pl") 03263 if len(gtemp_12_phi) > 0: 03264 tlegend.AddEntry(gtemp_12, "MB1 - ME2/2 (mean: %4.2f, RMS: %4.2f)" % (mean(gtemp_12_val), stdev(gtemp_12_val)), "pl") 03265 #if len(gtemp_12_phi) > 0: 03266 # tlegend.AddEntry(gtemp_12, "total mean: %4.2f, total RMS: %4.2f" % \ 03267 # (mean(gtemp_11_val + gtemp_12_val + gtemp_21_val), 03268 # stdev(gtemp_11_val + gtemp_12_val + gtemp_21_val)), "") 03269 tlegend.Draw() 03270 03271 f_11 = ROOT.TF1("f11", "[0] + [1]*sin(x) + [2]*cos(x)", -pi, pi) 03272 f_11.SetLineColor(ROOT.kRed) 03273 f_11.SetLineWidth(2) 03274 f_21 = ROOT.TF1("f21", "[0] + [1]*sin(x) + [2]*cos(x)", -pi, pi) 03275 f_21.SetLineColor(ROOT.kBlue) 03276 f_21.SetLineWidth(2) 03277 if len(gtemp_11_phi) > 0: 03278 gtemp_11.Fit(f_11,"") 03279 if len(gtemp_21_phi) > 0: 03280 gtemp_21.Fit(f_21,"") 03281 03282 global f_txt,f_11_txt, f_21_txt 03283 f_txt = ROOT.TLatex(-2.9, -0.7*window, "ME1/3 ring corrections equivalents:") 03284 f_txt.SetTextSize(0.028) 03285 f_txt.Draw() 03286 if len(gtemp_11_phi) > 0: 03287 rdt = signConventions[("DT", 2, 1, 1)][3]*10 03288 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" % ( 03289 -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)) 03290 f_11_txt.SetTextSize(0.028) 03291 f_11_txt.SetTextColor(ROOT.kRed) 03292 f_11_txt.Draw() 03293 if len(gtemp_11_phi) > 0: 03294 rdt = signConventions[("DT", 2, 2, 1)][3]*10 03295 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" % ( 03296 -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)) 03297 f_21_txt.SetTextSize(0.028) 03298 f_21_txt.SetTextColor(ROOT.kBlue) 03299 f_21_txt.Draw()
def plotscripts::segdiffvsphicsc | ( | tfiles, | |
component, | |||
pair, | |||
window = 5. , |
|||
args | |||
) |
Definition at line 3440 of file plotscripts.py.
03441 : 03442 tdrStyle.SetOptTitle(1) 03443 tdrStyle.SetTitleBorderSize(1) 03444 tdrStyle.SetTitleFontSize(0.05) 03445 03446 if not component[0:3] == "csc": Exception 03447 03448 endcap = args["endcap"] 03449 if endcap=="m": 03450 endcapnum=2 03451 endcapsign="-" 03452 elif endcap=="p": 03453 endcapnum=1 03454 endcapsign="+" 03455 else: raise Exception 03456 03457 station1 = int(str(pair)[0]) 03458 station2 = int(str(pair)[1]) 03459 if not station2-station1==1: raise Exception 03460 03461 rings = [1,2] 03462 if station2==4: rings = [1] 03463 03464 03465 global htemp, gtemp_1, gtemp2_1, gtemp_2, gtemp2_2, tlegend 03466 htemp = ROOT.TH1F("htemp", "", 1, -pi*5./180., pi*(2.-5./180.)) 03467 gtemp_1_phi, gtemp_1_val, gtemp_1_err, gtemp_1_val2, gtemp_1_err2 = [], [], [], [], [] 03468 gtemp_2_phi, gtemp_2_val, gtemp_2_err, gtemp_2_val2, gtemp_2_err2 = [], [], [], [], [] 03469 03470 for ring in rings: 03471 chambers = xrange(1,37) 03472 if ring == 1: chambers = xrange(1,19) 03473 03474 for chamber in chambers: 03475 phi, val, err, val2, err2, fit1, fit2, fit3 = segdiff(tfiles, component, pair, endcap=endcap, ring=ring, chamber=chamber) 03476 if fit1 and fit2 and fit3: 03477 if ring==1: 03478 gtemp_1_phi.append(phi) 03479 gtemp_1_val.append(val) 03480 gtemp_1_err.append(err) 03481 gtemp_1_val2.append(val2) 03482 gtemp_1_err2.append(err2) 03483 if ring==2: 03484 gtemp_2_phi.append(phi) 03485 gtemp_2_val.append(val) 03486 gtemp_2_err.append(err) 03487 gtemp_2_val2.append(val2) 03488 gtemp_2_err2.append(err2) 03489 03490 #print "len(gtemp_12_phi) ", len(gtemp_12_phi) 03491 #print "len(gtemp_23_phi) ",len(gtemp_23_phi) 03492 #print "len(gtemp_34_phi) ",len(gtemp_34_phi) 03493 if len(gtemp_1_phi) > 0: 03494 gtemp_1 = ROOT.TGraphErrors(len(gtemp_1_phi), array.array("d", gtemp_1_phi), array.array("d", gtemp_1_val), 03495 array.array("d", [0.] * len(gtemp_1_phi)), array.array("d", gtemp_1_err)) 03496 gtemp2_1 = ROOT.TGraphErrors(len(gtemp_1_phi), array.array("d", gtemp_1_phi), array.array("d", gtemp_1_val2), 03497 array.array("d", [0.] * len(gtemp_1_phi)), array.array("d", gtemp_1_err2)) 03498 if len(gtemp_2_phi) > 0: 03499 gtemp_2 = ROOT.TGraphErrors(len(gtemp_2_phi), array.array("d", gtemp_2_phi), array.array("d", gtemp_2_val), 03500 array.array("d", [0.] * len(gtemp_2_phi)), array.array("d", gtemp_2_err)) 03501 gtemp2_2 = ROOT.TGraphErrors(len(gtemp_2_phi), array.array("d", gtemp_2_phi), array.array("d", gtemp_2_val2), 03502 array.array("d", [0.] * len(gtemp_2_phi)), array.array("d", gtemp_2_err2)) 03503 03504 if len(gtemp_1_phi) > 0: 03505 gtemp_1.SetMarkerStyle(20); gtemp_1.SetMarkerSize(1.); 03506 gtemp_1.SetMarkerColor(ROOT.kBlue); gtemp_1.SetLineColor(ROOT.kBlue) 03507 gtemp2_1.SetMarkerStyle(24); gtemp2_1.SetMarkerSize(1.); 03508 gtemp2_1.SetMarkerColor(ROOT.kBlue); gtemp2_1.SetLineColor(ROOT.kBlue) 03509 if len(gtemp_2_phi) > 0: 03510 gtemp_2.SetMarkerStyle(21); gtemp_2.SetMarkerSize(1.); 03511 gtemp_2.SetMarkerColor(ROOT.kRed); gtemp_2.SetLineColor(ROOT.kRed) 03512 gtemp2_2.SetMarkerStyle(25); gtemp2_2.SetMarkerSize(1.); 03513 gtemp2_2.SetMarkerColor(ROOT.kRed); gtemp2_2.SetLineColor(ROOT.kRed) 03514 03515 htemp.SetTitle("ME%s%d - ME%s%d" % (endcapsign,station2,endcapsign,station1)) 03516 htemp.SetAxisRange(-window, window, "Y") 03517 htemp.SetXTitle("Average #phi of pair (rad)") 03518 if component == "csc_resid": htemp.SetYTitle("#Delta(r#phi)^{local} (mm)") 03519 if component == "csc_slope": htemp.SetYTitle("#Deltad(r#phi)/dz^{local} (mrad)") 03520 htemp.GetXaxis().CenterTitle() 03521 htemp.GetYaxis().CenterTitle() 03522 htemp.GetYaxis().SetTitleOffset(0.75) 03523 03524 c1.Clear() 03525 htemp.Draw() 03526 if len(gtemp_1_phi) > 0: 03527 gtemp_1.Draw("p") 03528 gtemp2_1.Draw("p") 03529 if len(gtemp_2_phi) > 0: 03530 gtemp_2.Draw("p") 03531 gtemp2_2.Draw("p") 03532 03533 tlegend = ROOT.TLegend(0.5, 0.72, 0.9, 0.92) 03534 tlegend.SetBorderSize(0) 03535 tlegend.SetFillColor(ROOT.kWhite) 03536 if len(gtemp_1_phi) > 0: 03537 tlegend.AddEntry(gtemp_1, "ring 1 (mean: %4.2f, RMS: %4.2f)" % (mean(gtemp_1_val), stdev(gtemp_1_val)), "pl") 03538 if len(gtemp_2_phi) > 0: 03539 tlegend.AddEntry(gtemp_2, "ring 2 (mean: %4.2f, RMS: %4.2f)" % (mean(gtemp_2_val), stdev(gtemp_2_val)), "pl") 03540 #if len(gtemp_12_phi) > 0: 03541 # tlegend.AddEntry(gtemp_12, "total mean: %4.2f, total RMS: %4.2f" % \ 03542 # (mean(gtemp_12_val + gtemp_23_val + gtemp_34_val), 03543 # stdev(gtemp_12_val + gtemp_23_val + gtemp_34_val)), "") 03544 tlegend.Draw() 03545 03546
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.
00227 : 00228 """Set a color palette from a given RGB list 00229 stops, red, green and blue should all be lists of the same length 00230 see set_decent_colors for an example""" 00231 00232 if name == "halfgray": 00233 stops = [0.00, 0.34, 0.61, 0.84, 1.00] 00234 red = map(lambda x: 1. - (1.-x)/2., [1.00, 0.84, 0.61, 0.34, 0.00]) 00235 green = map(lambda x: 1. - (1.-x)/2., [1.00, 0.84, 0.61, 0.34, 0.00]) 00236 blue = map(lambda x: 1. - (1.-x)/2., [1.00, 0.84, 0.61, 0.34, 0.00]) 00237 elif name == "gray": 00238 stops = [0.00, 0.34, 0.61, 0.84, 1.00] 00239 red = [1.00, 0.84, 0.61, 0.34, 0.00] 00240 green = [1.00, 0.84, 0.61, 0.34, 0.00] 00241 blue = [1.00, 0.84, 0.61, 0.34, 0.00] 00242 elif name == "blues": 00243 stops = [0.00, 0.34, 0.61, 0.84, 1.00] 00244 red = [1.00, 0.84, 0.61, 0.34, 0.00] 00245 green = [1.00, 0.84, 0.61, 0.34, 0.00] 00246 blue = [1.00, 1.00, 1.00, 1.00, 1.00] 00247 elif name == "reds": 00248 stops = [0.00, 0.34, 0.61, 0.84, 1.00] 00249 red = [1.00, 1.00, 1.00, 1.00, 1.00] 00250 green = [1.00, 0.84, 0.61, 0.34, 0.00] 00251 blue = [1.00, 0.84, 0.61, 0.34, 0.00] 00252 elif name == "antigray": 00253 stops = [0.00, 0.34, 0.61, 0.84, 1.00] 00254 red = [1.00, 0.84, 0.61, 0.34, 0.00] 00255 green = [1.00, 0.84, 0.61, 0.34, 0.00] 00256 blue = [1.00, 0.84, 0.61, 0.34, 0.00] 00257 red.reverse() 00258 green.reverse() 00259 blue.reverse() 00260 elif name == "fire": 00261 stops = [0.00, 0.20, 0.80, 1.00] 00262 red = [1.00, 1.00, 1.00, 0.50] 00263 green = [1.00, 1.00, 0.00, 0.00] 00264 blue = [0.20, 0.00, 0.00, 0.00] 00265 elif name == "antifire": 00266 stops = [0.00, 0.20, 0.80, 1.00] 00267 red = [0.50, 1.00, 1.00, 1.00] 00268 green = [0.00, 0.00, 1.00, 1.00] 00269 blue = [0.00, 0.00, 0.00, 0.20] 00270 else: 00271 # default palette, looks cool 00272 stops = [0.00, 0.34, 0.61, 0.84, 1.00] 00273 red = [0.00, 0.00, 0.87, 1.00, 0.51] 00274 green = [0.00, 0.81, 1.00, 0.20, 0.00] 00275 blue = [0.51, 1.00, 0.12, 0.00, 0.00] 00276 00277 s = array.array('d', stops) 00278 r = array.array('d', red) 00279 g = array.array('d', green) 00280 b = array.array('d', blue) 00281 00282 npoints = len(s) 00283 ROOT.TColor.CreateGradientColorTable(npoints, s, r, g, b, ncontours) 00284 ROOT.gStyle.SetNumberContours(ncontours) 00285 00286 set_palette()
def plotscripts::setTDRStyle | ( | ) |
Definition at line 87 of file plotscripts.py.
Referenced by BTagPerformanceAnalyzerOnData::bookHistos(), BTagPerformanceAnalyzerMC::endJob(), BTagPerformanceAnalyzerOnData::endRun(), LRHelpFunctions::LRHelpFunctions(), EffPurFromHistos::plot(), SoftLeptonTagPlotter::psPlot(), JetTagPlotter::psPlot(), TrackCountingTagPlotter::psPlot(), TrackIPTagPlotter::psPlot(), TrackProbabilityTagPlotter::psPlot(), and RecoBTag::tdrGrid().
00088 : 00089 global tdrStyle 00090 tdrStyle = ROOT.TStyle("tdrStyle","Style for P-TDR") 00091 # For the canvas: 00092 tdrStyle.SetCanvasBorderMode(0) 00093 tdrStyle.SetCanvasColor(ROOT.kWhite) 00094 tdrStyle.SetCanvasDefH(600) #Height of canvas 00095 tdrStyle.SetCanvasDefW(600) #Width of canvas 00096 tdrStyle.SetCanvasDefX(0) #POsition on screen 00097 tdrStyle.SetCanvasDefY(0) 00098 00099 # For the Pad: 00100 tdrStyle.SetPadBorderMode(0) 00101 # tdrStyle.SetPadBorderSize(Width_t size = 1) 00102 tdrStyle.SetPadColor(ROOT.kWhite) 00103 tdrStyle.SetPadGridX(False) 00104 tdrStyle.SetPadGridY(False) 00105 tdrStyle.SetGridColor(0) 00106 tdrStyle.SetGridStyle(3) 00107 tdrStyle.SetGridWidth(1) 00108 00109 # For the frame: 00110 tdrStyle.SetFrameBorderMode(0) 00111 tdrStyle.SetFrameBorderSize(1) 00112 tdrStyle.SetFrameFillColor(0) 00113 tdrStyle.SetFrameFillStyle(0) 00114 tdrStyle.SetFrameLineColor(1) 00115 tdrStyle.SetFrameLineStyle(1) 00116 tdrStyle.SetFrameLineWidth(1) 00117 00118 # For the histo: 00119 # tdrStyle.SetHistFillColor(1) 00120 # tdrStyle.SetHistFillStyle(0) 00121 tdrStyle.SetHistLineColor(1) 00122 tdrStyle.SetHistLineStyle(0) 00123 tdrStyle.SetHistLineWidth(1) 00124 # tdrStyle.SetLegoInnerR(Float_t rad = 0.5) 00125 # tdrStyle.SetNumberContours(Int_t number = 20) 00126 00127 tdrStyle.SetEndErrorSize(2) 00128 # tdrStyle.SetErrorMarker(20) 00129 tdrStyle.SetErrorX(0.) 00130 00131 tdrStyle.SetMarkerStyle(20) 00132 00133 #For the fit/function: 00134 tdrStyle.SetOptFit(1) 00135 tdrStyle.SetFitFormat("5.4g") 00136 tdrStyle.SetFuncColor(2) 00137 tdrStyle.SetFuncStyle(1) 00138 tdrStyle.SetFuncWidth(1) 00139 00140 #For the date: 00141 tdrStyle.SetOptDate(0) 00142 # tdrStyle.SetDateX(Float_t x = 0.01) 00143 # tdrStyle.SetDateY(Float_t y = 0.01) 00144 00145 # For the statistics box: 00146 tdrStyle.SetOptFile(0) 00147 tdrStyle.SetOptStat(0) # To display the mean and RMS: SetOptStat("mr") 00148 tdrStyle.SetStatColor(ROOT.kWhite) 00149 tdrStyle.SetStatFont(42) 00150 tdrStyle.SetStatFontSize(0.025) 00151 tdrStyle.SetStatTextColor(1) 00152 tdrStyle.SetStatFormat("6.4g") 00153 tdrStyle.SetStatBorderSize(1) 00154 tdrStyle.SetStatH(0.1) 00155 tdrStyle.SetStatW(0.15) 00156 # tdrStyle.SetStatStyle(Style_t style = 1001) 00157 # tdrStyle.SetStatX(Float_t x = 0) 00158 # tdrStyle.SetStatY(Float_t y = 0) 00159 00160 # Margins: 00161 tdrStyle.SetPadTopMargin(0.05) 00162 tdrStyle.SetPadBottomMargin(0.13) 00163 tdrStyle.SetPadLeftMargin(0.13) 00164 tdrStyle.SetPadRightMargin(0.05) 00165 00166 # For the Global title: 00167 tdrStyle.SetOptTitle(0) 00168 tdrStyle.SetTitleFont(42) 00169 tdrStyle.SetTitleColor(1) 00170 tdrStyle.SetTitleTextColor(1) 00171 tdrStyle.SetTitleFillColor(10) 00172 tdrStyle.SetTitleFontSize(0.05) 00173 # tdrStyle.SetTitleH(0) # Set the height of the title box 00174 # tdrStyle.SetTitleW(0) # Set the width of the title box 00175 # tdrStyle.SetTitleX(0) # Set the position of the title box 00176 # tdrStyle.SetTitleY(0.985) # Set the position of the title box 00177 # tdrStyle.SetTitleStyle(Style_t style = 1001) 00178 # tdrStyle.SetTitleBorderSize(2) 00179 00180 # For the axis titles: 00181 tdrStyle.SetTitleColor(1, "XYZ") 00182 tdrStyle.SetTitleFont(42, "XYZ") 00183 tdrStyle.SetTitleSize(0.06, "XYZ") 00184 # tdrStyle.SetTitleXSize(Float_t size = 0.02) # Another way to set the size? 00185 # tdrStyle.SetTitleYSize(Float_t size = 0.02) 00186 tdrStyle.SetTitleXOffset(0.9) 00187 tdrStyle.SetTitleYOffset(1.05) 00188 # tdrStyle.SetTitleOffset(1.1, "Y") # Another way to set the Offset 00189 00190 # For the axis labels: 00191 tdrStyle.SetLabelColor(1, "XYZ") 00192 tdrStyle.SetLabelFont(42, "XYZ") 00193 tdrStyle.SetLabelOffset(0.007, "XYZ") 00194 tdrStyle.SetLabelSize(0.05, "XYZ") 00195 00196 # For the axis: 00197 tdrStyle.SetAxisColor(1, "XYZ") 00198 tdrStyle.SetStripDecimals(True) 00199 tdrStyle.SetTickLength(0.03, "XYZ") 00200 tdrStyle.SetNdivisions(510, "XYZ") 00201 tdrStyle.SetPadTickX(1) # To get tick marks on the opposite side of the frame 00202 tdrStyle.SetPadTickY(1) 00203 00204 # Change for log plots: 00205 tdrStyle.SetOptLogx(0) 00206 tdrStyle.SetOptLogy(0) 00207 tdrStyle.SetOptLogz(0) 00208 00209 # Postscript options: 00210 tdrStyle.SetPaperSize(20.,20.) 00211 # tdrStyle.SetLineScalePS(Float_t scale = 3) 00212 # tdrStyle.SetLineStyleString(Int_t i, const char* text) 00213 # tdrStyle.SetHeaderPS(const char* header) 00214 # tdrStyle.SetTitlePS(const char* pstitle) 00215 00216 # tdrStyle.SetBarOffset(Float_t baroff = 0.5) 00217 # tdrStyle.SetBarWidth(Float_t barwidth = 0.5) 00218 # tdrStyle.SetPaintTextFormat(const char* format = "g") 00219 # tdrStyle.SetPalette(Int_t ncolors = 0, Int_t* colors = 0) 00220 # tdrStyle.SetTimeOffset(Double_t toffset) 00221 # tdrStyle.SetHistMinimumZero(True) 00222 00223 tdrStyle.cd() 00224 00225 setTDRStyle()
def plotscripts::stationIndex | ( | name | ) |
Definition at line 353 of file plotscripts.py.
Referenced by MuonIdProducer::fillArbitrationInfo(), reco::Muon::stationGapMaskDistance(), and reco::Muon::stationGapMaskPull().
00354 : 00355 if ("MB" in name or "ME" in name): 00356 # assume the name is ID 00357 pa = idToPostalAddress(name) 00358 if pa is None: return None 00359 if pa[0]=="CSC": 00360 if pa[2]==1 and pa[3]==1: return 0 00361 if pa[2]==1 and pa[3]==2: return 1 00362 if pa[2]==1 and pa[3]==3: return 2 00363 if pa[2]==1 and pa[3]==4: return 3 00364 if pa[2]==2 and pa[3]==1: return 4 00365 if pa[2]==2 and pa[3]==2: return 5 00366 if pa[2]==3 and pa[3]==1: return 6 00367 if pa[2]==3 and pa[3]==2: return 7 00368 if pa[2]==4 and pa[3]==1: return 8 00369 if pa[2]==4 and pa[3]==2: return 9 00370 if pa[0]=="DT": 00371 if pa[2]==1: return 10 00372 if pa[2]==2: return 11 00373 if pa[2]==3: return 12 00374 if pa[2]==4: return 13 00375 else: 00376 if ("mem11" in name or "mep11" in name): return 0 00377 if ("mem12" in name or "mep12" in name): return 1 00378 if ("mem13" in name or "mep13" in name): return 2 00379 if ("mem14" in name or "mep14" in name): return 3 00380 if ("mem21" in name or "mep21" in name): return 4 00381 if ("mem22" in name or "mep22" in name): return 5 00382 if ("mem31" in name or "mep31" in name): return 6 00383 if ("mem32" in name or "mep32" in name): return 7 00384 if ("mem41" in name or "mep41" in name): return 8 00385 if ("mem42" in name or "mep42" in name): return 9 00386 if ("st1" in name): return 10 00387 if ("st2" in name): return 11 00388 if ("st3" in name): return 12 00389 if ("st4" in name): return 13 00390 00391
def plotscripts::stdev | ( | xlist | ) |
Definition at line 67 of file plotscripts.py.
Referenced by MuonResidualsPositionFitter::fit(), MuonResidualsBfieldAngleFitter::fit(), and MuonResidualsAngleFitter::fit().
def plotscripts::testDeltaWithin5Sigma | ( | x, | |
sx | |||
) |
Definition at line 1052 of file plotscripts.py.
01053 : 01054 n = len(x) 01055 res = [] 01056 dr = [] 01057 #print x 01058 #print sx 01059 for i in range(1,n+1): 01060 x1 = x[i-1] 01061 sx1 = sx[i-1] 01062 x2 = x[0] 01063 sx2 = sx[0] 01064 if i<n: 01065 x2 = x[i] 01066 sx2 = sx[i] 01067 sig1 = sqrt( (sx1[0]-sx1[1])**2 + x1[1]**2 ) 01068 sig2 = sqrt( (sx2[0]-sx2[1])**2 + x2[1]**2 ) 01069 df = abs(x1[0]-x2[0]) - 3*( sig1 + sig2 ) 01070 #df = abs(sx1[1]-sx2[0]) - 5*(abs(x1[1]) + abs(x2[1])) 01071 #print i, df, '= abs(',sx1[1],'-',sx2[0],')-5*(abs(',x1[1],')+abs(',x2[1],'))' 01072 dr.append(df) 01073 if df > 0: res.append(i) 01074 #print dr 01075 #print res 01076 return res 01077
def plotscripts::testEntry | ( | testID, | |
scope, | |||
descr, | |||
severity | |||
) |
Definition at line 1038 of file plotscripts.py.
def plotscripts::testZeroWithin5Sigma | ( | x | ) |
Definition at line 1045 of file plotscripts.py.
def plotscripts::wheel0only | ( | dt, | |
wheel, | |||
station, | |||
sector | |||
) |
Definition at line 33 of file plotscripts.py.
00033 : return dt == "DT" and wheel == 0
def plotscripts::wheelLetter | ( | wheel | ) |
Definition at line 37 of file plotscripts.py.
def plotscripts::wheelm1only | ( | dt, | |
wheel, | |||
station, | |||
sector | |||
) |
Definition at line 32 of file plotscripts.py.
00032 : return dt == "DT" and wheel == -1
def plotscripts::wheelm2only | ( | dt, | |
wheel, | |||
station, | |||
sector | |||
) |
Convenience functions.
Definition at line 31 of file plotscripts.py.
00031 : return dt == "DT" and wheel == -2
def plotscripts::wheelNumber | ( | wheell | ) |
Definition at line 45 of file plotscripts.py.
Referenced by DTDataIntegrityTest::endLuminosityBlock().
def plotscripts::wheelp1only | ( | dt, | |
wheel, | |||
station, | |||
sector | |||
) |
Definition at line 34 of file plotscripts.py.
00034 : return dt == "DT" and wheel == 1
def plotscripts::wheelp2only | ( | dt, | |
wheel, | |||
station, | |||
sector | |||
) |
Definition at line 35 of file plotscripts.py.
00035 : return dt == "DT" and wheel == 2 00036
def plotscripts::wmean | ( | xlist | ) |
Definition at line 75 of file plotscripts.py.
def plotscripts::writeDQMReport | ( | fname_dqm, | |
run_name | |||
) |
Definition at line 1201 of file plotscripts.py.
01202 : 01203 tests = [] 01204 for c in TEST_RESULTS: 01205 tests.append({"objID":c, "name":c, "list":TEST_RESULTS[c]}) 01206 lt = time.localtime(time.time()) 01207 lts = "%04d-%02d-%02d %02d:%02d:%02d %s" % (lt[0], lt[1], lt[2], lt[3], lt[4], lt[5], time.tzname[1]) 01208 dqm_report = {"run":run_name, "genDate": lts, "report":tests} 01209 ff = open(fname_dqm,mode="w") 01210 print >>ff, "var DQM_REPORT = " 01211 json.dump(dqm_report,ff) 01212 #print >>ff, "];" 01213 ff.close() 01214
def plotscripts::zlines | ( | window, | |
abscissa | |||
) |
Definition at line 438 of file plotscripts.py.
00439 : 00440 global zline_tlines 00441 zline_tlines = [] 00442 for z in -401.625, -133.875, 133.875, 401.625: 00443 if abscissa is None or abscissa[0] < z < abscissa[1]: 00444 zline_tlines.append(ROOT.TLine(z, -window, z, window)) 00445 zline_tlines[-1].SetLineStyle(2) 00446 zline_tlines[-1].Draw() 00447 zline_labels = [] 00448 zline_labels.append(ROOT.TText(-550, -0.9*window, "-2")) 00449 zline_labels.append(ROOT.TText(-300, -0.9*window, "-1")) 00450 zline_labels.append(ROOT.TText(-10, -0.9*window, "0")) 00451 zline_labels.append(ROOT.TText(250, -0.9*window, "+1")) 00452 zline_labels.append(ROOT.TText(500, -0.9*window, "+2")) 00453 for z in zline_labels: z.Draw() 00454 zline_labels.append(ROOT.TText(-600, -0.75*window, "Wheel:")); zline_labels[-1].Draw()
plotscripts::CPP_LOADED = False |
Definition at line 18 of file plotscripts.py.
00001 [ 00002 {"idx":0, "name": "NONE", "color": "lightgreen", "hex":"#90EE90"}, 00003 {"idx":1, "name": "LOWSTAT05", "color": "lightgreen", "hex":"#96D953"}, 00004 {"idx":2, "name": "LOWSTAT075", "color": "lightgreen", "hex":"#94E26F"}, 00005 {"idx":3, "name": "LOWSTAT1", "color": "yellowgreen", "hex":"#9ACD32"}, 00006 {"idx":4, "name": "LOWSTAT", "color": "yellow", "hex":"#FFFF00"}, 00007 {"idx":5, "name": "TOLERABLE", "color": "lightpink", "hex":"#FFB6C1"}, 00008 {"idx":6, "name": "SEVERE", "color": "orange", "hex":"#FFA500"}, 00009 {"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.
00001 [ 00002 phiedgesCSC36, 00003 phiedgesCSC36, 00004 phiedgesCSC36, 00005 phiedgesCSC36, 00006 phiedgesCSC18, 00007 phiedgesCSC36, 00008 phiedgesCSC18, 00009 phiedgesCSC36, 00010 phiedgesCSC18, 00011 phiedgesCSC36, 00012 [0.35228048120123945, 0.87587781482541827, 1.3994776462193192, 1.923076807996136, 2.4466741416203148, 2.970273973014216, 00013 -2.7893121723885534, -2.2657148387643748, -1.7421150073704739, -1.2185158455936571, -0.69491851196947851, -0.17131868057557731], 00014 [0.22000706229660855, 0.74360690430428489, 1.267204926935573, 1.7908033890915052, 2.3144032310991816, 2.8380012537304697, 00015 -2.9215855912931841, -2.3979857492855081, -1.8743877266542202, -1.3507892644982882, -0.82718942249061178, -0.30359139985932365], 00016 [0.29751957124275596, 0.82111826253905784, 1.3447162969496083, 1.8683158980376524, 2.3919145893339548, 2.915512623744505, 00017 -2.844073082347037, -2.3204743910507353, -1.7968763566401849, -1.2732767555521407, -0.74967806425583894, -0.22608002984528835], 00018 [3.0136655290752188, -2.7530905195097337, -2.2922883025568734, -1.9222915077192773, -1.5707963267948966, -1.2193011458705159, 00019 -0.84930435103291968, -0.38850213408005951, 0.127927124514574, 0.65152597487624719, 1.1322596819239259, 1.5707963267948966, 00020 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(), RecoBTag::tdrGrid(), and tdrstyle().
dictionary plotscripts::TEST_RESULTS = {} |
Definition at line 26 of file plotscripts.py.