1 |
//
|
2 |
// $Id: TrackerIsolationPt.cc,v 1.4 2008/03/03 16:45:29 lowette Exp $
|
3 |
//
|
4 |
|
5 |
#include "PhysicsTools/PatUtils/interface/TrackerIsolationPt.h"
|
6 |
#include "FWCore/MessageLogger/interface/MessageLogger.h"
|
7 |
#include "FWCore/Utilities/interface/Exception.h"
|
8 |
#include "FWCore/Framework/interface/ESHandle.h"
|
9 |
#include "DataFormats/Common/interface/Handle.h"
|
10 |
#include "CLHEP/Vector/LorentzVector.h"
|
11 |
#include "DataFormats/GeometryVector/interface/GlobalVector.h"
|
12 |
#include "FWCore/ParameterSet/interface/InputTag.h"
|
13 |
#include "DataFormats/Common/interface/View.h"
|
14 |
#include "DataFormats/PatCandidates/interface/Electron.h"
|
15 |
#include "DataFormats/PatCandidates/interface/Muon.h"
|
16 |
#include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
|
17 |
#include <vector>
|
18 |
|
19 |
using namespace pat;
|
20 |
|
21 |
/// constructor
|
22 |
TrackerIsolationPt::TrackerIsolationPt() {
|
23 |
}
|
24 |
|
25 |
/// destructor
|
26 |
TrackerIsolationPt::~TrackerIsolationPt() {
|
27 |
}
|
28 |
|
29 |
/// calculate the TrackIsoPt for the lepton object
|
30 |
float TrackerIsolationPt::calculate(const Electron & theElectron, const edm::View<reco::Track> & theTracks, float isoConeElectron) const {
|
31 |
return this->calculate(*theElectron.gsfTrack(), theTracks, isoConeElectron);
|
32 |
}
|
33 |
|
34 |
float TrackerIsolationPt::calculate(const Muon & theMuon, const edm::View<reco::Track> & theTracks, float isoConeMuon) const {
|
35 |
return this->calculate(*theMuon.track(), theTracks, isoConeMuon);
|
36 |
}
|
37 |
|
38 |
/// calculate the TrackIsoPt for the lepton's track
|
39 |
float TrackerIsolationPt::calculate(const reco::Track & theTrack, const edm::View<reco::Track> & theTracks, float isoCone) const {
|
40 |
// initialize some variables
|
41 |
float isoPtLepton = 0;
|
42 |
const reco::Track * closestTrackDRPt = 0, * closestTrackDR = 0;
|
43 |
float closestDRPt = 10000, closestDR = 10000;
|
44 |
// use all these pointless vector conversions because the momenta from tracks
|
45 |
// are completely unusable; bah, these math-vectors are worthless!
|
46 |
HepLorentzVector lepton(theTrack.px(), theTrack.py(), theTrack.pz(), theTrack.p());
|
47 |
for (edm::View<reco::Track>::const_iterator itTrack = theTracks.begin(); itTrack != theTracks.end(); itTrack++) {
|
48 |
HepLorentzVector track(itTrack->px(), itTrack->py(), itTrack->pz(), itTrack->p());
|
49 |
float dR = lepton.deltaR(track);
|
50 |
if (dR < isoCone) {
|
51 |
isoPtLepton += track.perp();
|
52 |
// find the closest matching track
|
53 |
// FIXME: we could association by hits or chi2 to match
|
54 |
float pRatio = track.perp()/lepton.perp();
|
55 |
if (dR < closestDRPt && pRatio > 0.5 && pRatio < 1.5) {
|
56 |
closestDRPt = dR;
|
57 |
closestTrackDRPt = &*itTrack;
|
58 |
}
|
59 |
if (dR < closestDR) {
|
60 |
closestDR = dR;
|
61 |
closestTrackDR = &*itTrack;
|
62 |
}
|
63 |
}
|
64 |
}
|
65 |
if (closestTrackDRPt) {
|
66 |
GlobalVector closestTrackVector(closestTrackDRPt->px(), closestTrackDRPt->py(), closestTrackDRPt->pz());
|
67 |
isoPtLepton -= closestTrackVector.perp();
|
68 |
} else if (closestTrackDR) {
|
69 |
GlobalVector closestTrackVector(closestTrackDR->px(), closestTrackDR->py(), closestTrackDR->pz());
|
70 |
isoPtLepton -= closestTrackVector.perp();
|
71 |
}
|
72 |
// back to normal sum - S.L. 30/10/2007
|
73 |
if (isoPtLepton<0) isoPtLepton = 0;
|
74 |
// isoPtLepton <= 0.01 ? isoPtLepton = -1 : isoPtLepton = log(isoPtLepton);
|
75 |
return isoPtLepton;
|
76 |
}
|
77 |
|