File indexing completed on 2025-08-05 08:17:41
0001 #include "PHG4BbcSubsystem.h"
0002
0003 #include "PHG4BbcDetector.h"
0004 #include "PHG4BbcDisplayAction.h"
0005 #include "PHG4BbcSteppingAction.h"
0006
0007 #include <phparameter/PHParameters.h>
0008
0009 #include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
0010 #include <g4main/PHG4HitContainer.h>
0011 #include <g4main/PHG4SteppingAction.h> // for PHG4SteppingAction
0012
0013 #include <phool/PHCompositeNode.h>
0014 #include <phool/PHIODataNode.h> // for PHIODataNode
0015 #include <phool/PHNode.h> // for PHNode
0016 #include <phool/PHNodeIterator.h> // for PHNodeIterator
0017 #include <phool/PHObject.h> // for PHObject
0018 #include <phool/getClass.h>
0019 #include <phool/phool.h>
0020
0021 #include <iostream> // for operator<<, basic_ostream, endl
0022 #include <set> // for set
0023 #include <sstream>
0024
0025
0026 PHG4BbcSubsystem::PHG4BbcSubsystem(const std::string &name)
0027 : PHG4DetectorSubsystem(name)
0028 {
0029 InitializeParameters();
0030 }
0031
0032
0033 PHG4BbcSubsystem::~PHG4BbcSubsystem()
0034 {
0035 delete m_DisplayAction;
0036 }
0037
0038
0039 int PHG4BbcSubsystem::InitRunSubsystem(PHCompositeNode *topNode)
0040 {
0041 if (Verbosity() > 1)
0042 {
0043 std::cout << PHWHERE << " Initializing BBC Subsystem" << std::endl;
0044 }
0045
0046 PHNodeIterator iter(topNode);
0047 PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
0048
0049
0050 m_DisplayAction = new PHG4BbcDisplayAction(Name());
0051
0052 m_Detector = new PHG4BbcDetector(this, topNode, GetParams(), Name());
0053 m_Detector->SuperDetector(SuperDetector());
0054 m_Detector->OverlapCheck(CheckOverlap());
0055
0056 if (GetParams()->get_int_param("active"))
0057 {
0058 std::set<std::string> nodes;
0059 PHNodeIterator dstIter(dstNode);
0060 PHCompositeNode *DetNode = dstNode;
0061 if (SuperDetector() != "NONE" && !SuperDetector().empty())
0062 {
0063 PHNodeIterator iter_dst(dstNode);
0064 DetNode = dynamic_cast<PHCompositeNode *>(iter_dst.findFirst("PHCompositeNode", SuperDetector()));
0065
0066 if (!DetNode)
0067 {
0068 DetNode = new PHCompositeNode(SuperDetector());
0069 dstNode->addNode(DetNode);
0070 }
0071 }
0072
0073 std::string detector_suffix = SuperDetector();
0074 if (detector_suffix == "NONE")
0075 {
0076 detector_suffix = Name();
0077 }
0078
0079 m_HitNodeName = "G4HIT_" + detector_suffix;
0080 nodes.insert(m_HitNodeName);
0081 m_SupportNodeName = "G4HIT_SUPPORT_" + detector_suffix;
0082 if (GetParams()->get_int_param("supportactive"))
0083 {
0084 nodes.insert(m_SupportNodeName);
0085 }
0086 for (const auto &nodename : nodes)
0087 {
0088 PHG4HitContainer *g4_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename);
0089 if (!g4_hits)
0090 {
0091 g4_hits = new PHG4HitContainer(nodename);
0092 DetNode->addNode(new PHIODataNode<PHObject>(g4_hits, nodename, "PHObject"));
0093 }
0094 }
0095
0096 m_SteppingAction = new PHG4BbcSteppingAction(m_Detector, GetParams());
0097 m_SteppingAction->SetHitNodeName("G4HIT", m_HitNodeName);
0098 m_SteppingAction->SetHitNodeName("G4HIT_SUPPORT", m_SupportNodeName);
0099 }
0100 else if (GetParams()->get_int_param("blackhole"))
0101 {
0102 m_SteppingAction = new PHG4BbcSteppingAction(m_Detector, GetParams());
0103 }
0104
0105 return 0;
0106 }
0107
0108
0109 int PHG4BbcSubsystem::process_event(PHCompositeNode *topNode)
0110 {
0111
0112
0113 if (m_SteppingAction)
0114 {
0115 m_SteppingAction->SetInterfacePointers(topNode);
0116 }
0117 return 0;
0118 }
0119
0120 void PHG4BbcSubsystem::Print(const std::string &what) const
0121 {
0122 std::cout << Name() << " Parameters: " << std::endl;
0123 GetParams()->Print();
0124 if (m_Detector)
0125 {
0126 m_Detector->Print(what);
0127 }
0128 if (m_SteppingAction)
0129 {
0130 m_SteppingAction->Print(what);
0131 }
0132 return;
0133 }
0134
0135
0136 PHG4Detector *PHG4BbcSubsystem::GetDetector() const
0137 {
0138 return m_Detector;
0139 }
0140
0141 void PHG4BbcSubsystem::SetDefaultParameters()
0142 {
0143
0144
0145
0146
0147 }