Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:28:27

0001 // -*- C++ -*-
0002 //
0003 // Package:    FWCore/Integration
0004 // Class:      ConcurrentIOVESProducer
0005 //
0006 /**\class edmtest::ConcurrentIOVESProducer
0007 
0008   Description: Used in tests of the concurrent IOV feature of the
0009   EventSetup system.
0010 */
0011 // Original Author:  W. David Dagenhart
0012 //         Created:  22 March 2019
0013 
0014 #include "FWCore/Framework/interface/ESHandle.h"
0015 #include "FWCore/Framework/interface/ESProducer.h"
0016 #include "FWCore/Framework/interface/ModuleFactory.h"
0017 #include "FWCore/Integration/interface/ESTestRecords.h"
0018 #include "FWCore/Integration/test/IOVTestInfo.h"
0019 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0020 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0021 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0022 #include "FWCore/Utilities/interface/ESGetToken.h"
0023 #include "FWCore/Utilities/interface/ESInputTag.h"
0024 #include "FWCore/Utilities/interface/Exception.h"
0025 
0026 #include <memory>
0027 
0028 namespace edmtest {
0029 
0030   class ConcurrentIOVESProducer : public edm::ESProducer {
0031   public:
0032     ConcurrentIOVESProducer(edm::ParameterSet const&);
0033 
0034     std::unique_ptr<IOVTestInfo> produce(ESTestRecordI const&);
0035 
0036     static void fillDescriptions(edm::ConfigurationDescriptions&);
0037 
0038   private:
0039     edm::ESGetToken<IOVTestInfo, ESTestRecordI> token_;
0040   };
0041 
0042   ConcurrentIOVESProducer::ConcurrentIOVESProducer(edm::ParameterSet const&) {
0043     //auto collector = setWhatProduced(this);
0044     auto collector = setWhatProduced(this, "fromESProducer");
0045     token_ = collector.consumes<IOVTestInfo>(edm::ESInputTag{"", ""});
0046   }
0047 
0048   std::unique_ptr<IOVTestInfo> ConcurrentIOVESProducer::produce(ESTestRecordI const& record) {
0049     edm::ESHandle<IOVTestInfo> iovTestInfo = record.getHandle(token_);
0050 
0051     edm::ValidityInterval iov = record.validityInterval();
0052     if (iovTestInfo->iovStartLumi_ != iov.first().luminosityBlockNumber() ||
0053         iovTestInfo->iovEndLumi_ != iov.last().luminosityBlockNumber() || iovTestInfo->iovIndex_ != record.iovIndex() ||
0054         iovTestInfo->cacheIdentifier_ != record.cacheIdentifier()) {
0055       throw cms::Exception("TestFailure") << "ConcurrentIOVESProducer::ConcurrentIOVESProducer"
0056                                           << "read values do not agree with record";
0057     }
0058 
0059     auto data = std::make_unique<IOVTestInfo>();
0060     *data = *iovTestInfo;
0061     return data;
0062   }
0063 
0064   void ConcurrentIOVESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0065     edm::ParameterSetDescription desc;
0066     descriptions.add("concurrentIOVESProducer", desc);
0067   }
0068 }  // namespace edmtest
0069 using namespace edmtest;
0070 DEFINE_FWK_EVENTSETUP_MODULE(ConcurrentIOVESProducer);