Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-02-05 23:50:57

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 "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0018 #include "CommonTools/UtilAlgos/interface/ObjectSelector.h"
0019 #include "Alignment/CommonAlignmentProducer/interface/AlignmentMuonSelector.h"
0020 #include "DataFormats/MuonReco/interface/MuonFwd.h"
0021 
0022 // the following include is necessary to clone all track branches
0023 // including recoTrackExtras and TrackingRecHitsOwned.
0024 // if you remove it the code will compile, but the cloned
0025 // tracks have only the recoMuons branch!
0026 
0027 struct MuonConfigSelector {
0028   typedef std::vector<const reco::Muon *> container;
0029   typedef container::const_iterator const_iterator;
0030   typedef reco::MuonCollection collection;
0031 
0032   MuonConfigSelector(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC) : theSelector(cfg) {}
0033 
0034   const_iterator begin() const { return selected_.begin(); }
0035   const_iterator end() const { return selected_.end(); }
0036   size_t size() const { return selected_.size(); }
0037 
0038   void select(const edm::Handle<reco::MuonCollection> &c, const edm::Event &evt, const edm::EventSetup & /* dummy*/) {
0039     all_.clear();
0040     selected_.clear();
0041     for (collection::const_iterator i = c.product()->begin(), iE = c.product()->end(); i != iE; ++i) {
0042       all_.push_back(&*i);
0043     }
0044     selected_ = theSelector.select(all_, evt);  // might add dummy
0045   }
0046 
0047   static void fillPSetDescription(edm::ParameterSetDescription &desc) {
0048     AlignmentMuonSelector::fillPSetDescription(desc);
0049   }
0050 
0051 private:
0052   container all_, selected_;
0053   AlignmentMuonSelector theSelector;
0054 };
0055 
0056 typedef ObjectSelector<MuonConfigSelector> AlignmentMuonSelectorModule;
0057 
0058 DEFINE_FWK_MODULE(AlignmentMuonSelectorModule);