File indexing completed on 2024-04-06 12:26:14
0001
0002
0003
0004
0005
0006 #include "FWCore/Framework/interface/Frameworkfwd.h"
0007 #include "FWCore/Framework/interface/stream/EDProducer.h"
0008 #include "FWCore/Framework/interface/Event.h"
0009 #include "FWCore/Framework/interface/ESHandle.h"
0010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0011 #include "FWCore/Utilities/interface/InputTag.h"
0012 #include "FWCore/Utilities/interface/ESGetToken.h"
0013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0014
0015 #include "DataFormats/GEMRecHit/interface/ME0RecHitCollection.h"
0016 #include "DataFormats/GEMRecHit/interface/ME0SegmentCollection.h"
0017 #include "DataFormats/GEMRecHit/interface/ME0Segment.h"
0018 #include "DataFormats/Common/interface/Handle.h"
0019
0020 #include "RecoLocalMuon/GEMSegment/plugins/ME0SegmentBuilder.h"
0021
0022 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0023
0024 class ME0SegmentProducer : public edm::stream::EDProducer<> {
0025 public:
0026
0027 explicit ME0SegmentProducer(const edm::ParameterSet&);
0028
0029 ~ME0SegmentProducer() override {}
0030
0031 void produce(edm::Event&, const edm::EventSetup&) override;
0032
0033 private:
0034 int iev;
0035 edm::EDGetTokenT<ME0RecHitCollection> theME0RecHitToken;
0036 std::unique_ptr<ME0SegmentBuilder> segmentBuilder_;
0037 edm::ESGetToken<ME0Geometry, MuonGeometryRecord> me0GeomToken_;
0038 };
0039
0040 ME0SegmentProducer::ME0SegmentProducer(const edm::ParameterSet& ps) : iev(0) {
0041 theME0RecHitToken = consumes<ME0RecHitCollection>(ps.getParameter<edm::InputTag>("me0RecHitLabel"));
0042 segmentBuilder_ = std::make_unique<ME0SegmentBuilder>(ps);
0043 me0GeomToken_ = esConsumes<ME0Geometry, MuonGeometryRecord>();
0044
0045 produces<ME0SegmentCollection>();
0046 }
0047
0048 void ME0SegmentProducer::produce(edm::Event& ev, const edm::EventSetup& setup) {
0049 LogDebug("ME0SegmentProducer") << "start producing segments for " << ++iev << "th event with ME0 data";
0050
0051
0052 edm::ESHandle<ME0Geometry> me0g = setup.getHandle(me0GeomToken_);
0053 const ME0Geometry* mgeom = &*me0g;
0054 segmentBuilder_->setGeometry(mgeom);
0055
0056
0057 edm::Handle<ME0RecHitCollection> me0RecHits;
0058 ev.getByToken(theME0RecHitToken, me0RecHits);
0059
0060
0061 auto oc = std::make_unique<ME0SegmentCollection>();
0062
0063
0064 segmentBuilder_->build(me0RecHits.product(), *oc);
0065
0066
0067 ev.put(std::move(oc));
0068 }
0069
0070 #include "FWCore/Framework/interface/MakerMacros.h"
0071 DEFINE_FWK_MODULE(ME0SegmentProducer);