Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4ZDCDisplayAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4ZDCDisplayAction.cc
1 #include "PHG4ZDCDisplayAction.h"
2 
3 #include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
4 
5 #include <Geant4/G4Colour.hh>
6 #include <Geant4/G4LogicalVolume.hh>
7 #include <Geant4/G4VisAttributes.hh>
8 
9 #include <TSystem.h>
10 
11 #include <iostream>
12 #include <utility> // for pair
13 
15  : PHG4DisplayAction(name)
16 {
17 }
18 
20 {
21  for (auto &it : m_VisAttVec)
22  {
23  delete it;
24  }
25  m_VisAttVec.clear();
26 }
27 
29 {
30  // check if vis attributes exist, if so someone else has set them and we do nothing
31  for (const auto &it : m_LogicalVolumeMap)
32  {
33  G4LogicalVolume *logvol = it.first;
34  if (logvol->GetVisAttributes())
35  {
36  continue;
37  }
38  G4VisAttributes *visatt = new G4VisAttributes();
39  visatt->SetVisibility(true);
40  visatt->SetForceSolid(true);
41  m_VisAttVec.push_back(visatt); // for later deletion
42  if (it.second == "Absorber")
43  {
44  visatt->SetColour(G4Colour::Blue());
45  }
46  else if (it.second == "Envelope" || it.second == "fiber_plate_air")
47  {
48  visatt->SetVisibility(false);
49  visatt->SetForceSolid(false);
50  }
51  else if (it.second == "Fiber")
52  {
53  visatt->SetColour(G4Colour::Cyan());
54  }
55  else if (it.second == "FrontBackPlate")
56  {
57  visatt->SetColour(G4Colour::Red());
58  }
59  else if (it.second == "Window")
60  {
61  visatt->SetColour(G4Colour::Blue());
62  }
63  else if (it.second == "SMD")
64  {
65  visatt->SetColour(G4Colour::Yellow());
66  }
67  else if (it.second == "FiberPlate")
68  {
69  visatt->SetColour(G4Colour::Cyan());
70  }
71  else if (it.second == "Scint_solid")
72  {
73  visatt->SetColour(G4Colour::Cyan());
74  }
75  else
76  {
77  std::cout << GetName() << " unknown logical volume " << it.second << std::endl;
78  gSystem->Exit(1);
79  }
80  logvol->SetVisAttributes(visatt);
81  }
82  return;
83 }