Functions
test_diffuser.cxx File Reference
#include "WireCellGen/Diffuser.h"
#include "WireCellIface/IDiffusion.h"
#include "WireCellUtil/Testing.h"
#include "WireCellUtil/Units.h"
#include "TH2F.h"
#include "TStyle.h"
#include "TPolyMarker.h"
#include "MultiPdf.h"
#include <iostream>

Go to the source code of this file.

Functions

void dump_smear (IDiffusion::pointer smear)
 
void test_one ()
 
void test_plot_hist (MultiPdf &pdf)
 
int main (int argc, char *argv[])
 

Function Documentation

void dump_smear ( IDiffusion::pointer  smear)

Definition at line 22 of file test_diffuser.cxx.

23 {
24  cerr << "L: [ " << smear->lpos(0) << " , " << smear->lpos(smear->lsize()) << " ]"<< endl;
25  cerr << "L: [ " << smear->tpos(0) << " , " << smear->tpos(smear->tsize()) << " ]"<< endl;
26 
27  for (int tind = 0; tind < smear->tsize(); ++tind) {
28  for (int lind = 0; lind < smear->lsize(); ++lind) {
29  cerr << "\t" << smear->get(lind, tind);
30  }
31  cerr << endl;
32  }
33 }
QTextStream & endl(QTextStream &s)
int main ( int  argc,
char *  argv[] 
)

Definition at line 121 of file test_diffuser.cxx.

122 {
123  test_one();
124 
125  MultiPdf pdf(argv[0]);
126 
127  test_plot_hist(pdf);
128 
129  return 0;
130 }
void test_plot_hist(MultiPdf &pdf)
void test_one()
void test_one ( )

Definition at line 35 of file test_diffuser.cxx.

36 {
37  Ray pitch(Point(0,0,0), Point(0,0,10));
38 
39  // binsize_l, binsize_t
40  Diffuser diff(pitch, 1000);
41  // mean_l, mean_t, sigma_l, sigma_t
42  dump_smear(diff.diffuse(20000, 20, 2000, 2));
43 
44  for (double mean = -100; mean <= 100; mean += 0.11) {
45  Diffuser::bounds_type bb = diff.bounds(mean, 1.5, 1.0);
46  //cerr << "mean=" << mean << " [" << bb.first << " --> " << bb.second << "]" << endl;
47  Assert(bb.second - bb.first == 10.0);
48  }
49 }
std::pair< Point, Point > Ray
A line segment running from a first (tail) to a second (head) point.
Definition: Point.h:21
void dump_smear(IDiffusion::pointer smear)
#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::pair< double, double > bounds_type
Definition: Diffuser.h:34
double mean(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:15
void test_plot_hist ( MultiPdf pdf)

Definition at line 52 of file test_diffuser.cxx.

53 {
54  pdf.canvas.Clear();
55 
56  //const int nsigma = 3;
57  const double drift_velocity = 1.6 * units::mm/units::microsecond;
58  const double binsize_l = 0.5*units::microsecond*drift_velocity;
59  const double binsize_t = 5*units::mm;
60 
61  const double sigma_l = 3.0*units::microsecond*drift_velocity;
62  const double sigma_t = 3*units::mm;
63 
64  Ray pitch(Point(0,0,0), Point(0,0,binsize_t));
65 
66  Diffuser diff(pitch, binsize_l);
67 
68  vector< IDiffusion::pointer> diffs;
69  vector< pair<double,double> > pts;
70 
71  // make a diagnonal
72  for (double step=0; step<200; step += 5) {
73  double mean_l = (0.5+step)*binsize_l;
74  double mean_t = (0.5+step)*binsize_t;
75  diffs.push_back(diff.diffuse(mean_l, mean_t, sigma_l, sigma_t));
76  pts.push_back(make_pair(mean_l, mean_t));
77  }
78 
79  // and two isolated dots
80  diffs.push_back(diff.diffuse(10*binsize_l, 100*binsize_t, 3*sigma_l, 3*sigma_t, 10.0));
81  diffs.push_back(diff.diffuse(100*binsize_l, 10*binsize_t, 3*sigma_l, 3*sigma_t, 10.0));
82 
83  double min_l=0,min_t=0,max_l=0,max_t=0;
84  for (auto d : diffs) {
85  min_l = min(min_l, d->lpos(0));
86  min_t = min(min_t, d->tpos(0));
87  max_l = max(max_l, d->lpos(d->lsize()));
88  max_t = max(max_t, d->tpos(d->tsize()));
89  }
90 
91 
92  TH2F* h = new TH2F("smear","Smear",
93  (max_l-min_l)/binsize_l, min_l, max_l,
94  (max_t-min_t)/binsize_t, min_t, max_t);
95  for (auto smear : diffs) {
96  for (int tind = 0; tind < smear->tsize(); ++tind) {
97  for (int lind = 0; lind < smear->lsize(); ++lind) {
98  h->Fill(smear->lpos(lind,0.5), smear->tpos(tind,0.5), smear->get(lind, tind));
99  }
100  }
101  }
102 
103  h->SetXTitle("Longitudinal direction");
104  h->SetYTitle("Transverse direction");
105  h->Draw("colz");
106 
107  TPolyMarker* pm = new TPolyMarker;
108  pm->SetMarkerColor(5);
109  pm->SetMarkerStyle(8);
110  int count = 0;
111  for (auto xy : pts) {
112  pm->SetPoint(count++, xy.first, xy.second);
113  }
114  pm->Draw();
115 
116  gStyle->SetOptStat(11111111);
117  pdf();
118 }
std::pair< Point, Point > Ray
A line segment running from a first (tail) to a second (head) point.
Definition: Point.h:21
microsecond_as<> microsecond
Type of time stored in microseconds, in double precision.
Definition: spacetime.h:114
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
Definition: DCEL.h:34
static int max(int a, int b)
static const double mm
Definition: Units.h:73
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
h
training ###############################
Definition: train_cnn.py:186