File indexing completed on 2024-04-06 12:27:46
0001 #ifndef RecoTauTag_RecoTau_RecoTauCleaningTools_h
0002 #define RecoTauTag_RecoTau_RecoTauCleaningTools_h
0003
0004 #include <algorithm>
0005
0006 namespace reco::tau {
0007
0008 template <typename RankingList, typename Type>
0009 class RecoTauLexicographicalRanking {
0010 public:
0011
0012
0013 explicit RecoTauLexicographicalRanking(const RankingList& rankers) : rankers_(rankers) {}
0014
0015 bool operator()(const Type& a, const Type& b) const {
0016 for (auto const& ranker : rankers_) {
0017 double aResult = (*ranker)(a);
0018 double bResult = (*ranker)(b);
0019 if (aResult != bResult)
0020 return (aResult < bResult);
0021 }
0022
0023 return false;
0024 }
0025
0026 private:
0027 const RankingList& rankers_;
0028 };
0029
0030 template <typename Container, class OverlapFunction>
0031 Container cleanOverlaps(const Container& dirty) {
0032
0033 Container clean;
0034 OverlapFunction overlapChecker;
0035 for (auto const& candidate : dirty) {
0036
0037 bool overlaps = false;
0038 for (auto cleaned = clean.begin(); cleaned != clean.end() && !overlaps; ++cleaned) {
0039 overlaps = overlapChecker(candidate, *cleaned);
0040 }
0041
0042 if (!overlaps)
0043 clean.insert(clean.end(), candidate);
0044 }
0045 return clean;
0046 }
0047
0048 }
0049
0050 #endif