CMS 3D CMS Logo

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
edm::StreamID
Definition: StreamID.h:30
SonicAcquirer
Definition: SonicAcquirer.h:15
sonic_utils.h
submitPVValidationJobs.now
now
Definition: submitPVValidationJobs.py:639
SonicAcquirer::t_dispatch_
std::chrono::time_point< std::chrono::high_resolution_clock > t_dispatch_
Definition: SonicAcquirer.h:50
sonic_utils::printDebugTime
void printDebugTime(std::string_view debugName, std::string_view msg, const TimePoint &t0)
Definition: sonic_utils.cc:8
SonicAcquirer::verbose_
bool verbose_
Definition: SonicAcquirer.h:49
SonicAcquirer::clientPset_
edm::ParameterSet clientPset_
Definition: SonicAcquirer.h:46
edm::WaitingTaskWithArenaHolder
Definition: WaitingTaskWithArenaHolder.h:34
FrontierCondition_GT_autoExpress_cfi.t0
t0
Definition: FrontierCondition_GT_autoExpress_cfi.py:149
verbose
static constexpr int verbose
Definition: HLTExoticaSubAnalysis.cc:25
SonicAcquirer::Input
Client::Input Input
Definition: SonicAcquirer.h:18
SonicAcquirer::acquire
void acquire(edm::Event const &iEvent, edm::EventSetup const &iSetup, edm::WaitingTaskWithArenaHolder holder) final
Definition: SonicAcquirer.h:31
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
WaitingTaskWithArenaHolder.h
iEvent
int iEvent
Definition: GenABIO.cc:224
SonicAcquirer::client_
std::unique_ptr< Client > client_
Definition: SonicAcquirer.h:47
SonicAcquirer::~SonicAcquirer
~SonicAcquirer() override=default
edm::EventSetup
Definition: EventSetup.h:58
SonicAcquirer::makeClient
void makeClient()
Definition: SonicAcquirer.h:43
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
looper.cfg
cfg
Definition: looper.py:296
edm::getParameterSet
ParameterSet const & getParameterSet(ParameterSetID const &id)
Definition: ParameterSet.cc:862
TrackCandidateTopBottomHitFilter_cfi.Input
Input
Definition: TrackCandidateTopBottomHitFilter_cfi.py:4
EventSetup.h
SonicAcquirer::SonicAcquirer
SonicAcquirer(edm::ParameterSet const &cfg, const std::string &debugName="", bool verbose=true)
Definition: SonicAcquirer.h:20
ParameterSet.h
edm::Event
Definition: Event.h:73
SonicAcquirer::debugName_
std::string debugName_
Definition: SonicAcquirer.h:48
SonicAcquirer::beginStream
void beginStream(edm::StreamID) override
Definition: SonicAcquirer.h:27