00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "RecoEgamma/EgammaHLTAlgos/interface/EgammaHLTTrackIsolation.h"
00018
00019
00020 std::pair<int,float> EgammaHLTTrackIsolation::electronIsolation(const reco::Track * const tr, const reco::TrackCollection* isoTracks)
00021 {
00022 GlobalPoint vtx(0,0,tr->vertex().z());
00023 reco::Track::Vector p = tr->momentum();
00024 GlobalVector mom( p.x(), p.y(), p.z() );
00025 return findIsoTracks(mom,vtx,isoTracks,true);
00026 }
00027
00028
00029 std::pair<int,float> EgammaHLTTrackIsolation::electronIsolation(const reco::Track * const tr, const reco::TrackCollection* isoTracks, GlobalPoint zvtx)
00030 {
00031
00032 GlobalPoint vtx(0,0,zvtx.z());
00033 reco::Track::Vector p = tr->momentum();
00034 GlobalVector mom( p.x(), p.y(), p.z() );
00035 return findIsoTracks(mom,vtx,isoTracks,true);
00036 }
00037
00038 std::pair<int,float> EgammaHLTTrackIsolation::electronIsolation(const reco::Track * const tr, const reco::ElectronCollection* allEle, const reco::TrackCollection* isoTracks)
00039 {
00040 GlobalPoint vtx(0,0,tr->vertex().z());
00041 reco::Track::Vector p = tr->momentum();
00042 GlobalVector mom( p.x(), p.y(), p.z() );
00043 return findIsoTracksWithoutEle(mom,vtx,allEle,isoTracks);
00044 }
00045
00046 std::pair<int,float> EgammaHLTTrackIsolation::photonIsolation(const reco::RecoCandidate * const recocandidate, const reco::TrackCollection* isoTracks, bool useVertex)
00047 {
00048
00049 if (useVertex) {
00050 GlobalPoint vtx(0,0,recocandidate->vertex().z());
00051 return photonIsolation(recocandidate,isoTracks,vtx);
00052 } else {
00053 reco::RecoCandidate::Point pos = recocandidate->superCluster()->position();
00054 GlobalVector mom(pos.x(),pos.y(),pos.z());
00055 return findIsoTracks(mom,GlobalPoint(),isoTracks,false,false);
00056 }
00057
00058 }
00059
00060 std::pair<int,float> EgammaHLTTrackIsolation::photonIsolation(const reco::RecoCandidate * const recocandidate, const reco::TrackCollection* isoTracks, GlobalPoint zvtx)
00061 {
00062
00063
00064 GlobalPoint vtx(0,0,zvtx.z());
00065
00066 reco::RecoCandidate::Point pos = recocandidate->superCluster()->position();
00067 GlobalVector mom(pos.x()-vtx.x(),pos.y()-vtx.y(),pos.z()-vtx.z());
00068
00069 return findIsoTracks(mom,vtx,isoTracks,false);
00070
00071 }
00072
00073
00074 std::pair<int,float> EgammaHLTTrackIsolation::photonIsolation(const reco::RecoCandidate * const recocandidate, const reco::ElectronCollection* allEle, const reco::TrackCollection* isoTracks)
00075 {
00076
00077 reco::RecoCandidate::Point pos = recocandidate->superCluster()->position();
00078 GlobalVector mom(pos.x(),pos.y(),pos.z());
00079 return findIsoTracksWithoutEle(mom,GlobalPoint(),allEle,isoTracks);
00080
00081 }
00082
00083 std::pair<int,float> EgammaHLTTrackIsolation::findIsoTracks(GlobalVector mom, GlobalPoint vtx, const reco::TrackCollection* isoTracks, bool isElectron, bool useVertex)
00084 {
00085
00086
00087
00088 int ntrack = 0;
00089 float ptSum = 0.;
00090
00091 for(reco::TrackCollection::const_iterator trItr = isoTracks->begin(); trItr != isoTracks->end(); ++trItr){
00092
00093 GlobalPoint ivtx(trItr->vertex().x(),trItr->vertex().y(),trItr->vertex().z());
00094 reco::Track::Vector ip = trItr->momentum();
00095 GlobalVector imom ( ip.x(), ip.y(), ip.z());
00096
00097 float pt = imom.perp();
00098 float dperp = 0.;
00099 float dz = 0.;
00100 float deta = 0.;
00101 float dphi = 0.;
00102 if (useVertex) {
00103 dperp = ivtx.perp()-vtx.perp();
00104 dz = ivtx.z()-vtx.z();
00105 deta = imom.eta()-mom.eta();
00106 dphi = imom.phi()-mom.phi();
00107 } else {
00108
00109
00110
00111 GlobalVector mom_temp = mom - GlobalVector(ivtx.x(),ivtx.y(),ivtx.z());
00112 deta = imom.eta()-mom_temp.eta();
00113 dphi = imom.phi()-mom_temp.phi();
00114 }
00115
00116 if (dphi>M_PI) dphi = dphi - 2*M_PI;
00117 else if (dphi<-M_PI) dphi = dphi + 2*M_PI;
00118
00119 float R = sqrt( dphi*dphi + deta*deta );
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134 if (pt > ptMin && R < conesize && R > vetoConesize &&
00135 fabs(dperp) < rspan && fabs(dz) < zspan) {
00136 ntrack++;
00137 ptSum+=pt;
00138 }
00139 }
00140
00141
00142
00143 return (std::pair<int,float>(ntrack,ptSum));
00144
00145 }
00146
00147 std::pair<int,float> EgammaHLTTrackIsolation::findIsoTracksWithoutEle(GlobalVector mom, GlobalPoint vtx, const reco::ElectronCollection* allEle, const reco::TrackCollection* isoTracks)
00148 {
00149
00150
00151
00152 int iele = 0;
00153 int ntrack = 0;
00154 float ptSum = 0.;
00155 std::vector<float> etaele;
00156 std::vector<float> phiele;
00157
00158
00159
00160
00161 for (reco::ElectronCollection::const_iterator iElectron = allEle->begin(); iElectron != allEle->end(); iElectron++){
00162 iele++;
00163 reco::TrackRef anothereletrackref = iElectron->track();
00164 etaele.push_back(anothereletrackref->momentum().eta());
00165 phiele.push_back(anothereletrackref->momentum().phi());
00166
00167 }
00168
00169 for(reco::TrackCollection::const_iterator trItr = isoTracks->begin(); trItr != isoTracks->end(); ++trItr){
00170
00171 GlobalPoint ivtx(trItr->vertex().x(),trItr->vertex().y(),trItr->vertex().z());
00172 reco::Track::Vector ip = trItr->momentum();
00173 GlobalVector imom ( ip.x(), ip.y(), ip.z());
00174
00175 float pt = imom.perp();
00176 float dperp = ivtx.perp()-vtx.perp();
00177 float dz = ivtx.z()-vtx.z();
00178 float deta = imom.eta()-mom.eta();
00179 float dphi = imom.phi()-mom.phi();
00180
00181
00182 if (dphi>M_PI) dphi = dphi - 2*M_PI;
00183 else if (dphi<-M_PI) dphi = dphi + 2*M_PI;
00184
00185 float R = sqrt( dphi*dphi + deta*deta );
00186
00187
00188 bool selected=false;
00189 bool passedconeveto=true;
00190
00191 if (pt > ptMin && R < conesize &&
00192 fabs(dperp) < rspan && fabs(dz) < zspan) selected=true;
00193
00194
00195 for(unsigned int eleItr = 0; eleItr < etaele.size(); ++eleItr){
00196
00197 deta = etaele[eleItr] - imom.eta();
00198 dphi = phiele[eleItr] - imom.phi();
00199
00200
00201 if (dphi>M_PI) dphi = dphi - 2*M_PI;
00202 else if (dphi<-M_PI) dphi = dphi + 2*M_PI;
00203
00204 R = sqrt( dphi*dphi + deta*deta );
00205 if (R < vetoConesize) passedconeveto=false;
00206 }
00207
00208 if (selected && passedconeveto) {
00209 ntrack++;
00210 ptSum+=pt;
00211 }
00212
00213 }
00214
00215
00216
00217 return (std::pair<int,float>(ntrack,ptSum));
00218
00219 }