def _addShapeNuisances(self, nuisances, effects, opts, suffix, yields): # local copy shapeNu = OrderedDict() self._addWWShapeNuisances(shapeNu, effects) self._addInterfShapeNuisances(shapeNu, effects) self._addExperimentalShapeNuisances(shapeNu, effects, suffix, yields) if 'shapeFlags' not in opts: sys.exit(-1) flags = opts['shapeFlags'] nus = set(shapeNu.keys()) dummy = nus.copy() for exp,flag in flags: subset = set(fnmatch.filter(nus,exp)) if flag: dummy |= subset else: dummy -= subset for eff in shapeNu: if eff not in dummy: continue if eff in nuisances: del nuisances[eff] nuisances[eff] = shapeNu[eff]
def _addShapeNuisances(self, nuisances, effects, opts, suffix, yields): # local copy shapeNu = OrderedDict() self._addWWShapeNuisances(shapeNu, effects) self._addInterfShapeNuisances(shapeNu, effects) self._addExperimentalShapeNuisances(shapeNu, effects, suffix, yields) if 'shapeFlags' not in opts: sys.exit(-1) flags = opts['shapeFlags'] nus = set(shapeNu.keys()) dummy = nus.copy() for exp,flag in flags: subset = set(fnmatch.filter(nus,exp)) if flag: dummy |= subset else: dummy -= subset for eff in shapeNu: if eff not in dummy: continue if eff in nuisances: del nuisances[eff] nuisances[eff] = shapeNu[eff]
def nuisances(self, yields, effects, mass, channel, jetcat, flavor, opts): '''Add the nuisances according to the options''' allNus = OrderedDict() optMatt = mattOpts() optMatt.WJadd = 0.36 optMatt.WJsub = 0.0 qqWWfromData = self._wwddfilter.haswwdd(mass, channel) # vh and vbf and wwewk mapped to "2j" category if (jetcat == 'vh2j' or jetcat == 'whsc' or jetcat == '2jtche05' or jetcat == '2jtche05CJ' or jetcat == '2jtche05FJ') : jetcat = '2j' # vh : remove some nuisances, typical of vbf only if (jetcat == 'vh2j' or jetcat == 'whsc') : optMatt.VH = 1 else : optMatt.VH = 0 if jetcat not in ['0j','1j','2j','2jex']: raise ValueError('Unsupported jet category found: %s') # suffix = '_8TeV' # if '2011' in opt.dataset: suffix = '_7TeV' suffix = '_'+opt.energy CutBased = getCommonSysts(int(mass),flavor,int(jetcat[0]),qqWWfromData, self._shape, optMatt, suffix, self._isssactive) if self._shape: # float WW+ggWW background normalisation float together # for p in opts['floatN'].split(' '): for p in opts['floatN']: print p floatN = floatNorm(p) CutBased.update( floatN ) common = OrderedDict() for k in sorted(CutBased): common[k] = CutBased[k] allNus.update( common ) # only if not bin-by-bin, then add statistical uncertainty # for bbb it is already included if self._statmode != 'bybin': self._addStatisticalNuisances(allNus, yields, channel, suffix) self._addDataDrivenNuisances(allNus, yields, mass, channel, jetcat, suffix, opts) if self._shape: self._addShapeNuisances(allNus,effects, opts, suffix, yields) if 'nuisFlags' not in opts: raise RuntimeError('nuisFlags not found among the allNus options') flags = opts['nuisFlags'] finalNuisances = OrderedDict() nus = set(allNus.keys()) dummy = nus.copy() for exp,flag in flags: subset = set(fnmatch.filter(nus,exp)) if flag: dummy |= subset else: dummy -= subset nuisances = OrderedDict() for eff in allNus: if eff not in dummy: continue nuisances[eff] = allNus[eff] return nuisances
def nuisances(self, yields, effects, mass, channel, jetcat, flavor, opts ): '''Add the nuisances according to the options''' allNus = OrderedDict() optMatt = mattOpts() optMatt.WJadd = 0.36 optMatt.WJsub = 0.0 qqWWfromData = self._wwddfilter.haswwdd(mass, channel) # vh and vbf and wwewk mapped to "2j" category if (jetcat == 'vh2j' or jetcat == 'whsc' or jetcat == '2jtche05' or jetcat == '2jtche05CJ' or jetcat == '2jtche05FJ') : jetcat = '2j' # vh : remove some nuisances, typical of vbf only if (jetcat == 'vh2j' or jetcat == 'whsc') : optMatt.VH = 1 else : optMatt.VH = 0 optMatt.HWidth = 0 if 'SpecialSettings' in opts: if opts['SpecialSettings'] == 'HWidth' : optMatt.HWidth = 1 optMatt.WWxsec = 0 if 'SpecialSettings' in opts: if opts['SpecialSettings'] == 'WWxsec' : optMatt.WWxsec = 1 if jetcat not in ['0j','1j','2j','2jex','01j']: raise ValueError('Unsupported jet category found: %s') # suffix = '_8TeV' # if '2011' in opt.dataset: suffix = '_7TeV' suffix = '_'+opt.energy CutBased = getCommonSysts(int(mass),flavor,int(jetcat[0]),qqWWfromData, self._shape, optMatt, suffix, self._isssactive, opt.energy,opts['newInterf'],opt.YRSysVer,opt.mHSM,125.0,opts['ewksinglet']) if self._shape: # float WW+ggWW background normalisation float together # for p in opts['floatN'].split(' '): for p in opts['floatN']: print p floatN = floatNorm(p,jetcat) CutBased.update( floatN ) common = OrderedDict() for k in sorted(CutBased): common[k] = CutBased[k] allNus.update( common ) # only if not bin-by-bin, then add statistical uncertainty # for bbb it is already included if self._statmode != 'bybin': self._addStatisticalNuisances(allNus, yields, channel, suffix) self._addDataDrivenNuisances(allNus, yields, mass, channel, jetcat, suffix, opts) if self._shape: self._addShapeNuisances(allNus,effects, opts, suffix, yields) if 'nuisFlags' not in opts: raise RuntimeError('nuisFlags not found among the allNus options') flags = opts['nuisFlags'] finalNuisances = OrderedDict() nus = set(allNus.keys()) dummy = nus.copy() for exp,flag in flags: subset = set(fnmatch.filter(nus,exp)) if flag: dummy |= subset else: dummy -= subset nuisances = OrderedDict() for eff in allNus: if eff not in dummy: continue nuisances[eff] = allNus[eff] return nuisances