3 import re,os,sys,shutil
8 execfile(
"plotscripts.py")
10 ROOT.gROOT.SetBatch(1);
17 usage=
'%prog [options]\n'+\
18 'This script dumps muon alignment validation plots '+\
19 '(see https://twiki.cern.ch/twiki/bin/viewauth/CMS/SWGuideMuonAlignValidationPlots) '+\
20 'in web-friendly png format into a predefined directory structure '+\
21 'and also (to be implemented) does some quality checks for these plots.\n'+\
22 'Script uses output of the first and last iterations of muon alignment runs '+\
23 'that should be located in inputDir+i1 and inputDir+iN directories (see options descriptions). '+\
24 'Each of these directories should contain\ni#prefix+"_plotting.root"\ni#prefix+".root"\ni#prefix+"_report.py"\n'+\
25 'files, where # = 1 or N.\n'+\
26 'Output will be located in outputDir, which must exist. Plots from the first and last iterations '+\
27 'will be in outputDir+"iter1" and outputDir+"iterN" respectively, and plots relevant for all iterations will '+\
28 'reside in outputDir+"common/".\n'+\
29 'For a first run a --createDirSructure option must be present. If this option is present for subsequent runs '+\
30 'with the same outputDir, all previous results in "iter1", "iterN" and and "common" would be deleted!\n'+\
31 'If neither --dt or --csc is present, plots for both systems will be created.\n'+\
32 'Options must include either -a or any of the following: --map, --segdiff, --fit, --median'
34 parser=optparse.OptionParser(usage)
36 parser.add_option(
"-l",
"--runLabel",
37 help=
"[REQUIRED] label to use for a run",
42 parser.add_option(
"-i",
"--inputDir",
43 help=
"[REQUIRED] input directory: should contain directories with the first and the final iterations' results",
48 parser.add_option(
"--i1",
49 help=
"[REQUIRED] directory with the alignment 1st iteration's results relative to inputDir",
54 parser.add_option(
"--iN",
55 help=
"[REQUIRED] directory with the alignment last iteration's results relative to inputDir",
60 parser.add_option(
"--i1prefix",
61 help=
"filename prefix for the alignment 1st iteration's results. If not provided, i1prefix = i1",
66 parser.add_option(
"--iNprefix",
67 help=
"filename prefix for the alignment last iteration's results. If not provided, iNprefix = iN",
72 parser.add_option(
"-o",
"--outputDir",
73 help=
"output directory: all plots will be saved with relation to outputDir. If not provided, consider outputDir = inputDir",
78 parser.add_option(
"--createDirSructure",
79 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!",
82 dest=
"createDirSructure")
84 parser.add_option(
"--dt",
85 help=
"If it is present, but not --csc, DT only plots will be created",
90 parser.add_option(
"--csc",
91 help=
"If this is present, but not --dt, CSC only plots will be created",
96 parser.add_option(
"-a",
"--all",
97 help=
"If present, all types of plots will be created",
102 parser.add_option(
"--map",
103 help=
"If present, map plots will be created",
108 parser.add_option(
"--segdiff",
109 help=
"If present, segdiff plots will be created",
114 parser.add_option(
"--curvature",
115 help=
"If present, curvature plots will be created",
120 parser.add_option(
"--fit",
121 help=
"If present, fit functions plots will be created",
126 parser.add_option(
"--median",
127 help=
"If present, median plots will be created",
132 parser.add_option(
"--diagnostic",
133 help=
"If present, will run diagnostic checks",
138 parser.add_option(
"-v",
"--verbose",
139 help=
"Degree of debug info verbosity",
144 options,args=parser.parse_args()
146 if options.runLabel==
'' or options.inputDir==
'' or options.i1==
'' or options.iN==
'':
147 print "\nOne or more of REQUIRED options is missing!\n"
152 outdir = options.outputDir
153 if outdir==
'': outdir = options.inputDir
155 i1prefix = options.i1prefix
156 if i1prefix==
'' : i1prefix = options.i1
158 iNprefix = options.iNprefix
159 if iNprefix==
'' : iNprefix = options.iN
161 if not os.access(outdir,os.F_OK):
162 print "\noutDir = "+outdir+
"\ndoes not exist! Exiting..."
168 if options.dt
or not ( options.dt
or options.csc):
170 if options.csc
or not ( options.dt
or options.csc):
173 if not (options.all
or options.map
or options.curvature
or options.segdiff
or options.fit
or options.median
or options.diagnostic):
174 print "\nOptions must include either -a or any of the following: --map, --segdiff, --fit, --median, --diagnostic. Exiting..."
177 SINGLE_ITERATION =
False
178 if i1prefix == iNprefix: SINGLE_ITERATION =
True
185 if options.map
or options.all:
187 if options.segdiff
or options.all:
189 if options.curvature
or options.all:
191 if options.fit
or options.all:
193 if options.median
or options.all:
196 DO_DIAGNOSTIC = options.diagnostic
198 allOptions =
"-l "+options.runLabel+
" -i "+options.inputDir+
" --i1 "+options.i1+
" --iN "+options.iN
199 if options.i1prefix !=
'': allOptions +=
" --i1prefix " + options.i1prefix
200 if options.iNprefix !=
'': allOptions +=
" --iNprefix " + options.iNprefix
201 allOptions +=
" -o "+options.outputDir
202 if options.createDirSructure: allOptions +=
" --createDirSructure"
203 if DO_DT: allOptions +=
" --dt"
204 if DO_CSC: allOptions +=
" --csc"
205 if options.all: allOptions +=
" -a"
206 if options.map: allOptions +=
" --map"
207 if options.segdiff: allOptions +=
" --segdiff"
208 if options.curvature: allOptions +=
" --curvature"
209 if options.fit: allOptions +=
" --fit"
210 if options.median: allOptions +=
" --median"
211 if options.diagnostic: allOptions +=
" --diagnostic"
212 print sys.argv[0]+
" "+allOptions
222 CANVASES_LIST_TEMPLATE = [
224 [
'medians distribution',
'medians.png']
227 [
'Wheel&Station: map of dxdz residual vs phi',
'map_DTvsphi_dxdz.png'],
228 [
'Wheel&Station: map of dydz residual vs phi',
'map_DTvsphi_dydz.png'],
229 [
'Wheel&Station: map of x residual vs phi',
'map_DTvsphi_x.png'],
230 [
'Wheel&Station: map of y residual vs phi',
'map_DTvsphi_y.png'],
231 [
'Station&Sector: map of dxdz residual vs z',
'map_DTvsz_dxdz.png'],
232 [
'Station&Sector: map of dydz residual vs z',
'map_DTvsz_dydz.png'],
233 [
'Station&Sector: map of x residual vs z',
'map_DTvsz_x.png'],
234 [
'Station&Sector: map of y residual vs z',
'map_DTvsz_y.png'],
235 [
'Station: map of dxdz residual vs z',
'map_DTvsz_all_dxdz.png'],
236 [
'Station: map of dydz residual vs z',
'map_DTvsz_all_dydz.png'],
237 [
'Station: map of x residual vs z',
'map_DTvsz_all_x.png'],
238 [
'Station: map of y residual vs z',
'map_DTvsz_all_y.png'],
239 [
'Wheel: segdiff in x residuals vs phi',
'segdifphi_dt13_resid.png'],
240 [
'Wheel: segdiff in dxdz residuals vs phi',
'segdifphi_dt13_slope.png'],
241 [
'Wheel: segdiff in y residuals vs phi',
'segdifphi_dt2_resid.png'],
242 [
'Wheel: segdiff in dydz residuals vs phi',
'segdifphi_dt2_slope.png'],
243 [
'Wheel: segdiff DT-CSC in x residuals vs phi',
'segdifphi_x_dt_csc_resid.png'],
244 [
'Chamber: segdiff in x residuals',
'segdif_dt13_resid.png'],
245 [
'Chamber: segdiff in dxdz residuals',
'segdif_dt13_slope.png'],
246 [
'Chamber: segdiff in y residuals',
'segdif_dt2_resid.png'],
247 [
'Chamber: segdiff in dydz residuals',
'segdif_dt2_slope.png'],
248 [
'Chamber: segdiff DT-CSC in x residuals',
'segdif_x_dt_csc_resid.png'],
249 [
'Chamber: residuals distributions',
'dt_bellcurves.png'],
250 [
'Chamber: residuals relations to misalignments',
'dt_polynomials.png'],
251 [
'Chamber: Delta x residuals vs. curvature',
'dt_curvature_deltax.png'],
252 [
'Chamber: Delta dxdz residuals vs. curvature',
'dt_curvature_deltadxdz.png'],
253 [
'Extras: Extra plots in a separate window',
'dt_extras.php']
256 [
'Station&Ring: map of d(rphi)/dz residual vs phi',
'map_CSCvsphi_dxdz.png'],
257 [
'Station&Ring: map of rphi residual vs phi',
'map_CSCvsphi_x.png'],
258 [
'Station&Chamber: map of d(rphi)/dz residual vs r',
'map_CSCvsr_dxdz.png'],
259 [
'Station&Chamber: map of rphi residual vs r',
'map_CSCvsr_x.png'],
260 [
'Station: map of d(rphi)/dz residual vs r',
'map_CSCvsr_all_dxdz.png'],
261 [
'Station: map of rphi residual vs r',
'map_CSCvsr_all_x.png'],
262 [
'Station: segdiff in rphi residuals vs phi',
'segdifphi_csc_resid.png'],
263 [
'Station: segdiff in d(rphi)/dz residuals vs phi',
'segdifphi_csc_slope.png'],
264 [
'Chamber: segdiff in rphi residuals',
'segdif_csc_resid.png'],
265 [
'Chamber: segdiff in d(rphi)/dz residuals',
'segdif_csc_slope.png'],
266 [
'Chamber: residuals distributions',
'csc_bellcurves.png'],
267 [
'Chamber: residuals relations to misalignments',
'csc_polynomials.png'],
270 [
'Extras: Extra plots in a separate window',
'csc_extras.php']
280 '''Recursively looks for file named file_name under dir_name directory
282 if not DO_DT
and dir_name.find(
"MB")>-1:
284 if not DO_CSC
and dir_name.find(
"ME")>-1:
287 for f
in os.listdir(dir_name):
288 dirfile = os.path.join(dir_name, f)
289 if os.path.isfile(dirfile)
and f==file_name:
292 elif os.path.isdir(dirfile):
304 ddt[16] = 1./ddt[15]*((ddt[15]-1)*ddt[16] + tn-t1)
309 if not os.access(iteration_name,os.F_OK):
310 os.mkdir(iteration_name)
312 csc_basedir = iteration_name+
'/'
313 for endcap
in CSC_TYPES:
315 shutil.rmtree(csc_basedir+endcap[0],
True)
316 os.mkdir(csc_basedir+endcap[0])
317 for station
in endcap[2]:
319 os.mkdir(csc_basedir+endcap[0]+
'/'+station[1])
320 for ring
in station[2]:
322 os.mkdir(csc_basedir+endcap[0]+
'/'+station[1]+
'/'+ring[1])
323 for chamber
in range(1,ring[2]+1):
324 schamber =
"%02d" % chamber
326 os.mkdir(csc_basedir+endcap[0]+
'/'+station[1]+
'/'+ring[1]+
'/'+schamber)
328 dt_basedir = iteration_name+
'/MB/'
330 shutil.rmtree(dt_basedir,
True)
332 for wheel
in DT_TYPES:
334 os.mkdir(dt_basedir+wheel[0])
335 for station
in wheel[2]:
337 os.mkdir(dt_basedir+wheel[0]+
'/'+station[1])
338 for sector
in range(1,station[2]+1):
339 ssector =
"%02d" % sector
341 os.mkdir(dt_basedir+wheel[0]+
'/'+station[1]+
'/'+ssector)
348 """write DT map plots
350 "DTvsphi_st%dwh%s" % (station, wheelletter):
352 plots "integrated" over ALL SECTORS:
353 of x, y, dxdz, dydz vs. phi (y and dydz only for stations 1-3)
354 made for all (station,wheel) combinations
356 Access interface may be arranged into station(1 .. 4) vs. wheel(-2 .. +2) map.
357 It could be incorporated into a general DT chambers map (column1: wheel, column2: station,
358 columns3-16 correspond to sector #) by making station numbers in column 2 clickable.
361 "DTvsz_st%dsec%02d" % (station, sector)
363 plots "integrated" over ALL WHEELS:
364 of x, y, dxdz, dydz vs. z (y and dydz only for stations 1-3)
365 made for all (station,sector) combinations
367 Interface: may be arranged into station(1 .. 4) vs. sector(1 .. 14) map with sector range
368 (1 .. 12) for stations 1-3.
369 It could be incorporated into an EXTENDED general DT chambers map (extended by adding an
370 identifier "ALL" in column1 for wheel number).
373 "DTvsz_st%dsecALL" % (station)
375 plots spanning in z over ALL WHEELS and "integrated" over all sectors:
376 of x, y, dxdz, dydz vs. z (y and dydz only for stations 1-3)
377 made for all stations
379 Interface: may be arranged into station(1 .. 4) map
380 It could be incorporated into an EXTENDED general DT chambers map (extended by adding an
381 identifier "ALL" in column1 for wheel number)."""
384 for wheel
in DT_TYPES:
385 if wheel[1]==
"ALL":
continue
386 for station
in wheel[2]:
387 pdir = dt_basedir+
'/'+wheel[0]+
'/'+station[1]+
'/'
388 label =
"DTvsphi_st%dwh%s" % (int(station[1]),
wheelLetter(int(wheel[1])))
389 htitle =
"wheel %+d, station %s" % (int(wheel[1]), station[1])
391 mapplot(tfiles_plotting, label,
"x", window=10., title=htitle, fitsine=
True,fitpeaks=
True,peaksbins=2)
392 c1.SaveAs(pdir+
'map_DTvsphi_x.png')
394 mapplot(tfiles_plotting, label,
"dxdz", window=10., title=htitle,peaksbins=2)
395 c1.SaveAs(pdir+
'map_DTvsphi_dxdz.png')
397 if station[1]==
'4':
continue
399 mapplot(tfiles_plotting, label,
"y", window=10., title=htitle,peaksbins=2)
400 c1.SaveAs(pdir+
'map_DTvsphi_y.png')
402 mapplot(tfiles_plotting, label,
"dydz", window=10., title=htitle,peaksbins=2)
403 c1.SaveAs(pdir+
'map_DTvsphi_dydz.png')
407 for wheel
in DT_TYPES:
408 if wheel[1]!=
"ALL":
continue
409 for station
in wheel[2]:
410 for sector
in range(1,station[2]+1):
411 if qcount>QUICKTESTN:
break
413 ssector =
"%02d" % sector
414 pdir = dt_basedir+
'/'+wheel[0]+
'/'+station[1]+
'/'+ssector+
'/'
415 label =
"DTvsz_st%ssec%s" % (station[1], ssector)
416 htitle =
"station %s, sector %d" % (station[1], sector)
417 mapplot(tfiles_plotting, label,
"x", window=10., title=htitle, peaksbins=2)
418 c1.SaveAs(pdir+
'map_DTvsz_x.png')
419 mapplot(tfiles_plotting, label,
"dxdz", window=10., title=htitle, peaksbins=2)
420 c1.SaveAs(pdir+
'map_DTvsz_dxdz.png')
422 if station[1]==
'4':
continue
423 mapplot(tfiles_plotting, label,
"y", window=10., title=htitle, peaksbins=2)
424 c1.SaveAs(pdir+
'map_DTvsz_y.png')
425 mapplot(tfiles_plotting, label,
"dydz", window=10., title=htitle, peaksbins=2)
426 c1.SaveAs(pdir+
'map_DTvsz_dydz.png')
429 for wheel
in DT_TYPES:
430 if wheel[1]!=
"ALL":
continue
431 for station
in wheel[2]:
432 if qcount>QUICKTESTN:
break
434 pdir = dt_basedir+
'/'+wheel[0]+
'/'+station[1]+
'/'
435 label =
"DTvsz_st%ssecALL" % (station[1])
436 htitle =
"station %s" % (station[1])
439 mapplot(tfiles_plotting, label,
"x", window=10., title=htitle, peaksbins=2)
440 c1.SaveAs(pdir+
'map_DTvsz_all_x.png')
441 mapplot(tfiles_plotting, label,
"dxdz", window=10., title=htitle, peaksbins=2)
442 c1.SaveAs(pdir+
'map_DTvsz_all_dxdz.png')
444 if station[1]==
'4':
continue
445 mapplot(tfiles_plotting, label,
"y", window=10., title=htitle, peaksbins=2)
446 c1.SaveAs(pdir+
'map_DTvsz_all_y.png')
447 mapplot(tfiles_plotting, label,
"dydz", window=10., title=htitle, peaksbins=2)
448 c1.SaveAs(pdir+
'map_DTvsz_all_dydz.png')
454 """write CSC map plots
456 "CSCvsphi_me%s%d%d" % (endcap, station, ring)
458 plots "integrated" over ALL SECTORS:
459 of rphi, drphi/dz vs. phi
460 made for all (endcap,station,ring) combinations
462 Interface: may be arranged into two station(1 .. 4) vs. R(1 .. 4) maps for both endcaps
463 with R range (1 .. 4) for stations 2-4
464 It could be incorporated into a general CSC chambers map (column1: endcap, column2: station,
465 column3: ring, columns4-40 correspond to chamber #) by making ring numbers in column 3
469 "CSCvsr_me%s%dch%02d" % (endcap, station, chamberNumber)
471 plots "integrated" over ALL RINGS:
472 of rphi, drphi/dz vs. z
473 made for all (endcap,station,chamber) combinations
475 Interface: may be arranged into two station(1 .. 4) vs. chamber(1 .. 36) maps for both endcaps
476 It could be incorporated into an EXTENDED general CSC chambers map (extended by adding an
477 identifier "ALL" in column3 for ring number).
479 "CSCvsr_me%s%dchALL" % (endcap, station)
481 plots spanning over ALL RINGS along r and integrated over all SECTORS:
482 of rphi, drphi/dz vs. z
483 made for all (endcap,station) combinations
485 Interface: may be arranged into two station(1 .. 4) maps for both endcaps
486 It could be incorporated into an EXTENDED general CSC chambers map (extended by adding an
487 identifier "ALL" in column3 for ring number)."""
489 for endcap
in CSC_TYPES:
490 for station
in endcap[2]:
491 for ring
in station[2]:
492 if ring[1]==
"ALL":
continue
493 pdir = csc_basedir+
'/'+endcap[0]+
'/'+station[1]+
'/'+ring[1]+
'/'
494 label =
"CSCvsphi_me%s%s%s" % (endcap[1], station[1], ring[1])
495 htitle =
"%s%s/%s" % (endcap[0], station[1],ring[1])
496 mapplot(tfiles_plotting, label,
"x", window=15., title=htitle, fitsine=
True,fitpeaks=
True, peaksbins=2)
498 c1.SaveAs(pdir+
'map_CSCvsphi_x.png')
499 mapplot(tfiles_plotting, label,
"dxdz", window=15., title=htitle, peaksbins=2)
500 c1.SaveAs(pdir+
'map_CSCvsphi_dxdz.png')
505 for endcap
in CSC_TYPES:
506 for station
in endcap[2]:
507 for ring
in station[2]:
508 if ring[1]!=
"ALL":
continue
509 for chamber
in range(1,ring[2]+1):
510 if qcount>QUICKTESTN:
break
512 schamber =
"%02d" % chamber
513 pdir = csc_basedir+
'/'+endcap[0]+
'/'+station[1]+
'/'+ring[1]+
'/'+schamber+
'/'
514 label =
"CSCvsr_me%s%sch%s" % (endcap[1], station[1], schamber)
515 htitle =
"%s%s/ALL/%d" % (endcap[0], station[1],chamber)
516 mapplot(tfiles_plotting, label,
"x", window=15., title=htitle, peaksbins=2)
517 c1.SaveAs(pdir+
'map_CSCvsr_x.png')
518 mapplot(tfiles_plotting, label,
"dxdz", window=15., title=htitle, peaksbins=2)
519 c1.SaveAs(pdir+
'map_CSCvsr_dxdz.png')
522 for endcap
in CSC_TYPES:
523 for station
in endcap[2]:
524 for ring
in station[2]:
525 if ring[1]!=
"ALL":
continue
526 if qcount>QUICKTESTN:
break
528 schamber =
"%02d" % chamber
529 pdir = csc_basedir+
'/'+endcap[0]+
'/'+station[1]+
'/'+ring[1]+
'/'
530 label =
"CSCvsr_me%s%schALL" % (endcap[1], station[1])
531 htitle =
"%s%s" % (endcap[0], station[1])
532 mapplot(tfiles_plotting, label,
"x", window=10., title=htitle, peaksbins=2)
533 c1.SaveAs(pdir+
'map_CSCvsr_all_x.png')
534 mapplot(tfiles_plotting, label,
"dxdz", window=10., title=htitle, peaksbins=2)
535 c1.SaveAs(pdir+
'map_CSCvsr_all_dxdz.png')
540 """write DT curvature plots
542 "wheel%s_sector%s" % (wheel, sector)
544 wheel in "m2", "m1", "z", "p1", "p2"
546 sector in "01", ..., "12"
548 "param" may be one of
549 "deltax" (Delta x position residuals),
550 "deltadxdz" (Delta (dx/dz) angular residuals),
551 "curverr" (Delta x * d(Delta q/pT)/d(Delta x) = Delta q/pT in the absence of misalignment) - not necessary
553 made for all (wheel,station=1,sector) combinations
555 Interface: could be accesses through a general DT chambers map for station=1 chambers."""
557 w_dict = {
'-2':
'm2',
'-1':
'm1',
'0':
'z',
'1':
'p1',
'2':
'p2'}
559 for wheel
in DT_TYPES:
560 if wheel[1]==
"ALL":
continue
563 for station
in wheel[2]:
564 print "curv in ", wheel[0]+
'/'+station[1]
565 for sector
in range(1,station[2]+1):
567 if qcount>QUICKTESTN:
break
569 ssector =
"%02d" % sector
570 pdir = dt_basedir+
'/'+wheel[0]+
'/'+station[1]+
'/'+ssector+
'/'
571 label =
"wheel%s_st%s_sector%s" % (w_dict[wheel[1]], station[1], ssector)
572 thetitle =
"Wheel %s, station %s, sector %s" % (wheel[1], station[1], ssector)
573 curvatureplot(tfiles_plotting, label,
"deltax", title=thetitle, window=10., fitline=
True)
574 saveAs(pdir+
'dt_curvature_deltax.png')
575 curvatureplot(tfiles_plotting, label,
"deltadxdz", title=thetitle, window=10., fitline=
True)
576 saveAs(pdir+
'dt_curvature_deltadxdz.png')
581 """write segment-difference plots for DT
583 segdiff "dt13_resid" and "dt13_slope"
586 x vs qpt, x for positive, x for negative ("dt13_resid")
587 dxdz vs qpt, dxdz for positive, dxdz for negative ("dt13_slope")
588 done for MB1-MB2, MB2-MB3, and MB3-MB4 stations combinations with all possible (wheel, sector)
590 Interface: could be accessed through a general DT chambers map, but only for chambers in
591 stations 2-4 (e.g., station 2 would provide MB1-MB2 plots).
593 segdiff "dt2_resid" and "dt2_slope"
596 y vs q/pt, y for positive, y for negative ("dt2_resid")
597 dydz vs q/pt, dydz for positive, dydz for negative ("dt2_slope")
598 done for MB1-MB2, MB2-MB3 stations combinations with all possible (wheel, sector)
600 Interface: then the interface would still be a general DT map,
601 but the info only available from station 2 & 3 chambers."""
604 for iwheel
in DT_TYPES:
605 if iwheel[1]==
"ALL":
continue
606 for istation
in iwheel[2]:
607 if istation[1]==
"1":
continue
608 dstations = (int(istation[1])-1)*10 + int(istation[1])
610 for isector
in range(1, istation[2] + 1):
611 if isector > 12:
continue
612 if qcount>QUICKTESTN:
break
614 ssector =
"%02d" % isector
615 pdir = dt_basedir +
'/' + iwheel[0] +
'/' + istation[1] +
'/' + ssector +
'/'
617 segdiff(tfiles_plotting,
"dt13_resid", dstations, wheel=int(iwheel[1]), sector=isector, window=15.)
618 c1.SaveAs(pdir +
'segdif_dt13_resid.png')
619 segdiff(tfiles_plotting,
"dt13_slope", dstations, wheel=int(iwheel[1]), sector=isector, window=15.)
620 c1.SaveAs(pdir +
'segdif_dt13_slope.png')
622 if istation[1] !=
'4':
623 segdiff(tfiles_plotting,
"dt2_resid", dstations, wheel=int(iwheel[1]), sector=isector, window=15.)
624 c1.SaveAs(pdir +
'segdif_dt2_resid.png')
625 segdiff(tfiles_plotting,
"dt2_slope", dstations, wheel=int(iwheel[1]), sector=isector, window=15.)
626 c1.SaveAs(pdir +
'segdif_dt2_slope.png')
629 for iwheel
in DT_TYPES:
630 if iwheel[1]==
"ALL":
continue
631 if abs(int(iwheel[1])) != 2:
continue
632 for istation
in iwheel[2]:
633 if istation[1]==
"3":
continue
635 for isector
in range(1, istation[2] + 1):
636 ssector =
"%02d" % isector
637 pdir = dt_basedir +
'/' + iwheel[0] +
'/' + istation[1] +
'/' + ssector +
'/'
639 segdiff_xalign(tfiles_plotting,
"x_dt1_csc", wheel=int(iwheel[1]), sector=isector, cscstations =
"12")
640 c1.SaveAs(pdir +
'segdif_x_dt_csc_resid.png')
642 segdiff_xalign(tfiles_plotting,
"x_dt2_csc", wheel=int(iwheel[1]), sector=isector, cscstations =
"1")
643 c1.SaveAs(pdir +
'segdif_x_dt_csc_resid.png')
645 """segdiffvsphi "dt13_resid" and "dt13_slope"
647 plot for a specific wheel #:
648 x vs phi of pair ("dt13_resid")
649 dxdz vs phi of pair ("dt13_slope")
650 contains all three combinations of neighboring stations
651 made for all possible wheel values
653 Interface: could be accessed by clicking on wheel number under the "wheel" column
656 segdiffvsphi "dt2_resid" and "dt2_slope"
658 plot for a specific wheel #:
659 y vs phi of pair ("dt2_resid")
660 dydz vs phi of pair ("dt2_slope")
661 contains both MB1-MB2 and MB2-MB3 combinations
662 made for all possible wheel values
664 Interface: could be accessed by clicking on wheel number under the "wheel" column
665 in a general DT map"""
667 if len(iter_reports)==0:
return
669 for iwheel
in DT_TYPES:
670 if iwheel[1]==
"ALL":
continue
671 pdir = dt_basedir +
'/' + iwheel[0] +
'/'
672 segdiffvsphi(tfiles_plotting, iter_reports,
"dt13_resid", int(iwheel[1]), window=10.)
673 c1.SaveAs(pdir +
'segdifphi_dt13_resid.png')
674 segdiffvsphi(tfiles_plotting, iter_reports,
"dt13_slope", int(iwheel[1]), window=10.)
675 c1.SaveAs(pdir +
'segdifphi_dt13_slope.png')
676 segdiffvsphi(tfiles_plotting, iter_reports,
"dt2_resid", int(iwheel[1]), window=10.)
677 c1.SaveAs(pdir +
'segdifphi_dt2_resid.png')
678 segdiffvsphi(tfiles_plotting, iter_reports,
"dt2_slope", int(iwheel[1]), window=15.)
679 c1.SaveAs(pdir +
'segdifphi_dt2_slope.png')
681 for iwheel
in DT_TYPES:
682 if iwheel[1]==
"ALL":
continue
683 if abs(int(iwheel[1])) != 2:
continue
684 pdir = dt_basedir +
'/' + iwheel[0] +
'/'
686 c1.SaveAs(pdir +
'segdifphi_x_dt_csc_resid.png')
690 """write segment-difference plots for CSC
692 segdiff "csc_resid" and "csc_slope"
695 rphi vs qpt, rphi for positive, rphi for negative ("csc_resid")
696 drphidz vs qpt, drphidz for positive, drphidz for negative ("csc_slope")
697 done for ME1-ME2, ME2-ME3, and ME3-ME4 stations combinations with
700 chamber 1-18 (r1) or 1-36 (r2)
701 note: there's no ME3-ME4 plots for R2
703 Interface: could be accessed through a general CSC chambers map, but only for chambers in
704 stations 2-4 (e.g., station 2 would provide ME1-ME2 plots)."""
707 for iendcap
in CSC_TYPES:
708 for istation
in iendcap[2]:
709 if istation[1]==
"1":
continue
710 dstations = (int(istation[1])-1)*10 + int(istation[1])
711 for iring
in istation[2]:
712 if iring[1]==
"ALL":
continue
713 if istation[1]==
"4" and iring[1]==
"2":
continue
714 for ichamber
in range(1,iring[2]+1):
715 if qcount>QUICKTESTN:
break
717 schamber =
"%02d" % ichamber
718 pdir = csc_basedir+
'/'+iendcap[0]+
'/'+istation[1]+
'/'+iring[1]+
'/'+schamber+
'/'
719 segdiff(tfiles_plotting,
"csc_resid", dstations,
720 endcap=iendcap[1], ring=int(iring[1]), chamber=ichamber, window=15.)
721 c1.SaveAs(pdir +
'segdif_csc_resid.png')
722 segdiff(tfiles_plotting,
"csc_slope", dstations,
723 endcap=iendcap[1], ring=int(iring[1]), chamber=ichamber, window=15.)
724 c1.SaveAs(pdir +
'segdif_csc_slope.png')
726 """segdiffvsphicsc "csc_resid" and "csc_slope"
728 plot for a specific deltaME station differences:
729 rphi vs phi of pair ("csc_resid")
730 dxdz vs phi of pair ("csc_slope")
731 contains plots for two (or one for ME4-ME3) rings
732 done for ME1-ME2, ME2-ME3, and ME3-ME4 stations combinations with
735 Interface: could be accessed by clicking on ME station boxes, but only for stations 2-4
736 (e.g., station 2 would provide ME1-ME2 plots)."""
739 for iendcap
in CSC_TYPES:
740 for istation
in iendcap[2]:
741 if istation[1]==
"1":
continue
742 dstations = (int(istation[1])-1)*10 + int(istation[1])
743 if qcount>QUICKTESTN:
break
745 pdir = csc_basedir+
'/'+iendcap[0]+
'/'+istation[1]+
'/'
746 segdiffvsphicsc(tfiles_plotting,
"csc_resid", dstations, window=10., endcap=iendcap[1])
747 c1.SaveAs(pdir +
'segdifphi_csc_resid.png')
748 segdiffvsphicsc(tfiles_plotting,
"csc_slope", dstations, window=10., endcap=iendcap[1])
749 c1.SaveAs(pdir +
'segdifphi_csc_slope.png')
753 """write fit functions plots for DT
755 DT bellcurves and polynomials
757 set of plots of bellcurves
758 x, dxdz, x vs. dxdz (for all 4 stations)
759 y, dydz, x vs. dxdz (only for stations 1-3?)
761 set of plots of polynomials -- for stations 1-3 only??
762 x vs. xpos, x vs ypos, x vs dxdz angle, x vs dydz angle
763 y vs. xpos, y vs ypos, y vs dxdz angle, y vs dydz angle
764 dxdz vs. xpos, dxdz vs ypos, dxdz vs dxdz angle, dxdz vs dydz angle
765 dydz vs. xpos, dydz vs ypos, dydz vs dxdz angle, dydz vs dydz angle
767 set of plots of polynomials -- for station 4 only??
768 x vs. xpos, x vs dxdz angle
769 dxdz vs. xpos, dxdz vs dxdz angle
771 made for all (wheel,station,sector) combinations
773 Interface: could be accesses through a general DT chambers map."""
777 for wheel
in DT_TYPES:
778 if wheel[1]==
"ALL":
continue
779 for station
in wheel[2]:
780 print wheel[0]+
'/'+station[1]
781 for sector
in range(1,station[2]+1):
782 if qcount>QUICKTESTN:
break
784 ssector =
"%02d" % sector
785 pdir = dt_basedir+
'/'+wheel[0]+
'/'+station[1]+
'/'+ssector+
'/'
786 label =
"MBwh%sst%ssec%s" % (
wheelLetter(int(wheel[1])),station[1],ssector)
787 bellcurves(iter_tfile, iter_reports, label,
False)
789 saveAs(pdir+
'dt_bellcurves.png')
790 polynomials(iter_tfile, iter_reports, label,
False)
792 saveAs(pdir+
'dt_polynomials.png')
797 """write fit functions plots for CSC
799 CSC bellcurves and polynomials
801 set of plots of bellcurves
802 rphi, drphidz, rphi vs. drphidz
804 set of plots of polynomials
805 rphi vs. rphi pos, rphi vs drphidz angle
806 drphidz vs. rphi pos, drphidz vs drphidz angle
808 made for all (endcap,station,ring,chamber) combinations
810 Interface: could be accesses through a general CSC chambers map."""
814 for endcap
in CSC_TYPES:
815 for station
in endcap[2]:
816 for ring
in station[2]:
817 if ring[1]==
"ALL":
continue
818 print endcap[0]+
'/'+station[1]+
'/'+ring[1]
819 for chamber
in range(1,ring[2]+1):
820 if qcount>QUICKTESTN:
break
822 schamber =
"%02d" % chamber
823 pdir = csc_basedir+
'/'+endcap[0]+
'/'+station[1]+
'/'+ring[1]+
'/'+schamber+
'/'
824 label =
"ME%s%s%s_%s" % (endcap[1], station[1], ring[1], schamber)
825 bellcurves(iter_tfile, iter_reports, label,
False)
827 saveAs(pdir+
'csc_bellcurves.png')
828 polynomials(iter_tfile, iter_reports, label,
False)
830 saveAs(pdir+
'csc_polynomials.png')
836 dt_basedir = iteration_directory+
'/'+
'MB'
837 csc_basedir = iteration_directory+
'/'
841 if DO_CSC
and DO_MAP:
844 if DO_DT
and DO_CURVATURE:
849 if DO_DT
and DO_SEGDIFF:
851 if DO_CSC
and DO_SEGDIFF:
856 if DO_CSC
and DO_FIT:
861 '''Use CANVASES_LIST_TEMPLATE as a template to create a canvases list include for the browser.
862 Write out only those canvases which have existing filename.png plots.
865 for scope
in CANVASES_LIST_TEMPLATE:
868 scope_entry = [scope[0],scope[1]]
869 for canvas_entry
in scope[2:]:
871 scope_entry.append(canvas_entry)
872 CANVASES_LIST.append(scope_entry)
874 ff = open(fname,mode=
"w")
875 print >>ff,
"var CANVASES_LIST = "
876 json.dump(CANVASES_LIST,ff)
881 '''Writes out a canvas-2-ids list include for the browser.
882 Write out only those canvases which have existing filename.png plots.
883 Returns: list of unique IDs that have existing filename.png plots.
887 for scope
in CANVASES_LIST_TEMPLATE:
889 for canvas_entry
in scope[2:]:
896 print canvas_entry,
":", len(uids),
"ids"
898 CANVAS2ID_LIST.append( (canvas_entry[1],uids) )
900 CANVAS2ID_LIST_DICT =
dict(CANVAS2ID_LIST)
902 ff = open(fname,mode=
"w")
903 print >>ff,
"var CANVAS2ID_LIST = "
904 json.dump(CANVAS2ID_LIST_DICT,ff)
906 set_ids =
set(ID_LIST)
910 '''Recursively looks for file named file_name under dir_name directory
911 and fill the list with dir names converted to IDs
914 for f
in os.listdir(dir_name):
915 dirfile = os.path.join(dir_name, f)
916 if os.path.isfile(dirfile)
and f==file_name:
917 if file_name[-4:]==
'.php': id_list.append(dir_name+
'/'+file_name)
918 else: id_list.append(
dirToID(dir_name))
920 elif os.path.isdir(dirfile):
929 if d[-1]!=
'/': d +=
'/'
933 cscn = d.find(
"/ME-/")
935 return 'ME-'+d[cscn+5:-1]
936 cscn = d.find(
"/ME+/")
938 return 'ME+'+d[cscn+5:-1]
957 fname = options.inputDir+
'/'+options.i1+
'/'+i1prefix
958 tfiles1_plotting = []
961 if not SINGLE_ITERATION:
962 if (DO_MAP
or DO_SEGDIFF
or DO_CURVATURE)
and not os.access(fname+
"_plotting.root",os.F_OK):
963 print "no file "+fname+
"_plotting.root"
965 if DO_FIT
and not os.access(fname+
".root",os.F_OK):
966 print "no file "+fname+
".root"
968 if DO_MEDIAN
and not os.access(fname+
"_report.py",os.F_OK):
969 print "no file "+fname+
"_report.py"
971 if DO_MAP
or DO_SEGDIFF
or DO_CURVATURE: tfiles1_plotting.append(ROOT.TFile(fname+
"_plotting.root"))
972 if os.access(fname+
".root",os.F_OK):
973 iter1_tfile = ROOT.TFile(fname+
".root")
974 if os.access(fname+
"_report.py",os.F_OK):
975 execfile(fname+
"_report.py")
976 iter1_reports = reports
978 fname = options.inputDir+
'/'+options.iN+
'/'+iNprefix
979 tfilesN_plotting = []
982 if (DO_MAP
or DO_SEGDIFF
or DO_CURVATURE)
and not os.access(fname+
"_plotting.root",os.F_OK):
983 print "no file "+fname+
"_plotting.root"
985 if DO_FIT
and not os.access(fname+
".root",os.F_OK):
986 print "no file "+fname+
".root"
988 if DO_MEDIAN
and not os.access(fname+
"_report.py",os.F_OK):
989 print "no file "+fname+
"_report.py"
991 if DO_MAP
or DO_SEGDIFF
or DO_CURVATURE: tfilesN_plotting.append(ROOT.TFile(fname+
"_plotting.root"))
992 if os.access(fname+
".root",os.F_OK):
993 iterN_tfile = ROOT.TFile(fname+
".root")
994 if os.access(fname+
"_report.py",os.F_OK):
995 execfile(fname+
"_report.py")
996 iterN_reports = reports
999 os.chdir(options.inputDir)
1006 os.chdir(options.outputDir)
1009 iteration1 =
"iter1"
1010 iterationN =
"iterN"
1013 if options.createDirSructure:
1014 print "WARNING: all existing results in "+options.outputDir+
" will be deleted!"
1017 if not os.access(comdir,os.F_OK):
1023 c1 = ROOT.TCanvas(
"c1",
"c1",800,600)
1027 print "--- ITERATION 1 ---"
1028 if not SINGLE_ITERATION:
doIterationPlots(iteration1, tfiles1_plotting, iter1_tfile, iter1_reports)
1029 print "--- ITERATION N ---"
1032 if CPP_LOADED: ROOT.cleanUpHeap()
1038 plotmedians(iter1_reports, iterN_reports,binsx=100, windowx=10., binsy=100, windowy=10., binsdxdz=100, windowdxdz=10., binsdydz=100, windowdydz=10.)
1039 c1.SaveAs(comdir+
'medians.png')
1046 doTests(iterN_reports, pic_ids,
"mu_list.js",
"dqm_report.js",options.runLabel)
def curvatureplot
"param" may be one of "deltax" (Delta x position residuals), "deltadxdz" (Delta (dx/dz) angular resid...
def isFileUnderDir
functions definitions
def doFitFunctionsPlotsDT
def createDirectoryStructure
def doFitFunctionsPlotsCSC
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
void set(const std::string &name, int value)
set the flag, with a run-time name