Hello,
 The loop looks for the largest weight . If I do what you suggest I might screw up the logic.
Since this specific piece of code is from Florian, maybe he might comment on your comment.
Nancy

______________________________________

Nancy Marinelli

Research Associate Professor
University of Notre Dame, IN, US

CERN, Bdg 40/3-A01, 1211 Geneva,

SWITZERLAND

Phone +41-22-76-70809, fax +41-22-76-78940

From: slava77 <notifications@github.com<mailto:notifications@github.com>>
Reply-To: cms-sw/cmssw <reply@reply.github.com<mailto:reply@reply.github.com>>
Date: Mon, 28 Oct 2013 14:29:10 -0700
To: cms-sw/cmssw <cmssw@noreply.github.com<mailto:cmssw@noreply.github.com>>
Cc: Nancy Marinelli <nancy.marinelli@cern.ch<mailto:nancy.marinelli@cern.ch>>
Subject: Re: [cmssw] PF-Based Isolation for GED Electrons/Photons (#1174)


In RecoEgamma/PhotonIdentification/src/PFPhotonIsolationCalculator.cc:

> +  reco::TrackBaseRef trackBaseRef( pfcand.trackRef() );
> +
> +  size_t iVertex = 0;
> +  unsigned index=0;
> +  unsigned nFoundVertex = 0;
> +
> +  float bestweight=0;
> +
> +  const reco::VertexCollection& vertices = *(verticesColl.product());
> +
> +  for( reco::VertexCollection::const_iterator iv=vertices.begin(); iv!=vertices.end(); ++iv, ++index) {
> +
> +    const reco::Vertex& vtx = *iv;
> +
> +    // loop on tracks in vertices
> +    for(reco::Vertex::trackRef_iterator iTrack=vtx.tracks_begin();iTrack!=vtx.tracks_end(); ++iTrack) {


Is this loop over tracks really necessary?
Just call w = vtx.trackWeight(trackBaseRef);
The weight will be 0 if the track is not in the vertex list.

—
Reply to this email directly or view it on GitHub<https://github.com/cms-sw/cmssw/pull/1174/files#r7264234>.