Analysis Software
Documentation for sPHENIX simulation 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 
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  for (const auto &it : m_LogicalVolumeMap)
35  {
36  G4LogicalVolume *logvol = it.first;
37  if (logvol->GetVisAttributes())
38  {
39  continue;
40  }
41  G4VisAttributes *visatt = new G4VisAttributes();
42  visatt->SetVisibility(true);
43  visatt->SetForceSolid(true);
44  visatt->SetForceWireframe(false);
45 
46  m_VisAttVec.push_back(visatt); // for later deletion
47  if (it.second == "AzimuthSegment")
48  {
49  visatt->SetColor(.1, .1, .1, .5);
50  visatt->SetVisibility(m_Geom->is_virualize_fiber());
51  visatt->SetForceSolid(false);
52  }
53  else if (it.second == "Block")
54  {
55  visatt->SetColor(.3, .3, .3, .3);
56  visatt->SetVisibility(m_Geom->is_azimuthal_seg_visible() or m_Geom->is_virualize_fiber());
57  visatt->SetForceSolid(!m_Geom->is_virualize_fiber());
58  }
59  else if (it.second == "Divider")
60  {
61  visatt->SetColor(.8, 1, .8, .3);
62  visatt->SetVisibility(m_Geom->is_azimuthal_seg_visible());
63  }
64  else if (it.second == "Fiber")
65  {
66  PHG4Utils::SetColour(visatt, "G4_POLYSTYRENE");
67  visatt->SetVisibility(m_Geom->is_virualize_fiber());
68  visatt->SetForceSolid(m_Geom->is_virualize_fiber());
69  }
70  else if (it.second == "FiberCore")
71  {
72  PHG4Utils::SetColour(visatt, "G4_POLYSTYRENE");
73  visatt->SetVisibility(false);
74  visatt->SetForceSolid(false);
75  }
76  else if (it.second == "LightGuide")
77  {
78  PHG4Utils::SetColour(visatt, m_MaterialMap["LightGuide"]);
79  visatt->SetColor(.8, 1, .8, .3);
80  visatt->SetVisibility(m_Geom->is_azimuthal_seg_visible() or m_Geom->is_virualize_fiber());
81  visatt->SetForceSolid(!m_Geom->is_virualize_fiber());
82  }
83  else if (it.second == "Sector")
84  {
85  visatt->SetColor(.5, .9, .5, .5);
86  visatt->SetVisibility(m_Geom->is_azimuthal_seg_visible() or m_Geom->is_virualize_fiber());
87  visatt->SetForceSolid(false);
88  visatt->SetForceWireframe(true);
89  }
90  else if (it.second == "SpacalCylinder")
91  {
92  PHG4Utils::SetColour(visatt, "W_Epoxy");
93  visatt->SetForceSolid((!m_Geom->is_virualize_fiber()) && (!m_Geom->is_azimuthal_seg_visible()));
94  }
95  else if (it.second == "Wall")
96  {
97  visatt->SetColor(.5, .9, .5, .1);
98  visatt->SetVisibility(m_Geom->is_azimuthal_seg_visible());
99  }
100  else if (it.second == "WallProj")
101  {
102  visatt->SetColor(.5, .9, .5, .2);
103  visatt->SetVisibility(m_Geom->is_azimuthal_seg_visible() && (!m_Geom->is_virualize_fiber()));
104  }
105  else
106  {
107  std::cout << "did not assing color to " << it.first->GetName()
108  << " under " << it.second << std::endl;
109  gSystem->Exit(1);
110  }
111  logvol->SetVisAttributes(visatt);
112  }
113  return;
114 }