Public Member Functions | Private Attributes | List of all members
WireCell::SigProc::SignalROI Class Reference

#include <SignalROI.h>

Public Member Functions

 SignalROI (int plane, int chid, int start_bin, int end_bin, const Waveform::realseq_t &signal)
 
 SignalROI (SignalROI *roi)
 
 ~SignalROI ()
 
int get_start_bin ()
 
int get_end_bin ()
 
int get_ext_start_bin ()
 
int get_ext_end_bin ()
 
void set_ext_start_bin (int a)
 
void set_ext_end_bin (int a)
 
int get_chid ()
 
int get_plane ()
 
std::vector< float > & get_contents ()
 
std::vector< std::pair< int, int > > get_above_threshold (float th)
 
double get_average_heights ()
 
double get_max_height ()
 
bool overlap (SignalROI *roi)
 
bool overlap (SignalROI *roi1, float th, float th1)
 

Private Attributes

int plane
 
int chid
 
int start_bin
 
int end_bin
 
int ext_start_bin
 
int ext_end_bin
 
std::vector< float > contents
 

Detailed Description

Definition at line 14 of file SignalROI.h.

Constructor & Destructor Documentation

SignalROI::SignalROI ( int  plane,
int  chid,
int  start_bin,
int  end_bin,
const Waveform::realseq_t signal 
)

Definition at line 8 of file SignalROI.cxx.

9  : plane(plane)
10  , chid(chid)
12  , end_bin(end_bin)
13 {
14  float start_content = signal.at(start_bin);
15  float end_content = signal.at(end_bin);
16  contents.resize(end_bin-start_bin+1);
17 
18  for (int i=start_bin; i<= end_bin; i++){
19  float content = signal.at(i) - ((end_content - start_content)*(i-start_bin)/(end_bin-start_bin) + start_content);
20  contents.at(i-start_bin) = content;
21  }
22 }
std::vector< float > contents
Definition: SignalROI.h:48
SignalROI::SignalROI ( SignalROI roi)

Definition at line 24 of file SignalROI.cxx.

24  {
25  plane = roi->get_plane();
26  chid = roi->get_chid();
27  start_bin = roi->get_start_bin();
28  end_bin = roi->get_end_bin();
29  for (int i=start_bin; i<=end_bin;i++){
30  contents.push_back(roi->get_contents().at(i-start_bin));
31  }
32 }
std::vector< float > contents
Definition: SignalROI.h:48
std::vector< float > & get_contents()
Definition: SignalROI.h:30
SignalROI::~SignalROI ( )

Definition at line 104 of file SignalROI.cxx.

104  {
105 }

Member Function Documentation

std::vector< std::pair< int, int > > SignalROI::get_above_threshold ( float  th)

Definition at line 109 of file SignalROI.cxx.

109  {
110  std::vector<std::pair<int,int>> bins;
111  for (int i=0;i<int(contents.size());i++){
112  if (contents.at(i) > th){
113  int start = i;
114  int end = i;
115  for (int j=i+1;j<int(contents.size());j++){
116  if (contents.at(j) > th){
117  end = j;
118  }else{
119  break;
120  }
121  }
122  bins.push_back(std::make_pair(start,end));
123  i = end;
124  }
125  }
126 
127  return bins;
128 }
std::vector< float > contents
Definition: SignalROI.h:48
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:72
double SignalROI::get_average_heights ( )

Definition at line 43 of file SignalROI.cxx.

43  {
44  double sum1 = 0;
45  double sum2 = 0;
46  for (size_t i=0;i!=contents.size();i++){
47  sum1 += contents.at(i);
48  sum2 ++;
49  }
50  if (sum2!=0){
51  return sum1/sum2;
52  }else{
53  return 0;
54  }
55 }
Val sum2(const Sequence< Val > &seq)
Return sum of square of all entries in sequence.
Definition: Waveform.h:184
std::vector< float > contents
Definition: SignalROI.h:48
int WireCell::SigProc::SignalROI::get_chid ( )
inline

Definition at line 28 of file SignalROI.h.

28 {return chid;}
std::vector<float>& WireCell::SigProc::SignalROI::get_contents ( )
inline

Definition at line 30 of file SignalROI.h.

