File indexing completed on 2025-08-06 08:18:34
0001 #include "PHTrackSetMerging.h"
0002
0003 #include <trackbase_historic/SvtxTrackMap.h>
0004 #include <trackbase_historic/SvtxTrackMap_v1.h>
0005 #include <globalvertex/SvtxVertexMap.h>
0006
0007 #include <trackbase/TrkrClusterContainer.h>
0008
0009 #include <fun4all/Fun4AllReturnCodes.h>
0010 #include <fun4all/SubsysReco.h> // for SubsysReco
0011
0012 #include <phool/PHCompositeNode.h>
0013 #include <phool/PHIODataNode.h>
0014 #include <phool/PHNode.h> // for PHNode
0015 #include <phool/PHNodeIterator.h>
0016 #include <phool/PHObject.h> // for PHObject
0017 #include <phool/getClass.h>
0018 #include <phool/phool.h> // for PHWHERE
0019
0020 #include <iostream> // for operator<<, basic_os...
0021
0022 using namespace std;
0023
0024 PHTrackSetMerging::PHTrackSetMerging(const std::string& name)
0025 : SubsysReco(name)
0026 {
0027 }
0028
0029 int PHTrackSetMerging::Init(PHCompositeNode* )
0030 {
0031 return Fun4AllReturnCodes::EVENT_OK;
0032 }
0033
0034 int PHTrackSetMerging::InitRun(PHCompositeNode* topNode)
0035 {
0036 return Setup(topNode);
0037 }
0038
0039 int PHTrackSetMerging::process_event(PHCompositeNode* topNode)
0040 {
0041 return Process(topNode);
0042 }
0043
0044 int PHTrackSetMerging::End(PHCompositeNode* )
0045 {
0046 return Fun4AllReturnCodes::EVENT_OK;
0047 }
0048
0049 int PHTrackSetMerging::Setup(PHCompositeNode* topNode)
0050 {
0051 int ret = CreateNodes(topNode);
0052 if (ret != Fun4AllReturnCodes::EVENT_OK) return ret;
0053
0054 ret = GetNodes(topNode);
0055 if (ret != Fun4AllReturnCodes::EVENT_OK) return ret;
0056
0057 return Fun4AllReturnCodes::EVENT_OK;
0058 }
0059
0060 int PHTrackSetMerging::CreateNodes(PHCompositeNode* topNode)
0061 {
0062
0063 PHNodeIterator iter(topNode);
0064
0065 PHCompositeNode* dstNode = static_cast<PHCompositeNode*>(iter.findFirst(
0066 "PHCompositeNode", "DST"));
0067 if (!dstNode)
0068 {
0069 cerr << PHWHERE << "DST Node missing, doing nothing." << endl;
0070 return Fun4AllReturnCodes::ABORTEVENT;
0071 }
0072 PHNodeIterator iter_dst(dstNode);
0073
0074
0075 PHCompositeNode* tb_node =
0076 dynamic_cast<PHCompositeNode*>(iter_dst.findFirst("PHCompositeNode",
0077 "SVTX"));
0078 if (!tb_node)
0079 {
0080 tb_node = new PHCompositeNode("SVTX");
0081 dstNode->addNode(tb_node);
0082 if (Verbosity() > 0)
0083 cout << "SVTX node added" << endl;
0084 }
0085
0086 _track_map_out = new SvtxTrackMap_v1;
0087 PHIODataNode<PHObject>* tracks_node = new PHIODataNode<PHObject>(
0088 _track_map_out, _track_map_name_out, "PHObject");
0089
0090
0091
0092
0093 tb_node->addNode(tracks_node);
0094 if (Verbosity() > 0){
0095 cout << "Svtx/SvtxTrackMapOut node added" << endl;
0096
0097 }
0098
0099 return Fun4AllReturnCodes::EVENT_OK;
0100 }
0101
0102 int PHTrackSetMerging::GetNodes(PHCompositeNode* topNode)
0103 {
0104
0105
0106
0107
0108 _cluster_map = findNode::getClass<TrkrClusterContainer>(topNode, "TRKR_CLUSTER");
0109 if (!_cluster_map)
0110 {
0111 cerr << PHWHERE << " ERROR: Can't find node TRKR_CLUSTER" << endl;
0112 return Fun4AllReturnCodes::ABORTEVENT;
0113 }
0114
0115 _vertex_map = findNode::getClass<SvtxVertexMap>(topNode, "SvtxVertexMap");
0116 if (!_vertex_map)
0117 {
0118 cerr << PHWHERE << " ERROR: Can't find SvtxVertexMap." << endl;
0119 return Fun4AllReturnCodes::ABORTEVENT;
0120 }
0121
0122
0123 _track_map_in1 = findNode::getClass<SvtxTrackMap>(topNode, _track_map_name_in1);
0124 if (!_track_map_in1)
0125 {
0126 cerr << PHWHERE << " ERROR: Can't find " << _track_map_name_in1 << endl;
0127 return Fun4AllReturnCodes::ABORTEVENT;
0128 }
0129
0130 _track_map_in2 = findNode::getClass<SvtxTrackMap>(topNode, _track_map_name_in2);
0131 if (!_track_map_in2)
0132 {
0133 cerr << PHWHERE << " ERROR: Can't find " << _track_map_name_in2 << endl;
0134 return Fun4AllReturnCodes::ABORTEVENT;
0135 }
0136
0137 _track_map_out = findNode::getClass<SvtxTrackMap>(topNode, _track_map_name_out);
0138 if (!_track_map_out)
0139 {
0140 cerr << PHWHERE << " ERROR: Can't find " << _track_map_name_out << endl;
0141 return Fun4AllReturnCodes::ABORTEVENT;
0142 }
0143
0144 return Fun4AllReturnCodes::EVENT_OK;
0145 }