forked from sPHENIX-Collaboration/coresoftware
/
PHG4InttDisplayAction.cc
179 lines (152 loc) · 4.54 KB
/
PHG4InttDisplayAction.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
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
#include "PHG4InttDisplayAction.h"
#include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
#include <TSystem.h>
#include <Geant4/G4Colour.hh> // for G4Colour
#include <Geant4/G4LogicalVolume.hh>
#include <Geant4/G4String.hh> // for G4String
#include <Geant4/G4VisAttributes.hh>
#include <iostream>
#include <utility> // for pair
using namespace std;
PHG4InttDisplayAction::PHG4InttDisplayAction(const std::string &name)
: PHG4DisplayAction(name)
{
}
PHG4InttDisplayAction::~PHG4InttDisplayAction()
{
for (auto &it : m_VisAttVec)
{
delete it;
}
m_VisAttVec.clear();
}
void PHG4InttDisplayAction::ApplyDisplayAction(G4VPhysicalVolume */*physvol*/)
{
// check if vis attributes exist, if so someone else has set them and we do nothing
G4Colour colour_air ( 0.0, 0.0, 0.0, 0.0 );
G4Colour colour_CFRP ( 0.4, 0.4, 0.4, 1 );
G4Colour colour_endcap ( 0.0, 0.0, 1.0, 0.2 );
G4Colour colour_endcap_Al ( 0.3, 0.0, 1.0, 0.4);
G4Colour colour_endcap_C ( 0.4, 0.4, 0.4, 0.4 );
G4Colour colour_copper ( 0.7, 0.4, 0, 1 );
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 == "FPHX")
{
visatt->SetColour( G4Colour(1.0, 0.843, 0.0, 0.5) ); // HTML gold
visatt->SetVisibility( true );
}
else if (it.second == "Ladder"
|| it.second == "FPHXContainer"
|| it.second == "FPHXGlueContainer"
|| it.second == "StaveBox" ) // for containers
{
visatt->SetColour( colour_air );
visatt->SetForceWireframe( true );
visatt->SetVisibility( false );
}
else if (it.second == "Rail")
{
visatt->SetColour( G4Colour::Cyan());
//visatt->SetVisibility( false );
visatt->SetVisibility( true );
}
else if (it.second == "RohaCell")
{
visatt->SetColour( G4Colour(0.9, 0.9, 0.9, 0.5) ); // white
visatt->SetVisibility( true );
}
else if (it.second == "SiActive")
{
visatt->SetColour( G4Colour(1.0, 0, 0.0, 0.5) ); // transparent red
visatt->SetVisibility( true );
}
else if (it.second == "SiInActive")
{
visatt->SetColour( G4Colour(0, 0, 1, 0.5) ); // transparent blue
visatt->SetVisibility( true );
}
else if (it.second == "StaveCooler")
{
visatt->SetColour( colour_CFRP );
visatt->SetVisibility( true );
}
else if (it.second == "StaveCurve")
{
visatt->SetColour( colour_CFRP );
visatt->SetVisibility( true );
}
else if (it.second == "StaveGlueBox")
{
visatt->SetColour(G4Colour::Cyan());
visatt->SetVisibility( true );
}
else if (it.second == "StavePipe")
{
visatt->SetColour( colour_CFRP );
visatt->SetVisibility( true );
}
else if (it.second == "StaveStraightInner")
{
visatt->SetColour(G4Colour::Grey());
visatt->SetVisibility( true );
}
else if (it.second == "StaveStraightOuter")
{
visatt->SetColour( colour_CFRP );
visatt->SetVisibility( true );
}
else if (it.second == "StaveWater")
{
visatt->SetColour(G4Colour::Blue());
visatt->SetVisibility( true );
}
else if (it.second.find("Endcap") != string::npos ) // any Endcap
{
if( it.second.find("_Al" ) != string::npos )
visatt->SetColour( colour_endcap_Al );
else if( it.second.find("_C" ) != string::npos )
visatt->SetColour( colour_endcap_C );
else
visatt->SetColour( colour_endcap );
visatt->SetVisibility( true );
}
else if(it.second.find("Glue") != string::npos )
{
visatt->SetColour( G4Colour(0.1, 0.1, 0.1, 0.8) );
visatt->SetVisibility( true );
}
else if( it.second.find( "Copper" ) != string::npos ) // any copper
{
visatt->SetColour( colour_copper );
visatt->SetVisibility( true );
}
else if (it.second.find("Kapton") != string::npos ) // any Kapton
{
visatt->SetColour( G4Colour(0.0, 0.590, 1.0, 0.5 ) ); // blue
visatt->SetVisibility( true );
}
else if (it.second == "Skin")
{
visatt->SetColour( colour_CFRP );
visatt->SetVisibility( true );
}
else
{
cout << "did not assign color to " << it.first->GetName()
<< " under " << it.second << endl;
gSystem->Exit(1);
}
logvol->SetVisAttributes(visatt);
}
return;
}