Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:16:10

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