File indexing completed on 2024-04-06 12:26:01
0001
0002
0003
0004
0005 #include <RecoLocalMuon/CSCSegment/src/CSCSegmentProducer.h>
0006 #include <RecoLocalMuon/CSCSegment/src/CSCSegmentBuilder.h>
0007
0008 #include <DataFormats/Common/interface/Handle.h>
0009 #include <FWCore/Framework/interface/ESHandle.h>
0010 #include <FWCore/Utilities/interface/InputTag.h>
0011 #include <FWCore/MessageLogger/interface/MessageLogger.h>
0012
0013 #include <DataFormats/CSCRecHit/interface/CSCSegmentCollection.h>
0014 #include <DataFormats/CSCRecHit/interface/CSCSegment.h>
0015
0016 CSCSegmentProducer::CSCSegmentProducer(const edm::ParameterSet& pas) : iev(0) {
0017 m_token = consumes<CSCRecHit2DCollection>(pas.getParameter<edm::InputTag>("inputObjects"));
0018 m_cscGeometryToken = esConsumes<CSCGeometry, MuonGeometryRecord>();
0019 segmentBuilder_ = new CSCSegmentBuilder(pas);
0020
0021
0022 produces<CSCSegmentCollection>();
0023 }
0024
0025 CSCSegmentProducer::~CSCSegmentProducer() {
0026 LogDebug("CSCSegment|CSC") << "deleting CSCSegmentBuilder after " << iev << " events w/csc data.";
0027 delete segmentBuilder_;
0028 }
0029
0030 void CSCSegmentProducer::produce(edm::Event& ev, const edm::EventSetup& setup) {
0031 LogDebug("CSCSegment|CSC") << "start producing segments for " << ++iev << "th event with csc data";
0032
0033
0034
0035 edm::ESHandle<CSCGeometry> h = setup.getHandle(m_cscGeometryToken);
0036 const CSCGeometry* pgeom = &*h;
0037 segmentBuilder_->setGeometry(pgeom);
0038
0039
0040 edm::Handle<CSCRecHit2DCollection> cscRecHits;
0041 ev.getByToken(m_token, cscRecHits);
0042
0043
0044 auto oc = std::make_unique<CSCSegmentCollection>();
0045
0046
0047 segmentBuilder_->build(cscRecHits.product(), *oc);
0048
0049
0050 ev.put(std::move(oc));
0051 }