File indexing completed on 2025-12-16 09:22:00
0001 #include "PHG4PhenixDisplayAction.h"
0002
0003 #include <Geant4/G4LogicalVolume.hh>
0004 #include <Geant4/G4VisAttributes.hh>
0005
0006 #include <TSystem.h>
0007
0008 #include <iostream>
0009 #include <utility> // for pair
0010
0011 PHG4PhenixDisplayAction::PHG4PhenixDisplayAction(const std::string &name)
0012 : PHG4DisplayAction(name)
0013 {
0014 }
0015
0016 PHG4PhenixDisplayAction::~PHG4PhenixDisplayAction()
0017 {
0018 for (auto &it : m_VisAttVec)
0019 {
0020 delete it;
0021 }
0022 m_VisAttVec.clear();
0023 }
0024
0025 void PHG4PhenixDisplayAction::ApplyDisplayAction(G4VPhysicalVolume * )
0026 {
0027
0028 for (const auto &it : m_LogicalVolumeMap)
0029 {
0030 G4LogicalVolume *logvol = it.first;
0031 if (logvol->GetVisAttributes())
0032 {
0033 continue;
0034 }
0035 G4VisAttributes *visatt = new G4VisAttributes();
0036 m_VisAttVec.push_back(visatt);
0037 if (it.second == "World")
0038 {
0039 visatt->SetVisibility(false);
0040 }
0041 else
0042 {
0043 std::cout << "unknown logical volume " << it.second << std::endl;
0044 gSystem->Exit(1);
0045 }
0046 logvol->SetVisAttributes(visatt);
0047 }
0048 return;
0049 }