ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AllSiliconTrackerDisplayAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file AllSiliconTrackerDisplayAction.cc
2 
4 #include <g4main/PHG4Utils.h>
5 
6 #include <Geant4/G4Colour.hh> // for G4Colour
7 #include <Geant4/G4LogicalVolume.hh>
8 #include <Geant4/G4Material.hh>
9 #include <Geant4/G4VisAttributes.hh>
10 
11 #include <cmath> // for isfinite
12 
13 using namespace std;
14 
16  : PHG4DisplayAction(name)
17  , m_MyVolume(nullptr)
18 {
19 }
20 
22 {
23  for (auto &it : m_VisAttVec)
24  {
25  delete it;
26  }
27  m_VisAttVec.clear();
28  m_LogVolSet.clear();
29 }
30 
32 {
33  // check if vis attributes exist, if so someone else has set them and we do nothing
34  for (auto &it : m_LogVolSet)
35  {
36  if (it->GetVisAttributes())
37  {
38  continue;
39  }
40 
41  // cout << "mat: " << it->GetMaterial()->GetName() << endl;
42  G4VisAttributes *VisAtt = new G4VisAttributes();
43  m_VisAttVec.push_back(VisAtt);
44  VisAtt->SetVisibility(true);
45  VisAtt->SetForceSolid(true);
46  if (it->GetMaterial()->GetName().find("air") != string::npos)
47  {
48  VisAtt->SetVisibility(false);
49  VisAtt->SetForceSolid(false);
50  }
51  else if (it->GetMaterial()->GetName().find("CarbonFiber") != string::npos)
52  {
53  VisAtt->SetColour(G4Colour::Grey());
54  }
55  else if (it->GetMaterial()->GetName().find("Kapton") != string::npos)
56  {
57  VisAtt->SetColour(G4Colour::Green());
58  }
59  else if (it->GetMaterial()->GetName().find("water") != string::npos)
60  {
61  VisAtt->SetColour(G4Colour::Blue());
62  }
63  else if (it->GetMaterial()->GetName().find("silicon") != string::npos)
64  {
65  VisAtt->SetColour(G4Colour::Cyan());
66  }
67  else if (it->GetMaterial()->GetName().find("aluminum") != string::npos)
68  {
69  VisAtt->SetColour(G4Colour::Yellow());
70  }
71  else if (it->GetMaterial()->GetName().find("beryllium") != string::npos)
72  {
73  VisAtt->SetColour(G4Colour::Red());
74  }
75  else
76  {
77  VisAtt->SetColour(G4Colour::Red());
78  }
79 
80  it->SetVisAttributes(VisAtt);
81  }
82  return;
83 }