Skip to content

Commit 4e91541

Browse files
committed
Update KLepton
This now includes isolation and IDs
1 parent be117c2 commit 4e91541

File tree

5 files changed

+121
-30
lines changed

5 files changed

+121
-30
lines changed

DataFormats/interface/KTrack.h

Lines changed: 82 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -160,28 +160,96 @@ struct KMuonTriggerCandidate : public KTrack
160160

161161
typedef std::vector<KMuonTriggerCandidate> KMuonTriggerCandidates;
162162

163-
struct KTrackSummary
163+
const unsigned char KLeptonFlavourMask = 3;
164+
const unsigned char KLeptonChargeMask = 1 << 2;
165+
const unsigned char KLeptonAlternativeTrackMask = 1 << 3;
166+
const unsigned char KLeptonPFMask = 1 << 4;
167+
168+
namespace KLeptonFlavour { enum Type
169+
{
170+
NONE = 0,
171+
ELECTRON = 1,
172+
MUON = 2,
173+
TAU = 3
174+
};
175+
}
176+
177+
namespace KLeptonId { enum Type
164178
{
165-
unsigned int nTracks;
166-
unsigned int nTracksHQ;
179+
ANY = 0, //< returns true if the information for any ID was filled
180+
LOOSE = 1, //< e/mu/tau loose ID
181+
MEDIUM = 2, //< e/tau medium ID
182+
TIGHT = 3, //< e/mu tight ID
183+
VETO = 4, //< e veto ID
184+
SOFT = 5, //< mu soft ID
185+
HIGHPT = 6, //< mu high pt ID
186+
CUSTOM = 7, //< empty bit for any userdefined ID
187+
LOOSEELECTRONREJECTION = 4, // tau discriminator
188+
LOOSEMUONREJECTION = 5, // tau discriminator
189+
TIGHTMUONREJECTION = 6 // tau discriminator
167190
};
191+
}
168192

169193
struct KLepton : public KLV
170194
{
171195
public:
172-
enum Flavour
196+
unsigned char leptonInfo; //< bitset containing the flavour, charge and user bits
197+
unsigned char ids; //< most relevant IDs of the lepton
198+
float sumChargedHadronPt; //< sum pt of charged hadrons for isolation
199+
float sumNeutralHadronEt; //< sum Et of neutral hadrons for isolation
200+
float sumPhotonEt; //< sum Et of photons for isolation
201+
float sumPUPt; //< sum pt of pile-up for isolation
202+
KTrack track; //< (main) track of the lepton (e: GSF, mu: inner, tau: lead. PF candidate)
203+
204+
// access functions for leptonInfo
205+
/// lepton flavour according to KLeptonFlavour::Type
206+
inline KLeptonFlavour::Type flavour() const { return KLeptonFlavour::Type(leptonInfo & KLeptonFlavourMask); };
207+
/// lepton charge (+1 or -1)
208+
inline char charge() const { return ((leptonInfo & KLeptonChargeMask) ? +1 : -1); };
209+
/// whether the stored object is reconstructed using PF objects
210+
inline bool isPF() const { return (leptonInfo & KLeptonPFMask); };
211+
/// if the normal track is not available, the producer can fill the track information with a second option and set this flag
212+
inline bool isAlternativeTrack() const { return (leptonInfo & KLeptonAlternativeTrackMask); };
213+
214+
/// access function for ID bitset ids
215+
/// returns true if the ID is set and the flavour is correct
216+
inline bool isAvailable() const { return (ids & (1 << KLeptonId::ANY)); }; // e, mu, tau
217+
inline bool idLoose() const { return (ids & (1 << KLeptonId::LOOSE)); }; // e, mu, tau
218+
inline bool idMedium() const { return (ids & (1 << KLeptonId::MEDIUM)); }; // e, (mu,) tau
219+
inline bool idTight() const { return (ids & (1 << KLeptonId::TIGHT)); }; // e, mu, tau
220+
inline bool idVeto() const { return (ids & (1 << KLeptonId::VETO) && (KLeptonFlavour::ELECTRON == (leptonInfo & KLeptonFlavourMask))); }; // e
221+
inline bool idSoft() const { return (ids & (1 << KLeptonId::SOFT) && (KLeptonFlavour::MUON == (leptonInfo & KLeptonFlavourMask))); }; // mu
222+
inline bool idHighPt() const { return (ids & (1 << KLeptonId::HIGHPT) && (KLeptonFlavour::MUON == (leptonInfo & KLeptonFlavourMask))); }; // mu
223+
inline bool idLooseElectronRejection() const { return (ids & (1 << KLeptonId::LOOSEELECTRONREJECTION) && (KLeptonFlavour::TAU == (leptonInfo & KLeptonFlavourMask))); }; // tau
224+
inline bool idLooseMuonRejection() const { return (ids & (1 << KLeptonId::LOOSEMUONREJECTION) && (KLeptonFlavour::TAU == (leptonInfo & KLeptonFlavourMask))); }; // tau
225+
inline bool idTightMuonRejection() const { return (ids & (1 << KLeptonId::TIGHTMUONREJECTION) && (KLeptonFlavour::TAU == (leptonInfo & KLeptonFlavourMask))); }; // tau
226+
227+
/// PF isolation with delta beta corrections (default fraction of pile-up is 0.5)
228+
inline double pfIso(const double puFraction=0.5) const
173229
{
174-
NONE = 0,
175-
ELECTRON = 1,
176-
MUON = 2,
177-
TAU = 3
178-
};
179-
Flavour flavour;
180-
181-
char charge;
182-
KTrack track;
230+
return sumChargedHadronPt + std::max(0.0,
231+
sumNeutralHadronEt + sumPhotonEt - puFraction * sumPUPt);
232+
}
233+
234+
/// rho effective area isolation (approximation)
235+
/** this is an alternative method for pile-up subtraction:
236+
PFIso = PF(ChHad PFNoPU) + Max(PF(Nh+Ph) - rho’EA), 0.0) with rho'=max(rho,0)
237+
approximation: effective area as a circle area
238+
rho is usually provided by a KPileupDensity object
239+
*/
240+
double pfIsoRho(const double rho = 0.0, const double radius = 0.4) const
241+
{
242+
double area = radius * radius * 3.14159;
243+
return std::max(0.0, pfIso(0.0) - std::max(rho * area, 0.0));
244+
}
183245
};
184-
185246
typedef std::vector<KLepton> KLeptons;
186247

