Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:20:28

0001 /** \class ME0TriggerPseudoProducer
0002  *
0003  * Takes offline ME0 segment as input
0004  * Produces ME0 trigger objects
0005  *
0006  * \author Tao Huang (TAMU).
0007  *
0008  */
0009 
0010 #include "FWCore/Framework/interface/MakerMacros.h"
0011 #include "FWCore/Framework/interface/ConsumesCollector.h"
0012 #include "FWCore/Framework/interface/Frameworkfwd.h"
0013 #include "FWCore/Framework/interface/global/EDProducer.h"
0014 #include "FWCore/Framework/interface/Event.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0016 #include "FWCore/Utilities/interface/InputTag.h"
0017 #include "FWCore/Utilities/interface/ESGetToken.h"
0018 #include "FWCore/Framework/interface/ESHandle.h"
0019 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0020 #include "L1Trigger/L1TGEM/interface/ME0TriggerPseudoBuilder.h"
0021 #include "DataFormats/Common/interface/Handle.h"
0022 #include "DataFormats/GEMDigi/interface/ME0TriggerDigiCollection.h"
0023 #include "DataFormats/GEMRecHit/interface/ME0SegmentCollection.h"
0024 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0025 #include "Geometry/GEMGeometry/interface/ME0Geometry.h"
0026 
0027 class ME0TriggerPseudoBuilder;
0028 
0029 class ME0TriggerPseudoProducer : public edm::global::EDProducer<> {
0030 public:
0031   explicit ME0TriggerPseudoProducer(const edm::ParameterSet&);
0032   ~ME0TriggerPseudoProducer() override;
0033 
0034   void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
0035 
0036 private:
0037   edm::InputTag me0segmentProducer_;
0038   edm::EDGetTokenT<ME0SegmentCollection> me0segment_token_;
0039   edm::ESGetToken<ME0Geometry, MuonGeometryRecord> me0_geom_token_;
0040   edm::ParameterSet config_;
0041 };
0042 
0043 ME0TriggerPseudoProducer::ME0TriggerPseudoProducer(const edm::ParameterSet& conf) {
0044   me0segmentProducer_ = conf.getParameter<edm::InputTag>("ME0SegmentProducer");
0045   me0segment_token_ = consumes<ME0SegmentCollection>(me0segmentProducer_);
0046   me0_geom_token_ = esConsumes<ME0Geometry, MuonGeometryRecord>();
0047   config_ = conf;
0048 
0049   // register what this produces
0050   produces<ME0TriggerDigiCollection>();
0051 }
0052 
0053 ME0TriggerPseudoProducer::~ME0TriggerPseudoProducer() {}
0054 
0055 void ME0TriggerPseudoProducer::produce(edm::StreamID, edm::Event& ev, const edm::EventSetup& setup) const {
0056   edm::ESHandle<ME0Geometry> h_me0 = setup.getHandle(me0_geom_token_);
0057 
0058   edm::Handle<ME0SegmentCollection> me0Segmentcoll;
0059   ev.getByToken(me0segment_token_, me0Segmentcoll);
0060   const ME0SegmentCollection* me0segments = me0Segmentcoll.product();
0061 
0062   // Create empty collection
0063   auto oc_trig = std::make_unique<ME0TriggerDigiCollection>();
0064 
0065   auto trigBuilder = std::make_unique<ME0TriggerPseudoBuilder>(config_);
0066   trigBuilder->setME0Geometry(&*h_me0);
0067 
0068   // Fill output collections if valid input collection is available.
0069   if (me0Segmentcoll.isValid()) {
0070     trigBuilder->build(me0segments, *oc_trig);
0071   }
0072 
0073   // Put collections in event.
0074   ev.put(std::move(oc_trig));
0075 }
0076 
0077 DEFINE_FWK_MODULE(ME0TriggerPseudoProducer);