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, ValidationWithPlots, pythonboolstring
5 from helperFunctions import replaceByMap
6 from TkAlExceptions import AllInOneError
7 
9  configBaseName = "TkAlPrimaryVertexValidation"
10  scriptBaseName = "TkAlPrimaryVertexValidation"
11  crabCfgBaseName = "TkAlPrimaryVertexValidation"
12  resultBaseName = "PrimaryVertexValidation"
13  outputBaseName = "PrimaryVertexValidation"
14  defaults = {
15  "pvvalidationreference": ("/store/caf/user/musich/Alignment/TkAlPrimaryVertexValidation/Reference/PrimaryVertexValidation_test_pvvalidation_upgrade2017_design_mc_48bins.root"),
16  "doBPix":"True",
17  "doFPix":"True"
18  }
19  mandatories = {"isda","ismc","runboundary","trackcollection","vertexcollection","lumilist","ptCut","etaCut","runControl","numberOfBins"}
20  valType = "primaryvertex"
21  def __init__(self, valName, alignment, config):
22  super(PrimaryVertexValidation, self).__init__(valName, alignment, config)
23 
24  for name in "doBPix", "doFPix":
25  self.general[name] = pythonboolstring(self.general[name], name)
26 
27  if self.general["pvvalidationreference"].startswith("/store"):
28  self.general["pvvalidationreference"] = "root://eoscms//eos/cms" + self.general["pvvalidationreference"]
29  if self.NJobs > 1:
30  raise AllInOneError("Parallel jobs not implemented for the PrimaryVertex validation!\n"
31  "Please set parallelJobs = 1.")
32 
33  @property
34  def ValidationTemplate(self):
35  return configTemplates.PrimaryVertexValidationTemplate
36 
37  @property
39  return configTemplates.SingleTrackRefitter
40 
41  @property
42  def ProcessName(self):
43  return "PrimaryVertexValidation"
44 
45  @property
46  def DefinePath(self):
47  return configTemplates.PVValidationPath
48 
49  def createScript(self, path):
50  return super(PrimaryVertexValidation, self).createScript(path, template = configTemplates.PVValidationScriptTemplate)
51 
52  def createCrabCfg(self, path):
53  return super(PrimaryVertexValidation, self).createCrabCfg(path, self.crabCfgBaseName)
54 
55  def getRepMap(self, alignment = None):
56  if alignment == None:
57  alignment = self.alignmentToValidate
58  repMap = super(PrimaryVertexValidation, self).getRepMap(alignment)
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):
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  return "hadd -f %s %s\n" % (mergedoutputfile, parameters)
82 
83  def appendToPlots(self):
84  repMap = self.getRepMap()
85  return (' loadFileList("root://eoscms//eos/cms%(finalResultFile)s",'
86  '"PVValidation","%(title)s", %(color)s, %(style)s);\n')%repMap
87 
88  @classmethod
89  def runPlots(cls, validations):
90  return configTemplates.PrimaryVertexPlotExecution
91 
92  @classmethod
94  return "TkAlPrimaryVertexValidationPlot.C"
95 
96  @classmethod
98  return configTemplates.PrimaryVertexPlotTemplate
99 
100  @classmethod
101  def plotsdirname(cls):
102  return "PrimaryVertexValidation"
def pythonboolstring(string, name)
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def getRepMap(self, alignment=None)
def __init__(self, valName, alignment, config)