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