HeterogeneousCore
SonicCore
interface
SonicOneEDAnalyzer.h
Go to the documentation of this file.
1
#ifndef HeterogeneousCore_SonicCore_SonicOneEDAnalyzer
2
#define HeterogeneousCore_SonicCore_SonicOneEDAnalyzer
3
4
#include "
FWCore/Framework/interface/Event.h
"
5
#include "
FWCore/Framework/interface/one/EDAnalyzer.h
"
6
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
7
#include "
FWCore/Framework/interface/EventSetup.h
"
8
#include "
FWCore/Concurrency/interface/WaitingTaskWithArenaHolder.h
"
9
#include "
FWCore/MessageLogger/interface/MessageLogger.h
"
10
#include "
HeterogeneousCore/SonicCore/interface/SonicClientBase.h
"
11
#include "
HeterogeneousCore/SonicCore/interface/sonic_utils.h
"
12
13
#include <string>
14
#include <chrono>
15
16
//this is a one analyzer to enable writing trees/histograms for analysis users with results from inference as a service
17
template
<
typename
Client,
typename
... Capabilities>
18
class
SonicOneEDAnalyzer
:
public
edm::one::EDAnalyzer
<Capabilities...> {
19
public
:
20
//typedefs to simplify usage
21
typedef
typename
Client::Input
Input
;
22
typedef
typename
Client::Output
Output
;
23
//constructor
24
SonicOneEDAnalyzer
(
edm::ParameterSet
const
&
cfg
) :
client_
(
cfg
.getParameter<
edm
::
ParameterSet
>(
"Client"
)) {
25
//ExternalWork is not compatible with one modules, so Sync mode is enforced
26
if
(
client_
.mode() !=
SonicMode::Sync
)
27
throw
cms::Exception
(
"UnsupportedMode"
) <<
"SonicOneEDAnalyzer can only use Sync mode for clients"
;
28
}
29
//destructor
30
~SonicOneEDAnalyzer
()
override
=
default
;
31
32
//derived classes still use a dedicated acquire() interface that incorporates client_.input() for consistency
33
virtual
void
acquire
(
edm::Event
const
&
iEvent
,
edm::EventSetup
const
& iSetup,
Input
& iInput) = 0;
34
//derived classes use a dedicated analyze() interface that incorporates client_.output()
35
void
analyze
(
edm::Event
const
&
iEvent
,
edm::EventSetup
const
& iSetup)
final
{
36
auto
t0
=
std::chrono::high_resolution_clock::now
();
37
acquire
(
iEvent
, iSetup,
client_
.input());
38
sonic_utils::printDebugTime
(
client_
.debugName(),
"acquire() time: "
,
t0
);
39
40
//pattern similar to ExternalWork, but blocking
41
auto
t1
=
std::chrono::high_resolution_clock::now
();
42
client_
.dispatch();
43
44
//measure time between acquire and produce
45
sonic_utils::printDebugTime
(
client_
.debugName(),
"dispatch() time: "
,
t1
);
46
47
auto
t2
=
std::chrono::high_resolution_clock::now
();
48
analyze
(
iEvent
, iSetup,
client_
.output());
49
sonic_utils::printDebugTime
(
client_
.debugName(),
"analyze() time: "
,
t2
);
50
51
//reset client data
52
client_
.reset();
53
}
54
virtual
void
analyze
(
edm::Event
const
&
iEvent
,
edm::EventSetup
const
& iSetup,
Output
const
& iOutput) = 0;
55
56
protected
:
57
//for debugging
58
void
setDebugName
(
const
std::string
& debugName) {
client_
.setDebugName(debugName); }
59
//members
60
Client
client_
;
61
};
62
63
#endif
SonicOneEDAnalyzer::client_
Client client_
Definition:
SonicOneEDAnalyzer.h:60
RandomServiceHelper.t2
t2
Definition:
RandomServiceHelper.py:257
EDAnalyzer.h
MessageLogger.h
sonic_utils.h
submitPVValidationJobs.now
now
Definition:
submitPVValidationJobs.py:639
edm
HLT enums.
Definition:
AlignableModifier.h:19
sonic_utils::printDebugTime
void printDebugTime(std::string_view debugName, std::string_view msg, const TimePoint &t0)
Definition:
sonic_utils.cc:8
edm::one::EDAnalyzer
Definition:
EDAnalyzer.h:30
SonicOneEDAnalyzer::setDebugName
void setDebugName(const std::string &debugName)
Definition:
SonicOneEDAnalyzer.h:58
GetRecoTauVFromDQM_MC_cff.Output
Output
Definition:
GetRecoTauVFromDQM_MC_cff.py:12
RandomServiceHelper.t1
t1
Definition:
RandomServiceHelper.py:256
FrontierCondition_GT_autoExpress_cfi.t0
t0
Definition:
FrontierCondition_GT_autoExpress_cfi.py:148
SonicOneEDAnalyzer::Input
Client::Input Input
Definition:
SonicOneEDAnalyzer.h:21
SonicOneEDAnalyzer
Definition:
SonicOneEDAnalyzer.h:18
SonicOneEDAnalyzer::analyze
void analyze(edm::Event const &iEvent, edm::EventSetup const &iSetup) final
Definition:
SonicOneEDAnalyzer.h:35
SonicOneEDAnalyzer::Output
Client::Output Output
Definition:
SonicOneEDAnalyzer.h:22
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
SonicMode::Sync
edm::ParameterSet
Definition:
ParameterSet.h:47
Event.h
ParameterSet
Definition:
Functions.h:16
WaitingTaskWithArenaHolder.h
iEvent
int iEvent
Definition:
GenABIO.cc:224
SonicClientBase.h
edm::EventSetup
Definition:
EventSetup.h:57
looper.cfg
cfg
Definition:
looper.py:297
TrackCandidateTopBottomHitFilter_cfi.Input
Input
Definition:
TrackCandidateTopBottomHitFilter_cfi.py:4
EventSetup.h
cms::Exception
Definition:
Exception.h:70
ParameterSet.h
edm::Event
Definition:
Event.h:73
SonicOneEDAnalyzer::acquire
virtual void acquire(edm::Event const &iEvent, edm::EventSetup const &iSetup, Input &iInput)=0
SonicOneEDAnalyzer::SonicOneEDAnalyzer
SonicOneEDAnalyzer(edm::ParameterSet const &cfg)
Definition:
SonicOneEDAnalyzer.h:24
SonicOneEDAnalyzer::~SonicOneEDAnalyzer
~SonicOneEDAnalyzer() override=default
Generated for CMSSW Reference Manual by
1.8.16