CMS 3D CMS Logo

primaryVertexValidation.py
Go to the documentation of this file.
1 import os
2 import configTemplates
3 import globalDictionaries
4 from genericValidation import GenericValidationData
5 from helperFunctions import replaceByMap
6 from TkAlExceptions import AllInOneError
7 
9  def __init__(self, valName, alignment, config,
10  configBaseName = "TkAlPrimaryVertexValidation",
11  scriptBaseName = "TkAlPrimaryVertexValidation",
12  crabCfgBaseName = "TkAlPrimaryVertexValidation",
13  resultBaseName = "PrimaryVertexValidation",
14  outputBaseName = "PrimaryVertexValidation"):
15  defaults = {
16  "pvvalidationreference": ("/store/caf/user/musich/Alignment/TkAlPrimaryVertexValidation/Reference/PrimaryVertexValidation_test_pvvalidation_mc_design_mc_48bins.root"),
17  "ttrhbuilder":"WithAngleAndTemplate",
18  "doBPix":"True",
19  "doFPix":"True"
20  }
21 
22  mandatories = ["isda","ismc","runboundary","trackcollection","vertexcollection","lumilist","ptCut","etaCut","runControl","numberOfBins"]
23  self.configBaseName = configBaseName
24  self.scriptBaseName = scriptBaseName
25  self.crabCfgBaseName = crabCfgBaseName
26  self.resultBaseName = resultBaseName
27  self.outputBaseName = outputBaseName
28  self.needParentFiles = False
29  GenericValidationData.__init__(self, valName, alignment, config,
30  "primaryvertex", addDefaults=defaults,
31  addMandatories=mandatories)
32 
33  if self.general["pvvalidationreference"].startswith("/store"):
34  self.general["pvvalidationreference"] = "root://eoscms//eos/cms" + self.general["pvvalidationreference"]
35  if self.NJobs > 1:
36  raise AllInOneError("Parallel jobs not implemented for the PrimaryVertex validation!\n"
37  "Please set parallelJobs = 1.")
38 
39  def createConfiguration(self, path):
40  cfgName = "%s.%s.%s_cfg.py"%( self.configBaseName, self.name,
41  self.alignmentToValidate.name )
42  repMap = self.getRepMap()
43  cfgs = {cfgName: configTemplates.PrimaryVertexValidationTemplate}
44  self.filesToCompare[GenericValidationData.defaultReferenceName] = \
45  repMap["finalResultFile"]
46  GenericValidationData.createConfiguration(self, cfgs, path, repMap = repMap)
47 
48  def createScript(self, path):
49  return GenericValidationData.createScript(self, path, template = configTemplates.PVValidationScriptTemplate)
50 
51  def createCrabCfg(self, path):
52  return GenericValidationData.createCrabCfg(self, path, self.crabCfgBaseName)
53 
54  def getRepMap(self, alignment = None):
55  if alignment == None:
56  alignment = self.alignmentToValidate
57  repMap = GenericValidationData.getRepMap(self, alignment)
58 
59  repMap.update({
60  "nEvents": self.general["maxevents"],
61  "TrackCollection": self.general["trackcollection"],
62  "VertexCollection": self.general["vertexcollection"],
63  "eosdir": os.path.join(self.general["eosdir"]),
64  #"eosdir": os.path.join(self.general["eosdir"], "%s/%s/%s" % (self.outputBaseName, self.name, alignment.name)),
65  "workingdir": ".oO[datadir]Oo./%s/%s/%s" % (self.outputBaseName, self.name, alignment.name),
66  "plotsdir": ".oO[datadir]Oo./%s/%s/%s/plots" % (self.outputBaseName, self.name, alignment.name),
67  })
68 
69  return repMap
70 
71  def appendToMerge( self, validationsSoFar = "" ):
72  """
73  if no argument or "" is passed a string with an instantiation is returned,
74  else the validation is appended to the list
75  """
76  repMap = self.getRepMap()
77 
78  parameters = " ".join(os.path.join("root://eoscms//eos/cms", file.lstrip("/")) for file in repMap["resultFiles"])
79 
80  mergedoutputfile = os.path.join("root://eoscms//eos/cms", repMap["finalResultFile"].lstrip("/"))
81  validationsSoFar += "hadd -f %s %s\n" % (mergedoutputfile, parameters)
82  return validationsSoFar
83 
84  def appendToExtendedValidation( self, validationsSoFar = "" ):
85  """
86  if no argument or "" is passed a string with an instantiation is
87  returned, else the validation is appended to the list
88  """
89  repMap = self.getRepMap()
90 
91  if validationsSoFar == "":
92  validationsSoFar = (' loadFileList("root://eoscms//eos/cms%(finalResultFile)s",'
93  '"PVValidation","%(title)s", %(color)s, %(style)s);\n')%repMap
94  else:
95  validationsSoFar += (' loadFileList("root://eoscms//eos/cms%(finalResultFile)s",'
96  '"PVValidation","%(title)s", %(color)s, %(style)s);\n')%repMap
97 
98  return validationsSoFar
99 
100 
101  # if validationsSoFar != "":
102  # validationsSoFar += ','
103  # validationsSoFar += "root://eoscms//eos/cms%(finalResultFile)s=%(title)s"%repMap
104  # else:
105  # validationsSoFar += "root://eoscms//eos/cms%(finalResultFile)s=%(title)s"%repMap
106  # return validationsSoFar
107 
def appendToExtendedValidation(self, validationsSoFar="")
def __init__(self, valName, alignment, config, configBaseName="TkAlPrimaryVertexValidation", scriptBaseName="TkAlPrimaryVertexValidation", crabCfgBaseName="TkAlPrimaryVertexValidation", resultBaseName="PrimaryVertexValidation", outputBaseName="PrimaryVertexValidation")
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def getRepMap(self, alignment=None)