CMS 3D CMS Logo

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