File indexing completed on 2025-08-05 08:17:51
0001 #include "PHG4SectorSubsystem.h"
0002 #include "PHG4SectorDetector.h"
0003 #include "PHG4SectorDisplayAction.h"
0004 #include "PHG4SectorSteppingAction.h"
0005
0006 #include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
0007 #include <g4main/PHG4HitContainer.h>
0008 #include <g4main/PHG4SteppingAction.h> // for PHG4SteppingAction
0009 #include <g4main/PHG4Subsystem.h> // for PHG4Subsystem
0010
0011 #include <phool/PHCompositeNode.h>
0012 #include <phool/PHIODataNode.h> // for PHIODataNode
0013 #include <phool/PHNode.h> // for PHNode
0014 #include <phool/PHNodeIterator.h> // for PHNodeIterator
0015 #include <phool/PHObject.h> // for PHObject
0016 #include <phool/getClass.h>
0017
0018 #include <sstream>
0019
0020 class PHG4Detector;
0021
0022
0023 PHG4SectorSubsystem::PHG4SectorSubsystem(const std::string& name)
0024 : PHG4Subsystem(name)
0025 {
0026 }
0027
0028
0029 PHG4SectorSubsystem::~PHG4SectorSubsystem()
0030 {
0031 delete m_DisplayAction;
0032 }
0033
0034
0035 int PHG4SectorSubsystem::Init(PHCompositeNode* topNode)
0036 {
0037 PHNodeIterator iter(topNode);
0038 PHCompositeNode* dstNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "DST"));
0039
0040
0041 m_DisplayAction = new PHG4SectorDisplayAction(Name());
0042
0043 m_Detector = new PHG4SectorDetector(this, topNode, Name());
0044 m_Detector->geom = geom;
0045 m_Detector->SuperDetector(superdetector);
0046 m_Detector->OverlapCheck(CheckOverlap());
0047
0048 if (geom.GetNumActiveLayers())
0049 {
0050 std::ostringstream nodename;
0051 if (superdetector != "NONE")
0052 {
0053 nodename << "G4HIT_" << superdetector;
0054 }
0055 else
0056 {
0057 nodename << "G4HIT_" << Name();
0058 }
0059
0060 PHG4HitContainer* block_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename.str());
0061 if (!block_hits)
0062 {
0063 dstNode->addNode(new PHIODataNode<PHObject>(new PHG4HitContainer(nodename.str()), nodename.str(), "PHObject"));
0064 }
0065
0066 m_SteppingAction = new PHG4SectorSteppingAction(m_Detector);
0067 }
0068 return 0;
0069 }
0070
0071
0072 int PHG4SectorSubsystem::process_event(PHCompositeNode* topNode)
0073 {
0074
0075
0076 if (m_SteppingAction)
0077 {
0078 m_SteppingAction->SetInterfacePointers(topNode);
0079 }
0080 return 0;
0081 }
0082
0083
0084 PHG4Detector*
0085 PHG4SectorSubsystem::GetDetector() const
0086 {
0087 return m_Detector;
0088 }