File indexing completed on 2025-08-06 08:19:04
0001 #include "PHG4ZDCDisplayAction.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 PHG4ZDCDisplayAction::PHG4ZDCDisplayAction(const std::string &name)
0015 : PHG4DisplayAction(name)
0016 {
0017 }
0018
0019 PHG4ZDCDisplayAction::~PHG4ZDCDisplayAction()
0020 {
0021 for (auto &it : m_VisAttVec)
0022 {
0023 delete it;
0024 }
0025 m_VisAttVec.clear();
0026 }
0027
0028 void PHG4ZDCDisplayAction::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 == "Absorber" || it.second == "Window")
0043 {
0044 visatt->SetColour(G4Colour::Blue());
0045 }
0046 else if (it.second == "Envelope" || it.second == "fiber_plate_air")
0047 {
0048 visatt->SetVisibility(false);
0049 visatt->SetForceSolid(false);
0050 }
0051 else if (it.second == "Fiber" ||
0052 it.second == "Scint_solid" ||
0053 it.second == "FiberPlate")
0054 {
0055 visatt->SetColour(G4Colour::Cyan());
0056 }
0057 else if (it.second == "FrontBackPlate")
0058 {
0059 visatt->SetColour(G4Colour::Red());
0060 }
0061 else if (it.second == "SMD")
0062 {
0063 visatt->SetColour(G4Colour::Yellow());
0064 }
0065 else
0066 {
0067 std::cout << GetName() << " unknown logical volume " << it.second << std::endl;
0068 gSystem->Exit(1);
0069 }
0070 logvol->SetVisAttributes(visatt);
0071 }
0072 return;
0073 }