Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "CondTools/RPC/plugins/RPCInverseLBLinkMapESProducer.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/RPCLBLinkMap.h"
0011 #include "CondFormats/DataRecord/interface/RPCLBLinkMapRcd.h"
0012 #include "CondFormats/DataRecord/interface/RPCInverseLBLinkMapRcd.h"
0013 
0014 #include "DataFormats/MuonDetId/interface/RPCDetId.h"
0015 
0016 RPCInverseLBLinkMapESProducer::RPCInverseLBLinkMapESProducer(edm::ParameterSet const& _config) {
0017   auto cc = setWhatProduced(this);
0018 
0019   es_rpc_lb_map_token_ = cc.consumesFrom<RPCLBLinkMap, RPCLBLinkMapRcd>();
0020 }
0021 
0022 void RPCInverseLBLinkMapESProducer::fillDescriptions(edm::ConfigurationDescriptions& _descs) {
0023   edm::ParameterSetDescription _desc;
0024   _descs.add("RPCInverseLBLinkMapESProducer", _desc);
0025 }
0026 
0027 void RPCInverseLBLinkMapESProducer::setupRPCLBLinkMap(RPCLBLinkMapRcd const& _rcd,
0028                                                       RPCInverseLBLinkMap* inverse_linkmap) {
0029   RPCInverseLBLinkMap::map_type& _inverse_map(inverse_linkmap->getMap());
0030   _inverse_map.clear();
0031 
0032   RPCLBLinkMap const& _map = _rcd.get(es_rpc_lb_map_token_);
0033 
0034   for (auto const& _link : _map.getMap()) {
0035     _inverse_map.insert(RPCInverseLBLinkMap::map_type::value_type(_link.second.getRPCDetId().rawId(), _link));
0036   }
0037 }
0038 
0039 std::shared_ptr<RPCInverseLBLinkMap> RPCInverseLBLinkMapESProducer::produce(RPCInverseLBLinkMapRcd const& _rcd) {
0040   auto host = holder_.makeOrGet([]() { return new HostType; });
0041 
0042   host->ifRecordChanges<RPCLBLinkMapRcd>(_rcd, [this, h = host.get()](auto const& rec) { setupRPCLBLinkMap(rec, h); });
0043 
0044   return host;
0045 }
0046 
0047 //define this as a module
0048 #include "FWCore/Framework/interface/ModuleFactory.h"
0049 DEFINE_FWK_EVENTSETUP_MODULE(RPCInverseLBLinkMapESProducer);