Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:12:35

0001 // -*- C++ -*-
0002 //
0003 // Package:     FWCore/Integration
0004 // Class  :     RunLumiESSource
0005 //
0006 // Implementation:
0007 //     ESSource used for tests of Framework support for
0008 //     the EventSetup system in run and lumi transitions
0009 //
0010 // Original Author:  W. David Dagenhart
0011 //         Created:  18 April 2019
0012 
0013 #include "DataFormats/Provenance/interface/EventID.h"
0014 #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
0015 #include "FWCore/Framework/interface/ESProducer.h"
0016 #include "FWCore/Framework/interface/IOVSyncValue.h"
0017 #include "FWCore/Framework/interface/SourceFactory.h"
0018 #include "FWCore/Framework/interface/ValidityInterval.h"
0019 #include "FWCore/Integration/interface/ESTestRecords.h"
0020 #include "FWCore/Integration/interface/IOVTestInfo.h"
0021 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0022 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0023 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0024 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0025 
0026 #include <memory>
0027 
0028 namespace edmtest {
0029 
0030   class RunLumiESSource : public edm::EventSetupRecordIntervalFinder, public edm::ESProducer {
0031   public:
0032     RunLumiESSource(edm::ParameterSet const&);
0033 
0034     std::unique_ptr<IOVTestInfo> produce(ESTestRecordC const&);
0035 
0036     static void fillDescriptions(edm::ConfigurationDescriptions&);
0037 
0038   private:
0039     void setIntervalFor(edm::eventsetup::EventSetupRecordKey const&,
0040                         edm::IOVSyncValue const&,
0041                         edm::ValidityInterval&) override;
0042 
0043     bool isConcurrentFinder() const override { return true; }
0044   };
0045 
0046   RunLumiESSource::RunLumiESSource(edm::ParameterSet const&) {
0047     findingRecord<ESTestRecordC>();
0048     setWhatProduced(this);
0049   }
0050 
0051   std::unique_ptr<IOVTestInfo> RunLumiESSource::produce(ESTestRecordC const& record) {
0052     auto data = std::make_unique<IOVTestInfo>();
0053 
0054     edm::ValidityInterval iov = record.validityInterval();
0055     edm::LogAbsolute("RunLumiESSource") << "RunLumiESSource::produce startIOV = " << iov.first().eventID().run() << ":"
0056                                         << iov.first().luminosityBlockNumber()
0057                                         << " endIOV = " << iov.last().eventID().run() << ":"
0058                                         << iov.last().luminosityBlockNumber() << " IOV index = " << record.iovIndex()
0059                                         << " cache identifier = " << record.cacheIdentifier();
0060     data->iovStartRun_ = iov.first().eventID().run();
0061     data->iovStartLumi_ = iov.first().luminosityBlockNumber();
0062     data->iovEndRun_ = iov.last().eventID().run();
0063     data->iovEndLumi_ = iov.last().luminosityBlockNumber();
0064     data->iovIndex_ = record.iovIndex();
0065     data->cacheIdentifier_ = record.cacheIdentifier();
0066     return data;
0067   }
0068 
0069   void RunLumiESSource::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0070     edm::ParameterSetDescription desc;
0071     descriptions.addDefault(desc);
0072   }
0073 
0074   void RunLumiESSource::setIntervalFor(edm::eventsetup::EventSetupRecordKey const&,
0075                                        edm::IOVSyncValue const& syncValue,
0076                                        edm::ValidityInterval& interval) {
0077     interval = edm::ValidityInterval(syncValue, syncValue);
0078   }
0079 }  // namespace edmtest
0080 using namespace edmtest;
0081 DEFINE_FWK_EVENTSETUP_SOURCE(RunLumiESSource);