Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:19:02

0001 #include "PHG4SectorDisplayAction.h"
0002 
0003 #include <g4main/PHG4DisplayAction.h>  // for PHG4DisplayAction
0004 #include <g4main/PHG4Utils.h>
0005 
0006 #include <Geant4/G4Colour.hh>
0007 #include <Geant4/G4LogicalVolume.hh>
0008 #include <Geant4/G4Material.hh>
0009 #include <Geant4/G4String.hh>  // for G4String
0010 #include <Geant4/G4VisAttributes.hh>
0011 
0012 #include <TSystem.h>
0013 
0014 #include <iostream>
0015 #include <utility>  // for pair
0016 
0017 PHG4SectorDisplayAction::PHG4SectorDisplayAction(const std::string &name)
0018   : PHG4DisplayAction(name)
0019 {
0020 }
0021 
0022 PHG4SectorDisplayAction::~PHG4SectorDisplayAction()
0023 {
0024   for (auto &it : m_VisAttVec)
0025   {
0026     delete it;
0027   }
0028   m_VisAttVec.clear();
0029 }
0030 
0031 void PHG4SectorDisplayAction::ApplyDisplayAction(G4VPhysicalVolume * /*physvol*/)
0032 {
0033   // check if vis attributes exist, if so someone else has set them and we do nothing
0034   for (const auto &it : m_LogicalVolumeMap)
0035   {
0036     G4LogicalVolume *logvol = it.first;
0037     if (logvol->GetVisAttributes())
0038     {
0039       continue;
0040     }
0041     G4VisAttributes *visatt = new G4VisAttributes();
0042     visatt->SetVisibility(true);
0043     visatt->SetForceSolid(true);
0044     m_VisAttVec.push_back(visatt);  // for later deletion
0045     if (it.second == "SectorDetector")
0046     {
0047       PHG4Utils::SetColour(visatt, it.first->GetMaterial()->GetName());
0048     }
0049     else if (it.second == "DetectorBox")
0050     {
0051       visatt->SetColour(G4Colour::White());
0052       visatt->SetForceWireframe(true);
0053       visatt->SetForceLineSegmentsPerCircle(50);
0054     }
0055     else
0056     {
0057       std::cout << "unknown logical volume " << it.second << std::endl;
0058       gSystem->Exit(1);
0059     }
0060     logvol->SetVisAttributes(visatt);
0061   }
0062   return;
0063 }