CMS 3D CMS Logo

RecoTauCleaningTools.h
Go to the documentation of this file.
1 #ifndef RecoTauTag_RecoTau_RecoTauCleaningTools_h
2 #define RecoTauTag_RecoTau_RecoTauCleaningTools_h
3 
4 #include <algorithm>
5 
6 namespace reco::tau {
7 
8  template <typename RankingList, typename Type>
10  public:
11  // Store our list of ranking functions and intialize the vectors
12  // that hold the comparison result
13  explicit RecoTauLexicographicalRanking(const RankingList& rankers) : rankers_(rankers) {}
14  // Predicate to compare a and b
15  bool operator()(const Type& a, const Type& b) const {
16  typename RankingList::const_iterator ranker = rankers_.begin();
17  while (ranker != rankers_.end()) {
18  double aResult = (*ranker)(a);
19  double bResult = (*ranker)(b);
20  if (aResult != bResult)
21  return (aResult < bResult);
22  ++ranker;
23  }
24  // If all aare equal return false
25  return false;
26  }
27 
28  private:
29  const RankingList& rankers_;
30  };
31 
32  template <typename Container, class OverlapFunction>
34  typedef typename Container::const_iterator Iterator;
35  // Output container of clean objects
37  OverlapFunction overlapChecker;
38  for (Iterator candidate = dirty.begin(); candidate != dirty.end(); ++candidate) {
39  // Check if this overlaps with a pizero already in the clean list
40  bool overlaps = false;
41  for (Iterator cleaned = clean.begin(); cleaned != clean.end() && !overlaps; ++cleaned) {
42  overlaps = overlapChecker(*candidate, *cleaned);
43  }
44  // If it didn't overlap with anything clean, add it to the clean list
45  if (!overlaps)
46  clean.insert(clean.end(), *candidate);
47  }
48  return clean;
49  }
50 
51  template <typename T>
53  public:
54  bool operator()(const T& a, const T& b) const { return a.pt() > b.pt(); }
55  };
56 
57 } // namespace reco::tau
58 
59 #endif
bool operator()(const T &a, const T &b) const
TGeoIterator Iterator
static void clean(char *s)
RecoTauLexicographicalRanking(const RankingList &rankers)
bool operator()(const Type &a, const Type &b) const
double b
Definition: hdecay.h:118
double a
Definition: hdecay.h:119
Container cleanOverlaps(const Container &dirty)
long double T
edm::AssociationVector< reco::JetRefBaseProd, Values > Container