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  }
22  mandatories = {"isda","ismc","runboundary","trackcollection","vertexcollection","lumilist","ptCut","etaCut","runControl","numberOfBins"}
23  valType = "primaryvertex"
24  def __init__(self, valName, alignment, config):
25  super(PrimaryVertexValidation, self).__init__(valName, alignment, config)
26 
27  for name in "doBPix", "doFPix", "forceBeamSpot":
28  self.general[name] = pythonboolstring(self.general[name], name)
29 
30  if self.general["pvvalidationreference"].startswith("/store"):
31  self.general["pvvalidationreference"] = "root://eoscms//eos/cms" + self.general["pvvalidationreference"]
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 isPVValidation(self):
52  return True
53 
54  @property
55  def ProcessName(self):
56  return "PrimaryVertexValidation"
57 
58  def createScript(self, path):
59  return super(PrimaryVertexValidation, self).createScript(path, template = configTemplates.PVValidationScriptTemplate)
60 
61  def createCrabCfg(self, path):
62  return super(PrimaryVertexValidation, self).createCrabCfg(path, self.crabCfgBaseName)
63 
64  def getRepMap(self, alignment = None):
65  if alignment == None:
66  alignment = self.alignmentToValidate
67  repMap = super(PrimaryVertexValidation, self).getRepMap(alignment)
68  repMap.update({
69  "nEvents": self.general["maxevents"],
70  "TrackCollection": self.general["trackcollection"],
71  "VertexCollection": self.general["vertexcollection"],
72  "eosdir": os.path.join(self.general["eosdir"]),
73  #"eosdir": os.path.join(self.general["eosdir"], "%s/%s/%s" % (self.outputBaseName, self.name, alignment.name)),
74  "workingdir": ".oO[datadir]Oo./%s/%s/%s" % (self.outputBaseName, self.name, alignment.name),
75  "plotsdir": ".oO[datadir]Oo./%s/%s/%s/plots" % (self.outputBaseName, self.name, alignment.name),
76  "filetoplot": "root://eoscms//eos/cms.oO[finalResultFile]Oo.",
77  })
78 
79  return repMap
80 
81  def appendToMerge(self):
82  """
83  if no argument or "" is passed a string with an instantiation is returned,
84  else the validation is appended to the list
85  """
86  repMap = self.getRepMap()
87 
88  parameters = " ".join(os.path.join("root://eoscms//eos/cms", file.lstrip("/")) for file in repMap["resultFiles"])
89 
90  mergedoutputfile = os.path.join("root://eoscms//eos/cms", repMap["finalResultFile"].lstrip("/"))
91  return "hadd -f %s %s\n" % (mergedoutputfile, parameters)
92 
93  def appendToPlots(self):
94  repMap = self.getRepMap()
95  return (' loadFileList("%(filetoplot)s",'
96  '"PVValidation", "%(title)s", %(color)s, %(style)s);\n')%repMap
97 
98  @classmethod
99  def runPlots(cls, validations):
100  return configTemplates.PrimaryVertexPlotExecution
101 
102  @classmethod
104  return "TkAlPrimaryVertexValidationPlot.C"
105 
106  @classmethod
108  return configTemplates.PrimaryVertexPlotTemplate
109 
110  @classmethod
111  def plotsdirname(cls):
112  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)