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_CTSR, 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
38  def DefinePath(self):
39  return configTemplates.PVValidationPath
40 
41  @property
42  def ValidationSequence(self):
43  #never enters anywhere, since we use the custom DefinePath which includes the goodVertexSkim
44  return ""
45 
46  @property
47  def use_d0cut(self):
48  return False
49 
50  @property
51  def ProcessName(self):
52  return "PrimaryVertexValidation"
53 
54  def createScript(self, path):
55  return super(PrimaryVertexValidation, self).createScript(path, template = configTemplates.PVValidationScriptTemplate)
56 
57  def createCrabCfg(self, path):
58  return super(PrimaryVertexValidation, self).createCrabCfg(path, self.crabCfgBaseName)
59 
60  def getRepMap(self, alignment = None):
61  if alignment == None:
62  alignment = self.alignmentToValidate
63  repMap = super(PrimaryVertexValidation, self).getRepMap(alignment)
64  repMap.update({
65  "nEvents": self.general["maxevents"],
66  "TrackCollection": self.general["trackcollection"],
67  "VertexCollection": self.general["vertexcollection"],
68  "eosdir": os.path.join(self.general["eosdir"]),
69  #"eosdir": os.path.join(self.general["eosdir"], "%s/%s/%s" % (self.outputBaseName, self.name, alignment.name)),
70  "workingdir": ".oO[datadir]Oo./%s/%s/%s" % (self.outputBaseName, self.name, alignment.name),
71  "plotsdir": ".oO[datadir]Oo./%s/%s/%s/plots" % (self.outputBaseName, self.name, alignment.name),
72  })
73 
74  return repMap
75 
76  def appendToMerge(self):
77  """
78  if no argument or "" is passed a string with an instantiation is returned,
79  else the validation is appended to the list
80  """
81  repMap = self.getRepMap()
82 
83  parameters = " ".join(os.path.join("root://eoscms//eos/cms", file.lstrip("/")) for file in repMap["resultFiles"])
84 
85  mergedoutputfile = os.path.join("root://eoscms//eos/cms", repMap["finalResultFile"].lstrip("/"))
86  return "hadd -f %s %s\n" % (mergedoutputfile, parameters)
87 
88  def appendToPlots(self):
89  repMap = self.getRepMap()
90  return (' loadFileList("root://eoscms//eos/cms%(finalResultFile)s",'
91  '"PVValidation","%(title)s", %(color)s, %(style)s);\n')%repMap
92 
93  @classmethod
94  def runPlots(cls, validations):
95  return configTemplates.PrimaryVertexPlotExecution
96 
97  @classmethod
99  return "TkAlPrimaryVertexValidationPlot.C"
100 
101  @classmethod
103  return configTemplates.PrimaryVertexPlotTemplate
104 
105  @classmethod
106  def plotsdirname(cls):
107  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)