forked from sPHENIX-Collaboration/coresoftware
/
PHG4TpcDisplayAction.cc
101 lines (92 loc) · 3.08 KB
/
PHG4TpcDisplayAction.cc
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
#include "PHG4TpcDisplayAction.h"
#include <g4main/PHG4ColorDefs.h>
#include "g4main/PHG4DisplayAction.h" // for PHG4DisplayAction
#include <TSystem.h>
#include <Geant4/G4Colour.hh>
#include <Geant4/G4LogicalVolume.hh>
#include <Geant4/G4VisAttributes.hh>
#include "Geant4/G4String.hh" // for G4String
#include <cstdlib>
#include <iostream>
#include <utility> // for pair
PHG4TpcDisplayAction::PHG4TpcDisplayAction(const std::string &name)
: PHG4DisplayAction(name)
{
}
PHG4TpcDisplayAction::~PHG4TpcDisplayAction()
{
for (auto &it : m_VisAttVec)
{
delete it;
}
m_VisAttVec.clear();
}
void PHG4TpcDisplayAction::ApplyDisplayAction(G4VPhysicalVolume * /*physvol*/)
{
static const G4Colour color[] = {PHG4TpcColorDefs::tpc_cu_color,
PHG4TpcColorDefs::tpc_pcb_color,
PHG4TpcColorDefs::tpc_honeycomb_color,
PHG4TpcColorDefs::tpc_cu_color,
PHG4TpcColorDefs::tpc_pcb_color,
PHG4TpcColorDefs::tpc_kapton_color,
PHG4TpcColorDefs::tpc_cu_color,
PHG4TpcColorDefs::tpc_kapton_color,
PHG4TpcColorDefs::tpc_cu_color};
// check if vis attributes exist, if so someone else has set them and we do nothing
for (auto it : m_LogicalVolumeMap)
{
G4LogicalVolume *logvol = it.first;
if (logvol->GetVisAttributes())
{
continue;
}
G4VisAttributes *visatt = new G4VisAttributes();
visatt->SetVisibility(true);
visatt->SetForceSolid(true);
m_VisAttVec.push_back(visatt); // for later deletion
if (it.second == "TpcEnvelope")
{
visatt->SetVisibility(false);
}
else if (it.second == "TpcGas")
{
visatt->SetColor(PHG4TpcColorDefs::tpc_gas_color);
}
else if (it.second == "TpcHoneyComb")
{
visatt->SetColor(PHG4TpcColorDefs::tpc_honeycomb_color);
}
else if (it.second == "TpcWindow")
{
visatt->SetColor(PHG4TpcColorDefs::tpc_pcb_color);
}
else
{
std::cout << "did not assign specific color to " << it.first->GetName()
<< " under " << it.second << ". Defaulting to TpcWindow color." << std::endl;
visatt->SetColor(PHG4TpcColorDefs::tpc_pcb_color);
//gSystem->Exit(1);
//exit(1);
}
logvol->SetVisAttributes(visatt);
}
for (unsigned int i = 0; i < m_TpcInnerLayersVec.size(); i++)
{
G4VisAttributes *visatt = new G4VisAttributes();
visatt->SetVisibility(true);
visatt->SetForceSolid(true);
m_VisAttVec.push_back(visatt); // for later deletion
visatt->SetColor(color[i]);
m_TpcInnerLayersVec[i]->SetVisAttributes(visatt);
}
for (unsigned int i = 0; i < m_TpcOuterLayersVec.size(); i++)
{
G4VisAttributes *visatt = new G4VisAttributes();
visatt->SetVisibility(true);
visatt->SetForceSolid(true);
m_VisAttVec.push_back(visatt); // for later deletion
visatt->SetColor(color[i]);
m_TpcOuterLayersVec[i]->SetVisAttributes(visatt);
}
return;
}