30 {return contents;}
std::vector< float > contents
Definition: SignalROI.h:48
int WireCell::SigProc::SignalROI::get_end_bin ( )
inline

Definition at line 20 of file SignalROI.h.

20 {return end_bin;}
int WireCell::SigProc::SignalROI::get_ext_end_bin ( )
inline

Definition at line 23 of file SignalROI.h.

int WireCell::SigProc::SignalROI::get_ext_start_bin ( )
inline

Definition at line 22 of file SignalROI.h.

double SignalROI::get_max_height ( )

Definition at line 34 of file SignalROI.cxx.

34  {
35  double max = -1e9;
36  for (size_t i=0;i!=contents.size();i++){
37  if (max < contents.at(i))
38  max = contents.at(i);
39  }
40  return max;
41 }
std::vector< float > contents
Definition: SignalROI.h:48
static int max(int a, int b)
int WireCell::SigProc::SignalROI::get_plane ( )
inline

Definition at line 29 of file SignalROI.h.

29 {return plane;}
int WireCell::SigProc::SignalROI::get_start_bin ( )
inline

Definition at line 19 of file SignalROI.h.

bool SignalROI::overlap ( SignalROI roi)

Definition at line 80 of file SignalROI.cxx.

80  {
81 
82  int min_start_bin = start_bin;
83  if (start_bin < roi->get_start_bin())
84  min_start_bin = roi->get_start_bin();
85  int min_end_bin = end_bin;
86  if (end_bin > roi->get_end_bin())
87  min_end_bin = roi->get_end_bin();
88  if (min_end_bin > min_start_bin){
89  return true;
90  }else{
91  return false;
92  }
93  // if (start_bin < roi->get_end_bin() && end_bin >= roi->get_end_bin())
94  // return true;
95  // if (start_bin <= roi->get_start_bin() && end_bin > roi->get_start_bin())
96  // return true;
97  // if (start_bin >= roi->get_start_bin() && end_bin <= roi->get_end_bin())
98  // return true;
99  //return false;
100 }
bool SignalROI::overlap ( SignalROI roi1,
float  th,
float  th1 
)

Definition at line 57 of file SignalROI.cxx.

57  {
58  int min_start_bin = start_bin;
59  if (start_bin < roi1->get_start_bin())
60  min_start_bin = roi1->get_start_bin();
61  int min_end_bin = end_bin;
62  if (end_bin > roi1->get_end_bin())
63  min_end_bin = roi1->get_end_bin();
64  if (min_end_bin > min_start_bin){
65  std::vector<float>& contents1 = roi1->get_contents();
66 
67  for (int i=min_start_bin; i<= min_end_bin; i++){
68  if (contents.at(i-start_bin) > th &&
69  contents1.at(i-roi1->get_start_bin())>th1){
70  return true;
71  }
72  }
73 
74  return false;
75  }else{
76  return false;
77  }
78 }
std::vector< float > contents
Definition: SignalROI.h:48
std::vector< float > & get_contents()
Definition: SignalROI.h:30
void WireCell::SigProc::SignalROI::set_ext_end_bin ( int  a)
inline

Definition at line 26 of file SignalROI.h.

26 {ext_end_bin = a;}
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1124
void WireCell::SigProc::SignalROI::set_ext_start_bin ( int  a)
inline

Definition at line 25 of file SignalROI.h.

25 {ext_start_bin = a;}
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1124

Member Data Documentation

int WireCell::SigProc::SignalROI::chid
private

Definition at line 40 of file SignalROI.h.

std::vector<float> WireCell::SigProc::SignalROI::contents
private

Definition at line 48 of file SignalROI.h.

int WireCell::SigProc::SignalROI::end_bin
private

Definition at line 42 of file SignalROI.h.

int WireCell::SigProc::SignalROI::ext_end_bin
private

Definition at line 45 of file SignalROI.h.

int WireCell::SigProc::SignalROI::ext_start_bin
private

Definition at line 44 of file SignalROI.h.

int WireCell::SigProc::SignalROI::plane
private

Definition at line 39 of file SignalROI.h.

int WireCell::SigProc::SignalROI::start_bin
private

Definition at line 41 of file SignalROI.h.


The documentation for this class was generated from the following files: