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