EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4ConeDisplayAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4ConeDisplayAction.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 #include <string>
14 
15 class G4VPhysicalVolume;
16 
18  : PHG4DisplayAction(name)
19  , m_Params(pars)
20  , m_MyVolume(nullptr)
21  , m_VisAtt(nullptr)
22  , m_Colour(nullptr)
23 {
24 }
25 
27 {
28  delete m_VisAtt;
29  delete m_Colour;
30 }
31 
32 void PHG4ConeDisplayAction::ApplyDisplayAction(G4VPhysicalVolume */*physvol*/)
33 {
34  if (m_MyVolume->GetVisAttributes())
35  {
36  return;
37  }
38  m_VisAtt = new G4VisAttributes();
39  if (m_Params->get_int_param("blackhole"))
40  {
41  PHG4Utils::SetColour(m_VisAtt, "BlackHole");
42  m_VisAtt->SetVisibility(false);
43  m_VisAtt->SetForceSolid(false);
44  }
45  else
46  {
48  m_VisAtt->SetVisibility(true);
49  m_VisAtt->SetForceSolid(true);
50  }
51  if (m_Colour)
52  {
53  m_VisAtt->SetColour(m_Colour->GetRed(),
54  m_Colour->GetGreen(),
55  m_Colour->GetBlue(),
56  m_Colour->GetAlpha());
57  m_VisAtt->SetVisibility(true);
58  m_VisAtt->SetForceSolid(true);
59  }
60  // drawing 200 segments per circle makes it look smoother than default
61  m_VisAtt->SetForceLineSegmentsPerCircle(200);
62  m_MyVolume->SetVisAttributes(m_VisAtt);
63  return;
64 }
65 
66 void PHG4ConeDisplayAction::SetColor(const double red, const double green, const double blue, const double alpha)
67 {
68  if (std::isfinite(red) && std::isfinite(green) && std::isfinite(blue) && std::isfinite(alpha))
69  {
70  m_Colour = new G4Colour(red, green, blue, alpha);
71  }
72  return;
73 }