VLNEnergyAnalyzer_module.cc
Go to the documentation of this file.
4 
9 
10 namespace VLN {
11 
13 {
14 public:
15  explicit VLNEnergyAnalyzer(const fhicl::ParameterSet &pset);
16 
17  void analyze(const art::Event &evt) override;
18  void respondToOpenInputFile(const art::FileBlock &fb) override;
19 
20 private:
22  int precision;
23 
26 
28  std::unique_ptr<CSVExporter> exporter;
29 };
30 
32  : EDAnalyzer(pset),
33  precision(pset.get<int>("OutputPrecision")),
34  inputVarExtractor("", pset.get<fhicl::ParameterSet>("ConfigInputVars")),
35  model(pset.get<std::string>("ModelPath"))
36 {
37  format = parseFormat(pset.get<std::string>("OutputFormat"));
38 }
39 
41 {
42  const std::string filename = convertFilename(fb.fileName(), "./", format);
43 
44  switch (format) {
45  case Format::CSV:
46  exporter = std::make_unique<CSVExporter>(filename);
47  exporter->setPrecision(precision);
48  break;
49  }
50 }
51 
53 {
55 
56  const VLNEnergy energy = model.predict(vars);
57 
58  vars.scalar["vln.energy.totalE"] = energy.totalE;
59  vars.scalar["vln.energy.primaryE"] = energy.primaryE;
60  vars.scalar["vln.energy.secondaryE"] = energy.totalE - energy.primaryE;
61 
62  exporter->exportVars(vars);
63 }
64 
66 
67 }
68 
Format
Definition: utils.h:7
Format parseFormat(const std::string &formatStr)
Definition: utils.cxx:24
std::string string
Definition: nybbler.cc:12
void analyze(const art::Event &evt) override
STL namespace.
Definition: model.py:1
VLNEnergyAnalyzer(const fhicl::ParameterSet &pset)
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
string filename
Definition: train.py:213
Definition: VarDict.h:8
virtual void extract(const art::Event &evt, VarDict &vars)
DefaultInputVarExtractor inputVarExtractor
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
std::string convertFilename(const std::string &path, const std::string &root, Format format)
Definition: utils.cxx:35
std::unique_ptr< CSVExporter > exporter
T get(std::string const &key) const
Definition: ParameterSet.h:271
std::string const & fileName() const
Definition: FileBlock.cc:29
Definition: utils.cxx:6
float totalE
Definition: VLNEnergy.h:8
void respondToOpenInputFile(const art::FileBlock &fb) override
float primaryE
Definition: VLNEnergy.h:7
TCEvent evt
Definition: DataStructs.cxx:7
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
std::unordered_map< std::string, double > scalar
Definition: VarDict.h:10