Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:18:04

0001 #include "G4VtxNtuple.h"
0002 
0003 #include <g4main/PHG4TruthInfoContainer.h>
0004 #include <g4main/PHG4VtxPoint.h>
0005 
0006 #include <fun4all/Fun4AllHistoManager.h>
0007 #include <fun4all/SubsysReco.h>  // for SubsysReco
0008 
0009 #include <phool/getClass.h>
0010 
0011 #include <TNtuple.h>
0012 
0013 #include <sstream>
0014 
0015 using namespace std;
0016 
0017 G4VtxNtuple::G4VtxNtuple(const std::string &name, const std::string &filename)
0018   : SubsysReco(name)
0019   , m_FileName(filename)
0020 {
0021 }
0022 
0023 G4VtxNtuple::~G4VtxNtuple()
0024 {
0025   delete hm;
0026 }
0027 
0028 int G4VtxNtuple::Init(PHCompositeNode * /*unused*/)
0029 {
0030   hm = new Fun4AllHistoManager(Name());
0031   ntup = new TNtuple("vtxntup", "G4Vtxs", "vx:vy:vz");
0032   hm->registerHisto(ntup);
0033   return 0;
0034 }
0035 
0036 int G4VtxNtuple::process_event(PHCompositeNode *topNode)
0037 {
0038   PHG4TruthInfoContainer *truthinfo = findNode::getClass<PHG4TruthInfoContainer>(topNode, "G4TruthInfo");
0039   if (truthinfo)
0040   {
0041     PHG4VtxPoint *gvertex = truthinfo->GetPrimaryVtx(truthinfo->GetPrimaryVertexIndex());
0042     ntup->Fill(gvertex->get_x(), gvertex->get_y(), gvertex->get_z());
0043   }
0044   return 0;
0045 }
0046 
0047 int G4VtxNtuple::End(PHCompositeNode * /*topNode*/)
0048 {
0049   hm->dumpHistos(m_FileName, "RECREATE");
0050   return 0;
0051 }