def _makeGenSums(self, tree): self._genSums = {} genMetBE_X = genMetBE_Y = genMetHF_X = genMetHF_Y = 0 for genPartIt in range(tree.nPart): if abs(tree.partId[genPartIt]) in [12, 13, 14, 16]: genPhi = tree.partPhi[genPartIt] genPt = tree.partPt[genPartIt] genMetHF_X += genPt * math.cos(genPhi) genMetHF_Y += genPt * math.sin(genPhi) if abs(tree.partEta[genPartIt]) < 3.0: genMetBE_X += genPt * math.cos(genPhi) genMetBE_Y += genPt * math.sin(genPhi) genMetBE = math.sqrt(genMetBE_X * genMetBE_X + genMetBE_Y * genMetBE_Y) genMetHF = math.sqrt(genMetHF_X * genMetHF_X + genMetHF_Y * genMetHF_Y) if genMetBE_Y and genMetBE_X: genMetPhiBE = math.atan(genMetBE_Y / genMetBE_X) else: genMetPhiBE = 0 if genMetHF_Y and genMetHF_X: genMetPhiHF = math.atan(genMetHF_Y / genMetHF_X) else: genMetPhiHF = 0 genHT = 0 for jetIt in range(tree.nJet): genHT += tree.jetPt[jetIt] self._genSums["genMetBE"] = Met(genMetBE, genMetPhiBE) self._genSums["genMetHF"] = Met(genMetHF, genMetPhiHF) self._genSums["genHT"] = EnergySum(genHT)
def produce(self, event): setattr(event, self._outputs[0] + '_Met', Met(event['L1PhaseIPFJet_phaseIPFJetMET'], 0.)) setattr(event, self._outputs[0] + '_MetHF', Met(event['L1PhaseIPFJet_phaseIPFJetMETHF'], 0.)) setattr(event, self._outputs[0] + '_Htt', EnergySum(event['L1PhaseIPFJet_phaseIPFJetHt'])) return True
def produce(self, event): setattr(event, self._outputs[0] + '_MetBE', Met(event['L1PhaseIPFJet_genMet'], 0.)) setattr(event, self._outputs[0] + '_MetHF', Met(event['L1PhaseIPFJet_genMet'], 0.)) setattr(event, self._outputs[0] + '_HT', EnergySum(event['L1PhaseIPFJet_genJetHt'])) return True
def ExtractSums(event): offline = dict(HTT=EnergySum(event.sums.Ht), MHT=Met(event.sums.mHt, event.sums.mHtPhi), MET_HF=Met(event.sums.caloMet, event.sums.caloMetPhi), MET_noHF=Met(event.sums.caloMetBE, event.sums.caloMetPhiBE)) online = dict(HTT=event.l1Sums["L1Htt"], MHT=event.l1Sums["L1Mht"], MET_HF=event.l1Sums["L1MetHF"], MET_noHF=event.l1Sums["L1Met"]) return online, offline
def extractSums(event, doEmu): offline = dict( caloHT=EnergySum(event.sums.caloHt), pfHT=EnergySum(event.sums.Ht), caloMETBE=Met(event.sums.caloMetBE, event.sums.caloMetPhiBE), caloMETHF=Met(event.sums.caloMet, event.sums.caloMetPhi), pfMET_NoMu=Met(event.sums.pfMetNoMu, event.sums.pfMetNoMuPhi), ) online = dict( caloHT=event.l1Sums["L1Htt"], pfHT=event.l1Sums["L1Htt"], caloMETBE=event.l1Sums["L1Met"], caloMETHF=event.l1Sums["L1MetHF"], pfMET_NoMu=event.l1Sums["L1MetHF"], ) if doEmu: offline.update(dict( caloHT_Emu=EnergySum(event.sums.caloHt), pfHT_Emu=EnergySum(event.sums.Ht), caloMETBE_Emu=Met(event.sums.caloMetBE, event.sums.caloMetPhiBE), caloMETHF_Emu=Met(event.sums.caloMet, event.sums.caloMetPhi), pfMET_NoMu_Emu=Met(event.sums.pfMetNoMu, event.sums.pfMetNoMuPhi), )) online.update(dict( caloHT_Emu=event.l1Sums["L1EmuHtt"], pfHT_Emu=event.l1Sums["L1EmuHtt"], caloMETBE_Emu=event.l1Sums["L1EmuMet"], caloMETHF_Emu=event.l1Sums["L1EmuMetHF"], pfMET_NoMu_Emu=event.l1Sums["L1EmuMetHF"], )) return offline, online
def produce(self, event): calculateMET = True if 'Generator_genMetTrue' not in self._inputs else False variables = [event[i] for i in self._inputs] prefix = self._outputs[0] + '_' if calculateMET: jet_pt, jet_eta, part_id, partPhi, partPt, partEta = variables else: jet_pt, jet_eta, part_id, partPhi, partPt, partEta, genMetTrue = variables ht = 0 for pt, eta in zip(jet_pt, jet_eta): if abs(eta) < 2.4: ht += pt # setattr(event, prefix + 'HT', EnergySum(np.sum(jet_pt))) setattr(event, prefix + 'HT', EnergySum(ht)) if calculateMET: part_id = np.absolute(part_id) partEta = np.absolute(partEta) partPhi = np.array(partPhi) partPt = np.array(partPt) # nu_e, mu, nu_mu, nu_tau particleMask = (part_id == 12) | (part_id == 13) | ( part_id == 14) | (part_id == 16) eta_mask = partEta < 3.0 genMetHF = self._calculate_met(partPt, partPhi, particleMask) genMetBE = self._calculate_met(partPt, partPhi, particleMask & eta_mask) setattr(event, prefix + 'MetHF', genMetHF) setattr(event, prefix + 'MetBE', genMetBE) else: setattr(event, prefix + 'MetBE', Met(genMetTrue, 0)) setattr(event, prefix + 'MetHF', Met(genMetTrue, 0)) return True
def extractSums(event, doEmu, doReco, doGen): offline = dict() online = dict() if doReco: offline.update( dict( caloHT=EnergySum(event.Sums_caloHt), pfHT=EnergySum(event.Sums_Ht), caloMETBE=Met(event.Sums_caloMetBE, event.Sums_caloMetPhiBE), caloMETHF=Met(event.Sums_caloMet, event.Sums_caloMetPhi), pfMET_NoMu=Met(event.Sums_pfMetNoMu, event.Sums_pfMetNoMuPhi), )) online.update( dict( caloHT=event.l1Sums_Htt, pfHT=event.l1Sums_Htt, caloMETBE=event.l1Sums_Met, caloMETHF=event.l1Sums_MetHF, pfMET_NoMu=event.l1Sums_MetHF, )) if doEmu: offline.update( dict( caloHT_Emu=EnergySum(event.Sums_caloHt), pfHT_Emu=EnergySum(event.Sums_Ht), caloMETBE_Emu=Met(event.Sums_caloMetBE, event.Sums_caloMetPhiBE), caloMETHF_Emu=Met(event.Sums_caloMet, event.Sums_caloMetPhi), pfMET_NoMu_Emu=Met(event.Sums_pfMetNoMu, event.Sums_pfMetNoMuPhi), )) online.update( dict( caloHT_Emu=event.l1EmuSums_Htt, pfHT_Emu=event.l1EmuSums_Htt, caloMETBE_Emu=event.l1EmuSums_Met, caloMETHF_Emu=event.l1EmuSums_MetHF, pfMET_NoMu_Emu=event.l1EmuSums_MetHF, )) if doGen: offline.update( dict( genHT=event.genSums_HT, genMETHF=event.genSums_MetHF, genMETBE=event.genSums_MetBE, )) online.update( dict( genHT=event.l1Sums_Htt, genMETHF=event.l1Sums_MetHF, genMETBE=event.l1Sums_Met, )) if doEmu: offline.update( dict( genHT_Emu=event.genSums_HT, genMETHF_Emu=event.genSums_MetHF, genMETBE_Emu=event.genSums_MetBE, )) online.update( dict( genHT_Emu=event.l1EmuSums_Htt, genMETHF_Emu=event.l1EmuSums_MetHF, genMETBE_Emu=event.l1EmuSums_Met, )) return offline, online
def _calculate_met(self, partPt, partPhi, mask): met_x = np.dot(partPt[mask], np.cos(partPhi[mask])) met_y = np.dot(partPt[mask], np.sin(partPhi[mask])) met = np.sqrt(met_x**2 + met_y**2) met_phi = math.atan(met_y / met_x) return Met(met, met_phi)
def ExtractSums(event): offline = dict( HTT=EnergySum(event.sums.Ht), MHT=Met(event.sums.mHt, event.sums.mHtPhi), MET_HF=Met(event.sums.caloMet, event.sums.caloMetPhi), MET=Met(event.sums.caloMetBE, event.sums.caloMetPhiBE), MET_PF=Met(event.sums.met, event.sums.metPhi), MET_PF_NoMu=Met(event.sums.pfMetNoMu, event.sums.pfMetNoMuPhi), MET_PF_HF=Met(event.sums.met, event.sums.metPhi), MET_PF_NoMu_HF=Met(event.sums.pfMetNoMu, event.sums.pfMetNoMuPhi), HTT_Emu=EnergySum(event.sums.Ht), MHT_Emu=Met(event.sums.mHt, event.sums.mHtPhi), MET_HF_Emu=Met(event.sums.caloMet, event.sums.caloMetPhi), MET_Emu=Met(event.sums.caloMetBE, event.sums.caloMetPhiBE), MET_PF_Emu=Met(event.sums.met, event.sums.metPhi), MET_PF_NoMu_Emu=Met(event.sums.pfMetNoMu, event.sums.pfMetNoMuPhi), MET_PF_HF_Emu=Met(event.sums.met, event.sums.metPhi), MET_PF_NoMu_HF_Emu=Met(event.sums.pfMetNoMu, event.sums.pfMetNoMuPhi) ) online = dict( HTT=event.l1Sums["L1Htt"], MHT=event.l1Sums["L1Mht"], MET_HF=event.l1Sums["L1MetHF"], MET=event.l1Sums["L1Met"], MET_PF=event.l1Sums["L1Met"], MET_PF_NoMu=event.l1Sums["L1Met"], MET_PF_HF=event.l1Sums["L1MetHF"], MET_PF_NoMu_HF=event.l1Sums["L1MetHF"], HTT_Emu=event.l1Sums["L1EmuHtt"], MHT_Emu=event.l1Sums["L1EmuMht"], MET_HF_Emu=event.l1Sums["L1EmuMetHF"], MET_Emu=event.l1Sums["L1EmuMet"], MET_PF_Emu=event.l1Sums["L1EmuMet"], MET_PF_NoMu_Emu=event.l1Sums["L1EmuMet"], MET_PF_HF_Emu=event.l1Sums["L1EmuMetHF"], MET_PF_NoMu_HF_Emu=event.l1Sums["L1EmuMetHF"] ) return online, offline
def produce(self, event): setattr(event, self._outputs[0] + '_Met', Met(event['L1PhaseII_puppiMETEt'], event['L1PhaseII_puppiMETPhi'])) setattr(event, self._outputs[0] + '_MetHF', Met(event['L1PhaseII_puppiMETEt'], event['L1PhaseII_puppiMETPhi'])) setattr(event, self._outputs[0] + '_Htt', EnergySum(event['L1PhaseII_puppiHT'][0])) return True