+TGraph *AliEMCALHistoUtilities::DrawGraph(Int_t n, Double_t *x, Double_t *y, Int_t markerColor,
+Int_t markerStyle, const char* opt, const char* tit, const char* xTit,const char* yTit, Int_t ifun,
+const char *optFit, const char *fun)
+{
+ /* Drawing options
+ chopt='L' : A simple polyline between every points is drawn
+ chopt='F' : A fill area is drawn ('CF' draw a smooth fill area)
+ chopt='A' : Axis are drawn around the graph
+ chopt='C' : A smooth Curve is drawn
+ chopt='*' : A Star is plotted at each point
+ chopt='P' : Idem with the current marker
+ chopt='B' : A Bar chart is drawn at each point
+ chopt='1' : ylow=rwymin
+ chopt='X+' : The X-axis is drawn on the top side of the plot.
+ chopt='Y+' : The Y-axis is drawn on the right side of the plot.
+
+ Fitting options
+ The list of fit options is given in parameter option.
+ option = "W" Set all errors to 1
+ = "U" Use a User specified fitting algorithm (via SetFCN)
+ = "Q" Quiet mode (minimum printing)
+ = "V" Verbose mode (default is between Q and V)
+ = "B" Use this option when you want to fix one or more parameters
+ and the fitting function is like "gaus","expo","poln","landau".
+ = "R" Use the Range specified in the function range
+ = "N" Do not store the graphics function, do not draw
+ = "0" Do not plot the result of the fit. By default the fitted function
+ is drawn unless the option"N" above is specified.
+ = "+" Add this new fitted function to the list of fitted functions
+ (by default, any previous function is deleted)
+ = "C" In case of linear fitting, not calculate the chisquare
+ (saves time)
+ = "F" If fitting a polN, switch to minuit fitter
+ = "ROB" In case of linear fitting, compute the LTS regression
+ coefficients (robust(resistant) regression), using
+ the default fraction of good points
+ "ROB=0.x" - compute the LTS regression coefficients, using
+ 0.x as a fraction of good points
+
+ */
+ printf("AliEMCALHistoUtilities::drawGraph started \n");
+ printf("Drawing opt |%s| : Fitting opt |%s|\n", opt, optFit);
+
+ TGraph *gr = new TGraph(n, x, y);
+ gr->SetMarkerColor(markerColor);
+ gr->SetLineColor(markerColor);
+ gr->SetMarkerStyle(markerStyle);
+ gr->SetTitle(tit);
+ gr->Draw(opt);
+
+ TString ctmp(opt);
+ if(ctmp.Contains("A")) {
+ gr->GetHistogram()->SetXTitle(xTit);
+ gr->GetHistogram()->SetYTitle(yTit);
+ }
+ ctmp = optFit;
+ if(ifun>=0) {
+ TString sf("pol"); sf += ifun;
+ gr->Fit(sf.Data(),optFit);
+ printf("\n ** Fit by Polynomial of degree %i : %s **\n", ifun, sf.Data());
+ } else if(!ctmp.Contains("no",TString::kIgnoreCase)){
+ printf("\n ** ifun %i : %s **\n", ifun, fun);
+ gr->Fit(fun, optFit);
+ }
+
+ return gr;
+}
+
+TGraphErrors *AliEMCALHistoUtilities::DrawGraphErrors(const Int_t n,Double_t *x,Double_t *y,Double_t *ex,
+Double_t *ey, Int_t markerColor, Int_t markerStyle, const char* opt, const char* tit,
+const char* xTit,char* yTit, Int_t ifun, const char *optFit, const char *fun)
+{
+ printf("AliEMCALHistoUtilities::drawGraphErrors started \n");
+ printf("Drawing opt |%s| : ifun %i: Fitting opt |%s|, fun |%s|\n",
+ opt, ifun, optFit, fun);
+
+ TGraphErrors *gr = new TGraphErrors(n, x,y,ex,ey);
+ gr->SetMarkerColor(markerColor);
+ gr->SetLineColor(markerColor);
+ gr->SetMarkerStyle(markerStyle);
+ if(tit&&strlen(tit)>0) gr->SetTitle(tit);
+
+ TString ctmp(opt);
+ if(ctmp.Contains("A")) {
+ gr->GetHistogram()->SetXTitle(xTit);
+ gr->GetHistogram()->SetYTitle(yTit);
+ }
+ if(ifun>0) {
+ if(ifun != 999) {
+ TString sf("pol"); sf += ifun;
+ gr->Fit(sf.Data(),optFit);
+ printf("\n ** Fit by Polynomial of degree %i : %s **\n", ifun, sf.Data());
+ } else {
+ gr->Fit(fun, optFit);
+ printf("\n ** Fit by %s **\n", fun);
+ }
+ } else {
+ if(strlen(optFit)) {
+ printf("\n ** ifun %i : %s **\n", ifun, fun);
+ gr->Fit(fun, optFit);
+ }
+ }
+
+ gr->Draw(opt);
+
+ return gr;
+}
+
+TF1* AliEMCALHistoUtilities::GetResolutionFunction(const char *opt, TString &latexName)
+{
+ TString OPT(opt);
+ OPT.ToUpper();
+ TF1 *fres=0;
+ if (OPT.Contains("FRES1")) {
+ fres = new TF1("fres","[0]+[1]/sqrt(x)", 0.0, 101.);
+ latexName = "#frac{#sigma_{E}}{E} = A+#frac{B}{#sqrt{E}}";
+ } else if(OPT.Contains("FRES2")) {
+ fres = new TF1("fres","sqrt([0]*[0]+[1]*[1]/x)", 0.0, 101.);
+ latexName = "#sqrt{A^{2}+#frac{B^{2}}{E}}";
+ }
+ if(fres) {
+ fres->SetParName(0,"A");
+ fres->SetParName(1,"B");
+
+ fres->SetParameter(0, 2.0);
+ fres->SetParameter(1, 6.6);
+ fres->SetLineWidth(2);
+ fres->SetLineColor(kRed);
+ }
+ return fres;
+}
+