Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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