File indexing completed on 2024-04-06 12:15:47
0001 #ifndef HeterogeneousCore_SonicCore_SonicEDProducer
0002 #define HeterogeneousCore_SonicCore_SonicEDProducer
0003
0004 #include "FWCore/Framework/interface/stream/EDProducer.h"
0005 #include "HeterogeneousCore/SonicCore/interface/sonic_utils.h"
0006 #include "HeterogeneousCore/SonicCore/interface/SonicAcquirer.h"
0007
0008 #include <string>
0009 #include <chrono>
0010
0011
0012
0013 template <typename Client, typename... Capabilities>
0014 class SonicEDProducer : public SonicAcquirer<Client, edm::stream::EDProducer<edm::ExternalWork, Capabilities...>> {
0015 public:
0016
0017 typedef typename Client::Output Output;
0018
0019 SonicEDProducer(edm::ParameterSet const& cfg)
0020 : SonicAcquirer<Client, edm::stream::EDProducer<edm::ExternalWork, Capabilities...>>(cfg) {}
0021
0022 ~SonicEDProducer() override = default;
0023
0024
0025 void produce(edm::Event& iEvent, edm::EventSetup const& iSetup) final {
0026
0027 if (this->verbose_)
0028 sonic_utils::printDebugTime(this->debugName_, "dispatch() time: ", this->t_dispatch_);
0029
0030 auto t0 = std::chrono::high_resolution_clock::now();
0031 produce(iEvent, iSetup, this->client_->output());
0032 if (this->verbose_)
0033 sonic_utils::printDebugTime(this->debugName_, "produce() time: ", t0);
0034
0035
0036 this->client_->reset();
0037 }
0038 virtual void produce(edm::Event& iEvent, edm::EventSetup const& iSetup, Output const& iOutput) = 0;
0039 };
0040
0041 #endif