Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
web_cms.cxx
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_webgui
3/// Web-based geometry viewer for CMS geometry
4///
5/// \macro_code
6///
7/// \author Sergey Linev
8
10
11#include "TGeoManager.h"
12#include "TGeoVolume.h"
13#include "TFile.h"
14
15void web_cms(bool split = false)
16{
18
19 TGeoManager::Import("https://root.cern/files/cms.root");
20
21 gGeoManager->DefaultColors();
22 gGeoManager->SetVisLevel(4);
23 gGeoManager->GetVolume("TRAK")->InvisibleAll();
24 gGeoManager->GetVolume("HVP2")->SetTransparency(20);
25 gGeoManager->GetVolume("HVEQ")->SetTransparency(20);
26 gGeoManager->GetVolume("YE4")->SetTransparency(10);
27 gGeoManager->GetVolume("YE3")->SetTransparency(20);
28 gGeoManager->GetVolume("RB2")->SetTransparency(99);
29 gGeoManager->GetVolume("RB3")->SetTransparency(99);
30 gGeoManager->GetVolume("COCF")->SetTransparency(99);
31 gGeoManager->GetVolume("HEC1")->SetLineColor(7);
32 gGeoManager->GetVolume("EAP1")->SetLineColor(7);
33 gGeoManager->GetVolume("EAP2")->SetLineColor(7);
34 gGeoManager->GetVolume("EAP3")->SetLineColor(7);
35 gGeoManager->GetVolume("EAP4")->SetLineColor(7);
36 gGeoManager->GetVolume("HTC1")->SetLineColor(2);
37
38 auto viewer = std::make_shared<ROOT::RGeomViewer>(gGeoManager);
39
40 // select volume to draw
41 viewer->SelectVolume("CMSE");
42
43 // specify JSROOT draw options - here clipping on X,Y,Z axes
44 viewer->SetDrawOptions("clipxyz");
45
46 // set default limits for number of visible nodes and faces
47 // when viewer created, initial values exported from TGeoManager
48 viewer->SetLimits();
49
50 viewer->SetShowHierarchy(!split);
51
52 // start web browser
53 viewer->Show();
54
55 // destroy viewer only when connection to client is closed
56 viewer->ClearOnClose(viewer);
57
58 if (split) {
59 // create separate widget with geometry hierarchy only
60 auto hier = std::make_shared<ROOT::RGeomHierarchy>(viewer->Description());
61
62 // start web browser with hierarchy
63 hier->Show();
64
65 // destroy widget only when connection to client is closed
66 hier->ClearOnClose(hier);
67 }
68}
externTGeoManager * gGeoManager
static Bool_t SetCacheFileDir(std::string_view cacheDir, Bool_t operateDisconnected=kTRUE, Bool_t forceCacheread=kFALSE)
Sets the directory where to locally stage/cache remote files.
Definition TFile.cxx:4328
static TGeoManager * Import(const char *filename, const char *name="", Option_t *option="")
static function Import a geometry from a gdml or ROOT file