~christopher-hunt08/maus/maus_integrated_kalman

« back to all changes in this revision

Viewing changes to src/common_cpp/Recon/SciFi/SciFiTools.hh

MAUS-v2.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 *
16
16
 */
17
17
 
18
 
/** @namespace SciFiTools
19
 
 *
20
 
 * Various tools encapsulated in a class for use with SciFi data
21
 
 * (in particular during Pattern Recognition).
22
 
 *
23
 
 */
24
 
 
25
18
// C++ headers
26
19
#include <vector>
27
20
 
34
27
#include "src/common_cpp/Recon/SciFi/SimpleLine.hh"
35
28
#include "src/common_cpp/Recon/SciFi/SimpleCircle.hh"
36
29
 
 
30
/** @namespace SciFiTools
 
31
 *
 
32
 * Various tools encapsulated in a class for use with SciFi data
 
33
 * (in particular during Pattern Recognition).
 
34
 */
37
35
namespace SciFiTools {
38
36
 
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.
44
42
     * 
45
 
     * @param xpos - x position of spacepoint
46
 
     * @param ypos - y position of  spacepoint
47
 
     * @param circle - Contains the helix center
48
 
     *
 
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
49
47
     */
50
48
    double calc_phi(double xpos, double ypos, const MAUS::SimpleCircle &circle);
51
49
 
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
58
56
     */
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);
61
59
 
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
65
64
     */
66
65
    double calc_circle_residual(const MAUS::SciFiSpacePoint *sp, const MAUS::SimpleCircle &c);
67
66
 
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
73
72
     */
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)
81
80
     *
82
 
     * @param m - The 3*3 ROOT TMatrixD (a matrix of doubles)
83
 
     *
 
81
     *  @param[in] m - The 3*3 ROOT TMatrixD (a matrix of doubles)
 
82
     *  @return The determinant
84
83
     */
85
84
    double det3by3(const TMatrixD &m);
86
85
 
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.
92
91
     *
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
96
96
     */
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
105
105
     *
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
108
109
     */
109
110
    double my_mod(const double num, const double denom);
110
111
 
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
113
115
     */
114
116
    int num_stations_with_unused_spnts(const MAUS::SpacePoint2dPArray &spnts_by_station);
115
117
 
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
119
122
     */
120
123
     std::vector<double> phi_to_s(const double R, const std::vector<double> &phi);
121
124
 
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
 
127
      */
123
128
     void print_spacepoint_xyz(const std::vector<MAUS::SciFiSpacePoint*> &spnts);
124
129
 
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.
129
134
     *
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
132
137
     *
133
138
     */
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.
141
146
     *
142
 
     *  @param spnts - A vector of all the input spacepoints
143
 
     *
 
147
     *  @param[in] spnts - A vector of all the input spacepoints
 
148
     *  @return The sorted spacepoints
144
149
     */
145
150
    MAUS::SpacePoint2dPArray sort_by_tracker(const std::vector<MAUS::SciFiSpacePoint*> &spnts);
146
151
 
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
153
158
     */
154
159
    void stations_with_unused_spnts(const MAUS::SpacePoint2dPArray &spnts_by_station,
155
160
                                    std::vector<int> &stations_hit,