Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:17:19

0001 #include "Fun4AllEventOutputManager.h"
0002 
0003 #include "Fun4AllEventOutStream.h"
0004 #include "Fun4AllRolloverFileOutStream.h"
0005 
0006 #include <fun4all/Fun4AllOutputManager.h>  // for Fun4AllOutputManager
0007 #include <fun4all/Fun4AllServer.h>
0008 
0009 #include <phool/getClass.h>
0010 #include <phool/phool.h>  // for PHWHERE
0011 
0012 #include <Event/Event.h>
0013 
0014 #include <iostream>
0015 #include <string>
0016 
0017 Fun4AllEventOutputManager::Fun4AllEventOutputManager(const std::string &myname, const std::string &filerule, const unsigned int nEvents, const unsigned int sizeInMB, const int offset, const int increment)
0018   : Fun4AllOutputManager(myname)
0019   , m_OutFileRule(filerule)
0020 {
0021   m_OutStream = new Fun4AllRolloverFileOutStream(filerule, nEvents, sizeInMB, offset, increment);
0022   m_OutStream->SetManager(this);
0023   return;
0024 }
0025 
0026 Fun4AllEventOutputManager::~Fun4AllEventOutputManager()
0027 {
0028   delete m_OutStream;
0029   return;
0030 }
0031 
0032 void Fun4AllEventOutputManager::Print(const std::string &what) const
0033 {
0034   std::cout << Name() << " writes " << m_OutFileRule << std::endl;
0035   // base class print method
0036   Fun4AllOutputManager::Print(what);
0037 
0038   return;
0039 }
0040 
0041 int Fun4AllEventOutputManager::Write(PHCompositeNode * /*startNode*/)
0042 {
0043   Fun4AllServer *se = Fun4AllServer::instance();
0044   PHCompositeNode *topNode = se->topNode();
0045   Event *evt = findNode::getClass<Event>(topNode, "PRDF");
0046   if (!evt)
0047   {
0048     std::cout << PHWHERE << "0 Event Pointer" << std::endl;
0049     return -1;
0050   }
0051   m_OutStream->WriteEvent(evt);
0052   return 0;
0053 }
0054 
0055 int Fun4AllEventOutputManager::AddPacket(const int ipkt)
0056 {
0057   int iret = -1;
0058   if (m_OutStream)
0059   {
0060     iret = m_OutStream->AddPacket(ipkt);
0061   }
0062   else
0063   {
0064     std::cout << PHWHERE << "Cannot add packet" << std::endl;
0065   }
0066   return iret;
0067 }
0068 
0069 int Fun4AllEventOutputManager::AddPacketRange(const int ipktmin, const int ipktmax)
0070 {
0071   int iret = -1;
0072   if (m_OutStream)
0073   {
0074     iret = m_OutStream->AddPacketRange(ipktmin, ipktmax);
0075   }
0076   else
0077   {
0078     std::cout << PHWHERE << "Cannot add packet" << std::endl;
0079   }
0080   return iret;
0081 }
0082 
0083 int Fun4AllEventOutputManager::DropPacket(const int ipkt)
0084 {
0085   int iret = -1;
0086   if (m_OutStream)
0087   {
0088     iret = m_OutStream->DropPacket(ipkt);
0089   }
0090   else
0091   {
0092     std::cout << PHWHERE << "Cannot drop packet" << std::endl;
0093   }
0094   return iret;
0095 }
0096 
0097 int Fun4AllEventOutputManager::DropPacketRange(const int ipktmin, const int ipktmax)
0098 {
0099   int iret = -1;
0100   if (m_OutStream)
0101   {
0102     iret = m_OutStream->DropPacketRange(ipktmin, ipktmax);
0103   }
0104   else
0105   {
0106     std::cout << PHWHERE << "Cannot drop packet" << std::endl;
0107   }
0108   return iret;
0109 }
0110 
0111 void Fun4AllEventOutputManager::SetOutfileName(const std::string &fname)
0112 {
0113   OutFileName(fname);
0114   return;
0115 }
0116 
0117 void Fun4AllEventOutputManager::Verbosity(const uint64_t i)
0118 {
0119   Fun4AllBase::Verbosity(i);
0120   if (m_OutStream)
0121   {
0122     m_OutStream->Verbosity(i);
0123   }
0124   return;
0125 }