File indexing completed on 2025-12-17 09:19:45
0001 #include "Fun4AllPrdfOutputManager.h"
0002
0003 #include <fun4all/Fun4AllOutputManager.h> // for Fun4AllOutputManager
0004
0005 #include <phoolraw/PHRawOManager.h>
0006
0007 #include <phool/PHCompositeNode.h>
0008 #include <phool/PHNode.h> // for PHNode
0009 #include <phool/PHNodeIterator.h>
0010 #include <phool/recoConsts.h>
0011
0012 #include <iostream>
0013
0014
0015 Fun4AllPrdfOutputManager::Fun4AllPrdfOutputManager(const std::string &myname, const std::string &fname)
0016 : Fun4AllOutputManager(myname, fname)
0017 , m_PrdfNode(nullptr)
0018 , m_PrdfOutManager(nullptr)
0019 {
0020 return;
0021 }
0022
0023
0024 Fun4AllPrdfOutputManager::~Fun4AllPrdfOutputManager()
0025 {
0026 delete m_PrdfOutManager;
0027 return;
0028 }
0029
0030
0031 int Fun4AllPrdfOutputManager::InitPrdfNode(PHCompositeNode *top_node, const std::string &nodeName)
0032 {
0033 PHNodeIterator topIter(top_node);
0034 m_PrdfNode = dynamic_cast<PHCompositeNode *>(topIter.findFirst("PHCompositeNode", nodeName));
0035 if (m_PrdfNode)
0036 {
0037
0038 return 0;
0039 }
0040
0041
0042 if (nodeName != "SIMPRDF")
0043 {
0044 std::cout << "Fun4AllPrdfOutputManager::InitPrdfNode - WARNING: nodeName is \"" << nodeName << "\". most systems expect \"SIMPRDF\" and this is most likely not going to work" << std::endl;
0045 }
0046
0047
0048 m_PrdfNode = new PHCompositeNode(nodeName);
0049 top_node->addNode(m_PrdfNode);
0050 return 0;
0051 }
0052
0053
0054 int Fun4AllPrdfOutputManager::outfileopen(const std::string &fname)
0055 {
0056 if (m_PrdfOutManager)
0057 {
0058 if (Verbosity())
0059 {
0060 std::cout << "Fun4AllPrdfOutputManager::outfileopen - closing file \"" << OutFileName() << "\"" << std::endl;
0061 }
0062 delete m_PrdfOutManager;
0063 m_PrdfOutManager = nullptr;
0064 }
0065
0066 OutFileName(fname);
0067 if (Verbosity())
0068 {
0069 std::cout << "Fun4AllPrdfOutputManager::outfileopen - writing to file \"" << OutFileName() << "\"" << std::endl;
0070 }
0071
0072 return 0;
0073 }
0074
0075
0076 int Fun4AllPrdfOutputManager::Write(PHCompositeNode * )
0077 {
0078
0079 if (!m_PrdfNode)
0080 {
0081 std::cout << "Fun4AllPrdfOutputManager::Write - prdfNode not initialized" << std::endl;
0082 return -1;
0083 }
0084
0085
0086 if (!m_PrdfOutManager)
0087 {
0088 InitPrdfManager();
0089 }
0090 if (!m_PrdfOutManager)
0091 {
0092 std::cout << "Fun4AllPrdfOutputManager::Write - prdf manager not initialized" << std::endl;
0093 return -1;
0094 }
0095
0096
0097 bool prdf_status = m_PrdfOutManager->write(m_PrdfNode);
0098 return prdf_status ? 0 : -1;
0099 }
0100
0101
0102 int Fun4AllPrdfOutputManager::InitPrdfManager()
0103 {
0104 if (m_PrdfOutManager)
0105 {
0106 return -1;
0107 }
0108
0109
0110 recoConsts *rc = recoConsts::instance();
0111
0112
0113 int run_number = -1;
0114 if (rc->FlagExist("RUNNUMBER"))
0115 {
0116 run_number = rc->get_IntFlag("RUNNUMBER");
0117 }
0118
0119 static const int buffer_length(8 * 1024 * 1024 / 4);
0120
0121
0122 m_PrdfOutManager = new PHRawOManager(OutFileName(), run_number, buffer_length);
0123 return 0;
0124 }