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": ("trackCountingHighEffBJetTags", 1.7),
20  "TCHEM": ("trackCountingHighEffBJetTags", 3.3),
21  "TCHPT": ("trackCountingHighPurBJetTags", 3.41),
22  "JPL": ("jetProbabilityBJetTags", 0.275),
23  "JPM": ("jetProbabilityBJetTags", 0.545),
24  "JPT": ("jetProbabilityBJetTags", 0.790),
25  "CSVL": ("combinedSecondaryVertexBJetTags", 0.244),
26  "CSVM": ("combinedSecondaryVertexBJetTags", 0.679),
27  "CSVT": ("combinedSecondaryVertexBJetTags", 0.898),
28  "CSVv2IVFL": ("combinedInclusiveSecondaryVertexV2BJetTags", 0.423),
29  "CSVv2IVFM": ("combinedInclusiveSecondaryVertexV2BJetTags", 0.814),
30  "CSVv2IVFT": ("combinedInclusiveSecondaryVertexV2BJetTags", 0.941),
31  "CMVAL": ("combinedMVABJetTags", 0.630), # for same b-jet efficiency of CSVv2IVFL on ttbar MC, jet pt > 30
32  "CMVAM": ("combinedMVABJetTags", 0.732), # for same b-jet efficiency of CSVv2IVFM on ttbar MC, jet pt > 30
33  "CMVAT": ("combinedMVABJetTags", 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 (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 (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 (eta>2.4 or (elf<0.99 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  return self.bDiscriminator(name)
101 
102  def btagWP(self,name):
103  global _btagWPs
104  (disc,val) = _btagWPs[name]
105  return self.bDiscriminator(disc) > val
106 
107  def leadingTrack(self):
108  if self._leadingTrackSearched :
109  return self._leadingTrack
110  self._leadingTrackSearched = True
111  self._leadingTrack = max( self.daughterPtrVector() , key = lambda x : x.pt() if x.charge()!=0 else 0. )
112  if self._leadingTrack.charge()==0: #in case of "all neutral"
113  self._leadingTrack = None
114  return self._leadingTrack
115 
116  def leadTrackPt(self):
117  lt=self.leadingTrack()
118  if lt :
119  return lt.pt()
120  else :
121  return 0.
122 
124  pass
125 
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:107
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:116
_leadingTrackSearched
Definition: Jet.py:45
def rawFactor
Definition: Jet.py:94
def btagWP
Definition: Jet.py:102
Definition: Jet.py:37