CMS 3D CMS Logo

zMuMuValidation.py
Go to the documentation of this file.
1 import os
2 import configTemplates
3 import globalDictionaries
4 from genericValidation import GenericValidationData, ValidationWithPlots
5 from helperFunctions import replaceByMap
6 from TkAlExceptions import AllInOneError
7 
8 
10  configBaseName = "TkAlZMuMuValidation"
11  scriptBaseName = "TkAlZMuMuValidation"
12  crabCfgBaseName = "TkAlZMuMuValidation"
13  resultBaseName = "ZMuMuValidation"
14  outputBaseName = "ZMuMuValidation"
15  defaults = {
16  "zmumureference": ("/store/caf/user/emiglior/Alignment/TkAlDiMuonValidation/Reference/BiasCheck_DYToMuMu_Summer12_TkAlZMuMu_IDEAL.root"),
17  }
18  deprecateddefaults = {
19  "resonance": "",
20  "switchONfit": "",
21  "rebinphi": "",
22  "rebinetadiff": "",
23  "rebineta": "",
24  "rebinpt": "",
25  }
26  defaults.update(deprecateddefaults)
27  needpackages = {'MuonAnalysis/MomentumScaleCalibration'}
28  mandatories = {"etamaxneg", "etaminneg", "etamaxpos", "etaminpos"}
29  valType = "zmumu"
30  def __init__(self, valName, alignment, config):
31  super(ZMuMuValidation, self).__init__(valName, alignment, config)
32  if self.general["zmumureference"].startswith("/store"):
33  self.general["zmumureference"] = "root://eoscms//eos/cms" + self.general["zmumureference"]
34  if self.NJobs > 1:
35  raise AllInOneError("Parallel jobs not implemented for the Z->mumu validation!\n"
36  "Please set parallelJobs = 1.")
37  for option in self.deprecateddefaults:
38  if self.general[option]:
39  raise AllInOneError("The '%s' option has been moved to the [plots:zmumu] section. Please specify it there."%option)
40  del self.general[option]
41 
42  @property
43  def filesToCompare(self):
44  return {self.defaultReferenceName: replaceByMap(".oO[eosdir]Oo./0_zmumuHisto.root", self.getRepMap())}
45 
46  @property
47  def ValidationTemplate(self):
48  return configTemplates.ZMuMuValidationTemplate
49 
50  @property
51  def ProcessName(self):
52  return "ONLYHISTOS"
53 
54  @property
55  def FileOutputTemplate(self):
56  return ""
57 
58  @property
59  def LoadBasicModules(self):
60  return super(ZMuMuValidation, self).LoadBasicModules + configTemplates.LoadMuonModules
61 
62  @property
64  return configTemplates.SingleTrackRefitter
65 
66  @property
67  def DefinePath(self):
68  return configTemplates.ZMuMuPath
69 
70  def createScript(self, path):
71  return super(ZMuMuValidation, self).createScript(path, template = configTemplates.zMuMuScriptTemplate)
72 
73  def createCrabCfg(self, path):
74  return super(ZMuMuValidation, self).createCrabCfg(path, self.crabCfgBaseName)
75 
76  def getRepMap(self, alignment = None):
77  if alignment == None:
78  alignment = self.alignmentToValidate
79  repMap = super(ZMuMuValidation, self).getRepMap(alignment)
80  repMap.update({
81  "nEvents": self.general["maxevents"],
82  "outputFile": ("0_zmumuHisto.root"
83  ",genSimRecoPlots.root"
84  ",FitParameters.txt"),
85  "eosdir": os.path.join(self.general["eosdir"], "%s/%s/%s" % (self.outputBaseName, self.name, alignment.name)),
86  "workingdir": ".oO[datadir]Oo./%s/%s/%s" % (self.outputBaseName, self.name, alignment.name),
87  "plotsdir": ".oO[datadir]Oo./%s/%s/%s/plots" % (self.outputBaseName, self.name, alignment.name),
88  "TrackCollection": self.trackcollection,
89  })
90  return repMap
91 
92  @property
93  def trackcollection(self):
94  from plottingOptions import PlottingOptions
95  resonance = PlottingOptions(self.config, self.valType)["resonance"]
96  if resonance == "Z":
97  return 'ALCARECOTkAlZMuMu'
98  elif resonance == "JPsi":
99  return 'ALCARECOTkAlJpsiMuMu'
100  elif resonance in ("Y1S", "Y2S", "Y3S"):
101  return 'ALCARECOTkAlUpsilonMuMu'
102  else:
103  raise AllInOneError("Unknown resonance {}!".format(resonance))
104 
105  def appendToPlots(self):
106  """
107  if no argument or "" is passed a string with an instantiation is
108  returned, else the validation is appended to the list
109  """
110  repMap = self.getRepMap()
111  return replaceByMap(' filenames.push_back("root://eoscms//eos/cms/store/caf/user/$USER/.oO[eosdir]Oo./BiasCheck.root"); titles.push_back(".oO[title]Oo."); colors.push_back(.oO[color]Oo.); linestyles.push_back(.oO[style]Oo.);\n', repMap)
112 
113  @classmethod
115  return "TkAlMergeZmumuPlots.C"
116 
117  @classmethod
119  return configTemplates.mergeZmumuPlotsTemplate
120 
121  @classmethod
122  def plotsdirname(cls):
123  return ".oO[resonance]Oo.MuMuPlots"
def getRepMap(self, alignment=None)
def PlottingOptions(config, valType)
def replaceByMap(target, the_map)
— Helpers —############################
def getRepMap(self, alignment=None)
def __init__(self, valName, alignment, config)