CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Jet.py
Go to the documentation of this file.
2 
3 loose_WP = [
4  (0, 2.5, -0.8),
5  (2.5, 2.75, -0.74),
6  (2.75, 3.0, -0.68),
7  (3.0, 5.0, -0.77),
8  ]
9 
10 # Working point 2 May 2013 (Phil via H2tau list)
11 loose_53X_WP = [
12  (0, 2.5, -0.63),
13  (2.5, 2.75, -0.60),
14  (2.75, 3.0, -0.55),
15  (3.0, 5.2, -0.45),
16  ]
17 
18 _btagWPs = {
19  "TCHEL": ("pfTrackCountingHighEffBJetTags", 1.7),
20  "TCHEM": ("pfTrackCountingHighEffBJetTags", 3.3),
21  "TCHPT": ("pfTrackCountingHighPurBJetTags", 3.41),
22  "JPL": ("pfJetProbabilityBJetTags", 0.275),
23  "JPM": ("pfJetProbabilityBJetTags", 0.545),
24  "JPT": ("pfJetProbabilityBJetTags", 0.790),
25  "CSVL": ("combinedSecondaryVertexBJetTags", 0.244),
26  "CSVM": ("combinedSecondaryVertexBJetTags", 0.679),
27  "CSVT": ("combinedSecondaryVertexBJetTags", 0.898),
28  "CSVv2IVFL": ("pfCombinedInclusiveSecondaryVertexV2BJetTags", 0.423),
29  "CSVv2IVFM": ("pfCombinedInclusiveSecondaryVertexV2BJetTags", 0.814),
30  "CSVv2IVFT": ("pfCombinedInclusiveSecondaryVertexV2BJetTags", 0.941),
31  "CMVAL": ("pfCombinedMVABJetTags", 0.630), # for same b-jet efficiency of CSVv2IVFL on ttbar MC, jet pt > 30
32  "CMVAM": ("pfCombinedMVABJetTags", 0.732), # for same b-jet efficiency of CSVv2IVFM on ttbar MC, jet pt > 30
33  "CMVAT": ("pfCombinedMVABJetTags", 0.813), # for same b-jet efficiency of CSVv2IVFT on ttbar MC, jet pt > 30
34 
35 }
36 
38  def __init__(self, *args, **kwargs):
39  super(Jet, self).__init__(*args, **kwargs)
40  self._physObjInit()
41 
42  def _physObjInit(self):
44  self._leadingTrack = None
45  self._leadingTrackSearched = False
46 
47  def jetID(self,name=""):
48  if not self.isPFJet():
49  raise RuntimeError, "jetID implemented only for PF Jets"
50  eta = abs(self.eta());
51  energy = (self.p4()*self.rawFactor()).energy();
52  chf = self.chargedHadronEnergy()/energy;
53  nhf = self.neutralHadronEnergy()/energy;
54  phf = self.neutralEmEnergy()/energy;
55  muf = self.muonEnergy()/energy;
56  elf = self.chargedEmEnergy()/energy;
57  chm = self.chargedHadronMultiplicity();
58  npr = self.chargedMultiplicity() + self.neutralMultiplicity();
59  #if npr != self.nConstituents():
60  # import pdb; pdb.set_trace()
61  if name == "POG_PFID":
62  if self.jetID("POG_PFID_Tight") : return 3;
63  elif self.jetID("POG_PFID_Medium") : return 2;
64  elif self.jetID("POG_PFID_Loose") : return 1;
65  else : return 0;
66 
67  if name == "POG_PFID_Loose": return (npr>1 and phf<0.99 and nhf<0.99 and muf < 0.8) and (eta>2.4 or (elf<0.99 and chf>0 and chm>0));
68  if name == "POG_PFID_Medium": return (npr>1 and phf<0.95 and nhf<0.95 and muf < 0.8) and (eta>2.4 or (elf<0.99 and chf>0 and chm>0));
69  if name == "POG_PFID_Tight": return (npr>1 and phf<0.90 and nhf<0.90 and muf < 0.8) and (eta>2.4 or (elf<0.90 and chf>0 and chm>0));
70  if name == "VBFHBB_PFID_Loose": return (npr>1 and phf<0.99 and nhf<0.99);
71  if name == "VBFHBB_PFID_Medium": return (npr>1 and phf<0.99 and nhf<0.99) and ((eta<=2.4 and nhf<0.9 and phf<0.9 and elf<0.99 and muf<0.99 and chf>0 and chm>0) or eta>2.4);
72  if name == "VBFHBB_PFID_Tight": return (npr>1 and phf<0.99 and nhf<0.99) and ((eta<=2.4 and nhf<0.9 and phf<0.9 and elf<0.70 and muf<0.70 and chf>0 and chm>0) or eta>2.4);
73  raise RuntimeError, "jetID '%s' not supported" % name
74 
75  def looseJetId(self):
76  '''PF Jet ID (loose operation point) [method provided for convenience only]'''
77  return self.jetID("POG_PFID_Loose")
78 
79  def puMva(self, label="pileupJetId:fullDiscriminant"):
80  return self.userFloat(label)
81 
82  def puJetId(self, label="pileupJetId:fullDiscriminant"):
83  '''Full mva PU jet id'''
84 
85  puMva = self.puMva(label)
86  wp = loose_53X_WP
87  eta = abs(self.eta())
88 
89  for etamin, etamax, cut in wp:
90  if not(eta>=etamin and eta<etamax):
91  continue
92  return puMva>cut
93 
94  def rawFactor(self):
95  return self.jecFactor('Uncorrected') * self._rawFactorMultiplier
96  def setRawFactor(self, factor):
97  self._rawFactorMultiplier = factor/self.jecFactor('Uncorrected')
98 
99  def btag(self,name):
100  ret = self.bDiscriminator(name)
101  if ret == -1000 and name.startswith("pf"):
102  ret = self.bDiscriminator(name[2].lower()+name[3:])
103  return ret
104 
105  def btagWP(self,name):
106  global _btagWPs
107  (disc,val) = _btagWPs[name]
108  return self.btag(disc) > val
109 
110  def leadingTrack(self):
111  if self._leadingTrackSearched :
112  return self._leadingTrack
113  self._leadingTrackSearched = True
114  self._leadingTrack = max( self.daughterPtrVector() , key = lambda x : x.pt() if x.charge()!=0 else 0. )
115  if self._leadingTrack.charge()==0: #in case of "all neutral"
116  self._leadingTrack = None
117  return self._leadingTrack
118 
119  def leadTrackPt(self):
120  lt=self.leadingTrack()
121  if lt :
122  return lt.pt()
123  else :
124  return 0.
125 
127  pass
128 
def puMva
Definition: Jet.py:79
def looseJetId
Definition: Jet.py:75
def puJetId
Definition: Jet.py:82
_leadingTrack
Definition: Jet.py:44
def setRawFactor
Definition: Jet.py:96
def btag
Definition: Jet.py:99
def _physObjInit
Definition: Jet.py:42
_rawFactorMultiplier
Definition: Jet.py:43
def leadingTrack
Definition: Jet.py:110
def __init__
Definition: Jet.py:38
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def jetID
Definition: Jet.py:47
def leadTrackPt
Definition: Jet.py:119
_leadingTrackSearched
Definition: Jet.py:45
def rawFactor
Definition: Jet.py:94
def btagWP
Definition: Jet.py:105
Definition: Jet.py:37