CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RecoTauCleaningTools.h
Go to the documentation of this file.
1 #ifndef RecoTauTag_RecoTau_RecoTauCleaningTools_h
2 #define RecoTauTag_RecoTau_RecoTauCleaningTools_h
3 #include <algorithm>
4 #include <functional>
5 
6 namespace reco { namespace tau {
7 
8 template<typename RankingList, typename Type>
10  public std::binary_function<Type, Type, bool> {
11  public:
12  // Store our list of ranking functions and intialize the vectors
13  // that hold the comparison result
14  explicit RecoTauLexicographicalRanking(const RankingList& rankers):
15  rankers_(rankers) {}
16  // Predicate to compare a and b
17  bool operator()(const Type& a, const Type& b) const {
18  typename RankingList::const_iterator ranker = rankers_.begin();
19  while (ranker != rankers_.end()) {
20  double aResult = (*ranker)(a);
21  double bResult = (*ranker)(b);
22  if (aResult != bResult)
23  return (aResult < bResult);
24  ++ranker;
25  }
26  // If all aare equal return false
27  return false;
28  }
29  private:
30  const RankingList& rankers_;
31  };
32 
33 template<typename Container, class OverlapFunction>
35  typedef typename Container::const_iterator Iterator;
36  // Output container of clean objects
38  OverlapFunction overlapChecker;
39  for (Iterator candidate = dirty.begin(); candidate != dirty.end();
40  ++candidate) {
41  // Check if this overlaps with a pizero already in the clean list
42  bool overlaps = false;
43  for (Iterator cleaned = clean.begin();
44  cleaned != clean.end() && !overlaps; ++cleaned) {
45  overlaps = overlapChecker(*candidate, *cleaned);
46  }
47  // If it didn't overlap with anything clean, add it to the clean list
48  if (!overlaps)
49  clean.insert(clean.end(), *candidate);
50  }
51  return clean;
52 }
53 
54 template<typename T>
56  public:
57  bool operator()(const T& a, const T& b) const {
58  return a.pt() > b.pt();
59  }
60 };
61 }} // end reco::tau::
62 #endif
bool operator()(const T &a, const T &b) const
EcalChannelStatus Container
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
double a
Definition: hdecay.h:121
Container cleanOverlaps(const Container &dirty)
long double T