Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:15:59

0001 #ifndef PHHEPMC_FUN4ALLHEPMCINPUTMANAGER_H
0002 #define PHHEPMC_FUN4ALLHEPMCINPUTMANAGER_H
0003 
0004 #include "PHHepMCGenHelper.h"
0005 
0006 #include <fun4all/Fun4AllInputManager.h>
0007 #include <fun4all/Fun4AllReturnCodes.h>
0008 
0009 #include <boost/iostreams/filtering_streambuf.hpp>
0010 
0011 #include <fstream>
0012 #include <string>
0013 #include <vector>
0014 
0015 class PHCompositeNode;
0016 class SyncObject;
0017 
0018 // forward declaration of classes in namespace
0019 namespace HepMC
0020 {
0021   class IO_GenEvent;
0022   class GenEvent;
0023 }  // namespace HepMC
0024 
0025 class Fun4AllHepMCInputManager : public Fun4AllInputManager, public PHHepMCGenHelper
0026 {
0027  public:
0028   Fun4AllHepMCInputManager(const std::string &name = "DUMMY", const std::string &nodename = "DST", const std::string &topnodename = "TOP");
0029   ~Fun4AllHepMCInputManager() override;
0030   int fileopen(const std::string &filenam) override;
0031 // cppcheck-suppress virtualCallInConstructor
0032   int fileclose() override;
0033   int run(const int nevents = 0) override;
0034   int ResetEvent() override;
0035   void ReadOscar(const int i) { m_ReadOscarFlag = i; }
0036   int ReadOscar() const { return m_ReadOscarFlag; }
0037   void Print(const std::string &what = "ALL") const override;
0038   int PushBackEvents(const int i) override;
0039 
0040   // Effectivly turn off the synchronization checking
0041   //
0042   int SyncIt(const SyncObject * /*mastersync*/) override { return Fun4AllReturnCodes::SYNC_OK; }
0043   int GetSyncObject(SyncObject ** /*mastersync*/) override { return Fun4AllReturnCodes::SYNC_NOOBJECT; }
0044   int NoSyncPushBackEvents(const int nevt) override { return PushBackEvents(nevt); }
0045   HepMC::GenEvent *ConvertFromOscar();
0046 
0047   int SkipForThisManager(const int nevents) override { return PushBackEvents(-nevents); }
0048   int MyCurrentEvent(const unsigned int index = 0) const;
0049 
0050  protected:
0051   HepMC::GenEvent *evt = nullptr;
0052 
0053   int events_total = 0;
0054   int events_thisfile = 0;
0055   int m_EventPushedBackFlag = 0;
0056 
0057   HepMC::IO_GenEvent *ascii_in = nullptr;
0058 
0059   std::string m_HepMCTmpFile;
0060 
0061  private:
0062   PHCompositeNode *topNode = nullptr;
0063 
0064   // some pointers for use in decompression handling
0065   std::ifstream *filestream = nullptr;  // holds compressed filestream
0066   std::istream *unzipstream = nullptr;  // feed into HepMc
0067 
0068   int m_ReadOscarFlag = 0;
0069 
0070   std::vector<int> m_MyEvent;
0071 
0072   boost::iostreams::filtering_streambuf<boost::iostreams::input> zinbuffer;
0073 
0074   std::ifstream theOscarFile;
0075 
0076   std::string filename;
0077   std::string topNodeName;
0078 };
0079 
0080 #endif /* PHHEPMC_FUN4ALLHEPMCINPUTMANAGER_H */