Reading back some text TLatex written in a TPad

Hi,

I have a TPad with some TLatex text written in it. I would like to read the text that has been written.
Does anybody know how to do this ?

The initial code to make the plot looks like:

TCanvas *cTF = new TCanvas("cTF","cTF",wx,wy);
cTF->Divide(1,3);  
cTF->cd(1);
hmodulusrange->Draw();      // This is a TH2F
TLatex* latex1 = new TLatex(posx,posy,text);
latex1->Draw();

The TCanvas is then saved into a ROOT file and I would like to read it later.

Here is what is in the TCanvas cTF:

[  ] cTF->ls()

Canvas Name=cTF Title=cTF Option=
 TCanvas fXlowNDC=0 fYlowNDC=0 fWNDC=1 fHNDC=1 Name= cTF Title= cTF Option=
  OBJ: TList    TList   Doubly linked list : 0

   TPad fXlowNDC=0.01 fYlowNDC=0.676667 fWNDC=0.98 fHNDC=0.313333 Name= cTF_1 Title= cTF_1 Option=
    OBJ: TList  TList   Doubly linked list : 0
     TFrame  X1= 1.000000 Y1=-10.301030 X2=4.000000 Y2=-6.698970
     OBJ: TH2F  modulusrange   modulus. GPS: 976443468, UTC: Wed Dec 15 10:17:33 2010 : 0 at:0x1f5bd000
     Text  X=20.000000 Y=0.000000 Text=TF - GPS: 976443468, UTC: Wed Dec 15 10:17:33 2010
     OBJ: TH1D  modulus        modulus. GPS: 976443468, UTC: Wed Dec 15 10:17:33 2010 : 0 at: 0x1f728c50
     OBJ: TH1D  OFitModulus     OFitModulus : 0 at: 0x1f75f110
     Text  X=30.000000 Y=0.000000 Text=Optical gain:  5.49117e+09 #pm 556056 W/m
     Text  X=30.000000 Y=0.000000 Text=Additionnal delay: -7.8 #pm 0.0 #mu s
     Text  X=30.000000 Y=0.000000 Text=Cavity pole: 167.00 #pm 0.00 Hz  (F=149.60 #pm 0.00)
     Text  X=30.000000 Y=0.000000 Text=P(#chi^{2}): 99.969 %

   TPad fXlowNDC=0.01 fYlowNDC=0.343333 fWNDC=0.98 fHNDC=0.313333 Name= cTF_2 Title= cTF_2 Option=
      ........
      ........

I would like to get the Text “Optical gain: 5.49117e+09 #pm 556056 W/m”. Any idea ?

Thanks !
Loïc

Hi,

something like this?

TClass*cl = TClass::GetClass("TLatex");
TObject* prim = 0;
TIter iPrim(gPad->GetListOfPrimitives());
while ((prim = iPrim())) {
   if (prim->IsA() == cl) {
     cout << prim->GetTitle() << endl;
   }
}

Cheers, Axel.

Hi,
It works fine ! Thanks :slight_smile:
Cheers,
Loïc