LegacyGeometryInfoWriter_module.cc
Go to the documentation of this file.
1 /**
2  * @file LegacyGeometryInfoWriter_module.cc
3  * @brief Writes a sumdata::RunData record into the run(s).
4  * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
5  * @date November 12, 2020
6  */
7 
8 // LArSoft libraries
10 
11 // framework libraries
15 #include "fhiclcpp/types/Atom.h"
16 
17 // C/C++ standard library
18 #include <string>
19 #include <algorithm> // std::transform()
20 #include <iterator> // std::back_inserter()
21 #include <memory> // std::make_unique()
22 
23 // -----------------------------------------------------------------------------
24 namespace art { class Event; }
25 
26 // -----------------------------------------------------------------------------
27 /**
28  * @brief Writes a sumdata::RunData record into the run(s).
29  *
30  * A copy of the same data product is put into each of the runs on opening.
31  *
32  *
33  * Configuration parameters
34  * =========================
35  *
36  * * `Name` (string, mandatory): name of the detector to be stored in the
37  * `sumdata::RunData` data product
38  *
39  */
40 namespace geo { class LegacyGeometryInfoWriter; }
42  public:
43 
44  struct Config {
45 
47  fhicl::Name{ "Name" },
48  fhicl::Comment{ "Name of the detector to be stored in the data" }
49  };
50 
51  }; // struct Config
52 
54 
56 
57  virtual void beginRun(art::Run& run) override;
58 
59  virtual void produce(art::Event&) override {}
60 
61  private:
62 
63  std::string fDetectorName; ///< Name of the detector.
64 
65 }; // class geo::LegacyGeometryInfoWriter
66 
67 
68 // -----------------------------------------------------------------------------
69 // --- geo::LegacyGeometryInfoWriter implementation
70 // -----------------------------------------------------------------------------
71 
72 namespace {
73 
74  std::string toLower(std::string const& S) {
75 
76  std::string s;
77  s.reserve(S.length());
78  std::transform(S.begin(), S.end(), back_inserter(s), ::tolower);
79  return s;
80 
81  } // toLower()
82 
83 } // local namespace
84 
85 // -----------------------------------------------------------------------------
87  (Parameters const& config)
88  : art::EDProducer(config)
89  , fDetectorName(::toLower(config().Name()))
90 {
91 
92  produces<sumdata::RunData, art::InRun>();
93 
94 } // geo::LegacyGeometryInfoWriter::LegacyGeometryInfoWriter()
95 
96 
97 // -----------------------------------------------------------------------------
99 
100  run.put(std::make_unique<sumdata::RunData>(fDetectorName), art::fullRun());
101 
102 } // geo::LegacyGeometryInfoWriter::beginRun()
103 
104 
105 // -----------------------------------------------------------------------------
107 
108 
109 // -----------------------------------------------------------------------------
std::string fDetectorName
Name of the detector.
constexpr auto fullRun()
virtual void beginRun(art::Run &run) override
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
Definition: 044_section.h:5
Definition: Run.h:17
LegacyGeometryInfoWriter(Parameters const &config)
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
static Config * config
Definition: config.cpp:1054
virtual void produce(art::Event &) override
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
Definition: types.h:32
LArSoft geometry interface.
Definition: ChannelGeo.h:16
static QCString * s
Definition: config.cpp:1042