3 from __future__
import print_function
7 from Validation.RecoTrack.plotting.validation
import SimpleValidation, SimpleSample
8 import Validation.HGCalValidation.hgcalPlots
as hgcalPlots
9 import Validation.RecoTrack.plotting.plotting
as plotting
15 drawArgs[
"ratio"] =
False 17 drawArgs[
"separate"] =
True 19 drawArgs[
"saveFormat"] =
".png" 21 plotting.verbose =
True 23 filenames = [(f, f.replace(
".root",
""))
for f
in opts.files]
24 sample = SimpleSample(opts.subdirprefix[0], opts.html_sample, filenames)
26 val = SimpleValidation([sample], opts.outputDir[0])
27 htmlReport = val.createHtmlReport(validationName=opts.html_validation_name[0])
29 if opts.collection==
"hgcalLayerClusters":
30 hgclayclus = [hgcalPlots.hgcalLayerClustersPlotter]
31 val.doPlots(hgclayclus, plotterDrawArgs=drawArgs)
32 elif opts.collection
in [
"hgcalMultiClusters",
"multiClustersFromTrackstersMIP",
"multiClustersFromTrackstersTrk",
"multiClustersFromTrackstersEM",
"multiClustersFromTrackstersHAD"]:
33 hgcmulticlus = [hgcalPlots.hgcalMultiClustersPlotter]
34 val.doPlots(hgcmulticlus, plotterDrawArgs=drawArgs)
35 elif opts.collection==
"hitValidation":
36 hgchit = [hgcalPlots.hgcalHitPlotter]
37 val.doPlots(hgchit, plotterDrawArgs=drawArgs)
38 elif opts.collection==
"hitCalibration":
39 hgchitcalib = [hgcalPlots.hgcalHitCalibPlotter]
40 val.doPlots(hgchitcalib, plotterDrawArgs=drawArgs)
45 hgclayclus = [hgcalPlots.hgcalLayerClustersPlotter]
46 val.doPlots(hgclayclus, plotterDrawArgs=drawArgs)
48 sample = SimpleSample(opts.subdirprefix[1], opts.html_sample, filenames)
49 val = SimpleValidation([sample], opts.outputDir[1])
50 htmlReport_2 = val.createHtmlReport(validationName=opts.html_validation_name[1])
51 hgcmulticlus = [hgcalPlots.hgcalMultiClustersPlotter]
52 val.doPlots(hgcmulticlus, plotterDrawArgs=drawArgs)
54 sample = SimpleSample(opts.subdirprefix[2], opts.html_sample, filenames)
55 val = SimpleValidation([sample], opts.outputDir[2])
56 htmlReport_3 = val.createHtmlReport(validationName=opts.html_validation_name[2])
57 hgchit = [hgcalPlots.hgcalHitPlotter]
58 val.doPlots(hgchit, plotterDrawArgs=drawArgs)
60 sample = SimpleSample(opts.subdirprefix[3], opts.html_sample, filenames)
61 val = SimpleValidation([sample], opts.outputDir[3])
62 htmlReport_4 = val.createHtmlReport(validationName=opts.html_validation_name[3])
63 hgchitcalib = [hgcalPlots.hgcalHitCalibPlotter]
64 val.doPlots(hgchitcalib, plotterDrawArgs=drawArgs)
67 print(
"Plots created into directory '%s'." % opts.outputDir)
70 if(opts.collection==
"all"):
75 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" % (
','.
join(opts.outputDir)))
77 if __name__ ==
"__main__":
78 parser = argparse.ArgumentParser(description=
"Create set of HGCal validation plots from one or more DQM files.")
79 parser.add_argument(
"files", metavar=
"file", type=str, nargs=
"+",
80 default =
"DQM_V0001_R000000001__Global__CMSSW_X_Y_Z__RECO.root",
81 help=
"DQM file to plot the validation plots from")
82 parser.add_argument(
"-o",
"--outputDir", type=str, default=[
"plots1",
"plots2"], nargs=
"+",
83 help=
"Plot output directories (default: 'plots1'")
84 parser.add_argument(
"--subdirprefix", type=str, default=[
"plots1",
"plots2"], nargs=
"+",
85 help=
"Prefix for subdirectories inside outputDir (default: 'plots1')")
86 parser.add_argument(
"--no-ratio", action=
"store_true", default =
False,
87 help=
"Disable ratio pads")
88 parser.add_argument(
"--separate", action=
"store_true", default =
False,
89 help=
"Save all plots separately instead of grouping them")
90 parser.add_argument(
"--png", action=
"store_true",
91 help=
"Save plots in PNG instead of PDF")
92 parser.add_argument(
"--no-html", action=
"store_true", default =
False,
93 help=
"Disable HTML page generation")
94 parser.add_argument(
"--html-sample", default=
"Sample",
95 help=
"Sample name for HTML page generation (default 'Sample')")
96 parser.add_argument(
"--html-validation-name", type=str, default=[
"",
""], nargs=
"+",
97 help=
"Validation name for HTML page generation (enters to <title> element) (default '')")
98 parser.add_argument(
"--verbose", action=
"store_true", default =
False,
100 parser.add_argument(
"--collection", choices=[
"hgcalLayerClusters",
"hgcalMultiClusters",
"multiClustersFromTrackstersMIP",
"multiClustersFromTrackstersTrk",
"multiClustersFromTrackstersEM",
"multiClustersFromTrackstersHAD",
"hitValidation",
"hitCalibration",
"all"], default=
"hgcalLayerClusters",
101 help=
"Choose output plots collections: hgcalLayerCluster, hgcalMultiClusters, multiClustersFromTrackstersMIP, multiClustersFromTrackstersTrk, multiClustersFromTrackstersEM, multiClustersFromTrackstersHAD, hitValidation, hitCalibration, all")
103 opts = parser.parse_args()
105 if opts.collection ==
"all" and len(opts.outputDir)==1:
106 raise RuntimeError(
"need to assign names for all dirrectories")
109 if not os.path.exists(f):
110 parser.error(
"DQM file %s does not exist" % f)
S & print(S &os, JobReport::InputFile const &f)
static std::string join(char **cmd)