Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:26:12

0001 /** \file
0002  *
0003  *  $Date: 2013/04/24 17:16:35 $
0004  *  $Revision: 1.1 $
0005  *  \author M. Maggi -- INFN Bari
0006 */
0007 
0008 #include "RecoLocalMuon/GEMRecHit/plugins/ME0RecHitProducer.h"
0009 
0010 ME0RecHitProducer::ME0RecHitProducer(const edm::ParameterSet& config)
0011     :  // Get the concrete reconstruction algo from the factory
0012       theAlgo{ME0RecHitAlgoFactory::get()->create(config.getParameter<std::string>("recAlgo"),
0013                                                   config.getParameter<edm::ParameterSet>("recAlgoConfig"))} {
0014   produces<ME0RecHitCollection>();
0015 
0016   m_token = consumes<ME0DigiPreRecoCollection>(config.getParameter<edm::InputTag>("me0DigiLabel"));
0017   m_me0GeomToken = esConsumes<ME0Geometry, MuonGeometryRecord>();
0018 }
0019 
0020 ME0RecHitProducer::~ME0RecHitProducer() = default;
0021 
0022 void ME0RecHitProducer::produce(edm::Event& event, const edm::EventSetup& setup) {
0023   // Get the ME0 Geometry
0024   edm::ESHandle<ME0Geometry> me0Geom = setup.getHandle(m_me0GeomToken);
0025 
0026   // Get the digis from the event
0027 
0028   edm::Handle<ME0DigiPreRecoCollection> digis;
0029   event.getByToken(m_token, digis);
0030 
0031   // Pass the EventSetup to the algo
0032 
0033   theAlgo->setES(setup);
0034 
0035   // Create the pointer to the collection which will store the rechits
0036 
0037   auto recHitCollection = std::make_unique<ME0RecHitCollection>();
0038 
0039   // Iterate through all digi collections ordered by LayerId
0040 
0041   ME0DigiPreRecoCollection::DigiRangeIterator me0dgIt;
0042   for (me0dgIt = digis->begin(); me0dgIt != digis->end(); ++me0dgIt) {
0043     // The layerId
0044     const ME0DetId& me0Id = (*me0dgIt).first;
0045 
0046     // Get the iterators over the digis associated with this LayerId
0047     const ME0DigiPreRecoCollection::Range& range = (*me0dgIt).second;
0048 
0049     // Call the reconstruction algorithm
0050 
0051     edm::OwnVector<ME0RecHit> recHits = theAlgo->reconstruct(me0Id, range);
0052 
0053     if (!recHits.empty())
0054       recHitCollection->put(me0Id, recHits.begin(), recHits.end());
0055   }
0056 
0057   event.put(std::move(recHitCollection));
0058 }