ECCE @ EIC 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 <TSystem.h>
7 
8 #include <Geant4/G4Colour.hh>
9 #include <Geant4/G4LogicalVolume.hh>
10 #include <Geant4/G4VisAttributes.hh>
11 #include "Geant4/G4String.hh" // for G4String
12 
13 #include <cstdlib>
14 #include <iostream>
15 #include <utility> // for pair
16 
18  : PHG4DisplayAction(name)
19 {
20 }
21 
23 {
24  for (auto &it : m_VisAttVec)
25  {
26  delete it;
27  }
28  m_VisAttVec.clear();
29 }
30 
32 {
41  PHG4TpcColorDefs::tpc_cu_color};
42  // check if vis attributes exist, if so someone else has set them and we do nothing
43  for (auto it : m_LogicalVolumeMap)
44  {
45  G4LogicalVolume *logvol = it.first;
46  if (logvol->GetVisAttributes())
47  {
48  continue;
49  }
50  G4VisAttributes *visatt = new G4VisAttributes();
51  visatt->SetVisibility(true);
52  visatt->SetForceSolid(true);
53  m_VisAttVec.push_back(visatt); // for later deletion
54  if (it.second == "TpcEnvelope")
55  {
56  visatt->SetVisibility(false);
57  }
58  else if (it.second == "TpcGas")
59  {
61  }
62  else if (it.second == "TpcHoneyComb")
63  {
65  }
66  else if (it.second == "TpcWindow")
67  {
69  }
70  else
71  {
72  std::cout << "did not assign specific color to " << it.first->GetName()
73  << " under " << it.second << ". Defaulting to TpcWindow color." << std::endl;
75 
76  //gSystem->Exit(1);
77  //exit(1);
78  }
79  logvol->SetVisAttributes(visatt);
80  }
81  for (unsigned int i = 0; i < m_TpcInnerLayersVec.size(); i++)
82  {
83  G4VisAttributes *visatt = new G4VisAttributes();
84  visatt->SetVisibility(true);
85  visatt->SetForceSolid(true);
86  m_VisAttVec.push_back(visatt); // for later deletion
87  visatt->SetColor(color[i]);
88  m_TpcInnerLayersVec[i]->SetVisAttributes(visatt);
89  }
90  for (unsigned int i = 0; i < m_TpcOuterLayersVec.size(); i++)
91  {
92  G4VisAttributes *visatt = new G4VisAttributes();
93  visatt->SetVisibility(true);
94  visatt->SetForceSolid(true);
95  m_VisAttVec.push_back(visatt); // for later deletion
96  visatt->SetColor(color[i]);
97  m_TpcOuterLayersVec[i]->SetVisAttributes(visatt);
98  }
99 
100  return;
101 }