From profiling, this loop takes about 1% (or 20% of all tau reco), all of it is spent in the trackWeight function.

This code doesn't really make much sense:
- loop over all tracks (generalTracks)
    - loop over all tracks in a PV (offlinePrimaryVertices), which is made out of a subset of generalTracks
    - find the track, which is not the signal track that belongs to the PV
The external loop over tracks seems pointless.
  
Also, you are checking weights for the tracks already in the PV. Do we really have any zero weight or negative weight tracks in any PV?

This should be fixed