CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
10 class ZMuMuValidation(GenericValidationData, ValidationWithPlots):
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  "CustomMinY": "90.85",
25  "CustomMaxY": "91.4",
26  "multiIOV":"False",
27  }
28  deprecateddefaults = {
29  "resonance": "",
30  "switchONfit": "",
31  "rebinphi": "",
32  "rebinetadiff": "",
33  "rebineta": "",
34  "rebinpt": "",
35  }
36  defaults.update(deprecateddefaults)
37  needpackages = {'MuonAnalysis/MomentumScaleCalibration'}
38  valType = "zmumu"
39  def __init__(self, valName, alignment, config):
40  super(ZMuMuValidation, self).__init__(valName, alignment, config)
41  if self.general["zmumureference"].startswith("/store"):
42  self.general["zmumureference"] = "root://eoscms//eos/cms" + self.general["zmumureference"]
43  if self.NJobs > 1:
44  raise AllInOneError("Parallel jobs not implemented for the Z->mumu validation!\n"
45  "Please set parallelJobs = 1.")
46  for option in self.deprecateddefaults:
47  if self.general[option]:
48  raise AllInOneError("The '%s' option has been moved to the [plots:zmumu] section. Please specify it there."%option)
49  del self.general[option]
50 
51  @property
52  def filesToCompare(self):
53  return {self.defaultReferenceName: replaceByMap(".oO[eosdir]Oo./0_zmumuHisto.root", self.getRepMap())}
54 
55  @property
56  def ValidationTemplate(self):
57  return configTemplates.ZMuMuValidationTemplate
58 
59  @property
60  def ProcessName(self):
61  return "ONLYHISTOS"
62 
63  @property
64  def FileOutputTemplate(self):
65  return ""
66 
67  @property
68  def LoadBasicModules(self):
69  return super(ZMuMuValidation, self).LoadBasicModules + configTemplates.LoadMuonModules
70 
71  @property
73  return configTemplates.SingleTrackRefitter
74 
75  @property
76  def DefinePath(self):
77  return configTemplates.ZMuMuPath
78 
79  def createScript(self, path):
80  return super(ZMuMuValidation, self).createScript(path, template = configTemplates.zMuMuScriptTemplate)
81 
82  def createCrabCfg(self, path):
83  return super(ZMuMuValidation, self).createCrabCfg(path, self.crabCfgBaseName)
84 
85  def getRepMap(self, alignment = None):
86  if alignment == None:
87  alignment = self.alignmentToValidate
88  repMap = super(ZMuMuValidation, self).getRepMap(alignment)
89  repMap.update({
90  "nEvents": self.general["maxevents"],
91  "outputFile": ("0_zmumuHisto.root"
92  ",genSimRecoPlots.root"
93  ",FitParameters.txt"),
94  "eosdir": os.path.join(self.general["eosdir"], "%s/%s/%s" % (self.outputBaseName, self.name, alignment.name)),
95  "workingdir": ".oO[datadir]Oo./%s/%s/%s" % (self.outputBaseName, self.name, alignment.name),
96  "plotsdir": ".oO[datadir]Oo./%s/%s/%s/plots" % (self.outputBaseName, self.name, alignment.name),
97  "TrackCollection": self.trackcollection,
98  })
99  return repMap
100 
101  @property
102  def trackcollection(self):
103  from .plottingOptions import PlottingOptions
104  resonance = PlottingOptions(self.config, self.valType)["resonance"]
105  if resonance == "Z":
106  return 'ALCARECOTkAlZMuMu'
107  elif resonance == "JPsi":
108  return 'ALCARECOTkAlJpsiMuMu'
109  elif resonance in ("Y1S", "Y2S", "Y3S"):
110  return 'ALCARECOTkAlUpsilonMuMu'
111  else:
112  raise AllInOneError("Unknown resonance {}!".format(resonance))
113 
114  def appendToPlots(self):
115  """
116  if no argument or "" is passed a string with an instantiation is
117  returned, else the validation is appended to the list
118  """
119  repMap = self.getRepMap()
120  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)
121 
122  @classmethod
124  return "TkAlMergeZmumuPlots.C"
125 
126  @classmethod
128  return configTemplates.mergeZmumuPlotsTemplate
129 
130  @classmethod
131  def plotsdirname(cls):
132  return ".oO[resonance]Oo.MuMuPlots"
def replaceByMap
— Helpers —############################