-
Notifications
You must be signed in to change notification settings - Fork 496
Expand file tree
/
Copy pathInitializer.cxx
More file actions
195 lines (160 loc) · 6.87 KB
/
Initializer.cxx
File metadata and controls
195 lines (160 loc) · 6.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
///
/// \file Initializer.cxx
/// \author Jeremi Niedziela
/// \author julian.myrcha@cern.ch
/// \author p.nowakowski@cern.ch
///
#include "EventVisualisationView/Initializer.h"
#include "EventVisualisationBase/ConfigurationManager.h"
#include "EventVisualisationView/EventManager.h"
#include "EventVisualisationView/MultiView.h"
#include "EventVisualisationDataConverter/VisualisationConstants.h"
#include "EventVisualisationView/EventManagerFrame.h"
#include "EventVisualisationView/Options.h"
#include "EventVisualisationDetectors/DataReaderJSON.h"
#include "EventVisualisationBase/DataSourceOnline.h"
#include "EventVisualisationBase/DataSourceOffline.h"
#include <fairlogger/Logger.h>
#include <TGTab.h>
#include <TEnv.h>
#include <TEveBrowser.h>
#include <TEveManager.h>
#include <TRegexp.h>
#include <TSystem.h>
#include <TApplication.h>
#include <TEveWindowManager.h>
using namespace std;
namespace o2
{
namespace event_visualisation
{
void Initializer::setup()
{
TEnv settings;
ConfigurationManager::getInstance().getConfig(settings);
const bool fullscreen = settings.GetValue("fullscreen.mode",
false); // hide left and bottom tabs
const string ocdbStorage = settings.GetValue("OCDB.default.path",
o2::base::NameConf::getCCDBServer().c_str()); // default path to OCDB
LOGF(info, "Initializer -- OCDB path:", ocdbStorage);
auto& eventManager = EventManager::getInstance();
eventManager.setCdbPath(ocdbStorage);
auto const options = Options::Instance();
EventManagerFrame::RunMode runMode = EventManagerFrame::decipherRunMode(ConfigurationManager::getDataDefault());
if (options->json()) {
runMode = EventManagerFrame::decipherRunMode(options->dataFolder(), runMode);
eventManager.setDataSource(
new DataSourceOnline(EventManagerFrame::getSourceDirectory(runMode, EventManagerFrame::OnlineMode)));
} else {
eventManager.setDataSource(
new DataSourceOffline(options->AODConverterPath(), options->dataFolder(), options->fileName(),
options->hideDplGUI()));
}
eventManager.getDataSource()->registerReader(new DataReaderJSON());
setupGeometry();
gSystem->ProcessEvents();
gEve->Redraw3D(true);
setupBackground();
// Setup windows size, fullscreen and focus
TEveBrowser* browser = gEve->GetBrowser();
std::string title = std::string("o2-eve version:") + std::to_string(o2_eve_version / 100.0);
title = title.substr(0, title.find('.') + 3);
browser->SetWindowName(title.c_str());
browser->GetTabRight()->SetTab(1);
browser->MoveResize(0, 0, gClient->GetDisplayWidth(), gClient->GetDisplayHeight() - 32);
browser->StartEmbedding(TRootBrowser::kBottom);
EventManagerFrame* frame = new EventManagerFrame(eventManager);
frame->setRunMode(runMode);
browser->StopEmbedding("EventCtrl");
if (fullscreen) {
((TGWindow*)gEve->GetBrowser()->GetTabLeft()->GetParent())->Resize(1, 0);
((TGWindow*)gEve->GetBrowser()->GetTabBottom()->GetParent())->Resize(0, 1);
}
gEve->GetBrowser()->Layout();
gSystem->ProcessEvents();
setupCamera();
// Temporary:
// Later this will be triggered by button, and finally moved to configuration.
gEve->AddEvent(&EventManager::getInstance());
if (Options::Instance()->online()) {
frame->StartTimer();
} else {
eventManager.getDataSource()->refresh();
frame->DoFirstEvent();
}
gApplication->Connect("TEveBrowser", "CloseWindow()", "o2::event_visualisation::EventManagerFrame", frame,
"DoTerminate()");
}
void Initializer::setupGeometry()
{
// read path to geometry files from config file
TEnv settings;
ConfigurationManager::getInstance().getConfig(settings);
// get geometry from Geometry Manager and register in multiview
auto multiView = MultiView::getInstance();
// auto geometry_enabled = GeometryManager::getInstance().getR2Geometry()? R2Visualisation:R3Visualisation;
for (int iDet = 0; iDet < NvisualisationGroups; ++iDet) {
if (!R3Visualisation[iDet]) {
continue;
}
EVisualisationGroup det = static_cast<EVisualisationGroup>(iDet);
string detName = gVisualisationGroupName[det];
LOGF(info, detName);
if (detName == "TPC" || detName == "MCH" || detName == "MID" ||
detName == "MFT") { // don't load MUON+MFT and AD and standard TPC to R-Phi view
multiView->drawGeometryForDetector(detName, true, false);
} else if (detName == "RPH") { // special TPC geom from R-Phi view
multiView->drawGeometryForDetector(detName, false, true, false);
} else if (detName != "TST") { // default
multiView->drawGeometryForDetector(detName);
}
const auto geom = multiView->getDetectorGeometry(detName);
const auto show = settings.GetValue((detName + ".draw").c_str(), false);
if (geom != nullptr) {
geom->SetRnrSelfChildren(show, show);
}
}
}
void Initializer::setupCamera()
{
// move and rotate sub-views
const double angleHorizontal = ConfigurationManager::getCamera3DRotationHorizontal();
const double angleVertical = ConfigurationManager::getCamera3DRotationVertical();
double zoom[MultiView::NumberOfViews];
zoom[MultiView::View3d] = ConfigurationManager::getCamera3DZoom();
zoom[MultiView::ViewRphi] = ConfigurationManager::getCameraRPhiZoom();
zoom[MultiView::ViewZY] = ConfigurationManager::getCameraZYZoom();
// get necessary elements of the multiview and set camera position
auto multiView = MultiView::getInstance();
for (int viewIter = 0; viewIter < MultiView::NumberOfViews; ++viewIter) {
TGLViewer* glView = multiView->getView(static_cast<MultiView::EViews>(viewIter))->GetGLViewer();
glView->CurrentCamera().Reset();
if (viewIter == 0) {
glView->CurrentCamera().RotateRad(angleHorizontal, angleVertical);
}
glView->CurrentCamera().Dolly(zoom[viewIter], kFALSE, kTRUE);
}
}
void Initializer::setupBackground()
{
// get viewers of multiview and change color to the value from config file
TEnv settings;
ConfigurationManager::getInstance().getConfig(settings);
Color_t col = settings.GetValue("background.color", 1);
for (int viewIter = 0; viewIter < MultiView::NumberOfViews; ++viewIter) {
TEveViewer* view = MultiView::getInstance()->getView(static_cast<MultiView::EViews>(viewIter));
view->GetGLViewer()->SetClearColor(col);
}
}
} // namespace event_visualisation
} // namespace o2