ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Fun4AllPrdfOutputManager.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Fun4AllPrdfOutputManager.cc
2 
3 #include <fun4all/Fun4AllOutputManager.h> // for Fun4AllOutputManager
4 
6 
8 #include <phool/PHNode.h> // for PHNode
9 #include <phool/PHNodeIterator.h>
10 #include <phool/recoConsts.h>
11 
12 #include <iostream>
13 
14 using namespace std;
15 
16 //______________________________________________________
17 Fun4AllPrdfOutputManager::Fun4AllPrdfOutputManager(const string &myname, const string &fname)
18  : Fun4AllOutputManager(myname, fname)
19  , m_PrdfNode(nullptr)
20  , m_PrdfOutManager(nullptr)
21 {
22  return;
23 }
24 
25 //______________________________________________________
27 {
28  delete m_PrdfOutManager;
29  return;
30 }
31 
32 //______________________________________________________
33 int Fun4AllPrdfOutputManager::InitPrdfNode(PHCompositeNode *top_node, const string &nodeName)
34 {
35  PHNodeIterator topIter(top_node);
36  m_PrdfNode = dynamic_cast<PHCompositeNode *>(topIter.findFirst("PHCompositeNode", nodeName.c_str()));
37  if (m_PrdfNode)
38  {
39  // the m_PrdfNode already exists (Pisa Input Mgr creates one also)
40  return 0;
41  }
42 
43  // check name wrt default
44  if (nodeName != "SIMPRDF")
45  cout << "Fun4AllPrdfOutputManager::InitPrdfNode - WARNING: nodeName is \"" << nodeName << "\". most systems expect \"SIMPRDF\" and this is most likely not going to work" << endl;
46 
47  // create node
48  m_PrdfNode = new PHCompositeNode(nodeName.c_str());
49  top_node->addNode(m_PrdfNode);
50  return 0;
51 }
52 
53 //______________________________________________________
55 {
56  if (m_PrdfOutManager)
57  {
58  if (Verbosity()) cout << "Fun4AllPrdfOutputManager::outfileopen - closing file \"" << OutFileName() << "\"" << endl;
59  delete m_PrdfOutManager;
60  m_PrdfOutManager = nullptr;
61  }
62 
63  OutFileName(fname);
64  if (Verbosity()) cout << "Fun4AllPrdfOutputManager::outfileopen - writing to file \"" << OutFileName() << "\"" << endl;
65 
66  return 0;
67 }
68 
69 //______________________________________________________
71 {
72  // check m_PrdfNode
73  if (!m_PrdfNode)
74  {
75  cout << "Fun4AllPrdfOutputManager::Write - prdfNode not initialized" << endl;
76  return -1;
77  }
78 
79  // check m_PrdfOutManager
81  if (!m_PrdfOutManager)
82  {
83  cout << "Fun4AllPrdfOutputManager::Write - prdf manager not initialized" << endl;
84  return -1;
85  }
86 
87  // write prdfNode to prdfManager
88  bool prdf_status = m_PrdfOutManager->write(m_PrdfNode);
89  return prdf_status ? 0 : -1;
90 }
91 
92 //______________________________________________________
94 {
95  if (m_PrdfOutManager) return -1;
96 
97  // retrieve run number from recoConsts
99 
100  // retrieve run number
101  int run_number = -1;
102  if (rc->FlagExist("RUNNUMBER"))
103  {
104  run_number = rc->get_IntFlag("RUNNUMBER");
105  }
106  // buffer length (taken from offline/framework/simReco/PrdfReco.C)
107  static const int buffer_length(8 * 1024 * 1024 / 4);
108 
109  // create output manager
110  m_PrdfOutManager = new PHRawOManager(OutFileName(), run_number, buffer_length);
111  return 0;
112 }