30 ClassImp(TSpectrum2Fit);
 
   35 TSpectrum2Fit::TSpectrum2Fit() :TNamed(
"Spectrum2Fit", 
"Miroslav Morhac peak fitter")
 
   38    fNumberIterations = 1;
 
   43    fStatisticType = kFitOptimChiCounts;
 
   44    fAlphaOptim    = kFitAlphaHalving;
 
   46    fFitTaylor     = kFitTaylorOrderFirst;
 
  150 TSpectrum2Fit::TSpectrum2Fit(Int_t numberPeaks) :TNamed(
"Spectrum2Fit", 
"Miroslav Morhac peak fitter")
 
  152    if (numberPeaks <= 0){
 
  153       Error (
"TSpectrum2Fit",
"Invalid number of peaks, must be > than 0");
 
  156    fNPeaks = numberPeaks;
 
  157    fNumberIterations = 1;
 
  162    fStatisticType = kFitOptimChiCounts;
 
  163    fAlphaOptim = kFitAlphaHalving;
 
  165    fFitTaylor = kFitTaylorOrderFirst;
 
  168    fPositionInitX   = 
new Double_t[numberPeaks];
 
  169    fPositionCalcX   = 
new Double_t[numberPeaks];
 
  170    fPositionErrX    = 
new Double_t[numberPeaks];
 
  171    fPositionInitY   = 
new Double_t[numberPeaks];
 
  172    fPositionCalcY   = 
new Double_t[numberPeaks];
 
  173    fPositionErrY    = 
new Double_t[numberPeaks];
 
  174    fPositionInitX1  = 
new Double_t[numberPeaks];
 
  175    fPositionCalcX1  = 
new Double_t[numberPeaks];
 
  176    fPositionErrX1   = 
new Double_t[numberPeaks];
 
  177    fPositionInitY1  = 
new Double_t[numberPeaks];
 
  178    fPositionCalcY1  = 
new Double_t[numberPeaks];
 
  179    fPositionErrY1   = 
new Double_t[numberPeaks];
 
  180    fAmpInit    = 
new Double_t[numberPeaks];
 
  181    fAmpCalc    = 
new Double_t[numberPeaks];
 
  182    fAmpErr     = 
new Double_t[numberPeaks];
 
  183    fAmpInitX1  = 
new Double_t[numberPeaks];
 
  184    fAmpCalcX1  = 
new Double_t[numberPeaks];
 
  185    fAmpErrX1   = 
new Double_t[numberPeaks];
 
  186    fAmpInitY1  = 
new Double_t[numberPeaks];
 
  187    fAmpCalcY1  = 
new Double_t[numberPeaks];
 
  188    fAmpErrY1   = 
new Double_t[numberPeaks];
 
  189    fVolume     = 
new Double_t[numberPeaks];
 
  190    fVolumeErr  = 
new Double_t[numberPeaks];
 
  233    fFixPositionX    = 
new Bool_t[numberPeaks];
 
  234    fFixPositionY    = 
new Bool_t[numberPeaks];
 
  235    fFixPositionX1   = 
new Bool_t[numberPeaks];
 
  236    fFixPositionY1   = 
new Bool_t[numberPeaks];
 
  237    fFixAmp     = 
new Bool_t[numberPeaks];
 
  238    fFixAmpX1   = 
new Bool_t[numberPeaks];
 
  239    fFixAmpY1   = 
new Bool_t[numberPeaks];
 
  259 TSpectrum2Fit::~TSpectrum2Fit()
 
  261    delete [] fPositionInitX;
 
  262    delete [] fPositionCalcX;
 
  263    delete [] fPositionErrX;
 
  264    delete [] fFixPositionX;
 
  265    delete [] fPositionInitY;
 
  266    delete [] fPositionCalcY;
 
  267    delete [] fPositionErrY;
 
  268    delete [] fFixPositionY;
 
  269    delete [] fPositionInitX1;
 
  270    delete [] fPositionCalcX1;
 
  271    delete [] fPositionErrX1;
 
  272    delete [] fFixPositionX1;
 
  273    delete [] fPositionInitY1;
 
  274    delete [] fPositionCalcY1;
 
  275    delete [] fPositionErrY1;
 
  276    delete [] fFixPositionY1;
 
  281    delete [] fAmpInitX1;
 
  282    delete [] fAmpCalcX1;
 
  285    delete [] fAmpInitY1;
 
  286    delete [] fAmpCalcY1;
 
  290    delete [] fVolumeErr;
 
  298 Double_t TSpectrum2Fit::Erfc(Double_t x)
 
  300    Double_t da1 = 0.1740121, da2 = -0.0479399, da3 = 0.3739278, dap =
 
  313    c = c * t * (da1 + t * (da2 + t * da3));
 
  322 Double_t TSpectrum2Fit::Derfc(Double_t x)
 
  325    Double_t da1 = 0.1740121, da2 = -0.0479399, da3 = 0.3739278, dap =
 
  337    c = (-1.) * dap * c * t * t * (da1 + t * (2. * da2 + t * 3. * da3)) -
 
  345 Double_t TSpectrum2Fit::Ourpowl(Double_t a, Int_t pw)
 
  355    if (pw > 10) c *= a2;
 
  356    if (pw > 12) c *= a2;
 
  372 void TSpectrum2Fit::StiefelInversion(Double_t **a, Int_t size)
 
  375    Double_t sk = 0, b, lambdak, normk, normk_old = 0;
 
  381       for (i = 0; i < size; i++) {
 
  382          a[i][size + 2] = -a[i][size]; 
 
  383          for (j = 0; j < size; j++) {
 
  384             a[i][size + 2] += a[i][j] * a[j][size + 1]; 
 
  386          normk += a[i][size + 2] * a[i][size + 2]; 
 
  391          sk = normk / normk_old;
 
  395       for (i = 0; i < size; i++) {
 
  396          a[i][size + 3] = -a[i][size + 2] + sk * a[i][size + 3]; 
 
  401       for (i = 0; i < size; i++) {
 
  402          for (j = 0, b = 0; j < size; j++) {
 
  403             b += a[i][j] * a[j][size + 3]; 
 
  405          lambdak += b * a[i][size + 3];
 
  407       if (TMath::Abs(lambdak) > 1e-50) 
 
  408          lambdak = normk / lambdak;
 
  412       for (i = 0; i < size; i++)
 
  413          a[i][size + 1] += lambdak * a[i][size + 3]; 
 
  416    } 
while (k < size && TMath::Abs(normk) > 1e-50); 
 
  435 Double_t TSpectrum2Fit::Shape2(Int_t numOfFittedPeaks, Double_t x, Double_t y,
 
  436                             const Double_t *parameter, Double_t sigmax,
 
  437                             Double_t sigmay, Double_t ro, Double_t a0, Double_t ax,
 
  438                             Double_t ay, Double_t txy, Double_t sxy, Double_t tx,
 
  439                             Double_t ty, Double_t sx, Double_t sy, Double_t bx,
 
  443    Double_t r, p, r1, e, ex, ey, vx, s2, px, py, rx, ry, erx, ery;
 
  445    s2 = TMath::Sqrt(2.0);
 
  446    for (j = 0; j < numOfFittedPeaks; j++) {
 
  447       p = (x - parameter[7 * j + 1]) / sigmax;
 
  448       r = (y - parameter[7 * j + 2]) / sigmay;
 
  449       if (TMath::Abs(p) < 3 && TMath::Abs(r) < 3) {
 
  450          e = (p * p - 2 * ro * p * r + r * r) / (2 * (1 - ro * ro));
 
  459             erx = Erfc(p / s2 + 1 / (2 * bx)), ery =
 
  460                 Erfc(r / s2 + 1 / (2 * by));
 
  461             ex = p / (s2 * bx), ey = r / (s2 * by);
 
  462             if (TMath::Abs(ex) < 9 && TMath::Abs(ey) < 9) {
 
  463                px = exp(ex) * erx, py = exp(ey) * ery;
 
  465             r1 += 0.5 * txy * px * py;
 
  468             rx = Erfc(p / s2), ry = Erfc(r / s2);
 
  469             r1 += 0.5 * sxy * rx * ry;
 
  471          vx = vx + parameter[7 * j] * r1;
 
  473       p = (x - parameter[7 * j + 5]) / sigmax;
 
  474       if (TMath::Abs(p) < 3) {
 
  484             erx = Erfc(p / s2 + 1 / (2 * bx));
 
  486             if (TMath::Abs(ex) < 9) {
 
  495          vx = vx + parameter[7 * j + 3] * r1;
 
  497       r = (y - parameter[7 * j + 6]) / sigmay;
 
  498       if (TMath::Abs(r) < 3) {
 
  508             ery = Erfc(r / s2 + 1 / (2 * by));
 
  510             if (TMath::Abs(ey) < 9) {
 
  519          vx = vx + parameter[7 * j + 4] * r1;
 
  522    vx = vx + a0 + ax * x + ay * y;
 
  541 Double_t TSpectrum2Fit::Deramp2(Double_t x, Double_t y, Double_t x0, Double_t y0,
 
  542                             Double_t sigmax, Double_t sigmay, Double_t ro,
 
  543                             Double_t txy, Double_t sxy, Double_t bx, Double_t by)
 
  545    Double_t p, r, r1 = 0, e, ex, ey, px, py, rx, ry, erx, ery, s2;
 
  546    p = (x - x0) / sigmax;
 
  547    r = (y - y0) / sigmay;
 
  548    if (TMath::Abs(p) < 3 && TMath::Abs(r) < 3) {
 
  549       s2 = TMath::Sqrt(2.0);
 
  550       e = (p * p - 2 * ro * p * r + r * r) / (2 * (1 - ro * ro));
 
  559          erx = Erfc(p / s2 + 1 / (2 * bx)), ery =
 
  560              Erfc(r / s2 + 1 / (2 * by));
 
  561          ex = p / (s2 * bx), ey = r / (s2 * by);
 
  562          if (TMath::Abs(ex) < 9 && TMath::Abs(ey) < 9) {
 
  563             px = exp(ex) * erx, py = exp(ey) * ery;
 
  565          r1 += 0.5 * txy * px * py;
 
  568          rx = Erfc(p / s2), ry = Erfc(r / s2);
 
  569          r1 += 0.5 * sxy * rx * ry;
 
  588 Double_t TSpectrum2Fit::Derampx(Double_t x, Double_t x0, Double_t sigmax, Double_t tx,
 
  589                              Double_t sx, Double_t bx)
 
  591    Double_t p, r1 = 0, px, erx, rx, ex, s2;
 
  592    p = (x - x0) / sigmax;
 
  593    if (TMath::Abs(p) < 3) {
 
  594       s2 = TMath::Sqrt(2.0);
 
  604          erx = Erfc(p / s2 + 1 / (2 * bx));
 
  606          if (TMath::Abs(ex) < 9) {
 
  635 Double_t TSpectrum2Fit::Deri02(Double_t x, Double_t y, Double_t a, Double_t x0,
 
  636                             Double_t y0, Double_t sigmax, Double_t sigmay,
 
  637                             Double_t ro, Double_t txy, Double_t sxy, Double_t bx,
 
  640    Double_t p, r, r1 = 0, e, ex, ey, px, py, rx, ry, erx, ery, s2;
 
  641    p = (x - x0) / sigmax;
 
  642    r = (y - y0) / sigmay;
 
  643    if (TMath::Abs(p) < 3 && TMath::Abs(r) < 3) {
 
  644       s2 = TMath::Sqrt(2.0);
 
  645       e = (p * p - 2 * ro * p * r + r * r) / (2 * (1 - ro * ro));
 
  652       e = -(ro * r - p) / sigmax;
 
  653       e = e / (1 - ro * ro);
 
  658              (-Erfc(p / s2 + 1 / (2 * bx)) / (s2 * bx * sigmax) -
 
  659               Derfc(p / s2 + 1 / (2 * bx)) / (s2 * sigmax)), ery =
 
  660              Erfc(r / s2 + 1 / (2 * by));
 
  661          ex = p / (s2 * bx), ey = r / (s2 * by);
 
  662          if (TMath::Abs(ex) < 9 && TMath::Abs(ey) < 9) {
 
  663             px = exp(ex) * erx, py = exp(ey) * ery;
 
  665          r1 += 0.5 * txy * px * py;
 
  668          rx = -Derfc(p / s2) / (s2 * sigmax), ry = Erfc(r / s2);
 
  669          r1 += 0.5 * sxy * rx * ry;
 
  690 Double_t TSpectrum2Fit::Derderi02(Double_t x, Double_t y, Double_t a, Double_t x0,
 
  691                               Double_t y0, Double_t sigmax, Double_t sigmay,
 
  694    Double_t p, r, r1 = 0, e;
 
  695    p = (x - x0) / sigmax;
 
  696    r = (y - y0) / sigmay;
 
  697    if (TMath::Abs(p) < 3 && TMath::Abs(r) < 3) {
 
  698       e = (p * p - 2 * ro * p * r + r * r) / (2 * (1 - ro * ro));
 
  705       e = -(ro * r - p) / sigmax;
 
  706       e = e / (1 - ro * ro);
 
  707       r1 = r1 * (e * e - 1 / ((1 - ro * ro) * sigmax * sigmax));
 
  728 Double_t TSpectrum2Fit::Derj02(Double_t x, Double_t y, Double_t a, Double_t x0,
 
  729                             Double_t y0, Double_t sigmax, Double_t sigmay,
 
  730                             Double_t ro, Double_t txy, Double_t sxy, Double_t bx,
 
  735    Double_t p, r, r1 = 0, e, ex, ey, px, py, rx, ry, erx, ery, s2;
 
  736    p = (x - x0) / sigmax;
 
  737    r = (y - y0) / sigmay;
 
  738    if (TMath::Abs(p) < 3 && TMath::Abs(r) < 3) {
 
  739       s2 = TMath::Sqrt(2.0);
 
  740       e = (p * p - 2 * ro * p * r + r * r) / (2 * (1 - ro * ro));
 
  747       e = -(ro * p - r) / sigmay;
 
  748       e = e / (1 - ro * ro);
 
  753              (-Erfc(r / s2 + 1 / (2 * by)) / (s2 * by * sigmay) -
 
  754               Derfc(r / s2 + 1 / (2 * by)) / (s2 * sigmay)), erx =
 
  755              Erfc(p / s2 + 1 / (2 * bx));
 
  756          ex = p / (s2 * bx), ey = r / (s2 * by);
 
  757          if (TMath::Abs(ex) < 9 && TMath::Abs(ey) < 9) {
 
  758             px = exp(ex) * erx, py = exp(ey) * ery;
 
  760          r1 += 0.5 * txy * px * py;
 
  763          ry = -Derfc(r / s2) / (s2 * sigmay), rx = Erfc(p / s2);
 
  764          r1 += 0.5 * sxy * rx * ry;
 
  785 Double_t TSpectrum2Fit::Derderj02(Double_t x, Double_t y, Double_t a, Double_t x0,
 
  786                                Double_t y0, Double_t sigmax, Double_t sigmay,
 
  789    Double_t p, r, r1 = 0, e;
 
  790    p = (x - x0) / sigmax;
 
  791    r = (y - y0) / sigmay;
 
  792    if (TMath::Abs(p) < 3 && TMath::Abs(r) < 3) {
 
  793       e = (p * p - 2 * ro * p * r + r * r) / (2 * (1 - ro * ro));
 
  800       e = -(ro * p - r) / sigmay;
 
  801       e = e / (1 - ro * ro);
 
  802       r1 = r1 * (e * e - 1 / ((1 - ro * ro) * sigmay * sigmay));
 
  821 Double_t TSpectrum2Fit::Deri01(Double_t x, Double_t ax, Double_t x0, Double_t sigmax,
 
  822                             Double_t tx, Double_t sx, Double_t bx)
 
  824    Double_t p, e, r1 = 0, px, rx, erx, ex, s2;
 
  825    p = (x - x0) / sigmax;
 
  826    if (TMath::Abs(p) < 3) {
 
  827       s2 = TMath::Sqrt(2.0);
 
  835       r1 = r1 * p / sigmax;
 
  839              (-Erfc(p / s2 + 1 / (2 * bx)) / (s2 * bx * sigmax) -
 
  840               Derfc(p / s2 + 1 / (2 * bx)) / (s2 * sigmax));
 
  842          if (TMath::Abs(ex) < 9)
 
  847          rx = -Derfc(p / s2) / (s2 * sigmax);
 
  865 Double_t TSpectrum2Fit::Derderi01(Double_t x, Double_t ax, Double_t x0,
 
  868    Double_t p, e, r1 = 0;
 
  869    p = (x - x0) / sigmax;
 
  870    if (TMath::Abs(p) < 3) {
 
  878       r1 = r1 * (p * p / (sigmax * sigmax) - 1 / (sigmax * sigmax));
 
  898 Double_t TSpectrum2Fit::Dersigmax(Int_t numOfFittedPeaks, Double_t x, Double_t y,
 
  899                                const Double_t *parameter, Double_t sigmax,
 
  900                                Double_t sigmay, Double_t ro, Double_t txy,
 
  901                                Double_t sxy, Double_t tx, Double_t sx, Double_t bx,
 
  905        0, e, a, b, x0, y0, s2, px, py, rx, ry, erx, ery, ex, ey;
 
  907    s2 = TMath::Sqrt(2.0);
 
  908    for (j = 0; j < numOfFittedPeaks; j++) {
 
  909       a = parameter[7 * j];
 
  910       x0 = parameter[7 * j + 1];
 
  911       y0 = parameter[7 * j + 2];
 
  912       p = (x - x0) / sigmax;
 
  913       r = (y - y0) / sigmay;
 
  914       if (TMath::Abs(p) < 3 && TMath::Abs(r) < 3) {
 
  915          e = (p * p - 2 * ro * p * r + r * r) / (2 * (1 - ro * ro));
 
  922          b = -(ro * p * r - p * p) / sigmax;
 
  923          e = e * b / (1 - ro * ro);
 
  927                 -Erfc(p / s2 + 1 / (2 * bx)) * p / (s2 * bx * sigmax) -
 
  928                 Derfc(p / s2 + 1 / (2 * bx)) * p / (s2 * sigmax), ery =
 
  929                 Erfc(r / s2 + 1 / (2 * by));
 
  930             ex = p / (s2 * bx), ey = r / (s2 * by);
 
  931             if (TMath::Abs(ex) < 9 && TMath::Abs(ey) < 9) {
 
  932                px = exp(ex) * erx, py = exp(ey) * ery;
 
  934             e += 0.5 * txy * px * py;
 
  937             rx = -Derfc(p / s2) * p / (s2 * sigmax), ry = Erfc(r / s2);
 
  938             e += 0.5 * sxy * rx * ry;
 
  942       if (TMath::Abs(p) < 3) {
 
  943          x0 = parameter[7 * j + 5];
 
  944          p = (x - x0) / sigmax;
 
  952          e = 2 * b * e / sigmax;
 
  956                 (-Erfc(p / s2 + 1 / (2 * bx)) * p / (s2 * bx * sigmax) -
 
  957                  Derfc(p / s2 + 1 / (2 * bx)) * p / (s2 * sigmax));
 
  959             if (TMath::Abs(ex) < 9)
 
  964             rx = -Derfc(p / s2) * p / (s2 * sigmax);
 
  967          r1 += parameter[7 * j + 3] * e;
 
  985 Double_t TSpectrum2Fit::Derdersigmax(Int_t numOfFittedPeaks, Double_t x,
 
  986                                   Double_t y, 
const Double_t *parameter,
 
  987                                   Double_t sigmax, Double_t sigmay,
 
  990    Double_t p, r, r1 = 0, e, a, b, x0, y0;
 
  992    for (j = 0; j < numOfFittedPeaks; j++) {
 
  993       a = parameter[7 * j];
 
  994       x0 = parameter[7 * j + 1];
 
  995       y0 = parameter[7 * j + 2];
 
  996       p = (x - x0) / sigmax;
 
  997       r = (y - y0) / sigmay;
 
  998       if (TMath::Abs(p) < 3 && TMath::Abs(r) < 3) {
 
  999          e = (p * p - 2 * ro * p * r + r * r) / (2 * (1 - ro * ro));
 
 1006          b = -(ro * p * r - p * p) / sigmax;
 
 1007          e = e * (b * b / (1 - ro * ro) -
 
 1008                    (3 * p * p - 2 * ro * p * r) / (sigmax * sigmax)) / (1 -
 
 1014       if (TMath::Abs(p) < 3) {
 
 1015          x0 = parameter[7 * j + 5];
 
 1016          p = (x - x0) / sigmax;
 
 1024          e = e * (4 * b * b - 6 * b) / (sigmax * sigmax);
 
 1025          r1 += parameter[7 * j + 3] * e;
 
 1045 Double_t TSpectrum2Fit::Dersigmay(Int_t numOfFittedPeaks, Double_t x, Double_t y,
 
 1046                                const Double_t *parameter, Double_t sigmax,
 
 1047                                Double_t sigmay, Double_t ro, Double_t txy,
 
 1048                                Double_t sxy, Double_t ty, Double_t sy, Double_t bx,
 
 1052        0, e, a, b, x0, y0, s2, px, py, rx, ry, erx, ery, ex, ey;
 
 1054    s2 = TMath::Sqrt(2.0);
 
 1055    for (j = 0; j < numOfFittedPeaks; j++) {
 
 1056       a = parameter[7 * j];
 
 1057       x0 = parameter[7 * j + 1];
 
 1058       y0 = parameter[7 * j + 2];
 
 1059       p = (x - x0) / sigmax;
 
 1060       r = (y - y0) / sigmay;
 
 1061       if (TMath::Abs(p) < 3 && TMath::Abs(r) < 3) {
 
 1062          e = (p * p - 2 * ro * p * r + r * r) / (2 * (1 - ro * ro));
 
 1069          b = -(ro * p * r - r * r) / sigmay;
 
 1070          e = e * b / (1 - ro * ro);
 
 1074                 -Erfc(r / s2 + 1 / (2 * by)) * r / (s2 * by * sigmay) -
 
 1075                 Derfc(r / s2 + 1 / (2 * by)) * r / (s2 * sigmay), erx =
 
 1076                 Erfc(p / s2 + 1 / (2 * bx));
 
 1077             ex = p / (s2 * bx), ey = r / (s2 * by);
 
 1078             if (TMath::Abs(ex) < 9 && TMath::Abs(ey) < 9) {
 
 1079                px = exp(ex) * erx, py = exp(ey) * ery;
 
 1081             e += 0.5 * txy * px * py;
 
 1084             ry = -Derfc(r / s2) * r / (s2 * sigmay), rx = Erfc(p / s2);
 
 1085             e += 0.5 * sxy * rx * ry;
 
 1089       if (TMath::Abs(r) < 3) {
 
 1090          y0 = parameter[7 * j + 6];
 
 1091          r = (y - y0) / sigmay;
 
 1099          e = 2 * b * e / sigmay;
 
 1103                 (-Erfc(r / s2 + 1 / (2 * by)) * r / (s2 * by * sigmay) -
 
 1104                  Derfc(r / s2 + 1 / (2 * by)) * r / (s2 * sigmay));
 
 1106             if (TMath::Abs(ey) < 9)
 
 1111             ry = -Derfc(r / s2) * r / (s2 * sigmay);
 
 1114          r1 += parameter[7 * j + 4] * e;
 
 1132 Double_t TSpectrum2Fit::Derdersigmay(Int_t numOfFittedPeaks, Double_t x,
 
 1133                                   Double_t y, 
const Double_t *parameter,
 
 1134                                   Double_t sigmax, Double_t sigmay,
 
 1137    Double_t p, r, r1 = 0, e, a, b, x0, y0;
 
 1139    for (j = 0; j < numOfFittedPeaks; j++) {
 
 1140       a = parameter[7 * j];
 
 1141       x0 = parameter[7 * j + 1];
 
 1142       y0 = parameter[7 * j + 2];
 
 1143       p = (x - x0) / sigmax;
 
 1144       r = (y - y0) / sigmay;
 
 1145       if (TMath::Abs(p) < 3 && TMath::Abs(r) < 3) {
 
 1146          e = (p * p - 2 * ro * p * r + r * r) / (2 * (1 - ro * ro));
 
 1153          b = -(ro * p * r - r * r) / sigmay;
 
 1154          e = e * (b * b / (1 - ro * ro) -
 
 1155                    (3 * r * r - 2 * ro * r * p) / (sigmay * sigmay)) / (1 -
 
 1161       if (TMath::Abs(r) < 3) {
 
 1162          y0 = parameter[7 * j + 6];
 
 1163          r = (y - y0) / sigmay;
 
 1171          e = e * (4 * b * b - 6 * b) / (sigmay * sigmay);
 
 1172          r1 += parameter[7 * j + 4] * e;
 
 1190 Double_t TSpectrum2Fit::Derro(Int_t numOfFittedPeaks, Double_t x, Double_t y,
 
 1191                            const Double_t *parameter, Double_t sx, Double_t sy,
 
 1194    Double_t px, qx, rx, vx, x0, y0, a, ex, tx;
 
 1197    for (j = 0; j < numOfFittedPeaks; j++) {
 
 1198       a = parameter[7 * j];
 
 1199       x0 = parameter[7 * j + 1];
 
 1200       y0 = parameter[7 * j + 2];
 
 1203       if (TMath::Abs(px) < 3 && TMath::Abs(qx) < 3) {
 
 1204          rx = (px * px - 2 * r * px * qx + qx * qx);
 
 1205          ex = rx / (2 * (1 - r * r));
 
 1212          tx = px * qx / (1 - r * r);
 
 1213          tx = tx - r * rx / ((1 - r * r) * (1 - r * r));
 
 1214          vx = vx + a * ex * tx;
 
 1232 Double_t TSpectrum2Fit::Dertxy(Int_t numOfFittedPeaks, Double_t x, Double_t y,
 
 1233                             const Double_t *parameter, Double_t sigmax,
 
 1234                             Double_t sigmay, Double_t bx, Double_t by)
 
 1236    Double_t p, r, r1 = 0, ex, ey, px, py, erx, ery, s2, x0, y0, a;
 
 1238    s2 = TMath::Sqrt(2.0);
 
 1239    for (j = 0; j < numOfFittedPeaks; j++) {
 
 1240       a = parameter[7 * j];
 
 1241       x0 = parameter[7 * j + 1];
 
 1242       y0 = parameter[7 * j + 2];
 
 1243       p = (x - x0) / sigmax;
 
 1244       r = (y - y0) / sigmay;
 
 1246       erx = Erfc(p / s2 + 1 / (2 * bx)), ery =
 
 1247           Erfc(r / s2 + 1 / (2 * by));
 
 1248       ex = p / (s2 * bx), ey = r / (s2 * by);
 
 1249       if (TMath::Abs(ex) < 9 && TMath::Abs(ey) < 9) {
 
 1250          px = exp(ex) * erx, py = exp(ey) * ery;
 
 1252       r1 += 0.5 * a * px * py;
 
 1268 Double_t TSpectrum2Fit::Dersxy(Int_t numOfFittedPeaks, Double_t x, Double_t y,
 
 1269                             const Double_t *parameter, Double_t sigmax,
 
 1272    Double_t p, r, r1 = 0, rx, ry, x0, y0, a, s2;
 
 1274    s2 = TMath::Sqrt(2.0);
 
 1275    for (j = 0; j < numOfFittedPeaks; j++) {
 
 1276       a = parameter[7 * j];
 
 1277       x0 = parameter[7 * j + 1];
 
 1278       y0 = parameter[7 * j + 2];
 
 1279       p = (x - x0) / sigmax;
 
 1280       r = (y - y0) / sigmay;
 
 1281       rx = Erfc(p / s2), ry = Erfc(r / s2);
 
 1282       r1 += 0.5 * a * rx * ry;
 
 1298 Double_t TSpectrum2Fit::Dertx(Int_t numOfFittedPeaks, Double_t x,
 
 1299                            const Double_t *parameter, Double_t sigmax,
 
 1302    Double_t p, r1 = 0, ex, px, erx, s2, ax, x0;
 
 1304    s2 = TMath::Sqrt(2.0);
 
 1305    for (j = 0; j < numOfFittedPeaks; j++) {
 
 1306       ax = parameter[7 * j + 3];
 
 1307       x0 = parameter[7 * j + 5];
 
 1308       p = (x - x0) / sigmax;
 
 1310       erx = Erfc(p / s2 + 1 / (2 * bx));
 
 1312       if (TMath::Abs(ex) < 9) {
 
 1315       r1 += 0.5 * ax * px;
 
 1331 Double_t TSpectrum2Fit::Derty(Int_t numOfFittedPeaks, Double_t x,
 
 1332                            const Double_t *parameter, Double_t sigmax,
 
 1335    Double_t p, r1 = 0, ex, px, erx, s2, ax, x0;
 
 1337    s2 = TMath::Sqrt(2.0);
 
 1338    for (j = 0; j < numOfFittedPeaks; j++) {
 
 1339       ax = parameter[7 * j + 4];
 
 1340       x0 = parameter[7 * j + 6];
 
 1341       p = (x - x0) / sigmax;
 
 1343       erx = Erfc(p / s2 + 1 / (2 * bx));
 
 1345       if (TMath::Abs(ex) < 9) {
 
 1348       r1 += 0.5 * ax * px;
 
 1363 Double_t TSpectrum2Fit::Dersx(Int_t numOfFittedPeaks, Double_t x,
 
 1364                            const Double_t *parameter, Double_t sigmax)
 
 1366    Double_t p, r1 = 0, rx, ax, x0, s2;
 
 1368    s2 = TMath::Sqrt(2.0);
 
 1369    for (j = 0; j < numOfFittedPeaks; j++) {
 
 1370       ax = parameter[7 * j + 3];
 
 1371       x0 = parameter[7 * j + 5];
 
 1372       p = (x - x0) / sigmax;
 
 1373       s2 = TMath::Sqrt(2.0);
 
 1375       r1 += 0.5 * ax * rx;
 
 1390 Double_t TSpectrum2Fit::Dersy(Int_t numOfFittedPeaks, Double_t x,
 
 1391                            const Double_t *parameter, Double_t sigmax)
 
 1393    Double_t p, r1 = 0, rx, ax, x0, s2;
 
 1395    s2 = TMath::Sqrt(2.0);
 
 1396    for (j = 0; j < numOfFittedPeaks; j++) {
 
 1397       ax = parameter[7 * j + 4];
 
 1398       x0 = parameter[7 * j + 6];
 
 1399       p = (x - x0) / sigmax;
 
 1400       s2 = TMath::Sqrt(2.0);
 
 1402       r1 += 0.5 * ax * rx;
 
 1420 Double_t TSpectrum2Fit::Derbx(Int_t numOfFittedPeaks, Double_t x, Double_t y,
 
 1421                            const Double_t *parameter, Double_t sigmax,
 
 1422                            Double_t sigmay, Double_t txy, Double_t tx, Double_t bx,
 
 1425    Double_t p, r, r1 = 0, a, x0, y0, s2, px, py, erx, ery, ex, ey;
 
 1427    s2 = TMath::Sqrt(2.0);
 
 1428    for (j = 0; j < numOfFittedPeaks; j++) {
 
 1429       a = parameter[7 * j];
 
 1430       x0 = parameter[7 * j + 1];
 
 1431       y0 = parameter[7 * j + 2];
 
 1432       p = (x - x0) / sigmax;
 
 1433       r = (y - y0) / sigmay;
 
 1437              -Erfc(p / s2 + 1 / (2 * bx)) * p / (s2 * bx * bx) -
 
 1438              Derfc(p / s2 + 1 / (2 * bx)) / (s2 * bx * bx), ery =
 
 1439              Erfc(r / s2 + 1 / (2 * by));
 
 1440          ex = p / (s2 * bx), ey = r / (s2 * by);
 
 1441          if (TMath::Abs(ex) < 9 && TMath::Abs(ey) < 9) {
 
 1442             px = exp(ex) * erx, py = exp(ey) * ery;
 
 1444          r1 += 0.5 * a * txy * px * py;
 
 1446       a = parameter[7 * j + 3];
 
 1447       x0 = parameter[7 * j + 5];
 
 1448       p = (x - x0) / sigmax;
 
 1452              (-Erfc(p / s2 + 1 / (2 * bx)) * p / (s2 * bx * bx) -
 
 1453               Derfc(p / s2 + 1 / (2 * bx)) / (s2 * bx * bx));
 
 1455          if (TMath::Abs(ex) < 9)
 
 1457          r1 += 0.5 * a * tx * px;
 
 1476 Double_t TSpectrum2Fit::Derby(Int_t numOfFittedPeaks, Double_t x, Double_t y,
 
 1477                            const Double_t *parameter, Double_t sigmax,
 
 1478                            Double_t sigmay, Double_t txy, Double_t ty, Double_t bx,
 
 1481    Double_t p, r, r1 = 0, a, x0, y0, s2, px, py, erx, ery, ex, ey;
 
 1483    s2 = TMath::Sqrt(2.0);
 
 1484    for (j = 0; j < numOfFittedPeaks; j++) {
 
 1485       a = parameter[7 * j];
 
 1486       x0 = parameter[7 * j + 1];
 
 1487       y0 = parameter[7 * j + 2];
 
 1488       p = (x - x0) / sigmax;
 
 1489       r = (y - y0) / sigmay;
 
 1493              -Erfc(r / s2 + 1 / (2 * by)) * r / (s2 * by * by) -
 
 1494              Derfc(r / s2 + 1 / (2 * by)) / (s2 * by * by), erx =
 
 1495              Erfc(p / s2 + 1 / (2 * bx));
 
 1496          ex = p / (s2 * bx), ey = r / (s2 * by);
 
 1497          if (TMath::Abs(ex) < 9 && TMath::Abs(ey) < 9) {
 
 1498             px = exp(ex) * erx, py = exp(ey) * ery;
 
 1500          r1 += 0.5 * a * txy * px * py;
 
 1502       a = parameter[7 * j + 4];
 
 1503       y0 = parameter[7 * j + 6];
 
 1504       r = (y - y0) / sigmay;
 
 1508              (-Erfc(r / s2 + 1 / (2 * by)) * r / (s2 * by * by) -
 
 1509               Derfc(r / s2 + 1 / (2 * by)) / (s2 * by * by));
 
 1511          if (TMath::Abs(ey) < 9)
 
 1513          r1 += 0.5 * a * ty * py;
 
 1527 Double_t TSpectrum2Fit::Volume(Double_t a, Double_t sx, Double_t sy, Double_t ro)
 
 1529    Double_t pi = 3.1415926535, r;
 
 1537    r = 2 * a * pi * sx * sy * r;
 
 1549 Double_t TSpectrum2Fit::Derpa2(Double_t sx, Double_t sy, Double_t ro)
 
 1551    Double_t pi = 3.1415926535, r;
 
 1559    r = 2 * pi * sx * sy * r;
 
 1572 Double_t TSpectrum2Fit::Derpsigmax(Double_t a, Double_t sy, Double_t ro)
 
 1574    Double_t pi = 3.1415926535, r;
 
 1582    r = a * 2 * pi * sy * r;
 
 1595 Double_t TSpectrum2Fit::Derpsigmay(Double_t a, Double_t sx, Double_t ro)
 
 1597    Double_t pi = 3.1415926535, r;
 
 1605    r = a * 2 * pi * sx * r;
 
 1618 Double_t TSpectrum2Fit::Derpro(Double_t a, Double_t sx, Double_t sy, Double_t ro)
 
 1620    Double_t pi = 3.1415926535, r;
 
 1628    r = -a * 2 * pi * sx * sy * ro / r;
 
 1847 void TSpectrum2Fit::FitAwmi(Double_t **source)
 
 1851    Int_t i, i1, i2, j, k, shift =
 
 1852        7 * fNPeaks + 14, peak_vel, size, iter, pw,
 
 1854    Double_t a, b, c, d = 0, alpha, chi_opt, yw, ywm, f, chi2, chi_min, chi =
 
 1855        0, pi, pmin = 0, chi_cel = 0, chi_er;
 
 1856    Double_t *working_space = 
new Double_t[5 * (7 * fNPeaks + 14)];
 
 1857    for (i = 0, j = 0; i < fNPeaks; i++) {
 
 1858       working_space[7 * i] = fAmpInit[i]; 
 
 1859       if (fFixAmp[i] == 
false) {
 
 1860          working_space[shift + j] = fAmpInit[i]; 
 
 1863       working_space[7 * i + 1] = fPositionInitX[i]; 
 
 1864       if (fFixPositionX[i] == 
false) {
 
 1865          working_space[shift + j] = fPositionInitX[i]; 
 
 1868       working_space[7 * i + 2] = fPositionInitY[i]; 
 
 1869       if (fFixPositionY[i] == 
false) {
 
 1870          working_space[shift + j] = fPositionInitY[i]; 
 
 1873       working_space[7 * i + 3] = fAmpInitX1[i]; 
 
 1874       if (fFixAmpX1[i] == 
false) {
 
 1875          working_space[shift + j] = fAmpInitX1[i]; 
 
 1878       working_space[7 * i + 4] = fAmpInitY1[i]; 
 
 1879       if (fFixAmpY1[i] == 
false) {
 
 1880          working_space[shift + j] = fAmpInitY1[i]; 
 
 1883       working_space[7 * i + 5] = fPositionInitX1[i]; 
 
 1884       if (fFixPositionX1[i] == 
false) {
 
 1885          working_space[shift + j] = fPositionInitX1[i]; 
 
 1888       working_space[7 * i + 6] = fPositionInitY1[i]; 
 
 1889       if (fFixPositionY1[i] == 
false) {
 
 1890          working_space[shift + j] = fPositionInitY1[i]; 
 
 1895    working_space[7 * i] = fSigmaInitX; 
 
 1896    if (fFixSigmaX == 
false) {
 
 1897       working_space[shift + j] = fSigmaInitX; 
 
 1900    working_space[7 * i + 1] = fSigmaInitY; 
 
 1901    if (fFixSigmaY == 
false) {
 
 1902       working_space[shift + j] = fSigmaInitY; 
 
 1905    working_space[7 * i + 2] = fRoInit; 
 
 1906    if (fFixRo == 
false) {
 
 1907       working_space[shift + j] = fRoInit; 
 
 1910    working_space[7 * i + 3] = fA0Init; 
 
 1911    if (fFixA0 == 
false) {
 
 1912       working_space[shift + j] = fA0Init; 
 
 1915    working_space[7 * i + 4] = fAxInit; 
 
 1916    if (fFixAx == 
false) {
 
 1917       working_space[shift + j] = fAxInit; 
 
 1920    working_space[7 * i + 5] = fAyInit; 
 
 1921    if (fFixAy == 
false) {
 
 1922       working_space[shift + j] = fAyInit; 
 
 1925    working_space[7 * i + 6] = fTxyInit; 
 
 1926    if (fFixTxy == 
false) {
 
 1927       working_space[shift + j] = fTxyInit; 
 
 1930    working_space[7 * i + 7] = fSxyInit; 
 
 1931    if (fFixSxy == 
false) {
 
 1932       working_space[shift + j] = fSxyInit; 
 
 1935    working_space[7 * i + 8] = fTxInit; 
 
 1936    if (fFixTx == 
false) {
 
 1937       working_space[shift + j] = fTxInit; 
 
 1940    working_space[7 * i + 9] = fTyInit; 
 
 1941    if (fFixTy == 
false) {
 
 1942       working_space[shift + j] = fTyInit; 
 
 1945    working_space[7 * i + 10] = fSxyInit; 
 
 1946    if (fFixSx == 
false) {
 
 1947       working_space[shift + j] = fSxInit; 
 
 1950    working_space[7 * i + 11] = fSyInit; 
 
 1951    if (fFixSy == 
false) {
 
 1952       working_space[shift + j] = fSyInit; 
 
 1955    working_space[7 * i + 12] = fBxInit; 
 
 1956    if (fFixBx == 
false) {
 
 1957       working_space[shift + j] = fBxInit; 
 
 1960    working_space[7 * i + 13] = fByInit; 
 
 1961    if (fFixBy == 
false) {
 
 1962       working_space[shift + j] = fByInit; 
 
 1966    for (iter = 0; iter < fNumberIterations; iter++) {
 
 1967       for (j = 0; j < size; j++) {
 
 1968          working_space[2 * shift + j] = 0, working_space[3 * shift + j] = 0; 
 
 1973       chi_opt = 0, pw = fPower - 2;
 
 1974       for (i1 = fXmin; i1 <= fXmax; i1++) {
 
 1975          for (i2 = fYmin; i2 <= fYmax; i2++) {
 
 1976             yw = source[i1][i2];
 
 1978             f = Shape2(fNPeaks, i1, i2,
 
 1979                         working_space, working_space[peak_vel],
 
 1980                         working_space[peak_vel + 1],
 
 1981                         working_space[peak_vel + 2],
 
 1982                         working_space[peak_vel + 3],
 
 1983                         working_space[peak_vel + 4],
 
 1984                         working_space[peak_vel + 5],
 
 1985                         working_space[peak_vel + 6],
 
 1986                         working_space[peak_vel + 7],
 
 1987                         working_space[peak_vel + 8],
 
 1988                         working_space[peak_vel + 9],
 
 1989                         working_space[peak_vel + 10],
 
 1990                         working_space[peak_vel + 11],
 
 1991                         working_space[peak_vel + 12],
 
 1992                         working_space[peak_vel + 13]);
 
 1993             if (fStatisticType == kFitOptimMaxLikelihood) {
 
 1995                   chi_opt += yw * TMath::Log(f) - f;
 
 2000                   chi_opt += (yw - f) * (yw - f) / ywm;
 
 2002             if (fStatisticType == kFitOptimChiFuncValues) {
 
 2008             else if (fStatisticType == kFitOptimMaxLikelihood) {
 
 2020                 for (j = 0, k = 0; j < fNPeaks; j++) {
 
 2021                if (fFixAmp[j] == 
false) {
 
 2023                                working_space[7 * j + 1],
 
 2024                                working_space[7 * j + 2],
 
 2025                                working_space[peak_vel],
 
 2026                                working_space[peak_vel + 1],
 
 2027                                working_space[peak_vel + 2],
 
 2028                                working_space[peak_vel + 6],
 
 2029                                working_space[peak_vel + 7],
 
 2030                                working_space[peak_vel + 12],
 
 2031                                working_space[peak_vel + 13]);
 
 2034                      if (fStatisticType == kFitOptimChiFuncValues) {
 
 2035                         b = a * (yw * yw - f * f) / (ywm * ywm);
 
 2036                         working_space[2 * shift + k] += b * c; 
 
 2037                         b = a * a * (4 * yw - 2 * f) / (ywm * ywm);
 
 2038                         working_space[3 * shift + k] += b * c; 
 
 2042                         b = a * (yw - f) / ywm;
 
 2043                         working_space[2 * shift + k] += b * c; 
 
 2045                         working_space[3 * shift + k] += b * c; 
 
 2050                if (fFixPositionX[j] == 
false) {
 
 2052                               working_space[7 * j],
 
 2053                               working_space[7 * j + 1],
 
 2054                               working_space[7 * j + 2],
 
 2055                               working_space[peak_vel],
 
 2056                               working_space[peak_vel + 1],
 
 2057                               working_space[peak_vel + 2],
 
 2058                               working_space[peak_vel + 6],
 
 2059                               working_space[peak_vel + 7],
 
 2060                               working_space[peak_vel + 12],
 
 2061                               working_space[peak_vel + 13]);
 
 2062                   if (fFitTaylor == kFitTaylorOrderSecond)
 
 2063                      d = Derderi02(i1, i2,
 
 2064                                     working_space[7 * j],
 
 2065                                     working_space[7 * j + 1],
 
 2066                                     working_space[7 * j + 2],
 
 2067                                     working_space[peak_vel],
 
 2068                                     working_space[peak_vel + 1],
 
 2069                                     working_space[peak_vel + 2]);
 
 2072                      if (TMath::Abs(a) > 0.00000001
 
 2073                           && fFitTaylor == kFitTaylorOrderSecond) {
 
 2074                         d = d * TMath::Abs(yw - f) / (2 * a * ywm);
 
 2075                         if (((a + d) <= 0 && a >= 0) || ((a + d) >= 0
 
 2083                      if (fStatisticType == kFitOptimChiFuncValues) {
 
 2084                         b = a * (yw * yw - f * f) / (ywm * ywm);
 
 2085                         working_space[2 * shift + k] += b * c; 
 
 2086                         b = a * a * (4 * yw - 2 * f) / (ywm * ywm);
 
 2087                         working_space[3 * shift + k] += b * c; 
 
 2091                         b = a * (yw - f) / ywm;
 
 2092                         working_space[2 * shift + k] += b * c; 
 
 2094                         working_space[3 * shift + k] += b * c; 
 
 2099                if (fFixPositionY[j] == 
false) {
 
 2101                               working_space[7 * j],
 
 2102                               working_space[7 * j + 1],
 
 2103                               working_space[7 * j + 2],
 
 2104                               working_space[peak_vel],
 
 2105                               working_space[peak_vel + 1],
 
 2106                               working_space[peak_vel + 2],
 
 2107                               working_space[peak_vel + 6],
 
 2108                               working_space[peak_vel + 7],
 
 2109                               working_space[peak_vel + 12],
 
 2110                               working_space[peak_vel + 13]);
 
 2111                   if (fFitTaylor == kFitTaylorOrderSecond)
 
 2112                      d = Derderj02(i1, i2,
 
 2113                                     working_space[7 * j],
 
 2114                                     working_space[7 * j + 1],
 
 2115                                     working_space[7 * j + 2],
 
 2116                                     working_space[peak_vel],
 
 2117                                     working_space[peak_vel + 1],
 
 2118                                     working_space[peak_vel + 2]);
 
 2121                      if (TMath::Abs(a) > 0.00000001
 
 2122                           && fFitTaylor == kFitTaylorOrderSecond) {
 
 2123                         d = d * TMath::Abs(yw - f) / (2 * a * ywm);
 
 2124                         if (((a + d) <= 0 && a >= 0) || ((a + d) >= 0
 
 2132                      if (fStatisticType == kFitOptimChiFuncValues) {
 
 2133                         b = a * (yw * yw - f * f) / (ywm * ywm);
 
 2134                         working_space[2 * shift + k] += b * c; 
 
 2135                         b = a * a * (4 * yw - 2 * f) / (ywm * ywm);
 
 2136                         working_space[3 * shift + k] += b * c; 
 
 2140                         b = a * (yw - f) / ywm;
 
 2141                         working_space[2 * shift + k] += b * c; 
 
 2143                         working_space[3 * shift + k] += b * c; 
 
 2148                if (fFixAmpX1[j] == 
false) {
 
 2149                   a = Derampx(i1, working_space[7 * j + 5],
 
 2150                                working_space[peak_vel],
 
 2151                                working_space[peak_vel + 8],
 
 2152                                working_space[peak_vel + 10],
 
 2153                                working_space[peak_vel + 12]);
 
 2156                      if (fStatisticType == kFitOptimChiFuncValues) {
 
 2157                         b = a * (yw * yw - f * f) / (ywm * ywm);
 
 2158                         working_space[2 * shift + k] += b * c; 
 
 2159                         b = a * a * (4 * yw - 2 * f) / (ywm * ywm);
 
 2160                         working_space[3 * shift + k] += b * c; 
 
 2164                         b = a * (yw - f) / ywm;
 
 2165                         working_space[2 * shift + k] += b * c; 
 
 2167                         working_space[3 * shift + k] += b * c; 
 
 2172                if (fFixAmpY1[j] == 
false) {
 
 2173                   a = Derampx(i2, working_space[7 * j + 6],
 
 2174                                working_space[peak_vel + 1],
 
 2175                                working_space[peak_vel + 9],
 
 2176                                working_space[peak_vel + 11],
 
 2177                                working_space[peak_vel + 13]);
 
 2180                      if (fStatisticType == kFitOptimChiFuncValues) {
 
 2181                         b = a * (yw * yw - f * f) / (ywm * ywm);
 
 2182                         working_space[2 * shift + k] += b * c; 
 
 2183                         b = a * a * (4 * yw - 2 * f) / (ywm * ywm);
 
 2184                         working_space[3 * shift + k] += b * c; 
 
 2188                         b = a * (yw - f) / ywm;
 
 2189                         working_space[2 * shift + k] += b * c; 
 
 2191                         working_space[3 * shift + k] += b * c; 
 
 2196                if (fFixPositionX1[j] == 
false) {
 
 2197                   a = Deri01(i1, working_space[7 * j + 3],
 
 2198                               working_space[7 * j + 5],
 
 2199                               working_space[peak_vel],
 
 2200                               working_space[peak_vel + 8],
 
 2201                               working_space[peak_vel + 10],
 
 2202                               working_space[peak_vel + 12]);
 
 2203                   if (fFitTaylor == kFitTaylorOrderSecond)
 
 2204                      d = Derderi01(i1, working_space[7 * j + 3],
 
 2205                                     working_space[7 * j + 5],
 
 2206                                     working_space[peak_vel]);
 
 2209                      if (TMath::Abs(a) > 0.00000001
 
 2210                           && fFitTaylor == kFitTaylorOrderSecond) {
 
 2211                         d = d * TMath::Abs(yw - f) / (2 * a * ywm);
 
 2212                         if (((a + d) <= 0 && a >= 0) || ((a + d) >= 0
 
 2220                      if (fStatisticType == kFitOptimChiFuncValues) {
 
 2221                         b = a * (yw * yw - f * f) / (ywm * ywm);
 
 2222                         working_space[2 * shift + k] += b * c; 
 
 2223                         b = a * a * (4 * yw - 2 * f) / (ywm * ywm);
 
 2224                         working_space[3 * shift + k] += b * c; 
 
 2228                         b = a * (yw - f) / ywm;
 
 2229                         working_space[2 * shift + k] += b * c; 
 
 2231                         working_space[3 * shift + k] += b * c; 
 
 2236                if (fFixPositionY1[j] == 
false) {
 
 2237                   a = Deri01(i2, working_space[7 * j + 4],
 
 2238                               working_space[7 * j + 6],
 
 2239                               working_space[peak_vel + 1],
 
 2240                               working_space[peak_vel + 9],
 
 2241                               working_space[peak_vel + 11],
 
 2242                               working_space[peak_vel + 13]);
 
 2243                   if (fFitTaylor == kFitTaylorOrderSecond)
 
 2244                      d = Derderi01(i2, working_space[7 * j + 4],
 
 2245                                     working_space[7 * j + 6],
 
 2246                                     working_space[peak_vel + 1]);
 
 2249                      if (TMath::Abs(a) > 0.00000001
 
 2250                           && fFitTaylor == kFitTaylorOrderSecond) {
 
 2251                         d = d * TMath::Abs(yw - f) / (2 * a * ywm);
 
 2252                         if (((a + d) <= 0 && a >= 0) || ((a + d) >= 0
 
 2260                      if (fStatisticType == kFitOptimChiFuncValues) {
 
 2261                         b = a * (yw * yw - f * f) / (ywm * ywm);
 
 2262                         working_space[2 * shift + k] += b * c; 
 
 2263                         b = a * a * (4 * yw - 2 * f) / (ywm * ywm);
 
 2264                         working_space[3 * shift + k] += b * c; 
 
 2268                         b = a * (yw - f) / ywm;
 
 2269                         working_space[2 * shift + k] += b * c; 
 
 2271                         working_space[3 * shift + k] += b * c; 
 
 2277             if (fFixSigmaX == 
false) {
 
 2278                a = Dersigmax(fNPeaks, i1, i2,
 
 2279                               working_space, working_space[peak_vel],
 
 2280                               working_space[peak_vel + 1],
 
 2281                               working_space[peak_vel + 2],
 
 2282                               working_space[peak_vel + 6],
 
 2283                               working_space[peak_vel + 7],
 
 2284                               working_space[peak_vel + 8],
 
 2285                               working_space[peak_vel + 10],
 
 2286                               working_space[peak_vel + 12],
 
 2287                               working_space[peak_vel + 13]);
 
 2288                if (fFitTaylor == kFitTaylorOrderSecond)
 
 2289                   d = Derdersigmax(fNPeaks, i1,
 
 2291                                     working_space[peak_vel],
 
 2292                                     working_space[peak_vel + 1],
 
 2293                                     working_space[peak_vel + 2]);
 
 2296                   if (TMath::Abs(a) > 0.00000001
 
 2297                        && fFitTaylor == kFitTaylorOrderSecond) {
 
 2298                      d = d * TMath::Abs(yw - f) / (2 * a * ywm);
 
 2299                      if (((a + d) <= 0 && a >= 0) || ((a + d) >= 0 && a <= 0))
 
 2306                   if (fStatisticType == kFitOptimChiFuncValues) {
 
 2307                      b = a * (yw * yw - f * f) / (ywm * ywm);
 
 2308                      working_space[2 * shift + k] += b * c; 
 
 2309                      b = a * a * (4 * yw - 2 * f) / (ywm * ywm);
 
 2310                      working_space[3 * shift + k] += b * c; 
 
 2314                      b = a * (yw - f) / ywm;
 
 2315                      working_space[2 * shift + k] += b * c; 
 
 2317                      working_space[3 * shift + k] += b * c; 
 
 2322             if (fFixSigmaY == 
false) {
 
 2323                a = Dersigmay(fNPeaks, i1, i2,
 
 2324                               working_space, working_space[peak_vel],
 
 2325                               working_space[peak_vel + 1],
 
 2326                               working_space[peak_vel + 2],
 
 2327                               working_space[peak_vel + 6],
 
 2328                               working_space[peak_vel + 7],
 
 2329                               working_space[peak_vel + 9],
 
 2330                               working_space[peak_vel + 11],
 
 2331                               working_space[peak_vel + 12],
 
 2332                               working_space[peak_vel + 13]);
 
 2333                if (fFitTaylor == kFitTaylorOrderSecond)
 
 2334                   d = Derdersigmay(fNPeaks, i1,
 
 2336                                     working_space[peak_vel],
 
 2337                                     working_space[peak_vel + 1],
 
 2338                                     working_space[peak_vel + 2]);
 
 2341                   if (TMath::Abs(a) > 0.00000001
 
 2342                        && fFitTaylor == kFitTaylorOrderSecond) {
 
 2343                      d = d * TMath::Abs(yw - f) / (2 * a * ywm);
 
 2344                      if (((a + d) <= 0 && a >= 0) || ((a + d) >= 0 && a <= 0))
 
 2351                   if (fStatisticType == kFitOptimChiFuncValues) {
 
 2352                      b = a * (yw * yw - f * f) / (ywm * ywm);
 
 2353                      working_space[2 * shift + k] += b * c; 
 
 2354                      b = a * a * (4 * yw - 2 * f) / (ywm * ywm);
 
 2355                      working_space[3 * shift + k] += b * c; 
 
 2359                      b = a * (yw - f) / ywm;
 
 2360                      working_space[2 * shift + k] += b * c; 
 
 2362                      working_space[3 * shift + k] += b * c; 
 
 2367             if (fFixRo == 
false) {
 
 2368                a = Derro(fNPeaks, i1, i2,
 
 2369                           working_space, working_space[peak_vel],
 
 2370                           working_space[peak_vel + 1],
 
 2371                           working_space[peak_vel + 2]);
 
 2374                   if (TMath::Abs(a) > 0.00000001
 
 2375                        && fFitTaylor == kFitTaylorOrderSecond) {
 
 2376                      d = d * TMath::Abs(yw - f) / (2 * a * ywm);
 
 2377                      if (((a + d) <= 0 && a >= 0) || ((a + d) >= 0 && a <= 0))
 
 2384                   if (fStatisticType == kFitOptimChiFuncValues) {
 
 2385                      b = a * (yw * yw - f * f) / (ywm * ywm);
 
 2386                      working_space[2 * shift + k] += b * c; 
 
 2387                      b = a * a * (4 * yw - 2 * f) / (ywm * ywm);
 
 2388                      working_space[3 * shift + k] += b * c; 
 
 2392                      b = a * (yw - f) / ywm;
 
 2393                      working_space[2 * shift + k] += b * c; 
 
 2395                      working_space[3 * shift + k] += b * c; 
 
 2400             if (fFixA0 == 
false) {
 
 2404                   if (fStatisticType == kFitOptimChiFuncValues) {
 
 2405                      b = a * (yw * yw - f * f) / (ywm * ywm);
 
 2406                      working_space[2 * shift + k] += b * c; 
 
 2407                      b = a * a * (4 * yw - 2 * f) / (ywm * ywm);
 
 2408                      working_space[3 * shift + k] += b * c; 
 
 2412                      b = a * (yw - f) / ywm;
 
 2413                      working_space[2 * shift + k] += b * c; 
 
 2415                      working_space[3 * shift + k] += b * c; 
 
 2420             if (fFixAx == 
false) {
 
 2424                   if (fStatisticType == kFitOptimChiFuncValues) {
 
 2425                      b = a * (yw * yw - f * f) / (ywm * ywm);
 
 2426                      working_space[2 * shift + k] += b * c; 
 
 2427                      b = a * a * (4 * yw - 2 * f) / (ywm * ywm);
 
 2428                      working_space[3 * shift + k] += b * c; 
 
 2432                      b = a * (yw - f) / ywm;
 
 2433                      working_space[2 * shift + k] += b * c; 
 
 2435                      working_space[3 * shift + k] += b * c; 
 
 2440             if (fFixAy == 
false) {
 
 2444                   if (fStatisticType == kFitOptimChiFuncValues) {
 
 2445                      b = a * (yw * yw - f * f) / (ywm * ywm);
 
 2446                      working_space[2 * shift + k] += b * c; 
 
 2447                      b = a * a * (4 * yw - 2 * f) / (ywm * ywm);
 
 2448                      working_space[3 * shift + k] += b * c; 
 
 2452                      b = a * (yw - f) / ywm;
 
 2453                      working_space[2 * shift + k] += b * c; 
 
 2455                      working_space[3 * shift + k] += b * c; 
 
 2460             if (fFixTxy == 
false) {
 
 2461                a = Dertxy(fNPeaks, i1, i2,
 
 2462                            working_space, working_space[peak_vel],
 
 2463                            working_space[peak_vel + 1],
 
 2464                            working_space[peak_vel + 12],
 
 2465                            working_space[peak_vel + 13]);
 
 2468                   if (fStatisticType == kFitOptimChiFuncValues) {
 
 2469                      b = a * (yw * yw - f * f) / (ywm * ywm);
 
 2470                      working_space[2 * shift + k] += b * c; 
 
 2471                      b = a * a * (4 * yw - 2 * f) / (ywm * ywm);
 
 2472                      working_space[3 * shift + k] += b * c; 
 
 2476                      b = a * (yw - f) / ywm;
 
 2477                      working_space[2 * shift + k] += b * c; 
 
 2479                      working_space[3 * shift + k] += b * c; 
 
 2484             if (fFixSxy == 
false) {
 
 2485                a = Dersxy(fNPeaks, i1, i2,
 
 2486                            working_space, working_space[peak_vel],
 
 2487                            working_space[peak_vel + 1]);
 
 2490                   if (fStatisticType == kFitOptimChiFuncValues) {
 
 2491                      b = a * (yw * yw - f * f) / (ywm * ywm);
 
 2492                      working_space[2 * shift + k] += b * c; 
 
 2493                      b = a * a * (4 * yw - 2 * f) / (ywm * ywm);
 
 2494                      working_space[3 * shift + k] += b * c; 
 
 2498                      b = a * (yw - f) / ywm;
 
 2499                      working_space[2 * shift + k] += b * c; 
 
 2501                      working_space[3 * shift + k] += b * c; 
 
 2506             if (fFixTx == 
false) {
 
 2507                a = Dertx(fNPeaks, i1, working_space,
 
 2508                           working_space[peak_vel],
 
 2509                           working_space[peak_vel + 12]);
 
 2512                   if (fStatisticType == kFitOptimChiFuncValues) {
 
 2513                      b = a * (yw * yw - f * f) / (ywm * ywm);
 
 2514                      working_space[2 * shift + k] += b * c; 
 
 2515                      b = a * a * (4 * yw - 2 * f) / (ywm * ywm);
 
 2516                      working_space[3 * shift + k] += b * c; 
 
 2520                      b = a * (yw - f) / ywm;
 
 2521                      working_space[2 * shift + k] += b * c; 
 
 2523                      working_space[3 * shift + k] += b * c; 
 
 2528             if (fFixTy == 
false) {
 
 2529                a = Derty(fNPeaks, i2, working_space,
 
 2530                           working_space[peak_vel + 1],
 
 2531                           working_space[peak_vel + 13]);
 
 2534                   if (fStatisticType == kFitOptimChiFuncValues) {
 
 2535                      b = a * (yw * yw - f * f) / (ywm * ywm);
 
 2536                      working_space[2 * shift + k] += b * c; 
 
 2537                      b = a * a * (4 * yw - 2 * f) / (ywm * ywm);
 
 2538                      working_space[3 * shift + k] += b * c; 
 
 2542                      b = a * (yw - f) / ywm;
 
 2543                      working_space[2 * shift + k] += b * c; 
 
 2545                      working_space[3 * shift + k] += b * c; 
 
 2550             if (fFixSx == 
false) {
 
 2551                a = Dersx(fNPeaks, i1, working_space,
 
 2552                           working_space[peak_vel]);
 
 2555                   if (fStatisticType == kFitOptimChiFuncValues) {
 
 2556                      b = a * (yw * yw - f * f) / (ywm * ywm);
 
 2557                      working_space[2 * shift + k] += b * c; 
 
 2558                      b = a * a * (4 * yw - 2 * f) / (ywm * ywm);
 
 2559                      working_space[3 * shift + k] += b * c; 
 
 2563                      b = a * (yw - f) / ywm;
 
 2564                      working_space[2 * shift + k] += b * c; 
 
 2566                      working_space[3 * shift + k] += b * c; 
 
 2571             if (fFixSy == 
false) {
 
 2572                a = Dersy(fNPeaks, i2, working_space,
 
 2573                           working_space[peak_vel + 1]);
 
 2576                   if (fStatisticType == kFitOptimChiFuncValues) {
 
 2577                      b = a * (yw * yw - f * f) / (ywm * ywm);
 
 2578                      working_space[2 * shift + k] += b * c; 
 
 2579                      b = a * a * (4 * yw - 2 * f) / (ywm * ywm);
 
 2580                      working_space[3 * shift + k] += b * c; 
 
 2584                      b = a * (yw - f) / ywm;
 
 2585                      working_space[2 * shift + k] += b * c; 
 
 2587                      working_space[3 * shift + k] += b * c; 
 
 2592             if (fFixBx == 
false) {
 
 2593                a = Derbx(fNPeaks, i1, i2,
 
 2594                           working_space, working_space[peak_vel],
 
 2595                           working_space[peak_vel + 1],
 
 2596                           working_space[peak_vel + 6],
 
 2597                           working_space[peak_vel + 8],
 
 2598                           working_space[peak_vel + 12],
 
 2599                           working_space[peak_vel + 13]);
 
 2602                   if (fStatisticType == kFitOptimChiFuncValues) {
 
 2603                      b = a * (yw * yw - f * f) / (ywm * ywm);
 
 2604                      working_space[2 * shift + k] += b * c; 
 
 2605                      b = a * a * (4 * yw - 2 * f) / (ywm * ywm);
 
 2606                      working_space[3 * shift + k] += b * c; 
 
 2610                      b = a * (yw - f) / ywm;
 
 2611                      working_space[2 * shift + k] += b * c; 
 
 2613                      working_space[3 * shift + k] += b * c; 
 
 2618             if (fFixBy == 
false) {
 
 2619                a = Derby(fNPeaks, i1, i2,
 
 2620                           working_space, working_space[peak_vel],
 
 2621                           working_space[peak_vel + 1],
 
 2622                           working_space[peak_vel + 6],
 
 2623                           working_space[peak_vel + 8],
 
 2624                           working_space[peak_vel + 12],
 
 2625                           working_space[peak_vel + 13]);
 
 2628                   if (fStatisticType == kFitOptimChiFuncValues) {
 
 2629                      b = a * (yw * yw - f * f) / (ywm * ywm);
 
 2630                      working_space[2 * shift + k] += b * c; 
 
 2631                      b = a * a * (4 * yw - 2 * f) / (ywm * ywm);
 
 2632                      working_space[3 * shift + k] += b * c; 
 
 2636                      b = a * (yw - f) / ywm;
 
 2637                      working_space[2 * shift + k] += b * c; 
 
 2639                      working_space[3 * shift + k] += b * c; 
 
 2646       for (j = 0; j < size; j++) {
 
 2647          if (TMath::Abs(working_space[3 * shift + j]) > 0.000001)
 
 2648             working_space[2 * shift + j] = working_space[2 * shift + j] / TMath::Abs(working_space[3 * shift + j]); 
 
 2650             working_space[2 * shift + j] = 0; 
 
 2655       chi_opt = TMath::Sqrt(TMath::Abs(chi_opt));
 
 2659       for (j = 0; j < size; j++) {
 
 2660          working_space[4 * shift + j] = working_space[shift + j]; 
 
 2664          if (fAlphaOptim == kFitAlphaOptimal) {
 
 2665             if (fStatisticType != kFitOptimMaxLikelihood)
 
 2666                chi_min = 10000 * chi2;
 
 2669                chi_min = 0.1 * chi2;
 
 2671             for (pi = 0.1; flag == 0 && pi <= 100; pi += 0.1) {
 
 2672                for (j = 0; j < size; j++) {
 
 2673                   working_space[shift + j] = working_space[4 * shift + j] + pi * alpha * working_space[2 * shift + j]; 
 
 2675                for (i = 0, j = 0; i < fNPeaks; i++) {
 
 2676                   if (fFixAmp[i] == 
false) {
 
 2677                      if (working_space[shift + j] < 0) 
 
 2678                         working_space[shift + j] = 0; 
 
 2679                      working_space[7 * i] = working_space[shift + j]; 
 
 2682                   if (fFixPositionX[i] == 
false) {
 
 2683                      if (working_space[shift + j] < fXmin) 
 
 2684                         working_space[shift + j] = fXmin; 
 
 2685                      if (working_space[shift + j] > fXmax) 
 
 2686                         working_space[shift + j] = fXmax; 
 
 2687                      working_space[7 * i + 1] = working_space[shift + j]; 
 
 2690                   if (fFixPositionY[i] == 
false) {
 
 2691                      if (working_space[shift + j] < fYmin) 
 
 2692                         working_space[shift + j] = fYmin; 
 
 2693                      if (working_space[shift + j] > fYmax) 
 
 2694                         working_space[shift + j] = fYmax; 
 
 2695                      working_space[7 * i + 2] = working_space[shift + j]; 
 
 2698                   if (fFixAmpX1[i] == 
false) {
 
 2699                      if (working_space[shift + j] < 0) 
 
 2700                         working_space[shift + j] = 0; 
 
 2701                      working_space[7 * i + 3] = working_space[shift + j]; 
 
 2704                   if (fFixAmpY1[i] == 
false) {
 
 2705                      if (working_space[shift + j] < 0) 
 
 2706                         working_space[shift + j] = 0; 
 
 2707                      working_space[7 * i + 4] = working_space[shift + j]; 
 
 2710                   if (fFixPositionX1[i] == 
false) {
 
 2711                      if (working_space[shift + j] < fXmin) 
 
 2712                         working_space[shift + j] = fXmin; 
 
 2713                      if (working_space[shift + j] > fXmax) 
 
 2714                         working_space[shift + j] = fXmax; 
 
 2715                      working_space[7 * i + 5] = working_space[shift + j]; 
 
 2718                   if (fFixPositionY1[i] == 
false) {
 
 2719                      if (working_space[shift + j] < fYmin) 
 
 2720                         working_space[shift + j] = fYmin; 
 
 2721                      if (working_space[shift + j] > fYmax) 
 
 2722                         working_space[shift + j] = fYmax; 
 
 2723                      working_space[7 * i + 6] = working_space[shift + j]; 
 
 2727                if (fFixSigmaX == 
false) {
 
 2728                   if (working_space[shift + j] < 0.001) { 
 
 2729                      working_space[shift + j] = 0.001; 
 
 2731                   working_space[peak_vel] = working_space[shift + j]; 
 
 2734                if (fFixSigmaY == 
false) {
 
 2735                   if (working_space[shift + j] < 0.001) { 
 
 2736                      working_space[shift + j] = 0.001; 
 
 2738                   working_space[peak_vel + 1] = working_space[shift + j]; 
 
 2741                if (fFixRo == 
false) {
 
 2742                   if (working_space[shift + j] < -1) { 
 
 2743                      working_space[shift + j] = -1; 
 
 2745                   if (working_space[shift + j] > 1) { 
 
 2746                      working_space[shift + j] = 1; 
 
 2748                   working_space[peak_vel + 2] = working_space[shift + j]; 
 
 2751                if (fFixA0 == 
false) {
 
 2752                   working_space[peak_vel + 3] = working_space[shift + j]; 
 
 2755                if (fFixAx == 
false) {
 
 2756                   working_space[peak_vel + 4] = working_space[shift + j]; 
 
 2759                if (fFixAy == 
false) {
 
 2760                   working_space[peak_vel + 5] = working_space[shift + j]; 
 
 2763                if (fFixTxy == 
false) {
 
 2764                   working_space[peak_vel + 6] = working_space[shift + j]; 
 
 2767                if (fFixSxy == 
false) {
 
 2768                   working_space[peak_vel + 7] = working_space[shift + j]; 
 
 2771                if (fFixTx == 
false) {
 
 2772                   working_space[peak_vel + 8] = working_space[shift + j]; 
 
 2775                if (fFixTy == 
false) {
 
 2776                   working_space[peak_vel + 9] = working_space[shift + j]; 
 
 2779                if (fFixSx == 
false) {
 
 2780                   working_space[peak_vel + 10] = working_space[shift + j]; 
 
 2783                if (fFixSy == 
false) {
 
 2784                   working_space[peak_vel + 11] = working_space[shift + j]; 
 
 2787                if (fFixBx == 
false) {
 
 2788                   if (TMath::Abs(working_space[shift + j]) < 0.001) { 
 
 2789                      if (working_space[shift + j] < 0) 
 
 2790                         working_space[shift + j] = -0.001; 
 
 2792                         working_space[shift + j] = 0.001; 
 
 2794                   working_space[peak_vel + 12] = working_space[shift + j]; 
 
 2797                if (fFixBy == 
false) {
 
 2798                   if (TMath::Abs(working_space[shift + j]) < 0.001) { 
 
 2799                      if (working_space[shift + j] < 0) 
 
 2800                         working_space[shift + j] = -0.001; 
 
 2802                         working_space[shift + j] = 0.001; 
 
 2804                   working_space[peak_vel + 13] = working_space[shift + j]; 
 
 2808                for (i1 = fXmin; i1 <= fXmax; i1++) {
 
 2809                   for (i2 = fYmin; i2 <= fYmax; i2++) {
 
 2810                      yw = source[i1][i2];
 
 2812                      f = Shape2(fNPeaks, i1,
 
 2814                                  working_space[peak_vel],
 
 2815                                  working_space[peak_vel + 1],
 
 2816                                  working_space[peak_vel + 2],
 
 2817                                  working_space[peak_vel + 3],
 
 2818                                  working_space[peak_vel + 4],
 
 2819                                  working_space[peak_vel + 5],
 
 2820                                  working_space[peak_vel + 6],
 
 2821                                  working_space[peak_vel + 7],
 
 2822                                  working_space[peak_vel + 8],
 
 2823                                  working_space[peak_vel + 9],
 
 2824                                  working_space[peak_vel + 10],
 
 2825                                  working_space[peak_vel + 11],
 
 2826                                  working_space[peak_vel + 12],
 
 2827                                  working_space[peak_vel + 13]);
 
 2828                      if (fStatisticType == kFitOptimChiFuncValues) {
 
 2833                      if (fStatisticType == kFitOptimMaxLikelihood) {
 
 2835                            chi2 += yw * TMath::Log(f) - f;
 
 2840                            chi2 += (yw - f) * (yw - f) / ywm;
 
 2845                     && fStatisticType != kFitOptimMaxLikelihood)
 
 2847                     && fStatisticType == kFitOptimMaxLikelihood)) {
 
 2848                   pmin = pi, chi_min = chi2;
 
 2858                for (j = 0; j < size; j++) {
 
 2859                   working_space[shift + j] = working_space[4 * shift + j] + pmin * alpha * working_space[2 * shift + j]; 
 
 2861                for (i = 0, j = 0; i < fNPeaks; i++) {
 
 2862                   if (fFixAmp[i] == 
false) {
 
 2863                      if (working_space[shift + j] < 0) 
 
 2864                         working_space[shift + j] = 0; 
 
 2865                      working_space[7 * i] = working_space[shift + j]; 
 
 2868                   if (fFixPositionX[i] == 
false) {
 
 2869                      if (working_space[shift + j] < fXmin) 
 
 2870                         working_space[shift + j] = fXmin; 
 
 2871                      if (working_space[shift + j] > fXmax) 
 
 2872                         working_space[shift + j] = fXmax; 
 
 2873                      working_space[7 * i + 1] = working_space[shift + j]; 
 
 2876                   if (fFixPositionY[i] == 
false) {
 
 2877                      if (working_space[shift + j] < fYmin) 
 
 2878                         working_space[shift + j] = fYmin; 
 
 2879                      if (working_space[shift + j] > fYmax) 
 
 2880                         working_space[shift + j] = fYmax; 
 
 2881                      working_space[7 * i + 2] = working_space[shift + j]; 
 
 2884                   if (fFixAmpX1[i] == 
false) {
 
 2885                      if (working_space[shift + j] < 0) 
 
 2886                         working_space[shift + j] = 0; 
 
 2887                      working_space[7 * i + 3] = working_space[shift + j]; 
 
 2890                   if (fFixAmpY1[i] == 
false) {
 
 2891                      if (working_space[shift + j] < 0) 
 
 2892                         working_space[shift + j] = 0; 
 
 2893                      working_space[7 * i + 4] = working_space[shift + j]; 
 
 2896                   if (fFixPositionX1[i] == 
false) {
 
 2897                      if (working_space[shift + j] < fXmin) 
 
 2898                         working_space[shift + j] = fXmin; 
 
 2899                      if (working_space[shift + j] > fXmax) 
 
 2900                         working_space[shift + j] = fXmax; 
 
 2901                      working_space[7 * i + 5] = working_space[shift + j]; 
 
 2904                   if (fFixPositionY1[i] == 
false) {
 
 2905                      if (working_space[shift + j] < fYmin) 
 
 2906                         working_space[shift + j] = fYmin; 
 
 2907                      if (working_space[shift + j] > fYmax) 
 
 2908                         working_space[shift + j] = fYmax; 
 
 2909                      working_space[7 * i + 6] = working_space[shift + j]; 
 
 2913                if (fFixSigmaX == 
false) {
 
 2914                   if (working_space[shift + j] < 0.001) { 
 
 2915                      working_space[shift + j] = 0.001; 
 
 2917                   working_space[peak_vel] = working_space[shift + j]; 
 
 2920                if (fFixSigmaY == 
false) {
 
 2921                   if (working_space[shift + j] < 0.001) { 
 
 2922                      working_space[shift + j] = 0.001; 
 
 2924                   working_space[peak_vel + 1] = working_space[shift + j]; 
 
 2927                if (fFixRo == 
false) {
 
 2928                   if (working_space[shift + j] < -1) { 
 
 2929                      working_space[shift + j] = -1; 
 
 2931                   if (working_space[shift + j] > 1) { 
 
 2932                      working_space[shift + j] = 1; 
 
 2934                   working_space[peak_vel + 2] = working_space[shift + j]; 
 
 2937                if (fFixA0 == 
false) {
 
 2938                   working_space[peak_vel + 3] = working_space[shift + j]; 
 
 2941                if (fFixAx == 
false) {
 
 2942                   working_space[peak_vel + 4] = working_space[shift + j]; 
 
 2945                if (fFixAy == 
false) {
 
 2946                   working_space[peak_vel + 5] = working_space[shift + j]; 
 
 2949                if (fFixTxy == 
false) {
 
 2950                   working_space[peak_vel + 6] = working_space[shift + j]; 
 
 2953                if (fFixSxy == 
false) {
 
 2954                   working_space[peak_vel + 7] = working_space[shift + j]; 
 
 2957                if (fFixTx == 
false) {
 
 2958                   working_space[peak_vel + 8] = working_space[shift + j]; 
 
 2961                if (fFixTy == 
false) {
 
 2962                   working_space[peak_vel + 9] = working_space[shift + j]; 
 
 2965                if (fFixSx == 
false) {
 
 2966                   working_space[peak_vel + 10] = working_space[shift + j]; 
 
 2969                if (fFixSy == 
false) {
 
 2970                   working_space[peak_vel + 11] = working_space[shift + j]; 
 
 2973                if (fFixBx == 
false) {
 
 2974                   if (TMath::Abs(working_space[shift + j]) < 0.001) { 
 
 2975                      if (working_space[shift + j] < 0) 
 
 2976                         working_space[shift + j] = -0.001; 
 
 2978                         working_space[shift + j] = 0.001; 
 
 2980                   working_space[peak_vel + 12] = working_space[shift + j]; 
 
 2983                if (fFixBy == 
false) {
 
 2984                   if (TMath::Abs(working_space[shift + j]) < 0.001) { 
 
 2985                      if (working_space[shift + j] < 0) 
 
 2986                         working_space[shift + j] = -0.001; 
 
 2988                         working_space[shift + j] = 0.001; 
 
 2990                   working_space[peak_vel + 13] = working_space[shift + j]; 
 
 2998             for (j = 0; j < size; j++) {
 
 2999                working_space[shift + j] = working_space[4 * shift + j] + alpha * working_space[2 * shift + j]; 
 
 3001             for (i = 0, j = 0; i < fNPeaks; i++) {
 
 3002                if (fFixAmp[i] == 
false) {
 
 3003                   if (working_space[shift + j] < 0) 
 
 3004                      working_space[shift + j] = 0; 
 
 3005                   working_space[7 * i] = working_space[shift + j]; 
 
 3008                if (fFixPositionX[i] == 
false) {
 
 3009                   if (working_space[shift + j] < fXmin) 
 
 3010                      working_space[shift + j] = fXmin; 
 
 3011                   if (working_space[shift + j] > fXmax) 
 
 3012                      working_space[shift + j] = fXmax; 
 
 3013                   working_space[7 * i + 1] = working_space[shift + j]; 
 
 3016                if (fFixPositionY[i] == 
false) {
 
 3017                   if (working_space[shift + j] < fYmin) 
 
 3018                      working_space[shift + j] = fYmin; 
 
 3019                   if (working_space[shift + j] > fYmax) 
 
 3020                      working_space[shift + j] = fYmax; 
 
 3021                   working_space[7 * i + 2] = working_space[shift + j]; 
 
 3024                if (fFixAmpX1[i] == 
false) {
 
 3025                   if (working_space[shift + j] < 0) 
 
 3026                      working_space[shift + j] = 0; 
 
 3027                   working_space[7 * i + 3] = working_space[shift + j]; 
 
 3030                if (fFixAmpY1[i] == 
false) {
 
 3031                   if (working_space[shift + j] < 0) 
 
 3032                      working_space[shift + j] = 0; 
 
 3033                   working_space[7 * i + 4] = working_space[shift + j]; 
 
 3036                if (fFixPositionX1[i] == 
false) {
 
 3037                   if (working_space[shift + j] < fXmin) 
 
 3038                      working_space[shift + j] = fXmin; 
 
 3039                   if (working_space[shift + j] > fXmax) 
 
 3040                      working_space[shift + j] = fXmax; 
 
 3041                   working_space[7 * i + 5] = working_space[shift + j]; 
 
 3044                if (fFixPositionY1[i] == 
false) {
 
 3045                   if (working_space[shift + j] < fYmin) 
 
 3046                      working_space[shift + j] = fYmin; 
 
 3047                   if (working_space[shift + j] > fYmax) 
 
 3048                      working_space[shift + j] = fYmax; 
 
 3049                   working_space[7 * i + 6] = working_space[shift + j]; 
 
 3053             if (fFixSigmaX == 
false) {
 
 3054                if (working_space[shift + j] < 0.001) { 
 
 3055                   working_space[shift + j] = 0.001; 
 
 3057                working_space[peak_vel] = working_space[shift + j]; 
 
 3060             if (fFixSigmaY == 
false) {
 
 3061                if (working_space[shift + j] < 0.001) { 
 
 3062                   working_space[shift + j] = 0.001; 
 
 3064                working_space[peak_vel + 1] = working_space[shift + j]; 
 
 3067             if (fFixRo == 
false) {
 
 3068                if (working_space[shift + j] < -1) { 
 
 3069                   working_space[shift + j] = -1; 
 
 3071                if (working_space[shift + j] > 1) { 
 
 3072                   working_space[shift + j] = 1; 
 
 3074                working_space[peak_vel + 2] = working_space[shift + j]; 
 
 3077             if (fFixA0 == 
false) {
 
 3078                working_space[peak_vel + 3] = working_space[shift + j]; 
 
 3081             if (fFixAx == 
false) {
 
 3082                working_space[peak_vel + 4] = working_space[shift + j]; 
 
 3085             if (fFixAy == 
false) {
 
 3086                working_space[peak_vel + 5] = working_space[shift + j]; 
 
 3089             if (fFixTxy == 
false) {
 
 3090                working_space[peak_vel + 6] = working_space[shift + j]; 
 
 3093             if (fFixSxy == 
false) {
 
 3094                working_space[peak_vel + 7] = working_space[shift + j]; 
 
 3097             if (fFixTx == 
false) {
 
 3098                working_space[peak_vel + 8] = working_space[shift + j]; 
 
 3101             if (fFixTy == 
false) {
 
 3102                working_space[peak_vel + 9] = working_space[shift + j]; 
 
 3105             if (fFixSx == 
false) {
 
 3106                working_space[peak_vel + 10] = working_space[shift + j]; 
 
 3109             if (fFixSy == 
false) {
 
 3110                working_space[peak_vel + 11] = working_space[shift + j]; 
 
 3113             if (fFixBx == 
false) {
 
 3114                if (TMath::Abs(working_space[shift + j]) < 0.001) { 
 
 3115                   if (working_space[shift + j] < 0) 
 
 3116                      working_space[shift + j] = -0.001; 
 
 3118                      working_space[shift + j] = 0.001; 
 
 3120                working_space[peak_vel + 12] = working_space[shift + j]; 
 
 3123             if (fFixBy == 
false) {
 
 3124                if (TMath::Abs(working_space[shift + j]) < 0.001) { 
 
 3125                   if (working_space[shift + j] < 0) 
 
 3126                      working_space[shift + j] = -0.001; 
 
 3128                      working_space[shift + j] = 0.001; 
 
 3130                working_space[peak_vel + 13] = working_space[shift + j]; 
 
 3134             for (i1 = fXmin; i1 <= fXmax; i1++) {
 
 3135                for (i2 = fYmin; i2 <= fYmax; i2++) {
 
 3136                   yw = source[i1][i2];
 
 3138                   f = Shape2(fNPeaks, i1, i2,
 
 3139                               working_space, working_space[peak_vel],
 
 3140                               working_space[peak_vel + 1],
 
 3141                               working_space[peak_vel + 2],
 
 3142                               working_space[peak_vel + 3],
 
 3143                               working_space[peak_vel + 4],
 
 3144                               working_space[peak_vel + 5],
 
 3145                               working_space[peak_vel + 6],
 
 3146                               working_space[peak_vel + 7],
 
 3147                               working_space[peak_vel + 8],
 
 3148                               working_space[peak_vel + 9],
 
 3149                               working_space[peak_vel + 10],
 
 3150                               working_space[peak_vel + 11],
 
 3151                               working_space[peak_vel + 12],
 
 3152                               working_space[peak_vel + 13]);
 
 3153                   if (fStatisticType == kFitOptimChiFuncValues) {
 
 3158                   if (fStatisticType == kFitOptimMaxLikelihood) {
 
 3160                         chi += yw * TMath::Log(f) - f;
 
 3165                         chi += (yw - f) * (yw - f) / ywm;
 
 3171          chi = TMath::Sqrt(TMath::Abs(chi));
 
 3172          if (fAlphaOptim == kFitAlphaHalving && chi > 1E-6)
 
 3173             alpha = alpha * chi_opt / (2 * chi);
 
 3175          else if (fAlphaOptim == kFitAlphaOptimal)
 
 3176             alpha = alpha / 10.0;
 
 3179       } 
while (((chi > chi_opt
 
 3180                  && fStatisticType != kFitOptimMaxLikelihood)
 
 3182                  && fStatisticType == kFitOptimMaxLikelihood))
 
 3183                 && regul_cycle < kFitNumRegulCycles);
 
 3184       for (j = 0; j < size; j++) {
 
 3185          working_space[4 * shift + j] = 0; 
 
 3186          working_space[2 * shift + j] = 0; 
 
 3188       for (i1 = fXmin, chi_cel = 0; i1 <= fXmax; i1++) {
 
 3189          for (i2 = fYmin; i2 <= fYmax; i2++) {
 
 3190             yw = source[i1][i2];
 
 3193             f = Shape2(fNPeaks, i1, i2,
 
 3194                         working_space, working_space[peak_vel],
 
 3195                         working_space[peak_vel + 1],
 
 3196                         working_space[peak_vel + 2],
 
 3197                         working_space[peak_vel + 3],
 
 3198                         working_space[peak_vel + 4],
 
 3199                         working_space[peak_vel + 5],
 
 3200                         working_space[peak_vel + 6],
 
 3201                         working_space[peak_vel + 7],
 
 3202                         working_space[peak_vel + 8],
 
 3203                         working_space[peak_vel + 9],
 
 3204                         working_space[peak_vel + 10],
 
 3205                         working_space[peak_vel + 11],
 
 3206                         working_space[peak_vel + 12],
 
 3207                         working_space[peak_vel + 13]);
 
 3208             chi_opt = (yw - f) * (yw - f) / yw;
 
 3209             chi_cel += (yw - f) * (yw - f) / yw;
 
 3212                 for (j = 0, k = 0; j < fNPeaks; j++) {
 
 3213                if (fFixAmp[j] == 
false) {
 
 3215                                working_space[7 * j + 1],
 
 3216                                working_space[7 * j + 2],
 
 3217                                working_space[peak_vel],
 
 3218                                working_space[peak_vel + 1],
 
 3219                                working_space[peak_vel + 2],
 
 3220                                working_space[peak_vel + 6],
 
 3221                                working_space[peak_vel + 7],
 
 3222                                working_space[peak_vel + 12],
 
 3223                                working_space[peak_vel + 13]);
 
 3226                      working_space[2 * shift + k] += chi_opt * c; 
 
 3228                      working_space[4 * shift + k] += b * c; 
 
 3232                if (fFixPositionX[j] == 
false) {
 
 3234                               working_space[7 * j],
 
 3235                               working_space[7 * j + 1],
 
 3236                               working_space[7 * j + 2],
 
 3237                               working_space[peak_vel],
 
 3238                               working_space[peak_vel + 1],
 
 3239                               working_space[peak_vel + 2],
 
 3240                               working_space[peak_vel + 6],
 
 3241                               working_space[peak_vel + 7],
 
 3242                               working_space[peak_vel + 12],
 
 3243                               working_space[peak_vel + 13]);
 
 3246                      working_space[2 * shift + k] += chi_opt * c; 
 
 3248                      working_space[4 * shift + k] += b * c; 
 
 3252                if (fFixPositionY[j] == 
false) {
 
 3254                               working_space[7 * j],
 
 3255                               working_space[7 * j + 1],
 
 3256                               working_space[7 * j + 2],
 
 3257                               working_space[peak_vel],
 
 3258                               working_space[peak_vel + 1],
 
 3259                               working_space[peak_vel + 2],
 
 3260                               working_space[peak_vel + 6],
 
 3261                               working_space[peak_vel + 7],
 
 3262                               working_space[peak_vel + 12],
 
 3263                               working_space[peak_vel + 13]);
 
 3266                      working_space[2 * shift + k] += chi_opt * c; 
 
 3268                      working_space[4 * shift + k] += b * c; 
 
 3272                if (fFixAmpX1[j] == 
false) {
 
 3273                   a = Derampx(i1, working_space[7 * j + 5],
 
 3274                                working_space[peak_vel],
 
 3275                                working_space[peak_vel + 8],
 
 3276                                working_space[peak_vel + 10],
 
 3277                                working_space[peak_vel + 12]);
 
 3280                      working_space[2 * shift + k] += chi_opt * c; 
 
 3282                      working_space[4 * shift + k] += b * c; 
 
 3286                if (fFixAmpY1[j] == 
false) {
 
 3287                   a = Derampx(i2, working_space[7 * j + 6],
 
 3288                                working_space[peak_vel + 1],
 
 3289                                working_space[peak_vel + 9],
 
 3290                                working_space[peak_vel + 11],
 
 3291                                working_space[peak_vel + 13]);
 
 3294                      working_space[2 * shift + k] += chi_opt * c; 
 
 3296                      working_space[4 * shift + k] += b * c; 
 
 3300                if (fFixPositionX1[j] == 
false) {
 
 3301                   a = Deri01(i1, working_space[7 * j + 3],
 
 3302                               working_space[7 * j + 5],
 
 3303                               working_space[peak_vel],
 
 3304                               working_space[peak_vel + 8],
 
 3305                               working_space[peak_vel + 10],
 
 3306                               working_space[peak_vel + 12]);
 
 3309                      working_space[2 * shift + k] += chi_opt * c; 
 
 3311                      working_space[4 * shift + k] += b * c; 
 
 3315                if (fFixPositionY1[j] == 
false) {
 
 3316                   a = Deri01(i2, working_space[7 * j + 4],
 
 3317                               working_space[7 * j + 6],
 
 3318                               working_space[peak_vel + 1],
 
 3319                               working_space[peak_vel + 9],
 
 3320                               working_space[peak_vel + 11],
 
 3321                               working_space[peak_vel + 13]);
 
 3324                      working_space[2 * shift + k] += chi_opt * c; 
 
 3326                      working_space[4 * shift + k] += b * c; 
 
 3331             if (fFixSigmaX == 
false) {
 
 3332                a = Dersigmax(fNPeaks, i1, i2,
 
 3333                               working_space, working_space[peak_vel],
 
 3334                               working_space[peak_vel + 1],
 
 3335                               working_space[peak_vel + 2],
 
 3336                               working_space[peak_vel + 6],
 
 3337                               working_space[peak_vel + 7],
 
 3338                               working_space[peak_vel + 8],
 
 3339                               working_space[peak_vel + 10],
 
 3340                               working_space[peak_vel + 12],
 
 3341                               working_space[peak_vel + 13]);
 
 3344                   working_space[2 * shift + k] += chi_opt * c; 
 
 3346                   working_space[4 * shift + k] += b * c; 
 
 3350             if (fFixSigmaY == 
false) {
 
 3351                a = Dersigmay(fNPeaks, i1, i2,
 
 3352                               working_space, working_space[peak_vel],
 
 3353                               working_space[peak_vel + 1],
 
 3354                               working_space[peak_vel + 2],
 
 3355                               working_space[peak_vel + 6],
 
 3356                               working_space[peak_vel + 7],
 
 3357                               working_space[peak_vel + 9],
 
 3358                               working_space[peak_vel + 11],
 
 3359                               working_space[peak_vel + 12],
 
 3360                               working_space[peak_vel + 13]);
 
 3363                   working_space[2 * shift + k] += chi_opt * c; 
 
 3365                   working_space[4 * shift + k] += b * c; 
 
 3369             if (fFixRo == 
false) {
 
 3370                a = Derro(fNPeaks, i1, i2,
 
 3371                           working_space, working_space[peak_vel],
 
 3372                           working_space[peak_vel + 1],
 
 3373                           working_space[peak_vel + 2]);
 
 3376                   working_space[2 * shift + k] += chi_opt * c; 
 
 3378                   working_space[4 * shift + k] += b * c; 
 
 3382             if (fFixA0 == 
false) {
 
 3386                   working_space[2 * shift + k] += chi_opt * c; 
 
 3388                   working_space[4 * shift + k] += b * c; 
 
 3392             if (fFixAx == 
false) {
 
 3396                   working_space[2 * shift + k] += chi_opt * c; 
 
 3398                   working_space[4 * shift + k] += b * c; 
 
 3402             if (fFixAy == 
false) {
 
 3406                   working_space[2 * shift + k] += chi_opt * c; 
 
 3408                   working_space[4 * shift + k] += b * c; 
 
 3412             if (fFixTxy == 
false) {
 
 3413                a = Dertxy(fNPeaks, i1, i2,
 
 3414                            working_space, working_space[peak_vel],
 
 3415                            working_space[peak_vel + 1],
 
 3416                            working_space[peak_vel + 12],
 
 3417                            working_space[peak_vel + 13]);
 
 3420                   working_space[2 * shift + k] += chi_opt * c; 
 
 3422                   working_space[4 * shift + k] += b * c; 
 
 3426             if (fFixSxy == 
false) {
 
 3427                a = Dersxy(fNPeaks, i1, i2,
 
 3428                            working_space, working_space[peak_vel],
 
 3429                            working_space[peak_vel + 1]);
 
 3432                   working_space[2 * shift + k] += chi_opt * c; 
 
 3434                   working_space[4 * shift + k] += b * c; 
 
 3438             if (fFixTx == 
false) {
 
 3439                a = Dertx(fNPeaks, i1, working_space,
 
 3440                           working_space[peak_vel],
 
 3441                           working_space[peak_vel + 12]);
 
 3444                   working_space[2 * shift + k] += chi_opt * c; 
 
 3446                   working_space[4 * shift + k] += b * c; 
 
 3450             if (fFixTy == 
false) {
 
 3451                a = Derty(fNPeaks, i2, working_space,
 
 3452                           working_space[peak_vel + 1],
 
 3453                           working_space[peak_vel + 13]);
 
 3456                   working_space[2 * shift + k] += chi_opt * c; 
 
 3458                   working_space[4 * shift + k] += b * c; 
 
 3462             if (fFixSx == 
false) {
 
 3463                a = Dersx(fNPeaks, i1, working_space,
 
 3464                           working_space[peak_vel]);
 
 3467                   working_space[2 * shift + k] += chi_opt * c; 
 
 3469                   working_space[4 * shift + k] += b * c; 
 
 3473             if (fFixSy == 
false) {
 
 3474                a = Dersy(fNPeaks, i2, working_space,
 
 3475                           working_space[peak_vel + 1]);
 
 3478                   working_space[2 * shift + k] += chi_opt * c; 
 
 3480                   working_space[4 * shift + k] += b * c; 
 
 3484             if (fFixBx == 
false) {
 
 3485                a = Derbx(fNPeaks, i1, i2,
 
 3486                           working_space, working_space[peak_vel],
 
 3487                           working_space[peak_vel + 1],
 
 3488                           working_space[peak_vel + 6],
 
 3489                           working_space[peak_vel + 8],
 
 3490                           working_space[peak_vel + 12],
 
 3491                           working_space[peak_vel + 13]);
 
 3494                   working_space[2 * shift + k] += chi_opt * c; 
 
 3496                   working_space[4 * shift + k] += b * c; 
 
 3500             if (fFixBy == 
false) {
 
 3501                a = Derby(fNPeaks, i1, i2,
 
 3502                           working_space, working_space[peak_vel],
 
 3503                           working_space[peak_vel + 1],
 
 3504                           working_space[peak_vel + 6],
 
 3505                           working_space[peak_vel + 8],
 
 3506                           working_space[peak_vel + 12],
 
 3507                           working_space[peak_vel + 13]);
 
 3510                   working_space[2 * shift + k] += chi_opt * c; 
 
 3512                   working_space[4 * shift + k] += b * c; 
 
 3519    b = (fXmax - fXmin + 1) * (fYmax - fYmin + 1) - size;
 
 3520    chi_er = chi_cel / b;
 
 3521    for (i = 0, j = 0; i < fNPeaks; i++) {
 
 3523           Volume(working_space[7 * i], working_space[peak_vel],
 
 3524                  working_space[peak_vel + 1], working_space[peak_vel + 2]);
 
 3525       if (fVolume[i] > 0) {
 
 3527          if (fFixAmp[i] == 
false) {
 
 3528             a = Derpa2(working_space[peak_vel],
 
 3529                         working_space[peak_vel + 1],
 
 3530                         working_space[peak_vel + 2]);
 
 3531             b = working_space[4 * shift + j]; 
 
 3539          if (fFixSigmaX == 
false) {
 
 3540             a = Derpsigmax(working_space[shift + j],
 
 3541                             working_space[peak_vel + 1],
 
 3542                             working_space[peak_vel + 2]);
 
 3543             b = working_space[4 * shift + peak_vel]; 
 
 3551          if (fFixSigmaY == 
false) {
 
 3552             a = Derpsigmay(working_space[shift + j],
 
 3553                             working_space[peak_vel],
 
 3554                             working_space[peak_vel + 2]);
 
 3555             b = working_space[4 * shift + peak_vel + 1]; 
 
 3563          if (fFixRo == 
false) {
 
 3564             a = Derpro(working_space[shift + j], working_space[peak_vel],
 
 3565                         working_space[peak_vel + 1],
 
 3566                         working_space[peak_vel + 2]);
 
 3567             b = working_space[4 * shift + peak_vel + 2]; 
 
 3575          fVolumeErr[i] = TMath::Sqrt(TMath::Abs(chi_er * c));
 
 3581       if (fFixAmp[i] == 
false) {
 
 3582          fAmpCalc[i] = working_space[shift + j]; 
 
 3583          if (working_space[3 * shift + j] != 0)
 
 3584             fAmpErr[i] = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 3589          fAmpCalc[i] = fAmpInit[i];
 
 3592       if (fFixPositionX[i] == 
false) {
 
 3593          fPositionCalcX[i] = working_space[shift + j]; 
 
 3594          if (working_space[3 * shift + j] != 0)
 
 3595             fPositionErrX[i] = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 3600          fPositionCalcX[i] = fPositionInitX[i];
 
 3601          fPositionErrX[i] = 0;
 
 3603       if (fFixPositionY[i] == 
false) {
 
 3604          fPositionCalcY[i] = working_space[shift + j]; 
 
 3605          if (working_space[3 * shift + j] != 0)
 
 3606             fPositionErrY[i] = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 3611          fPositionCalcY[i] = fPositionInitY[i];
 
 3612          fPositionErrY[i] = 0;
 
 3614       if (fFixAmpX1[i] == 
false) {
 
 3615          fAmpCalcX1[i] = working_space[shift + j]; 
 
 3616          if (working_space[3 * shift + j] != 0)
 
 3617             fAmpErrX1[i] = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 3622          fAmpCalcX1[i] = fAmpInitX1[i];
 
 3625       if (fFixAmpY1[i] == 
false) {
 
 3626          fAmpCalcY1[i] = working_space[shift + j]; 
 
 3627          if (working_space[3 * shift + j] != 0)
 
 3628             fAmpErrY1[i] = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 3633          fAmpCalcY1[i] = fAmpInitY1[i];
 
 3636       if (fFixPositionX1[i] == 
false) {
 
 3637          fPositionCalcX1[i] = working_space[shift + j]; 
 
 3638          if (working_space[3 * shift + j] != 0)
 
 3639             fPositionErrX1[i] = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 3644          fPositionCalcX1[i] = fPositionInitX1[i];
 
 3645          fPositionErrX1[i] = 0;
 
 3647       if (fFixPositionY1[i] == 
false) {
 
 3648          fPositionCalcY1[i] = working_space[shift + j]; 
 
 3649          if (working_space[3 * shift + j] != 0)
 
 3650             fPositionErrY1[i] = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 3655          fPositionCalcY1[i] = fPositionInitY1[i];
 
 3656          fPositionErrY1[i] = 0;
 
 3659    if (fFixSigmaX == 
false) {
 
 3660       fSigmaCalcX = working_space[shift + j]; 
 
 3661       if (working_space[3 * shift + j] != 0) 
 
 3662          fSigmaErrX = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 3667       fSigmaCalcX = fSigmaInitX;
 
 3670    if (fFixSigmaY == 
false) {
 
 3671       fSigmaCalcY = working_space[shift + j]; 
 
 3672       if (working_space[3 * shift + j] != 0) 
 
 3673          fSigmaErrY = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 3678       fSigmaCalcY = fSigmaInitY;
 
 3681    if (fFixRo == 
false) {
 
 3682       fRoCalc = working_space[shift + j]; 
 
 3683       if (working_space[3 * shift + j] != 0) 
 
 3684          fRoErr = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 3692    if (fFixA0 == 
false) {
 
 3693       fA0Calc = working_space[shift + j]; 
 
 3694       if (working_space[3 * shift + j] != 0) 
 
 3695          fA0Err = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 3703    if (fFixAx == 
false) {
 
 3704       fAxCalc = working_space[shift + j]; 
 
 3705       if (working_space[3 * shift + j] != 0) 
 
 3706          fAxErr = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 3714    if (fFixAy == 
false) {
 
 3715       fAyCalc = working_space[shift + j]; 
 
 3716       if (working_space[3 * shift + j] != 0) 
 
 3717          fAyErr = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 3725    if (fFixTxy == 
false) {
 
 3726       fTxyCalc = working_space[shift + j]; 
 
 3727       if (working_space[3 * shift + j] != 0) 
 
 3728          fTxyErr = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 3733       fTxyCalc = fTxyInit;
 
 3736    if (fFixSxy == 
false) {
 
 3737       fSxyCalc = working_space[shift + j]; 
 
 3738       if (working_space[3 * shift + j] != 0) 
 
 3739          fSxyErr = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 3744       fSxyCalc = fSxyInit;
 
 3747    if (fFixTx == 
false) {
 
 3748       fTxCalc = working_space[shift + j]; 
 
 3749       if (working_space[3 * shift + j] != 0) 
 
 3750          fTxErr = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 3758    if (fFixTy == 
false) {
 
 3759       fTyCalc = working_space[shift + j]; 
 
 3760       if (working_space[3 * shift + j] != 0) 
 
 3761          fTyErr = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 3769    if (fFixSx == 
false) {
 
 3770       fSxCalc = working_space[shift + j]; 
 
 3771       if (working_space[3 * shift + j] != 0) 
 
 3772          fSxErr = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 3780    if (fFixSy == 
false) {
 
 3781       fSyCalc = working_space[shift + j]; 
 
 3782       if (working_space[3 * shift + j] != 0) 
 
 3783          fSyErr = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 3791    if (fFixBx == 
false) {
 
 3792       fBxCalc = working_space[shift + j]; 
 
 3793       if (working_space[3 * shift + j] != 0) 
 
 3794          fBxErr = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 3802    if (fFixBy == 
false) {
 
 3803       fByCalc = working_space[shift + j]; 
 
 3804       if (working_space[3 * shift + j] != 0) 
 
 3805          fByErr = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 3813    b = (fXmax - fXmin + 1) * (fYmax - fYmin + 1) - size;
 
 3815    for (i1 = fXmin; i1 <= fXmax; i1++) {
 
 3816       for (i2 = fYmin; i2 <= fYmax; i2++) {
 
 3817          f = Shape2(fNPeaks, i1, i2,
 
 3818                      working_space, working_space[peak_vel],
 
 3819                      working_space[peak_vel + 1],
 
 3820                      working_space[peak_vel + 2],
 
 3821                      working_space[peak_vel + 3],
 
 3822                      working_space[peak_vel + 4],
 
 3823                      working_space[peak_vel + 5],
 
 3824                      working_space[peak_vel + 6],
 
 3825                      working_space[peak_vel + 7],
 
 3826                      working_space[peak_vel + 8],
 
 3827                      working_space[peak_vel + 9],
 
 3828                      working_space[peak_vel + 10],
 
 3829                      working_space[peak_vel + 11],
 
 3830                      working_space[peak_vel + 12],
 
 3831                      working_space[peak_vel + 13]);
 
 3835    delete [] working_space;
 
 3942 void TSpectrum2Fit::FitStiefel(Double_t **source)
 
 3945    Int_t i, i1, i2, j, k, shift =
 
 3946        7 * fNPeaks + 14, peak_vel, size, iter, regul_cycle,
 
 3948    Double_t a, b, c, alpha, chi_opt, yw, ywm, f, chi2, chi_min, chi = 0
 
 3949        , pi, pmin = 0, chi_cel = 0, chi_er;
 
 3950    Double_t *working_space = 
new Double_t[5 * (7 * fNPeaks + 14)];
 
 3951    for (i = 0, j = 0; i < fNPeaks; i++) {
 
 3952       working_space[7 * i] = fAmpInit[i]; 
 
 3953       if (fFixAmp[i] == 
false) {
 
 3954          working_space[shift + j] = fAmpInit[i]; 
 
 3957       working_space[7 * i + 1] = fPositionInitX[i]; 
 
 3958       if (fFixPositionX[i] == 
false) {
 
 3959          working_space[shift + j] = fPositionInitX[i]; 
 
 3962       working_space[7 * i + 2] = fPositionInitY[i]; 
 
 3963       if (fFixPositionY[i] == 
false) {
 
 3964          working_space[shift + j] = fPositionInitY[i]; 
 
 3967       working_space[7 * i + 3] = fAmpInitX1[i]; 
 
 3968       if (fFixAmpX1[i] == 
false) {
 
 3969          working_space[shift + j] = fAmpInitX1[i]; 
 
 3972       working_space[7 * i + 4] = fAmpInitY1[i]; 
 
 3973       if (fFixAmpY1[i] == 
false) {
 
 3974          working_space[shift + j] = fAmpInitY1[i]; 
 
 3977       working_space[7 * i + 5] = fPositionInitX1[i]; 
 
 3978       if (fFixPositionX1[i] == 
false) {
 
 3979          working_space[shift + j] = fPositionInitX1[i]; 
 
 3982       working_space[7 * i + 6] = fPositionInitY1[i]; 
 
 3983       if (fFixPositionY1[i] == 
false) {
 
 3984          working_space[shift + j] = fPositionInitY1[i]; 
 
 3989    working_space[7 * i] = fSigmaInitX; 
 
 3990    if (fFixSigmaX == 
false) {
 
 3991       working_space[shift + j] = fSigmaInitX; 
 
 3994    working_space[7 * i + 1] = fSigmaInitY; 
 
 3995    if (fFixSigmaY == 
false) {
 
 3996       working_space[shift + j] = fSigmaInitY; 
 
 3999    working_space[7 * i + 2] = fRoInit; 
 
 4000    if (fFixRo == 
false) {
 
 4001       working_space[shift + j] = fRoInit; 
 
 4004    working_space[7 * i + 3] = fA0Init; 
 
 4005    if (fFixA0 == 
false) {
 
 4006       working_space[shift + j] = fA0Init; 
 
 4009    working_space[7 * i + 4] = fAxInit; 
 
 4010    if (fFixAx == 
false) {
 
 4011       working_space[shift + j] = fAxInit; 
 
 4014    working_space[7 * i + 5] = fAyInit; 
 
 4015    if (fFixAy == 
false) {
 
 4016       working_space[shift + j] = fAyInit; 
 
 4019    working_space[7 * i + 6] = fTxyInit; 
 
 4020    if (fFixTxy == 
false) {
 
 4021       working_space[shift + j] = fTxyInit; 
 
 4024    working_space[7 * i + 7] = fSxyInit; 
 
 4025    if (fFixSxy == 
false) {
 
 4026       working_space[shift + j] = fSxyInit; 
 
 4029    working_space[7 * i + 8] = fTxInit; 
 
 4030    if (fFixTx == 
false) {
 
 4031       working_space[shift + j] = fTxInit; 
 
 4034    working_space[7 * i + 9] = fTyInit; 
 
 4035    if (fFixTy == 
false) {
 
 4036       working_space[shift + j] = fTyInit; 
 
 4039    working_space[7 * i + 10] = fSxyInit; 
 
 4040    if (fFixSx == 
false) {
 
 4041       working_space[shift + j] = fSxInit; 
 
 4044    working_space[7 * i + 11] = fSyInit; 
 
 4045    if (fFixSy == 
false) {
 
 4046       working_space[shift + j] = fSyInit; 
 
 4049    working_space[7 * i + 12] = fBxInit; 
 
 4050    if (fFixBx == 
false) {
 
 4051       working_space[shift + j] = fBxInit; 
 
 4054    working_space[7 * i + 13] = fByInit; 
 
 4055    if (fFixBy == 
false) {
 
 4056       working_space[shift + j] = fByInit; 
 
 4060    Double_t **working_matrix = 
new Double_t *[size];
 
 4061    for (i = 0; i < size; i++)
 
 4062       working_matrix[i] = 
new Double_t[size + 4];
 
 4063    for (iter = 0; iter < fNumberIterations; iter++) {
 
 4064       for (j = 0; j < size; j++) {
 
 4065          working_space[3 * shift + j] = 0; 
 
 4066          for (k = 0; k < (size + 4); k++) {
 
 4067             working_matrix[j][k] = 0;
 
 4074       for (i1 = fXmin; i1 <= fXmax; i1++) {
 
 4075          for (i2 = fYmin; i2 <= fYmax; i2++) {
 
 4077             for (j = 0, k = 0; j < fNPeaks; j++) {
 
 4078                if (fFixAmp[j] == 
false) {
 
 4079                   working_space[2 * shift + k] =
 
 4081                               working_space[7 * j + 1],
 
 4082                               working_space[7 * j + 2],
 
 4083                               working_space[peak_vel],
 
 4084                               working_space[peak_vel + 1],
 
 4085                               working_space[peak_vel + 2],
 
 4086                               working_space[peak_vel + 6],
 
 4087                               working_space[peak_vel + 7],
 
 4088                               working_space[peak_vel + 12],
 
 4089                               working_space[peak_vel + 13]);
 
 4092                if (fFixPositionX[j] == 
false) {
 
 4093                   working_space[2 * shift + k] =
 
 4095                              working_space[7 * j],
 
 4096                              working_space[7 * j + 1],
 
 4097                              working_space[7 * j + 2],
 
 4098                              working_space[peak_vel],
 
 4099                              working_space[peak_vel + 1],
 
 4100                              working_space[peak_vel + 2],
 
 4101                              working_space[peak_vel + 6],
 
 4102                              working_space[peak_vel + 7],
 
 4103                              working_space[peak_vel + 12],
 
 4104                              working_space[peak_vel + 13]);
 
 4107                if (fFixPositionY[j] == 
false) {
 
 4108                   working_space[2 * shift + k] =
 
 4110                              working_space[7 * j],
 
 4111                              working_space[7 * j + 1],
 
 4112                              working_space[7 * j + 2],
 
 4113                              working_space[peak_vel],
 
 4114                              working_space[peak_vel + 1],
 
 4115                              working_space[peak_vel + 2],
 
 4116                              working_space[peak_vel + 6],
 
 4117                              working_space[peak_vel + 7],
 
 4118                              working_space[peak_vel + 12],
 
 4119                              working_space[peak_vel + 13]);
 
 4122                if (fFixAmpX1[j] == 
false) {
 
 4123                   working_space[2 * shift + k] =
 
 4124                       Derampx(i1, working_space[7 * j + 5],
 
 4125                               working_space[peak_vel],
 
 4126                               working_space[peak_vel + 8],
 
 4127                               working_space[peak_vel + 10],
 
 4128                               working_space[peak_vel + 12]);
 
 4131                if (fFixAmpY1[j] == 
false) {
 
 4132                   working_space[2 * shift + k] =
 
 4133                       Derampx(i2, working_space[7 * j + 6],
 
 4134                               working_space[peak_vel + 1],
 
 4135                               working_space[peak_vel + 9],
 
 4136                               working_space[peak_vel + 11],
 
 4137                               working_space[peak_vel + 13]);
 
 4140                if (fFixPositionX1[j] == 
false) {
 
 4141                   working_space[2 * shift + k] =
 
 4142                       Deri01(i1, working_space[7 * j + 3],
 
 4143                              working_space[7 * j + 5],
 
 4144                              working_space[peak_vel],
 
 4145                              working_space[peak_vel + 8],
 
 4146                              working_space[peak_vel + 10],
 
 4147                              working_space[peak_vel + 12]);
 
 4150                if (fFixPositionY1[j] == 
false) {
 
 4151                   working_space[2 * shift + k] =
 
 4152                       Deri01(i2, working_space[7 * j + 4],
 
 4153                              working_space[7 * j + 6],
 
 4154                              working_space[peak_vel + 1],
 
 4155                              working_space[peak_vel + 9],
 
 4156                              working_space[peak_vel + 11],
 
 4157                              working_space[peak_vel + 13]);
 
 4160             } 
if (fFixSigmaX == 
false) {
 
 4161                working_space[2 * shift + k] =
 
 4162                    Dersigmax(fNPeaks, i1, i2,
 
 4163                              working_space, working_space[peak_vel],
 
 4164                              working_space[peak_vel + 1],
 
 4165                              working_space[peak_vel + 2],
 
 4166                              working_space[peak_vel + 6],
 
 4167                              working_space[peak_vel + 7],
 
 4168                              working_space[peak_vel + 8],
 
 4169                              working_space[peak_vel + 10],
 
 4170                              working_space[peak_vel + 12],
 
 4171                              working_space[peak_vel + 13]);
 
 4174             if (fFixSigmaY == 
false) {
 
 4175                working_space[2 * shift + k] =
 
 4176                    Dersigmay(fNPeaks, i1, i2,
 
 4177                              working_space, working_space[peak_vel],
 
 4178                              working_space[peak_vel + 1],
 
 4179                              working_space[peak_vel + 2],
 
 4180                              working_space[peak_vel + 6],
 
 4181                              working_space[peak_vel + 7],
 
 4182                              working_space[peak_vel + 9],
 
 4183                              working_space[peak_vel + 11],
 
 4184                              working_space[peak_vel + 12],
 
 4185                              working_space[peak_vel + 13]);
 
 4188             if (fFixRo == 
false) {
 
 4189                working_space[2 * shift + k] =
 
 4190                    Derro(fNPeaks, i1, i2,
 
 4191                          working_space, working_space[peak_vel],
 
 4192                          working_space[peak_vel + 1],
 
 4193                          working_space[peak_vel + 2]);
 
 4196             if (fFixA0 == 
false) {
 
 4197                working_space[2 * shift + k] = 1.;
 
 4200             if (fFixAx == 
false) {
 
 4201                working_space[2 * shift + k] = i1;
 
 4204             if (fFixAy == 
false) {
 
 4205                working_space[2 * shift + k] = i2;
 
 4208             if (fFixTxy == 
false) {
 
 4209                working_space[2 * shift + k] =
 
 4210                    Dertxy(fNPeaks, i1, i2,
 
 4211                           working_space, working_space[peak_vel],
 
 4212                           working_space[peak_vel + 1],
 
 4213                           working_space[peak_vel + 12],
 
 4214                           working_space[peak_vel + 13]);
 
 4217             if (fFixSxy == 
false) {
 
 4218                working_space[2 * shift + k] =
 
 4219                    Dersxy(fNPeaks, i1, i2,
 
 4220                           working_space, working_space[peak_vel],
 
 4221                           working_space[peak_vel + 1]);
 
 4224             if (fFixTx == 
false) {
 
 4225                working_space[2 * shift + k] =
 
 4226                    Dertx(fNPeaks, i1, working_space,
 
 4227                          working_space[peak_vel],
 
 4228                          working_space[peak_vel + 12]);
 
 4231             if (fFixTy == 
false) {
 
 4232                working_space[2 * shift + k] =
 
 4233                    Derty(fNPeaks, i2, working_space,
 
 4234                          working_space[peak_vel + 1],
 
 4235                          working_space[peak_vel + 13]);
 
 4238             if (fFixSx == 
false) {
 
 4239                working_space[2 * shift + k] =
 
 4240                    Dersx(fNPeaks, i1, working_space,
 
 4241                          working_space[peak_vel]);
 
 4244             if (fFixSy == 
false) {
 
 4245                working_space[2 * shift + k] =
 
 4246                    Dersy(fNPeaks, i2, working_space,
 
 4247                          working_space[peak_vel + 1]);
 
 4250             if (fFixBx == 
false) {
 
 4251                working_space[2 * shift + k] =
 
 4252                    Derbx(fNPeaks, i1, i2,
 
 4253                          working_space, working_space[peak_vel],
 
 4254                          working_space[peak_vel + 1],
 
 4255                          working_space[peak_vel + 6],
 
 4256                          working_space[peak_vel + 8],
 
 4257                          working_space[peak_vel + 12],
 
 4258                          working_space[peak_vel + 13]);
 
 4261             if (fFixBy == 
false) {
 
 4262                working_space[2 * shift + k] =
 
 4263                    Derby(fNPeaks, i1, i2,
 
 4264                          working_space, working_space[peak_vel],
 
 4265                          working_space[peak_vel + 1],
 
 4266                          working_space[peak_vel + 6],
 
 4267                          working_space[peak_vel + 8],
 
 4268                          working_space[peak_vel + 12],
 
 4269                          working_space[peak_vel + 13]);
 
 4272             yw = source[i1][i2];
 
 4274             f = Shape2(fNPeaks, i1, i2,
 
 4275                         working_space, working_space[peak_vel],
 
 4276                         working_space[peak_vel + 1],
 
 4277                         working_space[peak_vel + 2],
 
 4278                         working_space[peak_vel + 3],
 
 4279                         working_space[peak_vel + 4],
 
 4280                         working_space[peak_vel + 5],
 
 4281                         working_space[peak_vel + 6],
 
 4282                         working_space[peak_vel + 7],
 
 4283                         working_space[peak_vel + 8],
 
 4284                         working_space[peak_vel + 9],
 
 4285                         working_space[peak_vel + 10],
 
 4286                         working_space[peak_vel + 11],
 
 4287                         working_space[peak_vel + 12],
 
 4288                         working_space[peak_vel + 13]);
 
 4289             if (fStatisticType == kFitOptimMaxLikelihood) {
 
 4291                   chi_opt += yw * TMath::Log(f) - f;
 
 4296                   chi_opt += (yw - f) * (yw - f) / ywm;
 
 4298             if (fStatisticType == kFitOptimChiFuncValues) {
 
 4304             else if (fStatisticType == kFitOptimMaxLikelihood) {
 
 4314             for (j = 0; j < size; j++) {
 
 4315                for (k = 0; k < size; k++) {
 
 4316                   b = working_space[2 * shift +
 
 4317                                      j] * working_space[2 * shift +
 
 4319                   if (fStatisticType == kFitOptimChiFuncValues)
 
 4320                      b = b * (4 * yw - 2 * f) / ywm;
 
 4321                   working_matrix[j][k] += b;
 
 4323                      working_space[3 * shift + j] += b;
 
 4326             if (fStatisticType == kFitOptimChiFuncValues)
 
 4327                b = (f * f - yw * yw) / (ywm * ywm);
 
 4331             for (j = 0; j < size; j++) {
 
 4332                working_matrix[j][size] -=
 
 4333                    b * working_space[2 * shift + j];
 
 4337       for (i = 0; i < size; i++) {
 
 4338          working_matrix[i][size + 1] = 0; 
 
 4340       StiefelInversion(working_matrix, size);
 
 4341       for (i = 0; i < size; i++) {
 
 4342          working_space[2 * shift + i] = working_matrix[i][size + 1]; 
 
 4347       chi_opt = TMath::Sqrt(TMath::Abs(chi_opt));
 
 4351       for (j = 0; j < size; j++) {
 
 4352          working_space[4 * shift + j] = working_space[shift + j]; 
 
 4356          if (fAlphaOptim == kFitAlphaOptimal) {
 
 4357             if (fStatisticType != kFitOptimMaxLikelihood)
 
 4358                chi_min = 10000 * chi2;
 
 4361                chi_min = 0.1 * chi2;
 
 4363             for (pi = 0.1; flag == 0 && pi <= 100; pi += 0.1) {
 
 4364                for (j = 0; j < size; j++) {
 
 4365                   working_space[shift + j] = working_space[4 * shift + j] + pi * alpha * working_space[2 * shift + j]; 
 
 4367                for (i = 0, j = 0; i < fNPeaks; i++) {
 
 4368                   if (fFixAmp[i] == 
false) {
 
 4369                      if (working_space[shift + j] < 0) 
 
 4370                         working_space[shift + j] = 0; 
 
 4371                      working_space[7 * i] = working_space[shift + j]; 
 
 4374                   if (fFixPositionX[i] == 
false) {
 
 4375                      if (working_space[shift + j] < fXmin) 
 
 4376                         working_space[shift + j] = fXmin; 
 
 4377                      if (working_space[shift + j] > fXmax) 
 
 4378                         working_space[shift + j] = fXmax; 
 
 4379                      working_space[7 * i + 1] = working_space[shift + j]; 
 
 4382                   if (fFixPositionY[i] == 
false) {
 
 4383                      if (working_space[shift + j] < fYmin) 
 
 4384                         working_space[shift + j] = fYmin; 
 
 4385                      if (working_space[shift + j] > fYmax) 
 
 4386                         working_space[shift + j] = fYmax; 
 
 4387                      working_space[7 * i + 2] = working_space[shift + j]; 
 
 4390                   if (fFixAmpX1[i] == 
false) {
 
 4391                      if (working_space[shift + j] < 0) 
 
 4392                         working_space[shift + j] = 0; 
 
 4393                      working_space[7 * i + 3] = working_space[shift + j]; 
 
 4396                   if (fFixAmpY1[i] == 
false) {
 
 4397                      if (working_space[shift + j] < 0) 
 
 4398                         working_space[shift + j] = 0; 
 
 4399                      working_space[7 * i + 4] = working_space[shift + j]; 
 
 4402                   if (fFixPositionX1[i] == 
false) {
 
 4403                      if (working_space[shift + j] < fXmin) 
 
 4404                         working_space[shift + j] = fXmin; 
 
 4405                      if (working_space[shift + j] > fXmax) 
 
 4406                         working_space[shift + j] = fXmax; 
 
 4407                      working_space[7 * i + 5] = working_space[shift + j]; 
 
 4410                   if (fFixPositionY1[i] == 
false) {
 
 4411                      if (working_space[shift + j] < fYmin) 
 
 4412                         working_space[shift + j] = fYmin; 
 
 4413                      if (working_space[shift + j] > fYmax) 
 
 4414                         working_space[shift + j] = fYmax; 
 
 4415                      working_space[7 * i + 6] = working_space[shift + j]; 
 
 4419                if (fFixSigmaX == 
false) {
 
 4420                   if (working_space[shift + j] < 0.001) { 
 
 4421                      working_space[shift + j] = 0.001; 
 
 4423                   working_space[peak_vel] = working_space[shift + j]; 
 
 4426                if (fFixSigmaY == 
false) {
 
 4427                   if (working_space[shift + j] < 0.001) { 
 
 4428                      working_space[shift + j] = 0.001; 
 
 4430                   working_space[peak_vel + 1] = working_space[shift + j]; 
 
 4433                if (fFixRo == 
false) {
 
 4434                   if (working_space[shift + j] < -1) { 
 
 4435                      working_space[shift + j] = -1; 
 
 4437                   if (working_space[shift + j] > 1) { 
 
 4438                      working_space[shift + j] = 1; 
 
 4440                   working_space[peak_vel + 2] = working_space[shift + j]; 
 
 4443                if (fFixA0 == 
false) {
 
 4444                   working_space[peak_vel + 3] = working_space[shift + j]; 
 
 4447                if (fFixAx == 
false) {
 
 4448                   working_space[peak_vel + 4] = working_space[shift + j]; 
 
 4451                if (fFixAy == 
false) {
 
 4452                   working_space[peak_vel + 5] = working_space[shift + j]; 
 
 4455                if (fFixTxy == 
false) {
 
 4456                   working_space[peak_vel + 6] = working_space[shift + j]; 
 
 4459                if (fFixSxy == 
false) {
 
 4460                   working_space[peak_vel + 7] = working_space[shift + j]; 
 
 4463                if (fFixTx == 
false) {
 
 4464                   working_space[peak_vel + 8] = working_space[shift + j]; 
 
 4467                if (fFixTy == 
false) {
 
 4468                   working_space[peak_vel + 9] = working_space[shift + j]; 
 
 4471                if (fFixSx == 
false) {
 
 4472                   working_space[peak_vel + 10] = working_space[shift + j]; 
 
 4475                if (fFixSy == 
false) {
 
 4476                   working_space[peak_vel + 11] = working_space[shift + j]; 
 
 4479                if (fFixBx == 
false) {
 
 4480                   if (TMath::Abs(working_space[shift + j]) < 0.001) { 
 
 4481                      if (working_space[shift + j] < 0) 
 
 4482                         working_space[shift + j] = -0.001; 
 
 4484                         working_space[shift + j] = 0.001; 
 
 4486                   working_space[peak_vel + 12] = working_space[shift + j]; 
 
 4489                if (fFixBy == 
false) {
 
 4490                   if (TMath::Abs(working_space[shift + j]) < 0.001) { 
 
 4491                      if (working_space[shift + j] < 0) 
 
 4492                         working_space[shift + j] = -0.001; 
 
 4494                         working_space[shift + j] = 0.001; 
 
 4496                   working_space[peak_vel + 13] = working_space[shift + j]; 
 
 4500                for (i1 = fXmin; i1 <= fXmax; i1++) {
 
 4501                   for (i2 = fYmin; i2 <= fYmax; i2++) {
 
 4502                      yw = source[i1][i2];
 
 4504                      f = Shape2(fNPeaks, i1,
 
 4506                                  working_space[peak_vel],
 
 4507                                  working_space[peak_vel + 1],
 
 4508                                  working_space[peak_vel + 2],
 
 4509                                  working_space[peak_vel + 3],
 
 4510                                  working_space[peak_vel + 4],
 
 4511                                  working_space[peak_vel + 5],
 
 4512                                  working_space[peak_vel + 6],
 
 4513                                  working_space[peak_vel + 7],
 
 4514                                  working_space[peak_vel + 8],
 
 4515                                  working_space[peak_vel + 9],
 
 4516                                  working_space[peak_vel + 10],
 
 4517                                  working_space[peak_vel + 11],
 
 4518                                  working_space[peak_vel + 12],
 
 4519                                  working_space[peak_vel + 13]);
 
 4520                      if (fStatisticType == kFitOptimChiFuncValues) {
 
 4525                      if (fStatisticType == kFitOptimMaxLikelihood) {
 
 4527                            chi2 += yw * TMath::Log(f) - f;
 
 4532                            chi2 += (yw - f) * (yw - f) / ywm;
 
 4537                     && fStatisticType != kFitOptimMaxLikelihood)
 
 4539                     && fStatisticType == kFitOptimMaxLikelihood)) {
 
 4540                   pmin = pi, chi_min = chi2;
 
 4550                for (j = 0; j < size; j++) {
 
 4551                   working_space[shift + j] = working_space[4 * shift + j] + pmin * alpha * working_space[2 * shift + j]; 
 
 4553                for (i = 0, j = 0; i < fNPeaks; i++) {
 
 4554                   if (fFixAmp[i] == 
false) {
 
 4555                      if (working_space[shift + j] < 0) 
 
 4556                         working_space[shift + j] = 0; 
 
 4557                      working_space[7 * i] = working_space[shift + j]; 
 
 4560                   if (fFixPositionX[i] == 
false) {
 
 4561                      if (working_space[shift + j] < fXmin) 
 
 4562                         working_space[shift + j] = fXmin; 
 
 4563                      if (working_space[shift + j] > fXmax) 
 
 4564                         working_space[shift + j] = fXmax; 
 
 4565                      working_space[7 * i + 1] = working_space[shift + j]; 
 
 4568                   if (fFixPositionY[i] == 
false) {
 
 4569                      if (working_space[shift + j] < fYmin) 
 
 4570                         working_space[shift + j] = fYmin; 
 
 4571                      if (working_space[shift + j] > fYmax) 
 
 4572                         working_space[shift + j] = fYmax; 
 
 4573                      working_space[7 * i + 2] = working_space[shift + j]; 
 
 4576                   if (fFixAmpX1[i] == 
false) {
 
 4577                      if (working_space[shift + j] < 0) 
 
 4578                         working_space[shift + j] = 0; 
 
 4579                      working_space[7 * i + 3] = working_space[shift + j]; 
 
 4582                   if (fFixAmpY1[i] == 
false) {
 
 4583                      if (working_space[shift + j] < 0) 
 
 4584                         working_space[shift + j] = 0; 
 
 4585                      working_space[7 * i + 4] = working_space[shift + j]; 
 
 4588                   if (fFixPositionX1[i] == 
false) {
 
 4589                      if (working_space[shift + j] < fXmin) 
 
 4590                         working_space[shift + j] = fXmin; 
 
 4591                      if (working_space[shift + j] > fXmax) 
 
 4592                         working_space[shift + j] = fXmax; 
 
 4593                      working_space[7 * i + 5] = working_space[shift + j]; 
 
 4596                   if (fFixPositionY1[i] == 
false) {
 
 4597                      if (working_space[shift + j] < fYmin) 
 
 4598                         working_space[shift + j] = fYmin; 
 
 4599                      if (working_space[shift + j] > fYmax) 
 
 4600                         working_space[shift + j] = fYmax; 
 
 4601                      working_space[7 * i + 6] = working_space[shift + j]; 
 
 4605                if (fFixSigmaX == 
false) {
 
 4606                   if (working_space[shift + j] < 0.001) { 
 
 4607                      working_space[shift + j] = 0.001; 
 
 4609                   working_space[peak_vel] = working_space[shift + j]; 
 
 4612                if (fFixSigmaY == 
false) {
 
 4613                   if (working_space[shift + j] < 0.001) { 
 
 4614                      working_space[shift + j] = 0.001; 
 
 4616                   working_space[peak_vel + 1] = working_space[shift + j]; 
 
 4619                if (fFixRo == 
false) {
 
 4620                   if (working_space[shift + j] < -1) { 
 
 4621                      working_space[shift + j] = -1; 
 
 4623                   if (working_space[shift + j] > 1) { 
 
 4624                      working_space[shift + j] = 1; 
 
 4626                   working_space[peak_vel + 2] = working_space[shift + j]; 
 
 4629                if (fFixA0 == 
false) {
 
 4630                   working_space[peak_vel + 3] = working_space[shift + j]; 
 
 4633                if (fFixAx == 
false) {
 
 4634                   working_space[peak_vel + 4] = working_space[shift + j]; 
 
 4637                if (fFixAy == 
false) {
 
 4638                   working_space[peak_vel + 5] = working_space[shift + j]; 
 
 4641                if (fFixTxy == 
false) {
 
 4642                   working_space[peak_vel + 6] = working_space[shift + j]; 
 
 4645                if (fFixSxy == 
false) {
 
 4646                   working_space[peak_vel + 7] = working_space[shift + j]; 
 
 4649                if (fFixTx == 
false) {
 
 4650                   working_space[peak_vel + 8] = working_space[shift + j]; 
 
 4653                if (fFixTy == 
false) {
 
 4654                   working_space[peak_vel + 9] = working_space[shift + j]; 
 
 4657                if (fFixSx == 
false) {
 
 4658                   working_space[peak_vel + 10] = working_space[shift + j]; 
 
 4661                if (fFixSy == 
false) {
 
 4662                   working_space[peak_vel + 11] = working_space[shift + j]; 
 
 4665                if (fFixBx == 
false) {
 
 4666                   if (TMath::Abs(working_space[shift + j]) < 0.001) { 
 
 4667                      if (working_space[shift + j] < 0) 
 
 4668                         working_space[shift + j] = -0.001; 
 
 4670                         working_space[shift + j] = 0.001; 
 
 4672                   working_space[peak_vel + 12] = working_space[shift + j]; 
 
 4675                if (fFixBy == 
false) {
 
 4676                   if (TMath::Abs(working_space[shift + j]) < 0.001) { 
 
 4677                      if (working_space[shift + j] < 0) 
 
 4678                         working_space[shift + j] = -0.001; 
 
 4680                         working_space[shift + j] = 0.001; 
 
 4682                   working_space[peak_vel + 13] = working_space[shift + j]; 
 
 4690             for (j = 0; j < size; j++) {
 
 4691                working_space[shift + j] = working_space[4 * shift + j] + alpha * working_space[2 * shift + j]; 
 
 4693             for (i = 0, j = 0; i < fNPeaks; i++) {
 
 4694                if (fFixAmp[i] == 
false) {
 
 4695                   if (working_space[shift + j] < 0) 
 
 4696                      working_space[shift + j] = 0; 
 
 4697                   working_space[7 * i] = working_space[shift + j]; 
 
 4700                if (fFixPositionX[i] == 
false) {
 
 4701                   if (working_space[shift + j] < fXmin) 
 
 4702                      working_space[shift + j] = fXmin; 
 
 4703                   if (working_space[shift + j] > fXmax) 
 
 4704                      working_space[shift + j] = fXmax; 
 
 4705                   working_space[7 * i + 1] = working_space[shift + j]; 
 
 4708                if (fFixPositionY[i] == 
false) {
 
 4709                   if (working_space[shift + j] < fYmin) 
 
 4710                      working_space[shift + j] = fYmin; 
 
 4711                   if (working_space[shift + j] > fYmax) 
 
 4712                      working_space[shift + j] = fYmax; 
 
 4713                   working_space[7 * i + 2] = working_space[shift + j]; 
 
 4716                if (fFixAmpX1[i] == 
false) {
 
 4717                   if (working_space[shift + j] < 0) 
 
 4718                      working_space[shift + j] = 0; 
 
 4719                   working_space[7 * i + 3] = working_space[shift + j]; 
 
 4722                if (fFixAmpY1[i] == 
false) {
 
 4723                   if (working_space[shift + j] < 0) 
 
 4724                      working_space[shift + j] = 0; 
 
 4725                   working_space[7 * i + 4] = working_space[shift + j]; 
 
 4728                if (fFixPositionX1[i] == 
false) {
 
 4729                   if (working_space[shift + j] < fXmin) 
 
 4730                      working_space[shift + j] = fXmin; 
 
 4731                   if (working_space[shift + j] > fXmax) 
 
 4732                      working_space[shift + j] = fXmax; 
 
 4733                   working_space[7 * i + 5] = working_space[shift + j]; 
 
 4736                if (fFixPositionY1[i] == 
false) {
 
 4737                   if (working_space[shift + j] < fYmin) 
 
 4738                      working_space[shift + j] = fYmin; 
 
 4739                   if (working_space[shift + j] > fYmax) 
 
 4740                      working_space[shift + j] = fYmax; 
 
 4741                   working_space[7 * i + 6] = working_space[shift + j]; 
 
 4745             if (fFixSigmaX == 
false) {
 
 4746                if (working_space[shift + j] < 0.001) { 
 
 4747                   working_space[shift + j] = 0.001; 
 
 4749                working_space[peak_vel] = working_space[shift + j]; 
 
 4752             if (fFixSigmaY == 
false) {
 
 4753                if (working_space[shift + j] < 0.001) { 
 
 4754                   working_space[shift + j] = 0.001; 
 
 4756                working_space[peak_vel + 1] = working_space[shift + j]; 
 
 4759             if (fFixRo == 
false) {
 
 4760                if (working_space[shift + j] < -1) { 
 
 4761                   working_space[shift + j] = -1; 
 
 4763                if (working_space[shift + j] > 1) { 
 
 4764                   working_space[shift + j] = 1; 
 
 4766                working_space[peak_vel + 2] = working_space[shift + j]; 
 
 4769             if (fFixA0 == 
false) {
 
 4770                working_space[peak_vel + 3] = working_space[shift + j]; 
 
 4773             if (fFixAx == 
false) {
 
 4774                working_space[peak_vel + 4] = working_space[shift + j]; 
 
 4777             if (fFixAy == 
false) {
 
 4778                working_space[peak_vel + 5] = working_space[shift + j]; 
 
 4781             if (fFixTxy == 
false) {
 
 4782                working_space[peak_vel + 6] = working_space[shift + j]; 
 
 4785             if (fFixSxy == 
false) {
 
 4786                working_space[peak_vel + 7] = working_space[shift + j]; 
 
 4789             if (fFixTx == 
false) {
 
 4790                working_space[peak_vel + 8] = working_space[shift + j]; 
 
 4793             if (fFixTy == 
false) {
 
 4794                working_space[peak_vel + 9] = working_space[shift + j]; 
 
 4797             if (fFixSx == 
false) {
 
 4798                working_space[peak_vel + 10] = working_space[shift + j]; 
 
 4801             if (fFixSy == 
false) {
 
 4802                working_space[peak_vel + 11] = working_space[shift + j]; 
 
 4805             if (fFixBx == 
false) {
 
 4806                if (TMath::Abs(working_space[shift + j]) < 0.001) { 
 
 4807                   if (working_space[shift + j] < 0) 
 
 4808                      working_space[shift + j] = -0.001; 
 
 4810                      working_space[shift + j] = 0.001; 
 
 4812                working_space[peak_vel + 12] = working_space[shift + j]; 
 
 4815             if (fFixBy == 
false) {
 
 4816                if (TMath::Abs(working_space[shift + j]) < 0.001) { 
 
 4817                   if (working_space[shift + j] < 0) 
 
 4818                      working_space[shift + j] = -0.001; 
 
 4820                      working_space[shift + j] = 0.001; 
 
 4822                working_space[peak_vel + 13] = working_space[shift + j]; 
 
 4826             for (i1 = fXmin; i1 <= fXmax; i1++) {
 
 4827                for (i2 = fYmin; i2 <= fYmax; i2++) {
 
 4828                   yw = source[i1][i2];
 
 4830                   f = Shape2(fNPeaks, i1, i2,
 
 4831                               working_space, working_space[peak_vel],
 
 4832                               working_space[peak_vel + 1],
 
 4833                               working_space[peak_vel + 2],
 
 4834                               working_space[peak_vel + 3],
 
 4835                               working_space[peak_vel + 4],
 
 4836                               working_space[peak_vel + 5],
 
 4837                               working_space[peak_vel + 6],
 
 4838                               working_space[peak_vel + 7],
 
 4839                               working_space[peak_vel + 8],
 
 4840                               working_space[peak_vel + 9],
 
 4841                               working_space[peak_vel + 10],
 
 4842                               working_space[peak_vel + 11],
 
 4843                               working_space[peak_vel + 12],
 
 4844                               working_space[peak_vel + 13]);
 
 4845                   if (fStatisticType == kFitOptimChiFuncValues) {
 
 4850                   if (fStatisticType == kFitOptimMaxLikelihood) {
 
 4852                         chi += yw * TMath::Log(f) - f;
 
 4857                         chi += (yw - f) * (yw - f) / ywm;
 
 4863          chi = TMath::Sqrt(TMath::Abs(chi));
 
 4864          if (fAlphaOptim == kFitAlphaHalving && chi > 1E-6)
 
 4865             alpha = alpha * chi_opt / (2 * chi);
 
 4867          else if (fAlphaOptim == kFitAlphaOptimal)
 
 4868             alpha = alpha / 10.0;
 
 4871       } 
while (((chi > chi_opt
 
 4872                  && fStatisticType != kFitOptimMaxLikelihood)
 
 4874                  && fStatisticType == kFitOptimMaxLikelihood))
 
 4875                 && regul_cycle < kFitNumRegulCycles);
 
 4876       for (j = 0; j < size; j++) {
 
 4877          working_space[4 * shift + j] = 0; 
 
 4878          working_space[2 * shift + j] = 0; 
 
 4880       for (i1 = fXmin, chi_cel = 0; i1 <= fXmax; i1++) {
 
 4881          for (i2 = fYmin; i2 <= fYmax; i2++) {
 
 4882             yw = source[i1][i2];
 
 4885             f = Shape2(fNPeaks, i1, i2,
 
 4886                         working_space, working_space[peak_vel],
 
 4887                         working_space[peak_vel + 1],
 
 4888                         working_space[peak_vel + 2],
 
 4889                         working_space[peak_vel + 3],
 
 4890                         working_space[peak_vel + 4],
 
 4891                         working_space[peak_vel + 5],
 
 4892                         working_space[peak_vel + 6],
 
 4893                         working_space[peak_vel + 7],
 
 4894                         working_space[peak_vel + 8],
 
 4895                         working_space[peak_vel + 9],
 
 4896                         working_space[peak_vel + 10],
 
 4897                         working_space[peak_vel + 11],
 
 4898                         working_space[peak_vel + 12],
 
 4899                         working_space[peak_vel + 13]);
 
 4900             chi_opt = (yw - f) * (yw - f) / yw;
 
 4901             chi_cel += (yw - f) * (yw - f) / yw;
 
 4904                 for (j = 0, k = 0; j < fNPeaks; j++) {
 
 4905                if (fFixAmp[j] == 
false) {
 
 4907                                working_space[7 * j + 1],
 
 4908                                working_space[7 * j + 2],
 
 4909                                working_space[peak_vel],
 
 4910                                working_space[peak_vel + 1],
 
 4911                                working_space[peak_vel + 2],
 
 4912                                working_space[peak_vel + 6],
 
 4913                                working_space[peak_vel + 7],
 
 4914                                working_space[peak_vel + 12],
 
 4915                                working_space[peak_vel + 13]);
 
 4917                      working_space[2 * shift + k] += chi_opt; 
 
 4919                      working_space[4 * shift + k] += b; 
 
 4923                if (fFixPositionX[j] == 
false) {
 
 4925                               working_space[7 * j],
 
 4926                               working_space[7 * j + 1],
 
 4927                               working_space[7 * j + 2],
 
 4928                               working_space[peak_vel],
 
 4929                               working_space[peak_vel + 1],
 
 4930                               working_space[peak_vel + 2],
 
 4931                               working_space[peak_vel + 6],
 
 4932                               working_space[peak_vel + 7],
 
 4933                               working_space[peak_vel + 12],
 
 4934                               working_space[peak_vel + 13]);
 
 4936                      working_space[2 * shift + k] += chi_opt; 
 
 4938                      working_space[4 * shift + k] += b; 
 
 4942                if (fFixPositionY[j] == 
false) {
 
 4944                               working_space[7 * j],
 
 4945                               working_space[7 * j + 1],
 
 4946                               working_space[7 * j + 2],
 
 4947                               working_space[peak_vel],
 
 4948                               working_space[peak_vel + 1],
 
 4949                               working_space[peak_vel + 2],
 
 4950                               working_space[peak_vel + 6],
 
 4951                               working_space[peak_vel + 7],
 
 4952                               working_space[peak_vel + 12],
 
 4953                               working_space[peak_vel + 13]);
 
 4955                      working_space[2 * shift + k] += chi_opt; 
 
 4957                      working_space[4 * shift + k] += b; 
 
 4961                if (fFixAmpX1[j] == 
false) {
 
 4962                   a = Derampx(i1, working_space[7 * j + 5],
 
 4963                                working_space[peak_vel],
 
 4964                                working_space[peak_vel + 8],
 
 4965                                working_space[peak_vel + 10],
 
 4966                                working_space[peak_vel + 12]);
 
 4968                      working_space[2 * shift + k] += chi_opt; 
 
 4970                      working_space[4 * shift + k] += b; 
 
 4974                if (fFixAmpY1[j] == 
false) {
 
 4975                   a = Derampx(i2, working_space[7 * j + 6],
 
 4976                                working_space[peak_vel + 1],
 
 4977                                working_space[peak_vel + 9],
 
 4978                                working_space[peak_vel + 11],
 
 4979                                working_space[peak_vel + 13]);
 
 4981                      working_space[2 * shift + k] += chi_opt; 
 
 4983                      working_space[4 * shift + k] += b; 
 
 4987                if (fFixPositionX1[j] == 
false) {
 
 4988                   a = Deri01(i1, working_space[7 * j + 3],
 
 4989                               working_space[7 * j + 5],
 
 4990                               working_space[peak_vel],
 
 4991                               working_space[peak_vel + 8],
 
 4992                               working_space[peak_vel + 10],
 
 4993                               working_space[peak_vel + 12]);
 
 4995                      working_space[2 * shift + k] += chi_opt; 
 
 4997                      working_space[4 * shift + k] += b; 
 
 5001                if (fFixPositionY1[j] == 
false) {
 
 5002                   a = Deri01(i2, working_space[7 * j + 4],
 
 5003                               working_space[7 * j + 6],
 
 5004                               working_space[peak_vel + 1],
 
 5005                               working_space[peak_vel + 9],
 
 5006                               working_space[peak_vel + 11],
 
 5007                               working_space[peak_vel + 13]);
 
 5009                      working_space[2 * shift + k] += chi_opt; 
 
 5011                      working_space[4 * shift + k] += b; 
 
 5016             if (fFixSigmaX == 
false) {
 
 5017                a = Dersigmax(fNPeaks, i1, i2,
 
 5018                               working_space, working_space[peak_vel],
 
 5019                               working_space[peak_vel + 1],
 
 5020                               working_space[peak_vel + 2],
 
 5021                               working_space[peak_vel + 6],
 
 5022                               working_space[peak_vel + 7],
 
 5023                               working_space[peak_vel + 8],
 
 5024                               working_space[peak_vel + 10],
 
 5025                               working_space[peak_vel + 12],
 
 5026                               working_space[peak_vel + 13]);
 
 5028                   working_space[2 * shift + k] += chi_opt; 
 
 5030                   working_space[4 * shift + k] += b; 
 
 5034             if (fFixSigmaY == 
false) {
 
 5035                a = Dersigmay(fNPeaks, i1, i2,
 
 5036                               working_space, working_space[peak_vel],
 
 5037                               working_space[peak_vel + 1],
 
 5038                               working_space[peak_vel + 2],
 
 5039                               working_space[peak_vel + 6],
 
 5040                               working_space[peak_vel + 7],
 
 5041                               working_space[peak_vel + 9],
 
 5042                               working_space[peak_vel + 11],
 
 5043                               working_space[peak_vel + 12],
 
 5044                               working_space[peak_vel + 13]);
 
 5046                   working_space[2 * shift + k] += chi_opt; 
 
 5048                   working_space[4 * shift + k] += b; 
 
 5052             if (fFixRo == 
false) {
 
 5053                a = Derro(fNPeaks, i1, i2,
 
 5054                           working_space, working_space[peak_vel],
 
 5055                           working_space[peak_vel + 1],
 
 5056                           working_space[peak_vel + 2]);
 
 5058                   working_space[2 * shift + k] += chi_opt; 
 
 5060                   working_space[4 * shift + k] += b; 
 
 5064             if (fFixA0 == 
false) {
 
 5067                   working_space[2 * shift + k] += chi_opt; 
 
 5069                   working_space[4 * shift + k] += b; 
 
 5073             if (fFixAx == 
false) {
 
 5076                   working_space[2 * shift + k] += chi_opt; 
 
 5078                   working_space[4 * shift + k] += b; 
 
 5082             if (fFixAy == 
false) {
 
 5085                   working_space[2 * shift + k] += chi_opt; 
 
 5087                   working_space[4 * shift + k] += b; 
 
 5091             if (fFixTxy == 
false) {
 
 5092                a = Dertxy(fNPeaks, i1, i2,
 
 5093                            working_space, working_space[peak_vel],
 
 5094                            working_space[peak_vel + 1],
 
 5095                            working_space[peak_vel + 12],
 
 5096                            working_space[peak_vel + 13]);
 
 5098                   working_space[2 * shift + k] += chi_opt; 
 
 5100                   working_space[4 * shift + k] += b; 
 
 5104             if (fFixSxy == 
false) {
 
 5105                a = Dersxy(fNPeaks, i1, i2,
 
 5106                            working_space, working_space[peak_vel],
 
 5107                            working_space[peak_vel + 1]);
 
 5109                   working_space[2 * shift + k] += chi_opt; 
 
 5111                   working_space[4 * shift + k] += b; 
 
 5115             if (fFixTx == 
false) {
 
 5116                a = Dertx(fNPeaks, i1, working_space,
 
 5117                           working_space[peak_vel],
 
 5118                           working_space[peak_vel + 12]);
 
 5120                   working_space[2 * shift + k] += chi_opt; 
 
 5122                   working_space[4 * shift + k] += b; 
 
 5126             if (fFixTy == 
false) {
 
 5127                a = Derty(fNPeaks, i2, working_space,
 
 5128                           working_space[peak_vel + 1],
 
 5129                           working_space[peak_vel + 13]);
 
 5131                   working_space[2 * shift + k] += chi_opt; 
 
 5133                   working_space[4 * shift + k] += b; 
 
 5137             if (fFixSx == 
false) {
 
 5138                a = Dersx(fNPeaks, i1, working_space,
 
 5139                           working_space[peak_vel]);
 
 5141                   working_space[2 * shift + k] += chi_opt; 
 
 5143                   working_space[4 * shift + k] += b; 
 
 5147             if (fFixSy == 
false) {
 
 5148                a = Dersy(fNPeaks, i2, working_space,
 
 5149                           working_space[peak_vel + 1]);
 
 5151                   working_space[2 * shift + k] += chi_opt; 
 
 5153                   working_space[4 * shift + k] += b; 
 
 5157             if (fFixBx == 
false) {
 
 5158                a = Derbx(fNPeaks, i1, i2,
 
 5159                           working_space, working_space[peak_vel],
 
 5160                           working_space[peak_vel + 1],
 
 5161                           working_space[peak_vel + 6],
 
 5162                           working_space[peak_vel + 8],
 
 5163                           working_space[peak_vel + 12],
 
 5164                           working_space[peak_vel + 13]);
 
 5166                   working_space[2 * shift + k] += chi_opt; 
 
 5168                   working_space[4 * shift + k] += b; 
 
 5172             if (fFixBy == 
false) {
 
 5173                a = Derby(fNPeaks, i1, i2,
 
 5174                           working_space, working_space[peak_vel],
 
 5175                           working_space[peak_vel + 1],
 
 5176                           working_space[peak_vel + 6],
 
 5177                           working_space[peak_vel + 8],
 
 5178                           working_space[peak_vel + 12],
 
 5179                           working_space[peak_vel + 13]);
 
 5181                   working_space[2 * shift + k] += chi_opt; 
 
 5183                   working_space[4 * shift + k] += b; 
 
 5190    b = (fXmax - fXmin + 1) * (fYmax - fYmin + 1) - size;
 
 5191    chi_er = chi_cel / b;
 
 5192    for (i = 0, j = 0; i < fNPeaks; i++) {
 
 5194           Volume(working_space[7 * i], working_space[peak_vel],
 
 5195                  working_space[peak_vel + 1], working_space[peak_vel + 2]);
 
 5196       if (fVolume[i] > 0) {
 
 5198          if (fFixAmp[i] == 
false) {
 
 5199             a = Derpa2(working_space[peak_vel],
 
 5200                         working_space[peak_vel + 1],
 
 5201                         working_space[peak_vel + 2]);
 
 5202             b = working_space[4 * shift + j]; 
 
 5210          if (fFixSigmaX == 
false) {
 
 5211             a = Derpsigmax(working_space[shift + j],
 
 5212                             working_space[peak_vel + 1],
 
 5213                             working_space[peak_vel + 2]);
 
 5214             b = working_space[4 * shift + peak_vel]; 
 
 5222          if (fFixSigmaY == 
false) {
 
 5223             a = Derpsigmay(working_space[shift + j],
 
 5224                             working_space[peak_vel],
 
 5225                             working_space[peak_vel + 2]);
 
 5226             b = working_space[4 * shift + peak_vel + 1]; 
 
 5234          if (fFixRo == 
false) {
 
 5235             a = Derpro(working_space[shift + j], working_space[peak_vel],
 
 5236                         working_space[peak_vel + 1],
 
 5237                         working_space[peak_vel + 2]);
 
 5238             b = working_space[4 * shift + peak_vel + 2]; 
 
 5246          fVolumeErr[i] = TMath::Sqrt(TMath::Abs(chi_er * c));
 
 5252       if (fFixAmp[i] == 
false) {
 
 5253          fAmpCalc[i] = working_space[shift + j]; 
 
 5254          if (working_space[3 * shift + j] != 0)
 
 5255             fAmpErr[i] = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 5260          fAmpCalc[i] = fAmpInit[i];
 
 5263       if (fFixPositionX[i] == 
false) {
 
 5264          fPositionCalcX[i] = working_space[shift + j]; 
 
 5265          if (working_space[3 * shift + j] != 0)
 
 5266             fPositionErrX[i] = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 5271          fPositionCalcX[i] = fPositionInitX[i];
 
 5272          fPositionErrX[i] = 0;
 
 5274       if (fFixPositionY[i] == 
false) {
 
 5275          fPositionCalcY[i] = working_space[shift + j]; 
 
 5276          if (working_space[3 * shift + j] != 0)
 
 5277             fPositionErrY[i] = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 5282          fPositionCalcY[i] = fPositionInitY[i];
 
 5283          fPositionErrY[i] = 0;
 
 5285       if (fFixAmpX1[i] == 
false) {
 
 5286          fAmpCalcX1[i] = working_space[shift + j]; 
 
 5287          if (working_space[3 * shift + j] != 0)
 
 5288             fAmpErrX1[i] = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 5293          fAmpCalcX1[i] = fAmpInitX1[i];
 
 5296       if (fFixAmpY1[i] == 
false) {
 
 5297          fAmpCalcY1[i] = working_space[shift + j]; 
 
 5298          if (working_space[3 * shift + j] != 0)
 
 5299             fAmpErrY1[i] = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 5304          fAmpCalcY1[i] = fAmpInitY1[i];
 
 5307       if (fFixPositionX1[i] == 
false) {
 
 5308          fPositionCalcX1[i] = working_space[shift + j]; 
 
 5309          if (working_space[3 * shift + j] != 0)
 
 5310             fPositionErrX1[i] = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 5315          fPositionCalcX1[i] = fPositionInitX1[i];
 
 5316          fPositionErrX1[i] = 0;
 
 5318       if (fFixPositionY1[i] == 
false) {
 
 5319          fPositionCalcY1[i] = working_space[shift + j]; 
 
 5320          if (working_space[3 * shift + j] != 0)
 
 5321             fPositionErrY1[i] = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 5326          fPositionCalcY1[i] = fPositionInitY1[i];
 
 5327          fPositionErrY1[i] = 0;
 
 5330    if (fFixSigmaX == 
false) {
 
 5331       fSigmaCalcX = working_space[shift + j]; 
 
 5332       if (working_space[3 * shift + j] != 0) 
 
 5333          fSigmaErrX = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 5338       fSigmaCalcX = fSigmaInitX;
 
 5341    if (fFixSigmaY == 
false) {
 
 5342       fSigmaCalcY = working_space[shift + j]; 
 
 5343       if (working_space[3 * shift + j] != 0) 
 
 5344          fSigmaErrY = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 5349       fSigmaCalcY = fSigmaInitY;
 
 5352    if (fFixRo == 
false) {
 
 5353       fRoCalc = working_space[shift + j]; 
 
 5354       if (working_space[3 * shift + j] != 0) 
 
 5355          fRoErr = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 5363    if (fFixA0 == 
false) {
 
 5364       fA0Calc = working_space[shift + j]; 
 
 5365       if (working_space[3 * shift + j] != 0) 
 
 5366          fA0Err = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 5374    if (fFixAx == 
false) {
 
 5375       fAxCalc = working_space[shift + j]; 
 
 5376       if (working_space[3 * shift + j] != 0) 
 
 5377          fAxErr = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 5385    if (fFixAy == 
false) {
 
 5386       fAyCalc = working_space[shift + j]; 
 
 5387       if (working_space[3 * shift + j] != 0) 
 
 5388          fAyErr = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 5396    if (fFixTxy == 
false) {
 
 5397       fTxyCalc = working_space[shift + j]; 
 
 5398       if (working_space[3 * shift + j] != 0) 
 
 5399          fTxyErr = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 5404       fTxyCalc = fTxyInit;
 
 5407    if (fFixSxy == 
false) {
 
 5408       fSxyCalc = working_space[shift + j]; 
 
 5409       if (working_space[3 * shift + j] != 0) 
 
 5410          fSxyErr = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 5415       fSxyCalc = fSxyInit;
 
 5418    if (fFixTx == 
false) {
 
 5419       fTxCalc = working_space[shift + j]; 
 
 5420       if (working_space[3 * shift + j] != 0) 
 
 5421          fTxErr = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 5429    if (fFixTy == 
false) {
 
 5430       fTyCalc = working_space[shift + j]; 
 
 5431       if (working_space[3 * shift + j] != 0) 
 
 5432          fTyErr = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 5440    if (fFixSx == 
false) {
 
 5441       fSxCalc = working_space[shift + j]; 
 
 5442       if (working_space[3 * shift + j] != 0) 
 
 5443          fSxErr = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 5451    if (fFixSy == 
false) {
 
 5452       fSyCalc = working_space[shift + j]; 
 
 5453       if (working_space[3 * shift + j] != 0) 
 
 5454          fSyErr = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 5462    if (fFixBx == 
false) {
 
 5463       fBxCalc = working_space[shift + j]; 
 
 5464       if (working_space[3 * shift + j] != 0) 
 
 5465          fBxErr = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 5473    if (fFixBy == 
false) {
 
 5474       fByCalc = working_space[shift + j]; 
 
 5475       if (working_space[3 * shift + j] != 0) 
 
 5476          fByErr = TMath::Sqrt(TMath::Abs(working_space[2 * shift + j])) / TMath::Sqrt(TMath::Abs(working_space[3 * shift + j])); 
 
 5484    b = (fXmax - fXmin + 1) * (fYmax - fYmin + 1) - size;
 
 5486    for (i1 = fXmin; i1 <= fXmax; i1++) {
 
 5487       for (i2 = fYmin; i2 <= fYmax; i2++) {
 
 5488          f = Shape2(fNPeaks, i1, i2,
 
 5489                      working_space, working_space[peak_vel],
 
 5490                      working_space[peak_vel + 1],
 
 5491                      working_space[peak_vel + 2],
 
 5492                      working_space[peak_vel + 3],
 
 5493                      working_space[peak_vel + 4],
 
 5494                      working_space[peak_vel + 5],
 
 5495                      working_space[peak_vel + 6],
 
 5496                      working_space[peak_vel + 7],
 
 5497                      working_space[peak_vel + 8],
 
 5498                      working_space[peak_vel + 9],
 
 5499                      working_space[peak_vel + 10],
 
 5500                      working_space[peak_vel + 11],
 
 5501                      working_space[peak_vel + 12],
 
 5502                      working_space[peak_vel + 13]);
 
 5507    for (i = 0; i < size; i++) 
delete [] working_matrix[i];
 
 5508    delete [] working_matrix;
 
 5509    delete [] working_space;
 
 5523 void TSpectrum2Fit::SetFitParameters(Int_t xmin,Int_t xmax,Int_t ymin,Int_t ymax, Int_t numberIterations, Double_t alpha, Int_t statisticType, Int_t alphaOptim, Int_t power, Int_t fitTaylor)
 
 5525    if(xmin<0 || xmax <= xmin || ymin<0 || ymax <= ymin){
 
 5526       Error(
"SetFitParameters", 
"Wrong range");
 
 5529    if (numberIterations <= 0){
 
 5530       Error(
"SetFitParameters",
"Invalid number of iterations, must be positive");
 
 5533    if (alpha <= 0 || alpha > 1){
 
 5534       Error (
"SetFitParameters",
"Invalid step coefficient alpha, must be > than 0 and <=1");
 
 5537    if (statisticType != kFitOptimChiCounts
 
 5538         && statisticType != kFitOptimChiFuncValues
 
 5539         && statisticType != kFitOptimMaxLikelihood){
 
 5540       Error(
"SetFitParameters",
"Wrong type of statistic");
 
 5543    if (alphaOptim != kFitAlphaHalving
 
 5544         && alphaOptim != kFitAlphaOptimal){
 
 5545       Error(
"SetFitParameters",
"Wrong optimization algorithm");
 
 5548    if (power != kFitPower2 && power != kFitPower4
 
 5549         && power != kFitPower6 && power != kFitPower8
 
 5550         && power != kFitPower10 && power != kFitPower12){
 
 5551       Error(
"SetFitParameters",
"Wrong power");
 
 5554    if (fitTaylor != kFitTaylorOrderFirst
 
 5555         && fitTaylor != kFitTaylorOrderSecond){
 
 5556       Error(
"SetFitParameters",
"Wrong order of Taylor development");
 
 5559    fXmin=xmin,fXmax=xmax,fYmin=ymin,fYmax=ymax,fNumberIterations=numberIterations,fAlpha=alpha,fStatisticType=statisticType,fAlphaOptim=alphaOptim,fPower=power,fFitTaylor=fitTaylor;
 
 5581 void TSpectrum2Fit::SetPeakParameters(Double_t sigmaX, Bool_t fixSigmaX, Double_t sigmaY, Bool_t fixSigmaY, Double_t ro, Bool_t fixRo, 
const Double_t *positionInitX, 
const Bool_t *fixPositionX, 
const Double_t *positionInitY, 
const Bool_t *fixPositionY, 
const Double_t *positionInitX1, 
const Bool_t *fixPositionX1, 
const Double_t *positionInitY1, 
const Bool_t *fixPositionY1, 
const Double_t *ampInit, 
const Bool_t *fixAmp, 
const Double_t *ampInitX1, 
const Bool_t *fixAmpX1, 
const Double_t *ampInitY1, 
const Bool_t *fixAmpY1)
 
 5583    if (sigmaX <= 0 || sigmaY <= 0){
 
 5584       Error (
"SetPeakParameters",
"Invalid sigma, must be > than 0");
 
 5587    if (ro < -1 || ro > 1){
 
 5588       Error (
"SetPeakParameters",
"Invalid ro, must be from region <-1,1>");
 
 5592    for(i=0; i < fNPeaks; i++){
 
 5593       if(positionInitX[i] < fXmin || positionInitX[i] > fXmax){
 
 5594          Error (
"SetPeakParameters",
"Invalid peak position, must be in the range fXmin, fXmax");
 
 5597       if(positionInitY[i] < fYmin || positionInitY[i] > fYmax){
 
 5598          Error (
"SetPeakParameters",
"Invalid peak position, must be in the range fYmin, fYmax");
 
 5601       if(positionInitX1[i] < fXmin || positionInitX1[i] > fXmax){
 
 5602          Error (
"SetPeakParameters",
"Invalid ridge position, must be in the range fXmin, fXmax");
 
 5605       if(positionInitY1[i] < fYmin || positionInitY1[i] > fYmax){
 
 5606          Error (
"SetPeakParameters",
"Invalid ridge position, must be in the range fYmin, fYmax");
 
 5610          Error (
"SetPeakParameters",
"Invalid peak amplitude, must be > than 0");
 
 5613       if(ampInitX1[i] < 0){
 
 5614          Error (
"SetPeakParameters",
"Invalid x ridge amplitude, must be > than 0");
 
 5617       if(ampInitY1[i] < 0){
 
 5618          Error (
"SetPeakParameters",
"Invalid y ridge amplitude, must be > than 0");
 
 5622    fSigmaInitX = sigmaX, fFixSigmaX = fixSigmaX, fSigmaInitY = sigmaY, fFixSigmaY = fixSigmaY, fRoInit = ro, fFixRo = fixRo;
 
 5623    for(i=0; i < fNPeaks; i++){
 
 5624       fPositionInitX[i] = positionInitX[i];
 
 5625       fFixPositionX[i] = fixPositionX[i];
 
 5626       fPositionInitY[i] = positionInitY[i];
 
 5627       fFixPositionY[i] = fixPositionY[i];
 
 5628       fPositionInitX1[i] = positionInitX1[i];
 
 5629       fFixPositionX1[i] = fixPositionX1[i];
 
 5630       fPositionInitY1[i] = positionInitY1[i];
 
 5631       fFixPositionY1[i] = fixPositionY1[i];
 
 5632       fAmpInit[i] = ampInit[i];
 
 5633       fFixAmp[i] = fixAmp[i];
 
 5634       fAmpInitX1[i] = ampInitX1[i];
 
 5635       fFixAmpX1[i] = fixAmpX1[i];
 
 5636       fAmpInitY1[i] = ampInitY1[i];
 
 5637       fFixAmpY1[i] = fixAmpY1[i];
 
 5650 void TSpectrum2Fit::SetBackgroundParameters(Double_t a0Init, Bool_t fixA0, Double_t axInit, Bool_t fixAx, Double_t ayInit, Bool_t fixAy)
 
 5679 void TSpectrum2Fit::SetTailParameters(Double_t tInitXY, Bool_t fixTxy, Double_t tInitX, Bool_t fixTx, Double_t tInitY, Bool_t fixTy, Double_t bInitX, Bool_t fixBx, Double_t bInitY, Bool_t fixBy, Double_t sInitXY, Bool_t fixSxy, Double_t sInitX, Bool_t fixSx, Double_t sInitY, Bool_t fixSy)
 
 5706 void TSpectrum2Fit::GetPositions(Double_t *positionsX, Double_t *positionsY, Double_t *positionsX1, Double_t *positionsY1)
 
 5708    for( Int_t i=0; i < fNPeaks; i++){
 
 5709       positionsX[i]  = fPositionCalcX[i];
 
 5710       positionsY[i]  = fPositionCalcY[i];
 
 5711       positionsX1[i] = fPositionCalcX1[i];
 
 5712       positionsY1[i] = fPositionCalcY1[i];
 
 5723 void TSpectrum2Fit::GetPositionErrors(Double_t *positionErrorsX, Double_t *positionErrorsY, Double_t *positionErrorsX1, Double_t *positionErrorsY1)
 
 5725    for( Int_t i=0; i < fNPeaks; i++){
 
 5726       positionErrorsX[i] = fPositionErrX[i];
 
 5727       positionErrorsY[i] = fPositionErrY[i];
 
 5728       positionErrorsX1[i] = fPositionErrX1[i];
 
 5729       positionErrorsY1[i] = fPositionErrY1[i];
 
 5739 void TSpectrum2Fit::GetAmplitudes(Double_t *amplitudes, Double_t *amplitudesX1, Double_t *amplitudesY1)
 
 5741    for( Int_t i=0; i < fNPeaks; i++){
 
 5742       amplitudes[i] = fAmpCalc[i];
 
 5743       amplitudesX1[i] = fAmpCalcX1[i];
 
 5744       amplitudesY1[i] = fAmpCalcY1[i];
 
 5754 void TSpectrum2Fit::GetAmplitudeErrors(Double_t *amplitudeErrors, Double_t *amplitudeErrorsX1, Double_t *amplitudeErrorsY1)
 
 5756    for( Int_t i=0; i < fNPeaks; i++){
 
 5757       amplitudeErrors[i] = fAmpErr[i];
 
 5758       amplitudeErrorsX1[i] = fAmpErrX1[i];
 
 5759       amplitudeErrorsY1[i] = fAmpErrY1[i];
 
 5767 void TSpectrum2Fit::GetVolumes(Double_t *volumes)
 
 5769    for( Int_t i=0; i < fNPeaks; i++){
 
 5770       volumes[i] = fVolume[i];
 
 5778 void TSpectrum2Fit::GetVolumeErrors(Double_t *volumeErrors)
 
 5780    for( Int_t i=0; i < fNPeaks; i++){
 
 5781       volumeErrors[i] = fVolumeErr[i];
 
 5790 void TSpectrum2Fit::GetSigmaX(Double_t &sigmaX, Double_t &sigmaErrX)
 
 5793    sigmaErrX=fSigmaErrX;
 
 5801 void TSpectrum2Fit::GetSigmaY(Double_t &sigmaY, Double_t &sigmaErrY)
 
 5804    sigmaErrY=fSigmaErrY;
 
 5812 void TSpectrum2Fit::GetRo(Double_t &ro, Double_t &roErr)
 
 5827 void TSpectrum2Fit::GetBackgroundParameters(Double_t &a0, Double_t &a0Err, Double_t &ax, Double_t &axErr, Double_t &ay, Double_t &ayErr)
 
 5856 void TSpectrum2Fit::GetTailParameters(Double_t &txy, Double_t &txyErr, Double_t &tx, Double_t &txErr, Double_t &ty, Double_t &tyErr, Double_t &bx, Double_t &bxErr, Double_t &by, Double_t &byErr, Double_t &sxy, Double_t &sxyErr, Double_t &sx, Double_t &sxErr, Double_t &sy, Double_t &syErr)