Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-06-02 02:22:44

0001 #include "CondTools/RPC/plugins/RPCInverseTwinMuxLinkMapESProducer.h"
0002 
0003 #include "FWCore/Framework/interface/Event.h"
0004 #include "FWCore/Framework/interface/EventSetup.h"
0005 #include "FWCore/Framework/interface/ESHandle.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0008 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0009 
0010 #include "CondFormats/RPCObjects/interface/RPCAMCLinkMap.h"
0011 #include "CondFormats/DataRecord/interface/RPCTwinMuxLinkMapRcd.h"
0012 #include "CondFormats/DataRecord/interface/RPCInverseTwinMuxLinkMapRcd.h"
0013 
0014 RPCInverseTwinMuxLinkMapESProducer::RPCInverseTwinMuxLinkMapESProducer(edm::ParameterSet const& _config) {
0015   auto cc = setWhatProduced(this);
0016   es_rpc_tm_l_map_token_ = cc.consumesFrom<RPCAMCLinkMap, RPCTwinMuxLinkMapRcd>();
0017 }
0018 
0019 void RPCInverseTwinMuxLinkMapESProducer::fillDescriptions(edm::ConfigurationDescriptions& _descs) {
0020   edm::ParameterSetDescription _desc;
0021   _descs.add("RPCInverseTwinMuxLinkMapESProducer", _desc);
0022 }
0023 
0024 void RPCInverseTwinMuxLinkMapESProducer::setupRPCTwinMuxLinkMap(RPCTwinMuxLinkMapRcd const& _rcd,
0025                                                                 RPCInverseAMCLinkMap* inverse_linkmap) {
0026   RPCInverseAMCLinkMap::map_type& _inverse_map(inverse_linkmap->getMap());
0027   _inverse_map.clear();
0028 
0029   RPCAMCLinkMap const& _map = _rcd.get(es_rpc_tm_l_map_token_);
0030   for (auto const& _link : _map.getMap()) {
0031     _inverse_map.insert(RPCInverseAMCLinkMap::map_type::value_type(_link.second, _link.first));
0032   }
0033 }
0034 
0035 std::shared_ptr<RPCInverseAMCLinkMap> RPCInverseTwinMuxLinkMapESProducer::produce(
0036     RPCInverseTwinMuxLinkMapRcd const& _rcd) {
0037   auto host = holder_.makeOrGet([]() { return new HostType; });
0038 
0039   host->ifRecordChanges<RPCTwinMuxLinkMapRcd>(
0040       _rcd, [this, h = host.get()](auto const& rec) { setupRPCTwinMuxLinkMap(rec, h); });
0041 
0042   return host;
0043 }
0044 
0045 //define this as a module
0046 #include "FWCore/Framework/interface/ModuleFactory.h"
0047 DEFINE_FWK_EVENTSETUP_MODULE(RPCInverseTwinMuxLinkMapESProducer);