Skip to content

Commit

Permalink
Update KTrack
Browse files Browse the repository at this point in the history
  • Loading branch information
JoramBerger committed Nov 30, 2014
1 parent 4e91541 commit 395bd6a
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 35 deletions.
70 changes: 43 additions & 27 deletions DataFormats/interface/KTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,61 @@
#ifndef KAPPA_TRACK_H
#define KAPPA_TRACK_H

#include <Math/GenVector/VectorUtil.h>
#include "KBasic.h"

enum KTrackQuality
#include <Math/GenVector/VectorUtil.h>

/** 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<KTrack> *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<KTrack>::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)
Expand Down Expand Up @@ -157,7 +174,6 @@ struct KMuonTriggerCandidate : public KTrack
bool isoDecision;
float isoQuantity;
};

typedef std::vector<KMuonTriggerCandidate> KMuonTriggerCandidates;

const unsigned char KLeptonFlavourMask = 3;
Expand Down
7 changes: 1 addition & 6 deletions Producers/interface/KTrackProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,16 @@ class KTrackProducer : public KBaseMultiLVProducer<edm::View<reco::Track>, 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();
}
};

Expand Down
9 changes: 7 additions & 2 deletions Producers/interface/KTrackSummaryProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@ class KTrackSummaryProducer : public KBaseMultiProducer<edm::View<reco::Track>,

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;
}
};
Expand Down

0 comments on commit 395bd6a

Please sign in to comment.