Classes | Macros | Functions | Variables
AlgoThreshold_test.cc File Reference
#include "cetlib/quiet_unit_test.hpp"
#include "fhiclcpp/ParameterSet.h"
#include "larana/OpticalDetector/OpHitFinder/AlgoThreshold.h"

Go to the source code of this file.

Classes

struct  AlgoThresholdFixture
 

Macros

#define BOOST_TEST_MODULE   ( AlgoThreshold_test )
 

Functions

 BOOST_AUTO_TEST_CASE (checkZeroVector)
 
 BOOST_AUTO_TEST_CASE (checkNPulse)
 
 BOOST_AUTO_TEST_CASE (checkSquarePulse)
 
 BOOST_AUTO_TEST_CASE (checkTrianglePulse)
 
 BOOST_AUTO_TEST_CASE (checkNonZeroPed)
 
 BOOST_AUTO_TEST_CASE (checkPulseOffEnd)
 
 BOOST_AUTO_TEST_CASE (checkPulseOffFront)
 
 BOOST_AUTO_TEST_CASE (checkDoublePulse)
 

Variables

double const tolerance = 1e-6
 

Macro Definition Documentation

#define BOOST_TEST_MODULE   ( AlgoThreshold_test )

Definition at line 1 of file AlgoThreshold_test.cc.

Function Documentation

BOOST_AUTO_TEST_CASE ( checkZeroVector  )

Definition at line 19 of file AlgoThreshold_test.cc.

20 {
21 
22  std::vector<short> wf(20,0);
23  std::vector<double> ped_mean(20,0);
24  std::vector<double> ped_sigma(20,0.1);
25  myAlgoThreshold.Reconstruct(wf,ped_mean,ped_sigma);
26 
27  BOOST_CHECK_EQUAL(myAlgoThreshold.GetNPulse(),0ul);
28 
29  //BOOST_FAIL("This test fails");
30 
31 }
BOOST_AUTO_TEST_CASE ( checkNPulse  )

Definition at line 33 of file AlgoThreshold_test.cc.

34 {
35  std::vector<short> wf(20,0);
36  std::vector<double> ped_mean(20,0);
37  std::vector<double> ped_sigma(20,0.1);
38  wf[10]=10;
39 
40  myAlgoThreshold.Reconstruct(wf,ped_mean,ped_sigma);
41  BOOST_CHECK_EQUAL(myAlgoThreshold.GetNPulse(),1ul);
42  //BOOST_CHECK_NE(myAlgoThreshold.GetPulse(0),(void*)0);
43  //BOOST_CHECK_EQUAL(myAlgoThreshold.GetPulse(1),(void*)0);
44 
45 }
BOOST_AUTO_TEST_CASE ( checkSquarePulse  )

Definition at line 46 of file AlgoThreshold_test.cc.

47 {
48 
49  std::vector<short> wf(20,0);
50  std::vector<double> ped_mean(20,0);
51  std::vector<double> ped_sigma(20,0.1);
52  //
53 
54  double area = 0;
55  for(size_t iter=0; iter<wf.size(); iter++){
56  if(iter>5 && iter<15) {
57  wf[iter] += 10;
58  area += wf[iter];
59  }
60  }
61 
62  myAlgoThreshold.Reconstruct(wf,ped_mean,ped_sigma);
63 
64  BOOST_CHECK_EQUAL(myAlgoThreshold.GetNPulse(),1ul);
65  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).t_start,5,tolerance);
66  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).t_end,15,tolerance);
67  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).t_max,6,tolerance);
68  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).area,area,tolerance);
69  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).peak,10.0,tolerance);
70 }
double const tolerance
BOOST_AUTO_TEST_CASE ( checkTrianglePulse  )

Definition at line 72 of file AlgoThreshold_test.cc.

73 {
74 
75  std::vector<short> wf(20,0);
76  std::vector<double> ped_mean(20,0);
77  std::vector<double> ped_sigma(20,0.1);
78  //
79 
80  double area = 0;
81  for(size_t iter=0; iter<wf.size(); iter++){
82  if(iter<=10)
83  wf[iter] += iter;
84  else if(iter>10)
85  wf[iter] += 20-iter;
86 
87  if(wf[iter]>=3)
88  area += wf[iter];
89 
90  }
91 
92  myAlgoThreshold.Reconstruct(wf,ped_mean,ped_sigma);
93  BOOST_CHECK_EQUAL(myAlgoThreshold.GetNPulse(),1ul);
94  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).t_start,1,tolerance);
95  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).t_end,19,tolerance);
96  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).t_max,10,tolerance);
97  //BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).area,area,tolerance);
98  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).peak,10.0,tolerance);
99 }
double const tolerance
BOOST_AUTO_TEST_CASE ( checkNonZeroPed  )

