forked from mcoquet642/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInitializer.cxx
More file actions
201 lines (161 loc) · 6.88 KB
/
Initializer.cxx
File metadata and controls
201 lines (161 loc) · 6.88 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
196
197
198
199
200
201
// 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 "EventVisualisationBase/GeometryManager.h"
#include "EventVisualisationView/EventManager.h"
#include "EventVisualisationView/MultiView.h"
#include "EventVisualisationBase/VisualisationConstants.h"
#include "EventVisualisationBase/DataSourceOffline.h"
#include "EventVisualisationView/EventManagerFrame.h"
#include "EventVisualisationView/Options.h"
#include "EventVisualisationDetectors/DataInterpreterITS.h"
#include "EventVisualisationDetectors/DataReaderITS.h"
#include "EventVisualisationDetectors/DataInterpreterTPC.h"
#include "EventVisualisationDetectors/DataReaderTPC.h"
#include "EventVisualisationDetectors/DataReaderJSON.h"
#include "FairLogger.h"
#include <TGTab.h>
#include <TEnv.h>
#include <TEveBrowser.h>
#include <TEveManager.h>
#include <TRegexp.h>
#include <TSystem.h>
#include <TEveWindowManager.h>
using namespace std;
namespace o2
{
namespace event_visualisation
{
void Initializer::setup(EventManager::EDataSource defaultDataSource)
{
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", "local://$ALICE_ROOT/OCDB"); // default path to OCDB
LOG(INFO) << "Initializer -- OCDB path:" << ocdbStorage;
auto& eventManager = EventManager::getInstance();
eventManager.setCdbPath(ocdbStorage);
eventManager.setDataSourceType(defaultDataSource);
eventManager.Open();
if (Options::Instance()->tpc()) {
eventManager.getDataSource()->registerDetector(new DataReaderTPC(new DataInterpreterTPC()), EVisualisationGroup::TPC);
}
if (Options::Instance()->its()) {
eventManager.getDataSource()->registerDetector(new DataReaderITS(new DataInterpreterITS()), EVisualisationGroup::ITS);
}
if (Options::Instance()->json()) {
eventManager.getDataSource()->registerDetector(new DataReaderJSON(nullptr), EVisualisationGroup::JSON);
}
GeometryManager::getInstance().setR2Geometry(std::string(settings.GetValue("simple.geom.default", "R3")).compare("R2") == 0);
setupGeometry();
gSystem->ProcessEvents();
gEve->Redraw3D(true);
setupBackground();
// Setup windows size, fullscreen and focus
TEveBrowser* browser = gEve->GetBrowser();
browser->GetTabRight()->SetTab(1);
browser->MoveResize(0, 0, gClient->GetDisplayWidth(), gClient->GetDisplayHeight() - 32);
browser->StartEmbedding(TRootBrowser::kBottom);
EventManagerFrame* frame = new EventManagerFrame(eventManager);
browser->StopEmbedding("EventCtrl Balbinka");
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:
// For the time being we draw single random event on startup.
// Later this will be triggered by button, and finally moved to configuration.
gEve->AddEvent(&EventManager::getInstance());
eventManager.getDataSource()->refresh();
frame->DoFirstEvent();
frame->StartTimer();
}
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 (GeometryManager::getInstance().getR2Geometry()) {
if (!R2Visualisation[iDet]) {
continue;
}
}
if (!GeometryManager::getInstance().getR2Geometry()) {
if (!R3Visualisation[iDet]) {
continue;
}
}
EVisualisationGroup det = static_cast<EVisualisationGroup>(iDet);
string detName = gVisualisationGroupName[det];
LOG(INFO) << detName;
if (settings.GetValue((detName + ".draw").c_str(), false)) {
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 { // default
if (detName != "ACO") {
multiView->drawGeometryForDetector(detName);
}
}
}
}
}
void Initializer::setupCamera()
{
// move and rotate sub-views
TEnv settings;
ConfigurationManager::getInstance().getConfig(settings);
// read settings from config file
const double angleHorizontal = settings.GetValue("camera.3D.rotation.horizontal", -0.4);
const double angleVertical = settings.GetValue("camera.3D.rotation.vertical", 1.0);
double zoom[MultiView::NumberOfViews];
zoom[MultiView::View3d] = settings.GetValue("camera.3D.zoom", 1.0);
zoom[MultiView::ViewRphi] = settings.GetValue("camera.R-Phi.zoom", 1.0);
zoom[MultiView::ViewZrho] = settings.GetValue("camera.Rho-Z.zoom", 1.0);
// 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