Dear @agheata The function is intended to create an air-filled box by placing an inner air volume inside an outer box volume. This outer box is then added to a volume assembly, which is subsequently placed in the top volume. When I visualize the full geometry from the top volume or the assembly, all components are correctly displayed. However, when I try to visualize the outer volume node directly, only the inner (daughter) volume is visible, while the outer (mother) volume itself is not shown.
In all volumes, I have explicitly set the SetVisContainers(true)
function.
TGeoVolume *CreateHollowBar(const char *name, double length, double width,
double height, double delta_w, double delta_h) {
// Create the inner box (air) to be placed inside
TGeoBBox *innerBox =
new TGeoBBox((std::string("InnerBox_") + name).c_str(), length - 0.1,
width - delta_w, height - delta_h);
TGeoVolume *innerVolume = new TGeoVolume(
(std::string("InnerAirVolume_") + name).c_str(), innerBox, airVolMed);
innerVolume->SetLineColor(kBlue);
innerVolume->SetTransparency(50);
// Create the outer solid box (aluminium)
TGeoBBox *outerBox = new TGeoBBox((std::string("OuterBox_") + name).c_str(),
length, width, height);
TGeoVolume *outerVolume =
new TGeoVolume((std::string("OuterBarVolume_") + name).c_str(), outerBox,
aluminiumVolMed);
outerVolume->SetLineColor(kRed);
outerVolume->SetVisContainers(kTRUE);
outerVolume->AddNode(innerVolume, 1, new TGeoTranslation(0, 0, 0));
return outerVolume;
}
Hi, if you also want to see the top volume that you are drawing, you have to call:
gGeoManager->SetTopVisible();
which is by default off
Let me try to explain a bit more clearly
(attached layout of the Geomtery):
The top volume in my geometry is different—OuterBarVolume
is not the top volume. The overall geometry layout starts with the top volume trd_v24c_1m
, which contains several layers, each defined as a TGeoVolumeAssembly
. These layers, in turn, include other assemblies. For example, one such assembly is tragwerk_block_left
, which includes the OuterBarVolume
created in the function I mentioned earlier.
This OuterBarVolume
includes a nested volume called InnerAirVolume
, which represents the air-filled inner region. When I draw the full geometry starting from the top volume, all volumes are visualized correctly. However, when I try to draw the OuterBarVolume
explicitly on its own, I only see the inner air-filled volume (InnerAirVolume
), while the outer box filled with aluminum (the mother volume) is not visible.
I understood correctly. When you draw a volume, it becomes the current top volume, and this can be different than the geometry ‘master’ volume, which is the one you must provide the first time you call TGeoManager::SetTopVolume
. In your case, the master volume is trdv24c_1m
, and when you draw this one directly, you see all volumes. However, if you call for any other volume: volume->Draw()
, vol
becomes the top volume and is by default NOT displayed, even if marked visible
unless you call gGeoManager->SetTopVisible()
before. SetTopVisible will be ignored if the volume you draw does not have the visibility flag set or is an assembly.
So in your case:
gGeoManager->SetTopVisible();
gGeoManager->GetVolume("OuterBarVolume")->SetVisibility(true);
gGeoManager->GetVolume("OuterBarVolume")->Draw();
Thank you for the response. The visualization works when using a macro and enabling drawing at runtime. However, I would like to visualize it directly from the generated ROOT file using TBrowser.