ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4SpacalDisplayAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4SpacalDisplayAction.cc
2 
3 #include "PHG4CylinderGeom_Spacalv1.h" // for PHG4CylinderGeom_Spacalv1
4 
5 #include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
6 #include <g4main/PHG4Utils.h>
7 
8 #include <TSystem.h>
9 
10 #include <Geant4/G4LogicalVolume.hh>
11 #include <Geant4/G4String.hh> // for G4String
12 #include <Geant4/G4VisAttributes.hh>
13 
14 #include <iostream>
15 #include <utility> // for pair
16 
17 using namespace std;
18 
20  : PHG4DisplayAction(name)
21  , m_Geom(nullptr)
22 {
23 }
24 
26 {
27  for (auto &it : m_VisAttVec)
28  {
29  delete it;
30  }
31  m_VisAttVec.clear();
32 }
33 
35 {
36  // check if vis attributes exist, if so someone else has set them and we do nothing
37  for (auto it : m_LogicalVolumeMap)
38  {
39  G4LogicalVolume *logvol = it.first;
40  if (logvol->GetVisAttributes())
41  {
42  continue;
43  }
44  G4VisAttributes *visatt = new G4VisAttributes();
45  visatt->SetVisibility(true);
46  visatt->SetForceSolid(true);
47  visatt->SetForceWireframe(false);
48 
49  m_VisAttVec.push_back(visatt); // for later deletion
50  if (it.second == "AzimuthSegment")
51  {
52  visatt->SetColor(.1, .1, .1, .5);
54  visatt->SetForceSolid(false);
55  }
56  else if (it.second == "Block")
57  {
58  visatt->SetColor(.3, .3, .3, .3);
60  visatt->SetForceSolid(not m_Geom->is_virualize_fiber());
61  }
62  else if (it.second == "Divider")
63  {
64  visatt->SetColor(.8, 1, .8, .3);
66  }
67  else if (it.second == "Fiber")
68  {
69  PHG4Utils::SetColour(visatt, "G4_POLYSTYRENE");
72  }
73  else if (it.second == "FiberCore")
74  {
75  PHG4Utils::SetColour(visatt, "G4_POLYSTYRENE");
76  visatt->SetVisibility(false);
77  visatt->SetForceSolid(false);
78  }
79  else if (it.second == "LightGuide")
80  {
81  PHG4Utils::SetColour(visatt, m_MaterialMap["LightGuide"]);
82  visatt->SetColor(.8, 1, .8, .3);
84  visatt->SetForceSolid(not m_Geom->is_virualize_fiber());
85  }
86  else if (it.second == "Sector")
87  {
88  visatt->SetColor(.5, .9, .5, .5);
90  visatt->SetForceSolid(false);
91  visatt->SetForceWireframe(true);
92  }
93  else if (it.second == "SpacalCylinder")
94  {
95  PHG4Utils::SetColour(visatt, "W_Epoxy");
97  }
98  else if (it.second == "Wall")
99  {
100  visatt->SetColor(.5, .9, .5, .1);
102  }
103  else if (it.second == "WallProj")
104  {
105  visatt->SetColor(.5, .9, .5, .2);
107  }
108  else
109  {
110  cout << "did not assing color to " << it.first->GetName()
111  << " under " << it.second << endl;
112  gSystem->Exit(1);
113  }
114  logvol->SetVisAttributes(visatt);
115  }
116  return;
117 }