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
21 "cmssw" : os.environ[
"CMSSW_BASE"],
22 "publicationstatus" :
"",
24 "customrighttitle" :
"",
27 "legendoptions":
"all",
30 needpackages = {
"Alignment/OfflineValidation"}
38 theUpdate = config.getResultingSection(
"plots:"+self.
type,
45 for character
in badcharacters:
46 if character
in self.
cmssw:
47 raise AllInOneError(
"The bad characters " + badcharacters +
" are not allowed in the cmssw\n" 48 "path name. If you really have it in such a ridiculously named location,\n" 49 "try making a symbolic link somewhere with a decent name.")
51 os.listdir(self.
cmssw)
55 if self.
cmssw == os.environ[
"CMSSW_BASE"]:
59 command = (
"cd '" + self.
cmssw +
"' && eval `scramv1 ru -sh 2> /dev/null`" 60 ' && echo "$CMSSW_BASE\n$SCRAM_ARCH\n$CMSSW_RELEASE_BASE"')
62 self.
cmssw = commandoutput[0]
68 pkgpath = os.path.join(placetolook,
"src", package)
69 if os.path.exists(pkgpath):
75 self.
general[
"publicationstatus"] = self.
general[
"publicationstatus"].upper()
78 if not self.
general[
"publicationstatus"]
and not self.
general[
"customtitle"]:
79 self.
general[
"publicationstatus"] =
"INTERNAL" 80 if self.
general[
"customtitle"]
and not self.
general[
"publicationstatus"]:
81 self.
general[
"publicationstatus"] =
"CUSTOM" 83 if self.
general[
"publicationstatus"] !=
"CUSTOM" and self.
general[
"customtitle"]:
84 raise AllInOneError(
"If you would like to use a custom title, please leave out the 'publicationstatus' parameter")
85 if self.
general[
"publicationstatus"] ==
"CUSTOM" and not self.
general[
"customtitle"]:
86 raise AllInOneError(
"If you want to use a custom title, you should provide it using 'customtitle' in the [plots:%s] section" % valType)
88 if self.
general[
"era"] !=
"NONE" and self.
general[
"customrighttitle"]:
89 raise AllInOneError(
"If you would like to use a custom right title, please leave out the 'era' parameter")
91 publicationstatusenum = [
"INTERNAL",
"INTERNAL_SIMULATION",
"PRELIMINARY",
"PUBLIC",
"SIMULATION",
"UNPUBLISHED",
"CUSTOM"]
92 eraenum = [
"NONE",
"CRUZET15",
"CRAFT15",
"COLL0T15"]
93 if self.
general[
"publicationstatus"]
not in publicationstatusenum:
94 raise AllInOneError(
"Publication status must be one of " +
", ".
join(publicationstatusenum) +
"!")
95 if self.
general[
"era"]
not in eraenum:
100 config.checkInput(
"plots:"+self.
type,
101 knownSimpleOptions = knownOpts,
102 ignoreOptions = ignoreOpts)
107 "workdir": os.path.join(self.
general[
"workdir"],
109 "datadir": self.
general[
"datadir"],
110 "logdir": self.
general[
"logdir"],
111 "CMSSW_BASE": self.
cmssw,
114 "validationId": self.validationclass.__name__,
116 if issubclass(self.validationclass, ValidationWithPlots):
117 result[
"plottingscriptname"] = self.validationclass.plottingscriptname()
118 result[
"plottingscriptpath"] =
".oO[scriptsdir]Oo./.oO[plottingscriptname]Oo." 119 result[
"PlotsDirName"] = self.validationclass.plotsdirname()
120 if issubclass(self.validationclass, ValidationWithComparison):
121 result[
"compareAlignmentsPath"] = self.validationclass.comparealignmentspath()
122 result[
"compareAlignmentsName"] = self.validationclass.comparealignmentsname()
127 "outliercut":
"-1.0",
128 "subdetector":
"none",
130 needpackages = {
"Alignment/CommonAlignmentProducer"}
131 validationclass = TrackSplittingValidation
133 super(PlottingOptionsTrackSplitting, self).
__init__(config,
"split")
135 if self.
general[
"subdetector"]
not in validsubdets:
136 raise AllInOneError(
"'%s' is not a valid subdetector!\n" % self.
general[
"subdetector"] +
"The options are: " +
", ".
join(validsubdets))
139 filename =
replaceByMap(
".oO[Alignment/CommonAlignmentProducer]Oo./python/AlignmentTrackSelector_cfi.py", self.
getRepMap())
140 with open(filename)
as f:
141 trackselector = f.read()
143 minhitspersubdet = trackselector.split(
"minHitsPerSubDet")[1].
split(
"(",1)[1]
147 for character
in minhitspersubdet:
149 parenthesesdepth += 1
151 parenthesesdepth -= 1
152 if parenthesesdepth < 0:
155 minhitspersubdet = minhitspersubdet[0:i]
157 results = minhitspersubdet.split(
",")
159 for i
in range(len(results)):
162 results.append(
"none")
164 return [a
for a
in results
if a]
169 "switchONfit":
"false",
174 "AutoSetRange":
"false",
176 needpackages = {
"MuonAnalysis/MomentumScaleCalibration"}
177 validationclass = ZMuMuValidation
179 super(PlottingOptionsZMuMu, self).
__init__(config,
"zmumu")
184 "DMRMethod":
"median,rmsNorm",
187 "OfflineTreeBaseDir":
"TrackHitFilter",
188 "SurfaceShapes":
"coarse",
190 "mergeOfflineParJobsScriptPath":
".oO[scriptsdir]Oo./TkAlOfflineJobsMerge.C",
191 "usefit":
"false",
"moduleid":
"" 193 validationclass = OfflineValidation
195 super(PlottingOptionsOffline, self).
__init__(config,
"offline")
196 for name
in "usefit",
"bigtext":
202 "autoLimits":
"false",
204 "stdResiduals":
"true",
209 "m_dxyPhiNormMax":
"0.5",
210 "m_dzPhiNormMax":
"0.5",
211 "m_dxyEtaNormMax":
"0.5",
212 "m_dzEtaNormMax":
"0.5",
217 "w_dxyPhiNormMax":
"1.8",
218 "w_dzPhiNormMax":
"1.8",
219 "w_dxyEtaNormMax":
"1.8",
220 "w_dzEtaNormMax":
"1.8",
222 validationclass = PrimaryVertexValidation
224 super(PlottingOptionsPrimaryVertex, self).
__init__(config,
"primaryvertex")
225 for name
in "autoLimits",
"doMaps",
"stdResiduals":
229 validationclass = OverlapValidation
231 super(PlottingOptionsOverlap, self).
__init__(config,
"overlap")
235 validationclass = PrimaryVertexResolution
237 super(PlottingOptionsPVResolution, self).
__init__(config,
"pvresolution")
240 plottingOptionsClasses = {
241 "offline": PlottingOptionsOffline,
242 "split": PlottingOptionsTrackSplitting,
243 "zmumu": PlottingOptionsZMuMu,
244 "primaryvertex": PlottingOptionsPrimaryVertex,
245 "overlap": PlottingOptionsOverlap,
246 "pvresolution": PlottingOptionsPVResolution,
248 if isinstance(valType, type):
249 valType = valType.valType
251 if valType
not in globalDictionaries.plottingOptions:
253 raise ValueError(
"Have to provide a config the first time you call PlottingOptions for {}".
format(valType))
254 globalDictionaries.plottingOptions[valType] = plottingOptionsClasses[valType](config)
255 return globalDictionaries.plottingOptions[valType].getRepMap()
def __init__(self, config)
def __init__(self, config)
def replace(string, replacements)
def __init__(self, config)
def __init__(self, config)
def getCommandOutput2(command)
def cppboolstring(string, name)
def __init__(self, config, valType)
def PlottingOptions(config, valType)
def replaceByMap(target, the_map)
— Helpers —############################
def split(sequence, size)
static std::string join(char **cmd)
def __init__(self, config)
def __init__(self, config)