Back to home page

sPhenix code displayed by LXR

 
 

    


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

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