Macros | Functions
Hit_test.cc File Reference

Simple test on a recob::Hit object. More...

#include <numeric>
#include "boost/test/unit_test.hpp"
#include "larcoreobj/SimpleTypesAndConstants/RawTypes.h"
#include "larcoreobj/SimpleTypesAndConstants/geo_types.h"
#include "lardataobj/RecoBase/Hit.h"

Go to the source code of this file.

Macros

#define BOOST_TEST_MODULE   ( hit_test )
 

Functions

void CheckHit (recob::Hit const &hit, raw::ChannelID_t channel, raw::TDCtick_t start_tick, raw::TDCtick_t end_tick, float peak_time, float sigma_peak_time, float rms, float peak_amplitude, float sigma_peak_amplitude, float summedADC, float hit_integral, float hit_sigma_integral, short int multiplicity, short int local_index, float goodness_of_fit, int dof, geo::View_t view, geo::SigType_t signal_type, geo::WireID wireID)
 
void HitTestDefaultConstructor ()
 
void HitTestCustomConstructors ()
 
 BOOST_AUTO_TEST_CASE (HitDefaultConstructor)
 
 BOOST_AUTO_TEST_CASE (HitCustomConstructors)
 

Detailed Description

Simple test on a recob::Hit object.

Author
Gianluca Petrillo (petri.nosp@m.llo@.nosp@m.fnal..nosp@m.gov)
Date
20150113
Version
1.0

This test simply creates recob::Hit objects and verifies that the values it can access are the right ones.

See http://www.boost.org/libs/test for the Boost test library home page.

Timing: version 1.0: ~1.5" (debug mode)

Definition in file Hit_test.cc.

Macro Definition Documentation

#define BOOST_TEST_MODULE   ( hit_test )

Definition at line 30 of file Hit_test.cc.

Function Documentation

BOOST_AUTO_TEST_CASE ( HitDefaultConstructor  )

Definition at line 300 of file Hit_test.cc.

300  {
302 }
void HitTestDefaultConstructor()
Definition: Hit_test.cc:152
BOOST_AUTO_TEST_CASE ( HitCustomConstructors  )

Definition at line 304 of file Hit_test.cc.

304  {
306 }
void HitTestCustomConstructors()
Definition: Hit_test.cc:208
void CheckHit ( recob::Hit const &  hit,
raw::ChannelID_t  channel,
raw::TDCtick_t  start_tick,
raw::TDCtick_t  end_tick,
float  peak_time,
float  sigma_peak_time,
float  rms,
float  peak_amplitude,
float  sigma_peak_amplitude,
float  summedADC,
float  hit_integral,
float  hit_sigma_integral,
short int  multiplicity,
short int  local_index,
float  goodness_of_fit,
int  dof,
geo::View_t  view,
geo::SigType_t  signal_type,
geo::WireID  wireID 
)

Definition at line 46 of file Hit_test.cc.

