ToFPositionFinder.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vector>
4 #include <iostream>
5 #include <cmath>
6 #include <map>
7 
8 #include "TH2D.h"
9 
10 int HIST_N_BINS = 100;
11 
12 namespace beamlinereco {
13  //useful
14  struct posn_t { double x; double y; };
15  struct testset_t { double tA; double tB; double tC; double tD; double s; posn_t expected; };
16 
17  //for floating point comparisons
18  const double EPSILON = 1e-6;
19 
21  public:
23  virtual ~ToFPositionFinder() = default;
24 
25  // Find location in x and y (in ns) given 3 hit times
26  // A = (0,s), B = (0,0), C = (s,0)
27  posn_t Get3CornerPosition(double tA, double tB, double tC, double s);
28 
29  // Find location in x and y (in ns) given 4 hit times (by taking average)
30  // A = (0,s), B = (0,0), C = (s,0), D = (s,s)
31  posn_t Get4CornerPosition(double tA, double tB, double tC, double tD, double s);
32 
33  // Find the spread of the four reconstructed positions
34  // Calculates the sum of the squares of the distance
35  // from each reconstructed point to the center of mass for the 4
36  // reconstructed points.
37  double Get4CornerSpread(double tA, double tB, double tC, double tD, double s);
38 
39  // Produce a 2D histogram with vals of 1 for corners, val of 4 for mean.
40  TH2D GetSummaryHist(TString name, TString title, double tA, double tB, double tC, double tD, double s);
41 
42  // Test whether the given posn is physical (inside the counter) or not.
43  bool IsPhysical(posn_t p, double s);
44 
45  // Run some tests to make sure methods are doing what we think they are
46  bool RunTests();
47 
48  // Find the distance to the nearest corner
49  double GetDistanceToNearestCorner(posn_t p, double s);
50 
51  private:
52  private:
53  // Posn utilities
54  posn_t PosnAvg(std::vector<posn_t> posns);
55  double PosnDist(posn_t a, posn_t b);
56  double GetSpread(std::vector<posn_t> posns);
57  posn_t Transform90posn(posn_t p, double s);
58  posn_t RotateCoords(posn_t p, double s, int n);
59  double GetClosestDist(posn_t p, std::vector<posn_t> others);
60 
61  // Helpers for 4-corner method
62  std::vector<posn_t> Get4Posns(double tA, double tB, double tC, double tD, double s);
63 
64  // Helpers for RunTests
65  bool Run3CornerTest(testset_t ts);
66  bool Run3CornerTests();
67  bool Run4CornerTest(testset_t ts);
68  bool Run4CornerTests();
69  };
70 }
const XML_Char * name
Definition: expat.h:151
const char * p
Definition: xmltok.h:285
const double EPSILON
const XML_Char * s
Definition: expat.h:262
const double a
int HIST_N_BINS
const hit & b
Definition: hits.cxx:21
Float_t e
Definition: plot.C:35