Visualizing geomentry in a cycle

I want ot visualize my geometry (to show triggered counters) reading the data from the file containing information about several events.

Sow how can I do this in a cycle?
If I write something like this

TGeoBBox *tankbox = new TGeoBBox("tankbox",50,75,50);
 TGeoVolume *tank1=new TGeoVolume("Tank",tankbox);
 TGeoVolume *tank2=new TGeoVolume("Tank",tankbox);
 TGeoVolume *tank3=new TGeoVolume("Tank",tankbox);
 TGeoVolume *tank4=new TGeoVolume("Tank",tankbox);

to separate colors of each tank and then, depending on their energy release

if(ener>50) top->AddNode(tank1,num[i], new TGeoTranslation(x[i]*100,y[i]*100,z[i]*100)); else if(ener>30) top->AddNode(tank2,num[i], new TGeoTranslation(x[i]*100,y[i]*100,z[i]*100)); else if(ener>20) top->AddNode(tank3,num[i], new TGeoTranslation(x[i]*100,y[i]*100,z[i]*100)); else if(ener>10) top->AddNode(tank4,num[i], new TGeoTranslation(x[i]*100,y[i]*100,z[i]*100));
where i is a number of counter and
x[i],y[i],z[i] - its coordinates.

then I should do

and then visualize

but this won’t work if I do this in cycle: I obtain an empty pad :frowning:

During executing i have the following:

while usually I have 840 nodes :unamused:

Send me the macro…

Attaching here
geom.C (11 KB)

I guess you want to do this several times for several events. Your macro should work for only one event - does it? I cannot test since it uses private input data. Which of the 4 pads gets empty ?


It does not work even for the first event.
2 pads where the geometry should be drawn (pad1 & pad2) are empty.
For the 2 used files you can place just several lines like these:

In “coordinate” file

1111 0 0 0 1112 0 0 1.5

In “event” file

0 1111 10.0 0 1112 5.0 0 -1 -1 1 1111 12.0 1 -1 -1

Sorry for the delay…

I do not fully understand your logic, but here is a version of your macro that works.

geom.C (7.03 KB)

Thank you. Although the code you’ve inserted in is not necessary I’ve found the mistake.

I’ve been initializing the gGeoManager reading every line in the file but I should have initialized it when I summarize the event.
(“That was the strange logics”).
Now it works.