1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#ifndef CommonTools_Utils_PdgIdSelector_h
#define CommonTools_Utils_PdgIdSelector_h
/* \class PdgIdSelector
*
* \author Luca Lista, INFN
*
* $Id: PdgIdSelector.h,v 1.4 2007/11/14 10:14:21 llista Exp $
*/
#include <vector>
#include <algorithm>
struct PdgIdSelector {
PdgIdSelector(const std::vector<int>& pdgId) {
for (std::vector<int>::const_iterator i = pdgId.begin(); i != pdgId.end(); ++i)
pdgId_.push_back(abs(*i));
begin_ = pdgId_.begin();
end_ = pdgId_.end();
}
PdgIdSelector(const PdgIdSelector& o) : pdgId_(o.pdgId_), begin_(pdgId_.begin()), end_(pdgId_.end()) {}
PdgIdSelector& operator=(const PdgIdSelector& o) = default;
PdgIdSelector& operator==(const PdgIdSelector& o) {
*this = o;
return *this;
}
template <typename T>
bool operator()(const T& t) const {
return std::find(begin_, end_, abs(t.pdgId())) != end_;
}
private:
std::vector<int> pdgId_;
std::vector<int>::const_iterator begin_, end_;
};
#endif
|