3 from __future__
import print_function
10 from Validation.RecoTrack.plotting.validation
import SeparateValidation, SimpleValidation, SimpleSample
11 import Validation.HGCalValidation.hgcalPlots
as hgcalPlots
12 import Validation.RecoTrack.plotting.plotting
as plotting
14 simClustersIters = [
"ClusterLevel",
"ticlSimTracksters"]
15 trackstersIters = [
'ticlTracksters'+iteration
for iteration
in ticlIterLabelsMerge]
16 trackstersIters.extend([
"ticlSimTracksters"])
19 layerClustersLabel =
'layerClusters'
20 trackstersLabel =
'tracksters'
21 trackstersWithEdgesLabel =
'trackstersWithEdges'
22 simLabel =
'simulation'
25 collection_choices = [allLabel]
26 collection_choices.extend([hitLabel]+[layerClustersLabel]+[trackstersLabel]+[trackstersWithEdgesLabel]+[simLabel])
33 drawArgs[
"ratio"] =
False
35 drawArgs[
"separate"] =
True
37 drawArgs[
"saveFormat"] =
".png"
41 plotting.verbose =
True
43 filenames = [(f, f.replace(
".root",
""))
for f
in opts.files]
44 sample = SimpleSample(opts.subdirprefix[0], opts.html_sample, filenames)
46 val = SimpleValidation([sample], opts.outputDir[0])
48 val = SeparateValidation([sample], opts.outputDir[0])
49 htmlReport = val.createHtmlReport(validationName=opts.html_validation_name[0])
53 hgclayclus = [hgcalPlots.hgcalLayerClustersPlotter]
55 val.doPlots(hgclayclus, plotterDrawArgs=drawArgs)
59 hgcsimclus = [hgcalPlots.hgcalSimClustersPlotter]
60 for i_iter
in simClustersIters:
62 val.doPlots(hgcsimclus, plotterDrawArgs=drawArgs)
66 hgctrackster = [hgcalPlots.hgcalTrackstersPlotter]
67 for tracksterCollection
in trackstersIters :
69 val.doPlots(hgctrackster, plotterDrawArgs=drawArgs)
74 for tracksterCollection
in trackstersIters :
76 val.doPlots(hgctracksters, plotterDrawArgs=drawArgs)
80 particletypes = {
"pion-":
"-211",
"pion+":
"211",
"pion0":
"111",
81 "muon-":
"-13",
"muon+":
"13",
82 "electron-":
"-11",
"electron+":
"11",
"photon":
"22",
83 "kaon0L":
"310",
"kaon0S":
"130",
84 "kaon-":
"-321",
"kaon+":
"321"}
85 hgcaloPart = [hgcalPlots.hgcalCaloParticlesPlotter]
86 for i_part, i_partID
in particletypes.iteritems() :
88 val.doPlots(hgcaloPart, plotterDrawArgs=drawArgs)
92 hgchit = [hgcalPlots.hgcalHitPlotter]
96 val.doPlots(hgchit, plotterDrawArgs=drawArgs)
100 hgchitcalib = [hgcalPlots.hgcalHitCalibPlotter]
101 val.doPlots(hgchitcalib, plotterDrawArgs=drawArgs)
104 plotDict = {hitLabel:[plot_hitVal, plot_hitCal], layerClustersLabel:[plot_LC], trackstersLabel:[plot_Tst], trackstersWithEdgesLabel:[plot_TstEdges], simLabel:[plot_SC, plot_CP]}
106 if (opts.collection != allLabel):
107 for task
in plotDict[opts.collection]:
110 for label
in plotDict:
111 if (label == trackstersLabel):
continue
112 for task
in plotDict[label]:
116 print(
"Plots created into directory '%s'." % opts.outputDir)
120 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)))
122 if __name__ ==
"__main__":
123 parser = argparse.ArgumentParser(description=
"Create set of HGCal validation plots from one or more DQM files.")
124 parser.add_argument(
"files", metavar=
"file", type=str, nargs=
"+",
125 default =
"DQM_V0001_R000000001__Global__CMSSW_X_Y_Z__RECO.root",
126 help=
"DQM file to plot the validation plots from")
127 parser.add_argument(
"-o",
"--outputDir", type=str, default=[
"plots1",
"plots2"], nargs=
"+",
128 help=
"Plot output directories (default: 'plots1'")
129 parser.add_argument(
"--subdirprefix", type=str, default=[
"plots1",
"plots2"], nargs=
"+",
130 help=
"Prefix for subdirectories inside outputDir (default: 'plots1')")
131 parser.add_argument(
"--no-ratio", action=
"store_true", default =
False,
132 help=
"Disable ratio pads")
133 parser.add_argument(
"--separate", action=
"store_true", default =
False,
134 help=
"Save all plots separately instead of grouping them")
135 parser.add_argument(
"--png", action=
"store_true",
136 help=
"Save plots in PNG instead of PDF")
137 parser.add_argument(
"--no-html", action=
"store_true", default =
False,
138 help=
"Disable HTML page generation")
139 parser.add_argument(
"--html-sample", default=
"Sample",
140 help=
"Sample name for HTML page generation (default 'Sample')")
141 parser.add_argument(
"--html-validation-name", type=str, default=[
"",
""], nargs=
"+",
142 help=
"Validation name for HTML page generation (enters to <title> element) (default '')")
143 parser.add_argument(
"--collection", choices=collection_choices, default=layerClustersLabel,
144 help=
"Choose output plots collections among possible choices")
145 parser.add_argument(
"--extended", action=
"store_true", default =
False,
146 help=
"Include extended set of plots (e.g. bunch of distributions; default off)")
147 parser.add_argument(
"--verbose", action=
"store_true", default =
False,
150 opts = parser.parse_args()
153 if not os.path.exists(f):
154 parser.error(
"DQM file %s does not exist" % f)