ROI_formation.h
Go to the documentation of this file.
1 
2 
3 #ifndef WIRECELLSIGPROC_ROIFORMATION
4 #define WIRECELLSIGPROC_ROIFORMATION
5 
6 #include "WireCellUtil/Array.h"
8 
9 #include <vector>
10 #include <map>
11 
12 namespace WireCell{
13  namespace SigProc{
15  public:
16  ROI_formation(Waveform::ChannelMaskMap& cmm,int nwire_u, int nwire_v, int nwire_w, int nbins = 9594, 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);
18 
19  void Clear();
20 
21  void find_ROI_by_decon_itself(int plane, const Array::array_xxf& r_data);
22  void find_ROI_by_decon_itself(int plane, const Array::array_xxf& r_data, const Array::array_xxf& r_data_tight);
23  void extend_ROI_self(int plane);
24  void create_ROI_connect_info(int plane);
25 
26  void find_ROI_loose(int plane, const Array::array_xxf& r_data);
27  void extend_ROI_loose(int plane);
28 
29 
30  void apply_roi(int plane, Array::array_xxf& r_data, int flag);
31 
32 
33  std::vector<std::pair<int,int>>& get_self_rois(int chid) {
34  if (chid < nwire_u){
35  return self_rois_u.at(chid);
36  }else if (chid < nwire_u + nwire_v){
37  return self_rois_v.at(chid - nwire_u);
38  }else{
39  return self_rois_w.at(chid - nwire_u - nwire_v);
40  }
41  }
42 
43  std::vector<std::pair<int,int>>& get_loose_rois(int chid) {
44  if (chid < nwire_u){
45  return loose_rois_u.at(chid);
46  }else if (chid < nwire_u + nwire_v){
47  return loose_rois_v.at(chid - nwire_u);
48  }else{
49  return loose_rois_w.at(chid - nwire_u - nwire_v);
50  }
51  }
52 
53  std::vector <float>& get_uplane_rms(){return uplane_rms;};
54  std::vector <float>& get_vplane_rms(){return vplane_rms;};
55  std::vector <float>& get_wplane_rms(){return wplane_rms;};
56 
57 
58  private:
59  double cal_RMS(Waveform::realseq_t signal);
60  double local_ave(Waveform::realseq_t& signal, int bin, int width);
61  int find_ROI_end(Waveform::realseq_t& signal, int bin, double th = 0, int jump_one_bin =0);
62  int find_ROI_begin(Waveform::realseq_t& signal, int bin, double th = 0, int jump_one_bin=0);
63 
64 
66  int nbins;
67 
68  // tight ROIs
70  int pad;
71  float asy;
72 
73  // loose ROI things
74  int rebin;
75  double l_factor;
76  double l_max_th;
77  double l_factor1;
80 
81 
82 
83  std::map<int,std::vector<std::pair<int,int>>> bad_ch_map;
84 
85  std::vector<std::vector<std::pair<int,int>>> self_rois_u; // tight ROIs
86  std::vector<std::vector<std::pair<int,int>>> self_rois_v; // tight ROIs
87  std::vector<std::vector<std::pair<int,int>>> self_rois_w; // tight ROIs
88 
89  std::vector<std::vector<std::pair<int,int>>> loose_rois_u; // tight ROIs
90  std::vector<std::vector<std::pair<int,int>>> loose_rois_v; // tight ROIs
91  std::vector<std::vector<std::pair<int,int>>> loose_rois_w; // tight ROIs
92 
93  std::vector<float> uplane_rms; // calibrated field response
94  std::vector<float> vplane_rms; // calibrated field response
95  std::vector<float> wplane_rms; // calibrated field response
96  };
97  }
98 }
99 
100 #endif
std::vector< std::pair< int, int > > & get_self_rois(int chid)
Definition: ROI_formation.h:33
std::vector< std::vector< std::pair< int, int > > > self_rois_u
Definition: ROI_formation.h:85
Sequence< real_t > realseq_t
Definition: Waveform.h:31
int find_ROI_end(Waveform::realseq_t &signal, int bin, double th=0, int jump_one_bin=0)
std::vector< std::vector< std::pair< int, int > > > loose_rois_w
Definition: ROI_formation.h:91
std::vector< float > uplane_rms
Definition: ROI_formation.h:93
std::vector< std::vector< std::pair< int, int > > > loose_rois_v
Definition: ROI_formation.h:90
std::map< int, std::vector< std::pair< int, int > > > bad_ch_map
Definition: ROI_formation.h:83
std::vector< std::vector< std::pair< int, int > > > loose_rois_u
Definition: ROI_formation.h:89
const double width
std::map< std::string, ChannelMasks > ChannelMaskMap
Collect channel masks by some label.
Definition: Waveform.h:59
std::vector< float > & get_wplane_rms()
Definition: ROI_formation.h:55
double cal_RMS(Waveform::realseq_t signal)
std::vector< std::vector< std::pair< int, int > > > self_rois_w
Definition: ROI_formation.h:87
int find_ROI_begin(Waveform::realseq_t &signal, int bin, double th=0, int jump_one_bin=0)
Definition: Main.h:22
void find_ROI_by_decon_itself(int plane, const Array::array_xxf &r_data)
QTextStream & bin(QTextStream &s)
void apply_roi(int plane, Array::array_xxf &r_data, int flag)
std::vector< std::pair< int, int > > & get_loose_rois(int chid)
Definition: ROI_formation.h:43
double local_ave(Waveform::realseq_t &signal, int bin, int width)
std::vector< float > & get_uplane_rms()
Definition: ROI_formation.h:53
ROI_formation(Waveform::ChannelMaskMap &cmm, int nwire_u, int nwire_v, int nwire_w, int nbins=9594, 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)
std::vector< std::vector< std::pair< int, int > > > self_rois_v
Definition: ROI_formation.h:86
std::vector< float > vplane_rms
Definition: ROI_formation.h:94
std::vector< float > wplane_rms
Definition: ROI_formation.h:95
std::vector< float > & get_vplane_rms()
Definition: ROI_formation.h:54
Eigen::ArrayXXf array_xxf
A real, 2D array.
Definition: Array.h:54
void find_ROI_loose(int plane, const Array::array_xxf &r_data)