forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigurationManager.cxx
More file actions
201 lines (168 loc) · 7.36 KB
/
ConfigurationManager.cxx
File metadata and controls
201 lines (168 loc) · 7.36 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 ConfigurationManager.cxx
/// \author Jeremi Niedziela
///
#include "EventVisualisationBase/ConfigurationManager.h"
#include <fairlogger/Logger.h>
#include <TSystem.h>
using namespace std;
namespace o2
{
namespace event_visualisation
{
ConfigurationManager& ConfigurationManager::getInstance()
{
static ConfigurationManager instance;
return instance;
}
void ConfigurationManager::getConfig(TEnv& settings) const
{
TString fileName;
if (not this->mOptionsFileName.empty() and settings.ReadFile(fileName = this->mOptionsFileName, kEnvUser) >= 0) {
return; // precise located options file name read succesfully
}
if (settings.ReadFile(fileName = ".o2eve_config", kEnvUser) < 0) {
LOGF(warn, "could not find .o2eve_config in working directory! Trying .o2eve_config in home directory");
if (settings.ReadFile(fileName = Form("%s/.o2eve_config", gSystem->Getenv("HOME")), kEnvUser) < 0) {
LOGF(warn, "could not find .o2eve_config in home directory! Trying o2eve_config in home directory");
if (settings.ReadFile(fileName = Form("%s/o2eve_config", gSystem->Getenv("HOME")), kEnvUser) < 0) {
LOGF(warn, "could not find o2eve_config in home directory! Trying o2eve_config in O2/EventVisualisation");
if (settings.ReadFile(fileName = Form("%s/EventVisualisation/o2eve_config",
gSystem->Getenv("ALICEO2_INSTALL_PATH")),
kEnvUser) < 0) {
LOGF(fatal, "could not find .o2eve_config or o2eve_config file!.");
exit(0);
}
}
}
}
LOGF(info, Form("using %s config settings", fileName.Data()));
}
const ConfigurationManager* ConfigurationManager::loadSettings()
{
if (this->mSettingsLoadCounter <= 0) {
this->getConfig(mSettings);
this->mSettingsLoadCounter = mSettings.GetValue("settings.reload", 10000);
}
this->mSettingsLoadCounter--;
return this;
}
UInt_t ConfigurationManager::getRefreshRateInSeconds()
{
return ConfigurationManager::getInstance().loadSettings()->mSettings.GetValue("refresh.rate", 5);
}
UInt_t ConfigurationManager::getOutreachFrequencyInRefreshRates() // 1 means skip one refresh
{
return ConfigurationManager::getInstance().loadSettings()->mSettings.GetValue("outreach.frequency.refresh.rate", 1);
}
std::string ConfigurationManager::getScreenshotPath(const char* prefix)
{
return ConfigurationManager::getInstance().loadSettings()->mSettings.GetValue((std::string(prefix) + ".path").c_str(), "Screenshots");
}
UInt_t ConfigurationManager::getOutreachFilesMax()
{
return ConfigurationManager::getInstance().loadSettings()->mSettings.GetValue("outreach.files.max", 10);
}
UInt_t ConfigurationManager::getScreenshotWidth(const char* prefix)
{
return ConfigurationManager::getInstance().loadSettings()->mSettings.GetValue((std::string(prefix) + ".width").c_str(), 3840);
}
UInt_t ConfigurationManager::getScreenshotHeight(const char* prefix)
{
return ConfigurationManager::getInstance().loadSettings()->mSettings.GetValue((std::string(prefix) + ".height").c_str(), 2160);
}
UInt_t ConfigurationManager::getScreenshotPixelObjectScale3d(const char* prefix)
{
return ConfigurationManager::getInstance().loadSettings()->mSettings.GetValue((std::string(prefix) + ".pixel_object_scale.3d").c_str(), 0);
}
UInt_t ConfigurationManager::getScreenshotPixelObjectScaleRphi(const char* prefix)
{
return ConfigurationManager::getInstance().loadSettings()->mSettings.GetValue((std::string(prefix) + ".pixel_object_scale.rphi").c_str(), 0);
}
UInt_t ConfigurationManager::getScreenshotPixelObjectScaleZY(const char* prefix)
{
return ConfigurationManager::getInstance().loadSettings()->mSettings.GetValue((std::string(prefix) + ".pixel_object_scale.zy").c_str(), 0);
}
bool ConfigurationManager::getScreenshotMonthly()
{
return ConfigurationManager::getInstance().loadSettings()->mSettings.GetValue("screenshot.monthly", 0);
}
std::string ConfigurationManager::getDataDefault()
{
return ConfigurationManager::getInstance().loadSettings()->mSettings.GetValue("data.default", "NEWEST");
}
std::string ConfigurationManager::getDataSyntheticRunDir()
{
return ConfigurationManager::getInstance().loadSettings()->mSettings.GetValue("data.synthetic.run.dir",
"jsons/synthetic");
}
std::string ConfigurationManager::getDataCosmicRunDir()
{
return ConfigurationManager::getInstance().loadSettings()->mSettings.GetValue("data.cosmics.run.dir",
"jsons/cosmics");
}
std::string ConfigurationManager::getDataPhysicsRunDir()
{
return ConfigurationManager::getInstance().loadSettings()->mSettings.GetValue("data.physics.run.dir",
"jsons/physics");
}
std::string ConfigurationManager::getSimpleGeomR3Path()
{
return ConfigurationManager::getInstance().loadSettings()->mSettings.GetValue("simple.geom.R3.path", "");
}
UInt_t ConfigurationManager::getBackgroundColor()
{
return ConfigurationManager::getInstance().loadSettings()->mSettings.GetValue("background.color", 1);
}
bool ConfigurationManager::getAxesShow()
{
return ConfigurationManager::getInstance().loadSettings()->mSettings.GetValue("simple.geom.R3.path", "");
}
bool ConfigurationManager::getFullScreenMode()
{
return ConfigurationManager::getInstance().loadSettings()->mSettings.GetValue("simple.geom.R3.path", "");
}
double ConfigurationManager::getCamera3DRotationHorizontal()
{
return ConfigurationManager::getInstance().loadSettings()->mSettings.GetValue("camera.3D.rotation.horizontal", -0.4);
}
double ConfigurationManager::getCamera3DRotationVertical()
{
return ConfigurationManager::getInstance().loadSettings()->mSettings.GetValue("camera.3D.rotation.vertical", 1.0);
}
double ConfigurationManager::getCamera3DZoom()
{
return ConfigurationManager::getInstance().loadSettings()->mSettings.GetValue("camera.3D.zoom", 1.0);
}
double ConfigurationManager::getCameraRPhiZoom()
{
return ConfigurationManager::getInstance().loadSettings()->mSettings.GetValue("camera.R-Phi.zoom", 1.0);
}
double ConfigurationManager::getCameraZYZoom()
{
return ConfigurationManager::getInstance().loadSettings()->mSettings.GetValue("camera.Z-Y.zoom", 1.0);
}
const char* ConfigurationManager::getScreenshotLogoO2()
{
static std::string str = ConfigurationManager::getInstance().loadSettings()->mSettings.GetValue("screenshot.logo.o2",
"o2.png");
return str.c_str();
}
const char* ConfigurationManager::getScreenshotLogoAlice()
{
static std::string str = ConfigurationManager::getInstance().loadSettings()->mSettings.GetValue(
"screenshot.logo.alice", "alice-white.png");
return str.c_str();
}
} // namespace event_visualisation
} // namespace o2