RecoTracker
FinalTrackSelectors
plugins
LwtnnESProducer.cc
Go to the documentation of this file.
1
#include "
FWCore/Framework/interface/ModuleFactory.h
"
2
#include "
FWCore/Framework/interface/ESProducer.h
"
3
#include "
FWCore/ParameterSet/interface/FileInPath.h
"
4
5
#include "
TrackingTools/Records/interface/TrackingComponentsRecord.h
"
6
7
//from lwtnn
8
#include "lwtnn/LightweightNeuralNetwork.hh"
9
#include "lwtnn/parse_json.hh"
10
#include <fstream>
11
12
class
LwtnnESProducer
:
public
edm::ESProducer
{
13
public
:
14
LwtnnESProducer
(
const
edm::ParameterSet
& iConfig);
15
~LwtnnESProducer
()
override
=
default
;
16
17
static
void
fillDescriptions
(
edm::ConfigurationDescriptions
& descriptions);
18
19
// TODO: Use of TrackingComponentsRecord is as inadequate as the
20
// placement of this ESProducer in RecoTracker/FinalTrackSelectors
21
// (but it works, I tried to create a new record but for some reason
22
// did not get it to work). Especially if this producer gets used
23
// wider we should figure out a better record and package.
24
std::unique_ptr<lwt::LightweightNeuralNetwork>
produce
(
const
TrackingComponentsRecord
& iRecord);
25
26
private
:
27
edm::FileInPath
fileName_
;
28
};
29
30
LwtnnESProducer::LwtnnESProducer
(
const
edm::ParameterSet
& iConfig)
31
: fileName_(iConfig.getParameter<
edm
::FileInPath>(
"fileName"
)) {
32
auto
componentName = iConfig.
getParameter
<
std::string
>(
"ComponentName"
);
33
setWhatProduced
(
this
, componentName);
34
}
35
36
void
LwtnnESProducer::fillDescriptions
(
edm::ConfigurationDescriptions
& descriptions) {
37
edm::ParameterSetDescription
desc
;
38
desc
.add<
std::string
>(
"ComponentName"
,
"lwtnnESProducer"
);
39
desc
.add<
edm::FileInPath
>(
"fileName"
,
edm::FileInPath
());
40
descriptions.
add
(
"lwtnnESProducer"
,
desc
);
41
}
42
43
std::unique_ptr<lwt::LightweightNeuralNetwork>
LwtnnESProducer::produce
(
const
TrackingComponentsRecord
& iRecord) {
44
std::ifstream
jsonfile
(
fileName_
.
fullPath
().c_str());
45
auto
config
= lwt::parse_json(
jsonfile
);
46
return
std::make_unique<lwt::LightweightNeuralNetwork>(
config
.inputs,
config
.layers,
config
.outputs);
47
}
48
49
#include "
FWCore/PluginManager/interface/ModuleDef.h
"
50
#include "
FWCore/Framework/interface/MakerMacros.h
"
51
DEFINE_FWK_EVENTSETUP_MODULE
(
LwtnnESProducer
);
edm
HLT enums.
Definition:
AlignableModifier.h:19
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition:
ESProducer.h:163
edm::ParameterSetDescription
Definition:
ParameterSetDescription.h:52
ESProducer.h
LwtnnESProducer
Definition:
LwtnnESProducer.cc:12
LwtnnESProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition:
LwtnnESProducer.cc:36
config
Definition:
config.py:1
edm::FileInPath
Definition:
FileInPath.h:61
MakerMacros.h
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition:
ConfigurationDescriptions.cc:57
gather_cfg.jsonfile
jsonfile
Definition:
gather_cfg.py:86
edm::ConfigurationDescriptions
Definition:
ConfigurationDescriptions.h:28
FileInPath.h
LwtnnESProducer::produce
std::unique_ptr< lwt::LightweightNeuralNetwork > produce(const TrackingComponentsRecord &iRecord)
Definition:
LwtnnESProducer.cc:43
edm::ParameterSet
Definition:
ParameterSet.h:47
ModuleDef.h
LwtnnESProducer::~LwtnnESProducer
~LwtnnESProducer() override=default
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
LwtnnESProducer::fileName_
edm::FileInPath fileName_
Definition:
LwtnnESProducer.cc:27
ModuleFactory.h
submitPVResolutionJobs.desc
string desc
Definition:
submitPVResolutionJobs.py:251
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition:
ModuleFactory.h:60
TrackingComponentsRecord.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition:
ParameterSet.h:303
LwtnnESProducer::LwtnnESProducer
LwtnnESProducer(const edm::ParameterSet &iConfig)
Definition:
LwtnnESProducer.cc:30
edm::ESProducer
Definition:
ESProducer.h:104
edm::FileInPath::fullPath
std::string fullPath() const
Definition:
FileInPath.cc:161
TrackingComponentsRecord
Definition:
TrackingComponentsRecord.h:12
Generated for CMSSW Reference Manual by
1.8.16