Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-26 10:51:09

0001 // -*- C++ -*-
0002 //
0003 // Package:    CondTools/SiPhase2Tracker
0004 // Class:      DTCCablingMapTestProducer
0005 //
0006 /**\class DTCCablingMapTestProducer DTCCablingMapTestProducer.cc CondTools/SiPhase2Tracker/plugins/DTCCablingMapTestProducer.cc
0007 
0008 Description: [one line class summary]
0009 
0010 Implementation:
0011         [Notes on implementation]
0012 */
0013 //
0014 // Original Author:  Luigi Calligaris, SPRACE, São Paulo, BR
0015 // Created        :  Wed, 27 Feb 2019 21:41:13 GMT
0016 //
0017 //
0018 
0019 #include <memory>
0020 
0021 #include <unordered_map>
0022 #include <utility>
0023 
0024 #include "FWCore/Framework/interface/Frameworkfwd.h"
0025 #include "FWCore/Framework/interface/Event.h"
0026 #include "FWCore/Framework/interface/MakerMacros.h"
0027 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0028 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0029 #include "FWCore/ServiceRegistry/interface/Service.h"
0030 
0031 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0032 
0033 #include "CondFormats/Common/interface/Time.h"
0034 #include "CondFormats/SiPhase2TrackerObjects/interface/TrackerDetToDTCELinkCablingMap.h"
0035 #include "CondFormats/SiPhase2TrackerObjects/interface/DTCELinkId.h"
0036 #include "CondFormats/DataRecord/interface/TrackerDetToDTCELinkCablingMapRcd.h"
0037 
0038 class DTCCablingMapTestProducer : public edm::one::EDAnalyzer<> {
0039 public:
0040   explicit DTCCablingMapTestProducer(const edm::ParameterSet&);
0041   ~DTCCablingMapTestProducer() override;
0042 
0043   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0044 
0045 private:
0046   void beginJob() override;
0047   void analyze(const edm::Event&, const edm::EventSetup&) override;
0048   void endJob() override;
0049 
0050 private:
0051   cond::Time_t iovBeginTime_;
0052   std::unique_ptr<TrackerDetToDTCELinkCablingMap> pCablingMap_;
0053   std::string recordName_;
0054 };
0055 
0056 void DTCCablingMapTestProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0057   edm::ParameterSetDescription desc;
0058   desc.setComment("Stores a dummy TrackerDetToDTCELinkCablingMap database object from a CSV file.");
0059   desc.add<long long unsigned int>("iovBeginTime", 1);
0060   desc.add<std::string>("record", "TrackerDetToDTCELinkCablingMap");
0061   descriptions.add("DTCCablingMapTestProducer", desc);
0062 }
0063 
0064 DTCCablingMapTestProducer::DTCCablingMapTestProducer(const edm::ParameterSet& iConfig)
0065     : iovBeginTime_(iConfig.getParameter<long long unsigned int>("iovBeginTime")),
0066       pCablingMap_(std::make_unique<TrackerDetToDTCELinkCablingMap>()),
0067       recordName_(iConfig.getParameter<std::string>("record")) {}
0068 
0069 void DTCCablingMapTestProducer::beginJob() {
0070   using namespace edm;
0071   using namespace std;
0072 
0073   pCablingMap_->insert(DTCELinkId(101u, 1u, 2u), 11111111);
0074   pCablingMap_->insert(DTCELinkId(102u, 2u, 2u), 22222222);
0075   pCablingMap_->insert(DTCELinkId(103u, 3u, 3u), 33333333);
0076   pCablingMap_->insert(DTCELinkId(104u, 4u, 4u), 44444444);
0077 
0078   edm::Service<cond::service::PoolDBOutputService> poolDbService;
0079 
0080   if (poolDbService.isAvailable())
0081     poolDbService->writeOneIOV(*pCablingMap_, iovBeginTime_, recordName_);
0082   else
0083     throw std::runtime_error("PoolDBService required.");
0084 }
0085 
0086 void DTCCablingMapTestProducer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {}
0087 
0088 void DTCCablingMapTestProducer::endJob() {}
0089 
0090 DTCCablingMapTestProducer::~DTCCablingMapTestProducer() {}
0091 
0092 //define this as a plug-in
0093 DEFINE_FWK_MODULE(DTCCablingMapTestProducer);