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
00135
00136
00137 double innerStrip = fabs(mom.eta())<1.479 ? stripBarrel : stripEndcap;
00138
00139 if (pt > ptMin && R < conesize && R > vetoConesize &&
00140 fabs(dperp) < rspan && fabs(dz) < zspan &&
00141 fabs(deta) >=innerStrip) {
00142 ntrack++;
00143 ptSum+=pt;
00144 }
00145 }
00146
00147
00148
00149 return (std::pair<int,float>(ntrack,ptSum));
00150
00151 }
00152
00153 std::pair<int,float> EgammaHLTTrackIsolation::findIsoTracksWithoutEle(GlobalVector mom, GlobalPoint vtx, const reco::ElectronCollection* allEle, const reco::TrackCollection* isoTracks)
00154 {
00155
00156
00157
00158 int iele = 0;
00159 int ntrack = 0;
00160 float ptSum = 0.;
00161 std::vector<float> etaele;
00162 std::vector<float> phiele;
00163
00164
00165
00166
00167 for (reco::ElectronCollection::const_iterator iElectron = allEle->begin(); iElectron != allEle->end(); iElectron++){
00168 iele++;
00169 reco::TrackRef anothereletrackref = iElectron->track();
00170 etaele.push_back(anothereletrackref->momentum().eta());
00171 phiele.push_back(anothereletrackref->momentum().phi());
00172
00173 }
00174
00175 for(reco::TrackCollection::const_iterator trItr = isoTracks->begin(); trItr != isoTracks->end(); ++trItr){
00176
00177 GlobalPoint ivtx(trItr->vertex().x(),trItr->vertex().y(),trItr->vertex().z());
00178 reco::Track::Vector ip = trItr->momentum();
00179 GlobalVector imom ( ip.x(), ip.y(), ip.z());
00180
00181 float pt = imom.perp();
00182 float dperp = ivtx.perp()-vtx.perp();
00183 float dz = ivtx.z()-vtx.z();
00184 float deta = imom.eta()-mom.eta();
00185 float dphi = imom.phi()-mom.phi();
00186
00187
00188 if (dphi>M_PI) dphi = dphi - 2*M_PI;
00189 else if (dphi<-M_PI) dphi = dphi + 2*M_PI;
00190
00191 float R = sqrt( dphi*dphi + deta*deta );
00192
00193
00194 bool selected=false;
00195 bool passedconeveto=true;
00196
00197
00198
00199
00200 double innerStrip = fabs(mom.eta())<1.479 ? stripBarrel : stripEndcap;
00201
00202 if (pt > ptMin && R < conesize &&
00203 fabs(dperp) < rspan && fabs(dz) < zspan &&
00204 fabs(deta) >=innerStrip) selected=true;
00205
00206
00207 for(unsigned int eleItr = 0; eleItr < etaele.size(); ++eleItr){
00208
00209 deta = etaele[eleItr] - imom.eta();
00210 dphi = phiele[eleItr] - imom.phi();
00211
00212
00213 if (dphi>M_PI) dphi = dphi - 2*M_PI;
00214 else if (dphi<-M_PI) dphi = dphi + 2*M_PI;
00215
00216 R = sqrt( dphi*dphi + deta*deta );
00217 if (R < vetoConesize) passedconeveto=false;
00218 }
00219
00220 if (selected && passedconeveto) {
00221 ntrack++;
00222 ptSum+=pt;
00223 }
00224
00225 }
00226
00227
00228
00229 return (std::pair<int,float>(ntrack,ptSum));
00230
00231 }