File indexing completed on 2025-08-06 08:18:53
0001 #include "PHG4BbcDisplayAction.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 PHG4BbcDisplayAction::PHG4BbcDisplayAction(const std::string &name)
0015 : PHG4DisplayAction(name)
0016 {
0017 }
0018
0019 PHG4BbcDisplayAction::~PHG4BbcDisplayAction()
0020 {
0021 for (auto &it : m_VisAttVec)
0022 {
0023 delete it;
0024 }
0025 m_VisAttVec.clear();
0026 }
0027
0028 void PHG4BbcDisplayAction::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 == "Bbc_Breeder_Module" ||
0043 it.second == "Bbc_Support_Post" ||
0044 it.second == "Bbc_Support_Arm")
0045 {
0046 visatt->SetColour(G4Colour::Green());
0047 }
0048 else if (it.second == "Bbc_Cover_Plates" ||
0049 it.second == "Bbc_Inner_Shell" ||
0050 it.second == "Bbc_Outer_Shell" ||
0051 it.second == "Bbc_attach_plate")
0052 {
0053 visatt->SetColour(G4Colour::Gray());
0054 }
0055 else if (it.second == "Bbc_quartz")
0056 {
0057 visatt->SetColour(G4Colour::Cyan());
0058 }
0059 else if (it.second == "Bbc_PMT")
0060 {
0061 visatt->SetColour(G4Colour::Blue());
0062 }
0063 else if (it.second == "Bbc_Shell" || it.second == "Bbc_Front_Plate")
0064 {
0065 visatt->SetColour(0.5, 0.5, 0.5, 0.4);
0066 }
0067 else if (it.second == "Bbc_CableCond")
0068 {
0069 visatt->SetColour(G4Colour::Yellow());
0070 }
0071 else if (it.second == "Bbc_CableShield" ||
0072 it.second == "Bbc_Base_Plates" ||
0073 it.second == "Bbc_Sidesupport_Plates" ||
0074 it.second == "Bbc_Gusset0_Plates" ||
0075 it.second == "Bbc_Gusset1_Plates" ||
0076 it.second == "Bbc_Gusset2_Plates" ||
0077 it.second == "Bbc_Splice_Plates")
0078 {
0079 visatt->SetColour(G4Colour::White());
0080 }
0081 else
0082 {
0083 std::cout << "PHG4BbcDisplayAction::ApplyDisplayAction unknown logical volume " << it.second << " in " << GetName() << std::endl;
0084 gSystem->Exit(1);
0085 }
0086 logvol->SetVisAttributes(visatt);
0087 }
0088 return;
0089 }