Re: [ROOT] How to write a variable value into a histogram?

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Nov 02 2001 - 09:36:03 MET


An example:

void com() {
   TH1F *h = new TH1F("h","test",100,-4,4);
   h->FillRandom("gaus",5000);
   Double_t mean = h->GetMean();
   Double_t rms  = h->GetRMS();
   char tmean[40];
   char trms[40];
   h->Draw();
   
   //using normal text in world coordinates
   sprintf(tmean,"mean = %g",mean);
   sprintf(trms,"rms = %g",rms);
   TText *t1 = new TText(-3,140,tmean);
   t1->SetTextColor(kRed);
   t1->SetTextSize(0.04);
   t1->Draw();
   
   //using normal text in NDC
   TText *t2 = new TText(0.2,0.92,tmean);
   t2->SetNDC();
   t2->SetTextColor(kBlue);
   t2->SetTextSize(0.04);
   t2->Draw();
 
   //Using a TPaveLabel
   TPaveLabel *p = new TPaveLabel(0.6,0.7,0.8,0.76,trms,"brNDC");
   p->Draw();
}     


Rene Brun

Kai Yi wrote:
> 
> Hi, All,
>     I have a histogram, fitted with signal plus background, then I
> calculated the S/N, I want ot write this value from the vaiable into
> the histogram, anyone can tell me how to do that?
> 
> Thanks a lot!
> 
> Kai Yi



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:05 MET