EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Fun4AllEventOutputManager.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Fun4AllEventOutputManager.cc
2 
5 
6 #include <fun4all/Fun4AllOutputManager.h> // for Fun4AllOutputManager
8 
9 #include <phool/getClass.h>
10 #include <phool/phool.h> // for PHWHERE
11 
12 #include <Event/Event.h>
13 
14 #include <iostream>
15 #include <string>
16 
17 using namespace std;
18 
19 Fun4AllEventOutputManager::Fun4AllEventOutputManager(const string &myname, const string &filerule, const unsigned int sizeInMB, const int offset, const int increment)
20  : Fun4AllOutputManager(myname)
21  , m_OutFileRule(filerule)
22 {
23  m_OutStream = new Fun4AllRolloverFileOutStream(filerule, sizeInMB, offset, increment);
24  m_OutStream->SetManager(this);
25  return;
26 }
27 
29 {
30  delete m_OutStream;
31  return;
32 }
33 
34 void Fun4AllEventOutputManager::Print(const string &what) const
35 {
36  cout << Name() << " writes " << m_OutFileRule << endl;
37  // base class print method
39 
40  return;
41 }
42 
44 {
46  PHCompositeNode *topNode = se->topNode();
47  Event *evt = findNode::getClass<Event>(topNode, "PRDF");
48  if (!evt)
49  {
50  cout << PHWHERE << "0 Event Pointer" << endl;
51  return -1;
52  }
53  m_OutStream->WriteEvent(evt);
54  return 0;
55 }
56 
58 {
59  int iret = -1;
60  if (m_OutStream)
61  {
62  iret = m_OutStream->AddPacket(ipkt);
63  }
64  else
65  {
66  cout << PHWHERE << "Cannot add packet" << endl;
67  }
68  return iret;
69 }
70 
71 int Fun4AllEventOutputManager::AddPacketRange(const int ipktmin, const int ipktmax)
72 {
73  int iret = -1;
74  if (m_OutStream)
75  {
76  iret = m_OutStream->AddPacketRange(ipktmin, ipktmax);
77  }
78  else
79  {
80  cout << PHWHERE << "Cannot add packet" << endl;
81  }
82  return iret;
83 }
84 
86 {
87  int iret = -1;
88  if (m_OutStream)
89  {
90  iret = m_OutStream->DropPacket(ipkt);
91  }
92  else
93  {
94  cout << PHWHERE << "Cannot drop packet" << endl;
95  }
96  return iret;
97 }
98 
99 int Fun4AllEventOutputManager::DropPacketRange(const int ipktmin, const int ipktmax)
100 {
101  int iret = -1;
102  if (m_OutStream)
103  {
104  iret = m_OutStream->DropPacketRange(ipktmin, ipktmax);
105  }
106  else
107  {
108  cout << PHWHERE << "Cannot drop packet" << endl;
109  }
110  return iret;
111 }
112 
113 void Fun4AllEventOutputManager::SetOutfileName(const std::string &fname)
114 {
115  OutFileName(fname);
116  return;
117 }