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"]
17 hitCalLabel =
'hitCalibration' 18 hitValLabel =
'hitValidation' 19 layerClustersLabel =
'layerClusters' 20 trackstersLabel =
'tracksters' 21 trackstersWithEdgesLabel =
'trackstersWithEdges' 22 candidatesLabel =
'candidates' 23 simLabel =
'simulation' 27 collection_choices = [allLabel]
28 collection_choices.extend([hitCalLabel]+[hitValLabel]+[layerClustersLabel]+[trackstersLabel]+[trackstersWithEdgesLabel]+[candidatesLabel]+[simLabel])
36 drawArgs[
"ratio"] =
False 38 drawArgs[
"separate"] =
True 40 drawArgs[
"saveFormat"] =
".png" 44 plotting.verbose =
True 48 filenames = [(f, f.replace(
".root",
""))
for f
in opts.files]
49 sample = SimpleSample(opts.subdirprefix[0], opts.html_sample, filenames)
51 val = SimpleValidation([sample], opts.outputDir[0], nProc=opts.jobs)
53 val = SeparateValidation([sample], opts.outputDir[0])
54 htmlReport = val.createHtmlReport(validationName=opts.html_validation_name[0])
56 if (ticlVersion == 5):
57 trackstersIters = ticlIterLabels_v5.copy()
58 trackstersIters.extend([
'ticlTracksterLinksSuperclusteringDNN',
'ticlTracksterLinksSuperclusteringMustache'])
60 trackstersIters = ticlIterLabels.copy()
61 trackstersIters.extend([
'ticlSimTracksters',
'ticlSimTracksters_fromCPs'])
64 hgclayclus = [hgcalPlots.hgcalLayerClustersPlotter]
66 val.doPlots(hgclayclus, plotterDrawArgs=drawArgs)
70 hgcsimclus = [hgcalPlots.hgcalSimClustersPlotter]
71 for i_iter
in simClustersIters:
73 val.doPlots(hgcsimclus, plotterDrawArgs=drawArgs)
78 hgctrackster = [hgcalPlots.hgcalTrackstersPlotter]
79 for tracksterCollection
in trackstersIters :
80 print(
"Searching for tracksters collection in DQM files: ", tracksterCollection)
83 val.doPlots(hgctrackster, plotterDrawArgs=drawArgs)
88 for tracksterCollection
in trackstersIters :
90 val.doPlots(hgctracksters, plotterDrawArgs=drawArgs)
94 particletypes = {
"pion-":
"-211",
"pion+":
"211",
"pion0":
"111",
95 "muon-":
"-13",
"muon+":
"13",
96 "electron-":
"-11",
"electron+":
"11",
"photon":
"22",
97 "kaon0L":
"310",
"kaon0S":
"130",
98 "kaon-":
"-321",
"kaon+":
"321"}
99 hgcaloPart = [hgcalPlots.hgcalCaloParticlesPlotter]
100 for i_part, i_partID
in particletypes.items() :
102 val.doPlots(hgcaloPart, plotterDrawArgs=drawArgs)
106 hgchit = [hgcalPlots.hgcalHitPlotter]
110 val.doPlots(hgchit, plotterDrawArgs=drawArgs)
114 hgchitcalib = [hgcalPlots.hgcalHitCalibPlotter]
115 val.doPlots(hgchitcalib, plotterDrawArgs=drawArgs)
118 ticlcand = [hgcalPlots.hgcalTICLCandPlotter]
119 val.doPlots(ticlcand, plotterDrawArgs=drawArgs)
121 plotDict = {hitCalLabel:[plot_hitCal], hitValLabel:[plot_hitVal], layerClustersLabel:[plot_LC], trackstersLabel:[plot_Tst], trackstersWithEdgesLabel:[plot_TstEdges], simLabel:[plot_SC, plot_CP], candidatesLabel:[plotCand]}
123 if (opts.collection != allLabel):
124 for task
in plotDict[opts.collection]:
127 for label
in plotDict:
128 if (label == trackstersLabel):
continue 129 for task
in plotDict[label]:
133 print(
"Plots created into directory '%s'." % opts.outputDir)
137 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)))
139 if __name__ ==
"__main__":
140 parser = argparse.ArgumentParser(description=
"Create set of HGCal validation plots from one or more DQM files.")
141 parser.add_argument(
"files", metavar=
"file", type=str, nargs=
"+",
142 default =
"DQM_V0001_R000000001__Global__CMSSW_X_Y_Z__RECO.root",
143 help=
"DQM file to plot the validation plots from")
144 parser.add_argument(
"-o",
"--outputDir", type=str, default=[
"plots1",
"plots2"], nargs=
"+",
145 help=
"Plot output directories (default: 'plots1'")
146 parser.add_argument(
"--subdirprefix", type=str, default=[
"plots1",
"plots2"], nargs=
"+",
147 help=
"Prefix for subdirectories inside outputDir (default: 'plots1')")
148 parser.add_argument(
"--no-ratio", action=
"store_true", default =
False,
149 help=
"Disable ratio pads")
150 parser.add_argument(
"--separate", action=
"store_true", default =
False,
151 help=
"Save all plots separately instead of grouping them")
152 parser.add_argument(
"--png", action=
"store_true", default =
True,
153 help=
"Save plots in PNG instead of PDF")
154 parser.add_argument(
"--no-html", action=
"store_true", default =
False,
155 help=
"Disable HTML page generation")
156 parser.add_argument(
"--html-sample", default=os.environ[
'CMSSW_VERSION'],
157 help=
"Sample name for HTML page generation (default: CMSSW version)")
158 parser.add_argument(
"--html-validation-name", type=str, default=[
"TICL Validation",
""], nargs=
"+",
159 help=
"Validation name for HTML page generation (enters to <title> element) (default 'TICL Validation')")
160 parser.add_argument(
"--collection", choices=collection_choices, default=layerClustersLabel,
161 help=
"Choose output plots collections among possible choices")
162 parser.add_argument(
"--extended", action=
"store_true", default =
False,
163 help=
"Include extended set of plots (e.g. bunch of distributions; default off)")
164 parser.add_argument(
"--jobs", default=0, type=int,
165 help=
"Number of jobs to run in parallel for generating plots. Default is 0 i.e. run number of cpu cores jobs.")
166 parser.add_argument(
"--ticlv", choices=ticlVersions, default=4, type=int,
167 help=
"TICL Version. Specify 4 or 5. Default 4.")
168 parser.add_argument(
"--verbose", action=
"store_true", default =
False,
171 opts = parser.parse_args()
174 if not os.path.exists(f):
175 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)