1 import ROOT, array, os, re, random
10 import simplejson
as json
18 MAP_RESULTS_SAWTOOTH = {}
19 MAP_RESULTS_FITSIN = {}
28 def wheelm2only(dt, wheel, station, sector):
return dt ==
"DT" and wheel == -2
29 def wheelm1only(dt, wheel, station, sector):
return dt ==
"DT" and wheel == -1
30 def wheel0only(dt, wheel, station, sector):
return dt ==
"DT" and wheel == 0
31 def wheelp1only(dt, wheel, station, sector):
return dt ==
"DT" and wheel == 1
32 def wheelp2only(dt, wheel, station, sector):
return dt ==
"DT" and wheel == 2
35 if wheel == -2:
return "A"
36 elif wheel == -1:
return "B"
37 elif wheel == 0:
return "C"
38 elif wheel == +1:
return "D"
39 elif wheel == +2:
return "E"
43 if wheell ==
"A":
return -2
44 elif wheell ==
"B":
return -1
45 elif wheell ==
"C":
return 0
46 elif wheell ==
"D":
return 1
47 elif wheell ==
"E":
return 2
70 return sqrt(s2/n - (s/n)**2)
79 return s/w,
sqrt(1./w)
86 tdrStyle = ROOT.TStyle(
"tdrStyle",
"Style for P-TDR")
88 tdrStyle.SetCanvasBorderMode(0)
89 tdrStyle.SetCanvasColor(ROOT.kWhite)
90 tdrStyle.SetCanvasDefH(600)
91 tdrStyle.SetCanvasDefW(600)
92 tdrStyle.SetCanvasDefX(0)
93 tdrStyle.SetCanvasDefY(0)
96 tdrStyle.SetPadBorderMode(0)
98 tdrStyle.SetPadColor(ROOT.kWhite)
99 tdrStyle.SetPadGridX(
False)
100 tdrStyle.SetPadGridY(
False)
101 tdrStyle.SetGridColor(0)
102 tdrStyle.SetGridStyle(3)
103 tdrStyle.SetGridWidth(1)
106 tdrStyle.SetFrameBorderMode(0)
107 tdrStyle.SetFrameBorderSize(1)
108 tdrStyle.SetFrameFillColor(0)
109 tdrStyle.SetFrameFillStyle(0)
110 tdrStyle.SetFrameLineColor(1)
111 tdrStyle.SetFrameLineStyle(1)
112 tdrStyle.SetFrameLineWidth(1)
117 tdrStyle.SetHistLineColor(1)
118 tdrStyle.SetHistLineStyle(0)
119 tdrStyle.SetHistLineWidth(1)
123 tdrStyle.SetEndErrorSize(2)
125 tdrStyle.SetErrorX(0.)
127 tdrStyle.SetMarkerStyle(20)
130 tdrStyle.SetOptFit(1)
131 tdrStyle.SetFitFormat(
"5.4g")
132 tdrStyle.SetFuncColor(2)
133 tdrStyle.SetFuncStyle(1)
134 tdrStyle.SetFuncWidth(1)
137 tdrStyle.SetOptDate(0)
142 tdrStyle.SetOptFile(0)
143 tdrStyle.SetOptStat(0)
144 tdrStyle.SetStatColor(ROOT.kWhite)
145 tdrStyle.SetStatFont(42)
146 tdrStyle.SetStatFontSize(0.025)
147 tdrStyle.SetStatTextColor(1)
148 tdrStyle.SetStatFormat(
"6.4g")
149 tdrStyle.SetStatBorderSize(1)
150 tdrStyle.SetStatH(0.1)
151 tdrStyle.SetStatW(0.15)
157 tdrStyle.SetPadTopMargin(0.05)
158 tdrStyle.SetPadBottomMargin(0.13)
159 tdrStyle.SetPadLeftMargin(0.13)
160 tdrStyle.SetPadRightMargin(0.05)
163 tdrStyle.SetOptTitle(0)
164 tdrStyle.SetTitleFont(42)
165 tdrStyle.SetTitleColor(1)
166 tdrStyle.SetTitleTextColor(1)
167 tdrStyle.SetTitleFillColor(10)
168 tdrStyle.SetTitleFontSize(0.05)
177 tdrStyle.SetTitleColor(1,
"XYZ")
178 tdrStyle.SetTitleFont(42,
"XYZ")
179 tdrStyle.SetTitleSize(0.06,
"XYZ")
182 tdrStyle.SetTitleXOffset(0.9)
183 tdrStyle.SetTitleYOffset(1.05)
187 tdrStyle.SetLabelColor(1,
"XYZ")
188 tdrStyle.SetLabelFont(42,
"XYZ")
189 tdrStyle.SetLabelOffset(0.007,
"XYZ")
190 tdrStyle.SetLabelSize(0.05,
"XYZ")
193 tdrStyle.SetAxisColor(1,
"XYZ")
194 tdrStyle.SetStripDecimals(
True)
195 tdrStyle.SetTickLength(0.03,
"XYZ")
196 tdrStyle.SetNdivisions(510,
"XYZ")
197 tdrStyle.SetPadTickX(1)
198 tdrStyle.SetPadTickY(1)
201 tdrStyle.SetOptLogx(0)
202 tdrStyle.SetOptLogy(0)
203 tdrStyle.SetOptLogz(0)
206 tdrStyle.SetPaperSize(20.,20.)
224 """Set a color palette from a given RGB list
225 stops, red, green and blue should all be lists of the same length
226 see set_decent_colors for an example"""
228 if name ==
"halfgray":
229 stops = [0.00, 0.34, 0.61, 0.84, 1.00]
230 red =
map(
lambda x: 1. - (1.-x)/2., [1.00, 0.84, 0.61, 0.34, 0.00])
231 green =
map(
lambda x: 1. - (1.-x)/2., [1.00, 0.84, 0.61, 0.34, 0.00])
232 blue =
map(
lambda x: 1. - (1.-x)/2., [1.00, 0.84, 0.61, 0.34, 0.00])
234 stops = [0.00, 0.34, 0.61, 0.84, 1.00]
235 red = [1.00, 0.84, 0.61, 0.34, 0.00]
236 green = [1.00, 0.84, 0.61, 0.34, 0.00]
237 blue = [1.00, 0.84, 0.61, 0.34, 0.00]
238 elif name ==
"blues":
239 stops = [0.00, 0.34, 0.61, 0.84, 1.00]
240 red = [1.00, 0.84, 0.61, 0.34, 0.00]
241 green = [1.00, 0.84, 0.61, 0.34, 0.00]
242 blue = [1.00, 1.00, 1.00, 1.00, 1.00]
244 stops = [0.00, 0.34, 0.61, 0.84, 1.00]
245 red = [1.00, 1.00, 1.00, 1.00, 1.00]
246 green = [1.00, 0.84, 0.61, 0.34, 0.00]
247 blue = [1.00, 0.84, 0.61, 0.34, 0.00]
248 elif name ==
"antigray":
249 stops = [0.00, 0.34, 0.61, 0.84, 1.00]
250 red = [1.00, 0.84, 0.61, 0.34, 0.00]
251 green = [1.00, 0.84, 0.61, 0.34, 0.00]
252 blue = [1.00, 0.84, 0.61, 0.34, 0.00]
257 stops = [0.00, 0.20, 0.80, 1.00]
258 red = [1.00, 1.00, 1.00, 0.50]
259 green = [1.00, 1.00, 0.00, 0.00]
260 blue = [0.20, 0.00, 0.00, 0.00]
261 elif name ==
"antifire":
262 stops = [0.00, 0.20, 0.80, 1.00]
263 red = [0.50, 1.00, 1.00, 1.00]
264 green = [0.00, 0.00, 1.00, 1.00]
265 blue = [0.00, 0.00, 0.00, 0.20]
268 stops = [0.00, 0.34, 0.61, 0.84, 1.00]
269 red = [0.00, 0.00, 0.87, 1.00, 0.51]
270 green = [0.00, 0.81, 1.00, 0.20, 0.00]
271 blue = [0.51, 1.00, 0.12, 0.00, 0.00]
273 s = array.array(
'd', stops)
274 r = array.array(
'd', red)
275 g = array.array(
'd', green)
276 b = array.array(
'd', blue)
279 ROOT.TColor.CreateGradientColorTable(npoints, s, r, g, b, ncontours)
280 ROOT.gStyle.SetNumberContours(ncontours)
288 [0.087266462599716474, 0.26179938550504211, 0.43633230751381297, 0.61086524309298951, 0.78539818789089832, 0.95993106410343132,
289 1.13446400890134, 1.3089969444805165, 1.4835298664892873, 1.6580627893946129, 1.8325957122999386, 2.0071286343087094,
290 2.1816615698878858, 2.3561945146857948, 2.5307273908983277, 2.7052603356962366, 2.8797932712754131, 3.0543261932841839,
291 -3.0543261909900767, -2.8797932680847511, -2.7052603460759803, -2.5307274104968038, -2.3561944656988949, -2.181661589486362,
292 -2.0071286446884531, -1.8325957091092766, -1.6580627871005058, -1.4835298641951802, -1.3089969412898546, -1.1344640192810838,
293 -0.95993108370190716, -0.78539813890399834, -0.61086526269146535, -0.43633231789355653, -0.26179938231437999, -0.087266460305609153],
294 [0.087266462599716474, 0.26179938297741073, 0.43633231700542385, 0.61086526005981812, 0.78539815872971441, 0.95993109326461523,
295 1.1344639919345114, 1.3089969349889057, 1.4835298690169187, 1.6580627893946129, 1.8325957097723073, 2.0071286438003204,
296 2.1816615868547147, 2.3561944855246111, 2.5307274200595118, 2.7052603187294082, 2.879793261783802, 3.0543261958118153,
297 -3.0543261909900767, -2.8797932706123825, -2.7052603365843693, -2.5307273935299754, -2.356194494860079, -2.1816615603251783,
298 -2.0071286616552819, -1.8325957186008877, -1.6580627845728746, -1.4835298641951802, -1.308996943817486, -1.1344640097894729,
299 -0.95993106673507855, -0.78539816806518226, -0.61086523353028144, -0.43633233486038514, -0.26179939180599088, -0.087266457777977771],
300 [0.087266462599716474, 0.26179938235213535, 0.43633230952414037, 0.61086523916470359, 0.78539817763669606, 0.95993107435763347,
301 1.1344640128296259, 1.3089969424701891, 1.4835298696421941, 1.6580627893946129, 1.832595709147032, 2.0071286363190368,
302 2.1816615659596001, 2.3561945044315924, 2.53072740115253, 2.7052603396245227, 2.8797932692650856, 3.0543261964370907,
303 -3.0543261909900767, -2.8797932712376579, -2.7052603440656529, -2.53072741442509, -2.3561944759530973, -2.1816615792321596,
304 -2.0071286407601674, -1.8325957111196041, -1.6580627839475992, -1.4835298641951802, -1.3089969444427614, -1.1344640172707563,
305 -0.95993108763019308, -0.7853981491582005, -0.61086525243726308, -0.43633231396527061, -0.2617993843247074, -0.087266457152702412],
306 [0.087266462599716474, 0.26179938550504211, 0.43633230751381297, 0.61086524309298951, 0.78539818789089832, 0.95993106410343132,
307 1.13446400890134, 1.3089969444805165, 1.4835298664892873, 1.6580627893946129, 1.8325957122999386, 2.0071286343087094,
308 2.1816615698878858, 2.3561945146857948, 2.5307273908983277, 2.7052603356962366, 2.8797932712754131, 3.0543261932841839,
309 -3.0543261909900767, -2.8797932680847511, -2.7052603460759803, -2.5307274104968038, -2.3561944656988949, -2.181661589486362,
310 -2.0071286446884531, -1.8325957091092766, -1.6580627871005058, -1.4835298641951802, -1.3089969412898546, -1.1344640192810838,
311 -0.95993108370190716, -0.78539813890399834, -0.61086526269146535, -0.43633231789355653, -0.26179938231437999, -0.087266460305609153],
312 [0.26179938481428705, 0.6108652193791777, 0.95993108859688125, 1.3089969578145848, 1.6580627923794755, 2.0071286538798305,
313 2.356194498693418, 2.7052603320901376, 3.0543261769037247, -2.8797932687755066, -2.5307274342106156, -2.1816615649929121,
314 -1.8325956957752083, -1.4835298612103178, -1.1344639997099626, -0.78539815489637521, -0.43633232149965551, -0.087266476686068212],
315 [0.087266462599716474, 0.26179938871066555, 0.43633231557670243, 0.61086524129631259, 0.785398172964478, 0.95993107902985153,
316 1.1344640106980168, 1.308996936417627, 1.483529863283664, 1.6580627893946129, 1.8325957155055621, 2.0071286423715993,
317 2.1816615680912093, 2.3561944997593747, 2.5307274058247482, 2.7052603374929136, 2.8797932632125236, 3.0543261900785605,
318 -3.0543261909900767, -2.8797932648791278, -2.7052603380130908, -2.5307274122934809, -2.3561944806253154, -2.1816615745599419,
319 -2.0071286428917765, -1.8325957171721663, -1.6580627903061294, -1.4835298641951802, -1.3089969380842312, -1.1344640112181943,
320 -0.95993108549858397, -0.78539815383041856, -0.61086524776504503, -0.43633231609687961, -0.26179939037726946, -0.087266463511232586],
321 [0.26179938498198485, 0.61086523665761272, 0.95993108859688125, 1.3089969405361499, 1.6580627922117777, 2.0071286313120122,
322 2.3561944778405319, 2.7052603529430232, 3.0543261994715434, -2.8797932686078087, -2.530727416932181, -2.1816615649929121,
323 -1.8325957130536434, -1.4835298613780155, -1.1344640222777811, -0.78539817574926085, -0.43633230064676976, -0.087266454118249653],
324 [0.087266462599716474, 0.26179938871066555, 0.43633231557670243, 0.61086524129631259, 0.785398172964478, 0.95993107902985153,
325 1.1344640106980168, 1.308996936417627, 1.483529863283664, 1.6580627893946129, 1.8325957155055621, 2.0071286423715993,
326 2.1816615680912093, 2.3561944997593747, 2.5307274058247482, 2.7052603374929136, 2.8797932632125236, 3.0543261900785605,
327 -3.0543261909900767, -2.8797932648791278, -2.7052603380130908, -2.5307274122934809, -2.3561944806253154, -2.1816615745599419,
328 -2.0071286428917765, -1.8325957171721663, -1.6580627903061294, -1.4835298641951802, -1.3089969380842312, -1.1344640112181943,
329 -0.95993108549858397, -0.78539815383041856, -0.61086524776504503, -0.43633231609687961, -0.26179939037726946, -0.087266463511232586],
330 [0.26179938879942166, 0.61086525092924071, 0.95993108859688125, 1.3089969262645218, 1.6580627883943408, 2.0071286288299772,
331 2.3561945088997609, 2.7052603218837943, 3.0543262019535784, -2.8797932647903717, -2.5307274026605526, -2.1816615649929121,
332 -1.8325957273252713, -1.4835298651954525, -1.1344640247598159, -0.785398144690032, -0.43633233170599861, -0.087266451636214853],
333 [0.087266462599716474, 0.26179938871066555, 0.43633231557670243, 0.61086524129631259, 0.785398172964478, 0.95993107902985153,
334 1.1344640106980168, 1.308996936417627, 1.483529863283664, 1.6580627893946129, 1.8325957155055621, 2.0071286423715993,
335 2.1816615680912093, 2.3561944997593747, 2.5307274058247482, 2.7052603374929136, 2.8797932632125236, 3.0543261900785605,
336 -3.0543261909900767, -2.8797932648791278, -2.7052603380130908, -2.5307274122934809, -2.3561944806253154, -2.1816615745599419,
337 -2.0071286428917765, -1.8325957171721663, -1.6580627903061294, -1.4835298641951802, -1.3089969380842312, -1.1344640112181943,
338 -0.95993108549858397, -0.78539815383041856, -0.61086524776504503, -0.43633231609687961, -0.26179939037726946, -0.087266463511232586],
339 [0.35228048120123945, 0.87587781482541827, 1.3994776462193192, 1.923076807996136, 2.4466741416203148, 2.970273973014216,
340 -2.7893121723885534, -2.2657148387643748, -1.7421150073704739, -1.2185158455936571, -0.69491851196947851, -0.17131868057557731],
341 [0.22000706229660855, 0.74360690430428489, 1.267204926935573, 1.7908033890915052, 2.3144032310991816, 2.8380012537304697,
342 -2.9215855912931841, -2.3979857492855081, -1.8743877266542202, -1.3507892644982882, -0.82718942249061178, -0.30359139985932365],
343 [0.29751957124275596, 0.82111826253905784, 1.3447162969496083, 1.8683158980376524, 2.3919145893339548, 2.915512623744505,
344 -2.844073082347037, -2.3204743910507353, -1.7968763566401849, -1.2732767555521407, -0.74967806425583894, -0.22608002984528835],
345 [3.0136655290752188, -2.7530905195097337, -2.2922883025568734, -1.9222915077192773, -1.5707963267948966, -1.2193011458705159,
346 -0.84930435103291968, -0.38850213408005951, 0.127927124514574, 0.65152597487624719, 1.1322596819239259, 1.5707963267948966,
347 2.0093329716658674, 2.4900666787135459]]
351 for ed
in phiedges[:]:
354 ed.extend([999
for n
in range(0,37-len(ed))])
355 lines.append(
'{' +
', '.
join(
map(str, ed)) +
'}')
357 res =
', '.
join(lines)
358 ff = open(
"phiedges_export.h",mode=
"w")
359 print>>ff,
'double phiedges[14][37] = {' + res +
'};'
368 self.ed.append(pi+1.)
373 if x < self.
ed[0]: x += 2*pi
375 for i
in range(0,self.
n):
376 if x <= self.
ed[i]:
continue
377 if x > self.
ed[i+1]:
continue
378 return par[i*2] + par[i*2+1]*(x - self.
ed[i])
381 print self.
name, self.
n
387 if (
"MB" in name
or "ME" in name):
390 if pa
is None:
return None
392 if pa[2]==1
and pa[3]==1:
return 0
393 if pa[2]==1
and pa[3]==1:
return 1
394 if pa[2]==1
and pa[3]==1:
return 2
395 if pa[2]==1
and pa[3]==1:
return 3
396 if pa[2]==1
and pa[3]==1:
return 4
397 if pa[2]==1
and pa[3]==1:
return 5
398 if pa[2]==1
and pa[3]==1:
return 6
399 if pa[2]==1
and pa[3]==1:
return 7
400 if pa[2]==1
and pa[3]==1:
return 8
401 if pa[2]==1
and pa[3]==1:
return 9
403 if pa[2]==1:
return 10
404 if pa[2]==2:
return 11
405 if pa[2]==3:
return 12
406 if pa[2]==2:
return 13
408 if (
"mem11" in name
or "mep11" in name):
return 0
409 if (
"mem12" in name
or "mep12" in name):
return 1
410 if (
"mem13" in name
or "mep13" in name):
return 2
411 if (
"mem14" in name
or "mep14" in name):
return 3
412 if (
"mem21" in name
or "mep21" in name):
return 4
413 if (
"mem22" in name
or "mep22" in name):
return 5
414 if (
"mem31" in name
or "mep31" in name):
return 6
415 if (
"mem32" in name
or "mep32" in name):
return 7
416 if (
"mem41" in name
or "mep41" in name):
return 8
417 if (
"mem42" in name
or "mep42" in name):
return 9
418 if (
"st1" in name):
return 10
419 if (
"st2" in name):
return 11
420 if (
"st3" in name):
return 12
421 if (
"st4" in name):
return 13
426 global philine_tlines, philine_labels
431 if abscissa
is None or abscissa[0] < phi < abscissa[1]:
432 philine_tlines.append(ROOT.TLine(phi, -window, phi, window))
433 philine_tlines[-1].SetLineStyle(2)
434 philine_tlines[-1].Draw()
440 labels = [
" 7",
" 8",
" 9",
"14",
"10",
"11",
"12",
" 1",
" 2",
" 3",
"13",
" 4",
" 5",
" 6"]
442 labels = [
" 8",
" 9",
"10",
"11",
"12",
" 1",
" 2",
" 3",
" 4",
" 5",
" 6"]
444 for phi, label
in zip(edges, labels):
446 if label
in (
" 7",
" 9",
"14",
"10",
"11"): littlebit = 0.05
447 philine_labels.append(ROOT.TText(phi-0.35+littlebit, -0.9*window, label))
448 philine_labels[-1].Draw()
449 philine_labels.append(ROOT.TText(-2.9, -0.75*window,
"Sector:"))
450 philine_labels[-1].Draw()
455 for z
in -401.625, -133.875, 133.875, 401.625:
456 if abscissa
is None or abscissa[0] < z < abscissa[1]:
457 zline_tlines.append(ROOT.TLine(z, -window, z, window))
458 zline_tlines[-1].SetLineStyle(2)
459 zline_tlines[-1].Draw()
461 zline_labels.append(ROOT.TText(-550, -0.9*window,
"-2"))
462 zline_labels.append(ROOT.TText(-300, -0.9*window,
"-1"))
463 zline_labels.append(ROOT.TText(-10, -0.9*window,
"0"))
464 zline_labels.append(ROOT.TText(250, -0.9*window,
"+1"))
465 zline_labels.append(ROOT.TText(500, -0.9*window,
"+2"))
466 for z
in zline_labels: z.Draw()
467 zline_labels.append(ROOT.TText(-600, -0.75*window,
"Wheel:")); zline_labels[-1].Draw()
472 if disk == 1: rl = [150., 270., 480.]
475 if abscissa
is None or abscissa[0] < r < abscissa[1]:
476 rline_tlines.append(ROOT.TLine(r, -window, r, window))
477 rline_tlines[-1].SetLineStyle(2)
478 rline_tlines[-1].Draw()
482 def DBMC(database, reports, window=10., selection=None, phi=False,
483 color=ROOT.kBlue-8, style=1, bins=50, normalized=
False, getvalues=
False, name=
""):
484 return DBdiff(database,
None, reports,
None, window, selection, phi, color, style, bins, normalized, getvalues, name)
486 def DBdiff(database1, database2, reports1, reports2, window=10., selection=None, phi=False, color=ROOT.kBlue-8,
487 style=1, bins=50, normalized=
False, getvalues=
False, name=
"tmp"):
488 tdrStyle.SetOptStat(
"emrou")
489 tdrStyle.SetStatW(0.40)
492 hx = ROOT.TH1F(
"%s_phi" % name,
"", bins, -window, window)
494 hx = ROOT.TH1F(
"%s_x" % name,
"", bins, -window, window)
495 hy = ROOT.TH1F(
"%s_y" % name,
"", bins, -window, window)
496 hz = ROOT.TH1F(
"%s_z" % name,
"", bins, -window, window)
497 hphix = ROOT.TH1F(
"%s_phix" % name,
"", bins, -window, window)
498 hphiy = ROOT.TH1F(
"%s_phiy" % name,
"", bins, -window, window)
499 hphiz = ROOT.TH1F(
"%s_phiz" % name,
"", bins, -window, window)
502 if selection
is None or (selection.func_code.co_argcount == len(r1.postal_address)
and selection(*r1.postal_address)):
504 r2 = Report(r1.chamberId, r1.postal_address, r1.name)
505 r2.add_parameters(ValErr(0., 0., 0.), ValErr(0., 0., 0.), ValErr(0., 0., 0.),
506 ValErr(0., 0., 0.), ValErr(0., 0., 0.), ValErr(0., 0., 0.), 0., 0., 0., 0.)
510 if r1.postal_address == r2.postal_address:
513 if not found:
continue
516 if r1.postal_address[0] ==
"DT":
517 if r1.postal_address[1:]
in database1.dt:
519 db1 = database1.dt[r1.postal_address[1:]]
520 if database2
is None:
522 db2.x = db2.y = db2.z = db2.phix = db2.phiy = db2.phiz = 0.
523 db2.xx = db2.xy = db2.xz = db2.yx = db2.yy = db2.yz = db2.zx = db2.zy = db2.zz = 0.
525 db2 = database2.dt[r1.postal_address[1:]]
527 if r1.postal_address[1:]
in database1.csc:
529 db1 = database1.csc[r1.postal_address[1:]]
530 if database2
is None:
532 db2.x = db2.y = db2.z = db2.phix = db2.phiy = db2.phiz = 0.
533 db2.xx = db2.xy = db2.xz = db2.yx = db2.yy = db2.yz = db2.zx = db2.zy = db2.zz = 0.
535 db2 = database2.csc[r1.postal_address[1:]]
537 if found
and r1.status ==
"PASS" and r2.status ==
"PASS":
538 if r1.deltax
is not None and r2.deltax
is not None and r1.deltax.error
is not None and \
539 r2.deltax.error
is not None and (r1.deltax.error**2 + r2.deltax.error**2) > 0.:
541 fill = (db1.x - db2.x)/
sqrt(r1.deltax.error**2 + r2.deltax.error**2) * signConventions[r1.postal_address][0]
544 fill = (db1.x - db2.x)/signConventions[r1.postal_address][3] * 1000. * signConventions[r1.postal_address][0]
546 fill = (db1.x - db2.x) * 10. * signConventions[r1.postal_address][0]
548 if getvalues
not in (
False,
None):
549 getvalues[
"x"].
append((fill, 10. *
sqrt(r1.deltax.error**2 + r2.deltax.error**2)))
551 if r1.deltay
is not None and r2.deltay
is not None and r1.deltay.error
is not None and \
552 r2.deltay.error
is not None and (r1.deltay.error**2 + r2.deltay.error**2) > 0.:
554 fill = (db1.y - db2.y)/
sqrt(r1.deltay.error**2 + r2.deltay.error**2) * signConventions[r1.postal_address][1]
556 fill = (db1.y - db2.y) * 10. * signConventions[r1.postal_address][1]
558 if getvalues
not in (
False,
None):
559 getvalues[
"y"].
append((fill, 10. *
sqrt(r1.deltay.error**2 + r2.deltay.error**2)))
561 if r1.deltaz
is not None and r2.deltaz
is not None and r1.deltaz.error
is not None and \
562 r2.deltaz.error
is not None and (r1.deltaz.error**2 + r2.deltaz.error**2) > 0.:
564 fill = (db1.z - db2.z)/
sqrt(r1.deltaz.error**2 + r2.deltaz.error**2) * signConventions[r1.postal_address][2]
566 fill = (db1.z - db2.z) * 10. * signConventions[r1.postal_address][2]
568 if getvalues
not in (
False,
None):
569 getvalues[
"z"].
append((fill, 10. *
sqrt(r1.deltaz.error**2 + r2.deltaz.error**2)))
571 if r1.deltaphix
is not None and r2.deltaphix
is not None and r1.deltaphix.error
is not None and \
572 r2.deltaphix.error
is not None and (r1.deltaphix.error**2 + r2.deltaphix.error**2) > 0.:
574 fill = (db1.phix - db2.phix)/
sqrt(r1.deltaphix.error**2 + r2.deltaphix.error**2)
576 fill = (db1.phix - db2.phix) * 1000.
578 if getvalues
not in (
False,
None):
579 getvalues[
"phix"].
append((fill, 10. *
sqrt(r1.deltaphix.error**2 + r2.deltaphix.error**2)))
581 if r1.deltaphiy
is not None and r2.deltaphiy
is not None and r1.deltaphiy.error
is not None and \
582 r2.deltaphiy.error
is not None and (r1.deltaphiy.error**2 + r2.deltaphiy.error**2) > 0.:
584 fill = (db1.phiy - db2.phiy)/
sqrt(r1.deltaphiy.error**2 + r2.deltaphiy.error**2)
586 fill = (db1.phiy - db2.phiy) * 1000.
588 if getvalues
not in (
False,
None):
589 getvalues[
"phiy"].
append((fill, 10. *
sqrt(r1.deltaphiy.error**2 + r2.deltaphiy.error**2)))
591 if r1.deltaphiz
is not None and r2.deltaphiz
is not None and r1.deltaphiz.error
is not None and \
592 r2.deltaphiz.error
is not None and (r1.deltaphiz.error**2 + r2.deltaphiz.error**2) > 0.:
594 fill = (db1.phiz - db2.phiz)/
sqrt(r1.deltaphiz.error**2 + r2.deltaphiz.error**2)
596 fill = (db1.phiz - db2.phiz) * 1000.
598 if getvalues
not in (
False,
None):
599 getvalues[
"phiz"].
append((fill, 10. *
sqrt(r1.deltaphiz.error**2 + r2.deltaphiz.error**2)))
603 hx.SetXTitle(
"#delta_{#phi} position (mrad)")
605 hx.SetXTitle(
"#delta_{x'} (mm)")
606 hy.SetXTitle(
"#delta_{y'} (mm)")
607 hz.SetXTitle(
"#delta_{z'} (mm)")
608 hphix.SetXTitle(
"#delta_{#phi_{x}} (mrad)")
609 hphiy.SetXTitle(
"#delta_{#phi_{y}} (mrad)")
610 hphiz.SetXTitle(
"#delta_{#phi_{z}} (mrad)")
613 hx.SetXTitle(
"#delta_{#phi}/#sigma_{#phi} position")
615 hx.SetXTitle(
"#delta_{x'}/#sigma_{x'}")
616 hy.SetXTitle(
"#delta_{y'}/#sigma_{y'}")
617 hz.SetXTitle(
"#delta_{z'}/#sigma_{z'}")
618 hphix.SetXTitle(
"#delta_{#phi_{x}}/#sigma_{#phi_{x}}")
619 hphiy.SetXTitle(
"#delta_{#phi_{y}}/#sigma_{#phi_{y}}")
620 hphiz.SetXTitle(
"#delta_{#phi_{z}}/#sigma_{#phi_{z}}")
622 for h
in hx, hy, hz, hphix, hphiy, hphiz:
623 h.GetXaxis().CenterTitle()
624 h.GetYaxis().CenterTitle()
625 h.SetFillColor(color)
626 h.SetLineStyle(style)
629 fx = ROOT.TF1(
"fx",
"%g * exp(-x**2/2.)/sqrt(2.*3.1415926)" % (hx.GetEntries()*2.*window/bins), -window, window)
630 fy = ROOT.TF1(
"fy",
"%g * exp(-x**2/2.)/sqrt(2.*3.1415926)" % (hy.GetEntries()*2.*window/bins), -window, window)
631 fz = ROOT.TF1(
"fz",
"%g * exp(-x**2/2.)/sqrt(2.*3.1415926)" % (hz.GetEntries()*2.*window/bins), -window, window)
632 fphix = ROOT.TF1(
"fphix",
"%g * exp(-x**2/2.)/sqrt(2.*3.1415926)" % (hphix.GetEntries()*2.*window/bins), -window, window)
633 fphiy = ROOT.TF1(
"fphiy",
"%g * exp(-x**2/2.)/sqrt(2.*3.1415926)" % (hphiy.GetEntries()*2.*window/bins), -window, window)
634 fphiz = ROOT.TF1(
"fphiz",
"%g * exp(-x**2/2.)/sqrt(2.*3.1415926)" % (hphiz.GetEntries()*2.*window/bins), -window, window)
635 for f
in fx, fy, fz, fphix, fphiy, fphiz:
637 f.SetLineColor(ROOT.kBlue)
638 for h, f
in (hx, fx), (hy, fy), (hz, fz), (hphix, fphix), (hphiy, fphiy), (hphiz, fphiz):
639 h.SetAxisRange(0, 1.1*
max(h.GetMaximum(), f.GetMaximum()),
"Y")
642 c1.GetPad(1).cd(); hx.Draw(); fx.Draw(
"same")
643 c1.GetPad(2).cd(); hy.Draw(); fy.Draw(
"same")
644 c1.GetPad(3).cd(); hz.Draw(); fz.Draw(
"same")
645 c1.GetPad(4).cd(); hphix.Draw(); fphix.Draw(
"same")
646 c1.GetPad(5).cd(); hphiy.Draw(); fphiy.Draw(
"same")
647 c1.GetPad(6).cd(); hphiz.Draw(); fphiz.Draw(
"same")
648 return hx, hy, hz, hphix, hphiy, hphiz, fx, fy, fz, fphix, fphiy, fphiz
652 c1.GetPad(1).cd(); hx.Draw()
653 c1.GetPad(2).cd(); hy.Draw()
654 c1.GetPad(3).cd(); hz.Draw()
655 c1.GetPad(4).cd(); hphix.Draw()
656 c1.GetPad(5).cd(); hphiy.Draw()
657 c1.GetPad(6).cd(); hphiz.Draw()
658 return hx, hy, hz, hphix, hphiy, hphiz
660 def DBMCVersus(quantity, versus, database, reports, window=10., selection=None, color=ROOT.kBlack):
661 return DBdiffVersus(quantity, versus, database,
None, reports,
None, window, selection, color)
663 def DBdiffVersus(quantity, versus, database1, database2, reports1, reports2, windwselection=None, color=ROOT.kBlack):
664 tdrStyle.SetOptStat(
"")
671 if selection
is None or (selection.func_code.co_argcount == len(r1.postal_address)
and selection(*r1.postal_address)):
673 r2 = Report(r1.chamberId, r1.postal_address, r1.name)
674 r2.add_parameters(ValErr(0., 0., 0.), ValErr(0., 0., 0.), ValErr(0., 0., 0.),
675 ValErr(0., 0., 0.), ValErr(0., 0., 0.), ValErr(0., 0., 0.), 0., 0., 0.)
679 if r1.postal_address == r2.postal_address:
682 if not found:
continue
685 if r1.postal_address[0] ==
"DT":
686 if r1.postal_address[1:]
in database1.dt:
688 db1 = database1.dt[r1.postal_address[1:]]
689 if database2
is None:
691 db2.x = db2.y = db2.z = db2.phix = db2.phiy = db2.phiz = 0.
692 db2.xx = db2.xy = db2.xz = db2.yx = db2.yy = db2.yz = db2.zx = db2.zy = db2.zz = 0.
694 db2 = database2.dt[r1.postal_address[1:]]
696 if r1.postal_address[1:]
in database1.csc:
698 db1 = database1.csc[r1.postal_address[1:]]
699 if database2
is None:
701 db2.x = db2.y = db2.z = db2.phix = db2.phiy = db2.phiz = 0.
702 db2.xx = db2.xy = db2.xz = db2.yx = db2.yy = db2.yz = db2.zx = db2.zy = db2.zz = 0.
704 db2 = database2.csc[r1.postal_address[1:]]
706 if found
and r1.status ==
"PASS" and r2.status ==
"PASS":
709 if quantity ==
"phi":
710 if r1.deltax
is not None and r2.deltax
is not None and r1.deltax.error
is not None and \
711 r2.deltax.error
is not None and (r1.deltax.error**2 + r2.deltax.error**2) > 0.:
713 values.append((db1.x - db2.x)/
714 signConventions[r1.postal_address][3] * 1000. * signConventions[r1.postal_address][0])
715 errors.append((r1.deltax.error**2 + r2.deltax.error**2)/
716 signConventions[r1.postal_address][3] * 1000. * signConventions[r1.postal_address][0])
718 elif quantity ==
"x":
719 if r1.deltax
is not None and r2.deltax
is not None and r1.deltax.error
is not None and \
720 r2.deltax.error
is not None and (r1.deltax.error**2 + r2.deltax.error**2) > 0.:
722 values.append((db1.x - db2.x) * 10. * signConventions[r1.postal_address][0])
723 errors.append((r1.deltax.error**2 + r2.deltax.error**2) * 10. * signConventions[r1.postal_address][0])
725 elif quantity ==
"y":
726 if r1.deltay
is not None and r2.deltay
is not None and r1.deltay.error
is not None and \
727 r2.deltay.error
is not None and (r1.deltay.error**2 + r2.deltay.error**2) > 0.:
729 values.append((db1.y - db2.y) * 10. * signConventions[r1.postal_address][1])
730 errors.append((r1.deltay.error**2 + r2.deltay.error**2) * 10. * signConventions[r1.postal_address][1])
732 elif quantity ==
"z":
733 if r1.deltaz
is not None and r2.deltaz
is not None and r1.deltaz.error
is not None and \
734 r2.deltaz.error
is not None and (r1.deltaz.error**2 + r2.deltaz.error**2) > 0.:
736 values.append((db1.z - db2.z) * 10. * signConventions[r1.postal_address][2])
737 errors.append((r1.deltaz.error**2 + r2.deltaz.error**2) * 10. * signConventions[r1.postal_address][2])
739 elif quantity ==
"phix":
740 if r1.deltaphix
is not None and r2.deltaphix
is not None and r1.deltaphix.error
is not None and \
741 r2.deltaphix.error
is not None and (r1.deltaphix.error**2 + r2.deltaphix.error**2) > 0.:
743 values.append((db1.phix - db2.phix) * 1000.)
744 errors.append((r1.deltaphix.error**2 + r2.deltaphix.error**2) * 1000.)
746 elif quantity ==
"phiy":
747 if r1.deltaphiy
is not None and r2.deltaphiy
is not None and r1.deltaphiy.error
is not None and \
748 r2.deltaphiy.error
is not None and (r1.deltaphiy.error**2 + r2.deltaphiy.error**2) > 0.:
750 values.append((db1.phiy - db2.phiy) * 1000.)
751 errors.append((r1.deltaphiy.error**2 + r2.deltaphiy.error**2) * 1000.)
753 elif quantity ==
"phiz":
754 if r1.deltaphiz
is not None and r2.deltaphiz
is not None and r1.deltaphiz.error
is not None and \
755 r2.deltaphiz.error
is not None and (r1.deltaphiz.error**2 + r2.deltaphiz.error**2) > 0.:
757 values.append((db1.phiz - db2.phiz) * 1000.)
758 errors.append((r1.deltaphiz.error**2 + r2.deltaphiz.error**2) * 1000.)
760 else:
raise Exception
763 if versus ==
"r": domain.append(signConventions[r1.postal_address][3])
764 elif versus ==
"phi": domain.append(signConventions[r1.postal_address][4])
765 elif versus ==
"z": domain.append(signConventions[r1.postal_address][5])
766 else:
raise Exception
769 bkgndhist = ROOT.TH1F("bkgndhist",
"", 100, 0., 800.)
770 bkgndhist.SetXTitle(
"R (cm)")
771 elif versus ==
"phi":
772 bkgndhist = ROOT.TH1F(
"bkgndhist",
"", 100, -pi, pi)
773 bkgndhist.SetXTitle(
"#phi (rad)")
775 bkgndhist = ROOT.TH1F(
"bkgndhist",
"", 100, -1100., 1100.)
776 bkgndhist.SetXTitle(
"z (cm)")
777 bkgndhist.GetXaxis().CenterTitle()
779 bkgndhist.SetAxisRange(-window, window,
"Y")
780 if quantity ==
"phi": bkgndhist.SetYTitle(
"#delta_{#phi} position (mrad)")
781 elif quantity ==
"x": bkgndhist.SetYTitle(
"#delta_{x'} (mm)")
782 elif quantity ==
"y": bkgndhist.SetYTitle(
"#delta_{y'} (mm)")
783 elif quantity ==
"z": bkgndhist.SetYTitle(
"#delta_{z'} (mm)")
784 elif quantity ==
"phix": bkgndhist.SetYTitle(
"#delta_{#phi_{x}} (mrad)")
785 elif quantity ==
"phiy": bkgndhist.SetYTitle(
"#delta_{#phi_{y}} (mrad)")
786 elif quantity ==
"phiz": bkgndhist.SetYTitle(
"#delta_{#phi_{z}} (mrad)")
787 else:
raise Exception
788 bkgndhist.GetYaxis().CenterTitle()
791 tgraph = ROOT.TGraphErrors(0)
793 tgraph = ROOT.TGraphErrors(len(domain), array.array(
"d", domain), array.array(
"d", values),
794 array.array(
"d", [0.]*len(domain)), array.array(
"d", errors))
795 tgraph.SetMarkerColor(color)
796 tgraph.SetLineColor(color)
799 if tgraph.GetN() > 0: tgraph.Draw(
"p")
800 return bkgndhist, tgraph, domain, values, errors
806 if len(id)!=9:
return None
809 pa = (
"DT", int(id[2:4]), int(id[5]), int(id[7:9]))
811 if pa[1]<-2
or pa[1]>2:
return None
812 if pa[2]>4:
return None
813 if pa[3]<1
or pa[3]>14
or (pa[3]==4
and pa[3]>12):
return None
817 elif id[2]==
"-": ec=2
819 pa = (
"CSC", ec, int(id[3]), int(id[5]), int(id[7:9]))
820 if pa[2]<1
or pa[2]>4:
return None
821 if pa[3]<1
or pa[3]>4
or (pa[2]>1
and pa[3]>2):
return None
822 if pa[4]<1
or pa[4]>36
or (pa[2]>1
and pa[3]==1
and pa[4]>18):
return None
828 if postal_address[0] ==
"DT":
829 wheel, station, sector = postal_address[1:]
832 return "MB%s/%d/%02d" % (w, station, sector)
833 elif postal_address[0] ==
"CSC":
834 endcap, station, ring, chamber = postal_address[1:]
835 if endcap != 1: station = -1 *
abs(station)
836 return "ME%+d/%d/%02d" % (station, ring, chamber)
840 if name[0:2] ==
"MB":
842 if wh ==
"A": w =
"-2"
843 elif wh ==
"B": w =
"-1"
844 elif wh ==
"C": w =
"-0"
845 elif wh ==
"D": w =
"+1"
846 elif wh ==
"E": w =
"+2"
850 return "MB%s/%s/%s" % (w, station, sector)
851 elif name[0:2] ==
"ME":
852 if name[2]==
"p": endcap =
"+"
853 elif name[2]==
"m": endcap =
"-"
858 return "ME%s%s/%s/%s" % (endcap, station, ring, chamber)
865 for iwheel
in DT_TYPES:
866 if iwheel[1]==
"ALL":
continue
867 dts.append(iwheel[0])
869 for wheel
in DT_TYPES:
870 if wheel[1]==
"ALL":
continue
871 for station
in wheel[2]:
872 dts.append(wheel[0]+
'/'+station[1])
874 for wheel
in DT_TYPES:
875 if wheel[1]!=
"ALL":
continue
876 for station
in wheel[2]:
877 for sector
in range(1,station[2]+1):
878 ssector =
"%02d" % sector
879 dts.append(wheel[0]+
'/'+station[1]+
'/'+ssector)
881 for wheel
in DT_TYPES:
882 if wheel[1]==
"ALL":
continue
883 for station
in wheel[2]:
884 for sector
in range(1,station[2]+1):
885 ssector =
"%02d" % sector
886 label =
"MBwh%sst%ssec%s" % (
wheelLetter(int(wheel[1])),station[1],ssector)
896 if not found:
continue
897 if r.status ==
"TOOFEWHITS" and r.posNum+r.negNum==0:
continue
898 if r.status ==
"NOFIT":
continue
899 dts.append(wheel[0]+
'/'+station[1]+
'/'+ssector)
906 for endcap
in CSC_TYPES:
907 for station
in endcap[2]:
908 for ring
in station[2]:
909 if ring[1]==
"ALL":
continue
911 cscs.append(
"%s%s/%s" % (endcap[0], station[1],ring[1]))
913 for endcap
in CSC_TYPES:
914 for station
in endcap[2]:
915 for ring
in station[2]:
916 if ring[1]!=
"ALL":
continue
917 for chamber
in range(1,ring[2]+1):
919 cscs.append(
"%s%s/ALL/%02d" % (endcap[0], station[1],chamber))
921 for endcap
in CSC_TYPES:
922 for station
in endcap[2]:
923 for ring
in station[2]:
924 if ring[1]==
"ALL":
continue
925 for chamber
in range(1,ring[2]+1):
927 if station[1]==
"4" and ring[1]==
"2":
928 if endcap[1]==
"m":
continue
929 if chamber<9
or chamber>13:
continue
930 schamber =
"%02d" % chamber
931 label =
"ME%s%s%s_%s" % (endcap[1], station[1], ring[1], schamber)
941 if not found:
continue
942 if r.status ==
"TOOFEWHITS" and r.posNum+r.negNum==0:
continue
943 if r.status ==
"NOFIT":
continue
944 cscs.append(endcap[0]+station[1]+
'/'+ring[1]+
'/'+schamber)
949 {
"idx":0,
"name":
"NONE",
"color":
"lightgreen",
"hex":
"#90EE90"},
950 {
"idx":1,
"name":
"LOWSTAT05",
"color":
"lightgreen",
"hex":
"#96D953"},
951 {
"idx":2,
"name":
"LOWSTAT075",
"color":
"lightgreen",
"hex":
"#94E26F"},
952 {
"idx":3,
"name":
"LOWSTAT1",
"color":
"yellowgreen",
"hex":
"#9ACD32"},
953 {
"idx":4,
"name":
"LOWSTAT",
"color":
"yellow",
"hex":
"#FFFF00"},
954 {
"idx":5,
"name":
"TOLERABLE",
"color":
"lightpink",
"hex":
"#FFB6C1"},
955 {
"idx":6,
"name":
"SEVERE",
"color":
"orange",
"hex":
"#FFA500"},
956 {
"idx":7,
"name":
"CRITICAL",
"color":
"red",
"hex":
"#FF0000"}];
961 if TEST_RESULTS.has_key(c): TEST_RESULTS[c].extend(res)
962 else: TEST_RESULTS[c] = res
967 for sev
in DQM_SEVERITY:
968 if sev[
"name"]==severity: s = sev[
"idx"]
969 return {
"testID":testID,
"scope":scope,
"descr":descr,
"severity":s}
973 if abs(x[1])==0.:
return 0.
974 pull =
abs(x[0])/
abs(x[1])
975 if pull <= 5:
return 0.
985 for i
in range(1,n+1):
993 sig1 =
sqrt( (sx1[0]-sx1[1])**2 + x1[1]**2 )
994 sig2 =
sqrt( (sx2[0]-sx2[1])**2 + x2[1]**2 )
995 df =
abs(x1[0]-x2[0]) - 3*( sig1 + sig2 )
999 if df > 0: res.append(i)
1009 if not postal_address:
continue
1014 if r.postal_address == postal_address:
1017 if not found:
continue
1021 scope = postal_address[0]
1024 if r.status ==
"FAIL" or r.status ==
"MINUITFAIL":
1025 res.append(
testEntry(
"FAILURE",scope,r.status+
" failure",
"CRITICAL"))
1030 nseg = r.posNum + r.negNum
1031 if r.status ==
"TOOFEWHITS" and nseg>0:
1032 res.append(
testEntry(
"LOW_STAT",scope,
"low stat, #segments=%d"%nseg,
"LOWSTAT"))
1037 sdx = 10.*r.deltax.error
1039 if sdx<0.75: res.append(
testEntry(
"LOW_STAT_DDX05",scope,
"low stat, delta(dx)=%f #segments=%d" % (sdx,nseg),
"LOWSTAT05"))
1040 elif sdx<1.: res.append(
testEntry(
"LOW_STAT_DDX075",scope,
"low stat, delta(dx)=%f #segments=%d" % (sdx,nseg),
"LOWSTAT075"))
1041 else: res.append(
testEntry(
"LOW_STAT_DDX1",scope,
"low stat, delta(dx)=%f #segments=%d" % (sdx,nseg),
"LOWSTAT1"))
1045 res.append(
testEntry(
"BIG_CHI2",scope,
"chi2=%f>2.5" % r.redchi2,
"TOLERABLE"))
1048 medx, meddx = 10.*r.median_x, 1000.*r.median_dxdz
1050 if medx>2: res.append(
testEntry(
"BIG_MED_X",scope,
"median dx=%f>2 mm"%medx,
"SEVERE"))
1052 if meddx>2: res.append(
testEntry(
"BIG_MED_DXDZ",scope,
"median d(dx/dz)=%f>2 mrad"%meddx,
"SEVERE"))
1057 if postal_address[0] ==
"DT" and postal_address[2]==4: isDTst4 =
True
1058 dx, dy, dpy, dpz = 10.*r.deltax.value, 0., 1000.*r.deltaphiy.value, 1000.*r.deltaphiz.value
1059 if not isDTst4: dy = 10.*r.deltay.value
1060 if dx>0.2: res.append(
testEntry(
"BIG_LAST_ITR_DX",scope,
"dx=%f>0.2 mm"%dx,
"CRITICAL"))
1061 if dy>0.2: res.append(
testEntry(
"BIG_LAST_ITR_DY",scope,
"dy=%f>0.2 mm"%dy,
"CRITICAL"))
1062 if dpy>0.2: res.append(
testEntry(
"BIG_LAST_ITR_DPHIY",scope,
"dphiy=%f>0.2 mrad"%dpy,
"CRITICAL"))
1063 if dpz>0.2: res.append(
testEntry(
"BIG_LAST_ITR_DPHIZ",scope,
"dphiz=%f>0.2 mrad"%dpz,
"CRITICAL"))
1074 if c[0:2]==
"MB": scope =
"DT"
1075 if c[0:2]==
"ME": scope =
"CSC"
1077 print "strange cell ID: ", c
1080 if MAP_RESULTS_FITSIN.has_key(c):
1081 t = MAP_RESULTS_FITSIN[c]
1086 descr =
"map fitsin 5 sigma away from 0; pulls : a=%.2f sin=%.2f, cos=%.2f" % (t_a,t_s,t_c)
1087 res.append(
testEntry(
"MAP_FITSIN",scope,descr,
"SEVERE"))
1089 if MAP_RESULTS_SAWTOOTH.has_key(c):
1090 t = MAP_RESULTS_SAWTOOTH[c]
1094 descr =
"map discontinuities: %s" %
",".
join(
map(str,t_a))
1095 res.append(
testEntry(
"MAP_DISCONTIN",scope,descr,
"SEVERE"))
1097 t_b =
map(testZeroWithin5Sigma, t[
'b'])
1099 for i
in range(0,len(t_b)):
1100 if t_b[i]>0: t_bi.append(i+1)
1102 descr =
"map sawteeth: %s" %
",".
join(
map(str,t_bi))
1103 res.append(
testEntry(
"MAP_SAWTEETH",scope,descr,
"TOLERABLE"))
1109 if len(MAP_RESULTS_SAWTOOTH)+len(MAP_RESULTS_FITSIN)==0:
return None
1110 ff = open(
"tmp_test_results_map__%s.pkl" % run_name,
"wb")
1111 pickle.dump(MAP_RESULTS_SAWTOOTH, ff)
1112 pickle.dump(MAP_RESULTS_FITSIN, ff)
1117 print "tmp_test_results_map__%s.pkl" % run_name, os.access(
"tmp_test_results_map__%s.pkl" % run_name,os.F_OK)
1118 if not os.access(
"tmp_test_results_map__%s.pkl" % run_name,os.F_OK):
return None
1119 global MAP_RESULTS_FITSIN, MAP_RESULTS_SAWTOOTH
1120 ff = open(
"tmp_test_results_map__%s.pkl" % run_name,
"rb")
1121 MAP_RESULTS_SAWTOOTH = pickle.load(ff)
1122 MAP_RESULTS_FITSIN = pickle.load(ff)
1130 for c
in TEST_RESULTS:
1131 tests.append({
"objID":c,
"name":c,
"list":TEST_RESULTS[c]})
1132 lt = time.localtime(time.time())
1133 lts =
"%04d-%02d-%02d %02d:%02d:%02d %s" % (lt[0], lt[1], lt[2], lt[3], lt[4], lt[5], time.tzname[1])
1134 dqm_report = {
"run":run_name,
"genDate": lts,
"report":tests}
1135 ff = open(fname_dqm,mode=
"w")
1136 print >>ff,
"var DQM_REPORT = "
1137 json.dump(dqm_report,ff)
1142 def doTests(reports,fname_base, fname_dqm, run_name):
1146 mulist = [
'Run: '+run_name,[
'ALL',[
'MU']],[
'DT',dts],[
'CSC',cscs]]
1147 ff = open(fname_base,mode=
"w")
1148 print >>ff,
"var MU_LIST = ["
1149 json.dump(mulist,ff)
1165 def plotmedians(reports1, reports2, selection=None, binsx=50, windowx=3., ceilingx=None, binsy=50, windowy=3.,
1166 ceilingy=
None, binsdxdz=50, windowdxdz=3., ceilingdxdz=
None, binsdydz=50, windowdydz=3., ceilingdydz=
None,
1167 r1text=
" before", r2text=
" after", which=
"median"):
1168 tdrStyle.SetOptStat(
"emrou")
1169 tdrStyle.SetStatW(0.40)
1170 tdrStyle.SetStatFontSize(0.05)
1172 global hmediandxdz_after, hmediandxdz_aftercopy, hmediandxdz_before, hmediandxdz_beforecopy, \
1173 hmediandydz_after, hmediandydz_aftercopy, hmediandydz_before, hmediandydz_beforecopy, \
1174 hmedianx_after, hmedianx_aftercopy, hmedianx_before, hmedianx_beforecopy, \
1175 hmediany_after, hmediany_aftercopy, hmediany_before, hmediany_beforecopy, tlegend
1177 hmedianx_before = ROOT.TH1F(
"hmedianx_before",
"", binsx, -windowx, windowx)
1178 hmediany_before = ROOT.TH1F(
"hmediany_before",
"", binsy, -windowy, windowy)
1179 hmediandxdz_before = ROOT.TH1F(
"hmediandxdz_before",
"", binsdxdz, -windowdxdz, windowdxdz)
1180 hmediandydz_before = ROOT.TH1F(
"hmediandydz_before",
"", binsdydz, -windowdydz, windowdydz)
1181 hmedianx_after = ROOT.TH1F(
"hmedianx_after",
"", binsx, -windowx, windowx)
1182 hmediany_after = ROOT.TH1F(
"hmediany_after",
"", binsy, -windowy, windowy)
1183 hmediandxdz_after = ROOT.TH1F(
"hmediandxdz_after",
"", binsdxdz, -windowdxdz, windowdxdz)
1184 hmediandydz_after = ROOT.TH1F(
"hmediandydz_after",
"", binsdydz, -windowdydz, windowdydz)
1186 if which ==
"median":
1187 whichx = whichy = whichdxdz = whichdydz =
"median"
1188 elif which ==
"bigmean":
1191 whichdxdz =
"mean20"
1192 whichdydz =
"mean50"
1193 elif which ==
"mean":
1196 whichdxdz =
"mean10"
1197 whichdydz =
"mean25"
1198 elif which ==
"bigwmean":
1201 whichdxdz =
"wmean20"
1202 whichdydz =
"wmean50"
1203 elif which ==
"wmean":
1206 whichdxdz =
"wmean10"
1207 whichdydz =
"wmean25"
1208 elif which ==
"bigstdev":
1211 whichdxdz =
"stdev20"
1212 whichdydz =
"stdev50"
1213 elif which ==
"stdev":
1216 whichdxdz =
"stdev10"
1217 whichdydz =
"stdev25"
1219 raise Exception, which +
" not recognized"
1222 if selection
is None or (selection.func_code.co_argcount == len(r1.postal_address)
and selection(*r1.postal_address)):
1225 if r1.postal_address == r2.postal_address:
1228 if not found:
continue
1230 if r1.status ==
"PASS" and r2.status ==
"PASS":
1231 hmedianx_before.Fill(10.*eval(
"r1.%s_x" % whichx))
1232 hmediandxdz_before.Fill(1000.*eval(
"r1.%s_dxdz" % whichdxdz))
1233 hmedianx_after.Fill(10.*eval(
"r2.%s_x" % whichx))
1234 hmediandxdz_after.Fill(1000.*eval(
"r2.%s_dxdz" % whichdxdz))
1236 if r1.median_y
is not None:
1237 hmediany_before.Fill(10.*eval(
"r1.%s_y" % whichy))
1238 hmediandydz_before.Fill(1000.*eval(
"r1.%s_dydz" % whichdydz))
1239 hmediany_after.Fill(10.*eval(
"r2.%s_y" % whichy))
1240 hmediandydz_after.Fill(1000.*eval(
"r2.%s_dydz" % whichdydz))
1242 hmedianx_beforecopy = hmedianx_before.Clone()
1243 hmediany_beforecopy = hmediany_before.Clone()
1244 hmediandxdz_beforecopy = hmediandxdz_before.Clone()
1245 hmediandydz_beforecopy = hmediandydz_before.Clone()
1246 hmedianx_beforecopy.SetLineStyle(2)
1247 hmediany_beforecopy.SetLineStyle(2)
1248 hmediandxdz_beforecopy.SetLineStyle(2)
1249 hmediandydz_beforecopy.SetLineStyle(2)
1251 hmedianx_before.SetFillColor(ROOT.kMagenta+2)
1252 hmediany_before.SetFillColor(ROOT.kMagenta+2)
1253 hmediandxdz_before.SetFillColor(ROOT.kMagenta+2)
1254 hmediandydz_before.SetFillColor(ROOT.kMagenta+2)
1255 hmedianx_after.SetFillColor(ROOT.kYellow)
1256 hmediany_after.SetFillColor(ROOT.kYellow)
1257 hmediandxdz_after.SetFillColor(ROOT.kYellow)
1258 hmediandydz_after.SetFillColor(ROOT.kYellow)
1260 hmedianx_aftercopy = hmedianx_after.Clone()
1261 hmediany_aftercopy = hmediany_after.Clone()
1262 hmediandxdz_aftercopy = hmediandxdz_after.Clone()
1263 hmediandydz_aftercopy = hmediandydz_after.Clone()
1264 hmedianx_aftercopy.GetXaxis().SetLabelColor(ROOT.kWhite)
1265 hmediany_aftercopy.GetXaxis().SetLabelColor(ROOT.kWhite)
1266 hmediandxdz_aftercopy.GetXaxis().SetLabelColor(ROOT.kWhite)
1267 hmediandydz_aftercopy.GetXaxis().SetLabelColor(ROOT.kWhite)
1268 hmedianx_aftercopy.GetYaxis().SetLabelColor(ROOT.kWhite)
1269 hmediany_aftercopy.GetYaxis().SetLabelColor(ROOT.kWhite)
1270 hmediandxdz_aftercopy.GetYaxis().SetLabelColor(ROOT.kWhite)
1271 hmediandydz_aftercopy.GetYaxis().SetLabelColor(ROOT.kWhite)
1273 hmedianx_after.SetXTitle(
"median(#Deltax) (mm)")
1274 hmediany_after.SetXTitle(
"median(#Deltay) (mm)")
1275 hmediandxdz_after.SetXTitle(
"median(#Deltadx/dz) (mrad)")
1276 hmediandydz_after.SetXTitle(
"median(#Deltadydz) (mrad)")
1277 hmedianx_after.GetXaxis().CenterTitle()
1278 hmediany_after.GetXaxis().CenterTitle()
1279 hmediandxdz_after.GetXaxis().CenterTitle()
1280 hmediandydz_after.GetXaxis().CenterTitle()
1282 if ceilingx
is not None: hmedianx_aftercopy.SetAxisRange(0., ceilingx,
"Y")
1283 if ceilingy
is not None: hmediany_aftercopy.SetAxisRange(0., ceilingy,
"Y")
1284 if ceilingdxdz
is not None: hmediandxdz_aftercopy.SetAxisRange(0., ceilingdxdz,
"Y")
1285 if ceilingdydz
is not None: hmediandydz_aftercopy.SetAxisRange(0., ceilingdydz,
"Y")
1291 hmedianx_aftercopy.Draw()
1292 hmedianx_before.Draw(
"same")
1293 hmedianx_after.Draw(
"same")
1294 hmedianx_beforecopy.Draw(
"same")
1295 hmedianx_after.Draw(
"axissame")
1297 tlegend = ROOT.TLegend(0.17, 0.75-0.05, 0.45+0.05, 0.9)
1298 tlegend.SetFillColor(ROOT.kWhite)
1299 tlegend.SetBorderSize(0)
1300 tlegend.AddEntry(hmedianx_after, r2text,
"f")
1301 tlegend.AddEntry(hmedianx_before, r1text,
"f")
1305 hmediandxdz_aftercopy.Draw()
1306 hmediandxdz_before.Draw(
"same")
1307 hmediandxdz_after.Draw(
"same")
1308 hmediandxdz_beforecopy.Draw(
"same")
1309 hmediandxdz_after.Draw(
"axissame")
1312 hmediany_aftercopy.Draw()
1313 hmediany_before.Draw(
"same")
1314 hmediany_after.Draw(
"same")
1315 hmediany_beforecopy.Draw(
"same")
1316 hmediany_after.Draw(
"axissame")
1319 hmediandydz_aftercopy.Draw()
1320 hmediandydz_before.Draw(
"same")
1321 hmediandydz_after.Draw(
"same")
1322 hmediandydz_beforecopy.Draw(
"same")
1323 hmediandydz_after.Draw(
"axissame")
1325 return hmediandxdz_after, hmediandxdz_aftercopy, hmediandxdz_before, hmediandxdz_beforecopy, \
1326 hmediandydz_after, hmediandydz_aftercopy, hmediandydz_before, hmediandydz_beforecopy, \
1327 hmedianx_after, hmedianx_aftercopy, hmedianx_before, hmedianx_beforecopy, \
1328 hmediany_after, hmediany_aftercopy, hmediany_before, hmediany_beforecopy, tlegend
1332 def mapplot(tfiles, name, param, mode="from2d", window=40., abscissa=None, title="",
1333 widebins=
False, fitsine=
False, fitline=
False, reset_palette=
False, fitsawteeth=
False):
1334 tdrStyle.SetOptTitle(1)
1335 tdrStyle.SetTitleBorderSize(0)
1336 tdrStyle.SetOptStat(0)
1338 tdrStyle.SetOptFit(0)
1339 tdrStyle.SetTitleFontSize(0.05)
1340 tdrStyle.SetPadRightMargin(0.1)
1346 global hist, hist2d, hist2dweight, tline1, tline2, tline3
1348 if fitsine
or fitsawteeth:
1351 print "bad id for ", name
1354 hdir =
"AlignmentMonitorMuonSystemMap1D/iter1/"
1355 hpref=
"%s_%s" % (name, param)
1358 prof = tfiles[0].Get(hhh+
"_prof").Clone(hpref+
"_prof_")
1359 profPos = tfiles[0].Get(hhh+
"_profPos").Clone(hpref+
"_profPos_")
1360 profNeg = tfiles[0].Get(hhh+
"_profNeg").Clone(hpref+
"_profNeg_")
1361 weights = tfiles[0].Get(hhh+
"_weights").Clone(hpref+
"_weights_")
1362 valweights = tfiles[0].Get(hhh+
"_valweights").Clone(hpref+
"_valweights_")
1363 hist2d = tfiles[0].Get(hhh+
"_2d").Clone(hpref+
"_2d_")
1364 hist2dweight = tfiles[0].Get(hhh+
"_2dweight").Clone(hpref+
"_2dweight_")
1366 for tfile
in tfiles[1:]:
1367 prof.Add(tfile.Get(hhh+
"_prof"))
1368 profPos.Add(tfile.Get(hhh+
"_profPos"))
1369 profNeg.Add(tfile.Get(hhh+
"_profNeg"))
1370 weights.Add(tfile.Get(hhh+
"_weights"))
1371 valweights.Add(tfile.Get(hhh+
"_valweights"))
1372 hist2d.Add(tfile.Get(hhh+
"_2d"))
1373 hist2dweight.Add(tfile.Get(hhh+
"_2dweight"))
1378 elif mode
in (
"from2d",
"from2dweight"):
1379 if mode ==
"from2d": the2d = hist2d
1380 else: the2d = hist2dweight
1382 hist = weights.Clone()
1390 for i
in xrange(0, int(weights.GetNbinsX()), skip):
1391 tmp = the2d.ProjectionY(
"tmp", i+1, i + skip)
1392 if tmp.GetEntries() > 1:
1394 hist.SetBinContent(i/skip+1, tmp.GetMean())
1395 hist.SetBinError(i/skip+1, ROOT.TMath.StudentQuantile(0.841345,tmp.GetEntries()) * tmp.GetRMS() /
sqrt(tmp.GetEntries()))
1401 hist.SetBinContent(i/skip+1, 0.)
1402 hist.SetBinError(i/skip+1, 0.)
1404 elif mode ==
"weighted":
1405 if weights.GetEntries() == 0:
1409 for i
in xrange(0, int(weights.GetNbinsX())+2):
1410 sumofweights += weights.GetBinContent(i)
1411 averageweight = sumofweights / weights.GetEntries()
1412 hist = weights.Clone()
1413 for i
in xrange(1, int(weights.GetNbinsX())+1):
1414 if weights.GetBinContent(i) > 0:
1415 thisweight = weights.GetBinContent(i) / averageweight
1416 hist.SetBinContent(i, valweights.GetBinContent(i) / thisweight)
1417 hist.SetBinError(i,
sqrt(1. / thisweight))
1419 hist.SetBinContent(i, 2000.)
1420 hist.SetBinError(i, 1000.)
1425 hist.SetAxisRange(-window, window,
"Y")
1426 if abscissa
is not None: hist.SetAxisRange(abscissa[0], abscissa[1],
"X")
1427 hist.SetMarkerStyle(20)
1428 hist.SetMarkerSize(0.75)
1429 hist.GetXaxis().CenterTitle()
1430 hist.GetYaxis().CenterTitle()
1431 hist.GetYaxis().SetTitleOffset(0.75)
1432 hist.GetXaxis().SetTitleSize(0.05)
1433 hist.GetYaxis().SetTitleSize(0.05)
1434 hist.SetTitle(title)
1435 if "vsphi" in name: hist.SetXTitle(
"Global #phi position (rad)")
1436 elif "vsz" in name: hist.SetXTitle(
"Global z position (cm)")
1437 elif "vsr" in name: hist.SetXTitle(
"Global R position (cm)")
1439 if param ==
"x": hist.SetYTitle(
"x' residual (mm)")
1440 if param ==
"dxdz": hist.SetYTitle(
"dx'/dz residual (mrad)")
1441 if param ==
"y": hist.SetYTitle(
"y' residual (mm)")
1442 if param ==
"dydz": hist.SetYTitle(
"dy'/dz residual (mm)")
1444 if param ==
"x": hist.SetYTitle(
"r#phi residual (mm)")
1445 if param ==
"dxdz": hist.SetYTitle(
"d(r#phi)/dz residual (mrad)")
1446 hist.SetMarkerColor(ROOT.kBlack)
1447 hist.SetLineColor(ROOT.kBlack)
1449 hist2d.Draw(
"colzsame")
1450 if widebins: hist.Draw(
"samee1")
1451 else: hist.Draw(
"same")
1453 if fitsine
and "vsphi" in name:
1454 global fitsine_const, fitsine_sin, fitsine_cos, fitsine_chi2, fitsine_ndf
1455 f = ROOT.TF1(
"f",
"[0] + [1]*sin(x) + [2]*cos(x)", -pi, pi)
1458 f.SetLineColor(ROOT.kRed)
1459 fitsine_const = f.GetParameter(0), f.GetParError(0)
1460 fitsine_sin = f.GetParameter(1), f.GetParError(1)
1461 fitsine_cos = f.GetParameter(2), f.GetParError(2)
1462 fitsine_chi2 = f.GetChisquare()
1463 fitsine_ndf = f.GetNDF()
1464 global MAP_RESULTS_FITSIN
1465 MAP_RESULTS_FITSIN[id] = {
'a':fitsine_const,
'sin': fitsine_sin,
'cos': fitsine_cos,
'chi2': fitsine_chi2,
'ndf': fitsine_ndf}
1467 global fitsine_ttext
1468 fitsine_ttext = ROOT.TLatex(-1., 0.8*window,
1469 "%.3g %+.3g sin(#phi) %+.3g cos(#phi)" % (fitsine_const[0], fitsine_sin[0], fitsine_cos[0]))
1470 fitsine_ttext.SetTextColor(ROOT.kRed)
1471 fitsine_ttext.Draw()
1474 f = ROOT.TF1(
"f",
"[0] + [1]*x", -1000., 1000.)
1476 hist2d.GetFunction(
"f").SetLineColor(ROOT.kRed)
1477 global fitline_const, fitline_linear, fitline_chi2, fitline_ndf
1478 fitline_const = hist2d.GetFunction(
"f").GetParameter(0), hist2d.GetFunction(
"f").GetParError(0)
1479 fitline_linear = hist2d.GetFunction(
"f").GetParameter(1), hist2d.GetFunction(
"f").GetParError(1)
1480 fitline_chi2 = hist2d.GetFunction(
"f").GetChisquare()
1481 fitline_ndf = hist2d.GetFunction(
"f").GetNDF()
1482 hist2d.GetFunction(
"f").Draw(
"same")
1483 global fitline_ttext
1484 if "vsz" in name: which =
"Z"
1485 elif "vsr" in name: which =
"R"
1486 fitline_ttext = ROOT.TText(hist.GetBinCenter(hist.GetNbinsX()/4),
1487 0.8*window, "%.3g %+.3g %s" % (fitline_const[0], fitline_linear[0], which))
1488 fitline_ttext.SetTextColor(ROOT.kRed)
1489 fitline_ttext.Draw()
1491 ROOT.gPad.RedrawAxis()
1494 if not widebins:
philines(name, window, abscissa)
1495 if abscissa
is None:
1496 tline1 = ROOT.TLine(-pi, 0, pi, 0); tline1.Draw()
1497 tline2 = ROOT.TLine(-pi, -window, pi, -window); tline2.SetLineWidth(2); tline2.Draw()
1498 tline3 = ROOT.TLine(-pi, window, pi, window); tline3.Draw()
1500 tline1 = ROOT.TLine(abscissa[0], 0, abscissa[1], 0); tline1.Draw()
1501 tline2 = ROOT.TLine(abscissa[0], -window, abscissa[1], -window); tline2.SetLineWidth(2); tline2.Draw()
1502 tline3 = ROOT.TLine(abscissa[0], window, abscissa[1], window); tline3.Draw()
1504 if not widebins:
zlines(window, abscissa)
1505 if abscissa
is None:
1506 tline1 = ROOT.TLine(-660, 0, 660, 0); tline1.Draw()
1507 tline2 = ROOT.TLine(-660, -window, 660, -window); tline2.SetLineWidth(2); tline2.Draw()
1508 tline3 = ROOT.TLine(-660, window, 660, window); tline3.Draw()
1510 tline1 = ROOT.TLine(abscissa[0], 0, abscissa[1], 0); tline1.Draw()
1511 tline2 = ROOT.TLine(abscissa[0], -window, abscissa[1], -window); tline2.SetLineWidth(2); tline2.Draw()
1512 tline3 = ROOT.TLine(abscissa[0], window, abscissa[1], window); tline3.Draw()
1514 if "mem1" in name
or "mep1" in name
and not widebins:
rlines(1, window, abscissa)
1515 if "mem2" in name
or "mep2" in name
and not widebins:
rlines(2, window, abscissa)
1516 if "mem3" in name
or "mep3" in name
and not widebins:
rlines(3, window, abscissa)
1517 if "mem4" in name
or "mep4" in name
and not widebins:
rlines(4, window, abscissa)
1518 if abscissa
is None:
1519 tline1 = ROOT.TLine(100, 0, 700, 0); tline1.Draw()
1520 tline2 = ROOT.TLine(100, -window, 700, -window); tline2.SetLineWidth(2); tline2.Draw()
1521 tline3 = ROOT.TLine(100, window, 700, window); tline3.Draw()
1523 tline1 = ROOT.TLine(abscissa[0], 0, abscissa[1], 0); tline1.Draw()
1524 tline2 = ROOT.TLine(abscissa[0], -window, abscissa[1], -window); tline2.SetLineWidth(2); tline2.Draw()
1525 tline3 = ROOT.TLine(abscissa[0], window, abscissa[1], window); tline3.Draw()
1527 if "vsphi" in name
and fitsawteeth:
1531 ROOT.gROOT.ProcessLine(
".L phiedges_fitfunctions.C++")
1549 fn.SetLineColor(ROOT.kYellow)
1557 ed.append(pi+
abs(ed[0]))
1559 global sawtooth_a, sawtooth_b
1563 for pr
in range(0,fn.GetNpar(),2):
1564 sawtooth_a.append( (fn.GetParameter(pr), fn.GetParError(pr)) )
1565 sawtooth_b.append( (fn.GetParameter(pr+1), fn.GetParError(pr+1)) )
1566 sawtooth_da.append( (fn.Eval(ed[pr/2]+0.01), fn.Eval(ed[pr/2+1]-0.01)) )
1567 global MAP_RESULTS_SAWTOOTH
1568 MAP_RESULTS_SAWTOOTH[id] = {
'a': sawtooth_a,
'da': sawtooth_da,
'b': sawtooth_b,
'chi2': fn.GetChisquare(),
'ndf': fn.GetNDF()}
1574 ROOT.SetOwnership(hist2d,
False)
1575 ROOT.SetOwnership(hist2dweight,
False)
1576 ROOT.SetOwnership(tline1,
False)
1577 ROOT.SetOwnership(tline2,
False)
1578 ROOT.SetOwnership(tline3,
False)
1585 if name.find(
'wh')>1: wh = name[name.find(
'wh')+2]
1586 if wh ==
"A": w =
"-2"
1587 elif wh ==
"B": w =
"-1"
1588 elif wh ==
"C": w =
"-0"
1589 elif wh ==
"D": w =
"+1"
1590 elif wh ==
"E": w =
"+2"
1591 elif wh ==
"-ALL": w =
"-ALL"
1595 if name.find(
'sec')<0:
return None
1596 station = name[name.find(
'sec')-1]
1598 sector = name[name.find(
'sec')+3:name.find(
'sec')+5]
1599 return "MB%s/%s/%s" % (w, station, sector)
1600 if name.find(
'st')>1: station = name[name.find(
'st')+2]
1602 return "MB%s/%s" % (w, station)
1606 if name[p+2]==
"p": endcap =
"+"
1607 elif name[p+2]==
"m": endcap =
"-"
1610 pch = name.find(
'ch')
1613 return "ME%s%s/%s" % (endcap, station, ring)
1615 chamber = name[pch+2:pch+4]
1616 return "ME%s%s/%s/%s" % (endcap, station, ring, chamber)
1620 def curvatureplot(tfiles, name, param, mode="from2d", window=15., widebins=False, title="", fitgauss=False, fitconst=False, fitline=False, reset_palette=False):
1622 tdrStyle.SetOptTitle(1)
1623 tdrStyle.SetTitleBorderSize(0)
1624 tdrStyle.SetOptStat(0)
1625 tdrStyle.SetOptFit(0)
1626 tdrStyle.SetTitleFontSize(0.05)
1630 global hist, histCOPY, hist2d, tline1, tline2, tline3, tline4, tline5
1632 hdir =
"AlignmentMonitorMuonVsCurvature/iter1/"
1634 if name
not in (
"all",
"top",
"bottom"):
1635 hsuffix =
"_%s_%s" % (name, param)
1636 prof = tfiles[0].Get(hdir+
"tprofile"+hsuffix).Clone(
"tprofile_"+hsuffix)
1637 hist2d = tfiles[0].Get(hdir+
"th2f"+hsuffix).Clone(
"th2f_"+hsuffix)
1638 for tfile
in tfiles[1:]:
1639 prof.Add(tfile.Get(hdir+
"tprofile"+hsuffix))
1640 hist2d.Add(tfile.Get(hdir+
"th2f"+hsuffix))
1644 for wheel
in "m2",
"m1",
"z",
"p1",
"p2":
1645 if name ==
"all": sectors =
"01",
"02",
"03",
"04",
"05",
"06",
"07",
"08",
"09",
"10",
"11",
"12"
1646 elif name ==
"top": sectors =
"01",
"02",
"03",
"04",
"05",
"06"
1647 elif name ==
"bottom": sectors =
"07",
"08",
"09",
"10",
"11",
"12"
1648 else:
raise Exception
1650 for sector
in sectors:
1651 hsuffix =
"_%s_%s" % (
"wheel%s_sector%s" % (wheel, sector), param)
1652 for tfile
in tfiles:
1654 prof = tfiles[0].Get(hdir+
"tprofile"+hsuffix).Clone(
"tprofile_"+hsuffix)
1655 hist2d = tfiles[0].Get(hdir+
"th2f"+hsuffix).Clone(
"tprofile_"+hsuffix)
1657 prof.Add(tfile.Get(hdir+
"tprofile"+hsuffix))
1658 hist2d.Add(tfile.Get(hdir+
"th2f"+hsuffix))
1660 hist = ROOT.TH1F(
"hist",
"", prof.GetNbinsX(), prof.GetBinLowEdge(1), -prof.GetBinLowEdge(1))
1661 for i
in xrange(1, prof.GetNbinsX()+1):
1662 hist.SetBinContent(i, prof.GetBinContent(i))
1663 hist.SetBinError(i, prof.GetBinError(i))
1667 elif mode ==
"from2d":
1672 for i
in xrange(0, int(prof.GetNbinsX()), skip):
1673 tmp = hist2d.ProjectionY(
"tmp", i+1, i + skip)
1674 if tmp.GetEntries() > 1:
1675 hist.SetBinContent(i/skip+1, tmp.GetMean())
1676 hist.SetBinError(i/skip+1, ROOT.TMath.StudentQuantile(0.841345,tmp.GetEntries()) * tmp.GetRMS() /
sqrt(tmp.GetEntries()))
1681 hist.SetBinContent(i/skip+1, 0.)
1682 hist.SetBinError(i/skip+1, 0.)
1688 f = ROOT.TF1(
"f",
"[0] + [1]*exp(-x**2/2/0.01**2)", hist.GetBinLowEdge(1), -hist.GetBinLowEdge(1))
1689 f.SetParameters(0, 0., 0.01)
1691 f.SetLineColor(ROOT.kRed)
1692 global fitgauss_diff, fitgauss_chi2, fitgauss_ndf
1696 fitgauss_diff = f.GetParameter(1), f.GetParError(1)
1697 fitgauss_chi2 = f.GetChisquare()
1698 fitgauss_ndf = f.GetNDF()
1700 global fitline_intercept, fitline_slope
1702 f = ROOT.TF1(
"f",
"[0]", hist.GetBinLowEdge(1), -hist.GetBinLowEdge(1))
1704 f.SetLineColor(ROOT.kRed)
1705 fitline_intercept = f.GetParameter(0), f.GetParError(0)
1708 f = ROOT.TF1(
"f",
"[0] + [1]*x", hist.GetBinLowEdge(1), -hist.GetBinLowEdge(1))
1710 f.SetLineColor(ROOT.kRed)
1712 f2 = ROOT.TF1(
"2",
"[0] + [1]*x", hist.GetBinLowEdge(1), -hist.GetBinLowEdge(1))
1713 f3 = ROOT.TF1(
"2",
"[0] + [1]*x", hist.GetBinLowEdge(1), -hist.GetBinLowEdge(1))
1714 f2.SetParameters(f.GetParameter(0), f.GetParameter(1) + f.GetParError(1))
1715 f3.SetParameters(f.GetParameter(0), f.GetParameter(1) - f.GetParError(1))
1716 f2.SetLineColor(ROOT.kRed)
1717 f3.SetLineColor(ROOT.kRed)
1720 fitline_intercept = f.GetParameter(0), f.GetParError(0)
1721 fitline_slope = f.GetParameter(1), f.GetParError(1)
1723 hist.SetAxisRange(-window, window,
"Y")
1724 hist.SetMarkerStyle(20)
1725 hist.SetMarkerSize(0.75)
1726 hist.GetXaxis().CenterTitle()
1727 hist.GetYaxis().CenterTitle()
1728 if param ==
"curverr":
1729 hist.GetYaxis().SetTitleOffset(1.35)
1731 hist.GetYaxis().SetTitleOffset(0.75)
1732 hist.GetXaxis().SetTitleOffset(1.2)
1733 hist.GetXaxis().SetTitleSize(0.05)
1734 hist.GetYaxis().SetTitleSize(0.05)
1735 hist.SetTitle(title)
1736 if param ==
"pterr": hist.SetXTitle(
"qp_{T} (GeV/c)")
1737 else: hist.SetXTitle(
"q/p_{T} (c/GeV)")
1738 if param ==
"deltax": hist.SetYTitle(
"#Deltax' (mm)")
1739 if param ==
"deltadxdz": hist.SetYTitle(
"#Deltadx'/dz (mrad)")
1740 if param ==
"pterr": hist.SetYTitle(
"#Deltap_{T}/p_{T} (%)")
1741 if param ==
"curverr": hist.SetYTitle(
"#Deltaq/p_{T} (c/GeV)")
1742 hist.SetMarkerColor(ROOT.kBlack)
1743 hist.SetLineColor(ROOT.kBlack)
1745 hist2d.Draw(
"colzsame")
1746 histCOPY = hist.Clone()
1747 histCOPY.SetXTitle(
"")
1748 histCOPY.SetYTitle(
"")
1751 histCOPY.Draw(
"samee1")
1752 histCOPY.Draw(
"sameaxis")
1754 histCOPY.Draw(
"same")
1755 histCOPY.Draw(
"sameaxis")
1762 tline1 = ROOT.TLine(hist.GetBinLowEdge(1), -window, hist.GetBinLowEdge(1), window)
1763 tline2 = ROOT.TLine(hist.GetBinLowEdge(1), window, -hist.GetBinLowEdge(1), window)
1764 tline3 = ROOT.TLine(-hist.GetBinLowEdge(1), window, -hist.GetBinLowEdge(1), -window)
1765 tline4 = ROOT.TLine(-hist.GetBinLowEdge(1), -window, hist.GetBinLowEdge(1), -window)
1766 tline5 = ROOT.TLine(-hist.GetBinLowEdge(1), 0., hist.GetBinLowEdge(1), 0.)
1767 for t
in tline1, tline2, tline3, tline4, tline5: t.Draw()
1771 global h, gm2, gm1, gz, gp1, gp2, tlegend
1774 phis = {-2: [], -1: [], 0: [], 1: [], 2: []}
1775 diffs = {-2: [], -1: [], 0: [], 1: [], 2: []}
1776 differrs = {-2: [], -1: [], 0: [], 1: [], 2: []}
1777 for wheelstr, wheel
in (
"m2",
"-2"), (
"m1",
"-1"), (
"z",
"0"), (
"p1",
"+1"), (
"p2",
"+2"):
1778 for sector
in "01",
"02",
"03",
"04",
"05",
"06",
"07",
"08",
"09",
"10",
"11",
"12":
1779 curvatureplot(tfiles,
"wheel%s_sector%s" % (wheelstr, sector),
"deltax",
1780 title=
"Wheel %s, sector %s" % (wheel, sector), fitgauss=
True, reset_palette=
False)
1781 if fitgauss_diff[1] < window:
1782 uncertainty = fitgauss_diff[1]
1783 if pdgSfactor
and (fitgauss_chi2/fitgauss_ndf) > 1.: uncertainty *=
sqrt(fitgauss_chi2/fitgauss_ndf)
1785 phis[int(wheel)].
append(signConventions[
"DT", int(wheel), 1, int(sector)][4])
1786 diffs[int(wheel)].
append(fitgauss_diff[0])
1787 differrs[int(wheel)].
append(uncertainty)
1789 h = ROOT.TH1F(
"h",
"", 1, -pi, pi)
1790 h.SetAxisRange(-window, window,
"Y")
1791 h.SetXTitle(
"#phi (rad)")
1792 h.SetYTitle(
"#Deltax(p_{T} #rightarrow #infty) - #Deltax(p_{T} #rightarrow 0) (mm)")
1793 h.GetXaxis().CenterTitle()
1794 h.GetYaxis().CenterTitle()
1796 gm2 = ROOT.TGraphErrors(len(phis[-2]), array.array(
"d", phis[-2]), array.array(
"d", diffs[-2]),
1797 array.array(
"d", [0.]*len(phis[-2])), array.array(
"d", differrs[-2]))
1798 gm1 = ROOT.TGraphErrors(len(phis[-1]), array.array(
"d", phis[-1]), array.array(
"d", diffs[-1]),
1799 array.array(
"d", [0.]*len(phis[-1])), array.array(
"d", differrs[-1]))
1800 gz = ROOT.TGraphErrors(len(phis[0]), array.array(
"d", phis[0]), array.array(
"d", diffs[0]),
1801 array.array(
"d", [0.]*len(phis[0])), array.array(
"d", differrs[0]))
1802 gp1 = ROOT.TGraphErrors(len(phis[1]), array.array(
"d", phis[1]), array.array(
"d", diffs[1]),
1803 array.array(
"d", [0.]*len(phis[1])), array.array(
"d", differrs[1]))
1804 gp2 = ROOT.TGraphErrors(len(phis[2]), array.array(
"d", phis[2]), array.array(
"d", diffs[2]),
1805 array.array(
"d", [0.]*len(phis[2])), array.array(
"d", differrs[2]))
1807 gm2.SetMarkerStyle(21); gm2.SetMarkerColor(ROOT.kRed); gm2.SetLineColor(ROOT.kRed)
1808 gm1.SetMarkerStyle(22); gm1.SetMarkerColor(ROOT.kBlue); gm1.SetLineColor(ROOT.kBlue)
1809 gz.SetMarkerStyle(3); gz.SetMarkerColor(ROOT.kBlack); gz.SetLineColor(ROOT.kBlack)
1810 gp1.SetMarkerStyle(26); gp1.SetMarkerColor(ROOT.kBlue); gp1.SetLineColor(ROOT.kBlue)
1811 gp2.SetMarkerStyle(25); gp2.SetMarkerColor(ROOT.kRed); gp2.SetLineColor(ROOT.kRed)
1814 tlegend = ROOT.TLegend(0.25, 0.2, 0.85, 0.5)
1815 tlegend.SetFillColor(ROOT.kWhite)
1816 tlegend.SetBorderSize(0)
1817 tlegend.AddEntry(gm2,
"Wheel -2",
"p")
1818 tlegend.AddEntry(gm1,
"Wheel -1",
"p")
1819 tlegend.AddEntry(gz,
"Wheel 0",
"p")
1820 tlegend.AddEntry(gp1,
"Wheel +1",
"p")
1821 tlegend.AddEntry(gp2,
"Wheel +2",
"p")
1832 if r.postal_address[0] ==
"DT":
1833 wheel, station, sector = r.postal_address[1:]
1834 return "DT wheel %d, station %d, sector %d" % (wheel, station, sector)
1835 elif r.postal_address[0] ==
"CSC":
1836 endcap, station, ring, chamber = r.postal_address[1:]
1837 if endcap != 1: station = -1 *
abs(station)
1838 return "CSC ME%d/%d chamber %d" % (station, ring, chamber)
1840 ddt=[0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.]
1842 for i
in range(0,15):
1848 if n==0
or n==7
or n==15:
print "%d calls" % t
1849 else:
print "%d : %0.3f ms" % (n,t*1000.0)
1852 def bellcurves(tfile, reports, name, twobin=True, suppressblue=False):
1855 tdrStyle.SetOptTitle(1)
1856 tdrStyle.SetTitleBorderSize(1)
1857 tdrStyle.SetTitleFontSize(0.1)
1858 tdrStyle.SetOptStat(0)
1859 tdrStyle.SetHistMinimumZero()
1869 if not found:
raise Exception,
"Not a valid name"
1870 if r.status ==
"FAIL":
1876 Pos =
"Pos"; Neg =
"Neg"
1880 pdirPos =
"MuonAlignmentFromReference/%s%s" % (name, Pos)
1881 pdirNeg =
"MuonAlignmentFromReference/%s%s" % (name, Neg)
1884 ddt[1] = 1./ddt[0]*((ddt[0]-1)*ddt[1] + t2-t1)
1886 chamber_x = tfile.Get(pdirPos+
"_x")
1887 chamber_x_fit = tfile.Get(pdirPos+
"_x_fit")
1888 chamber_y = tfile.Get(pdirPos+
"_y")
1889 chamber_y_fit = tfile.Get(pdirPos+
"_y_fit")
1890 chamber_dxdz = tfile.Get(pdirPos+
"_dxdz")
1891 chamber_dxdz_fit = tfile.Get(pdirPos+
"_dxdz_fit")
1892 chamber_dydz = tfile.Get(pdirPos+
"_dydz")
1893 chamber_dydz_fit = tfile.Get(pdirPos+
"_dydz_fit")
1894 chamber_alphax = tfile.Get(pdirPos+
"_alphax")
1895 chamber_alphax_fit = tfile.Get(pdirPos+
"_alphax_fit")
1896 chamber_alphay = tfile.Get(pdirPos+
"_alphay")
1897 chamber_alphay_fit = tfile.Get(pdirPos+
"_alphay_fit")
1898 chamber_x_fit2 = tfile.Get(pdirNeg+
"_x_fit")
1899 chamber_y_fit2 = tfile.Get(pdirNeg+
"_y_fit")
1900 chamber_dxdz_fit2 = tfile.Get(pdirNeg+
"_dxdz_fit")
1901 chamber_dydz_fit2 = tfile.Get(pdirNeg+
"_dydz_fit")
1902 chamber_alphax_fit2 = tfile.Get(pdirNeg+
"_alphax_fit")
1903 chamber_alphay_fit2 = tfile.Get(pdirNeg+
"_alphay_fit")
1906 chamber_x = tfile.Get(pdirPos+
"_residual")
1907 chamber_x_fit = tfile.Get(pdirPos+
"_residual_fit")
1908 chamber_dxdz = tfile.Get(pdirPos+
"_resslope")
1909 chamber_dxdz_fit = tfile.Get(pdirPos+
"_resslope_fit")
1910 chamber_alphax = tfile.Get(pdirPos+
"_alpha")
1911 chamber_alphax_fit = tfile.Get(pdirPos+
"_alpha_fit")
1912 chamber_x_fit2 = tfile.Get(pdirNeg+
"_residual_fit")
1913 chamber_dxdz_fit2 = tfile.Get(pdirNeg+
"_resslope_fit")
1914 chamber_alphax_fit2 = tfile.Get(pdirNeg+
"_alpha_fit")
1917 print "Can't find neither "+pdirPos+
"_x nor "+pdirPos+
"_residual"
1921 ddt[2] = 1./ddt[0]*((ddt[0]-1)*ddt[2] + t3-t2)
1924 chamber_x.SetAxisRange(-30., 30.,
"X")
1925 chamber_dxdz.SetAxisRange(-50., 50.,
"X")
1926 if not not chamber_y:
1927 chamber_y.SetAxisRange(-150., 150.,
"X")
1928 chamber_dydz.SetAxisRange(-200., 200.,
"X")
1931 chamber_x.SetXTitle(
"Local x residual (mm)")
1932 chamber_dxdz.SetXTitle(
"Local dx/dz residual (mrad)")
1933 chamber_alphax.SetXTitle(
"Local dx/dz residual (mrad)")
1934 chamber_alphax.SetYTitle(
"Local x residual (mm)")
1935 if not not chamber_y:
1936 chamber_y.SetXTitle(
"Local y residual (mm)")
1937 chamber_dydz.SetXTitle(
"Local dy/dz residual (mrad)")
1938 chamber_alphay.SetXTitle(
"Local dy/dz residual (mrad)")
1939 chamber_alphay.SetYTitle(
"Local y residual (mm)")
1940 if name[0:2] ==
"ME":
1941 chamber_x.SetXTitle(
"Local r#phi residual (mm)")
1942 chamber_dxdz.SetXTitle(
"Local d(r#phi)/dz residual (mrad)")
1943 chamber_alphax.SetXTitle(
"Local d(r#phi)/dz residual (mrad)")
1944 chamber_alphax.SetYTitle(
"Local r#phi residual (mm)")
1947 ddt[3] = 1./ddt[0]*((ddt[0]-1)*ddt[3] + t4-t3)
1949 for h
in chamber_x, chamber_dxdz, chamber_alphax, chamber_alphax, \
1950 chamber_y, chamber_dydz, chamber_alphay, chamber_alphay:
1952 h.GetXaxis().CenterTitle()
1953 h.GetYaxis().CenterTitle()
1954 h.GetXaxis().SetLabelSize(0.05)
1955 h.GetYaxis().SetLabelSize(0.05)
1956 h.GetXaxis().SetTitleSize(0.07)
1957 h.GetYaxis().SetTitleSize(0.07)
1958 h.GetXaxis().SetTitleOffset(0.9)
1959 h.GetYaxis().SetTitleOffset(0.9)
1961 for f
in chamber_x_fit2, chamber_y_fit2, chamber_dxdz_fit2, chamber_dydz_fit2, \
1962 chamber_alphax_fit2, chamber_alphay_fit2:
1967 ddt[4] = 1./ddt[0]*((ddt[0]-1)*ddt[4] + t5-t4)
1969 if not not chamber_y:
1972 chamber_x.SetTitle(
getname(r))
1976 if not suppressblue: chamber_x_fit2.Draw(
"same")
1977 chamber_x_fit.Draw(
"same")
1981 if not suppressblue: chamber_dxdz_fit2.Draw(
"same")
1982 chamber_dxdz_fit.Draw(
"same")
1985 chamber_alphax.Draw()
1986 if not suppressblue: chamber_alphax_fit2.Draw(
"same")
1987 chamber_alphax_fit.Draw(
"same")
1991 if not suppressblue: chamber_y_fit2.Draw(
"same")
1992 chamber_y_fit.Draw(
"same")
1996 if not suppressblue: chamber_dydz_fit2.Draw(
"same")
1997 chamber_dydz_fit.Draw(
"same")
2000 chamber_alphay.Draw()
2001 if not suppressblue: chamber_alphay_fit2.Draw(
"same")
2002 chamber_alphay_fit.Draw(
"same")
2007 chamber_x.SetTitle(
getname(r))
2011 if not suppressblue: chamber_x_fit2.Draw(
"same")
2012 chamber_x_fit.Draw(
"same")
2016 if not suppressblue: chamber_dxdz_fit2.Draw(
"same")
2017 chamber_dxdz_fit.Draw(
"same")
2020 chamber_alphax.Draw()
2021 if not suppressblue: chamber_alphax_fit2.Draw(
"same")
2022 chamber_alphax_fit.Draw(
"same")
2025 ddt[5] = 1./ddt[0]*((ddt[0]-1)*ddt[5] + t6-t5)
2026 ddt[6] = 1./ddt[0]*((ddt[0]-1)*ddt[6] + t6-t1)
2029 def polynomials(tfile, reports, name, twobin=True, suppressblue=False):
2032 global label1, label2, label3, label4, label5, label6, label7, label8, label9
2033 plotDirectory =
"MuonAlignmentFromReference"
2034 tdrStyle.SetOptTitle(1)
2035 tdrStyle.SetTitleBorderSize(1)
2036 tdrStyle.SetTitleFontSize(0.1)
2037 tdrStyle.SetOptStat(0)
2047 if not found:
raise Exception,
"Not a valid name"
2049 if r.status ==
"FAIL":
2055 Pos =
"Pos"; Neg =
"Neg"
2059 pdirPos =
"MuonAlignmentFromReference/%s%s" % (name, Pos)
2060 pdirNeg =
"MuonAlignmentFromReference/%s%s" % (name, Neg)
2062 global chamber_x_trackx, chamber_x_trackx_fit, chamber_y_trackx, chamber_y_trackx_fit, \
2063 chamber_dxdz_trackx, chamber_dxdz_trackx_fit, chamber_dydz_trackx, chamber_dydz_trackx_fit, \
2064 chamber_x_trackx_fit2, chamber_y_trackx_fit2, chamber_dxdz_trackx_fit2, chamber_dydz_trackx_fit2
2065 global chamber_x_tracky, chamber_x_tracky_fit, chamber_y_tracky, chamber_y_tracky_fit, \
2066 chamber_dxdz_tracky, chamber_dxdz_tracky_fit, chamber_dydz_tracky, chamber_dydz_tracky_fit, \
2067 chamber_x_tracky_fit2, chamber_y_tracky_fit2, chamber_dxdz_tracky_fit2, chamber_dydz_tracky_fit2
2068 global chamber_x_trackdxdz, chamber_x_trackdxdz_fit, chamber_y_trackdxdz, chamber_y_trackdxdz_fit, \
2069 chamber_dxdz_trackdxdz, chamber_dxdz_trackdxdz_fit, chamber_dydz_trackdxdz, chamber_dydz_trackdxdz_fit, \
2070 chamber_x_trackdxdz_fit2, chamber_y_trackdxdz_fit2, chamber_dxdz_trackdxdz_fit2, chamber_dydz_trackdxdz_fit2
2071 global chamber_x_trackdydz, chamber_x_trackdydz_fit, chamber_y_trackdydz, chamber_y_trackdydz_fit, \
2072 chamber_dxdz_trackdydz, chamber_dxdz_trackdydz_fit, chamber_dydz_trackdydz, chamber_dydz_trackdydz_fit, \
2073 chamber_x_trackdydz_fit2, chamber_y_trackdydz_fit2, chamber_dxdz_trackdydz_fit2, chamber_dydz_trackdydz_fit2
2075 chamber_x_trackx = tfile.Get(pdirPos+
"_x_trackx")
2076 chamber_x_trackx_fit = tfile.Get(pdirPos+
"_x_trackx_fitline")
2077 chamber_y_trackx = tfile.Get(pdirPos+
"_y_trackx")
2078 chamber_y_trackx_fit = tfile.Get(pdirPos+
"_y_trackx_fitline")
2079 chamber_dxdz_trackx = tfile.Get(pdirPos+
"_dxdz_trackx")
2080 chamber_dxdz_trackx_fit = tfile.Get(pdirPos+
"_dxdz_trackx_fitline")
2081 chamber_dydz_trackx = tfile.Get(pdirPos+
"_dydz_trackx")
2082 chamber_dydz_trackx_fit = tfile.Get(pdirPos+
"_dydz_trackx_fitline")
2083 chamber_x_trackx_fit2 = tfile.Get(pdirNeg+
"_x_trackx_fitline")
2084 chamber_y_trackx_fit2 = tfile.Get(pdirNeg+
"_y_trackx_fitline")
2085 chamber_dxdz_trackx_fit2 = tfile.Get(pdirNeg+
"_dxdz_trackx_fitline")
2086 chamber_dydz_trackx_fit2 = tfile.Get(pdirNeg+
"_dydz_trackx_fitline")
2088 chamber_x_tracky = tfile.Get(pdirPos+
"_x_tracky")
2089 chamber_x_tracky_fit = tfile.Get(pdirPos+
"_x_tracky_fitline")
2090 chamber_y_tracky = tfile.Get(pdirPos+
"_y_tracky")
2091 chamber_y_tracky_fit = tfile.Get(pdirPos+
"_y_tracky_fitline")
2092 chamber_dxdz_tracky = tfile.Get(pdirPos+
"_dxdz_tracky")
2093 chamber_dxdz_tracky_fit = tfile.Get(pdirPos+
"_dxdz_tracky_fitline")
2094 chamber_dydz_tracky = tfile.Get(pdirPos+
"_dydz_tracky")
2095 chamber_dydz_tracky_fit = tfile.Get(pdirPos+
"_dydz_tracky_fitline")
2096 chamber_x_tracky_fit2 = tfile.Get(pdirNeg+
"_x_tracky_fitline")
2097 chamber_y_tracky_fit2 = tfile.Get(pdirNeg+
"_y_tracky_fitline")
2098 chamber_dxdz_tracky_fit2 = tfile.Get(pdirNeg+
"_dxdz_tracky_fitline")
2099 chamber_dydz_tracky_fit2 = tfile.Get(pdirNeg+
"_dydz_tracky_fitline")
2101 chamber_x_trackdxdz = tfile.Get(pdirPos+
"_x_trackdxdz")
2102 chamber_x_trackdxdz_fit = tfile.Get(pdirPos+
"_x_trackdxdz_fitline")
2103 chamber_y_trackdxdz = tfile.Get(pdirPos+
"_y_trackdxdz")
2104 chamber_y_trackdxdz_fit = tfile.Get(pdirPos+
"_y_trackdxdz_fitline")
2105 chamber_dxdz_trackdxdz = tfile.Get(pdirPos+
"_dxdz_trackdxdz")
2106 chamber_dxdz_trackdxdz_fit = tfile.Get(pdirPos+
"_dxdz_trackdxdz_fitline")
2107 chamber_dydz_trackdxdz = tfile.Get(pdirPos+
"_dydz_trackdxdz")
2108 chamber_dydz_trackdxdz_fit = tfile.Get(pdirPos+
"_dydz_trackdxdz_fitline")
2109 chamber_x_trackdxdz_fit2 = tfile.Get(pdirNeg+
"_x_trackdxdz_fitline")
2110 chamber_y_trackdxdz_fit2 = tfile.Get(pdirNeg+
"_y_trackdxdz_fitline")
2111 chamber_dxdz_trackdxdz_fit2 = tfile.Get(pdirNeg+
"_dxdz_trackdxdz_fitline")
2112 chamber_dydz_trackdxdz_fit2 = tfile.Get(pdirNeg+
"_dydz_trackdxdz_fitline")
2114 chamber_x_trackdydz = tfile.Get(pdirPos+
"_x_trackdydz")
2115 chamber_x_trackdydz_fit = tfile.Get(pdirPos+
"_x_trackdydz_fitline")
2116 chamber_y_trackdydz = tfile.Get(pdirPos+
"_y_trackdydz")
2117 chamber_y_trackdydz_fit = tfile.Get(pdirPos+
"_y_trackdydz_fitline")
2118 chamber_dxdz_trackdydz = tfile.Get(pdirPos+
"_dxdz_trackdydz")
2119 chamber_dxdz_trackdydz_fit = tfile.Get(pdirPos+
"_dxdz_trackdydz_fitline")
2120 chamber_dydz_trackdydz = tfile.Get(pdirPos+
"_dydz_trackdydz")
2121 chamber_dydz_trackdydz_fit = tfile.Get(pdirPos+
"_dydz_trackdydz_fitline")
2122 chamber_x_trackdydz_fit2 = tfile.Get(pdirNeg+
"_x_trackdydz_fitline")
2123 chamber_y_trackdydz_fit2 = tfile.Get(pdirNeg+
"_y_trackdydz_fitline")
2124 chamber_dxdz_trackdydz_fit2 = tfile.Get(pdirNeg+
"_dxdz_trackdydz_fitline")
2125 chamber_dydz_trackdydz_fit2 = tfile.Get(pdirNeg+
"_dydz_trackdydz_fitline")
2127 if not chamber_x_trackx:
2128 chamber_x_trackx = tfile.Get(pdirPos+
"_residual_trackx")
2129 chamber_x_trackx_fit = tfile.Get(pdirPos+
"_residual_trackx_fitline")
2130 chamber_dxdz_trackx = tfile.Get(pdirPos+
"_resslope_trackx")
2131 chamber_dxdz_trackx_fit = tfile.Get(pdirPos+
"_resslope_trackx_fitline")
2132 chamber_x_trackx_fit2 = tfile.Get(pdirNeg+
"_residual_trackx_fitline")
2133 chamber_dxdz_trackx_fit2 = tfile.Get(pdirNeg+
"_resslope_trackx_fitline")
2135 chamber_x_tracky = tfile.Get(pdirPos+
"_residual_tracky")
2136 chamber_x_tracky_fit = tfile.Get(pdirPos+
"_residual_tracky_fitline")
2137 chamber_dxdz_tracky = tfile.Get(pdirPos+
"_resslope_tracky")
2138 chamber_dxdz_tracky_fit = tfile.Get(pdirPos+
"_resslope_tracky_fitline")
2139 chamber_x_tracky_fit2 = tfile.Get(pdirNeg+
"_residual_tracky_fitline")
2140 chamber_dxdz_tracky_fit2 = tfile.Get(pdirNeg+
"_resslope_tracky_fitline")
2142 chamber_x_trackdxdz = tfile.Get(pdirPos+
"_residual_trackdxdz")
2143 chamber_x_trackdxdz_fit = tfile.Get(pdirPos+
"_residual_trackdxdz_fitline")
2144 chamber_dxdz_trackdxdz = tfile.Get(pdirPos+
"_resslope_trackdxdz")
2145 chamber_dxdz_trackdxdz_fit = tfile.Get(pdirPos+
"_resslope_trackdxdz_fitline")
2146 chamber_x_trackdxdz_fit2 = tfile.Get(pdirNeg+
"_residual_trackdxdz_fitline")
2147 chamber_dxdz_trackdxdz_fit2 = tfile.Get(pdirNeg+
"_resslope_trackdxdz_fitline")
2149 chamber_x_trackdydz = tfile.Get(pdirPos+
"_residual_trackdydz")
2150 chamber_x_trackdydz_fit = tfile.Get(pdirPos+
"_residual_trackdydz_fitline")
2151 chamber_dxdz_trackdydz = tfile.Get(pdirPos+
"_resslope_trackdydz")
2152 chamber_dxdz_trackdydz_fit = tfile.Get(pdirPos+
"_resslope_trackdydz_fitline")
2153 chamber_x_trackdydz_fit2 = tfile.Get(pdirNeg+
"_residual_trackdydz_fitline")
2154 chamber_dxdz_trackdydz_fit2 = tfile.Get(pdirNeg+
"_resslope_trackdydz_fitline")
2156 if not chamber_x_trackx:
2157 print "Can't find neither "+pdirPos+
"_residual nor "+pdirPos+
"_residual_trackx"
2160 chamber_x_trackx = chamber_x_trackx.Clone()
2161 chamber_dxdz_trackx = chamber_dxdz_trackx.Clone()
2162 chamber_x_tracky = chamber_x_tracky.Clone()
2163 chamber_dxdz_tracky = chamber_dxdz_tracky.Clone()
2164 chamber_x_trackdxdz = chamber_x_trackdxdz.Clone()
2165 chamber_dxdz_trackdxdz = chamber_dxdz_trackdxdz.Clone()
2166 chamber_x_trackdydz = chamber_x_trackdydz.Clone()
2167 chamber_dxdz_trackdydz = chamber_dxdz_trackdydz.Clone()
2169 if not not chamber_y_trackx:
2170 chamber_y_trackx = chamber_y_trackx.Clone()
2171 chamber_dydz_trackx = chamber_dydz_trackx.Clone()
2172 chamber_y_tracky = chamber_y_tracky.Clone()
2173 chamber_dydz_tracky = chamber_dydz_tracky.Clone()
2174 chamber_y_trackdxdz = chamber_y_trackdxdz.Clone()
2175 chamber_dydz_trackdxdz = chamber_dydz_trackdxdz.Clone()
2176 chamber_y_trackdydz = chamber_y_trackdydz.Clone()
2177 chamber_dydz_trackdydz = chamber_dydz_trackdydz.Clone()
2179 if not not chamber_y_trackx:
2180 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+
"_x_trackx")); chamber_x_trackx.Merge(tlist)
2181 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+
"_dxdz_trackx")); chamber_dxdz_trackx.Merge(tlist)
2182 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+
"_x_tracky")); chamber_x_tracky.Merge(tlist)
2183 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+
"_dxdz_tracky")); chamber_dxdz_tracky.Merge(tlist)
2184 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+
"_x_trackdxdz")); chamber_x_trackdxdz.Merge(tlist)
2185 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+
"_dxdz_trackdxdz")); chamber_dxdz_trackdxdz.Merge(tlist)
2186 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+
"_x_trackdydz")); chamber_x_trackdydz.Merge(tlist)
2187 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+
"_dxdz_trackdydz")); chamber_dxdz_trackdydz.Merge(tlist)
2188 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+
"_y_trackx")); chamber_y_trackx.Merge(tlist)
2189 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+
"_dydz_trackx")); chamber_dydz_trackx.Merge(tlist)
2190 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+
"_y_tracky")); chamber_y_tracky.Merge(tlist)
2191 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+
"_dydz_tracky")); chamber_dydz_tracky.Merge(tlist)
2192 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+
"_y_trackdxdz")); chamber_y_trackdxdz.Merge(tlist)
2193 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+
"_dydz_trackdxdz")); chamber_dydz_trackdxdz.Merge(tlist)
2194 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+
"_y_trackdydz")); chamber_y_trackdydz.Merge(tlist)
2195 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+
"_dydz_trackdydz")); chamber_dydz_trackdydz.Merge(tlist)
2197 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+
"_residual_trackx")); chamber_x_trackx.Merge(tlist)
2198 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+
"_resslope_trackx")); chamber_dxdz_trackx.Merge(tlist)
2199 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+
"_residual_tracky")); chamber_x_tracky.Merge(tlist)
2200 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+
"_resslope_tracky")); chamber_dxdz_tracky.Merge(tlist)
2201 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+
"_residual_trackdxdz")); chamber_x_trackdxdz.Merge(tlist)
2202 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+
"_resslope_trackdxdz")); chamber_dxdz_trackdxdz.Merge(tlist)
2203 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+
"_residual_trackdydz")); chamber_x_trackdydz.Merge(tlist)
2204 tlist = ROOT.TList(); tlist.Add(tfile.Get(pdirNeg+
"_resslope_trackdydz")); chamber_dxdz_trackdydz.Merge(tlist)
2208 chamber_x_trackx.SetAxisRange(-rr1, rr1,
"Y")
2209 chamber_dxdz_trackx.SetAxisRange(-rr2, rr2,
"Y")
2210 chamber_x_tracky.SetAxisRange(-rr1, rr1,
"Y")
2211 chamber_dxdz_tracky.SetAxisRange(-rr2, rr2,
"Y")
2212 chamber_x_trackdxdz.SetAxisRange(-rr1, rr1,
"Y")
2213 chamber_dxdz_trackdxdz.SetAxisRange(-rr2, rr2,
"Y")
2214 chamber_x_trackdydz.SetAxisRange(-rr1, rr1,
"Y")
2215 chamber_dxdz_trackdydz.SetAxisRange(-rr2, rr2,
"Y")
2218 if not not chamber_y_trackx:
2219 chamber_y_trackx.SetAxisRange(-rr3, rr3,
"Y")
2220 chamber_dydz_trackx.SetAxisRange(-rr3, rr3,
"Y")
2221 chamber_y_tracky.SetAxisRange(-rr3, rr3,
"Y")
2222 chamber_dydz_tracky.SetAxisRange(-rr3, rr3,
"Y")
2223 chamber_y_trackdxdz.SetAxisRange(-rr3, rr3,
"Y")
2224 chamber_dydz_trackdxdz.SetAxisRange(-rr3, rr3,
"Y")
2225 chamber_y_trackdydz.SetAxisRange(-rr3, rr3,
"Y")
2226 chamber_dydz_trackdydz.SetAxisRange(-rr3, rr3,
"Y")
2228 for h
in chamber_x_trackx, chamber_y_trackx, chamber_dxdz_trackx, chamber_dydz_trackx, \
2229 chamber_x_tracky, chamber_y_tracky, chamber_dxdz_tracky, chamber_dydz_tracky, \
2230 chamber_x_trackdxdz, chamber_y_trackdxdz, chamber_dxdz_trackdxdz, chamber_dydz_trackdxdz, \
2231 chamber_x_trackdydz, chamber_y_trackdydz, chamber_dxdz_trackdydz, chamber_dydz_trackdydz:
2233 h.SetMarkerStyle(20)
2234 h.SetMarkerSize(0.5)
2235 h.GetXaxis().SetLabelSize(0.12)
2236 h.GetYaxis().SetLabelSize(0.12)
2237 h.GetXaxis().SetNdivisions(505)
2238 h.GetYaxis().SetNdivisions(505)
2239 h.GetXaxis().SetLabelOffset(0.03)
2240 h.GetYaxis().SetLabelOffset(0.03)
2242 trackdxdz_minimum, trackdxdz_maximum =
None,
None
2243 for h
in chamber_x_trackdxdz, chamber_y_trackdxdz, chamber_dxdz_trackdxdz, chamber_dydz_trackdxdz:
2245 for i
in xrange(1, h.GetNbinsX()+1):
2246 if h.GetBinError(i) > 0.01
and h.GetBinContent(i) - h.GetBinError(i) < 10.
and \
2247 h.GetBinContent(i) + h.GetBinError(i) > -10.:
2248 if not trackdxdz_minimum
or trackdxdz_minimum > h.GetBinCenter(i):
2249 trackdxdz_minimum = h.GetBinCenter(i)
2250 if trackdxdz_maximum < h.GetBinCenter(i):
2251 trackdxdz_maximum = h.GetBinCenter(i)
2252 if not not trackdxdz_minimum
and not not trackdxdz_maximum:
2253 for h
in chamber_x_trackdxdz, chamber_y_trackdxdz, chamber_dxdz_trackdxdz, chamber_dydz_trackdxdz:
2255 h.SetAxisRange(trackdxdz_minimum, trackdxdz_maximum,
"X")
2257 trackdydz_minimum, trackdydz_maximum =
None,
None
2258 for h
in chamber_x_trackdydz, chamber_y_trackdydz, chamber_dxdz_trackdydz, chamber_dydz_trackdydz:
2260 for i
in xrange(1, h.GetNbinsX()+1):
2261 if h.GetBinError(i) > 0.01
and h.GetBinContent(i) - h.GetBinError(i) < 10.
and \
2262 h.GetBinContent(i) + h.GetBinError(i) > -10.:
2263 if not trackdydz_minimum
or trackdydz_minimum > h.GetBinCenter(i):
2264 trackdydz_minimum = h.GetBinCenter(i)
2265 if trackdydz_maximum < h.GetBinCenter(i):
2266 trackdydz_maximum = h.GetBinCenter(i)
2267 if not not trackdydz_minimum
and not not trackdydz_maximum:
2268 for h
in chamber_x_trackdydz, chamber_y_trackdydz, chamber_dxdz_trackdydz, chamber_dydz_trackdydz:
2270 h.SetAxisRange(trackdydz_minimum, trackdydz_maximum,
"X")
2272 for f
in chamber_x_trackx_fit2, chamber_y_trackx_fit2, chamber_dxdz_trackx_fit2, chamber_dydz_trackx_fit2, \
2273 chamber_x_tracky_fit2, chamber_y_tracky_fit2, chamber_dxdz_tracky_fit2, chamber_dydz_tracky_fit2, \
2274 chamber_x_trackdxdz_fit2, chamber_y_trackdxdz_fit2, chamber_dxdz_trackdxdz_fit2, chamber_dydz_trackdxdz_fit2, \
2275 chamber_x_trackdydz_fit2, chamber_y_trackdydz_fit2, chamber_dxdz_trackdydz_fit2, chamber_dydz_trackdydz_fit2:
2279 if not not chamber_y_trackx:
2283 pads.append(ROOT.TPad(
"p1" ,
"",0.00,0.78,0.07,1.00,0,0,0))
2284 pads.append(ROOT.TPad(
"p2" ,
"",0.07,0.78,0.34,1.00,0,0,0))
2285 pads.append(ROOT.TPad(
"p3" ,
"",0.34,0.78,0.56,1.00,0,0,0))
2286 pads.append(ROOT.TPad(
"p4" ,
"",0.56,0.78,0.78,1.00,0,0,0))
2287 pads.append(ROOT.TPad(
"p5" ,
"",0.78,0.78,1.00,1.00,0,0,0))
2288 pads.append(ROOT.TPad(
"p6" ,
"",0.00,0.56,0.07,0.78,0,0,0))
2289 pads.append(ROOT.TPad(
"p7" ,
"",0.07,0.56,0.34,0.78,0,0,0))
2290 pads.append(ROOT.TPad(
"p8" ,
"",0.34,0.56,0.56,0.78,0,0,0))
2291 pads.append(ROOT.TPad(
"p9" ,
"",0.56,0.56,0.78,0.78,0,0,0))
2292 pads.append(ROOT.TPad(
"p10",
"",0.78,0.56,1.00,0.78,0,0,0))
2293 pads.append(ROOT.TPad(
"p11",
"",0.00,0.34,0.07,0.56,0,0,0))
2294 pads.append(ROOT.TPad(
"p12",
"",0.07,0.34,0.34,0.56,0,0,0))
2295 pads.append(ROOT.TPad(
"p13",
"",0.34,0.34,0.56,0.56,0,0,0))
2296 pads.append(ROOT.TPad(
"p14",
"",0.56,0.34,0.78,0.56,0,0,0))
2297 pads.append(ROOT.TPad(
"p15",
"",0.78,0.34,1.00,0.56,0,0,0))
2298 pads.append(ROOT.TPad(
"p16",
"",0.00,0.07,0.07,0.34,0,0,0))
2299 pads.append(ROOT.TPad(
"p17",
"",0.07,0.07,0.34,0.34,0,0,0))
2300 pads.append(ROOT.TPad(
"p18",
"",0.34,0.07,0.56,0.34,0,0,0))
2301 pads.append(ROOT.TPad(
"p19",
"",0.56,0.07,0.78,0.34,0,0,0))
2302 pads.append(ROOT.TPad(
"p20",
"",0.78,0.07,1.00,0.34,0,0,0))
2303 pads.append(ROOT.TPad(
"p21",
"",0.00,0.00,0.07,0.07,0,0,0))
2304 pads.append(ROOT.TPad(
"p22",
"",0.07,0.00,0.34,0.07,0,0,0))
2305 pads.append(ROOT.TPad(
"p23",
"",0.34,0.00,0.56,0.07,0,0,0))
2306 pads.append(ROOT.TPad(
"p24",
"",0.56,0.00,0.78,0.07,0,0,0))
2307 pads.append(ROOT.TPad(
"p25",
"",0.78,0.00,1.00,0.07,0,0,0))
2311 ROOT.SetOwnership(p,
False)
2313 label1 = ROOT.TPaveLabel(0, 0, 1, 1,
"x residuals (mm)",
"")
2314 label2 = ROOT.TPaveLabel(0, 0, 1, 1,
"y residuals (mm)",
"")
2315 label3 = ROOT.TPaveLabel(0, 0, 1, 1,
"dx/dz residuals (mrad)",
"")
2316 label4 = ROOT.TPaveLabel(0, 0, 1, 1,
"dy/dz residuals (mrad)",
"")
2317 label5 = ROOT.TPaveLabel(0, 0, 1, 1,
"x position (cm)",
"")
2318 label6 = ROOT.TPaveLabel(0, 0, 1, 1,
"y position (cm)",
"")
2319 label7 = ROOT.TPaveLabel(0, 0, 1, 1,
"dx/dz angle (rad)",
"")
2320 label8 = ROOT.TPaveLabel(0, 0, 1, 1,
"dy/dz angle (rad)",
"")
2321 label9 = ROOT.TPaveLabel(0, 0.85, 1, 1,
getname(r),
"NDC")
2323 for l
in label1, label2, label3, label4, label5, label6, label7, label8, label9:
2325 l.SetFillColor(ROOT.kWhite)
2327 for l
in label1, label2, label3, label4:
2332 label9.SetTextSize(0.59)
2334 pads[1].cd(); label1.Draw()
2335 pads[6].cd(); label2.Draw()
2336 pads[11].cd(); label3.Draw()
2337 pads[16].cd(); label4.Draw()
2338 pads[22].cd(); label5.Draw()
2339 pads[23].cd(); label6.Draw()
2340 pads[24].cd(); label7.Draw()
2341 pads[25].cd(); label8.Draw()
2343 pads[2].SetRightMargin(1e-5)
2344 pads[2].SetBottomMargin(1e-5)
2345 pads[2].SetLeftMargin(0.17)
2346 pads[3].SetLeftMargin(1e-5)
2347 pads[3].SetRightMargin(1e-5)
2348 pads[3].SetBottomMargin(1e-5)
2349 pads[4].SetLeftMargin(1e-5)
2350 pads[4].SetRightMargin(1e-5)
2351 pads[4].SetBottomMargin(1e-5)
2352 pads[5].SetLeftMargin(1e-5)
2353 pads[5].SetBottomMargin(1e-5)
2355 pads[7].SetRightMargin(1e-5)
2356 pads[7].SetBottomMargin(1e-5)
2357 pads[7].SetTopMargin(1e-5)
2358 pads[7].SetLeftMargin(0.17)
2359 pads[8].SetLeftMargin(1e-5)
2360 pads[8].SetRightMargin(1e-5)
2361 pads[8].SetBottomMargin(1e-5)
2362 pads[8].SetTopMargin(1e-5)
2363 pads[9].SetLeftMargin(1e-5)
2364 pads[9].SetRightMargin(1e-5)
2365 pads[9].SetBottomMargin(1e-5)
2366 pads[9].SetTopMargin(1e-5)
2367 pads[10].SetLeftMargin(1e-5)
2368 pads[10].SetBottomMargin(1e-5)
2369 pads[10].SetTopMargin(1e-5)
2371 pads[12].SetRightMargin(1e-5)
2372 pads[12].SetBottomMargin(1e-5)
2373 pads[12].SetTopMargin(1e-5)
2374 pads[12].SetLeftMargin(0.17)
2375 pads[13].SetLeftMargin(1e-5)
2376 pads[13].SetRightMargin(1e-5)
2377 pads[13].SetBottomMargin(1e-5)
2378 pads[13].SetTopMargin(1e-5)
2379 pads[14].SetLeftMargin(1e-5)
2380 pads[14].SetRightMargin(1e-5)
2381 pads[14].SetBottomMargin(1e-5)
2382 pads[14].SetTopMargin(1e-5)
2383 pads[15].SetLeftMargin(1e-5)
2384 pads[15].SetBottomMargin(1e-5)
2385 pads[15].SetTopMargin(1e-5)
2387 pads[17].SetRightMargin(1e-5)
2388 pads[17].SetTopMargin(1e-5)
2389 pads[17].SetLeftMargin(0.17)
2390 pads[18].SetLeftMargin(1e-5)
2391 pads[18].SetRightMargin(1e-5)
2392 pads[18].SetTopMargin(1e-5)
2393 pads[19].SetLeftMargin(1e-5)
2394 pads[19].SetRightMargin(1e-5)
2395 pads[19].SetTopMargin(1e-5)
2396 pads[20].SetLeftMargin(1e-5)
2397 pads[20].SetTopMargin(1e-5)
2399 chamber_x_trackx.GetXaxis().SetLabelColor(ROOT.kWhite)
2400 chamber_x_tracky.GetXaxis().SetLabelColor(ROOT.kWhite)
2401 chamber_x_tracky.GetYaxis().SetLabelColor(ROOT.kWhite)
2402 chamber_x_trackdxdz.GetXaxis().SetLabelColor(ROOT.kWhite)
2403 chamber_x_trackdxdz.GetYaxis().SetLabelColor(ROOT.kWhite)
2404 chamber_x_trackdydz.GetXaxis().SetLabelColor(ROOT.kWhite)
2405 chamber_x_trackdydz.GetYaxis().SetLabelColor(ROOT.kWhite)
2406 chamber_y_trackx.GetXaxis().SetLabelColor(ROOT.kWhite)
2407 chamber_y_tracky.GetXaxis().SetLabelColor(ROOT.kWhite)
2408 chamber_y_tracky.GetYaxis().SetLabelColor(ROOT.kWhite)
2409 chamber_y_trackdxdz.GetXaxis().SetLabelColor(ROOT.kWhite)
2410 chamber_y_trackdxdz.GetYaxis().SetLabelColor(ROOT.kWhite)
2411 chamber_y_trackdydz.GetXaxis().SetLabelColor(ROOT.kWhite)
2412 chamber_y_trackdydz.GetYaxis().SetLabelColor(ROOT.kWhite)
2413 chamber_dxdz_trackx.GetXaxis().SetLabelColor(ROOT.kWhite)
2414 chamber_dxdz_tracky.GetXaxis().SetLabelColor(ROOT.kWhite)
2415 chamber_dxdz_tracky.GetYaxis().SetLabelColor(ROOT.kWhite)
2416 chamber_dxdz_trackdxdz.GetXaxis().SetLabelColor(ROOT.kWhite)
2417 chamber_dxdz_trackdxdz.GetYaxis().SetLabelColor(ROOT.kWhite)
2418 chamber_dxdz_trackdydz.GetXaxis().SetLabelColor(ROOT.kWhite)
2419 chamber_dxdz_trackdydz.GetYaxis().SetLabelColor(ROOT.kWhite)
2422 chamber_dydz_tracky.GetYaxis().SetLabelColor(ROOT.kWhite)
2423 chamber_dydz_trackdxdz.GetYaxis().SetLabelColor(ROOT.kWhite)
2424 chamber_dydz_trackdydz.GetYaxis().SetLabelColor(ROOT.kWhite)
2427 chamber_x_trackx.Draw(
"e1")
2428 if not suppressblue: chamber_x_trackx_fit2.Draw(
"samel")
2429 chamber_x_trackx_fit.Draw(
"samel")
2437 chamber_x_tracky.Draw(
"e1")
2438 if not suppressblue: chamber_x_tracky_fit2.Draw(
"samel")
2439 chamber_x_tracky_fit.Draw(
"samel")
2442 chamber_x_trackdxdz.Draw(
"e1")
2443 if not suppressblue: chamber_x_trackdxdz_fit2.Draw(
"samel")
2444 chamber_x_trackdxdz_fit.Draw(
"samel")
2447 chamber_x_trackdydz.Draw(
"e1")
2448 if not suppressblue: chamber_x_trackdydz_fit2.Draw(
"samel")
2449 chamber_x_trackdydz_fit.Draw(
"samel")
2452 chamber_y_trackx.Draw(
"e1")
2453 if not suppressblue: chamber_y_trackx_fit2.Draw(
"samel")
2454 chamber_y_trackx_fit.Draw(
"samel")
2457 chamber_y_tracky.Draw(
"e1")
2458 if not suppressblue: chamber_y_tracky_fit2.Draw(
"samel")
2459 chamber_y_tracky_fit.Draw(
"samel")
2462 chamber_y_trackdxdz.Draw(
"e1")
2463 if not suppressblue: chamber_y_trackdxdz_fit2.Draw(
"samel")
2464 chamber_y_trackdxdz_fit.Draw(
"samel")
2467 chamber_y_trackdydz.Draw(
"e1")
2468 if not suppressblue: chamber_y_trackdydz_fit2.Draw(
"samel")
2469 chamber_y_trackdydz_fit.Draw(
"samel")
2472 chamber_dxdz_trackx.Draw(
"e1")
2473 if not suppressblue: chamber_dxdz_trackx_fit2.Draw(
"samel")
2474 chamber_dxdz_trackx_fit.Draw(
"samel")
2477 chamber_dxdz_tracky.Draw(
"e1")
2478 if not suppressblue: chamber_dxdz_tracky_fit2.Draw(
"samel")
2479 chamber_dxdz_tracky_fit.Draw(
"samel")
2482 chamber_dxdz_trackdxdz.Draw(
"e1")
2483 if not suppressblue: chamber_dxdz_trackdxdz_fit2.Draw(
"samel")
2484 chamber_dxdz_trackdxdz_fit.Draw(
"samel")
2487 chamber_dxdz_trackdydz.Draw(
"e1")
2488 if not suppressblue: chamber_dxdz_trackdydz_fit2.Draw(
"samel")
2489 chamber_dxdz_trackdydz_fit.Draw(
"samel")
2492 chamber_dydz_trackx.Draw(
"e1")
2493 if not suppressblue: chamber_dydz_trackx_fit2.Draw(
"samel")
2494 chamber_dydz_trackx_fit.Draw(
"samel")
2497 chamber_dydz_tracky.Draw(
"e1")
2498 if not suppressblue: chamber_dydz_tracky_fit2.Draw(
"samel")
2499 chamber_dydz_tracky_fit.Draw(
"samel")
2502 chamber_dydz_trackdxdz.Draw(
"e1")
2503 if not suppressblue: chamber_dydz_trackdxdz_fit2.Draw(
"samel")
2504 chamber_dydz_trackdxdz_fit.Draw(
"samel")
2507 chamber_dydz_trackdydz.Draw(
"e1")
2508 if not suppressblue: chamber_dydz_trackdydz_fit2.Draw(
"samel")
2509 chamber_dydz_trackdydz_fit.Draw(
"samel")
2515 pads.append(ROOT.TPad(
"p1" ,
"",0.00,0.55,0.07,1.00,0,0,0))
2516 pads.append(ROOT.TPad(
"p2" ,
"",0.07,0.55,0.34,1.00,0,0,0))
2517 pads.append(ROOT.TPad(
"p3" ,
"",0.34,0.55,0.56,1.00,0,0,0))
2518 pads.append(ROOT.TPad(
"p4" ,
"",0.56,0.55,0.78,1.00,0,0,0))
2519 pads.append(ROOT.TPad(
"p5" ,
"",0.78,0.55,1.00,1.00,0,0,0))
2520 pads.append(ROOT.TPad(
"p6" ,
"",0.00,0.1,0.07,0.55,0,0,0))
2521 pads.append(ROOT.TPad(
"p7" ,
"",0.07,0.1,0.34,0.55,0,0,0))
2522 pads.append(ROOT.TPad(
"p8" ,
"",0.34,0.1,0.56,0.55,0,0,0))
2523 pads.append(ROOT.TPad(
"p9" ,
"",0.56,0.1,0.78,0.55,0,0,0))
2524 pads.append(ROOT.TPad(
"p10",
"",0.78,0.1,1.00,0.55,0,0,0))
2525 pads.append(ROOT.TPad(
"p11",
"",0.00,0.,0.07,0.1,0,0,0))
2526 pads.append(ROOT.TPad(
"p12",
"",0.07,0.,0.34,0.1,0,0,0))
2527 pads.append(ROOT.TPad(
"p13",
"",0.34,0.,0.56,0.1,0,0,0))
2528 pads.append(ROOT.TPad(
"p14",
"",0.56,0.,0.78,0.1,0,0,0))
2529 pads.append(ROOT.TPad(
"p15",
"",0.78,0.,1.00,0.1,0,0,0))
2533 ROOT.SetOwnership(p,
False)
2535 label1 = ROOT.TPaveLabel(0, 0, 1, 1,
"x residuals (mm)")
2536 label2 = ROOT.TPaveLabel(0, 0, 1, 1,
"dx/dz residuals (mrad)")
2537 label3 = ROOT.TPaveLabel(0, 0.3, 1, 1,
"x position (cm)")
2538 label4 = ROOT.TPaveLabel(0, 0.3, 1, 1,
"y position (cm)")
2539 label5 = ROOT.TPaveLabel(0, 0.3, 1, 1,
"dx/dz angle (rad)")
2540 label6 = ROOT.TPaveLabel(0, 0.3, 1, 1,
"dy/dz angle (rad)")
2541 label9 = ROOT.TPaveLabel(0, 0.85, 1, 1,
getname(r),
"NDC")
2543 if name[0:2] ==
"ME":
2544 label1 = ROOT.TPaveLabel(0, 0, 1, 1,
"r#phi residuals (mm)")
2545 label2 = ROOT.TPaveLabel(0, 0, 1, 1,
"d(r#phi)/dz residuals (mrad)")
2547 for l
in label1, label2, label3, label4, label5, label6, label9:
2549 l.SetFillColor(ROOT.kWhite)
2551 for l
in label1, label2:
2556 label9.SetTextSize(0.29)
2558 pads[1].cd(); label1.Draw()
2559 pads[6].cd(); label2.Draw()
2560 pads[12].cd(); label3.Draw()
2561 pads[13].cd(); label4.Draw()
2562 pads[14].cd(); label5.Draw()
2563 pads[15].cd(); label6.Draw()
2566 pads[2].SetRightMargin(1e-5)
2567 pads[2].SetBottomMargin(1e-5)
2568 pads[3].SetLeftMargin(1e-5)
2569 pads[3].SetRightMargin(1e-5)
2570 pads[3].SetBottomMargin(1e-5)
2571 pads[4].SetLeftMargin(1e-5)
2572 pads[4].SetRightMargin(1e-5)
2573 pads[4].SetBottomMargin(1e-5)
2574 pads[5].SetLeftMargin(1e-5)
2575 pads[5].SetBottomMargin(1e-5)
2577 pads[7].SetRightMargin(1e-5)
2578 pads[7].SetTopMargin(1e-5)
2579 pads[8].SetLeftMargin(1e-5)
2580 pads[8].SetRightMargin(1e-5)
2581 pads[8].SetTopMargin(1e-5)
2582 pads[9].SetLeftMargin(1e-5)
2583 pads[9].SetRightMargin(1e-5)
2584 pads[9].SetTopMargin(1e-5)
2585 pads[10].SetLeftMargin(1e-5)
2586 pads[10].SetTopMargin(1e-5)
2588 chamber_x_trackx.GetXaxis().SetLabelColor(ROOT.kWhite)
2589 chamber_x_tracky.GetXaxis().SetLabelColor(ROOT.kWhite)
2590 chamber_x_tracky.GetYaxis().SetLabelColor(ROOT.kWhite)
2591 chamber_x_trackdxdz.GetXaxis().SetLabelColor(ROOT.kWhite)
2592 chamber_x_trackdxdz.GetYaxis().SetLabelColor(ROOT.kWhite)
2593 chamber_x_trackdydz.GetXaxis().SetLabelColor(ROOT.kWhite)
2594 chamber_x_trackdydz.GetYaxis().SetLabelColor(ROOT.kWhite)
2596 chamber_dxdz_tracky.GetYaxis().SetLabelColor(ROOT.kWhite)
2597 chamber_dxdz_trackdxdz.GetYaxis().SetLabelColor(ROOT.kWhite)
2598 chamber_dxdz_trackdydz.GetYaxis().SetLabelColor(ROOT.kWhite)
2601 chamber_x_trackx.Draw(
"e1")
2602 if not suppressblue: chamber_x_trackx_fit2.Draw(
"samel")
2603 chamber_x_trackx_fit.Draw(
"samel")
2607 chamber_x_tracky.Draw(
"e1")
2608 if not suppressblue: chamber_x_tracky_fit2.Draw(
"samel")
2609 chamber_x_tracky_fit.Draw(
"samel")
2612 chamber_x_trackdxdz.Draw(
"e1")
2613 if not suppressblue: chamber_x_trackdxdz_fit2.Draw(
"samel")
2614 chamber_x_trackdxdz_fit.Draw(
"samel")
2617 chamber_x_trackdydz.Draw(
"e1")
2618 if not suppressblue: chamber_x_trackdydz_fit2.Draw(
"samel")
2619 chamber_x_trackdydz_fit.Draw(
"samel")
2622 chamber_dxdz_trackx.Draw(
"e1")
2623 if not suppressblue: chamber_dxdz_trackx_fit2.Draw(
"samel")
2624 chamber_dxdz_trackx_fit.Draw(
"samel")
2627 chamber_dxdz_tracky.Draw(
"e1")
2628 if not suppressblue: chamber_dxdz_tracky_fit2.Draw(
"samel")
2629 chamber_dxdz_tracky_fit.Draw(
"samel")
2632 chamber_dxdz_trackdxdz.Draw(
"e1")
2633 if not suppressblue: chamber_dxdz_trackdxdz_fit2.Draw(
"samel")
2634 chamber_dxdz_trackdxdz_fit.Draw(
"samel")
2637 chamber_dxdz_trackdydz.Draw(
"e1")
2638 if not suppressblue: chamber_dxdz_trackdydz_fit2.Draw(
"samel")
2639 chamber_dxdz_trackdydz_fit.Draw(
"samel")
2642 ddt[8] = 1./ddt[7]*((ddt[7]-1)*ddt[8] + tn-t1)
2647 tdrStyle.SetOptFit(1)
2648 tdrStyle.SetOptTitle(1)
2649 tdrStyle.SetTitleBorderSize(1)
2650 tdrStyle.SetTitleFontSize(0.05)
2651 tdrStyle.SetStatW(0.2)
2652 tdrStyle.SetStatY(0.9)
2653 tdrStyle.SetStatFontSize(0.06)
2655 if component[0:2] ==
"dt":
2656 wheel = args[
"wheel"]
2658 sector = args[
"sector"]
2659 profname =
"%s_%s_%02d_%s" % (component, wheelletter, sector, str(pair))
2660 posname =
"pos" + profname
2661 negname =
"neg" + profname
2664 station1 = int(str(pair)[0])
2665 station2 = int(str(pair)[1])
2666 phi1 = signConventions[
"DT", wheel, station1, sector][4]
2667 phi2 = signConventions[
"DT", wheel, station2, sector][4]
2668 if abs(phi1 - phi2) > 1.:
2669 if phi1 > phi2: phi1 -= 2.*pi
2671 phi = (phi1 + phi2) / 2.
2672 while (phi < -pi): phi += 2.*pi
2673 while (phi > pi): phi -= 2.*pi
2675 elif component[0:3] ==
"csc":
2676 endcap = args[
"endcap"]
2683 else:
raise Exception
2686 if ring>2
or ring<1:
raise Exception
2687 station1 = int(str(pair)[0])
2688 station2 = int(str(pair)[1])
2689 if ring==1: ringname=
"inner"
2690 elif ring==2: ringname=
"outer"
2691 else:
raise Exception
2693 chamber = args[
"chamber"]
2694 if (ring==1
and chamber>18)
or (ring==2
and chamber>36):
raise Exception
2696 profname =
"csc%s_%s_%s_%02d_%s" % (ringname,component[4:], endcap, chamber, str(pair))
2697 posname =
"pos" + profname
2698 negname =
"neg" + profname
2701 station1 = int(str(pair)[0])
2702 station2 = int(str(pair)[1])
2703 phi1 = signConventions[
"CSC", endcapnum, station1, ring, chamber][4]
2704 phi2 = signConventions[
"CSC", endcapnum, station1, ring, chamber][4]
2705 if abs(phi1 - phi2) > 1.:
2706 if phi1 > phi2: phi1 -= 2.*pi
2708 phi = (phi1 + phi2) / 2.
2709 while (phi < -pi): phi += 2.*pi
2710 while (phi > pi): phi -= 2.*pi
2712 else:
raise Exception
2714 if "window" in args: window = args[
"window"]
2717 global tmpprof, tmppos, tmpneg
2718 pdir =
"AlignmentMonitorSegmentDifferences/iter1/"
2719 tmpprof = tfiles[0].Get(pdir + profname).Clone()
2720 tmpprof.SetMarkerStyle(8)
2721 tmppos = tfiles[0].Get(pdir + posname).Clone()
2722 tmpneg = tfiles[0].Get(pdir + negname).Clone()
2723 for tfile
in tfiles[1:]:
2724 tmpprof.Add(tfile.Get(pdir + profname))
2725 tmppos.Add(tfile.Get(pdir + posname))
2726 tmpneg.Add(tfile.Get(pdir + negname))
2728 for i
in xrange(1, tmpprof.GetNbinsX()+1):
2729 if tmpprof.GetBinError(i) < 1e-5:
2730 tmpprof.SetBinError(i, 100.)
2731 tmpprof.SetAxisRange(-window, window,
"Y")
2733 f = ROOT.TF1(
"p1",
"[0] + [1]*x", tmpprof.GetBinLowEdge(1), -tmpprof.GetBinLowEdge(1))
2734 f.SetParameters((tmppos.GetMean() + tmpneg.GetMean())/2., 0.)
2736 tmpprof.SetXTitle(
"q/p_{T} (c/GeV)")
2737 if component ==
"dt13_resid":
2738 tmpprof.SetYTitle(
"#Deltax^{local} (mm)")
2739 tmppos.SetXTitle(
"#Deltax^{local} (mm)")
2740 tmpneg.SetXTitle(
"#Deltax^{local} (mm)")
2741 f.SetParNames(
"#Deltax^{local}_{0}",
"Slope")
2742 if component ==
"dt13_slope":
2743 tmpprof.SetYTitle(
"#Deltadx/dz^{local} (mrad)")
2744 tmppos.SetXTitle(
"#Deltadx/dz^{local} (mrad)")
2745 tmpneg.SetXTitle(
"#Deltadx/dz^{local} (mrad)")
2746 f.SetParNames(
"#Deltadx/dz^{local}_{0}",
"Slope")
2747 if component ==
"dt2_resid":
2748 tmpprof.SetYTitle(
"#Deltay^{local} (mm)")
2749 tmppos.SetXTitle(
"#Deltay^{local} (mm)")
2750 tmpneg.SetXTitle(
"#Deltay^{local} (mm)")
2751 f.SetParNames(
"#Deltay^{local}_{0}",
"Slope")
2752 if component ==
"dt2_slope":
2753 tmpprof.SetYTitle(
"#Deltady/dz^{local} (mrad)")
2754 tmppos.SetXTitle(
"#Deltady/dz^{local} (mrad)")
2755 tmpneg.SetXTitle(
"#Deltady/dz^{local} (mrad)")
2756 f.SetParNames(
"#Deltady/dz^{local}_{0}",
"Slope")
2757 if component ==
"csc_resid":
2758 tmpprof.SetYTitle(
"#Delta(r#phi)^{local} (mm)")
2759 tmppos.SetXTitle(
"#Delta(r#phi)^{local} (mm)")
2760 tmpneg.SetXTitle(
"#Delta(r#phi)^{local} (mm)")
2761 f.SetParNames(
"#Delta(r#phi)^{local}_{0}",
"Slope")
2762 if component ==
"csc_slope":
2763 tmpprof.SetYTitle(
"#Deltad(r#phi)/dz^{local} (mrad)")
2764 tmppos.SetXTitle(
"#Deltad(r#phi)/dz^{local} (mrad)")
2765 tmpneg.SetXTitle(
"#Deltad(r#phi)/dz^{local} (mrad)")
2766 f.SetParNames(
"#Deltad(r#phi)/dz^{local}_{0}",
"Slope")
2768 tmpprof.GetXaxis().CenterTitle()
2769 tmpprof.GetYaxis().CenterTitle()
2770 tmppos.GetXaxis().CenterTitle()
2771 tmpneg.GetXaxis().CenterTitle()
2772 if component[0:2] ==
"dt":
2773 tmpprof.SetTitle(
"MB%d - MB%d, wheel %d, sector %02d" % (station1, station2, int(wheel), int(sector)))
2774 elif component[0:3] ==
"csc":
2775 tmpprof.SetTitle(
"ME%d - ME%d, for ME%s%d/%d/%d" % (station1, station2, endcapsign, station2, ring, chamber))
2776 else:
raise Exception
2778 tmppos.SetTitle(
"Positive muons")
2779 tmpneg.SetTitle(
"Negative muons")
2784 fit1 = tmpprof.Fit(
"p1",
"q")
2787 c1.GetPad(2).Divide(1, 2)
2788 c1.GetPad(2).GetPad(1).cd()
2790 f = ROOT.TF1(
"gausR",
"[0]*exp(-(x - [1])**2 / 2. / [2]**2) / sqrt(2.*3.1415926) / [2]",
2791 tmppos.GetMean() - tmppos.GetRMS(), tmppos.GetMean() + tmppos.GetRMS())
2792 f.SetParameters(tmppos.GetEntries() * ((10. - -10.)/100.), tmppos.GetMean(), tmppos.GetRMS())
2793 f.SetParNames(
"Constant",
"Mean",
"Sigma")
2794 fit2 = tmppos.Fit(
"gausR",
"qR")
2795 c1.GetPad(2).GetPad(2).cd()
2797 f = ROOT.TF1(
"gausR",
"[0]*exp(-(x - [1])**2 / 2. / [2]**2) / sqrt(2.*3.1415926) / [2]",
2798 tmpneg.GetMean() - tmpneg.GetRMS(), tmpneg.GetMean() + tmpneg.GetRMS())
2799 f.SetParameters(tmpneg.GetEntries() * ((10. - -10.)/100.), tmpneg.GetMean(), tmpneg.GetRMS())
2800 f.SetParNames(
"Constant",
"Mean",
"Sigma")
2801 fit3 = tmpneg.Fit(
"gausR",
"qR")
2803 fitresult1 =
None,
None
2805 fitresult1 = tmpprof.GetFunction(
"p1").GetParameter(0), tmpprof.GetFunction(
"p1").GetParError(0)
2806 fitresult2 =
None,
None
2807 if fit2 == 0
and fit3 == 0:
2808 fitresult2 = (tmppos.GetFunction(
"gausR").GetParameter(1) + tmpneg.GetFunction(
"gausR").GetParameter(1)) / 2., \
2809 sqrt(tmppos.GetFunction(
"gausR").GetParError(1)**2 + tmpneg.GetFunction(
"gausR").GetParError(1)**2) / 2.
2810 return phi, fitresult1[0], fitresult1[1], fitresult2[0], fitresult2[1], fit1, fit2, fit3
2812 def segdiffvsphi(tfiles, reports, component, wheel, window=5., excludesectors=()):
2813 tdrStyle.SetOptTitle(1)
2814 tdrStyle.SetTitleBorderSize(1)
2815 tdrStyle.SetTitleFontSize(0.05)
2817 global htemp, gtemp_12, gtemp2_12, gtemp_23, gtemp2_23, gtemp_34, gtemp2_34, tlegend
2818 htemp = ROOT.TH1F(
"htemp",
"", 1, -pi, pi)
2819 gtemp_12_phi, gtemp_12_val, gtemp_12_err, gtemp_12_val2, gtemp_12_err2 = [], [], [], [], []
2820 gtemp_23_phi, gtemp_23_val, gtemp_23_err, gtemp_23_val2, gtemp_23_err2 = [], [], [], [], []
2821 gtemp_34_phi, gtemp_34_val, gtemp_34_err, gtemp_34_val2, gtemp_34_err2 = [], [], [], [], []
2822 for sector
in xrange(1, 12+1):
2824 r1_found, r2_found, r3_found, r4_found =
False,
False,
False,
False
2826 if r1.postal_address == (
"DT", wheel, 1, sector):
2830 if r2.postal_address == (
"DT", wheel, 2, sector):
2834 if r3.postal_address == (
"DT", wheel, 3, sector):
2838 if r4.postal_address == (
"DT", wheel, 4, sector):
2843 if sector
not in excludesectors:
2844 if r1_found
and r2_found
and r1.status ==
"PASS" and r2.status ==
"PASS":
2845 phi, val, err, val2, err2, fit1, fit2, fit3 =
segdiff(tfiles, component, 12, wheel=wheel, sector=sector)
2847 if fit1 == 0
and fit2 == 0
and fit3 == 0:
2849 gtemp_12_phi.append(phi)
2850 gtemp_12_val.append(val)
2851 gtemp_12_err.append(err)
2852 gtemp_12_val2.append(val2)
2853 gtemp_12_err2.append(err2)
2854 if r2_found
and r3_found
and r2.status ==
"PASS" and r3.status ==
"PASS":
2855 phi, val, err, val2, err2, fit1, fit2, fit3 =
segdiff(tfiles, component, 23, wheel=wheel, sector=sector)
2857 if fit1 == 0
and fit2 == 0
and fit3 == 0:
2859 gtemp_23_phi.append(phi)
2860 gtemp_23_val.append(val)
2861 gtemp_23_err.append(err)
2862 gtemp_23_val2.append(val2)
2863 gtemp_23_err2.append(err2)
2864 if component[:4] ==
"dt13":
2865 if r3_found
and r4_found
and r3.status ==
"PASS" and r4.status ==
"PASS":
2866 phi, val, err, val2, err2, fit1, fit2, fit3 =
segdiff(tfiles, component, 34, wheel=wheel, sector=sector)
2868 if fit1 == 0
and fit2 == 0
and fit3 == 0:
2870 gtemp_34_phi.append(phi)
2871 gtemp_34_val.append(val)
2872 gtemp_34_err.append(err)
2873 gtemp_34_val2.append(val2)
2874 gtemp_34_err2.append(err2)
2879 if len(gtemp_12_phi) > 0:
2880 gtemp_12 = ROOT.TGraphErrors(len(gtemp_12_phi), array.array(
"d", gtemp_12_phi), array.array(
"d", gtemp_12_val),
2881 array.array(
"d", [0.] * len(gtemp_12_phi)), array.array(
"d", gtemp_12_err))
2882 gtemp2_12 = ROOT.TGraphErrors(len(gtemp_12_phi), array.array(
"d", gtemp_12_phi), array.array(
"d", gtemp_12_val2),
2883 array.array(
"d", [0.] * len(gtemp_12_phi)), array.array(
"d", gtemp_12_err2))
2884 if len(gtemp_23_phi) > 0:
2885 gtemp_23 = ROOT.TGraphErrors(len(gtemp_23_phi), array.array(
"d", gtemp_23_phi), array.array(
"d", gtemp_23_val),
2886 array.array(
"d", [0.] * len(gtemp_23_phi)), array.array(
"d", gtemp_23_err))
2887 gtemp2_23 = ROOT.TGraphErrors(len(gtemp_23_phi), array.array(
"d", gtemp_23_phi), array.array(
"d", gtemp_23_val2),
2888 array.array(
"d", [0.] * len(gtemp_23_phi)), array.array(
"d", gtemp_23_err2))
2889 if len(gtemp_34_phi) > 0:
2890 gtemp_34 = ROOT.TGraphErrors(len(gtemp_34_phi), array.array(
"d", gtemp_34_phi), array.array(
"d", gtemp_34_val),
2891 array.array(
"d", [0.] * len(gtemp_34_phi)), array.array(
"d", gtemp_34_err))
2892 gtemp2_34 = ROOT.TGraphErrors(len(gtemp_34_phi), array.array(
"d", gtemp_34_phi), array.array(
"d", gtemp_34_val2),
2893 array.array(
"d", [0.] * len(gtemp_34_phi)), array.array(
"d", gtemp_34_err2))
2895 if len(gtemp_12_phi) > 0:
2896 gtemp_12.SetMarkerStyle(20); gtemp_12.SetMarkerSize(1.);
2897 gtemp_12.SetMarkerColor(ROOT.kBlue); gtemp_12.SetLineColor(ROOT.kBlue)
2898 gtemp2_12.SetMarkerStyle(24); gtemp2_12.SetMarkerSize(1.);
2899 gtemp2_12.SetMarkerColor(ROOT.kBlue); gtemp2_12.SetLineColor(ROOT.kBlue)
2900 if len(gtemp_23_phi) > 0:
2901 gtemp_23.SetMarkerStyle(21); gtemp_23.SetMarkerSize(1.);
2902 gtemp_23.SetMarkerColor(ROOT.kRed); gtemp_23.SetLineColor(ROOT.kRed)
2903 gtemp2_23.SetMarkerStyle(25); gtemp2_23.SetMarkerSize(1.);
2904 gtemp2_23.SetMarkerColor(ROOT.kRed); gtemp2_23.SetLineColor(ROOT.kRed)
2905 if len(gtemp_34_phi) > 0
and component[:4] ==
"dt13":
2906 gtemp_34.SetMarkerStyle(22); gtemp_34.SetMarkerSize(1.25);
2907 gtemp_34.SetMarkerColor(ROOT.kGreen+2); gtemp_34.SetLineColor(ROOT.kGreen+2)
2908 gtemp2_34.SetMarkerStyle(26); gtemp2_34.SetMarkerSize(1.25);
2909 gtemp2_34.SetMarkerColor(ROOT.kGreen+2); gtemp2_34.SetLineColor(ROOT.kGreen+2)
2911 if wheel == 0: htemp.SetTitle(
"Wheel %d" % wheel)
2912 else: htemp.SetTitle(
"Wheel %+d" % wheel)
2913 htemp.SetAxisRange(-window, window,
"Y")
2914 htemp.SetXTitle(
"Average #phi of pair (rad)")
2915 if component ==
"dt13_resid": htemp.SetYTitle(
"#Deltax^{local} (mm)")
2916 if component ==
"dt13_slope": htemp.SetYTitle(
"#Deltadx/dz^{local} (mrad)")
2917 if component ==
"dt2_resid": htemp.SetYTitle(
"#Deltay^{local} (mm)")
2918 if component ==
"dt2_slope": htemp.SetYTitle(
"#Deltady/dz^{local} (mrad)")
2919 htemp.GetXaxis().CenterTitle()
2920 htemp.GetYaxis().CenterTitle()
2921 htemp.GetYaxis().SetTitleOffset(0.75)
2925 if len(gtemp_12_phi) > 0:
2928 if len(gtemp_23_phi) > 0:
2931 if len(gtemp_34_phi) > 0:
2935 tlegend = ROOT.TLegend(0.5, 0.72, 0.9, 0.92)
2936 tlegend.SetBorderSize(0)
2937 tlegend.SetFillColor(ROOT.kWhite)
2938 if len(gtemp_12_phi) > 0:
2939 tlegend.AddEntry(gtemp_12,
"MB1 - MB2 (mean: %4.2f, RMS: %4.2f)" % (
mean(gtemp_12_val),
stdev(gtemp_12_val)),
"pl")
2940 if len(gtemp_23_phi) > 0:
2941 tlegend.AddEntry(gtemp_23,
"MB2 - MB3 (mean: %4.2f, RMS: %4.2f)" % (
mean(gtemp_23_val),
stdev(gtemp_23_val)),
"pl")
2942 if len(gtemp_34_phi) > 0:
2943 tlegend.AddEntry(gtemp_34,
"MB3 - MB4 (mean: %4.2f, RMS: %4.2f)" % (
mean(gtemp_34_val),
stdev(gtemp_34_val)),
"pl")
2944 if len(gtemp_12_phi) > 0:
2945 tlegend.AddEntry(gtemp_12,
"total mean: %4.2f, total RMS: %4.2f" % \
2946 (
mean(gtemp_12_val + gtemp_23_val + gtemp_34_val),
2947 stdev(gtemp_12_val + gtemp_23_val + gtemp_34_val)),
"")
def wheelm2only
Convenience functions.
const T & max(const T &a, const T &b)
static std::string join(char **cmd)
def testDeltaWithin5Sigma