Definition at line 101 of file AlgoThreshold_test.cc.

102 {
103 
104  double ped = 2;
105  std::vector<short> wf(20,(short)ped);
106  std::vector<double> ped_mean(20,ped);
107  std::vector<double> ped_sigma(20,0.1);
108 
109  double area = 0;
110  for(size_t iter=0; iter<wf.size(); iter++){
111  if(iter<=10)
112  wf[iter] += iter;
113  else if(iter>10)
114  wf[iter] += 20-iter;
115 
116  if(wf[iter]>=3+ped)
117  area += wf[iter] - ped;
118 
119  }
120 
121  myAlgoThreshold.Reconstruct(wf,ped_mean,ped_sigma);
122  BOOST_CHECK_EQUAL(myAlgoThreshold.GetNPulse(),1ul);
123  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).t_start,0,tolerance);
124  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).t_end,19,tolerance);
125  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).t_max,10,tolerance);
126  //BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).area,area,tolerance);
127  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).peak,10.0,tolerance);
128 }
double const tolerance
BOOST_AUTO_TEST_CASE ( checkPulseOffEnd  )

Definition at line 130 of file AlgoThreshold_test.cc.

131 {
132 
133  std::vector<short> wf(20,0);
134  std::vector<double> ped_mean(20,0);
135  std::vector<double> ped_sigma(20,0.1);
136 
137 
138  wf[18] = 5; wf[19] = 10;
139  double area = 15;
140 
141  myAlgoThreshold.Reconstruct(wf,ped_mean,ped_sigma);
142  BOOST_CHECK_EQUAL(myAlgoThreshold.GetNPulse(),1ul);
143  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).t_start,17,tolerance);
144  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).t_end,19,tolerance);
145  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).t_max,19,tolerance);
146  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).area,area,tolerance);
147  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).peak,10.0,tolerance);
148 }
double const tolerance
BOOST_AUTO_TEST_CASE ( checkPulseOffFront  )

Definition at line 150 of file AlgoThreshold_test.cc.

151 {
152 
153  std::vector<short> wf(20,0);
154  std::vector<double> ped_mean(20,0);
155  std::vector<double> ped_sigma(20,0.1);
156 
157 
158  wf[0] = 10; wf[1] = 5;
159  double area = 15;
160 
161  myAlgoThreshold.Reconstruct(wf,ped_mean,ped_sigma);
162  BOOST_CHECK_EQUAL(myAlgoThreshold.GetNPulse(),1ul);
163  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).t_start,0,tolerance);
164  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).t_end,2,tolerance);
165  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).t_max,0,tolerance);
166  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).area,area,tolerance);
167  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).peak,10.0,tolerance);
168 }
double const tolerance
BOOST_AUTO_TEST_CASE ( checkDoublePulse  )

Definition at line 170 of file AlgoThreshold_test.cc.

171 {
172 
173  std::vector<short> wf(20,0);
174  std::vector<double> ped_mean(20,0);
175  std::vector<double> ped_sigma(20,0.1);
176 
177 
178  wf[4] = 5; wf[5] = 10; wf[6] = 5;
179  wf[14] = 5; wf[15] = 10; wf[16] = 5;
180  double area = 20;
181 
182  myAlgoThreshold.Reconstruct(wf,ped_mean,ped_sigma);
183  BOOST_CHECK_EQUAL(myAlgoThreshold.GetNPulse(),2ul);
184 
185  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).t_start,3,tolerance);
186  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).t_end,7,tolerance);
187  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).t_max,5,tolerance);
188  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).area,area,tolerance);
189  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(0).peak,10.0,tolerance);
190 
191  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(1).t_start,13,tolerance);
192  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(1).t_end,17,tolerance);
193  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(1).t_max,15,tolerance);
194  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(1).area,area,tolerance);
195  BOOST_CHECK_CLOSE(myAlgoThreshold.GetPulse(1).peak,10.0,tolerance);
196 
197 }
double const tolerance

Variable Documentation

double const tolerance = 1e-6

Definition at line 15 of file AlgoThreshold_test.cc.