File indexing completed on 2025-08-05 08:18:10
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 using namespace std;
0012
0013 PHG4PhenixDisplayAction::PHG4PhenixDisplayAction(const std::string &name)
0014 : PHG4DisplayAction(name)
0015 {
0016 }
0017
0018 PHG4PhenixDisplayAction::~PHG4PhenixDisplayAction()
0019 {
0020 for (auto &it : m_VisAttVec)
0021 {
0022 delete it;
0023 }
0024 m_VisAttVec.clear();
0025 }
0026
0027 void PHG4PhenixDisplayAction::ApplyDisplayAction(G4VPhysicalVolume * )
0028 {
0029
0030 for (const auto &it : m_LogicalVolumeMap)
0031 {
0032 G4LogicalVolume *logvol = it.first;
0033 if (logvol->GetVisAttributes())
0034 {
0035 continue;
0036 }
0037 G4VisAttributes *visatt = new G4VisAttributes();
0038 m_VisAttVec.push_back(visatt);
0039 if (it.second == "World")
0040 {
0041 visatt->SetVisibility(false);
0042 }
0043 else
0044 {
0045 cout << "unknown logical volume " << it.second << endl;
0046 gSystem->Exit(1);
0047 }
0048 logvol->SetVisAttributes(visatt);
0049 }
0050 return;
0051 }