Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:15

0001 #include "CondTools/RPC/plugins/RPCInverseCPPFLinkMapESProducer.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/RPCCPPFLinkMapRcd.h"
0012 #include "CondFormats/DataRecord/interface/RPCInverseCPPFLinkMapRcd.h"
0013 
0014 RPCInverseCPPFLinkMapESProducer::RPCInverseCPPFLinkMapESProducer(edm::ParameterSet const& _config) {
0015   auto cc = setWhatProduced(this);
0016   es_rpc_cppf_l_map_token_ = cc.consumesFrom<RPCAMCLinkMap, RPCCPPFLinkMapRcd>();
0017 }
0018 
0019 void RPCInverseCPPFLinkMapESProducer::fillDescriptions(edm::ConfigurationDescriptions& _descs) {
0020   edm::ParameterSetDescription _desc;
0021   _descs.add("RPCInverseCPPFLinkMapESProducer", _desc);
0022 }
0023 
0024 void RPCInverseCPPFLinkMapESProducer::setupRPCCPPFLinkMap(RPCCPPFLinkMapRcd 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_cppf_l_map_token_);
0030 
0031   for (auto const& _link : _map.getMap()) {
0032     _inverse_map.insert(RPCInverseAMCLinkMap::map_type::value_type(_link.second, _link.first));
0033   }
0034 }
0035 
0036 std::shared_ptr<RPCInverseAMCLinkMap> RPCInverseCPPFLinkMapESProducer::produce(RPCInverseCPPFLinkMapRcd const& _rcd) {
0037   auto host = holder_.makeOrGet([]() { return new HostType; });
0038 
0039   host->ifRecordChanges<RPCCPPFLinkMapRcd>(_rcd,
0040                                            [this, h = host.get()](auto const& rec) { setupRPCCPPFLinkMap(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(RPCInverseCPPFLinkMapESProducer);