Class Reference for E1039 Core & Analysis Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SQTrackletFitter.cxx
Go to the documentation of this file.
1 #include "SQTrackletFitter.h"
2 
3 #include <phool/recoConsts.h>
4 
6 {
7  nParameters = KMAG_ON ? 5 : 4;
8 
10  tx_max = rc->get_DoubleFlag("TX_MAX");
11  ty_max = rc->get_DoubleFlag("TY_MAX");
12  x0_max = rc->get_DoubleFlag("X0_MAX");
13  y0_max = rc->get_DoubleFlag("Y0_MAX");
14  invP_min = rc->get_DoubleFlag("INVP_MIN");
15  invP_max = rc->get_DoubleFlag("INVP_MAX");
16 
17  minimizer = ROOT::Math::Factory::CreateMinimizer("Minuit2", "Combined");
18  fcn = ROOT::Math::Functor(&tracklet_fit, &Tracklet::Eval, nParameters);
19 
20  minimizer->SetMaxFunctionCalls(1000000);
21  minimizer->SetMaxIterations(100);
22  minimizer->SetTolerance(1E-2);
23  minimizer->SetFunction(fcn);
24  minimizer->SetPrintLevel(0);
25 }
26 
28 {
29  delete minimizer;
30 }
31 
33 {
34  tracklet_fit = tracklet;
35 
36  minimizer->SetLimitedVariable(0, "tx", tracklet.tx, 0.001, -tx_max, tx_max);
37  minimizer->SetLimitedVariable(1, "ty", tracklet.ty, 0.001, -ty_max, ty_max);
38  minimizer->SetLimitedVariable(2, "x0", tracklet.x0, 0.1, -x0_max, x0_max);
39  minimizer->SetLimitedVariable(3, "y0", tracklet.y0, 0.1, -y0_max, y0_max);
40  if(nParameters == 5)
41  {
42  minimizer->SetLimitedVariable(4, "invP", tracklet.invP, 0.001*tracklet.invP, invP_min, invP_max);
43  }
44 
45  minimizer->Minimize();
46 
47  //update the track parameters
48  tracklet.tx = minimizer->X()[0];
49  tracklet.ty = minimizer->X()[1];
50  tracklet.x0 = minimizer->X()[2];
51  tracklet.y0 = minimizer->X()[3];
52 
53  tracklet.err_tx = minimizer->Errors()[0];
54  tracklet.err_ty = minimizer->Errors()[1];
55  tracklet.err_x0 = minimizer->Errors()[2];
56  tracklet.err_y0 = minimizer->Errors()[3];
57 
59  if (tracklet.err_tx < 1e-6) tracklet.err_tx = 1e-6;
60  if (tracklet.err_ty < 1e-6) tracklet.err_ty = 1e-6;
61  if (tracklet.err_x0 < 1e-4) tracklet.err_x0 = 1e-4;
62  if (tracklet.err_y0 < 1e-4) tracklet.err_y0 = 1e-4;
63 
64  if(nParameters == 5)
65  {
66  tracklet.invP = minimizer->X()[4];
67  tracklet.err_invP = minimizer->Errors()[4];
68  }
69 
70  tracklet.chisq = minimizer->MinValue();
71  return minimizer->Status();
72 }
virtual double get_DoubleFlag(const std::string &name) const
Definition: PHFlag.cc:49
SQTrackletFitter(bool KMAG_ON=true)
int fit(Tracklet &tracklet)
core function - fit the tracklet and return the fit status
double invP
Definition: FastTracklet.h:239
double err_invP
Definition: FastTracklet.h:245
double y0
Definition: FastTracklet.h:238
double ty
Definition: FastTracklet.h:236
double err_y0
Definition: FastTracklet.h:244
double err_x0
Definition: FastTracklet.h:243
double tx
Definition: FastTracklet.h:235
double Eval(const double *par)
double x0
Definition: FastTracklet.h:237
double chisq
Definition: FastTracklet.h:222
double err_tx
Definition: FastTracklet.h:241
double err_ty
Definition: FastTracklet.h:242
static recoConsts * instance()
Definition: recoConsts.cc:7