Weird and not complete and slow drawing


ROOT Version: 6.14/02
Platform: macOS, macbook pro
Compiler: Not Provided

Dear rooters:

I am trying to plot some graphs but meeting this weird problem. After a certain times of drawing a geometry which use TLine, the style is not working any more. The line become white color and opacity. I attach a simple code to reproduce the problem and the problematic graphs which begin showing up on the second page graph 9 in the pdf file. Also the drawing is pretty slow.
Anyone can help? Thank you.

detail_into.cpp (4.8 KB)
fmsgeo.root (285.7 KB)
test_pythia6_QCDfilter.root (558.5 KB)
detail_into.pdf (959.2 KB)

Yes the line drawing causes this slow down. I do not understand why yet.

The line drawing seems to be the slow part of your macro. I see you create 161792 TLine.
I tried to reproduce the effect with the following macro. It is slow too (but not as slow as your example). Note that with this example it is also very slow to quit root. Like with your example.

void manytline()
{
   auto l = new TLine();
   for (int i=0; i<161792; i++) {

     l->DrawLine(gRandom->Rndm(1), gRandom->Rndm(2),
                 gRandom->Rndm(3), gRandom->Rndm(4));
   }
}

I tried to group the line drawing in some dedicate class. Like in the following example. It seems to improve the speed:

class ManyLines : public TObject {

public:
   virtual void Paint(Option_t *option="") {
      for (int i = 0; i < 4096; i++) {
         gPad->PaintLine(gRandom->Rndm(1),gRandom->Rndm(2),
                         gRandom->Rndm(3),gRandom->Rndm(4));
      }
   }
};



void manytline()
{
   ManyLines *l = new ManyLines();
   for (int i=0; i<50; i++) {
      printf("%d\n",i);
      l->Draw();
   }
}
1 Like

It shouldn’t slow like that due to the ROOT design philosophy is to deal with big data. By the way, do you have any idea of the style not working after a certain drawing?

I tried again the macro:

void manytline()
{
   auto l = new TLine();
   for (int i=0; i<161792; i++) {

     l->DrawLine(gRandom->Rndm(1), gRandom->Rndm(2),
                 gRandom->Rndm(3), gRandom->Rndm(4));
   }
}

It is actually fast with both root 6 and root 5 on my mac it is just when I type “.q” to exit root that it takes a long time. I see the same with or without option “-b”. I guess it is because of the many TLine to delete… With the encapsulated line drawing exiting is fast.

I have made a new version of your macro avoiding to create that large amount TLine objects using the technique I described before. It is not very fast still. But it is because you open and close the fmsgeo.root file each time you draw.

detail_into2.cpp (4.6 KB)

I confirm that the problem is caused by creating too many TLines. Your idea or technique does improve a lot. I follow your idea to modify my macro of the function void fmsgeo(float) to vector<TLine> fmsgeo(float) which return the lines so that I can use repeatedly by calling once. Thank you.
detail_into.cpp (5.2 KB)

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