ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4BarrelEcalDisplayAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4BarrelEcalDisplayAction.cc
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 (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 == "BCalCylinder")
43  {
44  visatt->SetColour(G4Colour::White());
45  visatt->SetForceWireframe(true);
46  visatt->SetVisibility(false);
47  }
48  else if (it.second == "Block1")
49  {
50  visatt->SetColour(G4Colour(1., 0.5, 0.));
51  }
52  else if (it.second == "Block2")
53  {
54  visatt->SetColour(G4Colour::Blue());
55  }
56  else if (it.second == "Glass")
57  {
58  visatt->SetColour(G4Colour::White());
59  //visatt->SetForceWireframe(true);
60  }
61  else if (it.second == "Si")
62  {
63  visatt->SetColour(G4Colour::Green());
64  }
65  else if (it.second == "Kapton")
66  {
67  visatt->SetColour(G4Colour::Brown());
68  }
69  else if (it.second == "SIO2")
70  {
71  visatt->SetColour(G4Colour::Gray());
72  }
73  else if (it.second == "Carbon")
74  {
75  visatt->SetColour(G4Colour::Black());
76  }
77  else
78  {
79  std::cout << "unknown logical volume " << it.second << std::endl;
80  gSystem->Exit(1);
81  }
82  logvol->SetVisAttributes(visatt);
83  }
84  return;
85 }