SetVisible geometry in JSROOT

Dear ROOTers,
I would like to display the geometry of the detector with JSROOT. The problem is that some of the detectors are not visible. I figured out that such objects have “emtpy checkbox” in TBrowser, however I can’t change this visiblity. I tried something like topNode->GetDaughter()->SetVisibility(kTRUE) but after opening new file (with changed geoemtry) in TBrowser such object still is not visible (have empty checkbox).
I suppose that solution is simple but I cannot find it.

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Hi,

JSROOT requires that visibility flag is set already in ROOT file - this is most easy way.
Normally one does: gGeoMaganager->GetVolume("name")->SetVisibility(kTRUE);
If it does not help - can you provide reproducer macro?

Regards,
Sergey

Hi,
I tried something like this:

void FixDaughter(TGeoNodeMatrix* mother) {
  for (int i = 0; i < mother->GetNdaughters(); i++) {
    mother->GetDaughter(i)->SetVisibility(1);
    TGeoNode* dau = mother->GetDaughter(i);
    cout << dau << " " << dau->GetVolume() << endl;
    dau->SetVisibility(1);
    dau->GetVolume()->SetVisibility(1);
  }
}
void fix() {
  TFile* f          = new TFile("geom3.root");
  TGeoNodeMatrix* x = (TGeoNodeMatrix*) f->Get("cave_1");
  FixDaughter(x);
  TFile* f2 = new TFile("fixed.root", "recreate");
  x->Write();
  f2->Write();
}

However my code crash when calll

dau->GetVolume()->SetVisibility(1);

I’ve error like TGeoManager::IsClosed (this=0x0) at /opt/FairGroup/FairSoft_19/tools/root/build_for_fair/include/TGeoManager.h:283

Can you attach geom3.root file that I can reproduce problem?

I’m sending compressed version. I used event display and tried in event display do:

    mother->GetDaughter(i)->SetVisibility(kTRUE);
    mother->GetDaughter(i)->GetVolume()->SetVisStreamed(kTRUE);
    mother->GetDaughter(i)->SetVisStreamed(kTRUE);
    mother->GetDaughter(i)->GetVolume()->SetVisibility(kTRUE);
    mother->GetDaughter(i)->GetVolume()->SetAttVisibility(kTRUE);
    mother->GetDaughter(i)->SetVisDaughters(kTRUE);
    mother->GetDaughter(i)->GetVolume()->SetVisDaughters(kTRUE);

However exported files (via mother->Write()) are still not visible.
Edit: I created function for save geometry in Event Display, I see in “Geometry scene” that those functions make visible node but not the volume.
geom3.root.zip (2,6 MB)

Hi,

First of all, your macro does not work for me.
Problem that you tries to store part of geometry without TGeoManager - in many cases it does not work correctly.

But I can understand your problem now. It is kVisOnScreen bit which is assigned for very few volumes in geometry. JSROOT search first for such bits and if found displays only these volumes.

There is “no_screen” draw option for geometry which let ignore these bits. In your case:

https://jsroot.gsi.de/dev/?file=../files/tmp/geom3.root&item=cave_1&opt=no_screen;black

Or you can clear these bits already before storing TGeoManager to the file:

gGeoManager->GetPainter()->ClearVisibleVolumes();
gGeoManager->Export("file.root");

Regards,
Sergey

Just small remark:

“no_screen” option exists since a while in JSROOT, in “dev” version I just add it to default context menu that it can be easily used in interactive mode. I also add possibility to easily expand TGeoNodeMatrix object which you store in the file.

But again - I recommend to store TGeoManager object

Hi,
There are two problems:

  1. as far as I can see ClearVisibleVolumes is protected
  2. I look at your examples and still - some detectors are not visible

Hi,

as far as I can see ClearVisibleVolumes is protected

Sorry, oversees it. Then just call gGeoManager->SetVisLevel(4);, it automatically should remove visibility bits as well.

I look at your examples and still - some detectors are not visible

Either visibility is not set or there are too many volumes and JSROOT cuts drawing of so many elements. You can try to add “all” to draw options like opt=no_screen;black;all

Hi,
it seems to not help, I also tried geoManager->ClearAttributes() but still thes objects have some flag “not visible” also in event display I cannot change property “VisVolume”. I think it’s fixed somewhere in EventDiplay because when I try to change visibility of these volumes I get warning “Info in TGeoManager::SetVisLevel: Automatic visible depth disabled”.

Please try to draw geometry before calling SetVisLevel.
Only then painter object is created, it can reset visibility bits.
Or you can apply attached macro - reset_vis.C (327 Bytes)

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