Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:50:14

0001 #ifndef CommonTools_Utils_PdgIdSelector_h
0002 #define CommonTools_Utils_PdgIdSelector_h
0003 /* \class PdgIdSelector
0004  *
0005  * \author Luca Lista, INFN
0006  *
0007  * $Id: PdgIdSelector.h,v 1.4 2007/11/14 10:14:21 llista Exp $
0008  */
0009 #include <vector>
0010 #include <algorithm>
0011 
0012 struct PdgIdSelector {
0013   PdgIdSelector(const std::vector<int>& pdgId) {
0014     for (std::vector<int>::const_iterator i = pdgId.begin(); i != pdgId.end(); ++i)
0015       pdgId_.push_back(abs(*i));
0016     begin_ = pdgId_.begin();
0017     end_ = pdgId_.end();
0018   }
0019   PdgIdSelector(const PdgIdSelector& o) : pdgId_(o.pdgId_), begin_(pdgId_.begin()), end_(pdgId_.end()) {}
0020   PdgIdSelector& operator==(const PdgIdSelector& o) {
0021     *this = o;
0022     return *this;
0023   }
0024   template <typename T>
0025   bool operator()(const T& t) const {
0026     return std::find(begin_, end_, abs(t.pdgId())) != end_;
0027   }
0028 
0029 private:
0030   std::vector<int> pdgId_;
0031   std::vector<int>::const_iterator begin_, end_;
0032 };
0033 
0034 #endif