3 from __future__
import print_function
10 from Validation.RecoTrack.plotting.validation
import SeparateValidation, SimpleValidation, SimpleSample
12 import Validation.HGCalValidation.hgcalPlots
as hgcalPlots
13 import Validation.RecoTrack.plotting.plotting
as plotting
15 simClustersIters = [hgcalValidator.label_SimClustersLevel._InputTag__moduleLabel,
"ticlSimTracksters"]
16 trackstersIters = [
'ticlTracksters'+iteration
for iteration
in ticlIterLabelsMerge]
17 trackstersIters.extend([
"ticlSimTracksters"])
19 hitCalLabel =
'hitCalibration'
20 hitValLabel =
'hitValidation'
21 layerClustersLabel =
'layerClusters'
22 trackstersLabel =
'tracksters'
23 trackstersWithEdgesLabel =
'trackstersWithEdges'
24 simLabel =
'simulation'
27 collection_choices = [allLabel]
28 collection_choices.extend([hitCalLabel]+[hitValLabel]+[layerClustersLabel]+[trackstersLabel]+[trackstersWithEdgesLabel]+[simLabel])
35 drawArgs[
"ratio"] =
False
37 drawArgs[
"separate"] =
True
39 drawArgs[
"saveFormat"] =
".png"
43 plotting.verbose =
True
45 filenames = [(f, f.replace(
".root",
""))
for f
in opts.files]
46 sample = SimpleSample(opts.subdirprefix[0], opts.html_sample, filenames)
48 val = SimpleValidation([sample], opts.outputDir[0])
50 val = SeparateValidation([sample], opts.outputDir[0])
51 htmlReport = val.createHtmlReport(validationName=opts.html_validation_name[0])
55 hgclayclus = [hgcalPlots.hgcalLayerClustersPlotter]
57 val.doPlots(hgclayclus, plotterDrawArgs=drawArgs)
61 hgcsimclus = [hgcalPlots.hgcalSimClustersPlotter]
62 for i_iter
in simClustersIters:
64 val.doPlots(hgcsimclus, plotterDrawArgs=drawArgs)
68 hgctrackster = [hgcalPlots.hgcalTrackstersPlotter]
69 for tracksterCollection
in trackstersIters :
71 val.doPlots(hgctrackster, plotterDrawArgs=drawArgs)
76 for tracksterCollection
in trackstersIters :
78 val.doPlots(hgctracksters, plotterDrawArgs=drawArgs)
82 particletypes = {
"pion-":
"-211",
"pion+":
"211",
"pion0":
"111",
83 "muon-":
"-13",
"muon+":
"13",
84 "electron-":
"-11",
"electron+":
"11",
"photon":
"22",
85 "kaon0L":
"310",
"kaon0S":
"130",
86 "kaon-":
"-321",
"kaon+":
"321"}
87 hgcaloPart = [hgcalPlots.hgcalCaloParticlesPlotter]
88 for i_part, i_partID
in particletypes.items() :
90 val.doPlots(hgcaloPart, plotterDrawArgs=drawArgs)
94 hgchit = [hgcalPlots.hgcalHitPlotter]
98 val.doPlots(hgchit, plotterDrawArgs=drawArgs)
102 hgchitcalib = [hgcalPlots.hgcalHitCalibPlotter]
103 val.doPlots(hgchitcalib, plotterDrawArgs=drawArgs)
106 plotDict = {hitCalLabel:[plot_hitCal], hitValLabel:[plot_hitVal], layerClustersLabel:[plot_LC], trackstersLabel:[plot_Tst], trackstersWithEdgesLabel:[plot_TstEdges], simLabel:[plot_SC, plot_CP]}
108 if (opts.collection != allLabel):
109 for task
in plotDict[opts.collection]:
112 for label
in plotDict:
113 if (label == trackstersLabel):
continue
114 for task
in plotDict[label]:
118 print(
"Plots created into directory '%s'." % opts.outputDir)
122 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)))
124 if __name__ ==
"__main__":
125 parser = argparse.ArgumentParser(description=
"Create set of HGCal validation plots from one or more DQM files.")
126 parser.add_argument(
"files", metavar=
"file", type=str, nargs=
"+",
127 default =
"DQM_V0001_R000000001__Global__CMSSW_X_Y_Z__RECO.root",
128 help=
"DQM file to plot the validation plots from")
129 parser.add_argument(
"-o",
"--outputDir", type=str, default=[
"plots1",
"plots2"], nargs=
"+",
130 help=
"Plot output directories (default: 'plots1'")
131 parser.add_argument(
"--subdirprefix", type=str, default=[
"plots1",
"plots2"], nargs=
"+",
132 help=
"Prefix for subdirectories inside outputDir (default: 'plots1')")
133 parser.add_argument(
"--no-ratio", action=
"store_true", default =
False,
134 help=
"Disable ratio pads")
135 parser.add_argument(
"--separate", action=
"store_true", default =
False,
136 help=
"Save all plots separately instead of grouping them")
137 parser.add_argument(
"--png", action=
"store_true",
138 help=
"Save plots in PNG instead of PDF")
139 parser.add_argument(
"--no-html", action=
"store_true", default =
False,
140 help=
"Disable HTML page generation")
141 parser.add_argument(
"--html-sample", default=
"Sample",
142 help=
"Sample name for HTML page generation (default 'Sample')")
143 parser.add_argument(
"--html-validation-name", type=str, default=[
"",
""], nargs=
"+",
144 help=
"Validation name for HTML page generation (enters to <title> element) (default '')")
145 parser.add_argument(
"--collection", choices=collection_choices, default=layerClustersLabel,
146 help=
"Choose output plots collections among possible choices")
147 parser.add_argument(
"--extended", action=
"store_true", default =
False,
148 help=
"Include extended set of plots (e.g. bunch of distributions; default off)")
149 parser.add_argument(
"--verbose", action=
"store_true", default =
False,
152 opts = parser.parse_args()
155 if not os.path.exists(f):
156 parser.error(
"DQM file %s does not exist" % f)
def append_hgcalSimClustersPlots
def append_hgcalDigisPlots
def append_hgcalCaloParticlesPlots
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def append_hgcalTrackstersPlots
static std::string join(char **cmd)
def create_hgcalTrackstersPlotter
def append_hgcalHitsPlots
def append_hgcalLayerClustersPlots