Functions
test_pimpos.cxx File Reference
#include "WireCellUtil/Pimpos.h"
#include "WireCellUtil/Testing.h"
#include <iostream>
#include <sstream>
#include <string>

Go to the source code of this file.

Functions

template<typename Type >
std::string str (const std::pair< Type, Type > &tt)
 
int main ()
 

Function Documentation

int main ( void  )

Definition at line 19 of file test_pimpos.cxx.

20 {
21  const double pitch_dist = 3*units::mm;
22  const int nwires = 2001;
23  const double halfwireextent = pitch_dist * 0.5 * (nwires - 1);
24  cerr << "Wires at extremes +/- " << halfwireextent/units::mm << "mm\n";
25  Pimpos pimpos(nwires, -halfwireextent, halfwireextent);
26 
27  const Point zero(0,0,0);
28  const Point pt1(1*units::m,2*units::m,3*units::m);
29  const Point pt2(1*units::mm,2*units::mm,3*units::mm);
30 
31  for (int ind=0; ind<3; ++ind) {
32  cerr << "axis" << ind << ": " << pimpos.axis(ind) << endl;
33  }
34 
35  {
36  auto val = pimpos.relative(zero);
37  cerr << "relative: " << val << endl;
38  Assert(val == -1.0*pimpos.origin());
39  }
40 
41  {
42  auto val = pimpos.distance(zero, 0);
43  cerr << "distance 0: " << val << endl;
44  Assert (val == 0.0);
45  }
46 
47  auto rb = pimpos.region_binning();
48  cerr << str(rb.range()) << " " << str(rb.irange()) << " binsize:" << rb.binsize()/units::mm << "mm\n";
49  Assert(rb.nbins()==nwires);
50  Assert(rb.min()==-3001.5*units::mm);
51  Assert(rb.max()==3001.5*units::mm);
52  Assert(rb.binsize() == pitch_dist);
53 
54  Assert(rb.bin(0) == nwires/2);
55  Assert(rb.center(rb.bin(0)) == 0.0);
56 
57  Assert(rb.inside(0.0));
58  const double outside = halfwireextent+pitch_dist;
59  Assert(!rb.inside(outside));
60 
61  //auto ib = pimpos.impact_binning();
62 
63  const int center_wire = nwires/2;
64  auto center_wi = pimpos.closest(0.0);
65  Assert(center_wi.first == center_wire);
66  Assert(center_wi.second == 0);
67 
68  const int center_imp = pimpos.wire_impact(center_wire);
69  auto ref1 = pimpos.reflect(center_wire, center_imp+4);
70  Assert(ref1 == center_imp - 4);
71 
72 
73 
74  return 0;
75 
76 }
const int nwires
std::pair< int, int > closest(double pitch) const
Definition: Pimpos.cxx:34
static const double m
Definition: Units.h:79
const Point & origin() const
Return given 3-point origin for plane pitch.
Definition: Pimpos.h:85
const Binning & region_binning() const
Definition: Pimpos.h:109
double distance(const Point &pt, int axis=2) const
Definition: Pimpos.cxx:71
int reflect(int wireind, int impind) const
Definition: Pimpos.cxx:56
#define Assert
Definition: Testing.h:7
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
Definition: DCEL.h:34
std::string str(const std::pair< Type, Type > &tt)
Definition: test_pimpos.cxx:12
static const double mm
Definition: Units.h:73
int wire_impact(int wireind) const
Return the impact position index coincident with the wire index.
Definition: Pimpos.cxx:43
Pimpos pimpos(nwires, min_wire_pitch, max_wire_pitch)
Pitch-Impact-Position.
Definition: Pimpos.h:36
Vector relative(const Point &pt) const
Return the vector from the origin to the given point.
Definition: Pimpos.cxx:66
const Vector & axis(int i) const
Definition: Pimpos.h:89
QTextStream & endl(QTextStream &s)
template<typename Type >
std::string str ( const std::pair< Type, Type > &  tt)

Definition at line 12 of file test_pimpos.cxx.

13 {
14  stringstream ss;
15  ss << "[" << tt.first << "," << tt.second << "]";
16  return ss.str();
17 }
Definition: type_traits.h:56