File indexing completed on 2025-08-05 08:18:06
0001 #include "PHG4InttDisplayAction.h"
0002
0003 #include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
0004
0005 #include <TSystem.h>
0006
0007 #include <Geant4/G4Colour.hh> // for G4Colour
0008 #include <Geant4/G4LogicalVolume.hh>
0009 #include <Geant4/G4String.hh> // for G4String
0010 #include <Geant4/G4VisAttributes.hh>
0011
0012 #include <iostream>
0013 #include <utility> // for pair
0014
0015 PHG4InttDisplayAction::PHG4InttDisplayAction(const std::string &name)
0016 : PHG4DisplayAction(name)
0017 {
0018 }
0019
0020 PHG4InttDisplayAction::~PHG4InttDisplayAction()
0021 {
0022 for (auto &it : m_VisAttVec)
0023 {
0024 delete it;
0025 }
0026 m_VisAttVec.clear();
0027 }
0028
0029 void PHG4InttDisplayAction::ApplyDisplayAction(G4VPhysicalVolume * )
0030 {
0031
0032
0033 G4Colour colour_air(0.0, 0.0, 0.0, 0.0);
0034 G4Colour colour_CFRP(0.4, 0.4, 0.4, 1);
0035 G4Colour colour_endcap(0.0, 0.0, 1.0, 0.2);
0036 G4Colour colour_endcap_Al(0.3, 0.0, 1.0, 0.4);
0037 G4Colour colour_endcap_C(0.4, 0.4, 0.4, 0.4);
0038 G4Colour colour_copper(0.7, 0.4, 0, 1);
0039
0040 for (const auto &it : m_LogicalVolumeMap)
0041 {
0042 G4LogicalVolume *logvol = it.first;
0043 if (logvol->GetVisAttributes())
0044 {
0045 continue;
0046 }
0047
0048 G4VisAttributes *visatt = new G4VisAttributes();
0049 visatt->SetVisibility(true);
0050 visatt->SetForceSolid(true);
0051 m_VisAttVec.push_back(visatt);
0052
0053 if (it.second == "FPHX")
0054 {
0055 visatt->SetColour(G4Colour(1.0, 0.843, 0.0, 0.5));
0056 visatt->SetVisibility(true);
0057 }
0058 else if (it.second == "Ladder" || it.second == "FPHXContainer" || it.second == "FPHXGlueContainer" || it.second == "StaveBox")
0059 {
0060 visatt->SetColour(colour_air);
0061 visatt->SetForceWireframe(true);
0062 visatt->SetVisibility(false);
0063 }
0064 else if (it.second == "Rail" ||
0065 it.second == "StaveGlueBox")
0066 {
0067 visatt->SetColour(G4Colour::Cyan());
0068
0069 visatt->SetVisibility(true);
0070 }
0071 else if (it.second == "RohaCell")
0072 {
0073 visatt->SetColour(G4Colour(0.9, 0.9, 0.9, 0.5));
0074 visatt->SetVisibility(true);
0075 }
0076 else if (it.second == "SiActive")
0077 {
0078 visatt->SetColour(G4Colour(1.0, 0, 0.0, 0.5));
0079 visatt->SetVisibility(true);
0080 }
0081 else if (it.second == "SiInActive")
0082 {
0083 visatt->SetColour(G4Colour(0, 0, 1, 0.5));
0084 visatt->SetVisibility(true);
0085 }
0086 else if (it.second == "StaveCooler" ||
0087 it.second == "StaveCurve" ||
0088 it.second == "StavePipe" ||
0089 it.second == "StaveStraightOuter" ||
0090 it.second == "Skin")
0091 {
0092 visatt->SetColour(colour_CFRP);
0093 visatt->SetVisibility(true);
0094 }
0095 else if (it.second == "StaveStraightInner")
0096 {
0097 visatt->SetColour(G4Colour::Grey());
0098 visatt->SetVisibility(true);
0099 }
0100 else if (it.second == "StaveWater")
0101 {
0102 visatt->SetColour(G4Colour::Blue());
0103 visatt->SetVisibility(true);
0104 }
0105 else if (it.second.find("Endcap") != std::string::npos)
0106 {
0107 if (it.second.find("_Al") != std::string::npos)
0108 {
0109 visatt->SetColour(colour_endcap_Al);
0110 }
0111 else if (it.second.find("_C") != std::string::npos)
0112 {
0113 visatt->SetColour(colour_endcap_C);
0114 }
0115 else
0116 {
0117 visatt->SetColour(colour_endcap);
0118 }
0119 visatt->SetVisibility(true);
0120 }
0121 else if (it.second.find("Glue") != std::string::npos)
0122 {
0123 visatt->SetColour(G4Colour(0.1, 0.1, 0.1, 0.8));
0124 visatt->SetVisibility(true);
0125 }
0126 else if (it.second.find("Copper") != std::string::npos)
0127 {
0128 visatt->SetColour(colour_copper);
0129 visatt->SetVisibility(true);
0130 }
0131 else if (it.second.find("Kapton") != std::string::npos)
0132 {
0133 visatt->SetColour(G4Colour(0.0, 0.590, 1.0, 0.5));
0134 visatt->SetVisibility(true);
0135 }
0136 else
0137 {
0138 std::cout << "did not assign color to " << it.first->GetName()
0139 << " under " << it.second << std::endl;
0140 gSystem->Exit(1);
0141 }
0142 logvol->SetVisAttributes(visatt);
0143 }
0144 return;
0145 }