All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OpRecoFactoryStuff.h
Go to the documentation of this file.
1 /**
2  * @file icaruscode/PMT/OpReco/Algorithms/OpRecoFactoryStuff.h
3  * @brief Utility and boilerplate for optical algorithms.
4  * @date May 7, 2022
5  * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
6  *
7  * Some utility and boilerplate to make the use of optical reconstruction
8  * algorithms from `larana` more flexible.
9  *
10  * This does not attempt to interface those algorithms with _art_ tools, which
11  * is definitely possible but just not done here.
12  */
13 
14 #ifndef ICARUSCODE_PMT_OPRECO_ALGORITMS_OPRECOFACTORYSTUFF_H
15 #define ICARUSCODE_PMT_OPRECO_ALGORITMS_OPRECOFACTORYSTUFF_H
16 
17 // framework libraries
18 #include "fhiclcpp/ParameterSet.h"
19 #include "cetlib_except/exception.h"
20 
21 // C++ standard libraries
22 #include <vector>
23 #include <iterator> // std::empty(), std::begin(), ...
24 #include <memory> // std::unique_ptr
25 #include <string>
26 #include <utility> // std::move()
27 #include <type_traits> // std::is_base_of_v
28 
29 
30 // -----------------------------------------------------------------------------
31 // forward declarations
32 namespace art { class Event; }
33 
34 
35 // -----------------------------------------------------------------------------
36 namespace opdet::factory {
37 
38  namespace details { struct NoModule_t { explicit NoModule_t() = default; }; }
39 
40  // ---------------------------------------------------------------------------
41  /**
42  * @brief Returns a concatenation of strings in `s` separated by `sep`.
43  * @tparam S type of string
44  * @tparam Coll type of collection of strings
45  * @param sep separator string
46  * @param s list of strings
47  * @return a string of type `S` with the concatenation of all elements of `s`
48  *
49  * Example:
50  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
51  * using std::string_literals;
52  * std::array const s { "one"s, "2"s, "III"s, "d"s };
53  *
54  * std::cout << "Options: '" << join("', '", s) << "'." << std::endl;
55  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
56  * will print: `Options: 'one', '2', 'III', 'd'.`.
57  *
58  * Note that actually `S` can be any copyable type supporting in-place
59  * addition (that is concatenation for strings). Indeed, elements in `Coll`
60  * do not even need to be of type `S` as long as
61  * `S::operator+=(Coll::value_type)` is supported.
62  */
63  template <typename S, typename Coll>
64  S join(S const& sep, Coll const& s);
65 
66  // some tricks to avoid `S` above to become char* or char[]
67  template <typename Coll>
68  std::string join(const char* sep, Coll const& s);
69 
70  // ---------------------------------------------------------------------------
71  /// Token to register an algorithm, used in `AlgorithmFactory`.
72  template <typename Algo>
73  struct Decl {
74  using RealAlgo_t = Algo; ///< Type of the algorithm.
75  std::string name; ///< Name of the algorithm.
76  }; // Decl
77 
78  template <typename Base>
80 
81  // ---------------------------------------------------------------------------
82  /**
83  * @brief Template type for the third parameter of FWInterfacedIF objects.
84  * @tparam Event type of event-level data source
85  * @tparam Module type of framework actor calling the algorithm
86  * (e.g. `art::EDProducer` or even `art::ConsumesCollector`)
87  */
88  template <typename Event = art::Event, typename Module = details::NoModule_t>
90  using Event_t = Event;
91  using Module_t = Module;
92  };
93 
94  template <typename Base, typename FWTraits = FWInterfaceTraits<>>
96 
97  template
98  <typename Algo, typename Base, typename FWTraits = FWInterfaceTraits<>>
100 
101  template
102  <typename Algo, typename Base, typename FWTraits = FWInterfaceTraits<>>
104 
105 
106  // ---------------------------------------------------------------------------
107 
108 } // namespace opdet::factory
109 
110 
111 // ---------------------------------------------------------------------------
112 /**
113  * @brief An algorithm factory class.
114  * @tparam Base the base algorithm class
115  *
116  * This class merges the utilities above into a coherent interface, minimizing
117  * the maintenance cost at the expense of flexibility.
118  *
119  * Example of usage:
120  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
121  * opdet::factory::AlgorithmFactory<pmtana::PMTPulseRecoBase> const
122  * HitAlgoFactory {
123  * "Name"
124  * , opdet::factory::Decl<pmtana::AlgoThreshold >{"Threshold" }
125  * , opdet::factory::Decl<pmtana::AlgoSiPM >{"SiPM" }
126  * , opdet::factory::Decl<pmtana::AlgoSlidingWindow>{"SlidingWindow"}
127  * , opdet::factory::Decl<pmtana::AlgoFixedWindow >{"FixedWindow" }
128  * , opdet::factory::Decl<pmtana::AlgoCFD >{"CFD" }
129  * };
130  *
131  * // ...
132  *
133  * std::unique_ptr<pmtana::PMTPulseRecoBase> algo = HitAlgoFactory.create(pset);
134  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
135  * where we assume `pset` is a configuration for the algorithm, and that it
136  * contains the name of the algorithm (one of those declared strings) in the key
137  * `Name`.
138  *
139  */
140 template <typename Base>
142  public:
143  using Algo_t = Base; ///< The algorithm interface this factory produces.
144  using Factory_t = AlgorithmFactory<Algo_t>; ///< This type.
145 
146 
147  // --- BEGIN -- Registration of algorithms ---------------------------------
148  /// @name Registration of algorithms
149  /// @{
150 
151  /**
152  * @brief Derivative of `opdet::factory::Decl` with added type check.
153  * @tparam Algo the declared algorithm class
154  *
155  * This object is used in `AlgorithmFactory` just like
156  * `opdet::factory::Decl`, from which it derives. This derivative, whose
157  * full identifier is `opdet::factory::AlgorithmFactory<Base>::Decl<Algo>`,
158  * is aware of the expected base class of the algorithm and performs a
159  * static check on it for added QA.
160  */
161  template <typename Algo>
162  struct Decl: opdet::factory::Decl<Algo> {
163  static_assert(std::is_base_of_v<Algo_t, Algo>,
164  "The algorithm <Algo> must be a derivate of <Base>.");
165  }; // Decl
166 
167 
168  /**
169  * @brief Constructor: register the specified algorithms.
170  * @tparam Algos the types of algorithms to register
171  * @param algorithms the declarators of the algorithms to be registered
172  * @see `declare()`
173  *
174  * This constructor declares the specified algorithms like with `declare()`.
175  * In addition, it may be used for example to create a "constant" instance
176  * of a factory.
177  * The example in `declare()` becomes:
178  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
179  * using PedAlgoFactory_t
180  * = opdet::factory::AlgorithmFactory<pmtana::PMTPedestalBase>;
181  *
182  * PedAlgoFactory_t PedAlgoFactory;
183  * PedAlgoFactory.declare(
184  * opdet::factory::Decl<pmtana::PedAlgoEdges>{ "Edges" },
185  * opdet::factory::Decl<pmtana::PedAlgoUB >{ "UB" }
186  * );
187  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
188  *
189  */
190  template <typename... Algos>
192  : AlgorithmFactory{ "", std::move(algorithms)... } {}
193 
194 
195  /**
196  * @brief Constructor: register the specified algorithms.
197  * @tparam Algos the types of algorithms to register
198  * @param algoKey name of the configuration key whith the algorithm name
199  * @param algorithms the declarators of the algorithms to be registered
200  * @see `declare()`, `setAlgorithmConfigurationKey()`
201  *
202  * In addition to the declaration of algorithms (see `declare()` or the
203  * other constructor), this constructor also sets the configuration key
204  * where the algorithm name is expected to be found (@see
205  * `setAlgorithmConfigurationKey()`).
206  */
207  template <typename... Algos>
209  (std::string algoKey, opdet::factory::Decl<Algos>... algorithms);
210 
211 
212  /**
213  * @brief Sets the name of the configuration key with the algorithm name.
214  * @param key name of the configuration key with the algorithm name
215  * @return this factory
216  * @see `create()`
217  *
218  * When an algorithm instance is created with `create()`, it is always
219  * possible to specify the name of the algorithm explicitly,
220  * using `create(std::string const&, fhicl::ParameterSet const&)`.
221  * In addition, if it is known that the algorithm name is in a configuration
222  * key of that parameter set, the path of that configuration key can be
223  * specified here, and the other version of `create()`,
224  * `create(fhicl::ParameterSet const&)`, can be used which will discover
225  * the required algorithm name from the configuration in argument (which is
226  * still the same used to construct the algorithm itself).
227  *
228  * Example:
229  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
230  * factory.setAlgorithmConfigurationKey("Name");
231  * auto algo = factory.create(pset);
232  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
233  * is equivalent to:
234  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
235  * auto algo = factory.create(pset.get<std::string>("Name"), pset);
236  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
237  */
239  { fAlgoNameKey = std::move(key); return *this; }
240 
241 
242  /// Registers an algorithm of type `Algo` associated with a `name`.
243  template <typename Algo>
244  Factory_t& declare(std::string name);
245 
246  /**
247  * @brief Register a sequence of algorithms
248  * @tparam FirstAlgo the type of the first algorithm to register (mandatory)
249  * @tparam OtherAlgos the types of more algorithms to register
250  * @param first the declarator of the first algorithm to be registered
251  * @param others the declarators of more algorithms to be registered
252  * @return this factory object
253  *
254  * This method allows the declaration of many algorithms at once, one for
255  * each declarator in the arguments.
256  * For example:
257  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
258  * using PedAlgoFactory_t
259  * = opdet::factory::AlgorithmFactory<pmtana::PMTPedestalBase>;
260  * using PedAlgoDecl = PedAlgoFactory_t::Decl;
261  *
262  * PedAlgoFactory_t PedAlgoFactory;
263  * PedAlgoFactory.declare(
264  * PedAlgoDecl<pmtana::PedAlgoEdges>{ "Edges" },
265  * PedAlgoDecl<pmtana::PedAlgoUB >{ "UB" }
266  * );
267  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
268  * A constructor is likewise available to register algorithms.
269  */
270  template <typename FirstAlgo, typename... OtherAlgos>
274  );
275 
276  /// @}
277  // --- END ---- Registration of algorithms ---------------------------------
278 
279 
280  // --- BEGIN -- Queries and algorithm creation -----------------------------
281  /// @name Queries and algorithm creation
282  /// @{
283 
284  /**
285  * @brief Returns an instance of algorithm `name` constructed with `pset`.
286  * @param name declared name of the algorithm
287  * @param pset the configuration of the algorithm
288  * @return the newly created algorithm object
289  *
290  * The algorithm is constructed with `pset` as only constructor argument.
291  */
292  std::unique_ptr<Algo_t> create
293  (std::string const& name, fhicl::ParameterSet const& pset) const;
294 
295  /**
296  * @brief Creates an instance of the algorithm constructed with `pset`.
297  * @param pset the configuration of the algorithm
298  * @return the newly created algorithm object
299  *
300  * The type of algorithm is discovered from `pset` itself with the mechanism
301  * documented in `setAlgorithmConfigurationKey()`.
302  *
303  * For example:
304  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
305  * factory.setAlgorithmConfigurationKey("Name");
306  * auto algo = factory.create(pset);
307  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
308  * is equivalent to:
309  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
310  * auto algo = factory.create(pset.get<std::string>("Name"), pset);
311  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
312  */
313  std::unique_ptr<Algo_t> create(fhicl::ParameterSet const& pset) const;
314 
315  /// Returns a list with the names of supported algorithms.
316  std::vector<std::string> names() const;
317 
318  /// Returns a string with the names of supported algorithms, joint.
319  std::string names(std::string const& sep) const
320  { return join(sep, names()); }
321 
322  /// }
323  // --- END ---- Queries and algorithm creation -----------------------------
324 
325  private:
326 
327  /// Wrapper of an algorithm providing a polymorphic interface to create
328  /// objects of the wrapped type.
329  struct AlgoMaker;
330 
331  /**
332  * @brief Standard algorithm maker class.
333  * @tparam Algo the concrete algorithm class delivered by this object
334  *
335  * This class implements `AlgoMaker` by overriding `makeAlgo()` method.
336  * Its implementation simply constructs a new object of type `Algo` passing
337  * the parameter set in the interface to the constructor of the `Algo` class.
338  */
339  template <typename Algo>
340  struct AlgoMakerFor;
341 
342  /// Name of the configuration key with algorithm name (empty if not provided).
343  std::string fAlgoNameKey;
344 
345  /// Registry of all maker classes.
346  std::vector<std::unique_ptr<AlgoMaker>> fMakers;
347 
348  /// Returns the maker with the specified `name`, `nullptr` if none.
349  AlgoMaker const* getMaker(std::string const& name) const;
350 
351  /// Adds the `maker` to the list of registered maker classes.
352  Factory_t& registerMaker(std::unique_ptr<AlgoMaker>&& maker);
353 
354 }; // class opdet::factory::AlgorithmFactory
355 
356 
357 // -----------------------------------------------------------------------------
358 // wrapping for algorithms to allow an interface to the framework
359 template <typename Base, typename FWTraits /* = FWInterfaceTraits<> */>
361  public:
362  using Algo_t = Base;
363  using Event_t = typename FWTraits::Event_t;
364  using Module_t = typename FWTraits::Module_t;
365 
366  virtual ~FWInterfacedIF() = default;
367 
368  /// Access to the algorithm.
369  Algo_t& algo() const { return *getAlgo(); }
370 
371  // --- BEGIN -- Framework hooks ----------------------------------------------
373  void beginEvent(Event_t const& event) { doBeginEvent(event); }
374  void endEvent(Event_t const& event) { doEndEvent(event); }
375  // --- END ---- Framework hooks ----------------------------------------------
376 
377  private:
378 
379  virtual Algo_t* getAlgo() const = 0;
380 
381  virtual void doInitialize(Module_t& module) {}
382  virtual void doBeginEvent(Event_t const& event) {}
383  virtual void doEndEvent(Event_t const& event) {}
384 
385 }; // opdet::factory::FWInterfacedIF
386 
387 
388 /// Base class for specialization.
389 template
390  <typename Algo, typename Base, typename FWTraits /* = FWInterfaceTraits<> */>
392  : public opdet::factory::FWInterfacedIF<Base, FWTraits>
393 {
394  using RealAlgo_t = Algo;
395 
396  public:
397 
398  using Algo_t = Base;
399 
400  protected:
401 
402  FWInterfacedBase(fhicl::ParameterSet const& pset)
403  : fAlgo{ std::make_unique<RealAlgo_t>(pset) } {}
404 
405  /// Returns the stored algorithm.
406  virtual RealAlgo_t* getAlgo() const override { return fAlgo.get(); }
407 
408  private:
409 
410  std::unique_ptr<RealAlgo_t> fAlgo; ///< Instance of RealAlgo_t.
411 
412 }; // FWInterfacedBase
413 
414 
415 template
416  <typename Algo, typename Base, typename FWTraits /* = FWInterfaceTraits<> */>
418  : public opdet::factory::FWInterfacedBase<Algo, Base, FWTraits>
419 {
420  public:
421  FWInterfaced(fhicl::ParameterSet const& pset)
422  : FWInterfacedBase<Algo, Base, FWTraits>{ pset } {}
423 
424 }; // FWInterfaced
425 
426 
427 // -----------------------------------------------------------------------------
428 // --- template implementation
429 // -----------------------------------------------------------------------------
430 // --- opdet::factory::AlgorithmFactory::AlgoMaker
431 // -----------------------------------------------------------------------------
432 template <typename Base>
434 
435  std::string name; ///< The name associated to this algorithm.
436 
437  AlgoMaker(std::string name): name{ std::move(name) } {}
438 
439  virtual ~AlgoMaker() = default;
440 
441  /**
442  * @brief Algorithm class construction.
443  * @param pset the parameter set used to construct the algorithm object
444  * @return a pointer to an object derived from `Base`, ready for use
445  *
446  * The implementations will do whatever it takes to allocate and construct
447  * the `Algo_t`-derived object they cover, based on the content of `pset`,
448  * and return it.
449  */
450  virtual std::unique_ptr<Base> makeAlgo
451  (fhicl::ParameterSet const& pset) const = 0;
452 
453  /// Comparison: sort by name in lexicographic order.
454  bool operator< (AlgoMaker const& other) const
455  { return name < other.name; }
456 
457 }; // opdet::factory::AlgorithmFactory::AlgoMaker
458 
459 
460 template <typename Base>
461 template <typename Algo>
462 struct opdet::factory::AlgorithmFactory<Base>::AlgoMakerFor
463  : opdet::factory::AlgorithmFactory<Base>::AlgoMaker
464 {
465 
466  AlgoMakerFor(std::string const& name): AlgoMaker{ name } {}
467 
468  std::unique_ptr<Base> makeAlgo
469  (fhicl::ParameterSet const& pset) const override
470  { return std::make_unique<Algo>(pset); }
471 
472 }; // opdet::factory::AlgorithmFactory::AlgoMakerFor
473 
474 
475 // -----------------------------------------------------------------------------
476 // --- opdet::factory::AlgorithmFactory
477 // -----------------------------------------------------------------------------
478 template <typename Base>
479 template <typename... Algos>
481  (std::string algoKey, opdet::factory::Decl<Algos>... algorithms)
482  : fAlgoNameKey{ std::move(algoKey) }
483 {
484  if constexpr(sizeof...(Algos) > 0) declare(std::move(algorithms)...);
485 }
486 
487 
488 // -----------------------------------------------------------------------------
489 template <typename Base>
490 template <typename Algo>
491 auto opdet::factory::AlgorithmFactory<Base>::declare(std::string name)
492  -> Factory_t&
493 {
494  return registerMaker(std::make_unique<AlgoMakerFor<Algo>>(std::move(name)));
495 } // opdet::factory::AlgorithmFactory::declare(string)
496 
497 
498 // -----------------------------------------------------------------------------
499 template <typename Base>
500 template <typename FirstAlgo, typename... OtherAlgos>
504 ) -> Factory_t&
505 {
506  declare<FirstAlgo>(std::move(first.name));
507  if constexpr(sizeof...(OtherAlgos) > 0) declare(std::move(others)...);
508  return *this;
509 } // opdet::factory::AlgorithmFactory::declare(Decl)
510 
511 
512 // -----------------------------------------------------------------------------
513 template <typename Base>
515  (std::string const& name, fhicl::ParameterSet const& pset) const
516  -> std::unique_ptr<Algo_t>
517 {
518  AlgoMaker const* maker = getMaker(name);
519  if (maker) return maker->makeAlgo(pset);
520 
521  throw cet::exception{ "AlgorithmFactory" }
522  << "Unknown algorithm: '" << name << "'.\nSupported algorithms:\n - '"
523  << names("'\n - '") << "'\n";
524 
525 } // opdet::factory::AlgorithmFactory::create()
526 
527 
528 // -----------------------------------------------------------------------------
529 template <typename Base>
531  (fhicl::ParameterSet const& pset) const -> std::unique_ptr<Algo_t>
532 {
533  return create(pset.get<std::string>(fAlgoNameKey), pset);
534 } // opdet::factory::AlgorithmFactory::create()
535 
536 
537 // -----------------------------------------------------------------------------
538 template <typename Base>
539 std::vector<std::string> opdet::factory::AlgorithmFactory<Base>::names() const {
540  std::vector<std::string> v;
541  for (auto const& maker: fMakers) v.push_back(maker->name);
542  return v;
543 } // opdet::factory::AlgorithmFactory::names()
544 
545 
546 // -----------------------------------------------------------------------------
547 template <typename Base>
549  (std::string const& name) const -> AlgoMaker const*
550 {
551  // we could keep the makers ordered and do a binary search;
552  // not really worth though
553  for (std::unique_ptr<AlgoMaker> const& maker: fMakers)
554  if (maker->name == name) return maker.get();
555  return nullptr;
556 } // opdet::factory::AlgorithmFactory::getMaker()
557 
558 
559 // -----------------------------------------------------------------------------
560 template <typename Base>
562  (std::unique_ptr<AlgoMaker>&& maker) -> Factory_t&
563 {
564  fMakers.push_back(std::move(maker));
565  return *this;
566 } // opdet::factory::AlgorithmFactory::registerMaker()
567 
568 
569 // -----------------------------------------------------------------------------
570 // --- other utilities
571 // -----------------------------------------------------------------------------
572 template <typename S, typename Coll>
573 S opdet::factory::join(S const& sep, Coll const& s) {
575  if (empty(s)) return S{};
576  auto it = begin(s);
577  auto const send = end(s);
578  S cat { *it };
579  while (++it != send) { cat += sep; cat += *it; }
580  return cat;
581 } // join()
582 
583 template <typename Coll>
584 std::string opdet::factory::join(const char* sep, Coll const& s)
585  { return join<std::string>(sep, s); }
586 
587 // -----------------------------------------------------------------------------
588 
589 #endif // ICARUSCODE_PMT_OPRECO_ALGORITMS_OPRECOFACTORYSTUFF_H
Algo_t & algo() const
Access to the algorithm.
std::string fAlgoNameKey
Name of the configuration key with algorithm name (empty if not provided).
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Definition: UtilFunc.cxx:42
AlgorithmFactory(opdet::factory::Decl< Algos >...algorithms)
Constructor: register the specified algorithms.
see a below echo S(symbol in a section other than those above)
Factory_t & setAlgorithmConfigurationKey(std::string key)
Sets the name of the configuration key with the algorithm name.
virtual void doInitialize(Module_t &module)
Token to register an algorithm, used in AlgorithmFactory.
Factory_t & registerMaker(std::unique_ptr< AlgoMaker > &&maker)
Adds the maker to the list of registered maker classes.
Template type for the third parameter of FWInterfacedIF objects.
std::vector< std::string > names() const
Returns a list with the names of supported algorithms.
AlgorithmFactory< Algo_t > Factory_t
This type.
Derivative of opdet::factory::Decl with added type check.
constexpr bool operator<(CryostatID const &a, CryostatID const &b)
Order cryostats with increasing ID.
Definition: geo_types.h:706
Pedestal &quot;algorithm&quot; reading the pedestals from somewhere else.
Definition: PedAlgoFixed.h:64
void initialize(Module_t &module)
std::string name
The name associated to this algorithm.
Base Algo_t
The algorithm interface this factory produces.
virtual ~FWInterfacedIF()=default
AlgoMaker const * getMaker(std::string const &name) const
Returns the maker with the specified name, nullptr if none.
FWInterfaced(fhicl::ParameterSet const &pset)
std::string names(std::string const &sep) const
Returns a string with the names of supported algorithms, joint.
S join(S const &sep, Coll const &s)
Returns a concatenation of strings in s separated by sep.
Factory_t & declare(std::string name)
Registers an algorithm of type Algo associated with a name.
std::string name
Name of the algorithm.
void beginEvent(Event_t const &event)
std::vector< std::unique_ptr< AlgoMaker > > fMakers
Registry of all maker classes.
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
std::unique_ptr< Algo_t > create(std::string const &name, fhicl::ParameterSet const &pset) const
Returns an instance of algorithm name constructed with pset.
void endEvent(Event_t const &event)
FWInterfacedBase(fhicl::ParameterSet const &pset)
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
static const std::vector< std::string > names
std::unique_ptr< RealAlgo_t > fAlgo
Instance of RealAlgo_t.
An algorithm factory class.
virtual RealAlgo_t * getAlgo() const override
Returns the stored algorithm.
virtual std::unique_ptr< Base > makeAlgo(fhicl::ParameterSet const &pset) const =0
Algorithm class construction.
Base class for specialization.
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
then echo fcl name
virtual void doBeginEvent(Event_t const &event)
bool empty(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:555
Algo RealAlgo_t
Type of the algorithm.
virtual void doEndEvent(Event_t const &event)
virtual Algo_t * getAlgo() const =0