def process(self, iEvent, event): self.readCollections( iEvent ) cmgJets = self.handles['jets'].product() allJets = [] event.jets = [] event.bJets = [] event.cleanJets = [] event.cleanBJets = [] leptons = [] if hasattr(event, 'selectedLeptons'): leptons = event.selectedLeptons genJets = None if self.cfg_comp.isMC: genJets = map( GenJet, self.mchandles['genJets'].product() ) for cmgJet in cmgJets: jet = Jet( cmgJet ) allJets.append( jet ) if self.cfg_comp.isMC and hasattr( self.cfg_comp, 'jetScale'): scale = random.gauss( self.cfg_comp.jetScale, self.cfg_comp.jetSmear ) jet.scaleEnergy( scale ) if genJets: # Use DeltaR = 0.25 matching like JetMET pairs = matchObjectCollection( [jet], genJets, 0.25*0.25) if pairs[jet] is None: pass else: jet.matchedGenJet = pairs[jet] #Add JER correction for MC jets. Requires gen-jet matching. if self.cfg_comp.isMC and hasattr(self.cfg_ana, 'jerCorr') and self.cfg_ana.jerCorr: self.jerCorrection(jet) #Add JES correction for MC jets. if self.cfg_comp.isMC and hasattr(self.cfg_ana, 'jesCorr'): self.jesCorrection(jet, self.cfg_ana.jesCorr) if self.testJet( jet ): event.jets.append(jet) if self.testBJet(jet): event.bJets.append(jet) self.counters.counter('jets').inc('all events') event.cleanJets, dummy = cleanObjectCollection( event.jets, masks = leptons, deltaRMin = 0.5 ) event.cleanBJets, dummy = cleanObjectCollection( event.bJets, masks = leptons, deltaRMin = 0.5 ) pairs = matchObjectCollection( leptons, allJets, 0.5*0.5) # associating a jet to each lepton for lepton in leptons: jet = pairs[lepton] if jet is None: lepton.jet = lepton else: lepton.jet = jet # associating a leg to each clean jet invpairs = matchObjectCollection( event.cleanJets, leptons, 99999. ) for jet in event.cleanJets: leg = invpairs[jet] jet.leg = leg for jet in event.cleanJets: jet.matchGenParton=999.0 if self.cfg_comp.isMC and "BB" in self.cfg_comp.name: genParticles = self.mchandles['genParticles'].product() event.genParticles = map( GenParticle, genParticles) for gen in genParticles: if abs(gen.pdgId())==5 and gen.mother() and abs(gen.mother().pdgId())==21: for jet in event.cleanJets: dR=deltaR2(jet.eta(), jet.phi(), gen.eta(), gen.phi() ) if dR<jet.matchGenParton: jet.matchGenParton=dR event.jets30 = [jet for jet in event.jets if jet.pt()>30] event.cleanJets30 = [jet for jet in event.cleanJets if jet.pt()>30] if len( event.jets30 )>=2: self.counters.counter('jets').inc('at least 2 good jets') if len( event.cleanJets30 )>=2: self.counters.counter('jets').inc('at least 2 clean jets') if len(event.cleanJets)<2: return True return True
def process(self, iEvent, event): self.readCollections( iEvent ) cmgJets = self.handles['jets'].product() print 'cmgJets = ', len(cmgJets) allJets = [] event.jets = [] event.bJets = [] event.cleanJets = [] event.cleanBJets = [] # import pdb; pdb.set_trace(); leptons = [] if hasattr(event, 'selectedLeptons'): leptons = event.selectedLeptons # elif hasattr(event, 'muoncand'): ## leptons = event.muoncand + event.electroncand + event.taucand # leptons = event.muon + event.electron + event.tau # print '# of leptons = ', len(leptons) genJets = None if self.cfg_comp.isMC: genJets = map( GenJet, self.mchandles['genJets'].product() ) for cmgJet in cmgJets: jet = Jet( cmgJet ) allJets.append( jet ) if self.cfg_comp.isMC and hasattr( self.cfg_comp, 'jetScale'): scale = random.gauss( self.cfg_comp.jetScale, self.cfg_comp.jetSmear ) jet.scaleEnergy( scale ) if genJets: # Use DeltaR = 0.25 matching like JetMET pairs = matchObjectCollection( [jet], genJets, 0.25*0.25) if pairs[jet] is None: pass #jet.genJet = None else: jet.genJet = pairs[jet] # print jet, jet.genJet #Add JER correction for MC jets. Requires gen-jet matching. if self.cfg_comp.isMC and hasattr(self.cfg_ana, 'jerCorr') and self.cfg_ana.jerCorr: self.jerCorrection(jet) #Add JES correction for MC jets. if self.cfg_comp.isMC and hasattr(self.cfg_ana, 'jesCorr'): self.jesCorrection(jet, self.cfg_ana.jesCorr) if self.testJet( jet ): event.jets.append(jet) if self.testBJet(jet): event.bJets.append(jet) self.counters.counter('jets').inc('all events') # print 'check =', len(event.muon), len(event,electron), len(event.tau) # if isinstance(event.muoncand, list): # event.cleanBJets, dummy = cleanObjectCollection( event.bJets, # masks = event.muoncand, # deltaRMin = 0.4 ) # # event.cleanJets, dummy = cleanObjectCollection( event.jets, # masks = event.muoncand, # deltaRMin = 0.4 ) # # else: # event.cleanBJets, dummy = cleanObjectCollection( event.bJets, # masks = [event.muoncand], # deltaRMin = 0.4 ) # # event.cleanJets, dummy = cleanObjectCollection( event.jets, # masks = [event.muoncand], # deltaRMin = 0.4 ) # # if isinstance(event.electroncand, list): # event.cleanBJets, dummy = cleanObjectCollection( event.cleanBJets, # masks = event.electroncand, # deltaRMin = 0.4 ) # # event.cleanJets, dummy = cleanObjectCollection( event.cleanJets, # masks = event.electroncand, # deltaRMin = 0.4 ) # # else: # event.cleanBJets, dummy = cleanObjectCollection( event.cleanBJets, # masks = [event.electroncand], # deltaRMin = 0.4 ) # # # event.cleanJets, dummy = cleanObjectCollection( event.cleanJets, # masks = [event.electroncand], # deltaRMin = 0.4 ) # # # if isinstance(event.taucand, list): # event.cleanBJets, dummy = cleanObjectCollection( event.cleanBJets, # masks = event.taucand, # deltaRMin = 0.4 ) # # event.cleanJets, dummy = cleanObjectCollection( event.cleanJets, # masks = event.taucand, # deltaRMin = 0.4 ) # # else: # event.cleanBJets, dummy = cleanObjectCollection( event.cleanBJets, # masks = [event.taucand], # deltaRMin = 0.4 ) # # # event.cleanJets, dummy = cleanObjectCollection( event.cleanJets, # masks = [event.taucand], # deltaRMin = 0.4 ) pairs = matchObjectCollection( leptons, allJets, 0.5*0.5) # associating a jet to each lepton for lepton in leptons: jet = pairs[lepton] if jet is None: lepton.jet = lepton else: lepton.jet = jet # associating a leg to each clean jet invpairs = matchObjectCollection( event.cleanJets, leptons, 99999. ) for jet in event.cleanJets: leg = invpairs[jet] jet.leg = leg for jet in event.cleanJets: jet.matchGenParton=999.0 if self.cfg_comp.isMC and "BB" in self.cfg_comp.name: genParticles = self.mchandles['genParticles'].product() event.genParticles = map( GenParticle, genParticles) for gen in genParticles: if abs(gen.pdgId())==5 and gen.mother() and abs(gen.mother().pdgId())==21: for jet in event.cleanJets: dR=deltaR2(jet.eta(), jet.phi(), gen.eta(), gen.phi() ) if dR<jet.matchGenParton: jet.matchGenParton=dR event.jets30 = [jet for jet in event.jets if jet.pt()>30] event.cleanJets30 = [jet for jet in event.cleanJets if jet.pt()>30] # if len( event.jets30 )>=2: # self.counters.counter('jets').inc('at least 2 good jets') # if len( event.cleanJets30 )>=2: # self.counters.counter('jets').inc('at least 2 clean jets') event.cleanJets = event.jets event.cleanBJets = event.bJets # print 'cleanJets = ', len(event.jets) # print 'clean_bJets = ', len(event.bJets) # if len(event.bJets)>0: # if len(event.cleanBJets)>0: # import pdb; pdb.set_trace() # return False self.counters.counter('jets').inc('No b jets') return True
def process(self, iEvent, event): self.readCollections( iEvent ) cmgJets = self.handles['jets'].product() allJets = [] event.jets = [] event.bJets = [] event.cleanJets = [] event.cleanBJets = [] leg1 = event.diLepton.leg1() leg2 = event.diLepton.leg2() genJets = None if self.cfg_comp.isMC: genJets = map( GenJet, self.mchandles['genJets'].product() ) for cmgJet in cmgJets: jet = Jet( cmgJet ) allJets.append( jet ) if self.cfg_comp.isMC and hasattr( self.cfg_comp, 'jetScale'): scale = random.gauss( self.cfg_comp.jetScale, self.cfg_comp.jetSmear ) jet.scaleEnergy( scale ) if self.testJet( jet ): event.jets.append(jet) if self.testBJet(jet): event.bJets.append(jet) if genJets: # Use DeltaR = 0.25 matching like JetMET pairs = matchObjectCollection( [jet], genJets, 0.25*0.25) if pairs[jet] is None: pass #jet.genJet = None else: jet.genJet = pairs[jet] #Add JER correction for MC jets. Requires gen-jet matching if self.cfg_comp.isMC and hasattr(self.cfg_ana, 'jerCorr') and self.cfg_ana.jerCorr: self.jerCorrection(jet) self.counters.counter('VBF').inc('all events') event.cleanJets, dummy = cleanObjectCollection( event.jets, masks = [leg1, leg2 ], deltaRMin = 0.5 ) event.cleanBJets, dummy = cleanObjectCollection( event.bJets, masks = [leg1, leg2 ], deltaRMin = 0.5 ) pairs = matchObjectCollection( [ leg1, leg2 ], allJets, 0.5*0.5) # associating a jet to each leg leg1.jet = pairs[leg1] leg2.jet = pairs[leg2] if leg1.jet is None: #COLIN: I don't understand the code below... leg1.jet = leg1 if leg2.jet is None: leg2.jet = leg2 # associating a leg to each clean jet invpairs = matchObjectCollection( event.cleanJets, [ leg1,leg2 ], 99999. ) for jet in event.cleanJets: leg = invpairs[jet] jet.leg = leg for jet in event.cleanJets: jet.matchGenParton=999.0 if self.cfg_comp.isMC and "BB" in self.cfg_comp.name: genParticles = self.mchandles['genParticles'].product() event.genParticles = map( GenParticle, genParticles) for gen in genParticles: if abs(gen.pdgId())==5 and gen.mother() and abs(gen.mother().pdgId())==21: for jet in event.cleanJets: dR=deltaR2(jet.eta(), jet.phi(), gen.eta(), gen.phi() ) if dR<jet.matchGenParton: jet.matchGenParton=dR event.jets30 = [jet for jet in event.jets if jet.pt()>30] event.cleanJets30 = [jet for jet in event.cleanJets if jet.pt()>30] if len( event.jets30 )>=2: self.counters.counter('VBF').inc('at least 2 good jets') if len( event.cleanJets30 )>=2: self.counters.counter('VBF').inc('at least 2 clean jets') if len(event.cleanJets)<2: return True event.vbf = VBF( event.cleanJets, event.diLepton, None, self.cfg_ana.cjvPtCut ) if event.vbf.mjj > self.cfg_ana.Mjj: self.counters.counter('VBF').inc('M_jj > {cut:3.1f}'.format(cut=self.cfg_ana.Mjj) ) else: return True if abs(event.vbf.deta) > self.cfg_ana.deltaEta: self.counters.counter('VBF').inc('delta Eta > {cut:3.1f}'.format(cut=self.cfg_ana.deltaEta) ) else: return True if len(event.vbf.centralJets)==0: self.counters.counter('VBF').inc('no central jets') else: return True return True
def process(self, iEvent, event): self.readCollections( iEvent ) cmgJets = self.handles['jets'].product() allJets = [] event.jets = [] event.bJets = [] event.cleanJets = [] event.cleanBJets = [] leptons = event.selectedLeptons genJets = None if self.cfg_comp.isMC: genJets = map( GenJet, self.mchandles['genJets'].product() ) for cmgJet in cmgJets: jet = Jet( cmgJet ) allJets.append( jet ) if self.cfg_comp.isMC and hasattr( self.cfg_comp, 'jetScale'): scale = random.gauss( self.cfg_comp.jetScale, self.cfg_comp.jetSmear ) jet.scaleEnergy( scale ) if genJets: # Use DeltaR = 0.25 matching like JetMET pairs = matchObjectCollection( [jet], genJets, 0.25*0.25) if pairs[jet] is None: pass #jet.genJet = None else: jet.genJet = pairs[jet] # print jet, jet.genJet #Add JER correction for MC jets. Requires gen-jet matching. if self.cfg_comp.isMC and hasattr(self.cfg_ana, 'jerCorr') and self.cfg_ana.jerCorr: self.jerCorrection(jet) #Add JES correction for MC jets. if self.cfg_comp.isMC and hasattr(self.cfg_ana, 'jesCorr'): self.jesCorrection(jet, self.cfg_ana.jesCorr) if self.testJet( jet ): event.jets.append(jet) if self.testBJet(jet): event.bJets.append(jet) self.counters.counter('jets').inc('all events') event.cleanJets, dummy = cleanObjectCollection( event.jets, masks = leptons, deltaRMin = 0.5 ) event.cleanBJets, dummy = cleanObjectCollection( event.bJets, masks = leptons, deltaRMin = 0.5 ) pairs = matchObjectCollection( leptons, allJets, 0.5*0.5) # associating a jet to each lepton for lepton in leptons: jet = pairs[lepton] if jet is None: lepton.jet = lepton else: lepton.jet = jet # associating a leg to each clean jet invpairs = matchObjectCollection( event.cleanJets, leptons, 99999. ) for jet in event.cleanJets: leg = invpairs[jet] jet.leg = leg for jet in event.cleanJets: jet.matchGenParton=999.0 if self.cfg_comp.isMC and "BB" in self.cfg_comp.name: genParticles = self.mchandles['genParticles'].product() event.genParticles = map( GenParticle, genParticles) for gen in genParticles: if abs(gen.pdgId())==5 and gen.mother() and abs(gen.mother().pdgId())==21: for jet in event.cleanJets: dR=deltaR2(jet.eta(), jet.phi(), gen.eta(), gen.phi() ) if dR<jet.matchGenParton: jet.matchGenParton=dR event.jets30 = [jet for jet in event.jets if jet.pt()>30] event.cleanJets30 = [jet for jet in event.cleanJets if jet.pt()>30] if len( event.jets30 )>=2: self.counters.counter('jets').inc('at least 2 good jets') if len( event.cleanJets30 )>=2: self.counters.counter('jets').inc('at least 2 clean jets') if len(event.cleanJets)<2: return True return True