~christopher-hunt08/maus/maus_integrated_kalman

« back to all changes in this revision

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

merging in changes in merge branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 
33
33
// External libs headers
34
34
#include "TROOT.h"
 
35
#include "TFile.h"
 
36
#include "TH1D.h"
35
37
#include "TMatrixD.h"
36
38
 
37
39
// MAUS headers
52
54
  return (sp1->get_position().z() > sp2->get_position().z());
53
55
}
54
56
 
55
 
PatternRecognition::PatternRecognition(): _up_straight_pr_on(true),
 
57
PatternRecognition::PatternRecognition(): _debug(false),
 
58
                                          _up_straight_pr_on(true),
56
59
                                          _down_straight_pr_on(true),
57
60
                                          _up_helical_pr_on(true),
58
61
                                          _down_helical_pr_on(true),
72
75
                                          _n_turns_cut(0.75),
73
76
                                          _sz_chisq_cut(4.0),
74
77
                                          _Pt_max(180.0),
75
 
                                          _Pz_min(50.0) {
 
78
                                          _Pz_min(50.0),
 
79
                                          _rfile(NULL),
 
80
                                          _hx(NULL),
 
81
                                          _hy(NULL),
 
82
                                          _hxchisq(NULL),
 
83
                                          _hychisq(NULL) {
 
84
  // Do nothing
76
85
}
77
86
 
78
87
void PatternRecognition::set_parameters_to_default() {
 
88
  _debug = false;
79
89
  _up_straight_pr_on = true;
80
90
  _down_straight_pr_on = true;
81
91
  _up_helical_pr_on = true;
100
110
}
101
111
 
102
112
PatternRecognition::~PatternRecognition() {
103
 
  // Do nothing
 
113
  if (_debug) {
 
114
    if (_rfile) _rfile->cd();
 
115
    if (_hx) _hx->Write();
 
116
    if (_hy) _hy->Write();
 
117
    if (_hxchisq) _hxchisq->Write();
 
118
    if (_hychisq) _hychisq->Write();
 
119
  }
 
120
}
 
121
 
 
122
void PatternRecognition::setup_debug() {
 
123
  _debug = true;
 
124
  _rfile = new TFile("pattern_recongition_debug.root", "RECREATE");
 
125
  _hx = new TH1D("hx", "Pattern Recongition Road X Residuals", 200, -150, 150);
 
126
  _hy = new TH1D("hy", "Pattern Recongition Road Y Residuals", 500, -150, 150);
 
127
  _hxchisq = new TH1D("hxchisq", "Pattern Recongition Straight Fit x ChiSq", 200, 0, 500);
 
128
  _hychisq = new TH1D("hychisq", "Pattern Recongition Straight Fit y ChiSq", 200, 0, 500);
 
129
  _hx->Write();
 
130
  _hy->Write();
 
131
  _hxchisq->Write();
 
132
  _hychisq->Write();
104
133
}
105
134
 
106
135
bool PatternRecognition::LoadGlobals() {
396
425
                                     const std::vector<int> ignore_stations,
397
426
                                     SpacePoint2dPArray &spnts_by_station,
398
427
                                     std::vector<SciFiStraightPRTrack*> &strks) const {
 
428
 
 
429
  // Set up a secondary ROOT file to hold non-standard debug data
 
430
  if (_rfile && _debug) _rfile->cd();
 
431
 
399
432
  // Set inner and outer stations
400
433
  int o_st_num = -1, i_st_num = -1;
401
434
  set_end_stations(ignore_stations, o_st_num, i_st_num);
458
491
              double dx = (mx * pos.z() + cx) - pos.x();
459
492
              double dy = (my * pos.z() + cy) - pos.y();
460
493
              // Perpendicular residuals
461
 
              // dx = fabs(pos.x() - (cx + mx*pos.z())) / sqrt(1.0 + mx*mx);
462
 
              // dy = fabs(pos.y() - (cy + my*pos.z())) / sqrt(1.0 + my*my);
 
494
              // double dx = fabs(pos.x() - (cx + mx*pos.z())) / sqrt(1.0 + mx*mx);
 
495
              // double dy = fabs(pos.y() - (cy + my*pos.z())) / sqrt(1.0 + my*my);
 
496
              if (_hx && _debug) _hx->Fill(dx);
 
497
              if (_hy && _debug) _hy->Fill(dy);
463
498
              if ( fabs(dx) < _res_cut && fabs(dy) < _res_cut )  {
464
499
                if ( delta_sq > (dx*dx + dy*dy) ) {
465
500
                  delta_sq = dx*dx + dy*dy;
518
553
        std::vector<double> covariance(a1, &a1[16]);
519
554
 
520
555
        // Check track passes chisq test, then create SciFiStraightPRTrack
 
556
        if (_hxchisq && _debug) _hxchisq->Fill(( line_x.get_chisq() / ( n_points - 2 )));
 
557
        if (_hychisq && _debug) _hychisq->Fill(( line_y.get_chisq() / ( n_points - 2 )));
521
558
        if ( ( line_x.get_chisq() / ( n_points - 2 ) < _straight_chisq_cut ) &&
522
559
            ( line_y.get_chisq() / ( n_points - 2 ) < _straight_chisq_cut ) ) {
523
560