1 from builtins
import range
22 "TCHEL": (
"pfTrackCountingHighEffBJetTags", 1.7),
23 "TCHEM": (
"pfTrackCountingHighEffBJetTags", 3.3),
24 "TCHPT": (
"pfTrackCountingHighPurBJetTags", 3.41),
25 "JPL": (
"pfJetProbabilityBJetTags", 0.275),
26 "JPM": (
"pfJetProbabilityBJetTags", 0.545),
27 "JPT": (
"pfJetProbabilityBJetTags", 0.790),
28 "CSVL": (
"combinedSecondaryVertexBJetTags", 0.244),
29 "CSVM": (
"combinedSecondaryVertexBJetTags", 0.679),
30 "CSVT": (
"combinedSecondaryVertexBJetTags", 0.898),
32 "CMVAL": (
"pfCombinedMVABJetTags", 0.630),
33 "CMVAM": (
"pfCombinedMVABJetTags", 0.732),
34 "CMVAT": (
"pfCombinedMVABJetTags", 0.813),
35 "CMVAv2M": (
"pfCombinedMVAV2BJetTags", 0.185),
37 "CSVv2IVFL": (
"pfCombinedInclusiveSecondaryVertexV2BJetTags", 0.460),
38 "CSVv2IVFM": (
"pfCombinedInclusiveSecondaryVertexV2BJetTags", 0.800),
39 "CSVv2IVFT": (
"pfCombinedInclusiveSecondaryVertexV2BJetTags", 0.935),
40 "CMVAv2L": (
"pfCombinedMVAV2BJetTags", -0.715),
41 "CMVAv2M": (
"pfCombinedMVAV2BJetTags", 0.185),
42 "CMVAv2T": (
"pfCombinedMVAV2BJetTags", 0.875),
48 super(Jet, self).
__init__(*args, **kwargs)
64 return self.chargedEmEnergy()/self.
rawEnergy()
67 return self.chargedHadronEnergy()/self.
rawEnergy()
70 return self.chargedMuEnergy()/self.
rawEnergy()
73 return self.electronEnergy()/self.
rawEnergy()
79 return self.neutralEmEnergy()/self.
rawEnergy()
82 return self.neutralHadronEnergy()/self.
rawEnergy()
85 return self.photonEnergy()/self.
rawEnergy()
89 return self.HFHadronEnergy()/self.
rawEnergy()
100 if not self.isPFJet():
101 raise RuntimeError(
"jetID implemented only for PF Jets")
102 eta =
abs(self.eta());
104 chf = self.chargedHadronEnergy()/energy;
105 nhf = self.neutralHadronEnergy()/energy;
106 phf = self.neutralEmEnergy()/energy;
107 muf = self.muonEnergy()/energy;
108 elf = self.chargedEmEnergy()/energy;
109 chm = self.chargedHadronMultiplicity();
110 npr = self.chargedMultiplicity() + self.neutralMultiplicity();
111 npn = self.neutralMultiplicity();
114 if name ==
"POG_PFID":
116 if self.
jetID(
"PAG_monoID_Tight")
and self.
jetID(
"POG_PFID_Tight") :
return 5;
117 if self.
jetID(
"PAG_monoID_Loose")
and self.
jetID(
"POG_PFID_Tight") :
return 4;
118 if self.
jetID(
"POG_PFID_Tight") :
return 3;
120 elif self.
jetID(
"POG_PFID_Loose") :
return 1;
124 if name ==
"POG_PFID_Loose":
return ((eta<3.0
and ((npr>1
and phf<0.99
and nhf<0.99)
and (eta>2.4
or (elf<0.99
and chf>0
and chm>0))))
or (eta>3.0
and (phf<0.90
and npn>10)));
125 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));
126 if name ==
"POG_PFID_Tight":
return ((eta<3.0
and ((npr>1
and phf<0.90
and nhf<0.90)
and (eta>2.4
or (elf<0.99
and chf>0
and chm>0))))
or (eta>3.0
and (phf<0.90
and npn>10)));
127 if name ==
"VBFHBB_PFID_Loose":
return (npr>1
and phf<0.99
and nhf<0.99);
128 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);
129 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);
130 if name ==
"PAG_monoID_Loose":
return (eta<3.0
and chf>0.05
and nhf<0.7
and phf<0.8);
131 if name ==
"PAG_monoID_Tight":
return (eta<3.0
and chf>0.2
and nhf<0.7
and phf<0.7);
133 raise RuntimeError(
"jetID '%s' not supported" % name)
136 '''PF Jet ID (loose operation point) [method provided for convenience only]'''
137 return self.
jetID(
"POG_PFID_Loose")
139 def puMva(self, label="pileupJetId:fullDiscriminant
"):
140 if self.hasUserFloat(label):
141 return self.userFloat(label)
144 def puJetId(self, label="pileupJetId:fullDiscriminant
"):
145 '''Full mva PU jet id'''
147 puMva = self.
puMva(label)
149 eta =
abs(self.eta())
151 for etamin, etamax, cut
in wp:
152 if not(eta>=etamin
and eta<etamax):
168 corr = newP4.Pt() / (self.pt() * self.
rawFactor())
173 if hasattr(self,
'CorrFactor_L1'):
174 return self.CorrFactor_L1
176 raise RuntimeError(
"The jet was recalibrated, but without calculateSeparateCorrections. L1 is not available")
177 jecLevels = self.physObj.availableJECLevels()
178 for level
in jecLevels:
180 return self.physObj.jecFactor(level)/self.physObj.jecFactor(
'Uncorrected')
184 ret = self.bDiscriminator(name)
185 if ret == -1000
and name.startswith(
"pf"):
186 ret = self.bDiscriminator(name[2].lower()+name[3:])
191 (disc,val) = _btagWPs[name]
192 return self.
btag(disc) > val
198 self.
_leadingTrack =
max( self.daughterPtrVector() , key =
lambda x : x.pt()
if x.charge()!=0
else 0. )
210 if not hasattr(self,
"qgl_value") :
211 if hasattr(self,
"qgl_rho") :
221 if not hasattr(self,
"qgl_rho")
or getattr(self,
"hasQGVvars",
False) :
237 for ii
in range(0, jet.numberOfDaughters()) :
239 part = jet.daughter(ii)
241 if part.charge() == 0 :
243 if part.pt() < 1.:
continue
247 if part.trackHighPurity()==
False:
continue
248 if part.fromPV()<=1:
continue
253 deta = part.eta() - jet.eta()
254 dphi =
deltaPhi(part.phi(), jet.phi())
256 weight = partPt*partPt
259 sum_deta += deta*weight
260 sum_dphi += dphi*weight
261 sum_deta2 += deta*deta*weight
262 sum_detadphi += deta*dphi*weight
263 sum_dphi2 += dphi*dphi*weight
273 jet.ptd = math.sqrt(sum_weight)/sum_pt
274 ave_deta = sum_deta/sum_weight
275 ave_dphi = sum_dphi/sum_weight
276 ave_deta2 = sum_deta2/sum_weight
277 ave_dphi2 = sum_dphi2/sum_weight
278 a = ave_deta2 - ave_deta*ave_deta
279 b = ave_dphi2 - ave_dphi*ave_dphi
280 c = -(sum_detadphi/sum_weight - ave_deta*ave_dphi)
283 delta = math.sqrt(math.fabs((a-b)*(a-b)+4.*c*c))
285 if a+b-delta > 0: jet.axis2 = -math.log(math.sqrt(0.5*(a+b-delta)))
286 else: jet.axis2 = -1.