OmnibusSigProc.h
Go to the documentation of this file.
1 #ifndef WIRECELLSIGPROC_OMNIBUSSIGPROC
2 #define WIRECELLSIGPROC_OMNIBUSSIGPROC
3 
8 #include "WireCellUtil/Array.h"
9 #include "WireCellUtil/Logging.h"
10 
11 #include <list>
12 
13 namespace WireCell {
14  namespace SigProc {
15 
16  class SignalROI; //forward declaration
18  public:
19  OmnibusSigProc(const std::string& anode_tn = "AnodePlane",
20  const std::string& per_chan_resp_tn = "PerChannelResponse",
21  const std::string& field_response = "FieldResponse",
22  double fine_time_offset = 0.0 * units::microsecond,
23  double coarse_time_offset = -8.0 * units::microsecond,
24  double gain = 14.0 * units::mV/units::fC,
25  double shaping_time = 2.2 * units::microsecond,
26  double inter_gain = 1.2,
27  double ADC_mV = 4096/(2000.*units::mV),
28  float th_factor_ind = 3,
29  float th_factor_col = 5,
30  int pad = 5,
31  float asy = 0.1,
32  int rebin =6,
33  double l_factor=3.5,
34  double l_max_th=10000,
35  double l_factor1=0.7,
36  int l_short_length = 3,
37  int l_jump_one_bin = 0,
38  double r_th_factor = 3.0,
39  double r_fake_signal_low_th = 500,
40  double r_fake_signal_high_th = 1000,
41  double r_fake_signal_low_th_ind_factor = 1.0,
42  double r_fake_signal_high_th_ind_factor = 1.0,
43  int r_pad = 5,
44  int r_break_roi_loop = 2,
45  double r_th_peak = 3.0,
46  double r_sep_peak=6.0,
47  double r_low_peak_sep_threshold_pre = 1200,
48  int r_max_npeaks = 200,
49  double r_sigma = 2.0,
50  double r_th_percent = 0.1,
51  int charge_ch_offset = 10000,
52  const std::string& wiener_tag = "wiener",
53  const std::string& wiener_threshold_tag = "threshold",
54  const std::string& gauss_tag = "gauss",
55  bool use_roi_debug_mode = false,
56  const std::string& tight_lf_tag = "tight_lf",
57  const std::string& loose_lf_tag = "loose_lf",
58  const std::string& cleanup_roi_tag = "cleanup_roi",
59  const std::string& break_roi_loop1_tag = "break_roi_1st",
60  const std::string& break_roi_loop2_tag = "break_roi_2nd",
61  const std::string& shrink_roi_tag = "shrink_roi",
62  const std::string& extend_roi_tag = "extend_roi" );
63  virtual ~OmnibusSigProc();
64 
65  virtual bool operator()(const input_pointer& in, output_pointer& out);
66 
67  virtual void configure(const WireCell::Configuration& config);
69 
70  private:
71 
72  // convert data into Eigen Matrix
73  void load_data(const input_pointer& in, int plane);
74 
75  // deconvolution
76  void decon_2D_init(int plane); // main decon code
77  void decon_2D_ROI_refine(int plane);
78  void decon_2D_tightROI(int plane);
79  void decon_2D_tighterROI(int plane);
80  void decon_2D_looseROI(int plane);
81  void decon_2D_hits(int plane);
82  void decon_2D_charge(int plane);
83 
84  void decon_2D_looseROI_debug_mode(int plane);
85 
86  // save data into the out frame and collect the indices
87  void save_data(ITrace::vector& itraces, IFrame::trace_list_t& indices, int plane,
88  const std::vector<float>& perwire_rmses,
89  IFrame::trace_summary_t& threshold);
90 
91  // save ROI into the out frame (set use_roi_debug_mode=true)
92  void save_roi(ITrace::vector& itraces, IFrame::trace_list_t& indices, int plane,
93  std::vector<std::list<SignalROI*> >& roi_channel_list);
94 
95  // initialize the overall response function ...
97 
99 
100  // This little struct is used to map between WCT channel idents
101  // and internal OmnibusSigProc wire/channel numbers. See
102  // m_channel_map and m_channel_range below.
103  struct OspChan {
104  int channel; // between 0 and nwire_u+nwire_v+nwire_w-1
105  int wire; // between 0 and nwire_{u,v,w,}-1 depending on plane
106  int plane; // 0,1,2
107  int ident; // wct ident, opaque non-negative number. set in wires geom file
108  OspChan(int c=-1, int w=-1, int p=-1, int id=-1) : channel(c), wire(w), plane(p), ident(id) {}
109  std::string str() const;
110  };
111 
112 
113  // find if neighbor channels hare masked.
114  bool masked_neighbors(const std::string& cmname, OspChan& ochan, int nnn);
115 
116 
117  // Anode plane for geometry
122 
123  // Overall time offset
124  double m_fine_time_offset; // must be positive, between 0-0.5 us, shift the response function to earlier time --> shift the deconvoluted signal to a later time
125  double m_coarse_time_offset; // additional coarse time shift ...
127  int m_wire_shift[3];
128 
129  // bins
130  double m_period;
131  int m_nticks;
135 
136  // gain, shaping time, other applification factors
139 
140  // some parameters for ROI creating
143  int m_pad;
144  float m_asy ;
145  int m_rebin;
146  double m_l_factor;
147  double m_l_max_th;
148  double m_l_factor1;
151 
152 
153  // ROI_refinement
159  int m_r_pad;
161  double m_r_th_peak;
162  double m_r_sep_peak;
165  double m_r_sigma;
167 
168  // fixme: this is apparently not used:
169  // channel offset
171 
172  // CAUTION: this class was originally written for microboone
173  // which is degenerate in how wires and channels may be
174  // numbered. DUNE APAs do not have a one-to-one nor simple
175  // mapping between a sequenctial "channel number", "wire number"
176  // and "channel ident". In OSP and the related ROI code,
177  // wherever you see a "wire" number, it counts the segment-0
178  // wire segment in order of increasing pitch and assuming one
179  // logical plane so it will wrap around for two-faced APAs like
180  // in DUNE. An OSP "channel" number goes from 0 to
181  // nwire_u+nwire_v+nwire_w-1 over the entire APA. A WCT "ident"
182  // number is totally opaque, you can't assume anything about it
183  // except that it is nonnegative.
184  int m_nwires[3];
185 
186  // Need to go from WCT channel ident to {OSP channel, wire and plane}
187  std::map<int,OspChan> m_channel_map;
188 
189  // Need to go from OSP plane to iterable {OSP channel an wire and WCT ident}
190  std::vector<OspChan> m_channel_range[3];
191 
192  // This is the input channel mask map but converted to OSP
193  // channel number indices. See above. This is NOT a direct
194  // copy from the IFrame. It's reindexed by osp channel, not WCT
195  // channel ident!
197 
198  // Per-plane temporary working arrays. Each column is one tick,
199  // each row is indexec by an "OSP wire" number
202 
203  //average overall responses
204  std::vector<Waveform::realseq_t> overall_resp[3];
205 
206  // tag name for traces
211 
220 
221  // If true, safe output as a sparse frame. Traces will only
222  // cover segments of waveforms which have non-zero signal
223  // samples.
224  bool m_sparse;
225 
227 
228  };
229  }
230 }
231 
232 
233 #endif
234 // Local Variables:
235 // mode: c++
236 // c-basic-offset: 2
237 // End:
std::shared_ptr< const IFrame > pointer
Definition: IData.h:19
void init_overall_response(IFrame::pointer frame)
OspChan(int c=-1, int w=-1, int p=-1, int id=-1)
std::map< int, OspChan > m_channel_map
std::string string
Definition: nybbler.cc:12
virtual void configure(const WireCell::Configuration &config)
Accept a configuration.
OmnibusSigProc(const std::string &anode_tn="AnodePlane", const std::string &per_chan_resp_tn="PerChannelResponse", const std::string &field_response="FieldResponse", double fine_time_offset=0.0 *units::microsecond, double coarse_time_offset=-8.0 *units::microsecond, double gain=14.0 *units::mV/units::fC, double shaping_time=2.2 *units::microsecond, double inter_gain=1.2, double ADC_mV=4096/(2000.*units::mV), float th_factor_ind=3, float th_factor_col=5, int pad=5, float asy=0.1, int rebin=6, double l_factor=3.5, double l_max_th=10000, double l_factor1=0.7, int l_short_length=3, int l_jump_one_bin=0, double r_th_factor=3.0, double r_fake_signal_low_th=500, double r_fake_signal_high_th=1000, double r_fake_signal_low_th_ind_factor=1.0, double r_fake_signal_high_th_ind_factor=1.0, int r_pad=5, int r_break_roi_loop=2, double r_th_peak=3.0, double r_sep_peak=6.0, double r_low_peak_sep_threshold_pre=1200, int r_max_npeaks=200, double r_sigma=2.0, double r_th_percent=0.1, int charge_ch_offset=10000, const std::string &wiener_tag="wiener", const std::string &wiener_threshold_tag="threshold", const std::string &gauss_tag="gauss", bool use_roi_debug_mode=false, const std::string &tight_lf_tag="tight_lf", const std::string &loose_lf_tag="loose_lf", const std::string &cleanup_roi_tag="cleanup_roi", const std::string &break_roi_loop1_tag="break_roi_1st", const std::string &break_roi_loop2_tag="break_roi_2nd", const std::string &shrink_roi_tag="shrink_roi", const std::string &extend_roi_tag="extend_roi")
struct vector vector
Eigen::ArrayXXcf array_xxc
A complex, 2D array.
Definition: Array.h:57
static const double microsecond
Definition: Units.h:94
static const double mV
Definition: Units.h:180
std::vector< OspChan > m_channel_range[3]
std::vector< pointer > vector
Definition: IData.h:21
virtual bool operator()(const input_pointer &in, output_pointer &out)
The calling signature:
std::shared_ptr< const IFrame > input_pointer
Definition: IFunctionNode.h:39
void load_data(const input_pointer &in, int plane)
std::map< std::string, ChannelMasks > ChannelMaskMap
Collect channel masks by some label.
Definition: Waveform.h:59
static Config * config
Definition: config.cpp:1054
std::vector< double > trace_summary_t
Definition: IFrame.h:39
constexpr std::array< std::size_t, geo::vect::dimension< Vector >)> indices()
Returns a sequence of indices valid for a vector of the specified type.
std::shared_ptr< Interface > pointer
Definition: Interface.h:16
static const double fC
Definition: Units.h:113
virtual WireCell::Configuration default_configuration() const
Optional, override to return a hard-coded default configuration.
std::shared_ptr< const IFrame > output_pointer
Definition: IFunctionNode.h:40
std::shared_ptr< spdlog::logger > logptr_t
Definition: Logging.h:24
Definition: Main.h:22
p
Definition: test.py:223
Waveform::ChannelMaskMap m_cmm
void save_roi(ITrace::vector &itraces, IFrame::trace_list_t &indices, int plane, std::vector< std::list< SignalROI * > > &roi_channel_list)
Json::Value Configuration
Definition: Configuration.h:50
bool masked_neighbors(const std::string &cmname, OspChan &ochan, int nnn)
void save_data(ITrace::vector &itraces, IFrame::trace_list_t &indices, int plane, const std::vector< float > &perwire_rmses, IFrame::trace_summary_t &threshold)
void restore_baseline(WireCell::Array::array_xxf &arr)
def rebin(a, args)
Definition: arrays.py:2
std::vector< size_t > trace_list_t
Definition: IFrame.h:36
std::vector< Waveform::realseq_t > overall_resp[3]
Eigen::ArrayXXf array_xxf
A real, 2D array.
Definition: Array.h:54