3 from __future__
import print_function
4 from builtins
import range
5 import re,os,sys,shutil
10 execfile(
"plotscripts.py")
12 ROOT.gROOT.SetBatch(1);
19 usage=
'%prog [options]\n'+\
20 'This script dumps muon alignment validation plots '+\
21 '(see https://twiki.cern.ch/twiki/bin/viewauth/CMS/SWGuideMuonAlignValidationPlots) '+\
22 'in web-friendly png format into a predefined directory structure '+\
23 'and also (to be implemented) does some quality checks for these plots.\n'+\
24 'Script uses output of the first and last iterations of muon alignment runs '+\
25 'that should be located in inputDir+i1 and inputDir+iN directories (see options descriptions). '+\
26 'Each of these directories should contain\ni#prefix+"_plotting.root"\ni#prefix+".root"\ni#prefix+"_report.py"\n'+\
27 'files, where # = 1 or N.\n'+\
28 'Output will be located in outputDir, which must exist. Plots from the first and last iterations '+\
29 'will be in outputDir+"iter1" and outputDir+"iterN" respectively, and plots relevant for all iterations will '+\
30 'reside in outputDir+"common/".\n'+\
31 'For a first run a --createDirSructure option must be present. If this option is present for subsequent runs '+\
32 'with the same outputDir, all previous results in "iter1", "iterN" and and "common" would be deleted!\n'+\
33 'If neither --dt or --csc is present, plots for both systems will be created.\n'+\
34 'Options must include either -a or any of the following: --map, --segdiff, --fit, --median' 36 parser=optparse.OptionParser(usage)
38 parser.add_option(
"-l",
"--runLabel",
39 help=
"[REQUIRED] label to use for a run",
44 parser.add_option(
"-i",
"--inputDir",
45 help=
"[REQUIRED] input directory: should contain directories with the first and the final iterations' results",
50 parser.add_option(
"--i1",
51 help=
"[REQUIRED] directory with the alignment 1st iteration's results relative to inputDir",
56 parser.add_option(
"--iN",
57 help=
"[REQUIRED] directory with the alignment last iteration's results relative to inputDir",
62 parser.add_option(
"--i1prefix",
63 help=
"filename prefix for the alignment 1st iteration's results. If not provided, i1prefix = i1",
68 parser.add_option(
"--iNprefix",
69 help=
"filename prefix for the alignment last iteration's results. If not provided, iNprefix = iN",
74 parser.add_option(
"-o",
"--outputDir",
75 help=
"output directory: all plots will be saved with relation to outputDir. If not provided, consider outputDir = inputDir",
80 parser.add_option(
"--createDirSructure",
81 help=
"If present, new directory structure for storing plots will be first created for each iteration at outputDir+i1 and outputDir+iN. WARNING: this will delete any existing results!",
84 dest=
"createDirSructure")
86 parser.add_option(
"--dt",
87 help=
"If it is present, but not --csc, DT only plots will be created",
92 parser.add_option(
"--csc",
93 help=
"If this is present, but not --dt, CSC only plots will be created",
98 parser.add_option(
"-a",
"--all",
99 help=
"If present, all types of plots will be created",
104 parser.add_option(
"--map",
105 help=
"If present, map plots will be created",
110 parser.add_option(
"--segdiff",
111 help=
"If present, segdiff plots will be created",
116 parser.add_option(
"--curvature",
117 help=
"If present, curvature plots will be created",
122 parser.add_option(
"--fit",
123 help=
"If present, fit functions plots will be created",
128 parser.add_option(
"--median",
129 help=
"If present, median plots will be created",
134 parser.add_option(
"--diagnostic",
135 help=
"If present, will run diagnostic checks",
140 parser.add_option(
"-v",
"--verbose",
141 help=
"Degree of debug info verbosity",
146 options,args=parser.parse_args()
148 if options.runLabel==
'' or options.inputDir==
'' or options.i1==
'' or options.iN==
'':
149 print(
"\nOne or more of REQUIRED options is missing!\n")
154 outdir = options.outputDir
155 if outdir==
'': outdir = options.inputDir
157 i1prefix = options.i1prefix
158 if i1prefix==
'' : i1prefix = options.i1
160 iNprefix = options.iNprefix
161 if iNprefix==
'' : iNprefix = options.iN
163 if not os.access(outdir,os.F_OK):
164 print(
"\noutDir = "+outdir+
"\ndoes not exist! Exiting...")
170 if options.dt
or not ( options.dt
or options.csc):
172 if options.csc
or not ( options.dt
or options.csc):
175 if not (options.all
or options.map
or options.curvature
or options.segdiff
or options.fit
or options.median
or options.diagnostic):
176 print(
"\nOptions must include either -a or any of the following: --map, --segdiff, --fit, --median, --diagnostic. Exiting...")
179 SINGLE_ITERATION =
False 180 if i1prefix == iNprefix: SINGLE_ITERATION =
True 187 if options.map
or options.all:
189 if options.segdiff
or options.all:
191 if options.curvature
or options.all:
193 if options.fit
or options.all:
195 if options.median
or options.all:
198 DO_DIAGNOSTIC = options.diagnostic
200 allOptions =
"-l "+options.runLabel+
" -i "+options.inputDir+
" --i1 "+options.i1+
" --iN "+options.iN
201 if options.i1prefix !=
'': allOptions +=
" --i1prefix " + options.i1prefix
202 if options.iNprefix !=
'': allOptions +=
" --iNprefix " + options.iNprefix
203 allOptions +=
" -o "+options.outputDir
204 if options.createDirSructure: allOptions +=
" --createDirSructure" 205 if DO_DT: allOptions +=
" --dt" 206 if DO_CSC: allOptions +=
" --csc" 207 if options.all: allOptions +=
" -a" 208 if options.map: allOptions +=
" --map" 209 if options.segdiff: allOptions +=
" --segdiff" 210 if options.curvature: allOptions +=
" --curvature" 211 if options.fit: allOptions +=
" --fit" 212 if options.median: allOptions +=
" --median" 213 if options.diagnostic: allOptions +=
" --diagnostic" 214 print(sys.argv[0]+
" "+allOptions)
224 CANVASES_LIST_TEMPLATE = [
226 [
'medians distribution',
'medians.png']
229 [
'Wheel&Station: map of dxdz residual vs phi',
'map_DTvsphi_dxdz.png'],
230 [
'Wheel&Station: map of dydz residual vs phi',
'map_DTvsphi_dydz.png'],
231 [
'Wheel&Station: map of x residual vs phi',
'map_DTvsphi_x.png'],
232 [
'Wheel&Station: map of y residual vs phi',
'map_DTvsphi_y.png'],
233 [
'Station&Sector: map of dxdz residual vs z',
'map_DTvsz_dxdz.png'],
234 [
'Station&Sector: map of dydz residual vs z',
'map_DTvsz_dydz.png'],
235 [
'Station&Sector: map of x residual vs z',
'map_DTvsz_x.png'],
236 [
'Station&Sector: map of y residual vs z',
'map_DTvsz_y.png'],
237 [
'Station: map of dxdz residual vs z',
'map_DTvsz_all_dxdz.png'],
238 [
'Station: map of dydz residual vs z',
'map_DTvsz_all_dydz.png'],
239 [
'Station: map of x residual vs z',
'map_DTvsz_all_x.png'],
240 [
'Station: map of y residual vs z',
'map_DTvsz_all_y.png'],
241 [
'Wheel: segdiff in x residuals vs phi',
'segdifphi_dt13_resid.png'],
242 [
'Wheel: segdiff in dxdz residuals vs phi',
'segdifphi_dt13_slope.png'],
243 [
'Wheel: segdiff in y residuals vs phi',
'segdifphi_dt2_resid.png'],
244 [
'Wheel: segdiff in dydz residuals vs phi',
'segdifphi_dt2_slope.png'],
245 [
'Wheel: segdiff DT-CSC in x residuals vs phi',
'segdifphi_x_dt_csc_resid.png'],
246 [
'Chamber: segdiff in x residuals',
'segdif_dt13_resid.png'],
247 [
'Chamber: segdiff in dxdz residuals',
'segdif_dt13_slope.png'],
248 [
'Chamber: segdiff in y residuals',
'segdif_dt2_resid.png'],
249 [
'Chamber: segdiff in dydz residuals',
'segdif_dt2_slope.png'],
250 [
'Chamber: segdiff DT-CSC in x residuals',
'segdif_x_dt_csc_resid.png'],
251 [
'Chamber: residuals distributions',
'dt_bellcurves.png'],
252 [
'Chamber: residuals relations to misalignments',
'dt_polynomials.png'],
253 [
'Chamber: Delta x residuals vs. curvature',
'dt_curvature_deltax.png'],
254 [
'Chamber: Delta dxdz residuals vs. curvature',
'dt_curvature_deltadxdz.png'],
255 [
'Extras: Extra plots in a separate window',
'dt_extras.php']
258 [
'Station&Ring: map of d(rphi)/dz residual vs phi',
'map_CSCvsphi_dxdz.png'],
259 [
'Station&Ring: map of rphi residual vs phi',
'map_CSCvsphi_x.png'],
260 [
'Station&Chamber: map of d(rphi)/dz residual vs r',
'map_CSCvsr_dxdz.png'],
261 [
'Station&Chamber: map of rphi residual vs r',
'map_CSCvsr_x.png'],
262 [
'Station: map of d(rphi)/dz residual vs r',
'map_CSCvsr_all_dxdz.png'],
263 [
'Station: map of rphi residual vs r',
'map_CSCvsr_all_x.png'],
264 [
'Station: segdiff in rphi residuals vs phi',
'segdifphi_csc_resid.png'],
265 [
'Station: segdiff in d(rphi)/dz residuals vs phi',
'segdifphi_csc_slope.png'],
266 [
'Chamber: segdiff in rphi residuals',
'segdif_csc_resid.png'],
267 [
'Chamber: segdiff in d(rphi)/dz residuals',
'segdif_csc_slope.png'],
268 [
'Chamber: residuals distributions',
'csc_bellcurves.png'],
269 [
'Chamber: residuals relations to misalignments',
'csc_polynomials.png'],
272 [
'Extras: Extra plots in a separate window',
'csc_extras.php']
282 '''Recursively looks for file named file_name under dir_name directory 284 if not DO_DT
and dir_name.find(
"MB")>-1:
286 if not DO_CSC
and dir_name.find(
"ME")>-1:
289 for f
in os.listdir(dir_name):
290 dirfile = os.path.join(dir_name, f)
291 if os.path.isfile(dirfile)
and f==file_name:
294 elif os.path.isdir(dirfile):
306 ddt[16] = 1./ddt[15]*((ddt[15]-1)*ddt[16] + tn-t1)
311 if not os.access(iteration_name,os.F_OK):
312 os.mkdir(iteration_name)
314 csc_basedir = iteration_name+
'/' 315 for endcap
in CSC_TYPES:
317 shutil.rmtree(csc_basedir+endcap[0],
True)
318 os.mkdir(csc_basedir+endcap[0])
319 for station
in endcap[2]:
321 os.mkdir(csc_basedir+endcap[0]+
'/'+station[1])
322 for ring
in station[2]:
324 os.mkdir(csc_basedir+endcap[0]+
'/'+station[1]+
'/'+ring[1])
325 for chamber
in range(1,ring[2]+1):
326 schamber =
"%02d" % chamber
328 os.mkdir(csc_basedir+endcap[0]+
'/'+station[1]+
'/'+ring[1]+
'/'+schamber)
330 dt_basedir = iteration_name+
'/MB/' 332 shutil.rmtree(dt_basedir,
True)
334 for wheel
in DT_TYPES:
336 os.mkdir(dt_basedir+wheel[0])
337 for station
in wheel[2]:
339 os.mkdir(dt_basedir+wheel[0]+
'/'+station[1])
340 for sector
in range(1,station[2]+1):
341 ssector =
"%02d" % sector
343 os.mkdir(dt_basedir+wheel[0]+
'/'+station[1]+
'/'+ssector)
350 """write DT map plots 352 "DTvsphi_st%dwh%s" % (station, wheelletter): 354 plots "integrated" over ALL SECTORS: 355 of x, y, dxdz, dydz vs. phi (y and dydz only for stations 1-3) 356 made for all (station,wheel) combinations 358 Access interface may be arranged into station(1 .. 4) vs. wheel(-2 .. +2) map. 359 It could be incorporated into a general DT chambers map (column1: wheel, column2: station, 360 columns3-16 correspond to sector #) by making station numbers in column 2 clickable. 363 "DTvsz_st%dsec%02d" % (station, sector) 365 plots "integrated" over ALL WHEELS: 366 of x, y, dxdz, dydz vs. z (y and dydz only for stations 1-3) 367 made for all (station,sector) combinations 369 Interface: may be arranged into station(1 .. 4) vs. sector(1 .. 14) map with sector range 370 (1 .. 12) for stations 1-3. 371 It could be incorporated into an EXTENDED general DT chambers map (extended by adding an 372 identifier "ALL" in column1 for wheel number). 375 "DTvsz_st%dsecALL" % (station) 377 plots spanning in z over ALL WHEELS and "integrated" over all sectors: 378 of x, y, dxdz, dydz vs. z (y and dydz only for stations 1-3) 379 made for all stations 381 Interface: may be arranged into station(1 .. 4) map 382 It could be incorporated into an EXTENDED general DT chambers map (extended by adding an 383 identifier "ALL" in column1 for wheel number).""" 386 for wheel
in DT_TYPES:
387 if wheel[1]==
"ALL":
continue 388 for station
in wheel[2]:
389 pdir = dt_basedir+
'/'+wheel[0]+
'/'+station[1]+
'/' 391 htitle =
"wheel %+d, station %s" % (
int(wheel[1]), station[1])
393 mapplot(tfiles_plotting, label,
"x", window=10., title=htitle, fitsine=
True,fitpeaks=
True,peaksbins=2)
394 c1.SaveAs(pdir+
'map_DTvsphi_x.png')
396 mapplot(tfiles_plotting, label,
"dxdz", window=10., title=htitle,peaksbins=2)
397 c1.SaveAs(pdir+
'map_DTvsphi_dxdz.png')
399 if station[1]==
'4':
continue 401 mapplot(tfiles_plotting, label,
"y", window=10., title=htitle,peaksbins=2)
402 c1.SaveAs(pdir+
'map_DTvsphi_y.png')
404 mapplot(tfiles_plotting, label,
"dydz", window=10., title=htitle,peaksbins=2)
405 c1.SaveAs(pdir+
'map_DTvsphi_dydz.png')
409 for wheel
in DT_TYPES:
410 if wheel[1]!=
"ALL":
continue 411 for station
in wheel[2]:
412 for sector
in range(1,station[2]+1):
413 if qcount>QUICKTESTN:
break 415 ssector =
"%02d" % sector
416 pdir = dt_basedir+
'/'+wheel[0]+
'/'+station[1]+
'/'+ssector+
'/' 417 label =
"DTvsz_st%ssec%s" % (station[1], ssector)
418 htitle =
"station %s, sector %d" % (station[1], sector)
419 mapplot(tfiles_plotting, label,
"x", window=10., title=htitle, peaksbins=2)
420 c1.SaveAs(pdir+
'map_DTvsz_x.png')
421 mapplot(tfiles_plotting, label,
"dxdz", window=10., title=htitle, peaksbins=2)
422 c1.SaveAs(pdir+
'map_DTvsz_dxdz.png')
424 if station[1]==
'4':
continue 425 mapplot(tfiles_plotting, label,
"y", window=10., title=htitle, peaksbins=2)
426 c1.SaveAs(pdir+
'map_DTvsz_y.png')
427 mapplot(tfiles_plotting, label,
"dydz", window=10., title=htitle, peaksbins=2)
428 c1.SaveAs(pdir+
'map_DTvsz_dydz.png')
431 for wheel
in DT_TYPES:
432 if wheel[1]!=
"ALL":
continue 433 for station
in wheel[2]:
434 if qcount>QUICKTESTN:
break 436 pdir = dt_basedir+
'/'+wheel[0]+
'/'+station[1]+
'/' 437 label =
"DTvsz_st%ssecALL" % (station[1])
438 htitle =
"station %s" % (station[1])
440 print(label, end=
' ')
441 mapplot(tfiles_plotting, label,
"x", window=10., title=htitle, peaksbins=2)
442 c1.SaveAs(pdir+
'map_DTvsz_all_x.png')
443 mapplot(tfiles_plotting, label,
"dxdz", window=10., title=htitle, peaksbins=2)
444 c1.SaveAs(pdir+
'map_DTvsz_all_dxdz.png')
446 if station[1]==
'4':
continue 447 mapplot(tfiles_plotting, label,
"y", window=10., title=htitle, peaksbins=2)
448 c1.SaveAs(pdir+
'map_DTvsz_all_y.png')
449 mapplot(tfiles_plotting, label,
"dydz", window=10., title=htitle, peaksbins=2)
450 c1.SaveAs(pdir+
'map_DTvsz_all_dydz.png')
456 """write CSC map plots 458 "CSCvsphi_me%s%d%d" % (endcap, station, ring) 460 plots "integrated" over ALL SECTORS: 461 of rphi, drphi/dz vs. phi 462 made for all (endcap,station,ring) combinations 464 Interface: may be arranged into two station(1 .. 4) vs. R(1 .. 4) maps for both endcaps 465 with R range (1 .. 4) for stations 2-4 466 It could be incorporated into a general CSC chambers map (column1: endcap, column2: station, 467 column3: ring, columns4-40 correspond to chamber #) by making ring numbers in column 3 471 "CSCvsr_me%s%dch%02d" % (endcap, station, chamberNumber) 473 plots "integrated" over ALL RINGS: 474 of rphi, drphi/dz vs. z 475 made for all (endcap,station,chamber) combinations 477 Interface: may be arranged into two station(1 .. 4) vs. chamber(1 .. 36) maps for both endcaps 478 It could be incorporated into an EXTENDED general CSC chambers map (extended by adding an 479 identifier "ALL" in column3 for ring number). 481 "CSCvsr_me%s%dchALL" % (endcap, station) 483 plots spanning over ALL RINGS along r and integrated over all SECTORS: 484 of rphi, drphi/dz vs. z 485 made for all (endcap,station) combinations 487 Interface: may be arranged into two station(1 .. 4) maps for both endcaps 488 It could be incorporated into an EXTENDED general CSC chambers map (extended by adding an 489 identifier "ALL" in column3 for ring number).""" 491 for endcap
in CSC_TYPES:
492 for station
in endcap[2]:
493 for ring
in station[2]:
494 if ring[1]==
"ALL":
continue 495 pdir = csc_basedir+
'/'+endcap[0]+
'/'+station[1]+
'/'+ring[1]+
'/' 496 label =
"CSCvsphi_me%s%s%s" % (endcap[1], station[1], ring[1])
497 htitle =
"%s%s/%s" % (endcap[0], station[1],ring[1])
498 mapplot(tfiles_plotting, label,
"x", window=15., title=htitle, fitsine=
True,fitpeaks=
True, peaksbins=2)
500 c1.SaveAs(pdir+
'map_CSCvsphi_x.png')
501 mapplot(tfiles_plotting, label,
"dxdz", window=15., title=htitle, peaksbins=2)
502 c1.SaveAs(pdir+
'map_CSCvsphi_dxdz.png')
507 for endcap
in CSC_TYPES:
508 for station
in endcap[2]:
509 for ring
in station[2]:
510 if ring[1]!=
"ALL":
continue 511 for chamber
in range(1,ring[2]+1):
512 if qcount>QUICKTESTN:
break 514 schamber =
"%02d" % chamber
515 pdir = csc_basedir+
'/'+endcap[0]+
'/'+station[1]+
'/'+ring[1]+
'/'+schamber+
'/' 516 label =
"CSCvsr_me%s%sch%s" % (endcap[1], station[1], schamber)
517 htitle =
"%s%s/ALL/%d" % (endcap[0], station[1],chamber)
518 mapplot(tfiles_plotting, label,
"x", window=15., title=htitle, peaksbins=2)
519 c1.SaveAs(pdir+
'map_CSCvsr_x.png')
520 mapplot(tfiles_plotting, label,
"dxdz", window=15., title=htitle, peaksbins=2)
521 c1.SaveAs(pdir+
'map_CSCvsr_dxdz.png')
524 for endcap
in CSC_TYPES:
525 for station
in endcap[2]:
526 for ring
in station[2]:
527 if ring[1]!=
"ALL":
continue 528 if qcount>QUICKTESTN:
break 530 schamber =
"%02d" % chamber
531 pdir = csc_basedir+
'/'+endcap[0]+
'/'+station[1]+
'/'+ring[1]+
'/' 532 label =
"CSCvsr_me%s%schALL" % (endcap[1], station[1])
533 htitle =
"%s%s" % (endcap[0], station[1])
534 mapplot(tfiles_plotting, label,
"x", window=10., title=htitle, peaksbins=2)
535 c1.SaveAs(pdir+
'map_CSCvsr_all_x.png')
536 mapplot(tfiles_plotting, label,
"dxdz", window=10., title=htitle, peaksbins=2)
537 c1.SaveAs(pdir+
'map_CSCvsr_all_dxdz.png')
542 """write DT curvature plots 544 "wheel%s_sector%s" % (wheel, sector) 546 wheel in "m2", "m1", "z", "p1", "p2" 548 sector in "01", ..., "12" 550 "param" may be one of 551 "deltax" (Delta x position residuals), 552 "deltadxdz" (Delta (dx/dz) angular residuals), 553 "curverr" (Delta x * d(Delta q/pT)/d(Delta x) = Delta q/pT in the absence of misalignment) - not necessary 555 made for all (wheel,station=1,sector) combinations 557 Interface: could be accesses through a general DT chambers map for station=1 chambers.""" 559 w_dict = {
'-2':
'm2',
'-1':
'm1',
'0':
'z',
'1':
'p1',
'2':
'p2'}
561 for wheel
in DT_TYPES:
562 if wheel[1]==
"ALL":
continue 565 for station
in wheel[2]:
566 print(
"curv in ", wheel[0]+
'/'+station[1])
567 for sector
in range(1,station[2]+1):
569 if qcount>QUICKTESTN:
break 571 ssector =
"%02d" % sector
572 pdir = dt_basedir+
'/'+wheel[0]+
'/'+station[1]+
'/'+ssector+
'/' 573 label =
"wheel%s_st%s_sector%s" % (w_dict[wheel[1]], station[1], ssector)
574 thetitle =
"Wheel %s, station %s, sector %s" % (wheel[1], station[1], ssector)
575 curvatureplot(tfiles_plotting, label,
"deltax", title=thetitle, window=10., fitline=
True)
576 saveAs(pdir+
'dt_curvature_deltax.png')
577 curvatureplot(tfiles_plotting, label,
"deltadxdz", title=thetitle, window=10., fitline=
True)
578 saveAs(pdir+
'dt_curvature_deltadxdz.png')
583 """write segment-difference plots for DT 585 segdiff "dt13_resid" and "dt13_slope" 588 x vs qpt, x for positive, x for negative ("dt13_resid") 589 dxdz vs qpt, dxdz for positive, dxdz for negative ("dt13_slope") 590 done for MB1-MB2, MB2-MB3, and MB3-MB4 stations combinations with all possible (wheel, sector) 592 Interface: could be accessed through a general DT chambers map, but only for chambers in 593 stations 2-4 (e.g., station 2 would provide MB1-MB2 plots). 595 segdiff "dt2_resid" and "dt2_slope" 598 y vs q/pt, y for positive, y for negative ("dt2_resid") 599 dydz vs q/pt, dydz for positive, dydz for negative ("dt2_slope") 600 done for MB1-MB2, MB2-MB3 stations combinations with all possible (wheel, sector) 602 Interface: then the interface would still be a general DT map, 603 but the info only available from station 2 & 3 chambers.""" 606 for iwheel
in DT_TYPES:
607 if iwheel[1]==
"ALL":
continue 608 for istation
in iwheel[2]:
609 if istation[1]==
"1":
continue 610 dstations = (
int(istation[1])-1)*10 +
int(istation[1])
612 for isector
in range(1, istation[2] + 1):
613 if isector > 12:
continue 614 if qcount>QUICKTESTN:
break 616 ssector =
"%02d" % isector
617 pdir = dt_basedir +
'/' + iwheel[0] +
'/' + istation[1] +
'/' + ssector +
'/' 619 segdiff(tfiles_plotting,
"dt13_resid", dstations, wheel=
int(iwheel[1]), sector=isector, window=15.)
620 c1.SaveAs(pdir +
'segdif_dt13_resid.png')
621 segdiff(tfiles_plotting,
"dt13_slope", dstations, wheel=
int(iwheel[1]), sector=isector, window=15.)
622 c1.SaveAs(pdir +
'segdif_dt13_slope.png')
624 if istation[1] !=
'4':
625 segdiff(tfiles_plotting,
"dt2_resid", dstations, wheel=
int(iwheel[1]), sector=isector, window=15.)
626 c1.SaveAs(pdir +
'segdif_dt2_resid.png')
627 segdiff(tfiles_plotting,
"dt2_slope", dstations, wheel=
int(iwheel[1]), sector=isector, window=15.)
628 c1.SaveAs(pdir +
'segdif_dt2_slope.png')
631 for iwheel
in DT_TYPES:
632 if iwheel[1]==
"ALL":
continue 633 if abs(
int(iwheel[1])) != 2:
continue 634 for istation
in iwheel[2]:
635 if istation[1]==
"3":
continue 637 for isector
in range(1, istation[2] + 1):
638 ssector =
"%02d" % isector
639 pdir = dt_basedir +
'/' + iwheel[0] +
'/' + istation[1] +
'/' + ssector +
'/' 641 segdiff_xalign(tfiles_plotting,
"x_dt1_csc", wheel=
int(iwheel[1]), sector=isector, cscstations =
"12")
642 c1.SaveAs(pdir +
'segdif_x_dt_csc_resid.png')
644 segdiff_xalign(tfiles_plotting,
"x_dt2_csc", wheel=
int(iwheel[1]), sector=isector, cscstations =
"1")
645 c1.SaveAs(pdir +
'segdif_x_dt_csc_resid.png')
647 """segdiffvsphi "dt13_resid" and "dt13_slope" 649 plot for a specific wheel #: 650 x vs phi of pair ("dt13_resid") 651 dxdz vs phi of pair ("dt13_slope") 652 contains all three combinations of neighboring stations 653 made for all possible wheel values 655 Interface: could be accessed by clicking on wheel number under the "wheel" column 658 segdiffvsphi "dt2_resid" and "dt2_slope" 660 plot for a specific wheel #: 661 y vs phi of pair ("dt2_resid") 662 dydz vs phi of pair ("dt2_slope") 663 contains both MB1-MB2 and MB2-MB3 combinations 664 made for all possible wheel values 666 Interface: could be accessed by clicking on wheel number under the "wheel" column 667 in a general DT map""" 669 if len(iter_reports)==0:
return 671 for iwheel
in DT_TYPES:
672 if iwheel[1]==
"ALL":
continue 673 pdir = dt_basedir +
'/' + iwheel[0] +
'/' 674 segdiffvsphi(tfiles_plotting, iter_reports,
"dt13_resid",
int(iwheel[1]), window=10.)
675 c1.SaveAs(pdir +
'segdifphi_dt13_resid.png')
676 segdiffvsphi(tfiles_plotting, iter_reports,
"dt13_slope",
int(iwheel[1]), window=10.)
677 c1.SaveAs(pdir +
'segdifphi_dt13_slope.png')
678 segdiffvsphi(tfiles_plotting, iter_reports,
"dt2_resid",
int(iwheel[1]), window=10.)
679 c1.SaveAs(pdir +
'segdifphi_dt2_resid.png')
680 segdiffvsphi(tfiles_plotting, iter_reports,
"dt2_slope",
int(iwheel[1]), window=15.)
681 c1.SaveAs(pdir +
'segdifphi_dt2_slope.png')
683 for iwheel
in DT_TYPES:
684 if iwheel[1]==
"ALL":
continue 685 if abs(
int(iwheel[1])) != 2:
continue 686 pdir = dt_basedir +
'/' + iwheel[0] +
'/' 688 c1.SaveAs(pdir +
'segdifphi_x_dt_csc_resid.png')
692 """write segment-difference plots for CSC 694 segdiff "csc_resid" and "csc_slope" 697 rphi vs qpt, rphi for positive, rphi for negative ("csc_resid") 698 drphidz vs qpt, drphidz for positive, drphidz for negative ("csc_slope") 699 done for ME1-ME2, ME2-ME3, and ME3-ME4 stations combinations with 702 chamber 1-18 (r1) or 1-36 (r2) 703 note: there's no ME3-ME4 plots for R2 705 Interface: could be accessed through a general CSC chambers map, but only for chambers in 706 stations 2-4 (e.g., station 2 would provide ME1-ME2 plots).""" 709 for iendcap
in CSC_TYPES:
710 for istation
in iendcap[2]:
711 if istation[1]==
"1":
continue 712 dstations = (
int(istation[1])-1)*10 +
int(istation[1])
713 for iring
in istation[2]:
714 if iring[1]==
"ALL":
continue 715 if istation[1]==
"4" and iring[1]==
"2":
continue 716 for ichamber
in range(1,iring[2]+1):
717 if qcount>QUICKTESTN:
break 719 schamber =
"%02d" % ichamber
720 pdir = csc_basedir+
'/'+iendcap[0]+
'/'+istation[1]+
'/'+iring[1]+
'/'+schamber+
'/' 721 segdiff(tfiles_plotting,
"csc_resid", dstations,
722 endcap=iendcap[1], ring=
int(iring[1]), chamber=ichamber, window=15.)
723 c1.SaveAs(pdir +
'segdif_csc_resid.png')
724 segdiff(tfiles_plotting,
"csc_slope", dstations,
725 endcap=iendcap[1], ring=
int(iring[1]), chamber=ichamber, window=15.)
726 c1.SaveAs(pdir +
'segdif_csc_slope.png')
728 """segdiffvsphicsc "csc_resid" and "csc_slope" 730 plot for a specific deltaME station differences: 731 rphi vs phi of pair ("csc_resid") 732 dxdz vs phi of pair ("csc_slope") 733 contains plots for two (or one for ME4-ME3) rings 734 done for ME1-ME2, ME2-ME3, and ME3-ME4 stations combinations with 737 Interface: could be accessed by clicking on ME station boxes, but only for stations 2-4 738 (e.g., station 2 would provide ME1-ME2 plots).""" 741 for iendcap
in CSC_TYPES:
742 for istation
in iendcap[2]:
743 if istation[1]==
"1":
continue 744 dstations = (
int(istation[1])-1)*10 +
int(istation[1])
745 if qcount>QUICKTESTN:
break 747 pdir = csc_basedir+
'/'+iendcap[0]+
'/'+istation[1]+
'/' 748 segdiffvsphicsc(tfiles_plotting,
"csc_resid", dstations, window=10., endcap=iendcap[1])
749 c1.SaveAs(pdir +
'segdifphi_csc_resid.png')
750 segdiffvsphicsc(tfiles_plotting,
"csc_slope", dstations, window=10., endcap=iendcap[1])
751 c1.SaveAs(pdir +
'segdifphi_csc_slope.png')
755 """write fit functions plots for DT 757 DT bellcurves and polynomials 759 set of plots of bellcurves 760 x, dxdz, x vs. dxdz (for all 4 stations) 761 y, dydz, x vs. dxdz (only for stations 1-3?) 763 set of plots of polynomials -- for stations 1-3 only?? 764 x vs. xpos, x vs ypos, x vs dxdz angle, x vs dydz angle 765 y vs. xpos, y vs ypos, y vs dxdz angle, y vs dydz angle 766 dxdz vs. xpos, dxdz vs ypos, dxdz vs dxdz angle, dxdz vs dydz angle 767 dydz vs. xpos, dydz vs ypos, dydz vs dxdz angle, dydz vs dydz angle 769 set of plots of polynomials -- for station 4 only?? 770 x vs. xpos, x vs dxdz angle 771 dxdz vs. xpos, dxdz vs dxdz angle 773 made for all (wheel,station,sector) combinations 775 Interface: could be accesses through a general DT chambers map.""" 779 for wheel
in DT_TYPES:
780 if wheel[1]==
"ALL":
continue 781 for station
in wheel[2]:
782 print(wheel[0]+
'/'+station[1])
783 for sector
in range(1,station[2]+1):
784 if qcount>QUICKTESTN:
break 786 ssector =
"%02d" % sector
787 pdir = dt_basedir+
'/'+wheel[0]+
'/'+station[1]+
'/'+ssector+
'/' 788 label =
"MBwh%sst%ssec%s" % (
wheelLetter(
int(wheel[1])),station[1],ssector)
789 bellcurves(iter_tfile, iter_reports, label,
False)
791 saveAs(pdir+
'dt_bellcurves.png')
792 polynomials(iter_tfile, iter_reports, label,
False)
794 saveAs(pdir+
'dt_polynomials.png')
799 """write fit functions plots for CSC 801 CSC bellcurves and polynomials 803 set of plots of bellcurves 804 rphi, drphidz, rphi vs. drphidz 806 set of plots of polynomials 807 rphi vs. rphi pos, rphi vs drphidz angle 808 drphidz vs. rphi pos, drphidz vs drphidz angle 810 made for all (endcap,station,ring,chamber) combinations 812 Interface: could be accesses through a general CSC chambers map.""" 816 for endcap
in CSC_TYPES:
817 for station
in endcap[2]:
818 for ring
in station[2]:
819 if ring[1]==
"ALL":
continue 820 print(endcap[0]+
'/'+station[1]+
'/'+ring[1])
821 for chamber
in range(1,ring[2]+1):
822 if qcount>QUICKTESTN:
break 824 schamber =
"%02d" % chamber
825 pdir = csc_basedir+
'/'+endcap[0]+
'/'+station[1]+
'/'+ring[1]+
'/'+schamber+
'/' 826 label =
"ME%s%s%s_%s" % (endcap[1], station[1], ring[1], schamber)
827 bellcurves(iter_tfile, iter_reports, label,
False)
829 saveAs(pdir+
'csc_bellcurves.png')
830 polynomials(iter_tfile, iter_reports, label,
False)
832 saveAs(pdir+
'csc_polynomials.png')
838 dt_basedir = iteration_directory+
'/'+
'MB' 839 csc_basedir = iteration_directory+
'/' 843 if DO_CSC
and DO_MAP:
846 if DO_DT
and DO_CURVATURE:
851 if DO_DT
and DO_SEGDIFF:
853 if DO_CSC
and DO_SEGDIFF:
858 if DO_CSC
and DO_FIT:
863 '''Use CANVASES_LIST_TEMPLATE as a template to create a canvases list include for the browser. 864 Write out only those canvases which have existing filename.png plots. 867 for scope
in CANVASES_LIST_TEMPLATE:
870 scope_entry = [scope[0],scope[1]]
871 for canvas_entry
in scope[2:]:
873 scope_entry.append(canvas_entry)
874 CANVASES_LIST.append(scope_entry)
876 ff = open(fname,mode=
"w")
877 print(
"var CANVASES_LIST = ", file=ff)
878 json.dump(CANVASES_LIST,ff)
883 '''Writes out a canvas-2-ids list include for the browser. 884 Write out only those canvases which have existing filename.png plots. 885 Returns: list of unique IDs that have existing filename.png plots. 889 for scope
in CANVASES_LIST_TEMPLATE:
891 for canvas_entry
in scope[2:]:
898 print(canvas_entry,
":", len(uids),
"ids")
900 CANVAS2ID_LIST.append( (canvas_entry[1],uids) )
902 CANVAS2ID_LIST_DICT =
dict(CANVAS2ID_LIST)
904 ff = open(fname,mode=
"w")
905 print(
"var CANVAS2ID_LIST = ", file=ff)
906 json.dump(CANVAS2ID_LIST_DICT,ff)
908 set_ids = set(ID_LIST)
912 '''Recursively looks for file named file_name under dir_name directory 913 and fill the list with dir names converted to IDs 916 for f
in os.listdir(dir_name):
917 dirfile = os.path.join(dir_name, f)
918 if os.path.isfile(dirfile)
and f==file_name:
919 if file_name[-4:]==
'.php': id_list.append(dir_name+
'/'+file_name)
920 else: id_list.append(
dirToID(dir_name))
922 elif os.path.isdir(dirfile):
931 if d[-1]!=
'/': d +=
'/' 935 cscn = d.find(
"/ME-/")
937 return 'ME-'+d[cscn+5:-1]
938 cscn = d.find(
"/ME+/")
940 return 'ME+'+d[cscn+5:-1]
959 fname = options.inputDir+
'/'+options.i1+
'/'+i1prefix
960 tfiles1_plotting = []
963 if not SINGLE_ITERATION:
964 if (DO_MAP
or DO_SEGDIFF
or DO_CURVATURE)
and not os.access(fname+
"_plotting.root",os.F_OK):
965 print(
"no file "+fname+
"_plotting.root")
967 if DO_FIT
and not os.access(fname+
".root",os.F_OK):
968 print(
"no file "+fname+
".root")
970 if DO_MEDIAN
and not os.access(fname+
"_report.py",os.F_OK):
971 print(
"no file "+fname+
"_report.py")
973 if DO_MAP
or DO_SEGDIFF
or DO_CURVATURE: tfiles1_plotting.append(ROOT.TFile(fname+
"_plotting.root"))
974 if os.access(fname+
".root",os.F_OK):
975 iter1_tfile = ROOT.TFile(fname+
".root")
976 if os.access(fname+
"_report.py",os.F_OK):
977 execfile(fname+
"_report.py")
978 iter1_reports = reports
980 fname = options.inputDir+
'/'+options.iN+
'/'+iNprefix
981 tfilesN_plotting = []
984 if (DO_MAP
or DO_SEGDIFF
or DO_CURVATURE)
and not os.access(fname+
"_plotting.root",os.F_OK):
985 print(
"no file "+fname+
"_plotting.root")
987 if DO_FIT
and not os.access(fname+
".root",os.F_OK):
988 print(
"no file "+fname+
".root")
990 if DO_MEDIAN
and not os.access(fname+
"_report.py",os.F_OK):
991 print(
"no file "+fname+
"_report.py")
993 if DO_MAP
or DO_SEGDIFF
or DO_CURVATURE: tfilesN_plotting.append(ROOT.TFile(fname+
"_plotting.root"))
994 if os.access(fname+
".root",os.F_OK):
995 iterN_tfile = ROOT.TFile(fname+
".root")
996 if os.access(fname+
"_report.py",os.F_OK):
997 execfile(fname+
"_report.py")
998 iterN_reports = reports
1001 os.chdir(options.inputDir)
1008 os.chdir(options.outputDir)
1011 iteration1 =
"iter1" 1012 iterationN =
"iterN" 1015 if options.createDirSructure:
1016 print(
"WARNING: all existing results in "+options.outputDir+
" will be deleted!")
1019 if not os.access(comdir,os.F_OK):
1025 c1 = ROOT.TCanvas(
"c1",
"c1",800,600)
1029 print(
"--- ITERATION 1 ---")
1030 if not SINGLE_ITERATION:
doIterationPlots(iteration1, tfiles1_plotting, iter1_tfile, iter1_reports)
1031 print(
"--- ITERATION N ---")
1034 if CPP_LOADED: ROOT.cleanUpHeap()
1040 plotmedians(iter1_reports, iterN_reports,binsx=100, windowx=10., binsy=100, windowy=10., binsdxdz=100, windowdxdz=10., binsdydz=100, windowdydz=10.)
1041 c1.SaveAs(comdir+
'medians.png')
1048 doTests(iterN_reports, pic_ids,
"mu_list.js",
"dqm_report.js",options.runLabel)
def segdiffvsphi_xalign(tfiles, wheel, window=10.)
def saveTestResultsMap(run_name)
def curvatureplot(tfiles, name, param, mode="from2d", window=15., widebins=False, title="", fitgauss=False, fitconst=False, fitline=False, fitpeaks=True, reset_palette=False)
"param" may be one of "deltax" (Delta x position residuals), "deltadxdz" (Delta (dx/dz) angular resid...
def doTests(reports, pic_ids, fname_base, fname_dqm, run_name)
S & print(S &os, JobReport::InputFile const &f)
def doFitFunctionsPlotsCSC(csc_basedir, iter_tfile, iter_reports)
def doMapPlotsCSC(csc_basedir, tfiles_plotting)
def segdiff_xalign(tfiles, component, args)
def createCanvasesList(fname="canvases_list.js")
def mapplot(tfiles, name, param, mode="from2d", window=10., abscissa=None, title="", widebins=False, fitsine=False, fitline=False, reset_palette=False, fitsawteeth=False, fitpeaks=False, peaksbins=1, fixfitpars={}, args)
def segdiffvsphicsc(tfiles, component, pair, window=5., args)
def doFitFunctionsPlotsDT(dt_basedir, iter_tfile, iter_reports)
def doMapPlotsDT(dt_basedir, tfiles_plotting)
def doCurvaturePlotsDT(dt_basedir, tfiles_plotting)
Abs< T >::type abs(const T &t)
def createDirectoryStructure(iteration_name)
def segdiffvsphi(tfiles, reports, component, wheel, window=5., excludesectors=())
def polynomials(tfile, reports, name, twobin=True, suppressblue=False)
def isFileUnderDir(dir_name, file_name)
functions definitions
def doSegDiffPlotsCSC(csc_basedir, tfiles_plotting, iter_reports)
def bellcurves(tfile, reports, name, twobin=True, suppressblue=False)
def createCanvasToIDList(fname="canvas2id_list.js")
def segdiff(tfiles, component, pair, args)
def doSegDiffPlotsDT(dt_basedir, tfiles_plotting, iter_reports)
def idsForFile(dir_name, file_name)
def doIterationPlots(iteration_directory, tfiles_plotting, iter_tfile, iter_reports)
def set_palette(name=None, ncontours=999)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
def plotmedians(reports1, reports2, selection=None, binsx=100, windowx=5., ceilingx=None, binsy=100, windowy=5., ceilingy=None, binsdxdz=100, windowdxdz=5., ceilingdxdz=None, binsdydz=100, windowdydz=5., ceilingdydz=None, r1text=" before", r2text=" after", which="median")