ECCE @ EIC 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 
17 using namespace std;
18 
20  : PHG4DisplayAction(name)
21 {
22 }
23 
25 {
26  for (auto &it : m_VisAttVec)
27  {
28  delete it;
29  }
30  m_VisAttVec.clear();
31 }
32 
34 {
35  // check if vis attributes exist, if so someone else has set them and we do nothing
36  for (auto it : m_LogicalVolumeMap)
37  {
38  G4LogicalVolume *logvol = it.first;
39  if (logvol->GetVisAttributes())
40  {
41  continue;
42  }
43  G4VisAttributes *visatt = new G4VisAttributes();
44  visatt->SetVisibility(true);
45  visatt->SetForceSolid(true);
46  m_VisAttVec.push_back(visatt); // for later deletion
47  if (it.second == "SectorDetector")
48  {
49  PHG4Utils::SetColour(visatt, it.first->GetMaterial()->GetName());
50  }
51  else if (it.second == "DetectorBox")
52  {
53  visatt->SetColour(G4Colour::White());
54  visatt->SetForceWireframe(true);
56  }
57  else
58  {
59  cout << "unknown logical volume " << it.second << endl;
60  gSystem->Exit(1);
61  }
62  logvol->SetVisAttributes(visatt);
63  }
64  return;
65 }