Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /** \class GEMSegmentProducer derived by CSCSegmentProducer 
0002  * Produces a collection of GEMSegment's in endcap muon GEMs. 
0003  *
0004  * \author Piet Verwilligen
0005  */
0006 
0007 #include "FWCore/Framework/interface/Frameworkfwd.h"
0008 #include "FWCore/Framework/interface/stream/EDProducer.h"
0009 #include "FWCore/Framework/interface/Event.h"
0010 #include "FWCore/Framework/interface/ESHandle.h"
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012 #include "FWCore/Utilities/interface/InputTag.h"
0013 #include "FWCore/Utilities/interface/ESGetToken.h"
0014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0015 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0016 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0017 
0018 #include "DataFormats/Common/interface/Handle.h"
0019 #include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h"
0020 #include "DataFormats/GEMRecHit/interface/GEMSegmentCollection.h"
0021 #include "DataFormats/GEMRecHit/interface/GEMSegment.h"
0022 
0023 #include "RecoLocalMuon/GEMSegment/plugins/GEMSegmentBuilder.h"
0024 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0025 
0026 class GEMSegmentProducer : public edm::stream::EDProducer<> {
0027 public:
0028   /// Constructor
0029   explicit GEMSegmentProducer(const edm::ParameterSet&);
0030   /// Destructor
0031   ~GEMSegmentProducer() override {}
0032   /// Produce the GEMSegment collection
0033   void produce(edm::Event&, const edm::EventSetup&) override;
0034 
0035   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0036 
0037 private:
0038   int iev;  // events through
0039   edm::EDGetTokenT<GEMRecHitCollection> theGEMRecHitToken;
0040   std::unique_ptr<GEMSegmentBuilder> segmentBuilder_;
0041   edm::ESGetToken<GEMGeometry, MuonGeometryRecord> gemGeomToken_;
0042 };
0043 
0044 GEMSegmentProducer::GEMSegmentProducer(const edm::ParameterSet& ps) : iev(0) {
0045   theGEMRecHitToken = consumes<GEMRecHitCollection>(ps.getParameter<edm::InputTag>("gemRecHitLabel"));
0046   segmentBuilder_ = std::make_unique<GEMSegmentBuilder>(ps);  // pass on the Parameter Set
0047   gemGeomToken_ = esConsumes<GEMGeometry, MuonGeometryRecord>();
0048   // register what this produces
0049   produces<GEMSegmentCollection>();
0050 }
0051 
0052 void GEMSegmentProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0053   edm::ParameterSetDescription desc;
0054   desc.add<edm::InputTag>("gemRecHitLabel", edm::InputTag("gemRecHits"));
0055   GEMSegmentBuilder::fillDescription(desc);
0056   descriptions.add("gemSegments", desc);
0057 }
0058 
0059 void GEMSegmentProducer::produce(edm::Event& ev, const edm::EventSetup& setup) {
0060   LogDebug("GEMSegmentProducer") << "start producing segments for " << ++iev << "th event with GEM data";
0061 
0062   // find the geometry (& conditions?) for this event & cache it in the builder
0063   edm::ESHandle<GEMGeometry> gemg = setup.getHandle(gemGeomToken_);
0064   const GEMGeometry* mgeom = &*gemg;
0065   segmentBuilder_->setGeometry(mgeom);
0066 
0067   // get the collection of GEMRecHit
0068   edm::Handle<GEMRecHitCollection> gemRecHits;
0069   ev.getByToken(theGEMRecHitToken, gemRecHits);
0070 
0071   // create empty collection of Segments
0072   auto oc = std::make_unique<GEMSegmentCollection>();
0073 
0074   // fill the collection
0075   segmentBuilder_->build(gemRecHits.product(), *oc);  //@@ FILL oc
0076 
0077   // put collection in event
0078   ev.put(std::move(oc));
0079 }
0080 
0081 #include "FWCore/Framework/interface/MakerMacros.h"
0082 DEFINE_FWK_MODULE(GEMSegmentProducer);