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