EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CbmRichRingFitterEllipseMinuit.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CbmRichRingFitterEllipseMinuit.h
1 
9 #ifndef CBM_RICH_RING_FITTER_ELLIPSE_MINUIT
10 #define CBM_RICH_RING_FITTER_ELLIPSE_MINUIT
11 
13 #include "TFitterMinuit.h"
14 #include <vector>
15 
16 using std::vector;
17 
25 class FCNEllipse : public ROOT::Minuit2::FCNBase {
26 public:
31  const vector<Double_t>& x,
32  const vector<Double_t>& y) :
33  fX(x),
34  fY(y),
35  fErrorDef(1.)
36  {
37 
38  }
39 
44  {
45 
46  }
47 
51  virtual Double_t Up() const
52  {
53  return fErrorDef;
54  }
55 
59  virtual Double_t operator()(
60  const vector<Double_t>& par) const
61  {
62  Double_t r = 0.;
63  for(UInt_t i = 0; i < fX.size(); i++) {
64  Double_t ri = calcE(i, par);
65  r += ri * ri;
66  }
67  return r;
68  }
69 
75  Double_t calcE(
76  Int_t i,
77  const vector<Double_t>& par) const
78  {
79  Double_t d1 = sqrt( (fX[i] - par[0])*(fX[i] - par[0]) +
80  (fY[i] - par[1])*(fY[i] - par[1]) );
81  Double_t d2 = sqrt( (fX[i] - par[2])*(fX[i] - par[2]) +
82  (fY[i] - par[3])*(fY[i] - par[3]) );
83  Double_t ri = d1 + d2 - 2 * par[4];
84  return ri;
85  }
86 
87 
88  vector<Double_t> X() const {return fX;}
89 
90  vector<Double_t> Y() const {return fY;}
91 
92  void SetErrorDef(Double_t def) {fErrorDef = def;}
93 
94 private:
95  vector<Double_t> fX; // vector of X coordinates
96  vector<Double_t> fY; // vector of Y coordinates
97  Double_t fErrorDef;
98 };
99 
108 {
109 public:
110 
115 
120 
124  virtual void DoFit(
125  CbmRichRingLight *ring);
126 
127 private:
134  vector<double> DoFit(
135  const vector<double>& x,
136  const vector<double>& y);
137 
143  void TransformToRichRing(
144  CbmRichRingLight* ring,
145  const vector<double>& par);
146 };
147 
148 #endif