@@ -160,28 +160,96 @@ struct KMuonTriggerCandidate : public KTrack
160160
161161typedef 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
169193struct KLepton : public KLV
170194{
171195public:
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-
185246typedef 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
0 commit comments