TGraphAsymmErrors for fit

I am trying to run the program with TGraphAsymmErrors. The data file has no error in x but unsymmetrical errors in y. So in the data file I put 0 0 for x errors and ……
…… for y errors (two columns). the data file structure is x,y, errx+ errx-, erry+, erry-…
The program does not work, although it works with TGraphErrors.
Can any one point out the mistakes.

Thanks

The program code;

#include "TCanvas.h"
#include "TROOT.h"
#include "TMath.h"
#include "TGraphErrors.h"
#include "TGraphAsymmErrors.h"
#include "TF1.h"
#include "TLegend.h"
#include "TArrow.h"
#include "TLatex.h"
using namespace std;
void A()
{
//TGraphErrors graph2("A.txt");
TGraphAsymmErrors graph2("A.txt");

graph2.SetTitle(" Charged Multiplicity");
graph2.SetMarkerStyle(kOpenCircle);
graph2.SetMarkerColor(kBlue);
graph2.SetLineColor(kBlue);
TCanvas* mycanvas = new TCanvas();
graph2.DrawClone("APE");

TF1 f("f","[0]*([1]*TMath::Exp(-[1]*x) * TMath::Exp(-[2]*TMath::Exp(-[1]*x))) * (1 + [2]*(1-TMath::Exp(-[1]*x)))",10,30);


  f.SetParNames("c","b","eta");
  f.SetParameter(0, 0.2); // c (normalization constant)
  f.SetParameter(1, 0.2); // b 
  f.SetParameter(2, 4); // eta 

  graph2.Fit(&f, "ME");

  f.DrawClone("Same"); 

}
int main( )
{
A();
return 0;
}
-----------------------data File________________**

10	0.03987		0  0	0.0029644561	0.0020554318
11	0.03472		0  0	0.0025455844	0.0017670597
12	0.03035		0  0	0.0021980446	0.0015500323
13	0.02661		0  0	0.001908743	0.0013800362
14	0.02328		0  0	0.0016690416	0.0012684636
15	0.02018		0  0	0.0014689112	0.0011763078
16	0.01728		0  0	0.001317953	0.0010841587
17	0.0147		0  0	0.0011866339	0.0009823441
18	0.0125		0  0	0.0010651291	0.000880568
19	0.01067		0  0	0.0009339165	0.0007692204
20	0.00916		0  0	0.0008052329	0.0006705222
21	0.00786		0  0	0.0006868042	0.0005913544
22	0.00671		0  0	0.0005948109	0.0005375872
23	0.0057		0  0	0.0005440588	0.000515461
24	0.00478		0  0	0.0005220153	0.0005124451
25	0.00394		0  0	0.0005192302	0.000490408
26	0.00319		0  0	0.0004972927	0.0004492215
27	0.00251		0  0	0.0004368066	0.00037
28	0.00196		0  0	0.0003573514	0.0003008322
29	0.00156		0  0	0.0002879236	0.0002416609
30	0.001301	        0  0	0.0002420021	0.0002110853

You can format your code to show up as code by surrounding it with ``` or by using the </> button in the toolbar. This way it becomes a lot easier to read…

Also, could you add in what sense it does not work? Does it crash? If so, what is the error you get?

When I run your code I get:

$ root A.C
   ----------------------------------------------------------------
  | Welcome to ROOT 6.09/03                    http://root.cern.ch |
  |                                   (c) 1995-2017, The ROOT Team |
  | Built for macosx64                                             |
  | From heads/master@v6-09-02-882-g5b6f5fa, May 17 2017, 11:12:16 |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'     |
   ----------------------------------------------------------------

root [0] 
Processing A.C...
 FCN=4.39876 FROM MINOS     STATUS=SUCCESSFUL    103 CALLS         576 TOTAL
                     EDM=3.44047e-07    STRATEGY= 1      ERROR MATRIX ACCURATE 
  EXT PARAMETER                                   STEP         FIRST   
  NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE 
   1  c            6.14765e-01   9.95676e-02   1.02631e-03  -5.47642e-02
   2  b            1.87879e-01   7.14215e-03  -4.97973e-05   4.12929e-01
   3  eta          2.60418e+00   1.01587e+00   1.01587e+00   3.75010e-04

Could you tell what is wrong ?

AA.txt (1.1 KB)
A.C (602 Bytes)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.