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  "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"
zMuMuValidation.ZMuMuValidation.outputBaseName
string outputBaseName
Definition: zMuMuValidation.py:15
zMuMuValidation.ZMuMuValidation.plotsdirname
def plotsdirname(cls)
Definition: zMuMuValidation.py:131
zMuMuValidation.ZMuMuValidation.plottingscripttemplate
def plottingscripttemplate(cls)
Definition: zMuMuValidation.py:127
zMuMuValidation.ZMuMuValidation.trackcollection
def trackcollection(self)
Definition: zMuMuValidation.py:102
zMuMuValidation.ZMuMuValidation.filesToCompare
def filesToCompare(self)
Definition: zMuMuValidation.py:52
zMuMuValidation.ZMuMuValidation.valType
string valType
Definition: zMuMuValidation.py:38
zMuMuValidation.ZMuMuValidation.appendToPlots
def appendToPlots(self)
Definition: zMuMuValidation.py:114
zMuMuValidation.ZMuMuValidation.DefinePath
def DefinePath(self)
Definition: zMuMuValidation.py:76
zMuMuValidation.ZMuMuValidation.__init__
def __init__(self, valName, alignment, config)
Definition: zMuMuValidation.py:39
helperFunctions.replaceByMap
def replaceByMap(target, the_map)
— Helpers —############################
Definition: helperFunctions.py:12
plottingOptions.PlottingOptions
def PlottingOptions(config, valType)
Definition: plottingOptions.py:239
zMuMuValidation.ZMuMuValidation.TrackSelectionRefitting
def TrackSelectionRefitting(self)
Definition: zMuMuValidation.py:72
genericValidation.GenericValidation.NJobs
NJobs
Definition: genericValidation.py:68
zMuMuValidation.ZMuMuValidation.ValidationTemplate
def ValidationTemplate(self)
Definition: zMuMuValidation.py:56
genericValidation.GenericValidation.general
general
Definition: genericValidation.py:57
zMuMuValidation.ZMuMuValidation.getRepMap
def getRepMap(self, alignment=None)
Definition: zMuMuValidation.py:85
genericValidation.ValidationWithPlots
Definition: genericValidation.py:598
zMuMuValidation.ZMuMuValidation
Definition: zMuMuValidation.py:10
genericValidation.GenericValidation.alignmentToValidate
alignmentToValidate
Definition: genericValidation.py:56
zMuMuValidation.ZMuMuValidation.plottingscriptname
def plottingscriptname(cls)
Definition: zMuMuValidation.py:123
zMuMuValidation.ZMuMuValidation.createCrabCfg
def createCrabCfg(self, path)
Definition: zMuMuValidation.py:82
zMuMuValidation.ZMuMuValidation.crabCfgBaseName
string crabCfgBaseName
Definition: zMuMuValidation.py:13
genericValidation.GenericValidation.name
name
Definition: genericValidation.py:55
zMuMuValidation.ZMuMuValidation.createScript
def createScript(self, path)
Definition: zMuMuValidation.py:79
zMuMuValidation.ZMuMuValidation.LoadBasicModules
def LoadBasicModules(self)
Definition: zMuMuValidation.py:68
genericValidation.GenericValidation.getRepMap
def getRepMap(self, alignment=None)
Definition: genericValidation.py:136
genericValidation.GenericValidationData
Definition: genericValidation.py:250
zMuMuValidation.ZMuMuValidation.FileOutputTemplate
def FileOutputTemplate(self)
Definition: zMuMuValidation.py:64
format
zMuMuValidation.ZMuMuValidation.deprecateddefaults
dictionary deprecateddefaults
Definition: zMuMuValidation.py:28
TkAlExceptions.AllInOneError
Definition: TkAlExceptions.py:1
genericValidation.GenericValidation.defaultReferenceName
string defaultReferenceName
Definition: genericValidation.py:42
zMuMuValidation.ZMuMuValidation.ProcessName
def ProcessName(self)
Definition: zMuMuValidation.py:60
genericValidation.GenericValidation.config
config
Definition: genericValidation.py:60