ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BeamLineMagnetDisplayAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file BeamLineMagnetDisplayAction.cc
2 
3 #include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
4 
5 #include <phool/phool.h>
6 
7 #include <Geant4/G4Colour.hh>
8 #include <Geant4/G4LogicalVolume.hh>
9 #include <Geant4/G4VisAttributes.hh>
10 
11 #include <TSystem.h>
12 
13 #include <iostream>
14 #include <utility> // for pair
15 
17  : PHG4DisplayAction(name)
18 {
19 }
20 
22 {
23  for (auto &it : m_VisAttVec)
24  {
25  delete it;
26  }
27  m_VisAttVec.clear();
28 }
29 
31 {
32  // check if vis attributes exist, if so someone else has set them and we do nothing
33  for (auto it : m_LogicalVolumeMap)
34  {
35  G4LogicalVolume *logvol = it.first;
36  if (logvol->GetVisAttributes())
37  {
38  continue;
39  }
40  G4VisAttributes *visatt = new G4VisAttributes();
41  visatt->SetVisibility(true);
42  visatt->SetForceSolid(true);
43  m_VisAttVec.push_back(visatt); // for later deletion
44  if (it.second == "DIPOLE")
45  {
46  visatt->SetColour(G4Color(0.2, 0.8, 0.2, 0.8));
47  }
48  else if (it.second == "FIELDVOLUME" || it.second == "OFF")
49  {
50  visatt->SetVisibility(false);
51  visatt->SetForceSolid(false);
52  }
53  else if (it.second == "QUADRUPOLE")
54  {
55  visatt->SetColour(G4Color(0., 0.3, 0.7, 0.8));
56  }
57  else if (it.second == "SEXTUPOLE")
58  {
59  visatt->SetColour(G4Color(1., 0.5, 0.7, 0.8));
60  }
61  else
62  {
63  std::cout << PHWHERE << "unknown logical volume " << it.second << std::endl;
64  gSystem->Exit(1);
65  }
66  logvol->SetVisAttributes(visatt);
67  }
68  return;
69 }