File indexing completed on 2025-12-18 09:20:29
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 G4VtxNtuple::G4VtxNtuple(const std::string &name, const std::string &filename)
0016 : SubsysReco(name)
0017 , m_FileName(filename)
0018 {
0019 }
0020
0021 G4VtxNtuple::~G4VtxNtuple()
0022 {
0023 delete hm;
0024 }
0025
0026 int G4VtxNtuple::Init(PHCompositeNode * )
0027 {
0028 delete hm;
0029 hm = new Fun4AllHistoManager(Name());
0030 ntup = new TNtuple("vtxntup", "G4Vtxs", "vx:vy:vz");
0031 hm->registerHisto(ntup);
0032 return 0;
0033 }
0034
0035 int G4VtxNtuple::process_event(PHCompositeNode *topNode)
0036 {
0037 PHG4TruthInfoContainer *truthinfo = findNode::getClass<PHG4TruthInfoContainer>(topNode, "G4TruthInfo");
0038 if (truthinfo)
0039 {
0040 PHG4VtxPoint *gvertex = truthinfo->GetPrimaryVtx(truthinfo->GetPrimaryVertexIndex());
0041 ntup->Fill(gvertex->get_x(), gvertex->get_y(), gvertex->get_z());
0042 }
0043 return 0;
0044 }
0045
0046 int G4VtxNtuple::End(PHCompositeNode * )
0047 {
0048 hm->dumpHistos(m_FileName, "RECREATE");
0049 return 0;
0050 }