File indexing completed on 2024-04-06 12:26:12
0001
0002
0003
0004
0005
0006
0007
0008 #include "RecoLocalMuon/GEMRecHit/plugins/ME0RecHitProducer.h"
0009
0010 ME0RecHitProducer::ME0RecHitProducer(const edm::ParameterSet& config)
0011 :
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
0024 edm::ESHandle<ME0Geometry> me0Geom = setup.getHandle(m_me0GeomToken);
0025
0026
0027
0028 edm::Handle<ME0DigiPreRecoCollection> digis;
0029 event.getByToken(m_token, digis);
0030
0031
0032
0033 theAlgo->setES(setup);
0034
0035
0036
0037 auto recHitCollection = std::make_unique<ME0RecHitCollection>();
0038
0039
0040
0041 ME0DigiPreRecoCollection::DigiRangeIterator me0dgIt;
0042 for (me0dgIt = digis->begin(); me0dgIt != digis->end(); ++me0dgIt) {
0043
0044 const ME0DetId& me0Id = (*me0dgIt).first;
0045
0046
0047 const ME0DigiPreRecoCollection::Range& range = (*me0dgIt).second;
0048
0049
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 }