def PrepareWeightsAndHistos(self, regionString="", normString="", normCuts="", abstract=None, topLvl=None, chan=None, sam=None): nomName = "h%sNom_%s_obs_%s" % (sam.name, regionString, replaceSymbols(chan.variableName)) for lowhigh in ["High_", "Low_"]: lowhighName = "h%s%s%s%s_obs_%s" % ( sam.name, self.name, lowhigh, regionString, replaceSymbols(chan.variableName)) if abstract.hists[lowhighName] is None: if lowhigh == "High_": abstract.hists[ lowhighName] = histMgr.buildUserHistoSysFromHist( lowhighName, self.high, abstract.hists[nomName]) elif lowhigh == "Low_": abstract.hists[ lowhighName] = histMgr.buildUserHistoSysFromHist( lowhighName, self.low, abstract.hists[nomName]) return
def PrepareGlobalNormalization(self, normString, abstract, topLvl, chan, sam): for lowhigh in ["Nom_", self.name + "High_", self.name + "Low_"]: histName = "h%s%s%sNorm" % (sam.name, lowhigh, normString) if not histName in abstract.hists.keys(): if sam.normRegions: if not abstract.readFromTree: abstract.hists[histName] = None abstract.prepare.addHisto(histName) else: abstract.hists[histName] = TH1F( histName, histName, 1, 0.5, 1.5) totNorm = 0.0 for normReg in sam.normRegions: nameTmp = "h" + sam.name + lowhigh + normReg[ 0] + "_obs_" + replaceSymbols( chan.variableName) try: totNorm += abstract.hists[ nameTmp].GetSumOfWeights() except: log.warning( "could get histogram %s for normalization" % nameTmp) abstract.hists[histName].SetBinContent(1, totNorm) return
def PrepareWeightsAndHistos(self, regionString="", normString="", normCuts="", abstract=None, topLvl=None, chan=None, sam=None): nomName = "h%sNom_%s_obs_%s" % (sam.name, regionString, replaceSymbols(chan.variableName) ) for lowhigh in ["High_","Low_"]: lowhighName = "h%s%s%s%s_obs_%s" % (sam.name, self.name, lowhigh, regionString, replaceSymbols(chan.variableName)) if abstract.hists[lowhighName] is None: if lowhigh=="High_": abstract.hists[lowhighName] = histMgr.buildUserHistoSysFromHist(lowhighName, self.high, abstract.hists[nomName]) elif lowhigh=="Low_": abstract.hists[lowhighName] = histMgr.buildUserHistoSysFromHist(lowhighName, self.low, abstract.hists[nomName]) return
def tryAddHistos(self, highorlow="", regionString="", normString="", normCuts="", abstract=None, chan=None, sam=None): histName = "h%s%s%s%s_obs_%s" % (sam.name, self.name, highorlow, regionString, replaceSymbols(chan.variableName)) log.debug(" adding histo %s" % histName) try: abstract.prepare.addHisto(histName, useOverflow=chan.useOverflowBin, useUnderflow=chan.useUnderflowBin) except: pass
def PrepareGlobalNormalization(self,normString,abstract,topLvl,chan,sam): for lowhigh in ["Nom_",self.name+"High_",self.name+"Low_"]: histName = "h%s%s%sNorm" % (sam.name, lowhigh, normString) if not histName in abstract.hists.keys(): if sam.normRegions: if not abstract.readFromTree: abstract.hists[histName] = None abstract.prepare.addHisto(histName) else: abstract.hists[histName] = TH1F(histName, histName, 1, 0.5, 1.5) totNorm=0.0 for normReg in sam.normRegions: nameTmp = "h" + sam.name + lowhigh + normReg[0] + "_obs_" + replaceSymbols(chan.variableName) try: totNorm += abstract.hists[nameTmp].GetSumOfWeights() except: log.warning("could get histogram %s for normalization" % nameTmp) abstract.hists[histName].SetBinContent(1,totNorm) return
def tryAddHistos(self, highorlow="", regionString="", normString="", normCuts="", abstract=None, chan=None, sam=None): histName = "h%s%s%s%s_obs_%s" % (sam.name, self.name, highorlow, regionString, replaceSymbols(chan.variableName) ) log.debug(" adding histo %s" % histName) try: abstract.prepare.addHisto(histName, useOverflow=chan.useOverflowBin, useUnderflow=chan.useUnderflowBin) except: pass
def __init__(self, variableName, regions, prefix, nBins, binLow, binHigh, statErrorThreshold=None, hasB=False): """ Store configuration, set unique channel name from variable, define cut region, binning and open file @param variableName The name of the variable to bin in @param regions All regions used in the channel @param prefix A prefix for XML files for the channel @param nBins The number of bins to use @param binLow Lower edge of the first bin @param binHigh Upper edge of the last bin @param statErrorThreshold Threshold for statistical errors """ regions.sort() self.regionString = "".join(regions) self.variableName = variableName self.niceVarName = replaceSymbols(variableName) self.name = self.niceVarName + "_" + self.regionString self.channelName = self.regionString + "_" + self.niceVarName self.ConstructorInit(prefix) # shared method with Clone or deepcopy self.regions = regions self.nBins = nBins self.binHigh = binHigh self.binLow = binLow self.sampleList = [] self.dataList = [] self.weights = [] self.systDict = {} self.infoDict = {} self.hasBQCD = False self.useOverflowBin = False self.useUnderflowBin = False self.hasStatConfig = False self.hasDiscovery = False if statErrorThreshold is not None: self.hasStatConfig = True self.statErrorThreshold = statErrorThreshold self.statErrorType = "Gaussian" #"Gaussian" "Poisson" self.files = [] self.treeName = '' self.parentTopLvl = None # Plot cosmetics self.minY = None self.maxY = None self.title = None self.titleX = None self.titleY = None self.logY = None self.ATLASLabelX = None self.ATLASLabelY = None self.ATLASLabelText = None self.showLumi = None self.lumi = None self.remapSystChanName = "" self.blind = False self.text1 = '' self.text2 = '' self.textsize1 = 0.03 self.textsize2 = 0.03 log.debug("Defining new channel '{0}'".format(self.name)) return