Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4TpcDisplayAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4TpcDisplayAction.cc
1 #include "PHG4TpcDisplayAction.h"
2 
3 #include <g4main/PHG4ColorDefs.h>
4 #include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
5 
6 #include <Geant4/G4Colour.hh>
7 #include <Geant4/G4LogicalVolume.hh>
8 #include <Geant4/G4String.hh> // for G4String
9 #include <Geant4/G4VisAttributes.hh>
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  static const G4Colour color[] = {PHG4TpcColorDefs::tpc_cu_color,
38  PHG4TpcColorDefs::tpc_cu_color};
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  G4VisAttributes *visatt = new G4VisAttributes();
48  visatt->SetVisibility(true);
49  visatt->SetForceSolid(true);
50  m_VisAttVec.push_back(visatt); // for later deletion
51  if (it.second == "TpcEnvelope")
52  {
53  visatt->SetVisibility(false);
54  }
55  else if (it.second == "TpcGas")
56  {
57  visatt->SetColor(PHG4TpcColorDefs::tpc_gas_color);
58  }
59  else if (it.second == "TpcHoneyComb")
60  {
61  visatt->SetColor(PHG4TpcColorDefs::tpc_honeycomb_color);
62  }
63  else if (it.second == "TpcWindow")
64  {
65  visatt->SetColor(PHG4TpcColorDefs::tpc_pcb_color);
66  }
67  else
68  {
69  std::cout << "did not assign specific color to " << it.first->GetName()
70  << " under " << it.second << ". Defaulting to TpcWindow color." << std::endl;
71  visatt->SetColor(PHG4TpcColorDefs::tpc_pcb_color);
72 
73  //gSystem->Exit(1);
74  //exit(1);
75  }
76  logvol->SetVisAttributes(visatt);
77  }
78  for (unsigned int i = 0; i < m_TpcInnerLayersVec.size(); i++)
79  {
80  G4VisAttributes *visatt = new G4VisAttributes();
81  visatt->SetVisibility(true);
82  visatt->SetForceSolid(true);
83  m_VisAttVec.push_back(visatt); // for later deletion
84  visatt->SetColor(color[i]);
85  m_TpcInnerLayersVec[i]->SetVisAttributes(visatt);
86  }
87  for (unsigned int i = 0; i < m_TpcOuterLayersVec.size(); i++)
88  {
89  G4VisAttributes *visatt = new G4VisAttributes();
90  visatt->SetVisibility(true);
91  visatt->SetForceSolid(true);
92  m_VisAttVec.push_back(visatt); // for later deletion
93  visatt->SetColor(color[i]);
94  m_TpcOuterLayersVec[i]->SetVisAttributes(visatt);
95  }
96 
97  return;
98 }