3 from __future__
import print_function
4 import re,os,sys,shutil
9 execfile(
"plotscripts.py")
11 ROOT.gROOT.SetBatch(1);
18 usage=
'%prog [options]\n'+\
19 'This script dumps muon alignment validation plots '+\
20 '(see https://twiki.cern.ch/twiki/bin/viewauth/CMS/SWGuideMuonAlignValidationPlots) '+\
21 'in web-friendly png format into a predefined directory structure '+\
22 'and also (to be implemented) does some quality checks for these plots.\n'+\
23 'Script uses output of the first and last iterations of muon alignment runs '+\
24 'that should be located in inputDir+i1 and inputDir+iN directories (see options descriptions). '+\
25 'Each of these directories should contain\ni#prefix+"_plotting.root"\ni#prefix+".root"\ni#prefix+"_report.py"\n'+\
26 'files, where # = 1 or N.\n'+\
27 'Output will be located in outputDir, which must exist. Plots from the first and last iterations '+\
28 'will be in outputDir+"iter1" and outputDir+"iterN" respectively, and plots relevant for all iterations will '+\
29 'reside in outputDir+"common/".\n'+\
30 'For a first run a --createDirSructure option must be present. If this option is present for subsequent runs '+\
31 'with the same outputDir, all previous results in "iter1", "iterN" and and "common" would be deleted!\n'+\
32 'If neither --dt or --csc is present, plots for both systems will be created.\n'+\
33 'Options must include either -a or any of the following: --map, --segdiff, --fit, --median' 35 parser=optparse.OptionParser(usage)
37 parser.add_option(
"-l",
"--runLabel",
38 help=
"[REQUIRED] label to use for a run",
43 parser.add_option(
"-i",
"--inputDir",
44 help=
"[REQUIRED] input directory: should contain directories with the first and the final iterations' results",
49 parser.add_option(
"--i1",
50 help=
"[REQUIRED] directory with the alignment 1st iteration's results relative to inputDir",
55 parser.add_option(
"--iN",
56 help=
"[REQUIRED] directory with the alignment last iteration's results relative to inputDir",
61 parser.add_option(
"--i1prefix",
62 help=
"filename prefix for the alignment 1st iteration's results. If not provided, i1prefix = i1",
67 parser.add_option(
"--iNprefix",
68 help=
"filename prefix for the alignment last iteration's results. If not provided, iNprefix = iN",
73 parser.add_option(
"-o",
"--outputDir",
74 help=
"output directory: all plots will be saved with relation to outputDir. If not provided, consider outputDir = inputDir",
79 parser.add_option(
"--createDirSructure",
80 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!",
83 dest=
"createDirSructure")
85 parser.add_option(
"--dt",
86 help=
"If it is present, but not --csc, DT only plots will be created",
91 parser.add_option(
"--csc",
92 help=
"If this is present, but not --dt, CSC only plots will be created",
97 parser.add_option(
"-a",
"--all",
98 help=
"If present, all types of plots will be created",
103 parser.add_option(
"--map",
104 help=
"If present, map plots will be created",
109 parser.add_option(
"--segdiff",
110 help=
"If present, segdiff plots will be created",
115 parser.add_option(
"--curvature",
116 help=
"If present, curvature plots will be created",
121 parser.add_option(
"--fit",
122 help=
"If present, fit functions plots will be created",
127 parser.add_option(
"--median",
128 help=
"If present, median plots will be created",
133 parser.add_option(
"--diagnostic",
134 help=
"If present, will run diagnostic checks",
139 parser.add_option(
"-v",
"--verbose",
140 help=
"Degree of debug info verbosity",
145 options,args=parser.parse_args()
147 if options.runLabel==
'' or options.inputDir==
'' or options.i1==
'' or options.iN==
'':
148 print(
"\nOne or more of REQUIRED options is missing!\n")
153 outdir = options.outputDir
154 if outdir==
'': outdir = options.inputDir
156 i1prefix = options.i1prefix
157 if i1prefix==
'' : i1prefix = options.i1
159 iNprefix = options.iNprefix
160 if iNprefix==
'' : iNprefix = options.iN
162 if not os.access(outdir,os.F_OK):
163 print(
"\noutDir = "+outdir+
"\ndoes not exist! Exiting...")
169 if options.dt
or not ( options.dt
or options.csc):
171 if options.csc
or not ( options.dt
or options.csc):
174 if not (options.all
or options.map
or options.curvature
or options.segdiff
or options.fit
or options.median
or options.diagnostic):
175 print(
"\nOptions must include either -a or any of the following: --map, --segdiff, --fit, --median, --diagnostic. Exiting...")
178 SINGLE_ITERATION =
False 179 if i1prefix == iNprefix: SINGLE_ITERATION =
True 186 if options.map
or options.all:
188 if options.segdiff
or options.all:
190 if options.curvature
or options.all:
192 if options.fit
or options.all:
194 if options.median
or options.all:
197 DO_DIAGNOSTIC = options.diagnostic
199 allOptions =
"-l "+options.runLabel+
" -i "+options.inputDir+
" --i1 "+options.i1+
" --iN "+options.iN
200 if options.i1prefix !=
'': allOptions +=
" --i1prefix " + options.i1prefix
201 if options.iNprefix !=
'': allOptions +=
" --iNprefix " + options.iNprefix
202 allOptions +=
" -o "+options.outputDir
203 if options.createDirSructure: allOptions +=
" --createDirSructure" 204 if DO_DT: allOptions +=
" --dt" 205 if DO_CSC: allOptions +=
" --csc" 206 if options.all: allOptions +=
" -a" 207 if options.map: allOptions +=
" --map" 208 if options.segdiff: allOptions +=
" --segdiff" 209 if options.curvature: allOptions +=
" --curvature" 210 if options.fit: allOptions +=
" --fit" 211 if options.median: allOptions +=
" --median" 212 if options.diagnostic: allOptions +=
" --diagnostic" 213 print(sys.argv[0]+
" "+allOptions)
223 CANVASES_LIST_TEMPLATE = [
225 [
'medians distribution',
'medians.png']
228 [
'Wheel&Station: map of dxdz residual vs phi',
'map_DTvsphi_dxdz.png'],
229 [
'Wheel&Station: map of dydz residual vs phi',
'map_DTvsphi_dydz.png'],
230 [
'Wheel&Station: map of x residual vs phi',
'map_DTvsphi_x.png'],
231 [
'Wheel&Station: map of y residual vs phi',
'map_DTvsphi_y.png'],
232 [
'Station&Sector: map of dxdz residual vs z',
'map_DTvsz_dxdz.png'],
233 [
'Station&Sector: map of dydz residual vs z',
'map_DTvsz_dydz.png'],
234 [
'Station&Sector: map of x residual vs z',
'map_DTvsz_x.png'],
235 [
'Station&Sector: map of y residual vs z',
'map_DTvsz_y.png'],
236 [
'Station: map of dxdz residual vs z',
'map_DTvsz_all_dxdz.png'],
237 [
'Station: map of dydz residual vs z',
'map_DTvsz_all_dydz.png'],
238 [
'Station: map of x residual vs z',
'map_DTvsz_all_x.png'],
239 [
'Station: map of y residual vs z',
'map_DTvsz_all_y.png'],
240 [
'Wheel: segdiff in x residuals vs phi',
'segdifphi_dt13_resid.png'],
241 [
'Wheel: segdiff in dxdz residuals vs phi',
'segdifphi_dt13_slope.png'],
242 [
'Wheel: segdiff in y residuals vs phi',
'segdifphi_dt2_resid.png'],
243 [
'Wheel: segdiff in dydz residuals vs phi',
'segdifphi_dt2_slope.png'],
244 [
'Wheel: segdiff DT-CSC in x residuals vs phi',
'segdifphi_x_dt_csc_resid.png'],
245 [
'Chamber: segdiff in x residuals',
'segdif_dt13_resid.png'],
246 [
'Chamber: segdiff in dxdz residuals',
'segdif_dt13_slope.png'],
247 [
'Chamber: segdiff in y residuals',
'segdif_dt2_resid.png'],
248 [
'Chamber: segdiff in dydz residuals',
'segdif_dt2_slope.png'],
249 [
'Chamber: segdiff DT-CSC in x residuals',
'segdif_x_dt_csc_resid.png'],
250 [
'Chamber: residuals distributions',
'dt_bellcurves.png'],
251 [
'Chamber: residuals relations to misalignments',
'dt_polynomials.png'],
252 [
'Chamber: Delta x residuals vs. curvature',
'dt_curvature_deltax.png'],
253 [
'Chamber: Delta dxdz residuals vs. curvature',
'dt_curvature_deltadxdz.png'],
254 [
'Extras: Extra plots in a separate window',
'dt_extras.php']
257 [
'Station&Ring: map of d(rphi)/dz residual vs phi',
'map_CSCvsphi_dxdz.png'],
258 [
'Station&Ring: map of rphi residual vs phi',
'map_CSCvsphi_x.png'],
259 [
'Station&Chamber: map of d(rphi)/dz residual vs r',
'map_CSCvsr_dxdz.png'],
260 [
'Station&Chamber: map of rphi residual vs r',
'map_CSCvsr_x.png'],
261 [
'Station: map of d(rphi)/dz residual vs r',
'map_CSCvsr_all_dxdz.png'],
262 [
'Station: map of rphi residual vs r',
'map_CSCvsr_all_x.png'],
263 [
'Station: segdiff in rphi residuals vs phi',
'segdifphi_csc_resid.png'],
264 [
'Station: segdiff in d(rphi)/dz residuals vs phi',
'segdifphi_csc_slope.png'],
265 [
'Chamber: segdiff in rphi residuals',
'segdif_csc_resid.png'],
266 [
'Chamber: segdiff in d(rphi)/dz residuals',
'segdif_csc_slope.png'],
267 [
'Chamber: residuals distributions',
'csc_bellcurves.png'],
268 [
'Chamber: residuals relations to misalignments',
'csc_polynomials.png'],
271 [
'Extras: Extra plots in a separate window',
'csc_extras.php']
281 '''Recursively looks for file named file_name under dir_name directory 283 if not DO_DT
and dir_name.find(
"MB")>-1:
285 if not DO_CSC
and dir_name.find(
"ME")>-1:
288 for f
in os.listdir(dir_name):
289 dirfile = os.path.join(dir_name, f)
290 if os.path.isfile(dirfile)
and f==file_name:
293 elif os.path.isdir(dirfile):
305 ddt[16] = 1./ddt[15]*((ddt[15]-1)*ddt[16] + tn-t1)
310 if not os.access(iteration_name,os.F_OK):
311 os.mkdir(iteration_name)
313 csc_basedir = iteration_name+
'/' 314 for endcap
in CSC_TYPES:
316 shutil.rmtree(csc_basedir+endcap[0],
True)
317 os.mkdir(csc_basedir+endcap[0])
318 for station
in endcap[2]:
320 os.mkdir(csc_basedir+endcap[0]+
'/'+station[1])
321 for ring
in station[2]:
323 os.mkdir(csc_basedir+endcap[0]+
'/'+station[1]+
'/'+ring[1])
324 for chamber
in range(1,ring[2]+1):
325 schamber =
"%02d" % chamber
327 os.mkdir(csc_basedir+endcap[0]+
'/'+station[1]+
'/'+ring[1]+
'/'+schamber)
329 dt_basedir = iteration_name+
'/MB/' 331 shutil.rmtree(dt_basedir,
True)
333 for wheel
in DT_TYPES:
335 os.mkdir(dt_basedir+wheel[0])
336 for station
in wheel[2]:
338 os.mkdir(dt_basedir+wheel[0]+
'/'+station[1])
339 for sector
in range(1,station[2]+1):
340 ssector =
"%02d" % sector
342 os.mkdir(dt_basedir+wheel[0]+
'/'+station[1]+
'/'+ssector)
349 """write DT map plots 351 "DTvsphi_st%dwh%s" % (station, wheelletter): 353 plots "integrated" over ALL SECTORS: 354 of x, y, dxdz, dydz vs. phi (y and dydz only for stations 1-3) 355 made for all (station,wheel) combinations 357 Access interface may be arranged into station(1 .. 4) vs. wheel(-2 .. +2) map. 358 It could be incorporated into a general DT chambers map (column1: wheel, column2: station, 359 columns3-16 correspond to sector #) by making station numbers in column 2 clickable. 362 "DTvsz_st%dsec%02d" % (station, sector) 364 plots "integrated" over ALL WHEELS: 365 of x, y, dxdz, dydz vs. z (y and dydz only for stations 1-3) 366 made for all (station,sector) combinations 368 Interface: may be arranged into station(1 .. 4) vs. sector(1 .. 14) map with sector range 369 (1 .. 12) for stations 1-3. 370 It could be incorporated into an EXTENDED general DT chambers map (extended by adding an 371 identifier "ALL" in column1 for wheel number). 374 "DTvsz_st%dsecALL" % (station) 376 plots spanning in z over ALL WHEELS and "integrated" over all sectors: 377 of x, y, dxdz, dydz vs. z (y and dydz only for stations 1-3) 378 made for all stations 380 Interface: may be arranged into station(1 .. 4) map 381 It could be incorporated into an EXTENDED general DT chambers map (extended by adding an 382 identifier "ALL" in column1 for wheel number).""" 385 for wheel
in DT_TYPES:
386 if wheel[1]==
"ALL":
continue 387 for station
in wheel[2]:
388 pdir = dt_basedir+
'/'+wheel[0]+
'/'+station[1]+
'/' 390 htitle =
"wheel %+d, station %s" % (
int(wheel[1]), station[1])
392 mapplot(tfiles_plotting, label,
"x", window=10., title=htitle, fitsine=
True,fitpeaks=
True,peaksbins=2)
393 c1.SaveAs(pdir+
'map_DTvsphi_x.png')
395 mapplot(tfiles_plotting, label,
"dxdz", window=10., title=htitle,peaksbins=2)
396 c1.SaveAs(pdir+
'map_DTvsphi_dxdz.png')
398 if station[1]==
'4':
continue 400 mapplot(tfiles_plotting, label,
"y", window=10., title=htitle,peaksbins=2)
401 c1.SaveAs(pdir+
'map_DTvsphi_y.png')
403 mapplot(tfiles_plotting, label,
"dydz", window=10., title=htitle,peaksbins=2)
404 c1.SaveAs(pdir+
'map_DTvsphi_dydz.png')
408 for wheel
in DT_TYPES:
409 if wheel[1]!=
"ALL":
continue 410 for station
in wheel[2]:
411 for sector
in range(1,station[2]+1):
412 if qcount>QUICKTESTN:
break 414 ssector =
"%02d" % sector
415 pdir = dt_basedir+
'/'+wheel[0]+
'/'+station[1]+
'/'+ssector+
'/' 416 label =
"DTvsz_st%ssec%s" % (station[1], ssector)
417 htitle =
"station %s, sector %d" % (station[1], sector)
418 mapplot(tfiles_plotting, label,
"x", window=10., title=htitle, peaksbins=2)
419 c1.SaveAs(pdir+
'map_DTvsz_x.png')
420 mapplot(tfiles_plotting, label,
"dxdz", window=10., title=htitle, peaksbins=2)
421 c1.SaveAs(pdir+
'map_DTvsz_dxdz.png')
423 if station[1]==
'4':
continue 424 mapplot(tfiles_plotting, label,
"y", window=10., title=htitle, peaksbins=2)
425 c1.SaveAs(pdir+
'map_DTvsz_y.png')
426 mapplot(tfiles_plotting, label,
"dydz", window=10., title=htitle, peaksbins=2)
427 c1.SaveAs(pdir+
'map_DTvsz_dydz.png')
430 for wheel
in DT_TYPES:
431 if wheel[1]!=
"ALL":
continue 432 for station
in wheel[2]:
433 if qcount>QUICKTESTN:
break 435 pdir = dt_basedir+
'/'+wheel[0]+
'/'+station[1]+
'/' 436 label =
"DTvsz_st%ssecALL" % (station[1])
437 htitle =
"station %s" % (station[1])
439 print(label, end=
' ')
440 mapplot(tfiles_plotting, label,
"x", window=10., title=htitle, peaksbins=2)
441 c1.SaveAs(pdir+
'map_DTvsz_all_x.png')
442 mapplot(tfiles_plotting, label,
"dxdz", window=10., title=htitle, peaksbins=2)
443 c1.SaveAs(pdir+
'map_DTvsz_all_dxdz.png')
445 if station[1]==
'4':
continue 446 mapplot(tfiles_plotting, label,
"y", window=10., title=htitle, peaksbins=2)
447 c1.SaveAs(pdir+
'map_DTvsz_all_y.png')
448 mapplot(tfiles_plotting, label,
"dydz", window=10., title=htitle, peaksbins=2)
449 c1.SaveAs(pdir+
'map_DTvsz_all_dydz.png')
455 """write CSC map plots 457 "CSCvsphi_me%s%d%d" % (endcap, station, ring) 459 plots "integrated" over ALL SECTORS: 460 of rphi, drphi/dz vs. phi 461 made for all (endcap,station,ring) combinations 463 Interface: may be arranged into two station(1 .. 4) vs. R(1 .. 4) maps for both endcaps 464 with R range (1 .. 4) for stations 2-4 465 It could be incorporated into a general CSC chambers map (column1: endcap, column2: station, 466 column3: ring, columns4-40 correspond to chamber #) by making ring numbers in column 3 470 "CSCvsr_me%s%dch%02d" % (endcap, station, chamberNumber) 472 plots "integrated" over ALL RINGS: 473 of rphi, drphi/dz vs. z 474 made for all (endcap,station,chamber) combinations 476 Interface: may be arranged into two station(1 .. 4) vs. chamber(1 .. 36) maps for both endcaps 477 It could be incorporated into an EXTENDED general CSC chambers map (extended by adding an 478 identifier "ALL" in column3 for ring number). 480 "CSCvsr_me%s%dchALL" % (endcap, station) 482 plots spanning over ALL RINGS along r and integrated over all SECTORS: 483 of rphi, drphi/dz vs. z 484 made for all (endcap,station) combinations 486 Interface: may be arranged into two station(1 .. 4) maps for both endcaps 487 It could be incorporated into an EXTENDED general CSC chambers map (extended by adding an 488 identifier "ALL" in column3 for ring number).""" 490 for endcap
in CSC_TYPES:
491 for station
in endcap[2]:
492 for ring
in station[2]:
493 if ring[1]==
"ALL":
continue 494 pdir = csc_basedir+
'/'+endcap[0]+
'/'+station[1]+
'/'+ring[1]+
'/' 495 label =
"CSCvsphi_me%s%s%s" % (endcap[1], station[1], ring[1])
496 htitle =
"%s%s/%s" % (endcap[0], station[1],ring[1])
497 mapplot(tfiles_plotting, label,
"x", window=15., title=htitle, fitsine=
True,fitpeaks=
True, peaksbins=2)
499 c1.SaveAs(pdir+
'map_CSCvsphi_x.png')
500 mapplot(tfiles_plotting, label,
"dxdz", window=15., title=htitle, peaksbins=2)
501 c1.SaveAs(pdir+
'map_CSCvsphi_dxdz.png')
506 for endcap
in CSC_TYPES:
507 for station
in endcap[2]:
508 for ring
in station[2]:
509 if ring[1]!=
"ALL":
continue 510 for chamber
in range(1,ring[2]+1):
511 if qcount>QUICKTESTN:
break 513 schamber =
"%02d" % chamber
514 pdir = csc_basedir+
'/'+endcap[0]+
'/'+station[1]+
'/'+ring[1]+
'/'+schamber+
'/' 515 label =
"CSCvsr_me%s%sch%s" % (endcap[1], station[1], schamber)
516 htitle =
"%s%s/ALL/%d" % (endcap[0], station[1],chamber)
517 mapplot(tfiles_plotting, label,
"x", window=15., title=htitle, peaksbins=2)
518 c1.SaveAs(pdir+
'map_CSCvsr_x.png')
519 mapplot(tfiles_plotting, label,
"dxdz", window=15., title=htitle, peaksbins=2)
520 c1.SaveAs(pdir+
'map_CSCvsr_dxdz.png')
523 for endcap
in CSC_TYPES:
524 for station
in endcap[2]:
525 for ring
in station[2]:
526 if ring[1]!=
"ALL":
continue 527 if qcount>QUICKTESTN:
break 529 schamber =
"%02d" % chamber
530 pdir = csc_basedir+
'/'+endcap[0]+
'/'+station[1]+
'/'+ring[1]+
'/' 531 label =
"CSCvsr_me%s%schALL" % (endcap[1], station[1])
532 htitle =
"%s%s" % (endcap[0], station[1])
533 mapplot(tfiles_plotting, label,
"x", window=10., title=htitle, peaksbins=2)
534 c1.SaveAs(pdir+
'map_CSCvsr_all_x.png')
535 mapplot(tfiles_plotting, label,
"dxdz", window=10., title=htitle, peaksbins=2)
536 c1.SaveAs(pdir+
'map_CSCvsr_all_dxdz.png')
541 """write DT curvature plots 543 "wheel%s_sector%s" % (wheel, sector) 545 wheel in "m2", "m1", "z", "p1", "p2" 547 sector in "01", ..., "12" 549 "param" may be one of 550 "deltax" (Delta x position residuals), 551 "deltadxdz" (Delta (dx/dz) angular residuals), 552 "curverr" (Delta x * d(Delta q/pT)/d(Delta x) = Delta q/pT in the absence of misalignment) - not necessary 554 made for all (wheel,station=1,sector) combinations 556 Interface: could be accesses through a general DT chambers map for station=1 chambers.""" 558 w_dict = {
'-2':
'm2',
'-1':
'm1',
'0':
'z',
'1':
'p1',
'2':
'p2'}
560 for wheel
in DT_TYPES:
561 if wheel[1]==
"ALL":
continue 564 for station
in wheel[2]:
565 print(
"curv in ", wheel[0]+
'/'+station[1])
566 for sector
in range(1,station[2]+1):
568 if qcount>QUICKTESTN:
break 570 ssector =
"%02d" % sector
571 pdir = dt_basedir+
'/'+wheel[0]+
'/'+station[1]+
'/'+ssector+
'/' 572 label =
"wheel%s_st%s_sector%s" % (w_dict[wheel[1]], station[1], ssector)
573 thetitle =
"Wheel %s, station %s, sector %s" % (wheel[1], station[1], ssector)
574 curvatureplot(tfiles_plotting, label,
"deltax", title=thetitle, window=10., fitline=
True)
575 saveAs(pdir+
'dt_curvature_deltax.png')
576 curvatureplot(tfiles_plotting, label,
"deltadxdz", title=thetitle, window=10., fitline=
True)
577 saveAs(pdir+
'dt_curvature_deltadxdz.png')
582 """write segment-difference plots for DT 584 segdiff "dt13_resid" and "dt13_slope" 587 x vs qpt, x for positive, x for negative ("dt13_resid") 588 dxdz vs qpt, dxdz for positive, dxdz for negative ("dt13_slope") 589 done for MB1-MB2, MB2-MB3, and MB3-MB4 stations combinations with all possible (wheel, sector) 591 Interface: could be accessed through a general DT chambers map, but only for chambers in 592 stations 2-4 (e.g., station 2 would provide MB1-MB2 plots). 594 segdiff "dt2_resid" and "dt2_slope" 597 y vs q/pt, y for positive, y for negative ("dt2_resid") 598 dydz vs q/pt, dydz for positive, dydz for negative ("dt2_slope") 599 done for MB1-MB2, MB2-MB3 stations combinations with all possible (wheel, sector) 601 Interface: then the interface would still be a general DT map, 602 but the info only available from station 2 & 3 chambers.""" 605 for iwheel
in DT_TYPES:
606 if iwheel[1]==
"ALL":
continue 607 for istation
in iwheel[2]:
608 if istation[1]==
"1":
continue 609 dstations = (
int(istation[1])-1)*10 +
int(istation[1])
611 for isector
in range(1, istation[2] + 1):
612 if isector > 12:
continue 613 if qcount>QUICKTESTN:
break 615 ssector =
"%02d" % isector
616 pdir = dt_basedir +
'/' + iwheel[0] +
'/' + istation[1] +
'/' + ssector +
'/' 618 segdiff(tfiles_plotting,
"dt13_resid", dstations, wheel=
int(iwheel[1]), sector=isector, window=15.)
619 c1.SaveAs(pdir +
'segdif_dt13_resid.png')
620 segdiff(tfiles_plotting,
"dt13_slope", dstations, wheel=
int(iwheel[1]), sector=isector, window=15.)
621 c1.SaveAs(pdir +
'segdif_dt13_slope.png')
623 if istation[1] !=
'4':
624 segdiff(tfiles_plotting,
"dt2_resid", dstations, wheel=
int(iwheel[1]), sector=isector, window=15.)
625 c1.SaveAs(pdir +
'segdif_dt2_resid.png')
626 segdiff(tfiles_plotting,
"dt2_slope", dstations, wheel=
int(iwheel[1]), sector=isector, window=15.)
627 c1.SaveAs(pdir +
'segdif_dt2_slope.png')
630 for iwheel
in DT_TYPES:
631 if iwheel[1]==
"ALL":
continue 632 if abs(
int(iwheel[1])) != 2:
continue 633 for istation
in iwheel[2]:
634 if istation[1]==
"3":
continue 636 for isector
in range(1, istation[2] + 1):
637 ssector =
"%02d" % isector
638 pdir = dt_basedir +
'/' + iwheel[0] +
'/' + istation[1] +
'/' + ssector +
'/' 640 segdiff_xalign(tfiles_plotting,
"x_dt1_csc", wheel=
int(iwheel[1]), sector=isector, cscstations =
"12")
641 c1.SaveAs(pdir +
'segdif_x_dt_csc_resid.png')
643 segdiff_xalign(tfiles_plotting,
"x_dt2_csc", wheel=
int(iwheel[1]), sector=isector, cscstations =
"1")
644 c1.SaveAs(pdir +
'segdif_x_dt_csc_resid.png')
646 """segdiffvsphi "dt13_resid" and "dt13_slope" 648 plot for a specific wheel #: 649 x vs phi of pair ("dt13_resid") 650 dxdz vs phi of pair ("dt13_slope") 651 contains all three combinations of neighboring stations 652 made for all possible wheel values 654 Interface: could be accessed by clicking on wheel number under the "wheel" column 657 segdiffvsphi "dt2_resid" and "dt2_slope" 659 plot for a specific wheel #: 660 y vs phi of pair ("dt2_resid") 661 dydz vs phi of pair ("dt2_slope") 662 contains both MB1-MB2 and MB2-MB3 combinations 663 made for all possible wheel values 665 Interface: could be accessed by clicking on wheel number under the "wheel" column 666 in a general DT map""" 668 if len(iter_reports)==0:
return 670 for iwheel
in DT_TYPES:
671 if iwheel[1]==
"ALL":
continue 672 pdir = dt_basedir +
'/' + iwheel[0] +
'/' 673 segdiffvsphi(tfiles_plotting, iter_reports,
"dt13_resid",
int(iwheel[1]), window=10.)
674 c1.SaveAs(pdir +
'segdifphi_dt13_resid.png')
675 segdiffvsphi(tfiles_plotting, iter_reports,
"dt13_slope",
int(iwheel[1]), window=10.)
676 c1.SaveAs(pdir +
'segdifphi_dt13_slope.png')
677 segdiffvsphi(tfiles_plotting, iter_reports,
"dt2_resid",
int(iwheel[1]), window=10.)
678 c1.SaveAs(pdir +
'segdifphi_dt2_resid.png')
679 segdiffvsphi(tfiles_plotting, iter_reports,
"dt2_slope",
int(iwheel[1]), window=15.)
680 c1.SaveAs(pdir +
'segdifphi_dt2_slope.png')
682 for iwheel
in DT_TYPES:
683 if iwheel[1]==
"ALL":
continue 684 if abs(
int(iwheel[1])) != 2:
continue 685 pdir = dt_basedir +
'/' + iwheel[0] +
'/' 687 c1.SaveAs(pdir +
'segdifphi_x_dt_csc_resid.png')
691 """write segment-difference plots for CSC 693 segdiff "csc_resid" and "csc_slope" 696 rphi vs qpt, rphi for positive, rphi for negative ("csc_resid") 697 drphidz vs qpt, drphidz for positive, drphidz for negative ("csc_slope") 698 done for ME1-ME2, ME2-ME3, and ME3-ME4 stations combinations with 701 chamber 1-18 (r1) or 1-36 (r2) 702 note: there's no ME3-ME4 plots for R2 704 Interface: could be accessed through a general CSC chambers map, but only for chambers in 705 stations 2-4 (e.g., station 2 would provide ME1-ME2 plots).""" 708 for iendcap
in CSC_TYPES:
709 for istation
in iendcap[2]:
710 if istation[1]==
"1":
continue 711 dstations = (
int(istation[1])-1)*10 +
int(istation[1])
712 for iring
in istation[2]:
713 if iring[1]==
"ALL":
continue 714 if istation[1]==
"4" and iring[1]==
"2":
continue 715 for ichamber
in range(1,iring[2]+1):
716 if qcount>QUICKTESTN:
break 718 schamber =
"%02d" % ichamber
719 pdir = csc_basedir+
'/'+iendcap[0]+
'/'+istation[1]+
'/'+iring[1]+
'/'+schamber+
'/' 720 segdiff(tfiles_plotting,
"csc_resid", dstations,
721 endcap=iendcap[1], ring=
int(iring[1]), chamber=ichamber, window=15.)
722 c1.SaveAs(pdir +
'segdif_csc_resid.png')
723 segdiff(tfiles_plotting,
"csc_slope", dstations,
724 endcap=iendcap[1], ring=
int(iring[1]), chamber=ichamber, window=15.)
725 c1.SaveAs(pdir +
'segdif_csc_slope.png')
727 """segdiffvsphicsc "csc_resid" and "csc_slope" 729 plot for a specific deltaME station differences: 730 rphi vs phi of pair ("csc_resid") 731 dxdz vs phi of pair ("csc_slope") 732 contains plots for two (or one for ME4-ME3) rings 733 done for ME1-ME2, ME2-ME3, and ME3-ME4 stations combinations with 736 Interface: could be accessed by clicking on ME station boxes, but only for stations 2-4 737 (e.g., station 2 would provide ME1-ME2 plots).""" 740 for iendcap
in CSC_TYPES:
741 for istation
in iendcap[2]:
742 if istation[1]==
"1":
continue 743 dstations = (
int(istation[1])-1)*10 +
int(istation[1])
744 if qcount>QUICKTESTN:
break 746 pdir = csc_basedir+
'/'+iendcap[0]+
'/'+istation[1]+
'/' 747 segdiffvsphicsc(tfiles_plotting,
"csc_resid", dstations, window=10., endcap=iendcap[1])
748 c1.SaveAs(pdir +
'segdifphi_csc_resid.png')
749 segdiffvsphicsc(tfiles_plotting,
"csc_slope", dstations, window=10., endcap=iendcap[1])
750 c1.SaveAs(pdir +
'segdifphi_csc_slope.png')
754 """write fit functions plots for DT 756 DT bellcurves and polynomials 758 set of plots of bellcurves 759 x, dxdz, x vs. dxdz (for all 4 stations) 760 y, dydz, x vs. dxdz (only for stations 1-3?) 762 set of plots of polynomials -- for stations 1-3 only?? 763 x vs. xpos, x vs ypos, x vs dxdz angle, x vs dydz angle 764 y vs. xpos, y vs ypos, y vs dxdz angle, y vs dydz angle 765 dxdz vs. xpos, dxdz vs ypos, dxdz vs dxdz angle, dxdz vs dydz angle 766 dydz vs. xpos, dydz vs ypos, dydz vs dxdz angle, dydz vs dydz angle 768 set of plots of polynomials -- for station 4 only?? 769 x vs. xpos, x vs dxdz angle 770 dxdz vs. xpos, dxdz vs dxdz angle 772 made for all (wheel,station,sector) combinations 774 Interface: could be accesses through a general DT chambers map.""" 778 for wheel
in DT_TYPES:
779 if wheel[1]==
"ALL":
continue 780 for station
in wheel[2]:
781 print(wheel[0]+
'/'+station[1])
782 for sector
in range(1,station[2]+1):
783 if qcount>QUICKTESTN:
break 785 ssector =
"%02d" % sector
786 pdir = dt_basedir+
'/'+wheel[0]+
'/'+station[1]+
'/'+ssector+
'/' 787 label =
"MBwh%sst%ssec%s" % (
wheelLetter(
int(wheel[1])),station[1],ssector)
788 bellcurves(iter_tfile, iter_reports, label,
False)
790 saveAs(pdir+
'dt_bellcurves.png')
791 polynomials(iter_tfile, iter_reports, label,
False)
793 saveAs(pdir+
'dt_polynomials.png')
798 """write fit functions plots for CSC 800 CSC bellcurves and polynomials 802 set of plots of bellcurves 803 rphi, drphidz, rphi vs. drphidz 805 set of plots of polynomials 806 rphi vs. rphi pos, rphi vs drphidz angle 807 drphidz vs. rphi pos, drphidz vs drphidz angle 809 made for all (endcap,station,ring,chamber) combinations 811 Interface: could be accesses through a general CSC chambers map.""" 815 for endcap
in CSC_TYPES:
816 for station
in endcap[2]:
817 for ring
in station[2]:
818 if ring[1]==
"ALL":
continue 819 print(endcap[0]+
'/'+station[1]+
'/'+ring[1])
820 for chamber
in range(1,ring[2]+1):
821 if qcount>QUICKTESTN:
break 823 schamber =
"%02d" % chamber
824 pdir = csc_basedir+
'/'+endcap[0]+
'/'+station[1]+
'/'+ring[1]+
'/'+schamber+
'/' 825 label =
"ME%s%s%s_%s" % (endcap[1], station[1], ring[1], schamber)
826 bellcurves(iter_tfile, iter_reports, label,
False)
828 saveAs(pdir+
'csc_bellcurves.png')
829 polynomials(iter_tfile, iter_reports, label,
False)
831 saveAs(pdir+
'csc_polynomials.png')
837 dt_basedir = iteration_directory+
'/'+
'MB' 838 csc_basedir = iteration_directory+
'/' 842 if DO_CSC
and DO_MAP:
845 if DO_DT
and DO_CURVATURE:
850 if DO_DT
and DO_SEGDIFF:
852 if DO_CSC
and DO_SEGDIFF:
857 if DO_CSC
and DO_FIT:
862 '''Use CANVASES_LIST_TEMPLATE as a template to create a canvases list include for the browser. 863 Write out only those canvases which have existing filename.png plots. 866 for scope
in CANVASES_LIST_TEMPLATE:
869 scope_entry = [scope[0],scope[1]]
870 for canvas_entry
in scope[2:]:
872 scope_entry.append(canvas_entry)
873 CANVASES_LIST.append(scope_entry)
875 ff = open(fname,mode=
"w")
876 print(
"var CANVASES_LIST = ", file=ff)
877 json.dump(CANVASES_LIST,ff)
882 '''Writes out a canvas-2-ids list include for the browser. 883 Write out only those canvases which have existing filename.png plots. 884 Returns: list of unique IDs that have existing filename.png plots. 888 for scope
in CANVASES_LIST_TEMPLATE:
890 for canvas_entry
in scope[2:]:
897 print(canvas_entry,
":", len(uids),
"ids")
899 CANVAS2ID_LIST.append( (canvas_entry[1],uids) )
901 CANVAS2ID_LIST_DICT =
dict(CANVAS2ID_LIST)
903 ff = open(fname,mode=
"w")
904 print(
"var CANVAS2ID_LIST = ", file=ff)
905 json.dump(CANVAS2ID_LIST_DICT,ff)
907 set_ids = set(ID_LIST)
911 '''Recursively looks for file named file_name under dir_name directory 912 and fill the list with dir names converted to IDs 915 for f
in os.listdir(dir_name):
916 dirfile = os.path.join(dir_name, f)
917 if os.path.isfile(dirfile)
and f==file_name:
918 if file_name[-4:]==
'.php': id_list.append(dir_name+
'/'+file_name)
919 else: id_list.append(
dirToID(dir_name))
921 elif os.path.isdir(dirfile):
930 if d[-1]!=
'/': d +=
'/' 934 cscn = d.find(
"/ME-/")
936 return 'ME-'+d[cscn+5:-1]
937 cscn = d.find(
"/ME+/")
939 return 'ME+'+d[cscn+5:-1]
958 fname = options.inputDir+
'/'+options.i1+
'/'+i1prefix
959 tfiles1_plotting = []
962 if not SINGLE_ITERATION:
963 if (DO_MAP
or DO_SEGDIFF
or DO_CURVATURE)
and not os.access(fname+
"_plotting.root",os.F_OK):
964 print(
"no file "+fname+
"_plotting.root")
966 if DO_FIT
and not os.access(fname+
".root",os.F_OK):
967 print(
"no file "+fname+
".root")
969 if DO_MEDIAN
and not os.access(fname+
"_report.py",os.F_OK):
970 print(
"no file "+fname+
"_report.py")
972 if DO_MAP
or DO_SEGDIFF
or DO_CURVATURE: tfiles1_plotting.append(ROOT.TFile(fname+
"_plotting.root"))
973 if os.access(fname+
".root",os.F_OK):
974 iter1_tfile = ROOT.TFile(fname+
".root")
975 if os.access(fname+
"_report.py",os.F_OK):
976 execfile(fname+
"_report.py")
977 iter1_reports = reports
979 fname = options.inputDir+
'/'+options.iN+
'/'+iNprefix
980 tfilesN_plotting = []
983 if (DO_MAP
or DO_SEGDIFF
or DO_CURVATURE)
and not os.access(fname+
"_plotting.root",os.F_OK):
984 print(
"no file "+fname+
"_plotting.root")
986 if DO_FIT
and not os.access(fname+
".root",os.F_OK):
987 print(
"no file "+fname+
".root")
989 if DO_MEDIAN
and not os.access(fname+
"_report.py",os.F_OK):
990 print(
"no file "+fname+
"_report.py")
992 if DO_MAP
or DO_SEGDIFF
or DO_CURVATURE: tfilesN_plotting.append(ROOT.TFile(fname+
"_plotting.root"))
993 if os.access(fname+
".root",os.F_OK):
994 iterN_tfile = ROOT.TFile(fname+
".root")
995 if os.access(fname+
"_report.py",os.F_OK):
996 execfile(fname+
"_report.py")
997 iterN_reports = reports
1000 os.chdir(options.inputDir)
1007 os.chdir(options.outputDir)
1010 iteration1 =
"iter1" 1011 iterationN =
"iterN" 1014 if options.createDirSructure:
1015 print(
"WARNING: all existing results in "+options.outputDir+
" will be deleted!")
1018 if not os.access(comdir,os.F_OK):
1024 c1 = ROOT.TCanvas(
"c1",
"c1",800,600)
1028 print(
"--- ITERATION 1 ---")
1029 if not SINGLE_ITERATION:
doIterationPlots(iteration1, tfiles1_plotting, iter1_tfile, iter1_reports)
1030 print(
"--- ITERATION N ---")
1033 if CPP_LOADED: ROOT.cleanUpHeap()
1039 plotmedians(iter1_reports, iterN_reports,binsx=100, windowx=10., binsy=100, windowy=10., binsdxdz=100, windowdxdz=10., binsdydz=100, windowdydz=10.)
1040 c1.SaveAs(comdir+
'medians.png')
1047 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")