-
Notifications
You must be signed in to change notification settings - Fork 496
Expand file tree
/
Copy pathGeometryManager.cxx
More file actions
121 lines (102 loc) · 3.88 KB
/
GeometryManager.cxx
File metadata and controls
121 lines (102 loc) · 3.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
// 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 GeometryManager.cxx
/// \author Jeremi Niedziela
/// \author Julian Myrcha
#include "EventVisualisationBase/GeometryManager.h"
#include "EventVisualisationBase/ConfigurationManager.h"
#include <fairlogger/Logger.h>
#include <TFile.h>
#include <TGLViewer.h>
#include <TEveGeoShapeExtract.h>
#include <TEveManager.h>
#include <TEveProjectionManager.h>
#include <TSystem.h>
using namespace std;
namespace o2
{
namespace event_visualisation
{
GeometryManager& GeometryManager::getInstance()
{
static GeometryManager instance;
return instance;
}
TEveGeoShape* GeometryManager::getGeometryForDetector(string detectorName)
{
// read geometry path from config file
string geomPath = ConfigurationManager::getSimpleGeomR3Path();
// load ROOT file with geometry
TFile* f = TFile::Open(Form("%s/simple_geom_%s.root", geomPath.c_str(), detectorName.c_str()));
if (!f) {
LOGF(error, "GeometryManager::GetSimpleGeom -- no file with geometry found for: ", detectorName, "!");
return nullptr;
}
LOGF(info, "GeometryManager::GetSimpleGeom for: ", detectorName, " from ",
Form("%s/simple_geom_%s.root", geomPath.c_str(), detectorName.c_str()));
auto geomShapreExtract = dynamic_cast<TEveGeoShapeExtract*>(f->Get(detectorName.c_str()));
TEveGeoShape* geomShape = TEveGeoShape::ImportShapeExtract(geomShapreExtract);
f->Close();
geomShape->SetName(detectorName.c_str());
// prepare geometry to be drawn including all children
drawDeep(geomShape,
ConfigurationManager::getInstance().getSettings().GetValue(Form("%s.color", detectorName.c_str()), -1),
ConfigurationManager::getInstance().getSettings().GetValue(Form("%s.trans", detectorName.c_str()), -1),
ConfigurationManager::getInstance().getSettings().GetValue(Form("%s.line.color", detectorName.c_str()), -1));
gEve->GetDefaultGLViewer()->UpdateScene();
return geomShape;
}
void GeometryManager::drawDeep(TEveGeoShape* geomShape, Color_t color, Char_t transparency, Color_t lineColor)
{
if (geomShape->HasChildren()) {
geomShape->SetRnrSelf(false);
if (strcmp(geomShape->GetElementName(), "TPC_Drift_1") == 0) { // hack for TPC drift chamber
geomShape->SetRnrSelf(kTRUE);
if (color >= 0) {
geomShape->SetMainColor(color);
}
if (lineColor >= 0) {
geomShape->SetLineColor(lineColor);
geomShape->SetLineWidth(1); // 0.1
geomShape->SetDrawFrame(true);
} else {
geomShape->SetDrawFrame(false);
}
if (transparency >= 0) {
geomShape->SetMainTransparency(transparency);
}
}
for (TEveElement::List_i i = geomShape->BeginChildren(); i != geomShape->EndChildren(); ++i) {
drawDeep(static_cast<TEveGeoShape*>(*i), color, transparency, lineColor);
}
} else {
geomShape->SetRnrSelf(true);
if (color >= 0) {
geomShape->SetMainColor(color);
}
if (lineColor >= 0) {
geomShape->SetLineColor(lineColor);
geomShape->SetLineWidth(1); // 0.1
geomShape->SetDrawFrame(true);
} else {
geomShape->SetDrawFrame(false);
}
if (transparency >= 0) {
geomShape->SetMainTransparency(transparency);
}
if (strcmp(geomShape->GetElementName(), "PHOS_5") == 0) { // hack for PHOS module which is not installed
geomShape->SetRnrSelf(false);
}
}
}
} // namespace event_visualisation
} // namespace o2