248+
249+
struct KTrackSummary
250+
{
251+
unsigned int nTracks; //< number of tracks in the event
252+
unsigned int nTracksHQ; //< number of high quality tracks in the event
253+
};
254+
187255
#endif

DataFormats/test/KDebug.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ std::ostream &operator<<(std::ostream &os, const KJet &jet)
7777

7878
std::ostream &operator<<(std::ostream &os, const KBasicTau &tau)
7979
{
80-
return os << static_cast<const KLV>(tau) << " charge=" << tau.charge;
80+
return os << static_cast<const KLV>(tau) << " charge=" << tau.charge();
8181
}
8282

8383
std::ostream &operator<<(std::ostream &os, const KGenTau &tau)

Producers/interface/KBasicTauProducer.h

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,27 @@ class KBasicTauProducer : public KBaseMultiLVProducer<std::vector<TTau>, TProduc
136136
const typename KBaseMultiLVProducer<std::vector<TTau>, TProduct>::SingleInputType &in,
137137
typename KBaseMultiLVProducer<std::vector<TTau>, TProduct>::SingleOutputType &out)
138138
{
139-
out.flavour = KLepton::MUON;
140-
141-
// Momentum:
139+
// momentum:
142140
copyP4(in, out.p4);
143141

144-
// Charge:
145-
out.charge = in.charge();
142+
// charge and flavour (lepton type)
143+
out.leptonInfo = KLeptonFlavour::TAU;
144+
assert(in.charge() == 1 || in.charge() == -1);
145+
if (in.charge() > 0)
146+
out.leptonInfo |= KLeptonChargeMask;
147+
out.leptonInfo |= KLeptonPFMask;
148+
149+
if (in.leadPFChargedHadrCand().isNonnull())
150+
{
151+
if (in.leadPFChargedHadrCand()->trackRef().isNonnull())
152+
KTrackProducer::fillTrack(*in.leadPFChargedHadrCand()->trackRef(), out.track);
153+
else if (in.leadPFChargedHadrCand()->gsfTrackRef().isNonnull())
154+
{
155+
KTrackProducer::fillTrack(*in.leadPFChargedHadrCand()->gsfTrackRef(), out.track);
156+
out.leptonInfo |= KLeptonAlternativeTrackMask;
157+
}
158+
}
159+
146160
out.emFraction = in.emFraction();
147161
out.decayMode = in.decayMode();
148162

Producers/interface/KElectronProducer.h

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,26 @@ if (!trh.isValid())
8888
}
8989

9090
virtual void fillSingle(const SingleInputType &in, SingleOutputType &out)
91-
{
92-
out.flavour = KLepton::ELECTRON;
93-
94-
// Momentum:
91+
{
92+
// momentum:
9593
copyP4(in, out.p4);
9694

97-
// Charge, ...
98-
out.charge = in.charge();
95+
// charge and flavour (lepton type)
96+
assert(in.charge() == 1 || in.charge() == -1);
97+
out.leptonInfo = KLeptonFlavour::ELECTRON;
98+
if (in.charge() > 0)
99+
out.leptonInfo |= KLeptonChargeMask;
100+
if (in.isPF())
101+
out.leptonInfo |= KLeptonPFMask;
99102

100103
// electron track
101-
KTrackProducer::fillTrack(*in.gsfTrack(), out.track);
104+
if (in.gsfTrack().isNonnull())
105+
KTrackProducer::fillTrack(*in.gsfTrack(), out.track);
106+
else if (in.gsfTrack().isNonnull())
107+
{
108+
KTrackProducer::fillTrack(*in.gsfTrack(), out.track);
109+
out.leptonInfo |= KLeptonAlternativeTrackMask;
110+
}
102111

103112
// ECAL region: bits are set according to reco::GsfElectron::FiducialFlags
104113
// the last bit is set to show that this bitset is filled.

Producers/interface/KMuonProducer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,12 @@ class KMuonProducer : public KBaseMultiLVProducer<edm::View<reco::Muon>, KMuons>
109109
/// fill muon from DataFormats/MuonReco/interface/Muon.h
110110
virtual void fillSingle(const SingleInputType &in, SingleOutputType &out)
111111
{
112-
out.flavour = KLepton::MUON;
112+
out.leptonInfo = KLeptonFlavour::MUON;
113113

114-
// Momentum:
114+
/// momentum:
115115
copyP4(in, out.p4);
116116

117-
// Tracks
117+
/// Tracks and track extracted information
118118
if (in.track().isNonnull())
119119
KTrackProducer::fillTrack(*in.track(), out.track);
120120
if (in.globalTrack().isNonnull())

0 commit comments

Comments
 (0)