ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4TTLDisplayAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4TTLDisplayAction.cc
1 #include "PHG4TTLDisplayAction.h"
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 
22 PHG4TTLDisplayAction::PHG4TTLDisplayAction(const std::string &name, bool detailed)
23  : PHG4DisplayAction(name)
24 {
25  showdetails = detailed;
26  if (!detailed) std::cout << "PHG4TTLDisplayAction::disabled detailed view of towers" << std::endl;
27 }
28 
30 {
31  for (auto &it : m_VisAttVec)
32  {
33  delete it;
34  }
35  m_VisAttVec.clear();
36 }
37 
39 {
40  // check if vis attributes exist, if so someone else has set them and we do nothing
41  for (auto it : m_LogicalVolumeMap)
42  {
43  G4LogicalVolume *logvol = it.first;
44  if (logvol->GetVisAttributes())
45  {
46  continue;
47  }
48  G4VisAttributes *visatt = new G4VisAttributes();
49  visatt->SetVisibility(true);
50  visatt->SetForceSolid(true);
51  m_VisAttVec.push_back(visatt); // for later deletion
52  if (it.second == "TTLDetector")
53  {
54  PHG4Utils::SetColour(visatt, it.first->GetMaterial()->GetName());
55  if (!showdetails) visatt->SetVisibility(false);
56  }
57  else if (it.second == "TTLLayers")
58  {
59  // visatt->SetForceWireframe(true);
60  PHG4Utils::SetColour(visatt, it.first->GetMaterial()->GetName());
61  // if(it.first->GetMaterial()->GetName()=="CarbonFiberSupport") visatt->SetColour(G4Colour(21./255, 27./255, 31./255));
62  if (it.first->GetMaterial()->GetName() == "CarbonFiberSupport"){
63  visatt->SetVisibility(false);
64  visatt->SetColour(G4Colour(4 * 21. / 255, 4 * 27. / 255, 4 * 31. / 255));
65  }
66  if (it.first->GetMaterial()->GetName() == "G4_Al"){
67  visatt->SetVisibility(false);
68  visatt->SetColour(G4Colour(132. / 255, 135. / 255, 137. / 255));
69  }
70  if (it.first->GetMaterial()->GetName() == "G4_GRAPHITE"){
71  visatt->SetVisibility(false);
72  visatt->SetColour(G4Colour(2 * 21. / 255, 2 * 27. / 255, 2 * 31. / 255));
73  }
74  if (it.first->GetMaterial()->GetName() == "AluminiumNitrate"){
75  visatt->SetVisibility(false);
76  visatt->SetColour(G4Colour(0.8 * 138, 0.8 * 115, 0.8 * 115));
77  }
78  if (it.first->GetMaterial()->GetName() == "G4_PLEXIGLASS"){
79  visatt->SetVisibility(false);
80  visatt->SetColour(G4Colour(68, 131, 157));
81  }
82  }
83  else if (it.second == "SHLayers")
84  {
85  // visatt->SetForceWireframe(true);
86  PHG4Utils::SetColour(visatt, it.first->GetMaterial()->GetName());
87  if (it.first->GetMaterial()->GetName() == "G4_GRAPHITE") visatt->SetColour(G4Colour(2 * 21. / 255, 2 * 27. / 255, 2 * 31. / 255));
88  if (it.first->GetMaterial()->GetName() == "G4_POLYSTYRENE") visatt->SetColour(G4Colour(193, 89, 0));
89  }
90  else if (it.second == "Support")
91  {
92  // visatt->SetColour(G4Colour::White());
93  visatt->SetColour(G4Colour::Gray());
94  // visatt->SetColour(G4Colour(4*21./255, 4*27./255, 4*31./255,0.8));
95  visatt->SetForceSolid(true);
96  // visatt->SetForceWireframe(true);
97  }
98  else if (it.second == "StripBox")
99  {
100  visatt->SetColour(G4Colour::Blue());
101  // visatt->SetForceSolid(true);
102  visatt->SetForceWireframe(true);
103  visatt->SetVisibility(false);
104  }
105  else if (it.second == "Cooling_tube")
106  {
107  visatt->SetColour(G4Colour(0.7, 0.7, 0.7));
108  visatt->SetForceSolid(true);
109  // visatt->SetForceWireframe(true);
110  }
111 
112  // NEW TTL:
113  else if (it.second == "CoolingPlate")
114  {
115  visatt->SetColour(G4Colour(132. / 255, 135. / 255, 137. / 255)); // Al color
116  visatt->SetForceSolid(true);
117  // visatt->SetForceWireframe(true);
118  }
119  else if (it.second == "Epoxy")
120  {
121  visatt->SetColour(G4Colour(G4Colour::White()));
122  visatt->SetForceSolid(true);
123  // visatt->SetForceWireframe(true);
124  }
125  else if (it.second == "SensorStack" || it.second == "SensorLadder" || it.second == "SensorAndReadoutLadder")
126  {
127  visatt->SetVisibility(false);
128  visatt->SetColour(G4Colour(G4Colour::Green()));
129  visatt->SetForceWireframe(true);
130  }
131  else if (it.second == "SHLadder" || it.second == "SHStack")
132  {
133  visatt->SetVisibility(false);
134  visatt->SetColour(G4Colour(G4Colour::Green()));
135  visatt->SetForceWireframe(true);
136  }
137  else if (it.second == "ModuleEnvelope")
138  {
139  visatt->SetVisibility(false);
140  visatt->SetColour(G4Colour::Red());
141  // visatt->SetForceSolid(true);
142  visatt->SetForceWireframe(true);
143  }
144  else if (it.second == "FullEnvelope")
145  {
146  visatt->SetVisibility(false);
147  visatt->SetColour(G4Colour::Red());
148  // visatt->SetForceSolid(true);
149  visatt->SetForceWireframe(true);
150  }
151 
152  else if (it.second == "Water_cooling")
153  {
154  visatt->SetColour(G4Colour(0.823, 0.992, 0.980));
155  visatt->SetForceSolid(true);
156  // visatt->SetForceWireframe(true);
157  }
158  else if (it.second == "Cooling_Support" || it.second == "Carbon_Support")
159  {
160  // visatt->SetColour(G4Colour(21./255, 27./255, 31./255,0.5));
161  visatt->SetColour(G4Colour(4 * 21. / 255, 4 * 27. / 255, 4 * 31. / 255));
162  visatt->SetForceSolid(true);
163  // visatt->SetForceWireframe(true);
164  }
165  else if (it.second == "StripCoolingSupportBox")
166  {
167  visatt->SetColour(G4Colour::Green());
168  // visatt->SetForceSolid(true);
169  visatt->SetForceWireframe(true);
170  visatt->SetVisibility(false);
171  }
172  else if (it.second == "Module_Mother")
173  {
174  visatt->SetVisibility(false);
175  }
176  else if (it.second == "DetectorBox")
177  {
178  // visatt->SetVisibility(false);
179 
180  // if (showdetails){
181  // visatt->SetColour(G4Colour::Black());
182  visatt->SetColour(G4Colour::Red());
183  visatt->SetForceWireframe(true);
184  visatt->SetVisibility(false);
185  visatt->SetForceLineSegmentsPerCircle(50);
186  // } else {
187  // visatt->SetColour(34./255, 139./255, 34./255, 1. );
188  // visatt->SetForceSolid(true);
189  // visatt->SetVisibility(true);
190  // }
191  }
192  else if (it.second == "DetectorBoxFwd")
193  {
194  // if (showdetails){
195  visatt->SetColour(G4Colour::Red());
196  visatt->SetForceWireframe(true);
197  visatt->SetVisibility(true);
198  visatt->SetForceLineSegmentsPerCircle(50);
199  // } else {
200  // visatt->SetColour(34./255, 139./255, 34./255, 1. );
201  // visatt->SetForceSolid(true);
202  // visatt->SetVisibility(true);
203  // }
204  }
205  else
206  {
207  std::cout << "unknown logical volume " << it.second << std::endl;
208  gSystem->Exit(1);
209  }
210  logvol->SetVisAttributes(visatt);
211  }
212  return;
213 }