CMS 3D CMS Logo

GenHeavyFlavourAnalyzer.py
Go to the documentation of this file.
1 from PhysicsTools.Heppy.analyzers.core.Analyzer import Analyzer
3 
5  """
6  Makes:
7  event.genallbquarks, event.genallcquarks:
8  list of all b and c quarks (without doublecounting of b->b and c->c chains).
9  if status2Only == True, only status 2 ones are included.
10  event.allBPartons
11  all status 2 b-quarks, sorted by pt decreasingly
12  event.bPartons:
13  status 2 b-quarks passing a pt cut bquarkPtCut (default: 15)
14 
15  Requires:
16  event.genParticles
17  """
18 
19  def __init__(self, cfg_ana, cfg_comp, looperName ):
20  super(GenHeavyFlavourAnalyzer,self).__init__(cfg_ana,cfg_comp,looperName)
21  self.status2Only = cfg_ana.status2Only
22  self.bquarkPtCut = cfg_ana.bquarkPtCut
23 
24  def declareHandles(self):
25  super(GenHeavyFlavourAnalyzer, self).declareHandles()
26 
27  def beginLoop(self,setup):
28  super(GenHeavyFlavourAnalyzer,self).beginLoop(setup)
29 
30  def makeBPartons(self,event):
31  event.allBPartons = [ q for q in event.genParticles if abs(q.pdgId()) == 5 and abs(q.status()) == 2 and abs(q.pt()) > self.bquarkPtCut ]
32  event.allBPartons.sort(key = lambda q : q.pt(), reverse = True)
33  event.bPartons = []
34  for q in event.allBPartons:
35  duplicate = False
36  for q2 in event.bPartons:
37  if deltaR(q.eta(),q.phi(),q2.eta(),q2.phi()) < 0.5:
38  duplicate = True
39  continue
40  if not duplicate: event.bPartons.append(q)
41 
42  def process(self, event):
43  self.readCollections( event.input )
44 
45  # if not MC, nothing to do
46  if not self.cfg_comp.isMC:
47  return True
48 
49  status2f = (lambda p : p.status() == 2) if self.status2Only else (lambda p : True)
50  event.genallcquarks = [ p for p in event.genParticles if abs(p.pdgId()) == 5 and ( p.numberOfDaughters() == 0 or abs(p.daughter(0).pdgId()) != 5) and status2f(p) ]
51  event.genallbquarks = [ p for p in event.genParticles if abs(p.pdgId()) == 4 and ( p.numberOfDaughters() == 0 or abs(p.daughter(0).pdgId()) != 4) and status2f(p) ]
52 
53  self.makeBPartons(event)
54 
55  return True
56 
57 import PhysicsTools.HeppyCore.framework.config as cfg
58 setattr(GenHeavyFlavourAnalyzer,"defaultConfig",
59  cfg.Analyzer(GenHeavyFlavourAnalyzer,
60  status2Only = False,
61  bquarkPtCut = 15.0,
62  )
63 )
gen.GenHeavyFlavourAnalyzer.GenHeavyFlavourAnalyzer.bquarkPtCut
bquarkPtCut
Definition: GenHeavyFlavourAnalyzer.py:22
gen.GenHeavyFlavourAnalyzer.GenHeavyFlavourAnalyzer.makeBPartons
def makeBPartons(self, event)
Definition: GenHeavyFlavourAnalyzer.py:30
gen.GenHeavyFlavourAnalyzer.GenHeavyFlavourAnalyzer.declareHandles
def declareHandles(self)
Definition: GenHeavyFlavourAnalyzer.py:24
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
remoteMonitoring_LED_IterMethod_cfg.Analyzer
Analyzer
Definition: remoteMonitoring_LED_IterMethod_cfg.py:32
gen.GenHeavyFlavourAnalyzer.GenHeavyFlavourAnalyzer.beginLoop
def beginLoop(self, setup)
Definition: GenHeavyFlavourAnalyzer.py:27
EgammaValidation_cff.pdgId
pdgId
Definition: EgammaValidation_cff.py:118
gen.GenHeavyFlavourAnalyzer.GenHeavyFlavourAnalyzer.process
def process(self, event)
Definition: GenHeavyFlavourAnalyzer.py:42
gen.GenHeavyFlavourAnalyzer.GenHeavyFlavourAnalyzer
Definition: GenHeavyFlavourAnalyzer.py:4
gen.GenHeavyFlavourAnalyzer.GenHeavyFlavourAnalyzer.status2Only
status2Only
Definition: GenHeavyFlavourAnalyzer.py:21
deltar
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
gen.GenHeavyFlavourAnalyzer.GenHeavyFlavourAnalyzer.__init__
def __init__(self, cfg_ana, cfg_comp, looperName)
Definition: GenHeavyFlavourAnalyzer.py:19