File indexing completed on 2023-03-17 10:40:24
0001 from __future__ import absolute_import
0002 import os
0003 from .genericValidation import GenericValidation, GenericValidationData
0004 from .geometryComparison import GeometryComparison
0005 from .helperFunctions import boolfromstring, getCommandOutput2, parsecolor, parsestyle
0006 from .monteCarloValidation import MonteCarloValidation
0007 from .offlineValidation import OfflineValidation
0008 from .primaryVertexValidation import PrimaryVertexValidation
0009 from .plottingOptions import PlottingOptions
0010 from .TkAlExceptions import AllInOneError
0011 from .trackSplittingValidation import TrackSplittingValidation
0012 from .zMuMuValidation import ZMuMuValidation
0013
0014 class PreexistingValidation(GenericValidation):
0015 """
0016 Object representing a validation that has already been run,
0017 but should be included in plots.
0018 """
0019 defaults = {"title": ".oO[name]Oo."}
0020 mandatories = {"file", "color", "style", "originalValName", "eosdirName", "multiIOV"}
0021 removemandatories = {"dataset", "maxevents", "trackcollection"}
0022 def __init__(self, valName, config):
0023 self.general = config.getGeneral()
0024 self.name = self.general["name"] = valName
0025 self.config = config
0026
0027 theUpdate = config.getResultingSection("preexisting"+self.valType+":"+self.name,
0028 defaultDict = self.defaults,
0029 demandPars = self.mandatories)
0030 self.general.update(theUpdate)
0031
0032 self.originalValName = self.general["originalValName"]
0033 self.title = self.general["title"]
0034 if "|" in self.title or "," in self.title or '"' in self.title:
0035 msg = "The characters '|', '\"', and ',' cannot be used in the alignment title!"
0036 raise AllInOneError(msg)
0037 self.needsproxy = boolfromstring(self.general["needsproxy"], "needsproxy")
0038 self.jobid = self.general["jobid"]
0039 if self.jobid:
0040 try:
0041 output = getCommandOutput2("bjobs %(jobid)s 2>&1"%self.general)
0042 if "is not found" in output: raise RuntimeError
0043 except RuntimeError:
0044 raise AllInOneError("%s is not a valid jobid.\nMaybe it finished already?"%self.jobid)
0045
0046 knownOpts = set(self.defaults.keys())|self.mandatories|self.optionals
0047 ignoreOpts = []
0048 config.checkInput("preexisting"+self.valType+":"+self.name,
0049 knownSimpleOptions = knownOpts,
0050 ignoreOptions = ignoreOpts)
0051 self.jobmode = None
0052
0053 try:
0054 result = PlottingOptions(self.config, self.valType)
0055 except KeyError:
0056 pass
0057
0058 @property
0059 def filesToCompare(self):
0060 return {self.defaultReferenceName: self.general["file"]}
0061
0062 def getRepMap(self):
0063
0064 try:
0065 result = PlottingOptions(self.config, self.valType)
0066 except KeyError:
0067 result = {}
0068 result.update(self.general)
0069 result.update({
0070 "color": str(parsecolor(result["color"])),
0071 "style": str(parsestyle(result["style"])),
0072 })
0073 return result
0074
0075 def createFiles(self, *args, **kwargs):
0076 raise AllInOneError("Shouldn't be here...")
0077 def createConfiguration(self, *args, **kwargs):
0078 pass
0079 def createScript(self, *args, **kwargs):
0080 raise AllInOneError("Shouldn't be here...")
0081 def createCrabCfg(self, *args, **kwargs):
0082 raise AllInOneError("Shouldn't be here...")
0083
0084 class PreexistingOfflineValidation(PreexistingValidation, OfflineValidation):
0085 deprecateddefaults = {
0086 "DMRMethod":"",
0087 "DMRMinimum":"",
0088 "DMROptions":"",
0089 "OfflineTreeBaseDir":"",
0090 "SurfaceShapes":""
0091 }
0092 defaults = deprecateddefaults.copy()
0093 def __init__(self, valName, config):
0094 super(PreexistingOfflineValidation, self).__init__(valName, config)
0095 for option in self.deprecateddefaults:
0096 if self.general[option]:
0097 raise AllInOneError("The '%s' option has been moved to the [plots:offline] section. Please specify it there."%option)
0098
0099 def getRepMap(self):
0100 result = super(PreexistingOfflineValidation, self).getRepMap()
0101 result.update({
0102 "filetoplot": self.general["file"],
0103 })
0104 return result
0105
0106 def appendToMerge(self, *args, **kwargs):
0107 raise AllInOneError("Shouldn't be here...")
0108
0109 class PreexistingPrimaryVertexValidation(PreexistingValidation, PrimaryVertexValidation):
0110 removemandatories = {"isda","ismc","runboundary","vertexcollection","lumilist","ptCut","etaCut","runControl","numberOfBins"}
0111 def getRepMap(self):
0112 result = super(PreexistingPrimaryVertexValidation, self).getRepMap()
0113 result.update({
0114 "filetoplot": self.general["file"],
0115 })
0116 return result
0117
0118 def appendToMerge(self, *args, **kwargs):
0119 raise AllInOneError("Shouldn't be here...")
0120
0121 class PreexistingTrackSplittingValidation(PreexistingValidation, TrackSplittingValidation):
0122 def appendToMerge(self, *args, **kwargs):
0123 raise AllInOneError("Shouldn't be here...")
0124
0125 class PreexistingMonteCarloValidation(PreexistingValidation):
0126 pass
0127
0128 class PreexistingZMuMuValidation(PreexistingValidation):
0129 def __init__(self, *args, **kwargs):
0130 raise AllInOneError("Preexisting Z->mumu validation not implemented")
0131
0132
0133 class PreexistingGeometryComparison(PreexistingValidation):
0134 def __init__(self, *args, **kwargs):
0135 raise AllInOneError("Preexisting geometry comparison not implemented")