66  {
67 
68  // verify that the values are as expected
69  // - channel ID
70  BOOST_TEST(hit.Channel() == channel);
71 
72  // - view
73  BOOST_TEST(hit.View() == view);
74 
75  // - signal type
76  BOOST_TEST(hit.SignalType() == signal_type);
77 
78  // - start and end tick
79  BOOST_TEST(hit.StartTick() == start_tick);
80  BOOST_TEST(hit.EndTick() == end_tick);
81 
82  // - peak
83  BOOST_TEST(hit.PeakTime() == peak_time);
84  BOOST_TEST(hit.SigmaPeakTime() == sigma_peak_time);
85  BOOST_TEST(hit.PeakAmplitude() == peak_amplitude);
86  BOOST_TEST(hit.SigmaPeakAmplitude() == sigma_peak_amplitude);
87 
88  // the following comparisons are at 0.01%
89  BOOST_CHECK_CLOSE(hit.PeakTimePlusRMS(), peak_time + rms, 0.01);
90  BOOST_CHECK_CLOSE(hit.PeakTimeMinusRMS(), peak_time - rms, 0.01);
91 
92  for (float shift: { 0.0, 0.5, 1.0, 1.5, 2.0, 2.2 }) {
93 
94  const float time_up = peak_time + shift*rms;
95  const float time_down = peak_time - shift*rms;
96 
97  if (time_up == 0.) {
98  BOOST_CHECK_SMALL(hit.PeakTimePlusRMS(shift), 0.01F);
99  BOOST_CHECK_SMALL(hit.PeakTimeMinusRMS(-shift), 0.01F);
100  }
101  else {
102  BOOST_CHECK_CLOSE(hit.PeakTimePlusRMS(shift), time_up, 0.01F);
103  BOOST_CHECK_CLOSE(hit.PeakTimeMinusRMS(-shift), time_up, 0.01F);
104  }
105 
106  if (time_down == 0.) {
107  BOOST_CHECK_SMALL(hit.PeakTimePlusRMS(shift), 0.01F);
108  BOOST_CHECK_SMALL(hit.PeakTimeMinusRMS(-shift), 0.01F);
109  }
110  else {
111  BOOST_CHECK_CLOSE(hit.PeakTimeMinusRMS(shift), time_down, 0.01F);
112  BOOST_CHECK_CLOSE(hit.PeakTimePlusRMS(-shift), time_down, 0.01F);
113  }
114 
115  if (rms > 0.) {
116  if (shift == 0.) {
117  BOOST_CHECK_SMALL(hit.TimeDistanceAsRMS(time_up), 0.01F);
118  BOOST_CHECK_SMALL(hit.TimeDistanceAsRMS(time_down), 0.01F);
119  }
120  else {
121  BOOST_CHECK_CLOSE(hit.TimeDistanceAsRMS(time_up), shift, 0.01F);
122  BOOST_CHECK_CLOSE(hit.TimeDistanceAsRMS(time_down), -shift, 0.01F);
123  }
124  } // if rms is not 0
125 
126  } // for
127 
128  // - width
129  BOOST_TEST(hit.RMS() == rms);
130 
131  // - charge
132  BOOST_TEST(hit.SummedADC() == summedADC);
133  BOOST_TEST(hit.Integral() == hit_integral);
134  BOOST_TEST(hit.SigmaIntegral() == hit_sigma_integral);
135 
136  // - multiplicity
137  BOOST_TEST(hit.Multiplicity() == multiplicity);
138  BOOST_TEST(hit.LocalIndex() == local_index);
139  BOOST_TEST
140  (((hit.LocalIndex() < hit.Multiplicity()) || (hit.LocalIndex() == -1)));
141 
142  // - fit quality
143  BOOST_TEST(hit.GoodnessOfFit() == goodness_of_fit);
144  BOOST_TEST(hit.DegreesOfFreedom() == dof);
145 
146  // - wire ID
147  BOOST_TEST(hit.WireID() == wireID);
148 
149 } // CheckHit()
double rms(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:40
uint8_t channel
Definition: CRTFragment.hh:201
Detector simulation of raw signals on wires.
void HitTestCustomConstructors ( )

Definition at line 208 of file Hit_test.cc.

208  {
209 
210  //
211  // Part I: initialization of wire inputs
212  //
213  // these are the values expected for a default-constructed wire
215  std::vector<float> signal({
216  0.2, 1.2, 1.5, 2.0, 4.7,
217  12.8, 30.7, 85.2, 132.1, 154.7,
218  147.4, 127.0, 86.7, 29.3, 11.8,
219  4.5, 2.2, 1.5, 1.0, 0.3,
220  });
221  raw::TDCtick_t start_tick = 730;
222  raw::TDCtick_t end_tick = start_tick + signal.size();
223  float peak_time = start_tick + signal.size()/2 + 0.7;
224  float sigma_peak_time = 1.3;
225  float rms = signal.size() / 2.7;
226  float peak_amplitude = signal[signal.size()/2] - 0.3;
227  float sigma_peak_amplitude = 2.3;
228  float summedADC
229  = std::accumulate(signal.begin(), signal.end(), 0.0);
230  float hit_integral = summedADC * 0.97;
231  float hit_sigma_integral = peak_amplitude / 10.;
232  short int multiplicity = 2;
233  short int local_index = 1;
234  float goodness_of_fit = 0.95;
235  int dof = signal.size() - 3;
236  geo::View_t view = geo::kU;
237  geo::SigType_t signal_type = geo::kCollection;
238  geo::WireID wireID(0, 1, 2, 546);
239 
240 
241  //
242  // Part II: complete constructor
243  //
244  // step II.1: create a hit with the signal-copying constructor
245  recob::Hit hit1(
246  channel,
247  start_tick,
248  end_tick,
249  peak_time,
250  sigma_peak_time,
251  rms,
252  peak_amplitude,
253  sigma_peak_amplitude,
254  summedADC,
255  hit_integral,
256  hit_sigma_integral,
257  multiplicity,
258  local_index,
259  goodness_of_fit,
260  dof,
261  view,
262  signal_type,
263  wireID
264  );
265 
266  // step II.2: verify that the values are as expected
267  CheckHit(hit1,
268  channel,
269  start_tick,
270  end_tick,
271  peak_time,
272  sigma_peak_time,
273  rms,
274  peak_amplitude,
275  sigma_peak_amplitude,
276  summedADC,
277  hit_integral,
278  hit_sigma_integral,
279  multiplicity,
280  local_index,
281  goodness_of_fit,
282  dof,
283  view,
284  signal_type,
285  wireID
286  );
287 
288 } // HitTestCustomConstructors()
void CheckHit(recob::Hit const &hit, raw::ChannelID_t channel, raw::TDCtick_t start_tick, raw::TDCtick_t end_tick, float peak_time, float sigma_peak_time, float rms, float peak_amplitude, float sigma_peak_amplitude, float summedADC, float hit_integral, float hit_sigma_integral, short int multiplicity, short int local_index, float goodness_of_fit, int dof, geo::View_t view, geo::SigType_t signal_type, geo::WireID wireID)
Definition: Hit_test.cc:46
double rms(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:40
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
uint8_t channel
Definition: CRTFragment.hh:201
int TDCtick_t
Type representing a TDC tick.
Definition: RawTypes.h:25
Planes which measure U.
Definition: geo_types.h:129
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
Definition: RawTypes.h:32
enum geo::_plane_sigtype SigType_t
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
Signal from collection planes.
Definition: geo_types.h:146
void HitTestDefaultConstructor ( )

Definition at line 152 of file Hit_test.cc.

152  {
153 
154  //
155  // Part I: initialization of wire inputs
156  //
157  // these are the values expected for a default-constructed wire
159  raw::TDCtick_t start_tick = 0;
160  raw::TDCtick_t end_tick = 0;
161  float peak_time = 0.0;
162  float sigma_peak_time = -1.0;
163  float rms = 0.0;
164  float peak_amplitude = 0.0;
165  float sigma_peak_amplitude = -1.0;
166  float summedADC = 0.0;
167  float hit_integral = 0.0;
168  float hit_sigma_integral = -1.0;
169  short int multiplicity = 0;
170  short int local_index = -1;
171  float goodness_of_fit = 0.0;
172  int dof = -1;
173  geo::View_t view = geo::kUnknown;
174  geo::SigType_t signal_type = geo::kMysteryType;
175  geo::WireID wireID;
176 
177  //
178  // Part II: default constructor
179  //
180  // step II.1: create a hit with the default constructor
181  recob::Hit hit;
182 
183  // step II.2: verify that the values are as expected
184  CheckHit(hit,
185  channel,
186  start_tick,
187  end_tick,
188  peak_time,
189  sigma_peak_time,
190  rms,
191  peak_amplitude,
192  sigma_peak_amplitude,
193  summedADC,
194  hit_integral,
195  hit_sigma_integral,
196  multiplicity,
197  local_index,
198  goodness_of_fit,
199  dof,
200  view,
201  signal_type,
202  wireID
203  );
204 
205 } // HitTestDefaultConstructor()
Who knows?
Definition: geo_types.h:147
void CheckHit(recob::Hit const &hit, raw::ChannelID_t channel, raw::TDCtick_t start_tick, raw::TDCtick_t end_tick, float peak_time, float sigma_peak_time, float rms, float peak_amplitude, float sigma_peak_amplitude, float summedADC, float hit_integral, float hit_sigma_integral, short int multiplicity, short int local_index, float goodness_of_fit, int dof, geo::View_t view, geo::SigType_t signal_type, geo::WireID wireID)
Definition: Hit_test.cc:46
double rms(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:40
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
Unknown view.
Definition: geo_types.h:136
uint8_t channel
Definition: CRTFragment.hh:201
int TDCtick_t
Type representing a TDC tick.
Definition: RawTypes.h:25
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
Definition: RawTypes.h:32
enum geo::_plane_sigtype SigType_t
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28