Tobject is a TMarker, can I get a TMarker back?

Hi Everyone,

I’m trying to make someone else’s histogram prettier, but it turns out that they drew it in a really complicated way. Now I was able to draw a new histogram with the data in the file, and it looks the same (with my own modifications). So that is great, but I want to go one step further.

The way the plot is made, was by drawing a TMarker for every possible combination of x and y. The TMarker has different properties depending on the measurement outcome that was done with the combination of x an y. See the figure below:

hist

Now what I would like to do is change the marker colour for certain markers, and I was wondering if I could access the TMarker’s properties in such a way that I can change them, or in such a way that I can draw a new marker with the same properties except for the colour.

At the moment I do the following:

  allMyFiles = new TFile (getFileName("delay25_upstream"), "READ");
  TCanvas *canv = (TCanvas*)allMyFiles->Get("/i2c/i2c_master/RDa vs. SDa for portcard i2c_master_upstream and module BPix_BpO_SEC1_LYR3_LDR1F_MOD1"); 

  TList *lst = canv->GetListOfPrimitives();
  TObject *ob;

  TCanvas *c0 = allMyCanvasses(false, false);
  TH2F *h0 = new TH2F("hist", "histo", 65, 64, 128, 65, 64, 128);
  h0->Draw("hist");

  for (int i=0; i<lst->GetSize(); i++) {
    ob = lst->At(i);

    // THIS IS WHERE I WANT TO CHANGE THE COLOR OF THE MARKER, WHICH IS AN OBJECT HERE

    ob->Draw("same");
  }//end for list

So I was wondering, can I get a TMarker back from a TObject that is a TMarker?

Thanks in advance for the help!

Cheers,
Nikkie


_ROOT Version:6.14/08
_Platform: CentOS7 - CERN
_Compiler:linuxx8664gcc


Yes that’s possible. In the following example I do it with the TText primitive. But it is the same with TMarker. Look at the redraw() method.
sudoku.C (4.8 KB)

1 Like

Hi Couet,

Thanks a lot that works!

Cheers,
Nikkie

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