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):
14  rankers_(rankers) {}
15  // Predicate to compare a and b
16  bool operator()(const Type& a, const Type& b) const {
17  typename RankingList::const_iterator ranker = rankers_.begin();
18  while (ranker != rankers_.end()) {
19  double aResult = (*ranker)(a);
20  double bResult = (*ranker)(b);
21  if (aResult != bResult)
22  return (aResult < bResult);
23  ++ranker;
24  }
25  // If all aare equal return false
26  return false;
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();
39  ++candidate) {
40  // Check if this overlaps with a pizero already in the clean list
41  bool overlaps = false;
42  for (Iterator cleaned = clean.begin();
43  cleaned != clean.end() && !overlaps; ++cleaned) {
44  overlaps = overlapChecker(*candidate, *cleaned);
45  }
46  // If it didn't overlap with anything clean, add it to the clean list
47  if (!overlaps)
48  clean.insert(clean.end(), *candidate);
49  }
50  return clean;
51 }
52 
53 template<typename T>
55  public:
56  bool operator()(const T& a, const T& b) const {
57  return a.pt() > b.pt();
58  }
59 };
60 
61 } // end reco::tau namespace
62 
63 #endif
bool operator()(const T &a, const T &b) const
RecoTauLexicographicalRanking(const RankingList &rankers)
bool operator()(const Type &a, const Type &b) const
std::vector< T * > clean
Definition: MVATrainer.cc:154
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
Container cleanOverlaps(const Container &dirty)
long double T
edm::AssociationVector< reco::JetRefBaseProd, Values > Container