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, ParallelValidation, 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  # N.B.: the reference needs to be updated each time the format of the output is changed
16  "pvvalidationreference": ("/store/group/alca_trackeralign/validation/PVValidation/Reference/PrimaryVertexValidation_phaseIMC92X_upgrade2017_Ideal.root"),
17  "doBPix":"True",
18  "doFPix":"True",
19  "forceBeamSpot":"False",
20  }
21  mandatories = {"isda","ismc","runboundary","trackcollection","vertexcollection","lumilist","ptCut","etaCut","runControl","numberOfBins"}
22  valType = "primaryvertex"
23  def __init__(self, valName, alignment, config):
24  super(PrimaryVertexValidation, self).__init__(valName, alignment, config)
25 
26  for name in "doBPix", "doFPix", "forceBeamSpot":
27  self.general[name] = pythonboolstring(self.general[name], name)
28 
29  if self.general["pvvalidationreference"].startswith("/store"):
30  self.general["pvvalidationreference"] = "root://eoscms//eos/cms" + self.general["pvvalidationreference"]
31 
32  @property
33  def ValidationTemplate(self):
34  return configTemplates.PrimaryVertexValidationTemplate
35 
36  @property
37  def DefinePath(self):
38  return configTemplates.PVValidationPath
39 
40  @property
41  def ValidationSequence(self):
42  #never enters anywhere, since we use the custom DefinePath which includes the goodVertexSkim
43  return ""
44 
45  @property
46  def use_d0cut(self):
47  return False
48 
49  @property
50  def isPVValidation(self):
51  return True
52 
53  @property
54  def ProcessName(self):
55  return "PrimaryVertexValidation"
56 
57  def createScript(self, path):
58  return super(PrimaryVertexValidation, self).createScript(path, template = configTemplates.PVValidationScriptTemplate)
59 
60  def createCrabCfg(self, path):
61  return super(PrimaryVertexValidation, self).createCrabCfg(path, self.crabCfgBaseName)
62 
63  def getRepMap(self, alignment = None):
64  if alignment == None:
65  alignment = self.alignmentToValidate
66  repMap = super(PrimaryVertexValidation, self).getRepMap(alignment)
67  repMap.update({
68  "nEvents": self.general["maxevents"],
69  "TrackCollection": self.general["trackcollection"],
70  "VertexCollection": self.general["vertexcollection"],
71  "eosdir": os.path.join(self.general["eosdir"]),
72  #"eosdir": os.path.join(self.general["eosdir"], "%s/%s/%s" % (self.outputBaseName, self.name, alignment.name)),
73  "workingdir": ".oO[datadir]Oo./%s/%s/%s" % (self.outputBaseName, self.name, alignment.name),
74  "plotsdir": ".oO[datadir]Oo./%s/%s/%s/plots" % (self.outputBaseName, self.name, alignment.name),
75  "filetoplot": "root://eoscms//eos/cms.oO[finalResultFile]Oo.",
76  })
77 
78  return repMap
79 
80  def appendToMerge(self):
81  """
82  if no argument or "" is passed a string with an instantiation is returned,
83  else the validation is appended to the list
84  """
85  repMap = self.getRepMap()
86 
87  parameters = " ".join(os.path.join("root://eoscms//eos/cms", file.lstrip("/")) for file in repMap["resultFiles"])
88 
89  mergedoutputfile = os.path.join("root://eoscms//eos/cms", repMap["finalResultFile"].lstrip("/"))
90  return "hadd -f %s %s\n" % (mergedoutputfile, parameters)
91 
92  def appendToPlots(self):
93  repMap = self.getRepMap()
94  return (' loadFileList("%(filetoplot)s",'
95  '"PVValidation", "%(title)s", %(color)s, %(style)s);\n')%repMap
96 
97  @classmethod
98  def runPlots(cls, validations):
99  return configTemplates.PrimaryVertexPlotExecution
100 
101  @classmethod
103  return "TkAlPrimaryVertexValidationPlot.C"
104 
105  @classmethod
107  return configTemplates.PrimaryVertexPlotTemplate
108 
109  @classmethod
110  def plotsdirname(cls):
111  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)