CMS 3D CMS Logo

LwtnnESProducer.cc
Go to the documentation of this file.
4 
6 
7 //from lwtnn
8 #include "lwtnn/LightweightNeuralNetwork.hh"
9 #include "lwtnn/parse_json.hh"
10 #include <fstream>
11 
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:
28 };
29 
31  : fileName_(iConfig.getParameter<edm::FileInPath>("fileName")) {
32  auto componentName = iConfig.getParameter<std::string>("ComponentName");
33  setWhatProduced(this, componentName);
34 }
35 
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 
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