ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AllSi_Al_support_DisplayAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file AllSi_Al_support_DisplayAction.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("aluminum") != string::npos)
52  {
53  VisAtt->SetColour(G4Colour::Yellow());
54  }
55  else
56  {
57  VisAtt->SetColour(G4Colour::Red());
58  }
59 
60  it->SetVisAttributes(VisAtt);
61  }
62  return;
63 }