Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 //-------------------------------------------------
0002 //
0003 //   Class: L1TwinMuxProducer
0004 //
0005 //   L1TwinMuxProducer EDProducer
0006 //
0007 //
0008 //   Author :
0009 //   G. Flouris               U Ioannina    Feb. 2015
0010 //   Mod.: g Karathanasis
0011 //--------------------------------------------------
0012 
0013 #include "FWCore/Framework/interface/MakerMacros.h"
0014 #include "FWCore/Framework/interface/Event.h"
0015 #include "FWCore/Framework/interface/MakerMacros.h"
0016 #include "FWCore/Framework/interface/ConsumesCollector.h"
0017 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0018 #include "FWCore/Framework/interface/global/EDProducer.h"
0019 #include "FWCore/Utilities/interface/ESGetToken.h"
0020 
0021 #include "CondFormats/DataRecord/interface/L1TTwinMuxParamsRcd.h"
0022 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0023 
0024 #include "L1Trigger/L1TTwinMux/interface/L1TTwinMuxAlgorithm.h"
0025 
0026 #include <iostream>
0027 #include <iomanip>
0028 #include <memory>
0029 
0030 using namespace std;
0031 
0032 class L1TTwinMuxProducer : public edm::global::EDProducer<> {
0033 public:
0034   L1TTwinMuxProducer(const edm::ParameterSet& pset);
0035   ~L1TTwinMuxProducer() override {}
0036   void produce(edm::StreamID, edm::Event& e, const edm::EventSetup& c) const override;
0037 
0038 private:
0039   const edm::EDGetTokenT<L1MuDTChambPhContainer> m_dtdigi;
0040   const edm::EDGetTokenT<L1MuDTChambThContainer> m_dtthetadigi;
0041   const edm::EDGetTokenT<RPCDigiCollection> m_rpcsource;
0042   ///Event Setup Handler
0043   const edm::ESGetToken<L1TTwinMuxParams, L1TTwinMuxParamsRcd> m_tmParamsToken;
0044   const edm::ESGetToken<RPCGeometry, MuonGeometryRecord> m_rpcGeometryToken;
0045 
0046   const edm::EDPutTokenT<L1MuDTChambPhContainer> m_phContainerToken;
0047   const edm::EDPutTokenT<L1MuDTChambThContainer> m_thContainerToken;
0048 };
0049 
0050 L1TTwinMuxProducer::L1TTwinMuxProducer(const edm::ParameterSet& pset)
0051     : m_dtdigi(consumes(pset.getParameter<edm::InputTag>("DTDigi_Source"))),
0052       m_dtthetadigi(consumes(pset.getParameter<edm::InputTag>("DTThetaDigi_Source"))),
0053       m_rpcsource(consumes(pset.getParameter<edm::InputTag>("RPC_Source"))),
0054       m_tmParamsToken(esConsumes()),
0055       m_rpcGeometryToken(esConsumes()),
0056       m_phContainerToken(produces<L1MuDTChambPhContainer>()),
0057       m_thContainerToken(produces<L1MuDTChambThContainer>()) {}
0058 
0059 void L1TTwinMuxProducer::produce(edm::StreamID, edm::Event& e, const edm::EventSetup& c) const {
0060   ///Check consistency of the paramters
0061   auto const& tmParams = c.getData(m_tmParamsToken);
0062 
0063   ///Only RPC: the emulator's output consist from rpc->dy primitives only
0064   bool onlyRPC = tmParams.get_UseOnlyRPC();
0065   ///Only DT: the emulator's output consist from dt primitives only
0066   bool onlyDT = tmParams.get_UseOnlyDT();
0067 
0068   if (onlyDT && onlyRPC) {
0069     edm::LogWarning("Inconsistent configuration") << "onlyRPC and onlyDT options";
0070     return;
0071   }
0072   ///---Check consistency of the paramters
0073 
0074   edm::Handle<L1MuDTChambPhContainer> phiDigis = e.getHandle(m_dtdigi);
0075   edm::Handle<L1MuDTChambThContainer> thetaDigis = e.getHandle(m_dtthetadigi);
0076 
0077   edm::Handle<RPCDigiCollection> rpcDigis = e.getHandle(m_rpcsource);
0078 
0079   if (!phiDigis.isValid()) {
0080     edm::LogWarning("Inconsistent digis") << "input DT phi digis not valid";
0081   }
0082 
0083   auto const& rpcGeometry = c.getData(m_rpcGeometryToken);
0084 
0085   L1TTwinMuxAlgorithm l1tma;
0086   l1tma.run(phiDigis, thetaDigis, rpcDigis, tmParams, rpcGeometry);
0087   auto l1ttmp = l1tma.get_ph_tm_output();
0088   //null transfer of theta digis
0089   L1MuDTChambThContainer l1ttmth;
0090   const std::vector<L1MuDTChambThDigi>* theta = thetaDigis->getContainer();
0091   l1ttmth.setContainer(*theta);
0092 
0093   e.emplace(m_phContainerToken, std::move(l1ttmp));
0094   e.emplace(m_thContainerToken, std::move(l1ttmth));
0095 }
0096 
0097 DEFINE_FWK_MODULE(L1TTwinMuxProducer);