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 #include <functional>
6 
7 namespace reco { namespace tau {
8 
9 template<typename RankingList, typename Type>
11  public std::binary_function<Type, Type, bool> {
12  public:
13  // Store our list of ranking functions and intialize the vectors
14  // that hold the comparison result
15  explicit RecoTauLexicographicalRanking(const RankingList& rankers):
16  rankers_(rankers) {}
17  // Predicate to compare a and b
18  bool operator()(const Type& a, const Type& b) const {
19  typename RankingList::const_iterator ranker = rankers_.begin();
20  while (ranker != rankers_.end()) {
21  double aResult = (*ranker)(a);
22  double bResult = (*ranker)(b);
23  if (aResult != bResult)
24  return (aResult < bResult);
25  ++ranker;
26  }
27  // If all aare equal return false
28  return false;
29  }
30  private:
31  const RankingList& rankers_;
32  };
33 
34 template<typename Container, class OverlapFunction>
36  typedef typename Container::const_iterator Iterator;
37  // Output container of clean objects
39  OverlapFunction overlapChecker;
40  for (Iterator candidate = dirty.begin(); candidate != dirty.end();
41  ++candidate) {
42  // Check if this overlaps with a pizero already in the clean list
43  bool overlaps = false;
44  for (Iterator cleaned = clean.begin();
45  cleaned != clean.end() && !overlaps; ++cleaned) {
46  overlaps = overlapChecker(*candidate, *cleaned);
47  }
48  // If it didn't overlap with anything clean, add it to the clean list
49  if (!overlaps)
50  clean.insert(clean.end(), *candidate);
51  }
52  return clean;
53 }
54 
55 template<typename T>
57  public:
58  bool operator()(const T& a, const T& b) const {
59  return a.pt() > b.pt();
60  }
61 };
62 
63 }} // end reco::tau namespace
64 
65 #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:156
double b
Definition: hdecay.h:120
fixed size matrix
double a
Definition: hdecay.h:121
Container cleanOverlaps(const Container &dirty)
long double T
edm::AssociationVector< reco::JetRefBaseProd, Values > Container