CMS 3D CMS Logo

MCMatchSelector.h

Go to the documentation of this file.
00001 #ifndef MCMatchSelector_h
00002 #define MCMatchSelector_h
00003 /* \class MCMatchSelector
00004  *
00005  * Extended version of MCTruthPairSelector. Preselects matches
00006  * based on charge, pdgId and status.
00007  */
00008 
00009 #include <set>
00010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00011 
00012 namespace reco {
00013   template<typename T1, typename T2>
00014   class MCMatchSelector {
00015   public:
00016     MCMatchSelector(const edm::ParameterSet& cfg) : 
00017       checkCharge_(cfg.getParameter<bool>("checkCharge")) { 
00018       std::vector<int> ids = 
00019         cfg.getParameter< std::vector<int> >("mcPdgId");
00020       for ( std::vector<int>::const_iterator i=ids.begin();
00021             i!=ids.end(); ++i )  ids_.insert(*i);
00022       std::vector<int> status = 
00023         cfg.getParameter< std::vector<int> >("mcStatus");
00024       for ( std::vector<int>::const_iterator i=status.begin();
00025             i!=status.end(); ++i )  status_.insert(*i);
00026     }
00028     bool operator()( const T1 & c, const T2 & mc ) const {
00029       if ( checkCharge_ && c.charge() != mc.charge() ) return false;
00030       if ( !ids_.empty() ) {
00031         if ( ids_.find(abs(mc.pdgId()))==ids_.end() )  return false;
00032       }
00033       if ( status_.empty() )  return true;
00034       return status_.find(mc.status())!=status_.end();
00035     }
00036   private:
00037     bool checkCharge_;
00038     std::set<int> ids_;
00039     std::set<int> status_;
00040   };
00041 }
00042 
00043 #endif

Generated on Tue Jun 9 17:42:24 2009 for CMSSW by  doxygen 1.5.4