File indexing completed on 2025-08-05 08:17:47
0001 #include "PHG4EnvelopeSubsystem.h"
0002
0003 #include "PHG4EnvelopeDetector.h"
0004 #include "PHG4EnvelopeSteppingAction.h"
0005
0006 #include <g4main/PHG4HitContainer.h>
0007 #include <g4main/PHG4Subsystem.h> // for PHG4Subsystem
0008
0009 #include <phool/PHCompositeNode.h>
0010 #include <phool/PHIODataNode.h> // for PHIODataNode
0011 #include <phool/PHNode.h> // for PHNode
0012 #include <phool/PHNodeIterator.h> // for PHNodeIterator
0013 #include <phool/PHObject.h> // for PHObject
0014 #include <phool/getClass.h>
0015
0016 #include <sstream>
0017
0018 PHG4EnvelopeSubsystem::PHG4EnvelopeSubsystem(const std::string& name, const int )
0019 : PHG4Subsystem(name)
0020 , detector_(nullptr)
0021 , steppingAction_(nullptr)
0022 , material("G4_PbWO4")
0023 ,
0024 active(1)
0025 , detector_type(name)
0026 {
0027 }
0028
0029 int PHG4EnvelopeSubsystem::Init(PHCompositeNode* topNode)
0030 {
0031 PHNodeIterator iter(topNode);
0032 PHCompositeNode* dstNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "DST"));
0033
0034
0035 detector_ = new PHG4EnvelopeDetector(this, topNode, Name());
0036 detector_->SetActive(active);
0037 detector_->OverlapCheck(CheckOverlap());
0038
0039 if (active)
0040 {
0041
0042 std::string nodename;
0043 nodename = "G4HIT_ENVELOPE_" + detector_type;
0044
0045 PHG4HitContainer* crystal_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename);
0046 if (!crystal_hits)
0047 {
0048 crystal_hits = new PHG4HitContainer(nodename);
0049 PHIODataNode<PHObject>* hitNode = new PHIODataNode<PHObject>(crystal_hits, nodename, "PHObject");
0050 dstNode->addNode(hitNode);
0051 }
0052
0053
0054 steppingAction_ = new PHG4EnvelopeSteppingAction(detector_);
0055 }
0056 return 0;
0057 }
0058
0059
0060 int PHG4EnvelopeSubsystem::process_event(PHCompositeNode* topNode)
0061 {
0062
0063
0064 if (steppingAction_)
0065 {
0066 steppingAction_->SetInterfacePointers(topNode);
0067 }
0068 return 0;
0069 }
0070
0071
0072 PHG4Detector* PHG4EnvelopeSubsystem::GetDetector() const
0073 {
0074 return detector_;
0075 }
0076
0077
0078 PHG4SteppingAction* PHG4EnvelopeSubsystem::GetSteppingAction() const
0079 {
0080 return steppingAction_;
0081 }