Analysis Software
Documentation for sPHENIX simulation 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 
16  : PHG4DisplayAction(name)
17 {
18 }
19 
21 {
22  for (auto &it : m_VisAttVec)
23  {
24  delete it;
25  }
26  m_VisAttVec.clear();
27 }
28 
30 {
31  // check if vis attributes exist, if so someone else has set them and we do nothing
32 
33  G4Colour colour_air(0.0, 0.0, 0.0, 0.0);
34  G4Colour colour_CFRP(0.4, 0.4, 0.4, 1);
35  G4Colour colour_endcap(0.0, 0.0, 1.0, 0.2);
36  G4Colour colour_endcap_Al(0.3, 0.0, 1.0, 0.4);
37  G4Colour colour_endcap_C(0.4, 0.4, 0.4, 0.4);
38  G4Colour colour_copper(0.7, 0.4, 0, 1);
39 
40  for (auto it : m_LogicalVolumeMap)
41  {
42  G4LogicalVolume *logvol = it.first;
43  if (logvol->GetVisAttributes())
44  {
45  continue;
46  }
47 
48  G4VisAttributes *visatt = new G4VisAttributes();
49  visatt->SetVisibility(true);
50  visatt->SetForceSolid(true);
51  m_VisAttVec.push_back(visatt); // for later deletion
52 
53  if (it.second == "FPHX")
54  {
55  visatt->SetColour(G4Colour(1.0, 0.843, 0.0, 0.5)); // HTML gold
56  visatt->SetVisibility(true);
57  }
58  else if (it.second == "Ladder" || it.second == "FPHXContainer" || it.second == "FPHXGlueContainer" || it.second == "StaveBox") // for containers
59  {
60  visatt->SetColour(colour_air);
61  visatt->SetForceWireframe(true);
62  visatt->SetVisibility(false);
63  }
64  else if (it.second == "Rail")
65  {
66  visatt->SetColour(G4Colour::Cyan());
67  //visatt->SetVisibility( false );
68  visatt->SetVisibility(true);
69  }
70  else if (it.second == "RohaCell")
71  {
72  visatt->SetColour(G4Colour(0.9, 0.9, 0.9, 0.5)); // white
73  visatt->SetVisibility(true);
74  }
75  else if (it.second == "SiActive")
76  {
77  visatt->SetColour(G4Colour(1.0, 0, 0.0, 0.5)); // transparent red
78  visatt->SetVisibility(true);
79  }
80  else if (it.second == "SiInActive")
81  {
82  visatt->SetColour(G4Colour(0, 0, 1, 0.5)); // transparent blue
83  visatt->SetVisibility(true);
84  }
85  else if (it.second == "StaveCooler")
86  {
87  visatt->SetColour(colour_CFRP);
88  visatt->SetVisibility(true);
89  }
90  else if (it.second == "StaveCurve")
91  {
92  visatt->SetColour(colour_CFRP);
93  visatt->SetVisibility(true);
94  }
95  else if (it.second == "StaveGlueBox")
96  {
97  visatt->SetColour(G4Colour::Cyan());
98  visatt->SetVisibility(true);
99  }
100  else if (it.second == "StavePipe")
101  {
102  visatt->SetColour(colour_CFRP);
103  visatt->SetVisibility(true);
104  }
105  else if (it.second == "StaveStraightInner")
106  {
107  visatt->SetColour(G4Colour::Grey());
108  visatt->SetVisibility(true);
109  }
110  else if (it.second == "StaveStraightOuter")
111  {
112  visatt->SetColour(colour_CFRP);
113  visatt->SetVisibility(true);
114  }
115  else if (it.second == "StaveWater")
116  {
117  visatt->SetColour(G4Colour::Blue());
118  visatt->SetVisibility(true);
119  }
120  else if (it.second.find("Endcap") != std::string::npos) // any Endcap
121  {
122  if (it.second.find("_Al") != std::string::npos)
123  visatt->SetColour(colour_endcap_Al);
124  else if (it.second.find("_C") != std::string::npos)
125  visatt->SetColour(colour_endcap_C);
126  else
127  visatt->SetColour(colour_endcap);
128  visatt->SetVisibility(true);
129  }
130  else if (it.second.find("Glue") != std::string::npos)
131  {
132  visatt->SetColour(G4Colour(0.1, 0.1, 0.1, 0.8));
133  visatt->SetVisibility(true);
134  }
135  else if (it.second.find("Copper") != std::string::npos) // any copper
136  {
137  visatt->SetColour(colour_copper);
138  visatt->SetVisibility(true);
139  }
140  else if (it.second.find("Kapton") != std::string::npos) // any Kapton
141  {
142  visatt->SetColour(G4Colour(0.0, 0.590, 1.0, 0.5)); // blue
143  visatt->SetVisibility(true);
144  }
145  else if (it.second == "Skin")
146  {
147  visatt->SetColour(colour_CFRP);
148  visatt->SetVisibility(true);
149  }
150  else
151  {
152  std::cout << "did not assign color to " << it.first->GetName()
153  << " under " << it.second << std::endl;
154  gSystem->Exit(1);
155  }
156  logvol->SetVisAttributes(visatt);
157  }
158  return;
159 }