Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:09

0001 #ifndef CommonTools_RecoAlgos_RecoTrackViewRefSelector_h
0002 #define CommonTools_RecoAlgos_RecoTrackViewRefSelector_h
0003 
0004 #include "CommonTools/RecoAlgos/interface/RecoTrackSelectorBase.h"
0005 #include "DataFormats/Common/interface/RefToBaseVector.h"
0006 
0007 class RecoTrackViewRefSelector : public RecoTrackSelectorBase {
0008 public:
0009   typedef edm::View<reco::Track> collection;
0010   typedef edm::RefToBaseVector<reco::Track> ref_container;
0011   typedef ref_container::const_iterator const_ref_iterator;
0012 
0013   /// Constructors
0014   RecoTrackViewRefSelector() {}
0015 
0016   RecoTrackViewRefSelector(const edm::ParameterSet& cfg, edm::ConsumesCollector&& iC)
0017       : RecoTrackSelectorBase(cfg, iC) {}
0018 
0019   const_ref_iterator begin() const { return ref_selected_.begin(); }
0020   const_ref_iterator end() const { return ref_selected_.end(); }
0021 
0022   void select(const edm::Handle<collection>& c, const edm::Event& event, const edm::EventSetup& es) {
0023     init(event, es);
0024     ref_selected_.clear();
0025     for (unsigned int i = 0; i < c->size(); i++) {
0026       auto trk = c->refAt(i);
0027       if (operator()(*trk)) {
0028         ref_selected_.push_back(trk);
0029       }
0030     }
0031   }
0032 
0033   size_t size() const { return ref_selected_.size(); }
0034 
0035 private:
0036   ref_container ref_selected_;
0037 };
0038 
0039 #endif