CMS 3D CMS Logo

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