Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:22:49

0001 /** \class ME0TriggerProducer
0002  *
0003  * Takes ME0 pads as input
0004  * Produces ME0 trigger objects
0005  *
0006  * \author Sven Dildick (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/ME0TriggerBuilder.h"
0021 #include "DataFormats/Common/interface/Handle.h"
0022 #include "DataFormats/GEMDigi/interface/ME0PadDigiCollection.h"
0023 #include "DataFormats/GEMDigi/interface/ME0TriggerDigiCollection.h"
0024 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0025 #include "Geometry/GEMGeometry/interface/ME0Geometry.h"
0026 
0027 class ME0TriggerBuilder;
0028 
0029 class ME0TriggerProducer : public edm::global::EDProducer<> {
0030 public:
0031   explicit ME0TriggerProducer(const edm::ParameterSet&);
0032   ~ME0TriggerProducer() override;
0033 
0034   void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
0035 
0036 private:
0037   edm::InputTag me0PadDigis_;
0038   edm::EDGetTokenT<ME0PadDigiCollection> me0_pad_token_;
0039   edm::ESGetToken<ME0Geometry, MuonGeometryRecord> me0_geom_token_;
0040   edm::ParameterSet config_;
0041 };
0042 
0043 ME0TriggerProducer::ME0TriggerProducer(const edm::ParameterSet& conf) {
0044   me0PadDigis_ = conf.getParameter<edm::InputTag>("ME0PadDigis");
0045   me0_pad_token_ = consumes<ME0PadDigiCollection>(me0PadDigis_);
0046   me0_geom_token_ = esConsumes<ME0Geometry, MuonGeometryRecord>();
0047   config_ = conf;
0048 
0049   // register what this produces
0050   produces<ME0TriggerDigiCollection>();
0051 }
0052 
0053 ME0TriggerProducer::~ME0TriggerProducer() {}
0054 
0055 void ME0TriggerProducer::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<ME0PadDigiCollection> me0PadDigis;
0059   ev.getByToken(me0_pad_token_, me0PadDigis);
0060   const ME0PadDigiCollection* me0Pads = me0PadDigis.product();
0061 
0062   // Create empty collection
0063   std::unique_ptr<ME0TriggerDigiCollection> oc_trig(new ME0TriggerDigiCollection);
0064 
0065   std::unique_ptr<ME0TriggerBuilder> trigBuilder(new ME0TriggerBuilder(config_));
0066   trigBuilder->setME0Geometry(&*h_me0);
0067 
0068   // Fill output collections if valid input collection is available.
0069   trigBuilder->build(me0Pads, *oc_trig);
0070 
0071   // Put collections in event.
0072   ev.put(std::move(oc_trig));
0073 }
0074 
0075 DEFINE_FWK_MODULE(ME0TriggerProducer);