Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:40:24

0001 import os
0002 from . import configTemplates
0003 from . import globalDictionaries
0004 from .genericValidation import GenericValidationData, ValidationWithPlots, pythonboolstring
0005 from .helperFunctions import replaceByMap
0006 from .TkAlExceptions import AllInOneError
0007 
0008 class PrimaryVertexResolution(GenericValidationData, ValidationWithPlots):
0009     configBaseName  = "TkAlPrimaryVertexResolution"
0010     scriptBaseName  = "TkAlPrimaryVertexResolution"
0011     crabCfgBaseName = "TkAlPrimaryVertexResolution"
0012     resultBaseName  = "PrimaryVertexResolution"
0013     outputBaseName  = "PrimaryVertexResolution"
0014     defaults = {
0015         # N.B.: the reference needs to be updated each time the format of the output is changed
0016         "pvresolutionreference": ("/store/group/alca_trackeralign/validation/PVResolution/Reference/PrimaryVertexResolution_phaseIMC92X_upgrade2017_Ideal.root"),
0017         "multiIOV":"False",
0018         "startScale":"1.",
0019         "endScale":"1000.",
0020         "nTracksBins":"60.",
0021         "nVtxBins":"40."
0022     }
0023     #mandatories = {"isda","ismc","runboundary","trackcollection","vertexcollection","lumilist","ptCut","etaCut","runControl","numberOfBins"}
0024     mandatories = {"runControl","runboundary","doTriggerSelection","triggerBits","trackcollection"}
0025     valType = "pvresolution"
0026     def __init__(self, valName, alignment, config):
0027         super(PrimaryVertexResolution, self).__init__(valName, alignment, config)
0028 
0029         if self.general["pvresolutionreference"].startswith("/store"):
0030             self.general["pvresolutionreference"] = "root://eoscms//eos/cms" + self.general["pvresolutionreference"]
0031         if self.NJobs > 1:
0032             raise AllInOneError("Parallel jobs not implemented for the SplotVertexResolution validation!\n"
0033                                 "Please set parallelJobs = 1.")
0034     @property
0035     def ValidationTemplate(self):
0036         return configTemplates.PrimaryVertexResolutionTemplate
0037 
0038     @property
0039     def TrackSelectionRefitting(self):
0040         return configTemplates.SingleTrackRefitter
0041 
0042     @property
0043     def DefinePath(self):
0044         return configTemplates.PVResolutionPath
0045 
0046     @property
0047     def ValidationSequence(self):
0048         #never enters anywhere, since we use the custom DefinePath which includes the goodVertexSkim
0049         return ""
0050 
0051     @property
0052     def ProcessName(self):
0053         return "PrimaryVertexResolution"
0054 
0055     def createScript(self, path):
0056         return super(PrimaryVertexResolution, self).createScript(path, template = configTemplates.PVResolutionScriptTemplate)
0057 
0058     def createCrabCfg(self, path):
0059         return super(PrimaryVertexResolution, self).createCrabCfg(path, self.crabCfgBaseName)
0060 
0061     def getRepMap(self, alignment = None):
0062         if alignment == None:
0063             alignment = self.alignmentToValidate
0064         repMap = super(PrimaryVertexResolution, self).getRepMap(alignment)
0065         repMap.update({
0066             "nEvents": self.general["maxevents"],
0067             "TrackCollection": self.general["trackcollection"],
0068             "eosdir": os.path.join(self.general["eosdir"]),
0069             #"eosdir": os.path.join(self.general["eosdir"], "%s/%s/%s" % (self.outputBaseName, self.name, alignment.name)),
0070             "workingdir": ".oO[datadir]Oo./%s/%s/%s" % (self.outputBaseName, self.name, alignment.name),
0071             "plotsdir": ".oO[datadir]Oo./%s/%s/%s/plots" % (self.outputBaseName, self.name, alignment.name),
0072             })
0073 
0074         return repMap
0075 
0076     def appendToMerge(self):
0077         """
0078         if no argument or "" is passed a string with an instantiation is returned,
0079         else the validation is appended to the list
0080         """
0081         repMap = self.getRepMap()
0082 
0083         parameters = " ".join(os.path.join("root://eoscms//eos/cms", file.lstrip("/")) for file in repMap["resultFiles"])
0084 
0085         mergedoutputfile = os.path.join("root://eoscms//eos/cms", repMap["finalResultFile"].lstrip("/"))
0086         return "hadd -f %s %s\n" % (mergedoutputfile, parameters)
0087 
0088     def appendToPlots(self):
0089         repMap = self.getRepMap()
0090         return (' PVResolution::loadFileList("root://eoscms//eos/cms%(finalResultFile)s",'
0091                 '"PrimaryVertexResolution","%(title)s", %(color)s, %(style)s);\n')%repMap
0092 
0093     @classmethod
0094     def runPlots(cls, validations):
0095         return configTemplates.PVResolutionPlotExecution
0096 
0097     @classmethod
0098     def plottingscriptname(cls):
0099         return "TkAlPrimaryVertexResolutionPlot.C"
0100 
0101     @classmethod
0102     def plottingscripttemplate(cls):
0103         return configTemplates.PVResolutionPlotTemplate
0104 
0105     @classmethod
0106     def plotsdirname(cls):
0107         return "PrimaryVertexResolution"