All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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
12 #include "art/Framework/Core/ModuleMacros.h"
13 #include "art/Framework/Core/EDProducer.h"
14 #include "art/Framework/Principal/Run.h"
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; }
41 class geo::LegacyGeometryInfoWriter: public art::EDProducer {
42  public:
43 
44  struct Config {
45 
46  fhicl::Atom<std::string> Name {
47  fhicl::Name{ "Name" },
48  fhicl::Comment{ "Name of the detector to be stored in the data" }
49  };
50 
51  }; // struct Config
52 
53  using Parameters = art::EDProducer::Table<Config>;
54 
55  explicit LegacyGeometryInfoWriter(Parameters const& config);
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 // -----------------------------------------------------------------------------
106 DEFINE_ART_MODULE(geo::LegacyGeometryInfoWriter)
107 
108 
109 // -----------------------------------------------------------------------------
std::string fDetectorName
Name of the detector.
art::EDProducer::Table< Config > Parameters
see a below echo S(symbol in a section other than those above)
static constexpr Sample_t transform(Sample_t sample)
virtual void beginRun(art::Run &run) override
LegacyGeometryInfoWriter(Parameters const &config)
virtual void produce(art::Event &) override
BEGIN_PROLOG vertical distance to the surface Name
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60