Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef RecoSelectors_RecoTrackSelector_h
0002 #define RecoSelectors_RecoTrackSelector_h
0003 /* \class RecoTrackSelector
0004  *
0005  * \author Giuseppe Cerati, INFN
0006  *
0007  */
0008 #include "CommonTools/RecoAlgos/interface/RecoTrackSelectorBase.h"
0009 
0010 class RecoTrackSelector : public RecoTrackSelectorBase {
0011 public:
0012   typedef reco::TrackRef reference_type;
0013   typedef reco::TrackCollection collection;
0014   typedef std::vector<const reco::Track*> container;
0015   typedef container::const_iterator const_iterator;
0016 
0017   /// Constructors
0018   RecoTrackSelector() {}
0019   RecoTrackSelector(const edm::ParameterSet& cfg, edm::ConsumesCollector&& iC) : RecoTrackSelectorBase(cfg, iC) {}
0020 
0021   const_iterator begin() const { return selected_.begin(); }
0022   const_iterator end() const { return selected_.end(); }
0023 
0024   void select(const edm::Handle<collection>& c, const edm::Event& event, const edm::EventSetup& es) {
0025     init(event, es);
0026     selected_.clear();
0027     for (reco::TrackCollection::const_iterator trk = c->begin(); trk != c->end(); ++trk) {
0028       reference_type tkref(c, std::distance(c->begin(), trk));
0029       if (operator()(*tkref)) {
0030         selected_.push_back(&*trk);
0031       }
0032     }
0033   }
0034 
0035   size_t size() const { return selected_.size(); }
0036 
0037 private:
0038   container selected_;
0039 };
0040 
0041 #endif