1 from __future__
import absolute_import
2 from builtins
import range
6 from .
import globalDictionaries
7 from .
import configTemplates
9 from .genericValidation
import ValidationMetaClass, ValidationWithComparison, ValidationWithPlots
10 from .helperFunctions
import getCommandOutput2, replaceByMap, cppboolstring
11 from .offlineValidation
import OfflineValidation
12 from .primaryVertexValidation
import PrimaryVertexValidation
13 from .primaryVertexResolution
import PrimaryVertexResolution
14 from .TkAlExceptions
import AllInOneError
15 from .trackSplittingValidation
import TrackSplittingValidation
16 from .zMuMuValidation
import ZMuMuValidation
17 from .overlapValidation
import OverlapValidation
18 from six
import with_metaclass
22 "cmssw" : os.environ[
"CMSSW_BASE"],
23 "publicationstatus" :
"",
25 "customrighttitle" :
"",
28 "legendoptions":
"all",
31 needpackages = {
"Alignment/OfflineValidation"}
39 theUpdate = config.getResultingSection(
"plots:"+self.
type,
46 for character
in badcharacters:
47 if character
in self.
cmssw:
48 raise AllInOneError(
"The bad characters " + badcharacters +
" are not allowed in the cmssw\n"
49 "path name. If you really have it in such a ridiculously named location,\n"
50 "try making a symbolic link somewhere with a decent name.")
52 os.listdir(self.
cmssw)
56 if self.
cmssw == os.environ[
"CMSSW_BASE"]:
60 command = (
"cd '" + self.
cmssw +
"' && eval `scramv1 ru -sh 2> /dev/null`"
61 ' && echo "$CMSSW_BASE\n$SCRAM_ARCH\n$CMSSW_RELEASE_BASE"')
63 self.
cmssw = commandoutput[0]
69 pkgpath = os.path.join(placetolook,
"src", package)
70 if os.path.exists(pkgpath):
79 if not self.
general[
"publicationstatus"]
and not self.
general[
"customtitle"]:
80 self.
general[
"publicationstatus"] =
"INTERNAL"
81 if self.
general[
"customtitle"]
and not self.
general[
"publicationstatus"]:
82 self.
general[
"publicationstatus"] =
"CUSTOM"
84 if self.
general[
"publicationstatus"] !=
"CUSTOM" and self.
general[
"customtitle"]:
85 raise AllInOneError(
"If you would like to use a custom title, please leave out the 'publicationstatus' parameter")
86 if self.
general[
"publicationstatus"] ==
"CUSTOM" and not self.
general[
"customtitle"]:
87 raise AllInOneError(
"If you want to use a custom title, you should provide it using 'customtitle' in the [plots:%s] section" % valType)
89 if self.
general[
"era"] !=
"NONE" and self.
general[
"customrighttitle"]:
90 raise AllInOneError(
"If you would like to use a custom right title, please leave out the 'era' parameter")
92 publicationstatusenum = [
"INTERNAL",
"INTERNAL_SIMULATION",
"PRELIMINARY",
"PUBLIC",
"SIMULATION",
"UNPUBLISHED",
"CUSTOM"]
93 eraenum = [
"NONE",
"CRUZET15",
"CRAFT15",
"COLL0T15"]
94 if self.
general[
"publicationstatus"]
not in publicationstatusenum:
95 raise AllInOneError(
"Publication status must be one of " +
", ".
join(publicationstatusenum) +
"!")
96 if self.
general[
"era"]
not in eraenum:
101 config.checkInput(
"plots:"+self.
type,
102 knownSimpleOptions = knownOpts,
103 ignoreOptions = ignoreOpts)
108 "workdir": os.path.join(self.
general[
"workdir"],
110 "datadir": self.
general[
"datadir"],
111 "logdir": self.
general[
"logdir"],
112 "CMSSW_BASE": self.
cmssw,
115 "validationId": self.validationclass.__name__,
117 if issubclass(self.validationclass, ValidationWithPlots):
118 result[
"plottingscriptname"] = self.validationclass.plottingscriptname()
119 result[
"plottingscriptpath"] =
".oO[scriptsdir]Oo./.oO[plottingscriptname]Oo."
120 result[
"PlotsDirName"] = self.validationclass.plotsdirname()
121 if issubclass(self.validationclass, ValidationWithComparison):
122 result[
"compareAlignmentsPath"] = self.validationclass.comparealignmentspath()
123 result[
"compareAlignmentsName"] = self.validationclass.comparealignmentsname()
128 "outliercut":
"-1.0",
129 "subdetector":
"none",
131 needpackages = {
"Alignment/CommonAlignmentProducer"}
132 validationclass = TrackSplittingValidation
134 super(PlottingOptionsTrackSplitting, self).
__init__(config,
"split")
136 if self.
general[
"subdetector"]
not in validsubdets:
137 raise AllInOneError(
"'%s' is not a valid subdetector!\n" % self.
general[
"subdetector"] +
"The options are: " +
", ".
join(validsubdets))
140 filename =
replaceByMap(
".oO[Alignment/CommonAlignmentProducer]Oo./python/AlignmentTrackSelector_cfi.py", self.
getRepMap())
141 with open(filename)
as f:
142 trackselector = f.read()
144 minhitspersubdet = trackselector.split(
"minHitsPerSubDet")[1].
split(
"(",1)[1]
148 for character
in minhitspersubdet:
150 parenthesesdepth += 1
152 parenthesesdepth -= 1
153 if parenthesesdepth < 0:
156 minhitspersubdet = minhitspersubdet[0:i]
158 results = minhitspersubdet.split(
",")
160 for i
in range(len(results)):
163 results.append(
"none")
165 return [a
for a
in results
if a]
170 "switchONfit":
"false",
175 "AutoSetRange":
"false",
177 needpackages = {
"MuonAnalysis/MomentumScaleCalibration"}
178 validationclass = ZMuMuValidation
180 super(PlottingOptionsZMuMu, self).
__init__(config,
"zmumu")
185 "DMRMethod":
"median,rmsNorm",
188 "OfflineTreeBaseDir":
"TrackHitFilter",
189 "SurfaceShapes":
"coarse",
191 "mergeOfflineParJobsScriptPath":
".oO[scriptsdir]Oo./TkAlOfflineJobsMerge.C",
192 "usefit":
"false",
"moduleid":
""
194 validationclass = OfflineValidation
196 super(PlottingOptionsOffline, self).
__init__(config,
"offline")
197 for name
in "usefit",
"bigtext":
203 "autoLimits":
"false",
205 "stdResiduals":
"true",
210 "m_dxyPhiNormMax":
"0.5",
211 "m_dzPhiNormMax":
"0.5",
212 "m_dxyEtaNormMax":
"0.5",
213 "m_dzEtaNormMax":
"0.5",
218 "w_dxyPhiNormMax":
"1.8",
219 "w_dzPhiNormMax":
"1.8",
220 "w_dxyEtaNormMax":
"1.8",
221 "w_dzEtaNormMax":
"1.8",
223 validationclass = PrimaryVertexValidation
225 super(PlottingOptionsPrimaryVertex, self).
__init__(config,
"primaryvertex")
226 for name
in "autoLimits",
"doMaps",
"stdResiduals":
230 validationclass = OverlapValidation
232 super(PlottingOptionsOverlap, self).
__init__(config,
"overlap")
236 validationclass = PrimaryVertexResolution
238 super(PlottingOptionsPVResolution, self).
__init__(config,
"pvresolution")
241 plottingOptionsClasses = {
242 "offline": PlottingOptionsOffline,
243 "split": PlottingOptionsTrackSplitting,
244 "zmumu": PlottingOptionsZMuMu,
245 "primaryvertex": PlottingOptionsPrimaryVertex,
246 "overlap": PlottingOptionsOverlap,
247 "pvresolution": PlottingOptionsPVResolution,
249 if isinstance(valType, type):
250 valType = valType.valType
252 if valType
not in globalDictionaries.plottingOptions:
254 raise ValueError(
"Have to provide a config the first time you call PlottingOptions for {}".
format(valType))
255 globalDictionaries.plottingOptions[valType] = plottingOptionsClasses[valType](config)
256 return globalDictionaries.plottingOptions[valType].getRepMap()