Skip to content

Commit

Permalink
Merge pull request #34630 from Dr15Jones/esConsumes_OmtfRpc
Browse files Browse the repository at this point in the history
Add esConsumes to OmtfPacker and OmtfUnpacker
  • Loading branch information
cmsbuild authored Jul 27, 2021
2 parents 59b3621 + 86b5b65 commit 2c685bd
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 46 deletions.
6 changes: 2 additions & 4 deletions EventFilter/L1TRawToDigi/interface/OmtfLinkMappingRpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@

#include "EventFilter/L1TRawToDigi/interface/OmtfEleIndex.h"
#include "CondFormats/RPCObjects/interface/LinkBoardElectronicIndex.h"
#include "CondFormats/RPCObjects/interface/RPCAMCLinkMap.h"

class RPCReadOutMapping;
namespace edm {
class EventSetup;
}

namespace omtf {

Expand All @@ -33,7 +31,7 @@ namespace omtf {
public:
RpcLinkMap() {}

void init(const edm::EventSetup& es);
void init(const RPCAMCLinkMap& es);

void init(const std::string& fName);

Expand Down
7 changes: 4 additions & 3 deletions EventFilter/L1TRawToDigi/interface/OmtfRpcPacker.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "DataFormats/L1TMuon/interface/OMTF/OmtfDataWord64.h"
#include "EventFilter/L1TRawToDigi/interface/OmtfLinkMappingRpc.h"
#include "CondFormats/RPCObjects/interface/RPCReadOutMapping.h"
#include "CondFormats/RPCObjects/interface/RPCEMap.h"

namespace edm {
class EventSetup;
Expand All @@ -18,12 +19,12 @@ namespace omtf {
public:
RpcPacker() {}

void init(const edm::EventSetup& es);
void init(const edm::EventSetup& es, const std::string& connectionFile);
void init(const RPCEMap& readoutMapping, const RPCAMCLinkMap& linkMap);
void init(const RPCEMap& readoutMapping, const std::string& connectionFile);
void pack(const RPCDigiCollection* prod, FedAmcRawsMap& raws);

private:
void initCabling(const edm::EventSetup& es);
void initCabling(const RPCEMap& readoutMapping);

MapLBIndex2EleIndex thePact2Omtf;
std::unique_ptr<const RPCReadOutMapping> thePactCabling;
Expand Down
9 changes: 5 additions & 4 deletions EventFilter/L1TRawToDigi/interface/OmtfRpcUnpacker.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "DataFormats/L1TMuon/interface/OMTF/OmtfDataWord64.h"
#include "EventFilter/L1TRawToDigi/interface/OmtfLinkMappingRpc.h"
#include "CondFormats/RPCObjects/interface/RPCReadOutMapping.h"
#include "CondFormats/RPCObjects/interface/RPCEMap.h"

namespace edm {
class EventSetup;
Expand All @@ -22,12 +23,12 @@ namespace omtf {
public:
RpcUnpacker() {}

void init(const edm::EventSetup &es);
void init(const edm::EventSetup &es, const std::string &connectionFile);
void unpack(int triggerBX, unsigned int fed, unsigned int amc, const RpcDataWord64 &raw, RPCDigiCollection *prod);
void init(const RPCEMap& readoutMapping, const RPCAMCLinkMap& linkMap);
void init(const RPCEMap& readoutMapping, const std::string& connectionFile);
void unpack(int triggerBX, unsigned int fed, unsigned int amc, const RpcDataWord64& raw, RPCDigiCollection* prod);

private:
void initCabling(const edm::EventSetup &es);
void initCabling(const RPCEMap& readoutMapping);

MapEleIndex2LBIndex theOmtf2Pact;
std::unique_ptr<const RPCReadOutMapping> thePactCabling;
Expand Down
21 changes: 19 additions & 2 deletions EventFilter/L1TRawToDigi/plugins/OmtfPacker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
#include "EventFilter/L1TRawToDigi/interface/OmtfCscPacker.h"
#include "EventFilter/L1TRawToDigi/interface/OmtfDtPacker.h"

#include "CondFormats/RPCObjects/interface/RPCEMap.h"
#include "CondFormats/DataRecord/interface/RPCEMapRcd.h"
#include "CondFormats/DataRecord/interface/RPCOMTFLinkMapRcd.h"

namespace omtf {

class OmtfPacker : public edm::stream::EDProducer<> {
Expand Down Expand Up @@ -68,6 +72,9 @@ namespace omtf {
edm::EDGetTokenT<L1MuDTChambThContainer> theDtThToken;
edm::EDGetTokenT<L1MuDTChambPhContainer> theDtPhToken;

edm::ESGetToken<RPCEMap, RPCEMapRcd> theRPCEMapToken;
edm::ESGetToken<RPCAMCLinkMap, RPCOMTFLinkMapRcd> theAmcMappingToken;

CscPacker theCscPacker;
RpcPacker theRpcPacker;
DtPacker theDtPacker;
Expand All @@ -86,6 +93,13 @@ namespace omtf {
theSkipDt = pset.getParameter<bool>("skipDt");
theSkipRpc = pset.getParameter<bool>("skipRpc");
theSkipCsc = pset.getParameter<bool>("skipCsc");

if (!theSkipRpc) {
theRPCEMapToken = esConsumes<edm::Transition::BeginRun>();
if (not theConfig.getParameter<bool>("useRpcConnectionFile")) {
theAmcMappingToken = esConsumes<edm::Transition::BeginRun>();
}
}
}

void OmtfPacker::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
Expand All @@ -108,10 +122,13 @@ namespace omtf {
// initialise RPC packer
//
if (!theSkipRpc) {
edm::ESTransientHandle<RPCEMap> readoutMapping = es.getTransientHandle(theRPCEMapToken);
if (theConfig.getParameter<bool>("useRpcConnectionFile")) {
theRpcPacker.init(es, edm::FileInPath(theConfig.getParameter<std::string>("rpcConnectionFile")).fullPath());
theRpcPacker.init(*readoutMapping,
edm::FileInPath(theConfig.getParameter<std::string>("rpcConnectionFile")).fullPath());
} else {
theRpcPacker.init(es);
auto const& amcMapping = es.getData(theAmcMappingToken);
theRpcPacker.init(*readoutMapping, amcMapping);
}
}

Expand Down
21 changes: 19 additions & 2 deletions EventFilter/L1TRawToDigi/plugins/OmtfUnpacker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
#include "EventFilter/L1TRawToDigi/interface/OmtfDtUnpacker.h"
#include "EventFilter/L1TRawToDigi/interface/OmtfMuonUnpacker.h"

#include "CondFormats/RPCObjects/interface/RPCEMap.h"
#include "CondFormats/DataRecord/interface/RPCEMapRcd.h"
#include "CondFormats/DataRecord/interface/RPCOMTFLinkMapRcd.h"

namespace omtf {

class OmtfUnpacker : public edm::stream::EDProducer<> {
Expand All @@ -62,6 +66,9 @@ namespace omtf {

edm::EDGetTokenT<FEDRawDataCollection> theFedDataToken;

edm::ESGetToken<RPCEMap, RPCEMapRcd> theRPCEMapToken;
edm::ESGetToken<RPCAMCLinkMap, RPCOMTFLinkMapRcd> theAmcMappingToken;

RpcUnpacker theRpcUnpacker;
CscUnpacker theCscUnpacker;
DtUnpacker theDtUnpacker;
Expand All @@ -88,6 +95,13 @@ namespace omtf {
theSkipMuon = pset.getParameter<bool>("skipMuon");

theFedDataToken = consumes<FEDRawDataCollection>(pset.getParameter<edm::InputTag>("inputLabel"));

if (!theSkipRpc) {
theRPCEMapToken = esConsumes<edm::Transition::BeginRun>();
if (not theConfig.getParameter<bool>("useRpcConnectionFile")) {
theAmcMappingToken = esConsumes<edm::Transition::BeginRun>();
}
}
}

void OmtfUnpacker::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
Expand All @@ -108,10 +122,13 @@ namespace omtf {
// rpc unpacker
//
if (!theSkipRpc) {
edm::ESTransientHandle<RPCEMap> readoutMapping = es.getTransientHandle(theRPCEMapToken);
if (theConfig.getParameter<bool>("useRpcConnectionFile")) {
theRpcUnpacker.init(es, edm::FileInPath(theConfig.getParameter<std::string>("rpcConnectionFile")).fullPath());
theRpcUnpacker.init(*readoutMapping,
edm::FileInPath(theConfig.getParameter<std::string>("rpcConnectionFile")).fullPath());
} else {
theRpcUnpacker.init(es);
auto const& amcMapping = es.getData(theAmcMappingToken);
theRpcUnpacker.init(*readoutMapping, amcMapping);
}
}

Expand Down
9 changes: 2 additions & 7 deletions EventFilter/L1TRawToDigi/src/OmtfLinkMappingRpc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#include <fstream>

#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESTransientHandle.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "CondFormats/RPCObjects/interface/RPCReadOutMapping.h"
Expand All @@ -15,7 +13,6 @@
#include "CondFormats/RPCObjects/interface/TriggerBoardSpec.h"
#include "CondFormats/RPCObjects/interface/LinkBoardSpec.h"

#include "CondFormats/DataRecord/interface/RPCOMTFLinkMapRcd.h"
#include "CondFormats/RPCObjects/interface/RPCAMCLinkMap.h"

namespace omtf {
Expand Down Expand Up @@ -75,10 +72,8 @@ namespace omtf {
return pact2omtfs;
}

void RpcLinkMap::init(const edm::EventSetup& es) {
edm::ESHandle<RPCAMCLinkMap> amcMapping;
es.get<RPCOMTFLinkMapRcd>().get(amcMapping);
const RPCAMCLinkMap::map_type& amcMap = amcMapping->getMap();
void RpcLinkMap::init(const RPCAMCLinkMap& amcMapping) {
const RPCAMCLinkMap::map_type& amcMap = amcMapping.getMap();

for (const auto& item : amcMap) {
unsigned int fedId = item.first.getFED();
Expand Down
19 changes: 7 additions & 12 deletions EventFilter/L1TRawToDigi/src/OmtfRpcPacker.cc
Original file line number Diff line number Diff line change
@@ -1,35 +1,30 @@
#include "EventFilter/L1TRawToDigi/interface/OmtfRpcPacker.h"

#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESTransientHandle.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "CondFormats/RPCObjects/interface/RPCReadOutMapping.h"
#include "EventFilter/RPCRawToDigi/interface/RPCRecordFormatter.h"
#include "EventFilter/RPCRawToDigi/interface/RPCPackingModule.h"
#include "EventFilter/RPCRawToDigi/interface/DebugDigisPrintout.h"
#include "CondFormats/RPCObjects/interface/RPCEMap.h"
#include "CondFormats/DataRecord/interface/RPCEMapRcd.h"
#include "EventFilter/L1TRawToDigi/interface/OmtfRpcDataWord64.h"

namespace omtf {

void RpcPacker::initCabling(const edm::EventSetup& es) {
edm::ESTransientHandle<RPCEMap> readoutMapping;
es.get<RPCEMapRcd>().get(readoutMapping);
thePactCabling.reset(readoutMapping->convert());
void RpcPacker::initCabling(const RPCEMap& readoutMapping) {
thePactCabling.reset(readoutMapping.convert());
LogDebug("OmtfPacker") << " Has PACT readout map, VERSION: " << thePactCabling->version() << std::endl;
}

void RpcPacker::init(const edm::EventSetup& es) {
initCabling(es);
void RpcPacker::init(const RPCEMap& readoutMapping, const RPCAMCLinkMap& linkMap) {
initCabling(readoutMapping);
RpcLinkMap omtfLink2Ele;
omtfLink2Ele.init(es);
omtfLink2Ele.init(linkMap);
thePact2Omtf = translatePact2Omtf(omtfLink2Ele, thePactCabling.get());
}

void RpcPacker::init(const edm::EventSetup& es, const std::string& connectionFile) {
initCabling(es);
void RpcPacker::init(const RPCEMap& readoutMapping, const std::string& connectionFile) {
initCabling(readoutMapping);
RpcLinkMap omtfLink2Ele;
omtfLink2Ele.init(connectionFile);
thePact2Omtf = translatePact2Omtf(omtfLink2Ele, thePactCabling.get());
Expand Down
20 changes: 8 additions & 12 deletions EventFilter/L1TRawToDigi/src/OmtfRpcUnpacker.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "EventFilter/L1TRawToDigi/interface/OmtfRpcUnpacker.h"

#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESTransientHandle.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "EventFilter/RPCRawToDigi/interface/RPCRecordFormatter.h"
Expand All @@ -18,30 +16,28 @@

namespace omtf {

void RpcUnpacker::initCabling(const edm::EventSetup &es) {
edm::ESTransientHandle<RPCEMap> readoutMapping;
es.get<RPCEMapRcd>().get(readoutMapping);
thePactCabling.reset(readoutMapping->convert());
void RpcUnpacker::initCabling(const RPCEMap& readoutMapping) {
thePactCabling.reset(readoutMapping.convert());

LogDebug("OmtfUnpacker") << " Has PACT readout map, VERSION: " << thePactCabling->version() << std::endl;
}

void RpcUnpacker::init(const edm::EventSetup &es) {
initCabling(es);
void RpcUnpacker::init(const RPCEMap& readoutMapping, const RPCAMCLinkMap& linkMap) {
initCabling(readoutMapping);
RpcLinkMap omtfLink2Ele;
omtfLink2Ele.init(es);
omtfLink2Ele.init(linkMap);
theOmtf2Pact = translateOmtf2Pact(omtfLink2Ele, thePactCabling.get());
}

void RpcUnpacker::init(const edm::EventSetup &es, const std::string &connectionFile) {
initCabling(es);
void RpcUnpacker::init(const RPCEMap& readoutMapping, const std::string& connectionFile) {
initCabling(readoutMapping);
RpcLinkMap omtfLink2Ele;
omtfLink2Ele.init(connectionFile);
theOmtf2Pact = translateOmtf2Pact(omtfLink2Ele, thePactCabling.get());
}

void RpcUnpacker::unpack(
int triggerBX, unsigned int fed, unsigned int amc, const RpcDataWord64 &data, RPCDigiCollection *prod) {
int triggerBX, unsigned int fed, unsigned int amc, const RpcDataWord64& data, RPCDigiCollection* prod) {
LogTrace("RpcUnpacker:") << data;

// EleIndex omtfEle(fedHeader.sourceID(), bh.getAMCNumber()/2+1, data.linkNum());
Expand Down

0 comments on commit 2c685bd

Please sign in to comment.