~chris-rogers/maus/emr_mc_digitization

« back to all changes in this revision

Viewing changes to src/common_cpp/Recon/SciFi/LeastSquaresFitter.cc

  • Committer: Chris Rogers
  • Date: 2014-04-16 11:48:45 UTC
  • mfrom: (707 merge)
  • mto: This revision was merged to the branch mainline in revision 711.
  • Revision ID: chris.rogers@stfc.ac.uk-20140416114845-h3u3q7pdcxkxvovs
Update to trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include <CLHEP/Units/PhysicalConstants.h>
21
21
 
22
22
// MAUS headers
23
 
#include "src/common_cpp/Recon/SciFi/LSQFit.hh"
 
23
#include "src/common_cpp/Recon/SciFi/LeastSquaresFitter.hh"
24
24
#include "src/common_cpp/Utils/JsonWrapper.hh"
25
25
#include "src/common_cpp/Utils/Globals.hh"
26
26
 
27
27
namespace MAUS {
28
28
 
29
 
LSQFit::LSQFit(double sd_1to4, double sd_5, double R_res_cut) {
 
29
LeastSquaresFitter::LeastSquaresFitter(double sd_1to4, double sd_5, double R_res_cut) {
30
30
  _sd_1to4 = sd_1to4;
31
31
  _sd_5 = sd_5;
32
32
  _R_res_cut = R_res_cut;
33
33
}
34
34
 
35
 
LSQFit::~LSQFit() {}
 
35
LeastSquaresFitter::~LeastSquaresFitter() {}
36
36
 
37
 
bool LSQFit::LoadGlobals() {
 
37
bool LeastSquaresFitter::LoadGlobals() {
38
38
  if (!Globals::HasInstance()) {
39
39
    Json::Value *json = Globals::GetConfigurationCards();
40
40
    _sd_1to4 = (*json)["SciFiSD1To4"].asDouble();
46
46
  }
47
47
}
48
48
 
49
 
void LSQFit::linear_fit(const std::vector<double> &_x, const std::vector<double> &_y,
 
49
void LeastSquaresFitter::linear_fit(const std::vector<double> &_x, const std::vector<double> &_y,
50
50
                        const std::vector<double> &_y_err, SimpleLine &line) {
51
51
 
52
52
  int n_points = static_cast<int>(_x.size());
86
86
  line.set_chisq_dof(result[0][0] / n_points);
87
87
} // ~linear_fit(...)
88
88
 
89
 
bool LSQFit::circle_fit(const std::vector<SciFiSpacePoint*> &spnts, SimpleCircle &circle) {
 
89
bool LeastSquaresFitter::circle_fit(const std::vector<SciFiSpacePoint*> &spnts,
 
90
                                    SimpleCircle &circle) {
90
91
 
91
92
  int n_points = static_cast<int>(spnts.size());
92
93
  CLHEP::HepMatrix A(n_points, 3); // rows, columns
135
136
  else
136
137
    R = sqrt((4 * alpha) + (beta * beta) + (gamma * gamma)) / (2 * alpha);
137
138
 
138
 
  if ( R < 0. )
139
 
    std::cout << "R was < 0 geometrically but taking abs_val for physical correctness\n";
 
139
  // if ( R < 0. )
 
140
  //  std::cout << "R was < 0 but taking abs_val for physical correctness\n";
140
141
  R = fabs(R);
141
142
 
142
143
  if (R > _R_res_cut) return false; // Cannot be larger than 150mm or the track is not contained