Project
Loading...
Searching...
No Matches
GeometryManager.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
16
19#include <fairlogger/Logger.h>
20
21#include <TFile.h>
22#include <TGLViewer.h>
23#include <TEveGeoShapeExtract.h>
24#include <TEveManager.h>
25#include <TEveProjectionManager.h>
26#include <TSystem.h>
27
28using namespace std;
29
30namespace o2
31{
32namespace event_visualisation
33{
34
36{
37 static GeometryManager instance;
38 return instance;
39}
40
41TEveGeoShape* GeometryManager::getGeometryForDetector(string detectorName)
42{
43
44 // read geometry path from config file
46
47 // load ROOT file with geometry
48 TFile* f = TFile::Open(Form("%s/simple_geom_%s.root", geomPath.c_str(), detectorName.c_str()));
49 if (!f) {
50 LOGF(error, "GeometryManager::GetSimpleGeom -- no file with geometry found for: ", detectorName, "!");
51 return nullptr;
52 }
53 LOGF(info, "GeometryManager::GetSimpleGeom for: ", detectorName, " from ",
54 Form("%s/simple_geom_%s.root", geomPath.c_str(), detectorName.c_str()));
55
56 auto geomShapreExtract = dynamic_cast<TEveGeoShapeExtract*>(f->Get(detectorName.c_str()));
57 TEveGeoShape* geomShape = TEveGeoShape::ImportShapeExtract(geomShapreExtract);
58 f->Close();
59
60 geomShape->SetName(detectorName.c_str());
61
62 // prepare geometry to be drawn including all children
63 drawDeep(geomShape,
64 ConfigurationManager::getInstance().getSettings().GetValue(Form("%s.color", detectorName.c_str()), -1),
65 ConfigurationManager::getInstance().getSettings().GetValue(Form("%s.trans", detectorName.c_str()), -1),
66 ConfigurationManager::getInstance().getSettings().GetValue(Form("%s.line.color", detectorName.c_str()), -1));
67
68 gEve->GetDefaultGLViewer()->UpdateScene();
69
70 return geomShape;
71}
72
73void GeometryManager::drawDeep(TEveGeoShape* geomShape, Color_t color, Char_t transparency, Color_t lineColor)
74{
75 if (geomShape->HasChildren()) {
76 geomShape->SetRnrSelf(false);
77
78 if (strcmp(geomShape->GetElementName(), "TPC_Drift_1") == 0) { // hack for TPC drift chamber
79 geomShape->SetRnrSelf(kTRUE);
80 if (color >= 0) {
81 geomShape->SetMainColor(color);
82 }
83 if (lineColor >= 0) {
84 geomShape->SetLineColor(lineColor);
85 geomShape->SetLineWidth(1); // 0.1
86 geomShape->SetDrawFrame(true);
87 } else {
88 geomShape->SetDrawFrame(false);
89 }
90 if (transparency >= 0) {
91 geomShape->SetMainTransparency(transparency);
92 }
93 }
94
95 for (TEveElement::List_i i = geomShape->BeginChildren(); i != geomShape->EndChildren(); ++i) {
96 drawDeep(static_cast<TEveGeoShape*>(*i), color, transparency, lineColor);
97 }
98 } else {
99 geomShape->SetRnrSelf(true);
100 if (color >= 0) {
101 geomShape->SetMainColor(color);
102 }
103 if (lineColor >= 0) {
104 geomShape->SetLineColor(lineColor);
105 geomShape->SetLineWidth(1); // 0.1
106 geomShape->SetDrawFrame(true);
107 } else {
108 geomShape->SetDrawFrame(false);
109 }
110 if (transparency >= 0) {
111 geomShape->SetMainTransparency(transparency);
112 }
113
114 if (strcmp(geomShape->GetElementName(), "PHOS_5") == 0) { // hack for PHOS module which is not installed
115 geomShape->SetRnrSelf(false);
116 }
117 }
118}
119
120} // namespace event_visualisation
121} // namespace o2
int32_t i
int16_t Color_t
Definition GPUQA.h:32
static ConfigurationManager & getInstance()
Returns an instance of ConfigurationManager.
TEveGeoShape * getGeometryForDetector(std::string detectorName)
Returns ROOT shapes describing simplified geometry of given detector.
static GeometryManager & getInstance()
Returns an instance of GeometryManager.
GLuint color
Definition glcorearb.h:1272
GLdouble f
Definition glcorearb.h:310
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Defining DataPointCompositeObject explicitly as copiable.