4 import globalDictionaries
7 from genericValidation
import ValidationMetaClass, ValidationWithComparison, ValidationWithPlots
8 from helperFunctions
import getCommandOutput2, replaceByMap, cppboolstring
9 from offlineValidation
import OfflineValidation
10 from primaryVertexValidation
import PrimaryVertexValidation
11 from TkAlExceptions
import AllInOneError
12 from trackSplittingValidation
import TrackSplittingValidation
13 from zMuMuValidation
import ZMuMuValidation
16 __metaclass__ = ValidationMetaClass
18 "cmssw" : os.environ[
"CMSSW_BASE"],
19 "publicationstatus" :
"",
21 "customrighttitle" :
"",
24 "legendoptions":
"all",
27 needpackages = {
"Alignment/OfflineValidation"}
35 theUpdate = config.getResultingSection(
"plots:"+self.
type,
38 self.general.update(theUpdate)
42 for character
in badcharacters:
43 if character
in self.
cmssw:
44 raise AllInOneError(
"The bad characters " + badcharacters +
" are not allowed in the cmssw\n" 45 "path name. If you really have it in such a ridiculously named location,\n" 46 "try making a symbolic link somewhere with a decent name.")
48 os.listdir(self.
cmssw)
52 if self.
cmssw == os.environ[
"CMSSW_BASE"]:
56 command = (
"cd '" + self.
cmssw +
"' && eval `scramv1 ru -sh 2> /dev/null`" 57 ' && echo "$CMSSW_BASE\n$SCRAM_ARCH\n$CMSSW_RELEASE_BASE"')
59 self.
cmssw = commandoutput[0]
65 pkgpath = os.path.join(placetolook,
"src", package)
66 if os.path.exists(pkgpath):
75 if not self.
general[
"publicationstatus"]
and not self.
general[
"customtitle"]:
76 self.
general[
"publicationstatus"] =
"INTERNAL" 77 if self.
general[
"customtitle"]
and not self.
general[
"publicationstatus"]:
78 self.
general[
"publicationstatus"] =
"CUSTOM" 80 if self.
general[
"publicationstatus"] !=
"CUSTOM" and self.
general[
"customtitle"]:
81 raise AllInOneError(
"If you would like to use a custom title, please leave out the 'publicationstatus' parameter")
82 if self.
general[
"publicationstatus"] ==
"CUSTOM" and not self.
general[
"customtitle"]:
83 raise AllInOneError(
"If you want to use a custom title, you should provide it using 'customtitle' in the [plots:%s] section" % valType)
85 if self.
general[
"era"] !=
"NONE" and self.
general[
"customrighttitle"]:
86 raise AllInOneError(
"If you would like to use a custom right title, please leave out the 'era' parameter")
88 publicationstatusenum = [
"INTERNAL",
"INTERNAL_SIMULATION",
"PRELIMINARY",
"PUBLIC",
"SIMULATION",
"UNPUBLISHED",
"CUSTOM"]
89 eraenum = [
"NONE",
"CRUZET15",
"CRAFT15",
"COLL0T15"]
90 if self.
general[
"publicationstatus"]
not in publicationstatusenum:
91 raise AllInOneError(
"Publication status must be one of " +
", ".
join(publicationstatusenum) +
"!")
92 if self.
general[
"era"]
not in eraenum:
95 knownOpts = set(self.defaults.keys())|self.
mandatories|self.optionals
97 config.checkInput(
"plots:"+self.
type,
98 knownSimpleOptions = knownOpts,
99 ignoreOptions = ignoreOpts)
104 "workdir": os.path.join(self.
general[
"workdir"],
106 "datadir": self.
general[
"datadir"],
107 "logdir": self.
general[
"logdir"],
108 "CMSSW_BASE": self.
cmssw,
111 "validationId": self.validationclass.__name__,
113 if issubclass(self.validationclass, ValidationWithPlots):
114 result[
"plottingscriptname"] = self.validationclass.plottingscriptname()
115 result[
"plottingscriptpath"] =
".oO[scriptsdir]Oo./.oO[plottingscriptname]Oo." 116 result[
"PlotsDirName"] = self.validationclass.plotsdirname()
117 if issubclass(self.validationclass, ValidationWithComparison):
118 result[
"compareAlignmentsPath"] = self.validationclass.comparealignmentspath()
119 result[
"compareAlignmentsName"] = self.validationclass.comparealignmentsname()
124 "outliercut":
"-1.0",
125 "subdetector":
"none",
127 needpackages = {
"Alignment/CommonAlignmentProducer"}
128 validationclass = TrackSplittingValidation
130 super(PlottingOptionsTrackSplitting, self).
__init__(config,
"split")
132 if self.
general[
"subdetector"]
not in validsubdets:
133 raise AllInOneError(
"'%s' is not a valid subdetector!\n" % self.
general[
"subdetector"] +
"The options are: " +
", ".
join(validsubdets))
136 filename =
replaceByMap(
".oO[Alignment/CommonAlignmentProducer]Oo./python/AlignmentTrackSelector_cfi.py", self.
getRepMap())
137 with open(filename)
as f:
138 trackselector = f.read()
140 minhitspersubdet = trackselector.split(
"minHitsPerSubDet")[1].
split(
"(",1)[1]
144 for character
in minhitspersubdet:
146 parenthesesdepth += 1
148 parenthesesdepth -= 1
149 if parenthesesdepth < 0:
152 minhitspersubdet = minhitspersubdet[0:i]
154 results = minhitspersubdet.split(
",")
156 for i
in range(len(results)):
159 results.append(
"none")
161 return [a
for a
in results
if a]
166 "switchONfit":
"false",
172 needpackages = {
"MuonAnalysis/MomentumScaleCalibration"}
173 validationclass = ZMuMuValidation
175 super(PlottingOptionsZMuMu, self).
__init__(config,
"zmumu")
180 "DMRMethod":
"median,rmsNorm",
183 "OfflineTreeBaseDir":
"TrackHitFilter",
184 "SurfaceShapes":
"coarse",
186 "mergeOfflineParJobsScriptPath":
".oO[scriptsdir]Oo./TkAlOfflineJobsMerge.C",
189 validationclass = OfflineValidation
191 super(PlottingOptionsOffline, self).
__init__(config,
"offline")
192 for name
in "usefit",
"bigtext":
198 "autoLimits":
"false",
200 "stdResiduals":
"true",
205 "m_dxyPhiNormMax":
"0.5",
206 "m_dzPhiNormMax":
"0.5",
207 "m_dxyEtaNormMax":
"0.5",
208 "m_dzEtaNormMax":
"0.5",
213 "w_dxyPhiNormMax":
"1.8",
214 "w_dzPhiNormMax":
"1.8",
215 "w_dxyEtaNormMax":
"1.8",
216 "w_dzEtaNormMax":
"1.8",
218 validationclass = PrimaryVertexValidation
220 super(PlottingOptionsPrimaryVertex, self).
__init__(config,
"primaryvertex")
221 for name
in "autoLimits",
"doMaps",
"stdResiduals":
225 plottingOptionsClasses = {
226 "offline": PlottingOptionsOffline,
227 "split": PlottingOptionsTrackSplitting,
228 "zmumu": PlottingOptionsZMuMu,
229 "primaryvertex": PlottingOptionsPrimaryVertex,
231 if isinstance(valType, type):
232 valType = valType.valType
234 if valType
not in globalDictionaries.plottingOptions:
236 raise ValueError(
"Have to provide a config the first time you call PlottingOptions for {}".
format(valType))
237 globalDictionaries.plottingOptions[valType] = plottingOptionsClasses[valType](config)
238 return globalDictionaries.plottingOptions[valType].getRepMap()
def __init__(self, config)
def __init__(self, config)
def replace(string, replacements)
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 —############################
static std::string join(char **cmd)
def __init__(self, config)