Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:32:21

0001 // -*- C++ -*-
0002 //
0003 // Package:     Integration
0004 // Class  :     IntProductESSource
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author:  Chris Jones
0010 //         Created:  Fri Jun 24 14:39:39 EDT 2005
0011 //
0012 
0013 // system include files
0014 
0015 // user include files
0016 #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
0017 #include "FWCore/Framework/interface/ESProducer.h"
0018 #include "FWCore/Framework/interface/SourceFactory.h"
0019 
0020 #include "PhysicsTools/CondLiteIO/test/IntProductRecord.h"
0021 #include "DataFormats/TestObjects/interface/ToyProducts.h"
0022 
0023 namespace edmtest {
0024   class IntProductESSource : public edm::EventSetupRecordIntervalFinder, public edm::ESProducer {
0025   public:
0026     IntProductESSource(const edm::ParameterSet&);
0027 
0028     std::unique_ptr<edmtest::IntProduct> produce(const IntProductRecord&);
0029 
0030   protected:
0031     virtual void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&,
0032                                 const edm::IOVSyncValue& iTime,
0033                                 edm::ValidityInterval& iInterval);
0034 
0035   private:
0036     IntProductESSource(const IntProductESSource&);  // stop default
0037 
0038     const IntProductESSource& operator=(const IntProductESSource&);  // stop default
0039 
0040     // ---------- member data --------------------------------
0041     unsigned int nCalls_;
0042   };
0043 
0044   //
0045   // constants, enums and typedefs
0046   //
0047 
0048   //
0049   // static data member definitions
0050   //
0051 
0052   //
0053   // constructors and destructor
0054   //
0055   IntProductESSource::IntProductESSource(const edm::ParameterSet&) : nCalls_(0) {
0056     this->findingRecord<IntProductRecord>();
0057     setWhatProduced(this);
0058   }
0059 
0060   //IntProductESSource::~IntProductESSource()
0061   //{
0062   //}
0063 
0064   //
0065   // member functions
0066   //
0067 
0068   std::unique_ptr<edmtest::IntProduct> IntProductESSource::produce(const IntProductRecord&) {
0069     auto data = std::make_unique<edmtest::IntProduct>();
0070     data->value = nCalls_;
0071     ++nCalls_;
0072     return data;
0073   }
0074 
0075   void IntProductESSource::setIntervalFor(const edm::eventsetup::EventSetupRecordKey&,
0076                                           const edm::IOVSyncValue& iTime,
0077                                           edm::ValidityInterval& iInterval) {
0078     //Be valid for 3 runs
0079     edm::EventID newTime = edm::EventID(1, 0, 0);
0080     edm::EventID endTime = edm::EventID(4, 0, 0);
0081     iInterval = edm::ValidityInterval(edm::IOVSyncValue(newTime), edm::IOVSyncValue(endTime));
0082   }
0083 
0084   //
0085   // const member functions
0086   //
0087 
0088   //
0089   // static member functions
0090   //
0091 }  // namespace edmtest
0092 using namespace edmtest;
0093 
0094 DEFINE_FWK_EVENTSETUP_SOURCE(IntProductESSource);