FrameSaver.h
Go to the documentation of this file.
1 /** A WCT component which passes through IFrames untouched and saves
2  * their content as:
3 
4  - waveform content as vector collections of either raw::RawDigit or
5  recob::Wire.
6 
7  - summaries as vector<double>
8 
9  - channel mask maps as vector<int> holding channel numbers
10 
11  It can be configured to scale waveform or summary values by some constant.
12 */
13 
14 #ifndef LARWIRECELL_COMPONENTS_FRAMESAVER
15 #define LARWIRECELL_COMPONENTS_FRAMESAVER
16 
17 #include "WireCellIface/IFrameFilter.h"
18 #include "WireCellIface/IConfigurable.h"
21 
22 #include <string>
23 #include <functional>
24 #include <vector>
25 #include <map>
26 #include <unordered_map>
27 
28 namespace wcls {
29 
30  class FrameSaver : public IArtEventVisitor,
31  public WireCell::IFrameFilter,
32  public WireCell::IConfigurable {
33  public:
34  FrameSaver();
35  virtual ~FrameSaver();
36 
37  /// IArtEventVisitor
38  virtual void produces(art::ProducesCollector& collector);
39  virtual void visit(art::Event & event);
40 
41  /// IFrameFilter
42  virtual bool operator()(const WireCell::IFrame::pointer& inframe,
43  WireCell::IFrame::pointer& outframe);
44 
45  /// IConfigurable
47  virtual void configure(const WireCell::Configuration& config);
48 
49  /// A WCT frame includes the concept of a "channel mask map"
50  /// which is a named association between a set of channels and
51  /// a number of bin ranges (the masks) for each channel. The
52  /// name is meant to connote some semantic meaning to the
53  /// masks (eg, "bad" or "noisy"). The bin ranges are
54  /// expressed as a begin and end index into the associated
55  /// channel waveform (aka the "trace"). The end index is one
56  /// past the intended coverage in the usual C++ iterator
57  /// convention. This information is stored in two
58  /// vecotor<int> data products which are given instance names
59  /// based on the channel mask map name. The first vector<int>
60  /// named "<name>channels" holds a simple list of channel
61  /// numbers which have at least one mask. The second
62  /// vector<int> named "<name>masks" is a flattened 3xN array
63  /// of entries like: [(channel, begin, end), ...]. This
64  /// contrivied storage format is to avoid creating an data
65  /// product class. Both are produced so that the job may be
66  /// configured to drop one or both.
67  typedef std::vector<int> channel_list;
68  typedef std::vector<int> channel_masks;
69 
70 
71  private:
72 
73  // ordered.
74  std::map<int, geo::View_t> m_chview;
75 
76 
77  WireCell::IFrame::pointer m_frame;
78  std::vector<std::string> m_frame_tags, m_summary_tags;
79  std::vector<double> m_frame_scale, m_summary_scale;
80 
81  typedef std::function<float(const std::vector<float>& tsvals)> summarizer_function;
82  std::unordered_map< std::string, summarizer_function> m_summary_operators;
83 
84  int m_nticks;
86  Json::Value m_cmms, m_pedestal_mean;
88 
89  void save_as_raw(art::Event & event);
90  void save_as_cooked(art::Event & event);
91  void save_summaries(art::Event & event);
92  void save_cmms(art::Event & event);
93  void save_empty(art::Event& event);
94 
95  };
96 }
97 
98 #endif
std::map< int, geo::View_t > m_chview
Definition: FrameSaver.h:74
std::vector< int > channel_masks
Definition: FrameSaver.h:68
virtual WireCell::Configuration default_configuration() const
IConfigurable.
Definition: FrameSaver.cxx:36
void save_cmms(art::Event &event)
Definition: FrameSaver.cxx:474
virtual bool operator()(const WireCell::IFrame::pointer &inframe, WireCell::IFrame::pointer &outframe)
IFrameFilter.
Definition: FrameSaver.cxx:562
void save_empty(art::Event &event)
Definition: FrameSaver.cxx:511
virtual void visit(art::Event &event)
Implement to visit an Art event.
Definition: FrameSaver.cxx:542
std::vector< std::string > m_summary_tags
Definition: FrameSaver.h:78
virtual ~FrameSaver()
Definition: FrameSaver.cxx:33
void save_as_cooked(art::Event &event)
Definition: FrameSaver.cxx:332
static Config * config
Definition: config.cpp:1054
virtual void configure(const WireCell::Configuration &config)
Definition: FrameSaver.cxx:110
std::vector< std::string > m_frame_tags
Definition: FrameSaver.h:78
Json::Value m_pedestal_mean
Definition: FrameSaver.h:86
Definition of data types for geometry description.
void save_as_raw(art::Event &event)
Definition: FrameSaver.cxx:269
std::function< float(const std::vector< float > &tsvals)> summarizer_function
Definition: FrameSaver.h:81
std::vector< double > m_summary_scale
Definition: FrameSaver.h:79
WireCell::IFrame::pointer m_frame
Definition: FrameSaver.h:77
std::unordered_map< std::string, summarizer_function > m_summary_operators
Definition: FrameSaver.h:82
Json::Value m_cmms
Definition: FrameSaver.h:86
std::vector< double > m_frame_scale
Definition: FrameSaver.h:79
std::vector< int > channel_list
Definition: FrameSaver.h:67
virtual void produces(art::ProducesCollector &collector)
IArtEventVisitor.
Definition: FrameSaver.cxx:197
void save_summaries(art::Event &event)
Definition: FrameSaver.cxx:427
Event finding and building.
double m_pedestal_sigma
Definition: FrameSaver.h:87