Project
Loading...
Searching...
No Matches
Initializer.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
18
20
30
31#include <fairlogger/Logger.h>
32#include <TGTab.h>
33#include <TEnv.h>
34#include <TEveBrowser.h>
35#include <TEveManager.h>
36#include <TRegexp.h>
37#include <TSystem.h>
38#include <TApplication.h>
39#include <TEveWindowManager.h>
40
41using namespace std;
42
43namespace o2
44{
45namespace event_visualisation
46{
47
49{
50 TEnv settings;
52
53 const bool fullscreen = settings.GetValue("fullscreen.mode",
54 false); // hide left and bottom tabs
55 const string ocdbStorage = settings.GetValue("OCDB.default.path",
56 o2::base::NameConf::getCCDBServer().c_str()); // default path to OCDB
57 LOGF(info, "Initializer -- OCDB path:", ocdbStorage);
58
59 auto& eventManager = EventManager::getInstance();
60 eventManager.setCdbPath(ocdbStorage);
61
62 auto const options = Options::Instance();
63
65
66 if (options->json()) {
67 runMode = EventManagerFrame::decipherRunMode(options->dataFolder(), runMode);
68 eventManager.setDataSource(
70 } else {
71 eventManager.setDataSource(
72 new DataSourceOffline(options->AODConverterPath(), options->dataFolder(), options->fileName(),
73 options->hideDplGUI()));
74 }
75
76 eventManager.getDataSource()->registerReader(new DataReaderJSON());
77
78 setupGeometry();
79 gSystem->ProcessEvents();
80 gEve->Redraw3D(true);
81
82 setupBackground();
83
84 // Setup windows size, fullscreen and focus
85 TEveBrowser* browser = gEve->GetBrowser();
86 std::string title = std::string("o2-eve version:") + std::to_string(o2_eve_version / 100.0);
87 title = title.substr(0, title.find('.') + 3);
88 browser->SetWindowName(title.c_str());
89 browser->GetTabRight()->SetTab(1);
90 browser->MoveResize(0, 0, gClient->GetDisplayWidth(), gClient->GetDisplayHeight() - 32);
91
92 browser->StartEmbedding(TRootBrowser::kBottom);
93 EventManagerFrame* frame = new EventManagerFrame(eventManager);
94 frame->setRunMode(runMode);
95 browser->StopEmbedding("EventCtrl");
96
97 if (fullscreen) {
98 ((TGWindow*)gEve->GetBrowser()->GetTabLeft()->GetParent())->Resize(1, 0);
99 ((TGWindow*)gEve->GetBrowser()->GetTabBottom()->GetParent())->Resize(0, 1);
100 }
101 gEve->GetBrowser()->Layout();
102 gSystem->ProcessEvents();
103
104 setupCamera();
105
106 // Temporary:
107 // Later this will be triggered by button, and finally moved to configuration.
108 gEve->AddEvent(&EventManager::getInstance());
109
110 if (Options::Instance()->online()) {
111 frame->StartTimer();
112 } else {
113 eventManager.getDataSource()->refresh();
114 frame->DoFirstEvent();
115 }
116 gApplication->Connect("TEveBrowser", "CloseWindow()", "o2::event_visualisation::EventManagerFrame", frame,
117 "DoTerminate()");
118}
119
120void Initializer::setupGeometry()
121{
122 // read path to geometry files from config file
123 TEnv settings;
125
126 // get geometry from Geometry Manager and register in multiview
127 auto multiView = MultiView::getInstance();
128
129 // auto geometry_enabled = GeometryManager::getInstance().getR2Geometry()? R2Visualisation:R3Visualisation;
130 for (int iDet = 0; iDet < NvisualisationGroups; ++iDet) {
131 if (!R3Visualisation[iDet]) {
132 continue;
133 }
134 EVisualisationGroup det = static_cast<EVisualisationGroup>(iDet);
135 string detName = gVisualisationGroupName[det];
136 LOGF(info, detName);
137
138 if (detName == "TPC" || detName == "MCH" || detName == "MID" ||
139 detName == "MFT") { // don't load MUON+MFT and AD and standard TPC to R-Phi view
140 multiView->drawGeometryForDetector(detName, true, false);
141 } else if (detName == "RPH") { // special TPC geom from R-Phi view
142 multiView->drawGeometryForDetector(detName, false, true, false);
143 } else if (detName != "TST") { // default
144 multiView->drawGeometryForDetector(detName);
145 }
146
147 const auto geom = multiView->getDetectorGeometry(detName);
148 const auto show = settings.GetValue((detName + ".draw").c_str(), false);
149
150 if (geom != nullptr) {
151 geom->SetRnrSelfChildren(show, show);
152 }
153 }
154}
155
156void Initializer::setupCamera()
157{
158 // move and rotate sub-views
159 const double angleHorizontal = ConfigurationManager::getCamera3DRotationHorizontal();
160 const double angleVertical = ConfigurationManager::getCamera3DRotationVertical();
161
162 double zoom[MultiView::NumberOfViews];
166
167 // get necessary elements of the multiview and set camera position
168 auto multiView = MultiView::getInstance();
169
170 for (int viewIter = 0; viewIter < MultiView::NumberOfViews; ++viewIter) {
171 TGLViewer* glView = multiView->getView(static_cast<MultiView::EViews>(viewIter))->GetGLViewer();
172 glView->CurrentCamera().Reset();
173
174 if (viewIter == 0) {
175 glView->CurrentCamera().RotateRad(angleHorizontal, angleVertical);
176 }
177 glView->CurrentCamera().Dolly(zoom[viewIter], kFALSE, kTRUE);
178 }
179}
180
181void Initializer::setupBackground()
182{
183 // get viewers of multiview and change color to the value from config file
184 TEnv settings;
186 Color_t col = settings.GetValue("background.color", 1);
187
188 for (int viewIter = 0; viewIter < MultiView::NumberOfViews; ++viewIter) {
189 TEveViewer* view = MultiView::getInstance()->getView(static_cast<MultiView::EViews>(viewIter));
190 view->GetGLViewer()->SetClearColor(col);
191 }
192}
193
194} // namespace event_visualisation
195} // namespace o2
Grouping reading from file(s)
Grouping reading from file(s)
GUI (bottom buttons) for visualisation.
int16_t Color_t
Definition GPUQA.h:32
uint32_t col
Definition RawData.h:4
static std::string getCCDBServer()
Definition NameConf.cxx:110
static ConfigurationManager & getInstance()
Returns an instance of ConfigurationManager.
void getConfig(TEnv &settings) const
Returns current event display configuration.
static std::vector< std::string > getSourceDirectory(EventManagerFrame::RunMode runMode, EventManagerFrame::DisplayMode displayMode)
void setRunMode(EventManagerFrame::RunMode runMode)
static RunMode decipherRunMode(TString name, RunMode defaultRun=SyntheticRun)
static EventManager & getInstance()
Returns an instance of EventManager.
static void setup()
Default constructor.
static MultiView * getInstance()
Returns an instance of the MultiView.
TEveViewer * getView(EViews view)
Returns pointer to specific view.
Definition MultiView.h:70
@ NumberOfViews
Total number of views.
Definition MultiView.h:48
std::string show(const DeliveryType type)
const bool R3Visualisation[NvisualisationGroups]
const std::string gVisualisationGroupName[NvisualisationGroups]
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Defining DataPointCompositeObject explicitly as copiable.
std::string to_string(gsl::span< T, Size > span)
Definition common.h:52