CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Alignment/CommonAlignmentProducer/plugins/AlignmentMuonSelectorModule.cc

Go to the documentation of this file.
00001 
00015 #include "FWCore/Framework/interface/MakerMacros.h"
00016 #include "CommonTools/UtilAlgos/interface/ObjectSelector.h"
00017 #include "Alignment/CommonAlignmentProducer/interface/AlignmentMuonSelector.h"
00018 #include "DataFormats/MuonReco/interface/MuonFwd.h" 
00019 
00020 // the following include is necessary to clone all track branches
00021 // including recoTrackExtras and TrackingRecHitsOwned.
00022 // if you remove it the code will compile, but the cloned
00023 // tracks have only the recoMuons branch!
00024 
00025 struct MuonConfigSelector {
00026 
00027   typedef std::vector<const reco::Muon*> container;
00028   typedef container::const_iterator const_iterator;
00029   typedef reco::MuonCollection collection; 
00030 
00031   MuonConfigSelector( const edm::ParameterSet & cfg ) :
00032     theSelector(cfg) {}
00033 
00034   const_iterator begin() const { return selected_.begin(); }
00035   const_iterator end() const { return selected_.end(); }
00036   size_t size() const { return selected_.size(); }
00037 
00038   void select( const edm::Handle<reco::MuonCollection> & c,  const edm::Event & evt, const edm::EventSetup &/* dummy*/)
00039   {
00040     all_.clear();
00041     selected_.clear();
00042     for (collection::const_iterator i = c.product()->begin(), iE = c.product()->end();
00043          i != iE; ++i){
00044       all_.push_back(& * i );
00045     }
00046     selected_ = theSelector.select(all_, evt); // might add dummy 
00047   }
00048 
00049 private:
00050   container all_,selected_;
00051   AlignmentMuonSelector theSelector;
00052 };
00053 
00054 typedef ObjectSelector<MuonConfigSelector>  AlignmentMuonSelectorModule;
00055 
00056 DEFINE_FWK_MODULE( AlignmentMuonSelectorModule );
00057