# Draw a plot of 2 variables

Dear Expert,

I calculate the sigma for each mass, I have three mass [2750, 3450, 4500]
Then I have three sigmas: sigma_2750, sigma_3450 and sigma_4500
I want to draw these sigmas as a function of these mass on one plot

Can someone help me how I can do this plot?

Thanks

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided

I tried to use Tgraph and also TProfil but it doesn’t work for me

I do like :
TGraph *g = new TGraph(dim, diff_Mass, sigma_2750);

Knowing that I declare diff_Mass as :
double diff_Mass[] = {2750, 3450, 4500};

and int dim = 3;

But for ,me I want to draw one plot take these three mass and its sigma

TGraph sounds like the way to go, but you have to tell us what should be on the x axis and what’s on the y axis.

But it looks like the sigmas (sigma_2750, sigma_3450 and sigma_4500) are 3 separate variables. You need to do an array, just like you did for diff_Mass, and use these 2 arrays in the TGraph.

Yes @dastudillo the sigmas are 3 separate variables you can find below what I do.

``````    for(int i = 1; i < nBins; i++){

sigma27_mttphi2[i] = sqrt(2*((h3->GetBinContent(i) + htt->GetBinContent(i))*log(1+(h3->GetBinContent(i)/htt->GetBinContent(i))) - h3->GetBinContent(i)));
sigma3_mttphi2[i] = sqrt(2*((h3->GetBinContent(i) + htt->GetBinContent(i))*log(1+(h3->GetBinContent(i)/htt->GetBinContent(i))) - h3->GetBinContent(i)));
sigma4_mttphi2[i] = sqrt(2*((h3->GetBinContent(i) + htt->GetBinContent(i))*log(1+(h3->GetBinContent(i)/htt->GetBinContent(i))) - h3->GetBinContent(i)));

chi2_Z27 += sigma27_mttphi2[i]*sigma27_mttphi2[i];
chi2_Z3 += sigma3_mttphi2[i]*sigma3_mttphi2[i];
chi2_Z4 += sigma4_mttphi2[i]*sigma4_mttphi2[i];

double pvalue_Z27 = ROOT::Math::chisquared_cdf_c(chi2_Z27, nBins);
significance_Z27 = ROOT::Math::normal_quantile_c(pvalue_Z27, 1);

double pvalue_Z3 = ROOT::Math::chisquared_cdf_c(chi2_Z3, nBins);
double significance_Z3 = ROOT::Math::normal_quantile_c(pvalue_Z3, 1);

double pvalue_Z4 = ROOT::Math::chisquared_cdf_c(chi2_Z4, nBins);
double significance_Z4 = ROOT::Math::normal_quantile_c(pvalue_Z4, 1);
``````

I think, I should to do what you suggest put each significance on an array and after draw them by Tgraph

Thanks,

}

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