Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SingleStreamingInput.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SingleStreamingInput.cc
1 #include "SingleStreamingInput.h"
2 
3 #include <frog/FROG.h>
4 
5 #include <phool/phool.h>
6 
7 #include <Event/Eventiterator.h>
8 #include <Event/fileEventiterator.h>
9 
10 #include <cstdint> // for uint64_t
11 #include <iostream> // for operator<<, basic_ostream, endl
12 #include <set>
13 #include <utility> // for pair
14 
15 SingleStreamingInput::SingleStreamingInput(const std::string &name, Fun4AllEvtInputPoolManager *inman)
16  : Fun4AllBase(name)
17  , m_InputMgr(inman)
18 {
19 }
20 
22  : Fun4AllBase(name)
23 {
24 }
25 
27 {
28  delete m_EventIterator;
29 }
30 
32 {
33  std::cout << PHWHERE << "trying to open " << filenam << std::endl;
34  if (IsOpen())
35  {
36  std::cout << "Closing currently open file "
37  << FileName()
38  << " and opening " << filenam << std::endl;
39  fileclose();
40  }
41  FileName(filenam);
42  FROG frog;
44  if (Verbosity() > 0)
45  {
46  std::cout << Name() << ": opening file " << FileName() << std::endl;
47  }
48  int status = 0;
49  m_EventIterator = new fileEventiterator(fname.c_str(), status);
50  m_EventsThisFile = 0;
51  if (status)
52  {
53  delete m_EventIterator;
54  m_EventIterator = nullptr;
55  std::cout << PHWHERE << Name() << ": could not open file " << fname << std::endl;
56  return -1;
57  }
58  IsOpen(1);
59  AddToFileOpened(fname); // add file to the list of files which were opened
60  return 0;
61 }
62 
64 {
65  if (!IsOpen())
66  {
67  std::cout << Name() << ": fileclose: No Input file open" << std::endl;
68  return -1;
69  }
70  delete m_EventIterator;
71  m_EventIterator = nullptr;
72  IsOpen(0);
73  // if we have a file list, move next entry to top of the list
74  // or repeat the same entry again
76  return 0;
77 }
78 
80 {
81  if (what == "ALL" || what == "FEE")
82  {
83  for (const auto &bcliter : m_BeamClockFEE)
84  {
85  std::cout << "Beam clock 0x" << std::hex << bcliter.first << std::dec << std::endl;
86  for (auto feeiter : bcliter.second)
87  {
88  std::cout << "FEM: " << feeiter << std::endl;
89  }
90  }
91  }
92  if (what == "ALL" || what == "FEEBCLK")
93  {
94  for (auto bcliter : m_FEEBclkMap)
95  {
96  std::cout << "FEE" << bcliter.first << " bclk: 0x"
97  << std::hex << bcliter.second << std::dec << std::endl;
98  }
99  }
100  if (what == "ALL" || what == "STACK")
101  {
102  for (auto iter : m_BclkStack)
103  {
104  std::cout << "stacked bclk: 0x" << std::hex << iter << std::dec << std::endl;
105  }
106  }
107 }
108 
109 bool SingleStreamingInput::CheckPoolDepth(const uint64_t bclk)
110 {
111  // if (m_FEEBclkMap.size() < 10)
112  // {
113  // std::cout << "not all FEEs in map: " << m_FEEBclkMap.size() << std::endl;
114  // return true;
115  // }
116  for (auto iter : m_FEEBclkMap)
117  {
118  if (Verbosity() > 2)
119  {
120  std::cout << "my bclk 0x" << std::hex << iter.second
121  << " req: 0x" << bclk << std::dec << std::endl;
122  }
123  if (iter.second < bclk)
124  {
125  if (Verbosity() > 1)
126  {
127  std::cout << "FEE " << iter.first << " beamclock 0x" << std::hex << iter.second
128  << " smaller than req bclk: 0x" << bclk << std::dec << std::endl;
129  }
130  return true;
131  }
132  }
133  return false;
134 }
135 
137 {
138  // called interactively, to get rid of the current event
139  uint64_t currentbclk = *m_BclkStack.begin();
140  std::cout << "clearing bclk 0x" << std::hex << currentbclk << std::dec << std::endl;
141  CleanupUsedPackets(currentbclk);
142  m_BclkStack.erase(currentbclk);
143  m_BeamClockFEE.erase(currentbclk);
144  return;
145 }