3 from __future__
import print_function
8 from Validation.RecoTrack.plotting.validation
import SeparateValidation, SimpleValidation, SimpleSample
9 import Validation.HGCalValidation.hgcalPlots
as hgcalPlots
10 import Validation.RecoTrack.plotting.plotting
as plotting
12 trackstersIters = [
"ticlMultiClustersFromTrackstersMerge",
"ticlMultiClustersFromTrackstersMIP",
13 "ticlMultiClustersFromTrackstersTrk",
"ticlMultiClustersFromTrackstersTrkEM",
14 "ticlMultiClustersFromTrackstersEM",
"ticlMultiClustersFromTrackstersHAD",
15 "ticlMultiClustersFromTrackstersDummy"]
17 layerClustersGeneralLabel =
'hgcalLayerClusters'
18 multiclustersGeneralLabel =
'hgcalMultiClusters'
19 trackstersGeneralLabel =
'allTiclMultiClusters'
20 hitValidationLabel =
'hitValidation'
21 hitCalibrationLabel =
'hitCalibration'
24 collection_choices = [layerClustersGeneralLabel]
25 collection_choices.extend([multiclustersGeneralLabel]+[trackstersGeneralLabel]+[hitValidationLabel]+[hitCalibrationLabel]+[allLabel])
31 drawArgs[
"ratio"] =
False
33 drawArgs[
"separate"] =
True
35 drawArgs[
"saveFormat"] =
".png"
37 plotting.verbose =
True
39 filenames = [(f, f.replace(
".root",
""))
for f
in opts.files]
40 sample = SimpleSample(opts.subdirprefix[0], opts.html_sample, filenames)
42 val = SimpleValidation([sample], opts.outputDir[0])
44 val = SeparateValidation([sample], opts.outputDir[0])
45 htmlReport = val.createHtmlReport(validationName=opts.html_validation_name[0])
47 if opts.collection==layerClustersGeneralLabel:
48 hgclayclus = [hgcalPlots.hgcalLayerClustersPlotter]
50 val.doPlots(hgclayclus, plotterDrawArgs=drawArgs)
51 elif opts.collection == multiclustersGeneralLabel:
52 hgcmulticlus = [hgcalPlots.hgcalMultiClustersPlotter]
54 val.doPlots(hgcmulticlus, plotterDrawArgs=drawArgs)
55 elif (opts.collection == trackstersGeneralLabel) :
56 hgcmulticlus = [hgcalPlots.hgcalMultiClustersPlotter]
57 for i_iter
in trackstersIters :
58 tracksterCollection = i_iter.replace(
"ticlMultiClustersFromTracksters",
"ticlTracksters")
60 val.doPlots(hgcmulticlus, plotterDrawArgs=drawArgs)
61 elif opts.collection==hitValidationLabel:
62 hgchit = [hgcalPlots.hgcalHitPlotter]
66 val.doPlots(hgchit, plotterDrawArgs=drawArgs)
67 elif opts.collection==hitCalibrationLabel:
68 hgchitcalib = [hgcalPlots.hgcalHitCalibPlotter]
69 val.doPlots(hgchitcalib, plotterDrawArgs=drawArgs)
73 hgchit = [hgcalPlots.hgcalHitPlotter]
77 val.doPlots(hgchit, plotterDrawArgs=drawArgs)
80 hgchitcalib = [hgcalPlots.hgcalHitCalibPlotter]
81 val.doPlots(hgchitcalib, plotterDrawArgs=drawArgs)
84 hgclayclus = [hgcalPlots.hgcalLayerClustersPlotter]
86 val.doPlots(hgclayclus, plotterDrawArgs=drawArgs)
89 hgcmulticlus = [hgcalPlots.hgcalMultiClustersPlotter]
90 for i_iter
in trackstersIters :
91 tracksterCollection = i_iter.replace(
"ticlMultiClustersFromTracksters",
"ticlTracksters")
93 val.doPlots(hgcmulticlus, plotterDrawArgs=drawArgs)
96 print(
"Plots created into directory '%s'." % opts.outputDir)
100 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)))
102 if __name__ ==
"__main__":
103 parser = argparse.ArgumentParser(description=
"Create set of HGCal validation plots from one or more DQM files.")
104 parser.add_argument(
"files", metavar=
"file", type=str, nargs=
"+",
105 default =
"DQM_V0001_R000000001__Global__CMSSW_X_Y_Z__RECO.root",
106 help=
"DQM file to plot the validation plots from")
107 parser.add_argument(
"-o",
"--outputDir", type=str, default=[
"plots1",
"plots2"], nargs=
"+",
108 help=
"Plot output directories (default: 'plots1'")
109 parser.add_argument(
"--subdirprefix", type=str, default=[
"plots1",
"plots2"], nargs=
"+",
110 help=
"Prefix for subdirectories inside outputDir (default: 'plots1')")
111 parser.add_argument(
"--no-ratio", action=
"store_true", default =
False,
112 help=
"Disable ratio pads")
113 parser.add_argument(
"--separate", action=
"store_true", default =
False,
114 help=
"Save all plots separately instead of grouping them")
115 parser.add_argument(
"--png", action=
"store_true",
116 help=
"Save plots in PNG instead of PDF")
117 parser.add_argument(
"--no-html", action=
"store_true", default =
False,
118 help=
"Disable HTML page generation")
119 parser.add_argument(
"--html-sample", default=
"Sample",
120 help=
"Sample name for HTML page generation (default 'Sample')")
121 parser.add_argument(
"--html-validation-name", type=str, default=[
"",
""], nargs=
"+",
122 help=
"Validation name for HTML page generation (enters to <title> element) (default '')")
123 parser.add_argument(
"--verbose", action=
"store_true", default =
False,
125 parser.add_argument(
"--collection", choices=collection_choices, default=layerClustersGeneralLabel,
126 help=
"Choose output plots collections among possible choices")
128 opts = parser.parse_args()
131 if not os.path.exists(f):
132 parser.error(
"DQM file %s does not exist" % f)