Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:19:25

0001 // This is the new trackbase container version
0002 
0003 /*!
0004  * \file PHG4VertexSelection.cc
0005  * \author Hugo Pereira Da Costa <hugo.pereira-da-costa@cea.fr>
0006  */
0007 
0008 #include "PHG4VertexSelection.h"
0009 
0010 #include "PHG4TruthInfoContainer.h"
0011 #include "PHG4VtxPoint.h"
0012 
0013 #include <fun4all/Fun4AllReturnCodes.h>
0014 
0015 #include <phool/getClass.h>
0016 
0017 #include <iostream>  // for operator<<, basic_ostream, endl
0018 
0019 //____________________________________________________________________________
0020 PHG4VertexSelection::PHG4VertexSelection(const std::string &name)
0021   : SubsysReco(name)
0022   , PHParameterInterface(name)
0023 {
0024   InitializeParameters();
0025 }
0026 
0027 //____________________________________________________________________________
0028 int PHG4VertexSelection::InitRun(PHCompositeNode * /*topNode*/)
0029 {
0030   UpdateParametersWithMacro();
0031 
0032   // load parameters
0033   m_vertex_zcut = get_double_param("vertex_zcut");
0034 
0035   // printout
0036   std::cout
0037       << "PHG4VertexSelection::InitRun\n"
0038       << " m_vertex_zcut: " << m_vertex_zcut << " cm\n"
0039       << std::endl;
0040 
0041   return Fun4AllReturnCodes::EVENT_OK;
0042 }
0043 
0044 //____________________________________________________________________________
0045 int PHG4VertexSelection::process_event(PHCompositeNode *topNode)
0046 {
0047   // g4 truth info
0048   auto g4truthinfo = findNode::getClass<PHG4TruthInfoContainer>(topNode, "G4TruthInfo");
0049 
0050   // main vertex
0051   const auto main_vertex_id = g4truthinfo->GetPrimaryVertexIndex();
0052   const auto vertex = g4truthinfo->GetPrimaryVtx(main_vertex_id);
0053   if (!vertex)
0054   {
0055     return false;
0056   }
0057 
0058   // check vertex position along the beam
0059   return (m_vertex_zcut > 0 && std::abs(vertex->get_z()) > m_vertex_zcut) ? Fun4AllReturnCodes::DISCARDEVENT : Fun4AllReturnCodes::EVENT_OK;
0060 }
0061 
0062 //___________________________________________________________________________
0063 void PHG4VertexSelection::SetDefaultParameters()
0064 {
0065   set_default_double_param("vertex_zcut", 10);
0066 }