Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:13

0001 /** \class AlignmentMuonSelectorModule
0002  *
0003  * selects a subset of a muon collection and clones
0004  * Track, TrackExtra parts and RecHits collection
0005  * for SA, GB and Tracker Only options
0006  *
0007  * \author Javier Fernandez, IFCA
0008  *
0009  * \version $Revision: 1.3 $
0010  *
0011  * $Id: AlignmentMuonSelectorModule.cc,v 1.3 2008/02/04 19:32:26 flucke Exp $
0012  *
0013  */
0014 
0015 #include "FWCore/Framework/interface/ConsumesCollector.h"
0016 #include "FWCore/Framework/interface/MakerMacros.h"
0017 #include "CommonTools/UtilAlgos/interface/ObjectSelector.h"
0018 #include "Alignment/CommonAlignmentProducer/interface/AlignmentMuonSelector.h"
0019 #include "DataFormats/MuonReco/interface/MuonFwd.h"
0020 
0021 // the following include is necessary to clone all track branches
0022 // including recoTrackExtras and TrackingRecHitsOwned.
0023 // if you remove it the code will compile, but the cloned
0024 // tracks have only the recoMuons branch!
0025 
0026 struct MuonConfigSelector {
0027   typedef std::vector<const reco::Muon *> container;
0028   typedef container::const_iterator const_iterator;
0029   typedef reco::MuonCollection collection;
0030 
0031   MuonConfigSelector(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC) : theSelector(cfg) {}
0032 
0033   const_iterator begin() const { return selected_.begin(); }
0034   const_iterator end() const { return selected_.end(); }
0035   size_t size() const { return selected_.size(); }
0036 
0037   void select(const edm::Handle<reco::MuonCollection> &c, const edm::Event &evt, const edm::EventSetup & /* dummy*/) {
0038     all_.clear();
0039     selected_.clear();
0040     for (collection::const_iterator i = c.product()->begin(), iE = c.product()->end(); i != iE; ++i) {
0041       all_.push_back(&*i);
0042     }
0043     selected_ = theSelector.select(all_, evt);  // might add dummy
0044   }
0045 
0046 private:
0047   container all_, selected_;
0048   AlignmentMuonSelector theSelector;
0049 };
0050 
0051 typedef ObjectSelector<MuonConfigSelector> AlignmentMuonSelectorModule;
0052 
0053 DEFINE_FWK_MODULE(AlignmentMuonSelectorModule);