Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "CondTools/RPC/plugins/RPCInverseOMTFLinkMapESProducer.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/RPCOMTFLinkMapRcd.h"
0012 #include "CondFormats/DataRecord/interface/RPCInverseOMTFLinkMapRcd.h"
0013 
0014 RPCInverseOMTFLinkMapESProducer::RPCInverseOMTFLinkMapESProducer(edm::ParameterSet const& _config) {
0015   auto cc = setWhatProduced(this);
0016   es_rpc_omt_l_map_token_ = cc.consumesFrom<RPCAMCLinkMap, RPCOMTFLinkMapRcd>();
0017 }
0018 
0019 void RPCInverseOMTFLinkMapESProducer::fillDescriptions(edm::ConfigurationDescriptions& _descs) {
0020   edm::ParameterSetDescription _desc;
0021   _descs.add("RPCInverseOMTFLinkMapESProducer", _desc);
0022 }
0023 
0024 void RPCInverseOMTFLinkMapESProducer::setupRPCOMTFLinkMap(RPCOMTFLinkMapRcd 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_omt_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> RPCInverseOMTFLinkMapESProducer::produce(RPCInverseOMTFLinkMapRcd const& _rcd) {
0037   auto host = holder_.makeOrGet([]() { return new HostType; });
0038 
0039   host->ifRecordChanges<RPCOMTFLinkMapRcd>(_rcd,
0040                                            [this, h = host.get()](auto const& rec) { setupRPCOMTFLinkMap(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(RPCInverseOMTFLinkMapESProducer);