CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SonicAcquirer.h
Go to the documentation of this file.
1 #ifndef HeterogeneousCore_SonicCore_SonicAcquirer
2 #define HeterogeneousCore_SonicCore_SonicAcquirer
3 
9 
10 #include <chrono>
11 #include <memory>
12 #include <string>
13 
14 template <typename Client, typename Module>
15 class SonicAcquirer : public Module {
16 public:
17  //typedef to simplify usage
18  typedef typename Client::Input Input;
19  //constructor
20  SonicAcquirer(edm::ParameterSet const& cfg, const std::string& debugName = "", bool verbose = true)
21  : clientPset_(cfg.getParameterSet("Client")), debugName_(debugName), verbose_(verbose) {}
22  //destructor
23  ~SonicAcquirer() override = default;
24 
25  //construct client at beginning of job
26  //in case client constructor depends on operations happening in derived module constructors
27  void beginStream(edm::StreamID) override { makeClient(); }
28 
29  //derived classes use a dedicated acquire() interface that incorporates client_->input()
30  //(no need to interact with callback holder)
31  void acquire(edm::Event const& iEvent, edm::EventSetup const& iSetup, edm::WaitingTaskWithArenaHolder holder) final {
33  acquire(iEvent, iSetup, client_->input());
34  if (verbose_)
35  sonic_utils::printDebugTime(debugName_, "acquire() time: ", t0);
37  client_->dispatch(holder);
38  }
39  virtual void acquire(edm::Event const& iEvent, edm::EventSetup const& iSetup, Input& iInput) = 0;
40 
41 protected:
42  //helper
43  void makeClient() { client_ = std::make_unique<Client>(clientPset_, debugName_); }
44 
45  //members
47  std::unique_ptr<Client> client_;
49  bool verbose_;
50  std::chrono::time_point<std::chrono::high_resolution_clock> t_dispatch_;
51 };
52 
53 #endif
std::chrono::time_point< std::chrono::high_resolution_clock > t_dispatch_
Definition: SonicAcquirer.h:50
tuple cfg
Definition: looper.py:296
ParameterSet const & getParameterSet(ParameterSetID const &id)
~SonicAcquirer() override=default
SonicAcquirer(edm::ParameterSet const &cfg, const std::string &debugName="", bool verbose=true)
Definition: SonicAcquirer.h:20
int iEvent
Definition: GenABIO.cc:224
static constexpr int verbose
void makeClient()
Definition: SonicAcquirer.h:43
Client::Input Input
Definition: SonicAcquirer.h:18
void beginStream(edm::StreamID) override
Definition: SonicAcquirer.h:27
std::string debugName_
Definition: SonicAcquirer.h:48
edm::ParameterSet clientPset_
Definition: SonicAcquirer.h:46
void acquire(edm::Event const &iEvent, edm::EventSetup const &iSetup, edm::WaitingTaskWithArenaHolder holder) final
Definition: SonicAcquirer.h:31
void printDebugTime(std::string_view debugName, std::string_view msg, const TimePoint &t0)
Definition: sonic_utils.cc:8
std::unique_ptr< Client > client_
Definition: SonicAcquirer.h:47