ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4InttDisplayAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4InttDisplayAction.cc
2 
3 #include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
4 
5 #include <TSystem.h>
6 
7 #include <Geant4/G4Colour.hh> // for G4Colour
8 #include <Geant4/G4LogicalVolume.hh>
9 #include <Geant4/G4String.hh> // for G4String
10 #include <Geant4/G4VisAttributes.hh>
11 
12 #include <iostream>
13 #include <utility> // for pair
14 
15 using namespace std;
16 
18  : PHG4DisplayAction(name)
19 {
20 }
21 
23 {
24  for (auto &it : m_VisAttVec)
25  {
26  delete it;
27  }
28  m_VisAttVec.clear();
29 }
30 
32 {
33  // check if vis attributes exist, if so someone else has set them and we do nothing
34 
35  G4Colour colour_air ( 0.0, 0.0, 0.0, 0.0 );
36  G4Colour colour_CFRP ( 0.4, 0.4, 0.4, 1 );
37  G4Colour colour_endcap ( 0.0, 0.0, 1.0, 0.2 );
38  G4Colour colour_endcap_Al ( 0.3, 0.0, 1.0, 0.4);
39  G4Colour colour_endcap_C ( 0.4, 0.4, 0.4, 0.4 );
40  G4Colour colour_copper ( 0.7, 0.4, 0, 1 );
41 
42  for (auto it : m_LogicalVolumeMap)
43  {
44  G4LogicalVolume *logvol = it.first;
45  if (logvol->GetVisAttributes())
46  {
47  continue;
48  }
49 
50  G4VisAttributes *visatt = new G4VisAttributes();
51  visatt->SetVisibility(true);
52  visatt->SetForceSolid(true);
53  m_VisAttVec.push_back(visatt); // for later deletion
54 
55  if (it.second == "FPHX")
56  {
57  visatt->SetColour( G4Colour(1.0, 0.843, 0.0, 0.5) ); // HTML gold
58  visatt->SetVisibility( true );
59 
60  }
61  else if (it.second == "Ladder"
62  || it.second == "FPHXContainer"
63  || it.second == "FPHXGlueContainer"
64  || it.second == "StaveBox" ) // for containers
65  {
66  visatt->SetColour( colour_air );
67  visatt->SetForceWireframe( true );
68  visatt->SetVisibility( false );
69 
70  }
71  else if (it.second == "Rail")
72  {
73  visatt->SetColour( G4Colour::Cyan());
74  //visatt->SetVisibility( false );
75  visatt->SetVisibility( true );
76 
77  }
78  else if (it.second == "RohaCell")
79  {
80  visatt->SetColour( G4Colour(0.9, 0.9, 0.9, 0.5) ); // white
81  visatt->SetVisibility( true );
82 
83  }
84  else if (it.second == "SiActive")
85  {
86  visatt->SetColour( G4Colour(1.0, 0, 0.0, 0.5) ); // transparent red
87  visatt->SetVisibility( true );
88 
89  }
90  else if (it.second == "SiInActive")
91  {
92  visatt->SetColour( G4Colour(0, 0, 1, 0.5) ); // transparent blue
93  visatt->SetVisibility( true );
94 
95  }
96  else if (it.second == "StaveCooler")
97  {
98  visatt->SetColour( colour_CFRP );
99  visatt->SetVisibility( true );
100 
101  }
102  else if (it.second == "StaveCurve")
103  {
104  visatt->SetColour( colour_CFRP );
105  visatt->SetVisibility( true );
106 
107  }
108  else if (it.second == "StaveGlueBox")
109  {
110  visatt->SetColour(G4Colour::Cyan());
111  visatt->SetVisibility( true );
112 
113  }
114  else if (it.second == "StavePipe")
115  {
116  visatt->SetColour( colour_CFRP );
117  visatt->SetVisibility( true );
118 
119  }
120  else if (it.second == "StaveStraightInner")
121  {
122  visatt->SetColour(G4Colour::Grey());
123  visatt->SetVisibility( true );
124  }
125  else if (it.second == "StaveStraightOuter")
126  {
127  visatt->SetColour( colour_CFRP );
128  visatt->SetVisibility( true );
129 
130  }
131  else if (it.second == "StaveWater")
132  {
133  visatt->SetColour(G4Colour::Blue());
134  visatt->SetVisibility( true );
135  }
136  else if (it.second.find("Endcap") != string::npos ) // any Endcap
137  {
138  if( it.second.find("_Al" ) != string::npos )
139  visatt->SetColour( colour_endcap_Al );
140  else if( it.second.find("_C" ) != string::npos )
141  visatt->SetColour( colour_endcap_C );
142  else
143  visatt->SetColour( colour_endcap );
144  visatt->SetVisibility( true );
145  }
146  else if(it.second.find("Glue") != string::npos )
147  {
148  visatt->SetColour( G4Colour(0.1, 0.1, 0.1, 0.8) );
149  visatt->SetVisibility( true );
150 
151  }
152  else if( it.second.find( "Copper" ) != string::npos ) // any copper
153  {
154  visatt->SetColour( colour_copper );
155  visatt->SetVisibility( true );
156 
157  }
158  else if (it.second.find("Kapton") != string::npos ) // any Kapton
159  {
160  visatt->SetColour( G4Colour(0.0, 0.590, 1.0, 0.5 ) ); // blue
161  visatt->SetVisibility( true );
162 
163  }
164  else if (it.second == "Skin")
165  {
166  visatt->SetColour( colour_CFRP );
167  visatt->SetVisibility( true );
168 
169  }
170  else
171  {
172  cout << "did not assign color to " << it.first->GetName()
173  << " under " << it.second << endl;
174  gSystem->Exit(1);
175  }
176  logvol->SetVisAttributes(visatt);
177  }
178  return;
179 }