ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4LFHcalDisplayAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4LFHcalDisplayAction.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 
14 using namespace std;
15 
17  : PHG4DisplayAction(name)
18 {
19 }
20 
21 PHG4LFHcalDisplayAction::PHG4LFHcalDisplayAction(const std::string &name, bool detailed)
22  : PHG4DisplayAction(name)
23 {
24  showdetails = detailed;
25  if (!detailed) std::cout << "PHG4LFHcalDisplayAction::disabled detailed view of towers" << std::endl;
26 }
27 
29 {
30  for (auto &it : m_VisAttVec)
31  {
32  delete it;
33  }
34  m_VisAttVec.clear();
35 }
36 
38 {
39  // check if vis attributes exist, if so someone else has set them and we do nothing
40  for (auto it : m_LogicalVolumeMap)
41  {
42  G4LogicalVolume *logvol = it.first;
43  if (logvol->GetVisAttributes())
44  {
45  continue;
46  }
47  // std::cout << showdetails << "\t" << it.second ;
48  G4VisAttributes *visatt = new G4VisAttributes();
49  visatt->SetForceSolid(true);
50  m_VisAttVec.push_back(visatt); // for later deletion
51  if (it.second == "Invisible")
52  {
53  visatt->SetVisibility(false);
54  }
55  else if (it.second == "Wireframe")
56  {
57  visatt->SetColour(G4Colour::Red());
58  visatt->SetForceWireframe(true);
59  visatt->SetVisibility(true);
60  }
61  else if (it.second == "Absorber_W")
62  {
63  if (showdetails)
64  {
65  visatt->SetColour(G4Colour::Black());
66  visatt->SetVisibility(true);
67  // visatt->SetForceWireframe(true);
68  // std::cout << " is visible" ;
69  }
70  else
71  visatt->SetVisibility(false);
72  }
73  else if (it.second == "Absorber")
74  {
75  if (showdetails)
76  {
77  visatt->SetColour(4 * 21. / 255, 4 * 27. / 255, 4 * 31. / 255);
78  visatt->SetVisibility(true);
79  // visatt->SetForceWireframe(true);
80  // std::cout << " is visible" ;
81  }
82  else
83  visatt->SetVisibility(false);
84  }
85  else if (it.second == "Spacer")
86  {
87  if (showdetails)
88  {
89  visatt->SetColour(220. / 255, 220. / 255, 220. / 255);
90  visatt->SetVisibility(true);
91  // visatt->SetForceWireframe(true);
92  // std::cout << " is visible" ;
93  }
94  else
95  visatt->SetVisibility(false);
96  }
97  else if (it.second == "LFHcalEnvelope")
98  {
99  visatt->SetColour(G4Colour::Magenta());
100  visatt->SetForceSolid(false);
101  visatt->SetVisibility(false);
102  }
103  else if (it.second == "Scintillator")
104  {
105  if (showdetails)
106  {
107  // visatt->SetColour(G4Colour::White());
108  visatt->SetColour(127. / 255, 255. / 255, 212. / 255, 0.5);
109  visatt->SetVisibility(true);
110  // visatt->SetForceWireframe(true);
111  // std::cout << " is visible" ;
112  }
113  else
114  visatt->SetVisibility(false);
115  }
116  else if (it.second == "WLSfiber")
117  {
118  if (showdetails)
119  {
120  // visatt->SetColour(G4Colour::Blue());
121  visatt->SetColour(20. / 255, 10. / 255, 200. / 255, 1.0);
122  // visatt->SetColour(152./ 255,10./ 255,10./ 255, 1.0);
123  // visatt->SetColour(152./ 255,251./ 255,152./ 255, 0.9);
124  visatt->SetVisibility(true);
125  // std::cout << " is visible" ;
126  }
127  else
128  visatt->SetVisibility(false);
129  }
130  else if (it.second == "Frame")
131  {
132  if (showdetails)
133  {
134  visatt->SetColour(G4Colour::Yellow());
135  // visatt->SetColour(152./ 255,10./ 255,10./ 255, 0.9);
136  // visatt->SetColour(152./ 255,251./ 255,152./ 255, 0.9);
137  visatt->SetVisibility(true);
138  visatt->SetForceWireframe(true);
139  // std::cout << " is visible" ;
140  }
141  else
142  visatt->SetVisibility(false);
143  }
144  else if (it.second == "SingleTower_W")
145  {
146  if (showdetails)
147  visatt->SetVisibility(false);
148  else
149  {
150  visatt->SetColour(G4Colour::Black());
151  visatt->SetVisibility(true);
152  // std::cout << " is visible" ;
153  }
154  }
155  else if (it.second == "SingleTower")
156  {
157  if (showdetails)
158  visatt->SetVisibility(false);
159  else
160  {
161  visatt->SetColour(G4Colour::Blue());
162  visatt->SetVisibility(true);
163  // std::cout << " is visible" ;
164  }
165  }
166  else
167  {
168  cout << "unknown logical volume " << it.second << endl;
169  gSystem->Exit(1);
170  }
171  // std::cout << std::endl ;
172  logvol->SetVisAttributes(visatt);
173  }
174  return;
175 }