Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4SectorDisplayAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4SectorDisplayAction.cc
2 
3 #include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
4 #include <g4main/PHG4Utils.h>
5 
6 #include <Geant4/G4Colour.hh>
7 #include <Geant4/G4LogicalVolume.hh>
8 #include <Geant4/G4Material.hh>
9 #include <Geant4/G4String.hh> // for G4String
10 #include <Geant4/G4VisAttributes.hh>
11 
12 #include <TSystem.h>
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  m_VisAttVec.push_back(visatt); // for later deletion
45  if (it.second == "SectorDetector")
46  {
47  PHG4Utils::SetColour(visatt, it.first->GetMaterial()->GetName());
48  }
49  else if (it.second == "DetectorBox")
50  {
51  visatt->SetColour(G4Colour::White());
52  visatt->SetForceWireframe(true);
53  visatt->SetForceLineSegmentsPerCircle(50);
54  }
55  else
56  {
57  std::cout << "unknown logical volume " << it.second << std::endl;
58  gSystem->Exit(1);
59  }
60  logvol->SetVisAttributes(visatt);
61  }
62  return;
63 }