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