CMS 3D CMS Logo

makeHGCalValidationPlots.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 from __future__ import print_function
4 import os
5 import argparse
6 
7 from Validation.RecoTrack.plotting.validation import SimpleValidation, SimpleSample
8 import Validation.HGCalValidation.hgcalPlots as hgcalPlots
9 import Validation.RecoTrack.plotting.plotting as plotting
10 
11 def main(opts):
12  sample = SimpleSample(opts.subdirprefix, opts.html_sample, [(f, f.replace(".root", "")) for f in opts.files])
13 
14  drawArgs={}
15  if opts.no_ratio:
16  drawArgs["ratio"] = False
17  if opts.separate:
18  drawArgs["separate"] = True
19  if opts.png:
20  drawArgs["saveFormat"] = ".png"
21  if opts.verbose:
22  plotting.verbose = True
23 
24  val = SimpleValidation([sample], opts.outputDir)
25  htmlReport = val.createHtmlReport(validationName=opts.html_validation_name)
26 
27  hgclayclus = [hgcalPlots.hgcalLayerClustersPlotter]
28  val.doPlots(hgclayclus, plotterDrawArgs=drawArgs)
29  print()
30  if opts.no_html:
31  print("Plots created into directory '%s'." % opts.outputDir)
32  else:
33  htmlReport.write()
34  print("Plots and HTML report created into directory '%s'. You can just move it to some www area and access the pages via web browser" % opts.outputDir)
35 
36 if __name__ == "__main__":
37  parser = argparse.ArgumentParser(description="Create set of HGCal validation plots from one or more DQM files.")
38  parser.add_argument("files", metavar="file", type=str, nargs="+",
39  help="DQM file to plot the validation plots from")
40  parser.add_argument("-o", "--outputDir", type=str, default="plots",
41  help="Plot output directory (default: 'plots')")
42  parser.add_argument("--subdirprefix", type=str, default="plots",
43  help="Prefix for subdirectories inside outputDir (default: 'plots')")
44  parser.add_argument("--no-ratio", action="store_true",
45  help="Disable ratio pads")
46  parser.add_argument("--separate", action="store_true",
47  help="Save all plots separately instead of grouping them")
48  parser.add_argument("--png", action="store_true",
49  help="Save plots in PNG instead of PDF")
50  parser.add_argument("--no-html", action="store_true",
51  help="Disable HTML page generation")
52  parser.add_argument("--html-sample", default="Sample",
53  help="Sample name for HTML page generation (default 'Sample')")
54  parser.add_argument("--html-validation-name", default="",
55  help="Validation name for HTML page generation (enters to <title> element) (default '')")
56  parser.add_argument("--verbose", action="store_true",
57  help="Be verbose")
58  opts = parser.parse_args()
59 
60  for f in opts.files:
61  if not os.path.exists(f):
62  parser.error("DQM file %s does not exist" % f)
63 
64  main(opts)
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
Definition: main.py:1