Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:18:30

0001 #include "PHInitVertexing.h"
0002 
0003 #include <globalvertex/SvtxVertexMap_v1.h>
0004 
0005 #include <trackbase/TrkrClusterContainer.h>
0006 
0007 #include <fun4all/Fun4AllReturnCodes.h>
0008 #include <fun4all/SubsysReco.h>                   // for SubsysReco
0009 
0010 #include <phool/PHCompositeNode.h>
0011 #include <phool/PHIODataNode.h>
0012 #include <phool/PHNode.h>                         // for PHNode
0013 #include <phool/PHNodeIterator.h>
0014 #include <phool/PHObject.h>                       // for PHObject
0015 #include <phool/getClass.h>
0016 #include <phool/phool.h>                          // for PHWHERE
0017 
0018 #include <iostream>                               // for operator<<, endl
0019 
0020 using namespace std;
0021 
0022 PHInitVertexing::PHInitVertexing(const std::string& name)
0023   : SubsysReco(name)
0024 {}
0025 
0026 int PHInitVertexing::InitRun(PHCompositeNode* topNode)
0027 {
0028   return Setup(topNode);
0029 }
0030 
0031 int PHInitVertexing::process_event(PHCompositeNode* topNode)
0032 {
0033   return Process(topNode);
0034 }
0035 
0036 int PHInitVertexing::Setup(PHCompositeNode* topNode)
0037 {
0038   int ret = CreateNodes(topNode);
0039   if (ret != Fun4AllReturnCodes::EVENT_OK) return ret;
0040 
0041   ret = GetNodes(topNode);
0042   if (ret != Fun4AllReturnCodes::EVENT_OK) return ret;
0043 
0044   return Fun4AllReturnCodes::EVENT_OK;
0045 }
0046 
0047 int PHInitVertexing::CreateNodes(PHCompositeNode* topNode)
0048 {
0049   // create nodes...
0050   PHNodeIterator iter(topNode);
0051 
0052   PHCompositeNode* dstNode = static_cast<PHCompositeNode*>(iter.findFirst(
0053       "PHCompositeNode", "DST"));
0054   if (!dstNode)
0055   {
0056     cerr << PHWHERE << "DST Node missing, doing nothing." << endl;
0057     return Fun4AllReturnCodes::ABORTEVENT;
0058   }
0059   PHNodeIterator iter_dst(dstNode);
0060 
0061   // Create the SVTX node
0062   PHCompositeNode* tb_node =
0063       dynamic_cast<PHCompositeNode*>(iter_dst.findFirst("PHCompositeNode",
0064                                                         "SVTX"));
0065   if (!tb_node)
0066   {
0067     tb_node = new PHCompositeNode("SVTX");
0068     dstNode->addNode(tb_node);
0069     if (Verbosity() > 0)
0070       cout << PHWHERE << "SVTX node added" << endl;
0071   }
0072 
0073   _vertex_map = new SvtxVertexMap_v1;
0074   PHIODataNode<PHObject>* vertexes_node = new PHIODataNode<PHObject>(
0075       _vertex_map, "SvtxVertexMap", "PHObject");
0076   tb_node->addNode(vertexes_node);
0077   if (Verbosity() > 0)
0078     cout << PHWHERE << "Svtx/SvtxVertexMap node added" << endl;
0079 
0080   return Fun4AllReturnCodes::EVENT_OK;
0081 }
0082 
0083 int PHInitVertexing::GetNodes(PHCompositeNode* topNode)
0084 {
0085   //---------------------------------
0086   // Get Objects off of the Node Tree
0087   //---------------------------------
0088 
0089   _cluster_map = findNode::getClass<TrkrClusterContainer>(topNode, "TRKR_CLUSTER");
0090   if (!_cluster_map)
0091   {
0092     cerr << PHWHERE << " ERROR: Can't find node TrkrClusterContainer" << endl;
0093     return Fun4AllReturnCodes::ABORTEVENT;
0094   }
0095 
0096   // Pull the reconstructed track information off the node tree...
0097   _vertex_map = findNode::getClass<SvtxVertexMap>(topNode, "SvtxVertexMap");
0098   if (!_vertex_map)
0099   {
0100     cerr << PHWHERE << " ERROR: Can't find SvtxVertexMap." << endl;
0101     return Fun4AllReturnCodes::ABORTEVENT;
0102   }
0103 
0104   return Fun4AllReturnCodes::EVENT_OK;
0105 }