Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Fun4AllRunNodeInputManager.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Fun4AllRunNodeInputManager.cc
2 
3 #include "Fun4AllReturnCodes.h"
4 #include "Fun4AllServer.h"
5 
6 #include <ffaobjects/RunHeader.h>
7 
8 #include <frog/FROG.h>
9 
10 #include <phool/PHCompositeNode.h>
11 #include <phool/PHNodeIOManager.h>
12 #include <phool/PHNodeIntegrate.h>
13 #include <phool/getClass.h>
14 #include <phool/phool.h> // for PHWHERE, PHReadOnly, PHRunTree
15 #include <phool/phooldefs.h>
16 
17 #include <TSystem.h>
18 
19 #include <cstdlib>
20 #include <iostream>
21 
23  const std::string &nodename,
24  const std::string &topnodename)
25  : Fun4AllDstInputManager(name, nodename, topnodename)
26 {
27  return;
28 }
29 
31 {
33  if (IsOpen())
34  {
35  std::cout << "Closing currently open file "
36  << FileName()
37  << " and opening " << filenam << std::endl;
38  fileclose();
39  }
40  FileName(filenam);
41  FROG frog;
42  fullfilename = frog.location(FileName());
43  if (Verbosity() > 0)
44  {
45  std::cout << Name() << ": opening file " << fullfilename << std::endl;
46  }
47  // sanity check - the IManager must be nullptr when this method is executed
48  // if not something is very very wrong and we must not continue
49  if (IManager())
50  {
51  std::cout << PHWHERE << " IManager pointer is not nullptr but " << IManager()
52  << std::endl;
53  std::cout << "Send mail to off-l with this printout and the macro you used"
54  << std::endl;
55  std::cout << "Trying to execute IManager->print() to display more info"
56  << std::endl;
57  std::cout << "Code will probably segfault now" << std::endl;
58  IManager()->print();
59  std::cout << "Have someone look into this problem - Exiting now" << std::endl;
60  exit(1);
61  }
63  if (IManager()->isFunctional())
64  {
66  IManager()->read(runNode());
67  // get the current run number from an existing run noder
68  RunHeader *runheader = findNode::getClass<RunHeader>(runNode(), "RunHeader");
69  if (runheader)
70  {
71  SetRunNumber(runheader->get_RunNumber());
72  }
73  }
74  // DLW: move the delete outside the if block to cover the case where isFunctional() fails
75  delete IManager();
76  IManager(nullptr);
77  IsOpen(1);
78  return 0;
79 }
80 
81 int Fun4AllRunNodeInputManager::run(const int /*nevents*/)
82 {
83  if (!IsOpen())
84  {
85  if (FileListEmpty())
86  {
87  if (Verbosity() > 0)
88  {
89  std::cout << Name() << ": No Input file open" << std::endl;
90  }
91  return -1;
92  }
93  else
94  {
95  if (OpenNextFile())
96  {
97  std::cout << Name() << ": No Input file from filelist opened" << std::endl;
98  return -1;
99  }
100  }
101  }
102  return 0;
103 }