From 395bd6a4d5906df811e34ca36c0197b1679451f2 Mon Sep 17 00:00:00 2001 From: Joram Berger Date: Fri, 21 Nov 2014 20:29:21 +0100 Subject: [PATCH] Update KTrack --- DataFormats/interface/KTrack.h | 70 +++++++++++++-------- Producers/interface/KTrackProducer.h | 7 +-- Producers/interface/KTrackSummaryProducer.h | 9 ++- 3 files changed, 51 insertions(+), 35 deletions(-) diff --git a/DataFormats/interface/KTrack.h b/DataFormats/interface/KTrack.h index 8a37dc83..dee04005 100644 --- a/DataFormats/interface/KTrack.h +++ b/DataFormats/interface/KTrack.h @@ -7,44 +7,61 @@ #ifndef KAPPA_TRACK_H #define KAPPA_TRACK_H -#include #include "KBasic.h" -enum KTrackQuality +#include + +/** Data format definition for KTracks and KLeptons + + */ + +/// TrackBase::TrackQuality +/// from DataFormats/TrackReco/interface/TrackBase.h +namespace KTrackQuality { + +enum KTrackQualityType { - TQ_Loose = 1 << 0, TQ_Tight = 1 << 1, TQ_HighPurity = 1 << 2, TQ_Confirmed = 1 << 3, TQ_GoodIterative = 1 << 4 + undefQuality = -1, loose = 0, tight = 1, highPurity = 2, confirmed = 3, goodIterative = 4, + looseSetWithPV = 5, highPuritySetWithPV = 6, qualitySize = 7 }; +} +/// Kappa Track data format +/** copy from DataFormats/TrackReco/interface/TrackBase.h + copy from DataFormats/TrackReco/interface/Track.h */ struct KTrack : public KLV { - RMPoint ref; // reference point ("vertex") + /// reference point (formerly known as "vertex", not the PV) + RMPoint ref; + + /// charge and fit quality char charge; float chi2, nDOF; float errPt, errEta, errPhi, errDxy, errDz; - unsigned short nPixelLayers, nStripLayers; - unsigned short nValidPixelHits, nValidStripHits; - unsigned short nValidMuonHits, nLostMuonHits, nBadMuonHits; - unsigned short nValidHits, nLostHits; - unsigned short nInnerHits, nLostInnerHits; - int quality; - - double getTrackIsolation(std::vector *tracks, double isoCone = 0.3, double vetoCone = 0.01, double minPt = 1.5) + + /// number of hits or tracker layers in detector components (used for lepton IDs) + /// DataFormats/TrackReco/interface/HitPattern.h (numberOf...) + /// layers and hits for pixel, strip tracker and muon system + unsigned short nValidPixelHits; //< number of valid hits in the pixel detector (for tight muID) + unsigned short nValidStripHits; //< number of valid hits in the strip detector + unsigned short nValidMuonHits; //< number of valid hits in the muon system (for tight muID) + + unsigned short nLostHits; + unsigned short nPixelLayers, nStripLayers; // for soft/tight muID as trackerLayers + /// functions for combinations + inline unsigned short nValidHits() const { return nValidPixelHits + nValidStripHits + nValidMuonHits; }; + inline unsigned short nValidTrackerHits() const { return nValidPixelHits + nValidStripHits; }; + inline unsigned short nTrackerLayers() const { return nPixelLayers + nStripLayers; }; + + /// quality bitset + unsigned char qualityBits; // for soft muID + inline bool quality(KTrackQuality::KTrackQualityType bit) const { - double sum = 0.; - for (std::vector::iterator it = tracks->begin(); it != tracks->end(); it++) - { - if (it->p4.pt() > minPt && ROOT::Math::VectorUtil::DeltaR(it->p4, p4) > vetoCone && ROOT::Math::VectorUtil::DeltaR(it->p4, p4) < isoCone) - { - // "real" track isolation takes only tracks near the studied track into account - // (but there is even more magic why one needs isodeposits) - //if ( std::abs(it->ref.z() - ref.z()) > 0.2 || sqrt( (it->ref.x() - ref.x() )*(it->ref.x() - ref.x() ) + (it->ref.y() - ref.y())*(it->ref.y() - ref.y()) + (it->ref.z() - ref.z())*(it->ref.z() - ref.z()) ) > 0.1 ) - // continue; - sum += it->p4.pt(); - } - } - return sum; - } + if (bit < 0) return false; + return (qualityBits & (1 << bit)); + }; + /// distances to primary vertex, beamspot and interaction point double getDxy(const KVertex * pv) const { if (!pv) @@ -157,7 +174,6 @@ struct KMuonTriggerCandidate : public KTrack bool isoDecision; float isoQuantity; }; - typedef std::vector KMuonTriggerCandidates; const unsigned char KLeptonFlavourMask = 3; diff --git a/Producers/interface/KTrackProducer.h b/Producers/interface/KTrackProducer.h index a8f57e55..5fcdecda 100644 --- a/Producers/interface/KTrackProducer.h +++ b/Producers/interface/KTrackProducer.h @@ -41,21 +41,16 @@ class KTrackProducer : public KBaseMultiLVProducer, KTrac out.charge = in.charge(); out.chi2 = in.chi2(); out.nDOF = in.ndof(); - out.quality = in.qualityMask(); + out.qualityBits = in.qualityMask(); out.errDxy = in.dxyError(); out.errDz = in.dzError(); out.nValidPixelHits = in.hitPattern().numberOfValidPixelHits(); out.nValidStripHits = in.hitPattern().numberOfValidStripHits(); out.nValidMuonHits = in.hitPattern().numberOfValidMuonHits(); - out.nLostMuonHits = in.hitPattern().numberOfLostMuonHits(); - out.nBadMuonHits = in.hitPattern().numberOfBadMuonHits(); - out.nValidHits = in.hitPattern().numberOfValidHits(); out.nLostHits = in.hitPattern().numberOfLostHits(); out.nPixelLayers = in.hitPattern().pixelLayersWithMeasurement(); out.nStripLayers = in.hitPattern().trackerLayersWithMeasurement(); - out.nInnerHits = in.trackerExpectedHitsInner().numberOfHits(); - out.nLostInnerHits = in.trackerExpectedHitsInner().numberOfLostHits(); } }; diff --git a/Producers/interface/KTrackSummaryProducer.h b/Producers/interface/KTrackSummaryProducer.h index fcabf4fc..d9f206d9 100644 --- a/Producers/interface/KTrackSummaryProducer.h +++ b/Producers/interface/KTrackSummaryProducer.h @@ -16,14 +16,19 @@ class KTrackSummaryProducer : public KBaseMultiProducer, static const std::string getLabel() { return "TrackSummary"; } - virtual void clearProduct(OutputType &output) { output.nTracks = 0; output.nTracksHQ = 0; } + virtual void clearProduct(OutputType &output) + { + output.nTracks = 0; + output.nTracksHQ = 0; + } + virtual void fillProduct(const InputType &in, OutputType &out, const std::string &name, const edm::InputTag *tag, const edm::ParameterSet &pset) { out.nTracks = in.size(); InputType::const_iterator lvit; for (lvit = in.begin(); lvit < in.end(); ++lvit) - if (lvit->qualityMask() & TQ_HighPurity) + if (lvit->qualityMask() & KTrackQuality::highPurity) ++out.nTracksHQ; } };