CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  }
18 
19  mandatories = ["isda","ismc","runboundary","trackcollection","vertexcollection","lumilist","ptCut","runControl","numberOfBins"]
20  self.configBaseName = configBaseName
21  self.scriptBaseName = scriptBaseName
22  self.crabCfgBaseName = crabCfgBaseName
23  self.resultBaseName = resultBaseName
24  self.outputBaseName = outputBaseName
25  self.needParentFiles = False
26  GenericValidationData.__init__(self, valName, alignment, config,
27  "primaryvertex", addDefaults=defaults,
28  addMandatories=mandatories)
29 
30  if self.general["pvvalidationreference"].startswith("/store"):
31  self.general["pvvalidationreference"] = "root://eoscms//eos/cms" + self.general["pvvalidationreference"]
32  if self.NJobs > 1:
33  raise AllInOneError("Parallel jobs not implemented for the PrimaryVertex validation!\n"
34  "Please set parallelJobs = 1.")
35 
36  def createConfiguration(self, path):
37  cfgName = "%s.%s.%s_cfg.py"%( self.configBaseName, self.name,
38  self.alignmentToValidate.name )
39  repMap = self.getRepMap()
40  cfgs = {cfgName: configTemplates.PrimaryVertexValidationTemplate}
41  self.filesToCompare[GenericValidationData.defaultReferenceName] = \
42  repMap["finalResultFile"]
43  GenericValidationData.createConfiguration(self, cfgs, path, repMap = repMap)
44 
45  def createScript(self, path):
46  return GenericValidationData.createScript(self, path, template = configTemplates.PVValidationScriptTemplate)
47 
48  def createCrabCfg(self, path):
49  return GenericValidationData.createCrabCfg(self, path, self.crabCfgBaseName)
50 
51  def getRepMap(self, alignment = None):
52  if alignment == None:
53  alignment = self.alignmentToValidate
54  repMap = GenericValidationData.getRepMap(self, alignment)
55  repMap.update({
56  "nEvents": self.general["maxevents"],
57  "TrackCollection": self.general["trackcollection"],
58  "VertexCollection": self.general["vertexcollection"],
59  "eosdir": os.path.join(self.general["eosdir"]),
60  #"eosdir": os.path.join(self.general["eosdir"], "%s/%s/%s" % (self.outputBaseName, self.name, alignment.name)),
61  "workingdir": ".oO[datadir]Oo./%s/%s/%s" % (self.outputBaseName, self.name, alignment.name),
62  "plotsdir": ".oO[datadir]Oo./%s/%s/%s/plots" % (self.outputBaseName, self.name, alignment.name),
63  })
64 
65  return repMap
66 
67  def appendToMerge( self, validationsSoFar = "" ):
68  """
69  if no argument or "" is passed a string with an instantiation is returned,
70  else the validation is appended to the list
71  """
72  repMap = self.getRepMap()
73 
74  parameters = " ".join(os.path.join("root://eoscms//eos/cms", file.lstrip("/")) for file in repMap["resultFiles"])
75 
76  mergedoutputfile = os.path.join("root://eoscms//eos/cms", repMap["finalResultFile"].lstrip("/"))
77  validationsSoFar += "hadd -f %s %s\n" % (mergedoutputfile, parameters)
78  return validationsSoFar
79 
80  def appendToExtendedValidation( self, validationsSoFar = "" ):
81  """
82  if no argument or "" is passed a string with an instantiation is
83  returned, else the validation is appended to the list
84  """
85  repMap = self.getRepMap()
86 
87  if validationsSoFar != "":
88  validationsSoFar += ','
89  validationsSoFar += "root://eoscms//eos/cms%(finalResultFile)s=%(title)s"%repMap
90  else:
91  validationsSoFar += "root://eoscms//eos/cms%(finalResultFile)s=%(title)s"%repMap
92  return validationsSoFar
93 
static std::string join(char **cmd)
Definition: RemoteFile.cc:18