File indexing completed on 2025-12-16 09:19:35
0001 #include "Fun4AllRunNodeInputManager.h"
0002
0003 #include "DBInterface.h"
0004 #include "Fun4AllReturnCodes.h"
0005 #include "Fun4AllServer.h"
0006
0007 #include <ffaobjects/RunHeader.h>
0008
0009 #include <phool/PHCompositeNode.h>
0010 #include <phool/PHNodeIOManager.h>
0011 #include <phool/PHNodeIntegrate.h>
0012 #include <phool/getClass.h>
0013 #include <phool/phool.h> // for PHWHERE, PHReadOnly, PHRunTree
0014 #include <phool/phooldefs.h>
0015
0016 #include <TSystem.h>
0017
0018 #include <cstdlib>
0019 #include <iostream>
0020
0021 Fun4AllRunNodeInputManager::Fun4AllRunNodeInputManager(const std::string &name,
0022 const std::string &nodename,
0023 const std::string &topnodename)
0024 : Fun4AllDstInputManager(name, nodename, topnodename)
0025 {
0026 return;
0027 }
0028
0029 int Fun4AllRunNodeInputManager::fileopen(const std::string &filenam)
0030 {
0031 Fun4AllServer *se = Fun4AllServer::instance();
0032 if (IsOpen())
0033 {
0034 std::cout << "Closing currently open file "
0035 << FileName()
0036 << " and opening " << filenam << std::endl;
0037 fileclose();
0038 }
0039 FileName(filenam);
0040 fullfilename = DBInterface::instance()->location(FileName());
0041 if (Verbosity() > 0)
0042 {
0043 std::cout << Name() << ": opening file " << fullfilename << std::endl;
0044 }
0045
0046
0047 if (IManager())
0048 {
0049 std::cout << PHWHERE << " IManager pointer is not nullptr but " << IManager()
0050 << std::endl;
0051 std::cout << "Send mail to off-l with this printout and the macro you used"
0052 << std::endl;
0053 std::cout << "Trying to execute IManager->print() to display more info"
0054 << std::endl;
0055 std::cout << "Code will probably segfault now" << std::endl;
0056 IManager()->print();
0057 std::cout << "Have someone look into this problem - Exiting now" << std::endl;
0058 exit(1);
0059 }
0060 IManager(new PHNodeIOManager(fullfilename, PHReadOnly, PHRunTree));
0061 if (IManager()->isFunctional())
0062 {
0063 runNode(se->getNode(RunNodeName(), TopNodeName()));
0064 IManager()->read(runNode());
0065
0066 RunHeader *runheader = findNode::getClass<RunHeader>(runNode(), "RunHeader");
0067 if (runheader)
0068 {
0069 SetRunNumber(runheader->get_RunNumber());
0070 }
0071 }
0072
0073 delete IManager();
0074 IManager(nullptr);
0075 IsOpen(1);
0076 return 0;
0077 }
0078
0079 int Fun4AllRunNodeInputManager::run(const int )
0080 {
0081 if (!IsOpen())
0082 {
0083 if (FileListEmpty())
0084 {
0085 if (Verbosity() > 0)
0086 {
0087 std::cout << Name() << ": No Input file open" << std::endl;
0088 }
0089 return -1;
0090 }
0091
0092 if (OpenNextFile())
0093 {
0094 std::cout << Name() << ": No Input file from filelist opened" << std::endl;
0095 return -1;
0096 }
0097 }
0098 return 0;
0099 }