Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:18:16

0001 #include "PHG4TpcDisplayAction.h"
0002 
0003 #include <g4main/PHG4ColorDefs.h>
0004 #include <g4main/PHG4DisplayAction.h>  // for PHG4DisplayAction
0005 
0006 #include <Geant4/G4Colour.hh>
0007 #include <Geant4/G4LogicalVolume.hh>
0008 #include <Geant4/G4String.hh>  // for G4String
0009 #include <Geant4/G4VisAttributes.hh>
0010 
0011 #include <iostream>
0012 #include <utility>  // for pair
0013 
0014 PHG4TpcDisplayAction::PHG4TpcDisplayAction(const std::string &name)
0015   : PHG4DisplayAction(name)
0016 {
0017 }
0018 
0019 PHG4TpcDisplayAction::~PHG4TpcDisplayAction()
0020 {
0021   for (auto &it : m_VisAttVec)
0022   {
0023     delete it;
0024   }
0025   m_VisAttVec.clear();
0026 }
0027 
0028 void PHG4TpcDisplayAction::ApplyDisplayAction(G4VPhysicalVolume * /*physvol*/)
0029 {
0030   static const G4Colour color[] = {PHG4TpcColorDefs::tpc_cu_color,
0031                                    PHG4TpcColorDefs::tpc_pcb_color,
0032                                    PHG4TpcColorDefs::tpc_honeycomb_color,
0033                                    PHG4TpcColorDefs::tpc_cu_color,
0034                                    PHG4TpcColorDefs::tpc_pcb_color,
0035                                    PHG4TpcColorDefs::tpc_kapton_color,
0036                                    PHG4TpcColorDefs::tpc_cu_color,
0037                                    PHG4TpcColorDefs::tpc_kapton_color,
0038                                    PHG4TpcColorDefs::tpc_cu_color};
0039   // check if vis attributes exist, if so someone else has set them and we do nothing
0040   for (const auto &it : m_LogicalVolumeMap)
0041   {
0042     G4LogicalVolume *logvol = it.first;
0043     if (logvol->GetVisAttributes())
0044     {
0045       continue;
0046     }
0047     G4VisAttributes *visatt = new G4VisAttributes();
0048     visatt->SetVisibility(true);
0049     visatt->SetForceSolid(true);
0050     m_VisAttVec.push_back(visatt);  // for later deletion
0051     if (it.second == "TpcEnvelope")
0052     {
0053       visatt->SetVisibility(false);
0054     }
0055     else if (it.second == "TpcGas")
0056     {
0057       visatt->SetColor(PHG4TpcColorDefs::tpc_gas_color);
0058     }
0059     else if (it.second == "TpcHoneyComb")
0060     {
0061       visatt->SetColor(PHG4TpcColorDefs::tpc_honeycomb_color);
0062     }
0063     else if (it.second == "TpcWindow")
0064     {
0065       visatt->SetColor(PHG4TpcColorDefs::tpc_pcb_color);
0066     }
0067     else
0068     {
0069       std::cout << "did not assign specific color to " << it.first->GetName()
0070                 << " under " << it.second << ".  Defaulting to TpcWindow color." << std::endl;
0071       visatt->SetColor(PHG4TpcColorDefs::tpc_pcb_color);
0072 
0073       // gSystem->Exit(1);
0074       // exit(1);
0075     }
0076     logvol->SetVisAttributes(visatt);
0077   }
0078   for (unsigned int i = 0; i < m_TpcInnerLayersVec.size(); i++)
0079   {
0080     G4VisAttributes *visatt = new G4VisAttributes();
0081     visatt->SetVisibility(true);
0082     visatt->SetForceSolid(true);
0083     m_VisAttVec.push_back(visatt);  // for later deletion
0084     visatt->SetColor(color[i]);
0085     m_TpcInnerLayersVec[i]->SetVisAttributes(visatt);
0086   }
0087   for (unsigned int i = 0; i < m_TpcOuterLayersVec.size(); i++)
0088   {
0089     G4VisAttributes *visatt = new G4VisAttributes();
0090     visatt->SetVisibility(true);
0091     visatt->SetForceSolid(true);
0092     m_VisAttVec.push_back(visatt);  // for later deletion
0093     visatt->SetColor(color[i]);
0094     m_TpcOuterLayersVec[i]->SetVisAttributes(visatt);
0095   }
0096 
0097   return;
0098 }