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 simClustersIters = [
"ClusterLevel",
"ticlTrackstersTrkEM",
"ticlTrackstersEM",
"ticlTrackstersTrk",
"ticlTrackstersHAD",
"ticlSimTracksters"]
14 trackstersIters = [
"ticlMultiClustersFromTrackstersMerge",
"ticlMultiClustersFromTrackstersMIP",
15 "ticlMultiClustersFromTrackstersTrk",
"ticlMultiClustersFromTrackstersTrkEM",
16 "ticlMultiClustersFromTrackstersEM",
"ticlMultiClustersFromTrackstersHAD",
17 "ticlMultiClustersFromSimTracksters"]
19 simClustersGeneralLabel =
'simClusters'
20 layerClustersGeneralLabel =
'hgcalLayerClusters'
21 multiclustersGeneralLabel =
'hgcalMultiClusters'
22 trackstersGeneralLabel =
'allTiclMultiClusters'
23 hitValidationLabel =
'hitValidation'
24 hitCalibrationLabel =
'hitCalibration'
25 caloParticlesLabel =
'caloParticles'
28 collection_choices = [layerClustersGeneralLabel]
29 collection_choices.extend([simClustersGeneralLabel]+[multiclustersGeneralLabel]+[trackstersGeneralLabel]+[hitValidationLabel]+[hitCalibrationLabel]+[allLabel]+[caloParticlesLabel])
36 drawArgs[
"ratio"] =
False
38 drawArgs[
"separate"] =
True
40 drawArgs[
"saveFormat"] =
".png"
44 plotting.verbose =
True
46 filenames = [(f, f.replace(
".root",
""))
for f
in opts.files]
47 sample = SimpleSample(opts.subdirprefix[0], opts.html_sample, filenames)
49 val = SimpleValidation([sample], opts.outputDir[0])
51 val = SeparateValidation([sample], opts.outputDir[0])
52 htmlReport = val.createHtmlReport(validationName=opts.html_validation_name[0])
55 if (opts.collection == layerClustersGeneralLabel):
56 hgclayclus = [hgcalPlots.hgcalLayerClustersPlotter]
58 val.doPlots(hgclayclus, plotterDrawArgs=drawArgs)
60 elif (opts.collection == simClustersGeneralLabel):
61 hgcsimclus = [hgcalPlots.hgcalSimClustersPlotter]
62 for i_iter
in simClustersIters:
64 val.doPlots(hgcsimclus, plotterDrawArgs=drawArgs)
66 elif (opts.collection == multiclustersGeneralLabel):
67 hgcmulticlus = [hgcalPlots.hgcalMultiClustersPlotter]
69 val.doPlots(hgcmulticlus, plotterDrawArgs=drawArgs)
71 elif (opts.collection == trackstersGeneralLabel):
72 hgcmulticlus = [hgcalPlots.hgcalMultiClustersPlotter]
73 for i_iter
in trackstersIters :
74 tracksterCollection = i_iter.replace(
"ticlMultiClustersFromTracksters",
"ticlTracksters")
76 val.doPlots(hgcmulticlus, plotterDrawArgs=drawArgs)
78 for i_iter
in trackstersIters :
79 tracksterCollection = i_iter.replace(
"ticlMultiClustersFromTracksters",
"ticlTracksters")
81 val.doPlots(hgctracksters, plotterDrawArgs=drawArgs)
82 elif (opts.collection == caloParticlesLabel):
83 particletypes = {
"pion-":
"-211",
"pion+":
"211",
"pion0":
"111",
84 "muon-":
"-13",
"muon+":
"13",
85 "electron-":
"-11",
"electron+":
"11",
"photon":
"22",
86 "kaon0L":
"310",
"kaon0S":
"130",
87 "kaon-":
"-321",
"kaon+":
"321"}
88 hgcaloPart = [hgcalPlots.hgcalCaloParticlesPlotter]
89 for i_part, i_partID
in particletypes.iteritems() :
91 val.doPlots(hgcaloPart, plotterDrawArgs=drawArgs)
93 elif (opts.collection == hitValidationLabel):
94 hgchit = [hgcalPlots.hgcalHitPlotter]
98 val.doPlots(hgchit, plotterDrawArgs=drawArgs)
100 elif (opts.collection == hitCalibrationLabel):
101 hgchitcalib = [hgcalPlots.hgcalHitCalibPlotter]
102 val.doPlots(hgchitcalib, plotterDrawArgs=drawArgs)
103 elif (opts.collection == allLabel):
105 particletypes = {
"pion-":
"-211",
"pion+":
"211",
"pion0":
"111",
106 "muon-":
"-13",
"muon+":
"13",
107 "electron-":
"-11",
"electron+":
"11",
"photon":
"22",
108 "kaon0L":
"310",
"kaon0S":
"130",
109 "kaon-":
"-321",
"kaon+":
"321"}
110 hgcaloPart = [hgcalPlots.hgcalCaloParticlesPlotter]
111 for i_part, i_partID
in particletypes.iteritems() :
113 val.doPlots(hgcaloPart, plotterDrawArgs=drawArgs)
116 hgchit = [hgcalPlots.hgcalHitPlotter]
120 val.doPlots(hgchit, plotterDrawArgs=drawArgs)
123 hgchitcalib = [hgcalPlots.hgcalHitCalibPlotter]
124 val.doPlots(hgchitcalib, plotterDrawArgs=drawArgs)
127 hgcsimclus = [hgcalPlots.hgcalSimClustersPlotter]
128 for i_iter
in simClustersIters :
130 val.doPlots(hgcsimclus, plotterDrawArgs=drawArgs)
133 hgclayclus = [hgcalPlots.hgcalLayerClustersPlotter]
135 val.doPlots(hgclayclus, plotterDrawArgs=drawArgs)
138 hgcmulticlus = [hgcalPlots.hgcalMultiClustersPlotter]
139 for i_iter
in trackstersIters :
140 tracksterCollection = i_iter.replace(
"ticlMultiClustersFromTracksters",
"ticlTracksters")
142 val.doPlots(hgcmulticlus, plotterDrawArgs=drawArgs)
144 for i_iter
in trackstersIters :
145 tracksterCollection = i_iter.replace(
"ticlMultiClustersFromTracksters",
"ticlTracksters")
147 val.doPlots(hgctracksters, plotterDrawArgs=drawArgs)
151 print(
"Plots created into directory '%s'." % opts.outputDir)
155 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)))
157 if __name__ ==
"__main__":
158 parser = argparse.ArgumentParser(description=
"Create set of HGCal validation plots from one or more DQM files.")
159 parser.add_argument(
"files", metavar=
"file", type=str, nargs=
"+",
160 default =
"DQM_V0001_R000000001__Global__CMSSW_X_Y_Z__RECO.root",
161 help=
"DQM file to plot the validation plots from")
162 parser.add_argument(
"-o",
"--outputDir", type=str, default=[
"plots1",
"plots2"], nargs=
"+",
163 help=
"Plot output directories (default: 'plots1'")
164 parser.add_argument(
"--subdirprefix", type=str, default=[
"plots1",
"plots2"], nargs=
"+",
165 help=
"Prefix for subdirectories inside outputDir (default: 'plots1')")
166 parser.add_argument(
"--no-ratio", action=
"store_true", default =
False,
167 help=
"Disable ratio pads")
168 parser.add_argument(
"--separate", action=
"store_true", default =
False,
169 help=
"Save all plots separately instead of grouping them")
170 parser.add_argument(
"--png", action=
"store_true",
171 help=
"Save plots in PNG instead of PDF")
172 parser.add_argument(
"--no-html", action=
"store_true", default =
False,
173 help=
"Disable HTML page generation")
174 parser.add_argument(
"--html-sample", default=
"Sample",
175 help=
"Sample name for HTML page generation (default 'Sample')")
176 parser.add_argument(
"--html-validation-name", type=str, default=[
"",
""], nargs=
"+",
177 help=
"Validation name for HTML page generation (enters to <title> element) (default '')")
178 parser.add_argument(
"--collection", choices=collection_choices, default=layerClustersGeneralLabel,
179 help=
"Choose output plots collections among possible choices")
180 parser.add_argument(
"--extended", action=
"store_true", default =
False,
181 help=
"Include extended set of plots (e.g. bunch of distributions; default off)")
182 parser.add_argument(
"--verbose", action=
"store_true", default =
False,
185 opts = parser.parse_args()
188 if not os.path.exists(f):
189 parser.error(
"DQM file %s does not exist" % f)