FileCatalogMetadataPlugin.h
Go to the documentation of this file.
1 #ifndef art_Framework_Core_FileCatalogMetadataPlugin_h
2 #define art_Framework_Core_FileCatalogMetadataPlugin_h
3 // vim: set sw=2 expandtab :
4 
5 //
6 // The base class for user-defined plugins to produce SAM metadata
7 // specific to a particular output stream. Configure with:
8 //
9 // FCMDPlugins: [ { plugin_type: <pluginClassName> ... }, ... ]
10 //
11 // Entry points are called as indicated by their names, with the
12 // following extra notes:
13 //
14 // * doCollectMetadata(...) is called only when an event is selected for
15 // output by the output module for which the current plugin is
16 // configured.
17 //
18 // * doProduceMetadata() is called immediately before a file is closed
19 // by the output module for which the current plugin is configured.
20 //
21 // General notes.
22 //
23 // * Subclasses implementing this interface *must* implement
24 // produceMetadata(). Other entry points are optional.
25 //
26 // * Subclasses should not provide a header file: any communication with
27 // the plugin is accomplished solely via the base class interface.
28 //
29 // * Use the macro DEFINE_FILECATALOGMETADATA_PLUGIN(<classname>) (see
30 // below) at the bottom of your implementation file to declare your
31 // plugin to the art system.
32 //
33 
38 #include "fhiclcpp/ParameterSet.h"
40 
41 #define DEFINE_ART_FILECATALOGMETADATA_PLUGIN(klass) \
42  CET_PROVIDE_FILE_PATH() \
43  FHICL_PROVIDE_ALLOWED_CONFIGURATION(klass) \
44  DEFINE_BASIC_PLUGIN(klass, art::FileCatalogMetadataPlugin)
45 
46 namespace art {
47 
48  class Event;
49  class FileCatalogMetadataPlugin;
50  class Run;
51  class SubRun;
52 
53 } // namespace art
54 
55 namespace cet {
56 
57  template <>
58  struct PluginTypeDeducer<art::FileCatalogMetadataPlugin> {
59  static std::string const value;
60  };
61 
62 } // namespace cet
63 
64 namespace art {
65 
67  public:
69 
71  virtual ~FileCatalogMetadataPlugin() = default;
72 
73  void doBeginJob();
74  void doEndJob();
75 
76  void doBeginRun(Run const& r);
77  void doEndRun(Run const& r);
78 
79  void doBeginSubRun(SubRun const& sr);
80  void doEndSubRun(SubRun const& sr);
81 
82  void doCollectMetadata(Event const& e);
83 
84  collection_type doProduceMetadata();
85 
86  private:
87  virtual void
89  {}
90  virtual void
92  {}
93 
94  virtual void
95  beginRun(Run const&)
96  {}
97  virtual void
98  endRun(Run const&)
99  {}
100 
101  virtual void
103  {}
104  virtual void
106  {}
107 
108  virtual void
110  {}
111 
112  virtual collection_type produceMetadata() = 0;
113  };
114 
115  inline void
117  {
118  beginJob();
119  }
120 
121  inline void
123  {
124  endJob();
125  }
126 
127  inline void
129  {
130  collectMetadata(e);
131  }
132 
133  inline void
135  {
136  beginRun(r);
137  }
138 
139  inline void
141  {
142  endRun(r);
143  }
144 
145  inline void
147  {
148  beginSubRun(r);
149  }
150 
151  inline void
153  {
154  endSubRun(r);
155  }
156 
157  inline auto
159  {
160  return produceMetadata();
161  }
162 
163 } // namespace art
164 
165 #endif /* art_Framework_Core_FileCatalogMetadataPlugin_h */
166 
167 // Local Variables:
168 // mode: c++
169 // End:
std::vector< std::pair< std::string, std::string >> collection_type
Definition: Run.h:21
virtual void beginSubRun(SubRun const &)
void beginJob()
caf::StandardRecord * sr
FileCatalogMetadata::collection_type collection_type
virtual void endSubRun(SubRun const &)
TRandom3 r(0)
Service to store calibration data products (CDP) in the SQLite3 metadatabase of a file...
Definition: FillParentInfo.h:8
Float_t e
Definition: plot.C:35
virtual void collectMetadata(Event const &)
enum BeamMode string