File indexing completed on 2025-08-05 08:17:52
0001 #include "PHG4sPHENIXMagnetDisplayAction.h"
0002
0003 #include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
0004
0005 #include <Geant4/G4Colour.hh>
0006 #include <Geant4/G4LogicalVolume.hh>
0007 #include <Geant4/G4VisAttributes.hh>
0008
0009 #include <TSystem.h>
0010
0011 #include <iostream>
0012 #include <utility> // for pair
0013
0014 PHG4sPHENIXMagnetDisplayAction::PHG4sPHENIXMagnetDisplayAction(const std::string &name)
0015 : PHG4DisplayAction(name)
0016 {
0017 }
0018
0019 PHG4sPHENIXMagnetDisplayAction::~PHG4sPHENIXMagnetDisplayAction()
0020 {
0021 for (auto &it : m_VisAttVec)
0022 {
0023 delete it;
0024 }
0025 m_VisAttVec.clear();
0026 }
0027
0028 void PHG4sPHENIXMagnetDisplayAction::ApplyDisplayAction(G4VPhysicalVolume * )
0029 {
0030
0031 for (const auto &it : m_LogicalVolumeMap)
0032 {
0033 G4LogicalVolume *logvol = it.first;
0034 if (logvol->GetVisAttributes())
0035 {
0036 continue;
0037 }
0038 G4VisAttributes *visatt = new G4VisAttributes();
0039 visatt->SetVisibility(true);
0040 visatt->SetForceSolid(true);
0041 m_VisAttVec.push_back(visatt);
0042 if (it.second == "CRYOSTAT" || it.second == "THERM" || it.second == "COILSUP" || it.second == "COIL" || it.second == "CONNECTOR")
0043 {
0044 visatt->SetColour(G4Colour::Magenta());
0045 }
0046 else if (it.second == "CRYOINT" || it.second == "THERMVAC")
0047 {
0048
0049
0050 visatt->SetColour(G4Colour::Gray());
0051 }
0052 else if (it.second == "BusbarD")
0053 {
0054 visatt->SetColour(G4Colour::Brown());
0055 }
0056 else
0057 {
0058 std::cout << GetName() << " unknown logical volume " << it.second << std::endl;
0059 gSystem->Exit(1);
0060 }
0061 logvol->SetVisAttributes(visatt);
0062 }
0063 return;
0064 }