ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4ForwardEcalDisplayAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4ForwardEcalDisplayAction.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  : PHG4DisplayAction(name)
21 {
22  showdetails = detailed;
23  if (!detailed) std::cout << "PHG4ForwardEcalDisplayAction::disabled detailed view of towers" << std::endl;
24 }
25 
27 {
28  for (auto &it : m_VisAttVec)
29  {
30  delete it;
31  }
32  m_VisAttVec.clear();
33 }
34 
36 {
37  // check if vis attributes exist, if so someone else has set them and we do nothing
38  for (auto it : m_LogicalVolumeMap)
39  {
40  G4LogicalVolume *logvol = it.first;
41  if (logvol->GetVisAttributes())
42  {
43  continue;
44  }
45  G4VisAttributes *visatt = new G4VisAttributes();
46  visatt->SetVisibility(true);
47  visatt->SetForceSolid(true);
48  m_VisAttVec.push_back(visatt); // for later deletion
49  if (it.second == "Absorber")
50  {
51  visatt->SetColour(G4Colour::Gray());
52  if (showdetails)
53  visatt->SetVisibility(true);
54  else
55  visatt->SetVisibility(false);
56  }
57  else if (it.second == "Coating")
58  {
59  visatt->SetColour(G4Colour::Black());
60  if (showdetails)
61  visatt->SetVisibility(true);
62  else
63  visatt->SetVisibility(false);
64  }
65  else if (it.second == "Clamp")
66  {
67  visatt->SetColour(4 * 21. / 255, 4 * 27. / 255, 4 * 31. / 255);
68  // visatt->SetForceWireframe(true);
69  if (showdetails)
70  visatt->SetVisibility(true);
71  else
72  visatt->SetVisibility(false);
73  }
74  else if (it.second == "Envelope")
75  {
76  visatt->SetColour(G4Colour::Magenta());
77  visatt->SetVisibility(false);
78  visatt->SetForceWireframe(true);
79  }
80  else if (it.second == "Fiber")
81  {
82  // visatt->SetColour(G4Colour::Cyan());
83  visatt->SetColour(152. / 255, 251. / 255, 152. / 255, 0.4);
84  if (showdetails)
85  visatt->SetVisibility(true);
86  else
87  visatt->SetVisibility(false);
88  }
89  else if (it.second == "Scintillator")
90  {
91  // visatt->SetColour(G4Colour::White());
92  // visatt->SetColour(G4Colour::Cyan());
93  visatt->SetColour(127. / 255, 255. / 255, 212. / 255, 0.2);
94  if (showdetails)
95  visatt->SetVisibility(true);
96  else
97  visatt->SetVisibility(false);
98  }
99  else if (it.second == "SingleTower")
100  {
101  // visatt->SetColour(G4Colour::Cyan());
102  visatt->SetColour(4 * 21. / 255, 4 * 27. / 255, 4 * 31. / 255);
103  // visatt->SetForceWireframe(true);
104  if (showdetails)
105  visatt->SetVisibility(false);
106  else
107  visatt->SetVisibility(true);
108  }
109  else if (it.second == "miniblock")
110  {
111  visatt->SetVisibility(false);
112  visatt->SetColour(G4Colour::Red());
113  visatt->SetForceSolid(false);
114  }
115  else
116  {
117  std::cout << "unknown logical volume " << it.second << std::endl;
118  gSystem->Exit(1);
119  }
120  logvol->SetVisAttributes(visatt);
121  }
122  return;
123 }