Handeling TPaveText()

Dear All,
I am using TPaveText() in a way that I think is not the best one, it works but it’s very handwriting. Actually to display something in my histogram using TPaveText() I proceed like this:

TPaveText *pt_2e2m = new TPaveText(300,1.e-2,750,1.e3);
 pt_2e2m->AddText("qqZZ:     348.23 #pm 2.05");
 pt_2e2m->AddText("ggZZ:     28.69 #pm 0.14");
 pt_2e2m->AddText("ggHZZ:    0.94 #pm 0.00");
 pt_2e2m->AddText("VBFHZZ:   0.035 #pm 0.001");
 pt_2e2m->Draw("NB");

But before that I have to use cout first:

 std::cout <<"Integral_ggZZ_4e "     <<std::setprecision(3)<<  Integral_ggZZ_4e     << "+- " << error_ggZZ_4e     << std::endl; 
 std::cout <<"Integral_ggHZZ_4e "    <<std::setprecision(3)<<  Integral_ggHZZ_4e    << "+- " << error_ggHZZ_4e    << std::endl; 
 std::cout <<"Integral_VBFHZZ_4e "   <<std::setprecision(3)<<  Integral_VBFHZZ_4e   << "+- " << error_VBFHZZ_4e   << std::endl;   

to print out on my terminal what I want to display in my histogram and then copy from my terminal to and paste it to my code, in the first block of code below.
Is there any other way of doing it without printing it ? Thanks in advance.
Cheers,
Diallo.

You can use Form

pt_2e2m->AddText(Form("value = %f",value));

Hi,
Thanks very much, it works :slight_smile:

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