Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4CylinderDisplayAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4CylinderDisplayAction.cc
2 
3 #include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
4 #include <g4main/PHG4Utils.h>
5 
6 #include <phparameter/PHParameters.h>
7 
8 #include <Geant4/G4Colour.hh>
9 #include <Geant4/G4LogicalVolume.hh>
10 #include <Geant4/G4VisAttributes.hh>
11 
12 #include <cmath>
13 
14 class G4VPhysicalVolume;
15 
17  : PHG4DisplayAction(name)
18  , m_Params(pars)
19  , m_MyVolume(nullptr)
20  , m_VisAtt(nullptr)
21  , m_Colour(nullptr)
22 {
23 }
24 
26 {
27  delete m_VisAtt;
28  delete m_Colour;
29 }
30 
32 {
33  if (m_MyVolume->GetVisAttributes())
34  {
35  return;
36  }
37  m_VisAtt = new G4VisAttributes();
38  if (m_Params->get_int_param("blackhole"))
39  {
40  PHG4Utils::SetColour(m_VisAtt, "BlackHole");
41  m_VisAtt->SetVisibility(false);
42  m_VisAtt->SetForceSolid(false);
43  }
44  else
45  {
47  m_VisAtt->SetVisibility(true);
48  m_VisAtt->SetForceSolid(true);
49  }
50  if (m_Colour)
51  {
52  m_VisAtt->SetColour(m_Colour->GetRed(),
53  m_Colour->GetGreen(),
54  m_Colour->GetBlue(),
55  m_Colour->GetAlpha());
56  m_VisAtt->SetVisibility(true);
57  m_VisAtt->SetForceSolid(true);
58  }
59  // drawing 200 segments per circle makes it look smoother than default
60  m_VisAtt->SetForceLineSegmentsPerCircle(200);
61  m_MyVolume->SetVisAttributes(m_VisAtt);
62  return;
63 }
64 
65 void PHG4CylinderDisplayAction::SetColor(const double red, const double green, const double blue, const double alpha)
66 {
67  if (std::isfinite(red) && std::isfinite(green) && std::isfinite(blue) && std::isfinite(alpha))
68  {
69  m_Colour = new G4Colour(red, green, blue, alpha);
70  }
71  return;
72 }