File indexing completed on 2024-10-22 22:52:35
0001 #include "RecoEgamma/EgammaIsolationAlgos/interface/SuperclusTkIsolFromCands.h"
0002 #include "DataFormats/TrackReco/interface/Track.h"
0003 #include "DataFormats/Math/interface/deltaR.h"
0004
0005 SuperclusTkIsolFromCands::Output SuperclusTkIsolFromCands::operator()(const reco::SuperCluster& sc,
0006 const math::XYZPoint& vtx) {
0007 using namespace edm::soa::col;
0008
0009 float ptSum = 0.;
0010 int nrTrks = 0;
0011
0012 const float scEta = sc.eta();
0013 const float scPhi = sc.phi();
0014 const float vtxVz = vtx.z();
0015
0016 const bool isBarrelSC = std::abs(scEta) < 1.5;
0017
0018 auto const& preselectedTracks = getPreselectedTracks(isBarrelSC);
0019 auto const& cuts = isBarrelSC ? cfg_.barrelCuts : cfg_.endcapCuts;
0020
0021 for (auto const& trk : preselectedTracks) {
0022 const float dR2 = reco::deltaR2(scEta, scPhi, trk.get<Eta>(), trk.get<Phi>());
0023 const float dEta = trk.get<Eta>() - scEta;
0024 const float dZ = vtxVz - trk.get<Vz>();
0025
0026 if (dR2 >= cuts.minDR2 && dR2 <= cuts.maxDR2 && std::abs(dEta) >= cuts.minDEta && std::abs(dZ) < cuts.maxDZ) {
0027 ptSum += trk.get<Pt>();
0028 nrTrks++;
0029 }
0030 }
0031
0032 return {nrTrks, ptSum};
0033 }