Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:45:59

0001 from __future__ import absolute_import
0002 import os
0003 from . import configTemplates
0004 from . import globalDictionaries
0005 from .genericValidation import GenericValidationData, ValidationWithPlots
0006 from .helperFunctions import replaceByMap
0007 from .TkAlExceptions import AllInOneError
0008 
0009 
0010 class ZMuMuValidation(GenericValidationData, ValidationWithPlots):
0011     configBaseName = "TkAlZMuMuValidation"
0012     scriptBaseName = "TkAlZMuMuValidation"
0013     crabCfgBaseName = "TkAlZMuMuValidation"
0014     resultBaseName = "ZMuMuValidation"
0015     outputBaseName = "ZMuMuValidation"
0016     defaults = {
0017         "zmumureference": ("/store/caf/user/emiglior/Alignment/TkAlDiMuonValidation/Reference/BiasCheck_DYToMuMu_Summer12_TkAlZMuMu_IDEAL.root"),
0018         "minpt" : "0.",
0019         "maxpt" : "1000.",
0020         "etamaxneg" : "2.4",
0021         "etaminneg" : "-2.4",
0022         "etamaxpos" : "2.4",
0023         "etaminpos" : "-2.4",
0024         "CustomMinY": "90.85",
0025         "CustomMaxY": "91.4",
0026         "multiIOV":"False",
0027         }
0028     deprecateddefaults = {
0029         "resonance": "",
0030         "switchONfit": "",
0031         "rebinphi": "",
0032         "rebinetadiff": "",
0033         "rebineta": "",
0034         "rebinpt": "",
0035         }
0036     defaults.update(deprecateddefaults)
0037     needpackages = {'MuonAnalysis/MomentumScaleCalibration'}
0038     valType = "zmumu"
0039     def __init__(self, valName, alignment, config):
0040         super(ZMuMuValidation, self).__init__(valName, alignment, config)
0041         if self.general["zmumureference"].startswith("/store"):
0042             self.general["zmumureference"] = "root://eoscms//eos/cms" + self.general["zmumureference"]
0043         if self.NJobs > 1:
0044             raise AllInOneError("Parallel jobs not implemented for the Z->mumu validation!\n"
0045                                 "Please set parallelJobs = 1.")
0046         for option in self.deprecateddefaults:
0047             if self.general[option]:
0048                 raise AllInOneError("The '%s' option has been moved to the [plots:zmumu] section.  Please specify it there."%option)
0049             del self.general[option]
0050 
0051     @property
0052     def filesToCompare(self):
0053         return {self.defaultReferenceName: replaceByMap(".oO[eosdir]Oo./0_zmumuHisto.root", self.getRepMap())}
0054 
0055     @property
0056     def ValidationTemplate(self):
0057         return configTemplates.ZMuMuValidationTemplate
0058 
0059     @property
0060     def ProcessName(self):
0061         return "ONLYHISTOS"
0062 
0063     @property
0064     def FileOutputTemplate(self):
0065         return ""
0066 
0067     @property
0068     def LoadBasicModules(self):
0069         return super(ZMuMuValidation, self).LoadBasicModules + configTemplates.LoadMuonModules
0070 
0071     @property
0072     def TrackSelectionRefitting(self):
0073         return configTemplates.SingleTrackRefitter
0074 
0075     @property
0076     def DefinePath(self):
0077         return configTemplates.ZMuMuPath
0078 
0079     def createScript(self, path):
0080         return super(ZMuMuValidation, self).createScript(path, template = configTemplates.zMuMuScriptTemplate)
0081 
0082     def createCrabCfg(self, path):
0083         return super(ZMuMuValidation, self).createCrabCfg(path, self.crabCfgBaseName)
0084 
0085     def getRepMap(self, alignment = None):
0086         if alignment == None:
0087             alignment = self.alignmentToValidate
0088         repMap = super(ZMuMuValidation, self).getRepMap(alignment)
0089         repMap.update({
0090             "nEvents": self.general["maxevents"],
0091             "outputFile": ("0_zmumuHisto.root"
0092                            ",genSimRecoPlots.root"
0093                            ",FitParameters.txt"),
0094             "eosdir": os.path.join(self.general["eosdir"], "%s/%s/%s" % (self.outputBaseName, self.name, alignment.name)),
0095             "workingdir": ".oO[datadir]Oo./%s/%s/%s" % (self.outputBaseName, self.name, alignment.name),
0096             "plotsdir": ".oO[datadir]Oo./%s/%s/%s/plots" % (self.outputBaseName, self.name, alignment.name),
0097             "TrackCollection": self.trackcollection,
0098         })
0099         return repMap
0100 
0101     @property
0102     def trackcollection(self):
0103         from .plottingOptions import PlottingOptions
0104         resonance = PlottingOptions(self.config, self.valType)["resonance"]
0105         if resonance == "Z":
0106             return 'ALCARECOTkAlZMuMu'
0107         elif resonance == "JPsi":
0108             return 'ALCARECOTkAlJpsiMuMu'
0109         elif resonance in ("Y1S", "Y2S", "Y3S"):
0110             return 'ALCARECOTkAlUpsilonMuMu'
0111         else:
0112             raise AllInOneError("Unknown resonance {}!".format(resonance))
0113 
0114     def appendToPlots(self):
0115         """
0116         if no argument or "" is passed a string with an instantiation is
0117         returned, else the validation is appended to the list
0118         """
0119         repMap = self.getRepMap()
0120         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)
0121 
0122     @classmethod
0123     def plottingscriptname(cls):
0124         return "TkAlMergeZmumuPlots.C"
0125 
0126     @classmethod
0127     def plottingscripttemplate(cls):
0128         return configTemplates.mergeZmumuPlotsTemplate
0129 
0130     @classmethod
0131     def plotsdirname(cls):
0132         return ".oO[resonance]Oo.MuMuPlots"