3 from __future__
import print_function
8 from Validation.HGCalValidation.PostProcessorHGCAL_cfi
import tracksterLabels
as trackstersIters
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"]
17 hitCalLabel =
'hitCalibration' 18 hitValLabel =
'hitValidation' 19 layerClustersLabel =
'layerClusters' 20 trackstersLabel =
'tracksters' 21 trackstersWithEdgesLabel =
'trackstersWithEdges' 22 candidatesLabel =
'candidates' 23 simLabel =
'simulation' 26 collection_choices = [allLabel]
27 collection_choices.extend([hitCalLabel]+[hitValLabel]+[layerClustersLabel]+[trackstersLabel]+[trackstersWithEdgesLabel]+[candidatesLabel]+[simLabel])
34 drawArgs[
"ratio"] =
False 36 drawArgs[
"separate"] =
True 38 drawArgs[
"saveFormat"] =
".png" 42 plotting.verbose =
True 44 filenames = [(f, f.replace(
".root",
""))
for f
in opts.files]
45 sample = SimpleSample(opts.subdirprefix[0], opts.html_sample, filenames)
47 val = SimpleValidation([sample], opts.outputDir[0], nProc=opts.jobs)
49 val = SeparateValidation([sample], opts.outputDir[0])
50 htmlReport = val.createHtmlReport(validationName=opts.html_validation_name[0])
54 hgclayclus = [hgcalPlots.hgcalLayerClustersPlotter]
56 val.doPlots(hgclayclus, plotterDrawArgs=drawArgs)
60 hgcsimclus = [hgcalPlots.hgcalSimClustersPlotter]
61 for i_iter
in simClustersIters:
63 val.doPlots(hgcsimclus, plotterDrawArgs=drawArgs)
67 hgctrackster = [hgcalPlots.hgcalTrackstersPlotter]
68 for tracksterCollection
in trackstersIters :
70 val.doPlots(hgctrackster, plotterDrawArgs=drawArgs)
75 for tracksterCollection
in trackstersIters :
77 val.doPlots(hgctracksters, plotterDrawArgs=drawArgs)
81 particletypes = {
"pion-":
"-211",
"pion+":
"211",
"pion0":
"111",
82 "muon-":
"-13",
"muon+":
"13",
83 "electron-":
"-11",
"electron+":
"11",
"photon":
"22",
84 "kaon0L":
"310",
"kaon0S":
"130",
85 "kaon-":
"-321",
"kaon+":
"321"}
86 hgcaloPart = [hgcalPlots.hgcalCaloParticlesPlotter]
87 for i_part, i_partID
in particletypes.items() :
89 val.doPlots(hgcaloPart, plotterDrawArgs=drawArgs)
93 hgchit = [hgcalPlots.hgcalHitPlotter]
97 val.doPlots(hgchit, plotterDrawArgs=drawArgs)
101 hgchitcalib = [hgcalPlots.hgcalHitCalibPlotter]
102 val.doPlots(hgchitcalib, plotterDrawArgs=drawArgs)
105 ticlcand = [hgcalPlots.hgcalTICLCandPlotter]
106 val.doPlots(ticlcand, plotterDrawArgs=drawArgs)
108 plotDict = {hitCalLabel:[plot_hitCal], hitValLabel:[plot_hitVal], layerClustersLabel:[plot_LC], trackstersLabel:[plot_Tst], trackstersWithEdgesLabel:[plot_TstEdges], simLabel:[plot_SC, plot_CP], candidatesLabel:[plotCand]}
110 if (opts.collection != allLabel):
111 for task
in plotDict[opts.collection]:
114 for label
in plotDict:
115 if (label == trackstersLabel):
continue 116 for task
in plotDict[label]:
120 print(
"Plots created into directory '%s'." % opts.outputDir)
124 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)))
126 if __name__ ==
"__main__":
127 parser = argparse.ArgumentParser(description=
"Create set of HGCal validation plots from one or more DQM files.")
128 parser.add_argument(
"files", metavar=
"file", type=str, nargs=
"+",
129 default =
"DQM_V0001_R000000001__Global__CMSSW_X_Y_Z__RECO.root",
130 help=
"DQM file to plot the validation plots from")
131 parser.add_argument(
"-o",
"--outputDir", type=str, default=[
"plots1",
"plots2"], nargs=
"+",
132 help=
"Plot output directories (default: 'plots1'")
133 parser.add_argument(
"--subdirprefix", type=str, default=[
"plots1",
"plots2"], nargs=
"+",
134 help=
"Prefix for subdirectories inside outputDir (default: 'plots1')")
135 parser.add_argument(
"--no-ratio", action=
"store_true", default =
False,
136 help=
"Disable ratio pads")
137 parser.add_argument(
"--separate", action=
"store_true", default =
False,
138 help=
"Save all plots separately instead of grouping them")
139 parser.add_argument(
"--png", action=
"store_true", default =
True,
140 help=
"Save plots in PNG instead of PDF")
141 parser.add_argument(
"--no-html", action=
"store_true", default =
False,
142 help=
"Disable HTML page generation")
143 parser.add_argument(
"--html-sample", default=
"Sample",
144 help=
"Sample name for HTML page generation (default 'Sample')")
145 parser.add_argument(
"--html-validation-name", type=str, default=[
"",
""], nargs=
"+",
146 help=
"Validation name for HTML page generation (enters to <title> element) (default '')")
147 parser.add_argument(
"--collection", choices=collection_choices, default=layerClustersLabel,
148 help=
"Choose output plots collections among possible choices")
149 parser.add_argument(
"--extended", action=
"store_true", default =
False,
150 help=
"Include extended set of plots (e.g. bunch of distributions; default off)")
151 parser.add_argument(
"--jobs", default=0, type=int,
152 help=
"Number of jobs to run in parallel for generating plots. Default is 0 i.e. run number of cpu cores jobs.")
153 parser.add_argument(
"--verbose", action=
"store_true", default =
False,
156 opts = parser.parse_args()
159 if not os.path.exists(f):
160 parser.error(
"DQM file %s does not exist" % f)
def append_hgcalHitsPlots(collection="HGCalSimHitsV", name_collection="Simulated Hits")
def append_hgcalTrackstersPlots(collection='ticlTrackstersMerge', name_collection="TrackstersMerge")
def create_hgcalTrackstersPlotter(files, collection='ticlTrackstersMerge', name_collection="TrackstersMerge")
def append_hgcalDigisPlots(collection="HGCalDigisV", name_collection="Digis")
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
static std::string join(char **cmd)
def append_hgcalCaloParticlesPlots(files, collection='-211', name_collection="pion-")
def append_hgcalSimClustersPlots(collection, name_collection)
def append_hgcalLayerClustersPlots(collection=hgcalValidator.label_layerClusterPlots._InputTag__moduleLabel, name_collection=layerClustersLabel, extended=False)