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  # 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  }
20  mandatories = {"isda","ismc","runboundary","trackcollection","vertexcollection","lumilist","ptCut","etaCut","runControl","numberOfBins"}
21  valType = "primaryvertex"
22  def __init__(self, valName, alignment, config):
23  super(PrimaryVertexValidation, self).__init__(valName, alignment, config)
24 
25  for name in "doBPix", "doFPix":
26  self.general[name] = pythonboolstring(self.general[name], name)
27 
28  if self.general["pvvalidationreference"].startswith("/store"):
29  self.general["pvvalidationreference"] = "root://eoscms//eos/cms" + self.general["pvvalidationreference"]
30  if self.NJobs > 1:
31  raise AllInOneError("Parallel jobs not implemented for the PrimaryVertex validation!\n"
32  "Please set parallelJobs = 1.")
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  })
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("root://eoscms//eos/cms%(finalResultFile)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)