Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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