34
27
#include "src/common_cpp/Recon/SciFi/SimpleLine.hh"
35
28
#include "src/common_cpp/Recon/SciFi/SimpleCircle.hh"
30
/** @namespace SciFiTools
32
* Various tools encapsulated in a class for use with SciFi data
33
* (in particular during Pattern Recognition).
37
35
namespace SciFiTools {
39
37
/** @brief Calculates the turning angle of a spacepoint w.r.t. the x' axis
42
40
* x0 and y0 are used, it returns phi_0. Do not confuse the returned angle with phi_i itself,
43
41
* the turning angle wrt the x' axis not the x axis.
45
* @param xpos - x position of spacepoint
46
* @param ypos - y position of spacepoint
47
* @param circle - Contains the helix center
43
* @param[in] xpos - x position of spacepoint
44
* @param[in] ypos - y position of spacepoint
45
* @param[out] circle - Contains the helix center
46
* @return The turning angle
50
48
double calc_phi(double xpos, double ypos, const MAUS::SimpleCircle &circle);
52
50
/** @brief Calculate the residuals of a straight line to a spacepoint
53
* @param sp - The spacepoint
54
* @param line_x - The x projection of the line
55
* @param line_y - The y projection of the line
56
* @param dx - x residual
57
* @param dy - y residual
51
* @param[in] sp - The spacepoint
52
* @param[in] line_x - The x projection of the line
53
* @param[in] line_y - The y projection of the line
54
* @param[out] dx - x residual
55
* @param[out] dy - y residual
59
57
void calc_straight_residual(const MAUS::SciFiSpacePoint *sp, const MAUS::SimpleLine &line_x,
60
58
const MAUS::SimpleLine &line_y, double &dx, double &dy);
62
60
/** @brief Calculate the residual of a circle to a spacepoint
63
* @param sp - The spacepoint
64
* @param c - The circle (x0, y0 and rho must be set)
61
* @param[in] sp - The spacepoint
62
* @param[in] c - The circle (x0, y0 and rho must be set)
63
* @return The residual
66
65
double calc_circle_residual(const MAUS::SciFiSpacePoint *sp, const MAUS::SimpleCircle &c);
68
67
/** @brief Take two spoints and return 2 straight lines connecting them, 1 in x-z, 1 in y-z
69
* @param sp1 - The first spacepoint
70
* @param sp2 - The second spacepoint
71
* @param line_x - The output line in x-z
72
* @param line_y - The output line in y-z
68
* @param[in] sp1 - The first spacepoint
69
* @param[in] sp2 - The second spacepoint
70
* @param[out] line_x - The output line in x-z
71
* @param[out] line_y - The output line in y-z
74
73
void draw_line(const MAUS::SciFiSpacePoint *sp1, const MAUS::SciFiSpacePoint *sp2,
75
74
MAUS::SimpleLine &line_x, MAUS::SimpleLine &line_y);
79
78
* Calculate the determinant for a 3*3 ROOT matrix (the in-built ROOT method falls over
80
79
* in the case of a singular matrix)
82
* @param m - The 3*3 ROOT TMatrixD (a matrix of doubles)
81
* @param[in] m - The 3*3 ROOT TMatrixD (a matrix of doubles)
82
* @return The determinant
85
84
double det3by3(const TMatrixD &m);
90
89
* For 3 spacepoints we can make a simple circle without requiring least squares fitting.
91
90
* See the tracker documentation for a description of algorithms.
93
* @param sp1 - The first spacepoint
94
* @param sp2 - The second spacepoint
95
* @param sp3 - The third spacepoint
92
* @param[in] sp1 - The first spacepoint
93
* @param[in] sp2 - The second spacepoint
94
* @param[in] sp3 - The third spacepoint
95
* @return The output circle
97
97
MAUS::SimpleCircle make_3pt_circle(const MAUS::SciFiSpacePoint *sp1,
98
98
const MAUS::SciFiSpacePoint *sp2,
103
103
* Short function to calculate the remainder of a division of num / denom, slightly
104
104
* different to cmath's fod
106
* @param num - the numerator
107
* @param denom - the denominator
106
* @param[in] num - the numerator
107
* @param[in] denom - the denominator
108
* @return The remainder
109
110
double my_mod(const double num, const double denom);
111
/** @brief Count the number of stations that have unused spacepoint
112
* @param spnts_by_station - Input 2D vector of spacepoints sorted by station
112
/** @brief Count the number of stations that have unused spacepoints
113
* @param[in] spnts_by_station - Input 2D vector of spacepoints sorted by station
114
* @return Number of stations with unused spacepoints
114
116
int num_stations_with_unused_spnts(const MAUS::SpacePoint2dPArray &spnts_by_station);
116
/** @brief Changes dphi vector to ds vector (scalar multiplication of each element phi by R).
117
* @param R - radius of helix
118
* @param phi - vector containing turning angle for each spacepoint
118
/** @brief Changes phi vector to s vector (scalar multiplication of each element phi by R).
119
* @param[in] R - radius of helix
120
* @param[in] phi - vector containing turning angle for each spacepoint
121
* @return The s values
120
123
std::vector<double> phi_to_s(const double R, const std::vector<double> &phi);
122
/** @brief Print the x,y,z coordinates of each spacepoint in vector */
125
/** @brief Print the x,y,z coordinates of each spacepoint in vector
126
* @param[in] spnts The spacepoints
123
128
void print_spacepoint_xyz(const std::vector<MAUS::SciFiSpacePoint*> &spnts);
125
130
/** @brief Create a 2D vector of SciFi spacepoints sorted by tracker station
127
132
* Take an input vector of spacepoints and output a 2D vector of spacepoints
128
133
* where the first index is the station the spacepoint is located in.
130
* @param spnts - A vector of all the input spacepoints
131
* @param spnts_by_station - Output 2D vector of spacepoints sorted by station
135
* @param[in] spnts - A vector of all the input spacepoints
136
* @param[out] spnts_by_station - Output 2D vector of spacepoints sorted by station
134
139
void sort_by_station(const MAUS::SciFiSpacePointPArray &spnts,
139
144
* Take an input vector of spacepoints and output a 2D vector of spacepoints
140
145
* where the first index is the tracker the spacepoint is located in.
142
* @param spnts - A vector of all the input spacepoints
147
* @param[in] spnts - A vector of all the input spacepoints
148
* @return The sorted spacepoints
145
150
MAUS::SpacePoint2dPArray sort_by_tracker(const std::vector<MAUS::SciFiSpacePoint*> &spnts);
147
152
/** @brief Count and return how many tracker stations have at least 1 unused spacepoint
148
* @param spnts_by_station - Input 2D vector of spacepoints sorted by station
149
* @param stations_hit - Output vector holding the numbers of each station with at
150
* least 1 unused spacepoint
151
* @param stations_not_hit - Output vector holding the numbers of each station with
152
* no unused spacepoints
153
* @param[in] spnts_by_station Input 2D vector of spacepoints sorted by station
154
* @param[out] stations_hit Vector holding the numbers of each station with at
155
* least 1 unused spacepoint
156
* @param[out] stations_not_hit Vector holding the numbers of each station with
157
* no unused spacepoints
154
159
void stations_with_unused_spnts(const MAUS::SpacePoint2dPArray &spnts_by_station,
155
160
std::vector<int> &stations_hit,