Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:17:53

0001 #include "PHG4EPDDisplayAction.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 <iostream>  // for operator<<, basic_ostream, endl
0010 #include <string>
0011 #include <utility>  // for pair
0012 
0013 PHG4EPDDisplayAction::PHG4EPDDisplayAction(const std::string &name)
0014   : PHG4DisplayAction(name)
0015 {
0016 }
0017 
0018 PHG4EPDDisplayAction::~PHG4EPDDisplayAction()
0019 {
0020   for (auto &it : m_VisAttVec)
0021   {
0022     delete it;
0023   }
0024   m_VisAttVec.clear();
0025 }
0026 
0027 void PHG4EPDDisplayAction::ApplyDisplayAction(G4VPhysicalVolume * /*physvol*/)
0028 {
0029   for (const auto &it : m_LogicalVolumeMap)
0030   {
0031     G4LogicalVolume *logvol = it.first;
0032     if (logvol->GetVisAttributes())
0033     {
0034       continue;
0035     }
0036     G4VisAttributes *visatt = new G4VisAttributes();
0037     visatt->SetVisibility(true);
0038     visatt->SetForceSolid(true);
0039     m_VisAttVec.push_back(visatt);  // for later deletion
0040     if (it.second == "Absorber")
0041     {
0042       visatt->SetColour(G4Colour::Blue());
0043     }
0044     if (it.second.find("EPD_tile") != std::string::npos)
0045     {
0046       visatt->SetColour(G4Colour::Red());
0047     }
0048     else
0049     {
0050       std::cout << GetName() << " unknown logical volume " << it.second << std::endl;
0051       visatt->SetColour(G4Colour::White());
0052     }
0053     logvol->SetVisAttributes(visatt);
0054   }
0055   return;
0056 }