TMathText from TPad in TFile

Dear experts.

A colleague gave me his TFile which contains a TCanvas which is divided into two TPads. There is a TMathText field attached to the TPad and I would like to alter it, redraw and save the TCanvas (which is the reason why I asked him for the TFile). However, doing an canvas->ls() tells me that there is no reference nor name for the text field in question. I merely know the text content (and NDC location). How can I still modify this?

In the ROOT prompt output below the last line is the one of interest.

Thanks a lot for your advice!
heico

root [3] TCanvas* c = (TCanvas*) _file0->Get("canvas")
(TCanvas *) 0x7f8e4acf68d0
root [4] c->ls()
Canvas Name=canvas Title=canvas Option=
 TCanvas fXlowNDC=0 fYlowNDC=0 fWNDC=1 fHNDC=1 Name= canvas Title= canvas Option=
  OBJ: TList	TList	Doubly linked list : 0
   TPad fXlowNDC=0 fYlowNDC=0 fWNDC=1 fHNDC=1 Name= bottom_pad_19 Title= bottom_pad Option=
    OBJ: TList	TList	Doubly linked list : 0
     [...]
   TPad fXlowNDC=0 fYlowNDC=0 fWNDC=1 fHNDC=1 Name= top_pad_18 Title= top_pad Option=
    OBJ: TList	TList	Doubly linked list : 0
     [...]
     OBJ: TH1D	bkg_Data 2b_10_copy	 : 1 at: 0x7f8e4ae003f0
     Text  X=0.915000 Y=0.809000 Text=150 < p_{T}^{miss} #leq 200 GeV

Can you post the TFile ?

Dear couet!

Thank you for your response. I do not think I am allowed to share the original TFile.
But I found another one with a similar text field without reference, and that one is public,
see: http://cms-results.web.cern.ch/cms-results/public-results/preliminary-results/SUS-16-039/CMS-PAS-SUS-16-039_Figure_013.root

Again, the last line in the print out below is the text object in question.

Thank you!
heico

root [2] TCanvas* c = (TCanvas*) _file0->Get("TChiSlepSnu_FD")
(TCanvas *) 0x7ff300e4bf50
root [3] c->ls()
Canvas Name=TChiSlepSnu_FD Title=TChiSlepSnu_FD Option=
 TCanvas fXlowNDC=0 fYlowNDC=0 fWNDC=1 fHNDC=1 Name= TChiSlepSnu_FD Title= TChiSlepSnu_FD Option=
  OBJ: TList	TList	Doubly linked list : 0
   [...]
   Text  X=232.000000 Y=863.500000 Text=Observed #pm 1 #sigma_{theory}

If you need to alter a text only once the easiest is surely to open the editor from the View menu in the TCanvas then click on the text and modify it.

Sometimes it is easier than expected! :slight_smile: I wasn’t aware of that vast functionality…
Thanks couet, I will try like this and repost a message in case I get stuck again…

heico

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