Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:19:56

0001 /*******************************************************************************
0002  * Copyright (c) The JETSCAPE Collaboration, 2018
0003  *
0004  * Modular, task-based framework for simulating all aspects of heavy-ion collisions
0005  * 
0006  * For the list of contributors see AUTHORS.
0007  *
0008  * Report issues at https://github.com/JETSCAPE/JETSCAPE/issues
0009  *
0010  * or via email to bugs.jetscape@gmail.com
0011  *
0012  * Distributed under the GNU General Public License 3.0 (GPLv3 or later).
0013  * See COPYING for details.
0014  ******************************************************************************/
0015 
0016 // jetscape writer ascii class
0017 
0018 #ifndef JETSCAPEWRITERSTREAM_H
0019 #define JETSCAPEWRITERSTREAM_H
0020 
0021 #include <fstream>
0022 #include <string>
0023 
0024 #ifdef USE_GZIP
0025 #include "gzstream.h"
0026 #endif
0027 
0028 #include "JetScapeWriter.h"
0029 
0030 using std::ofstream;
0031 
0032 namespace Jetscape {
0033 
0034 template <class T> class JetScapeWriterStream : public JetScapeWriter {
0035 
0036 public:
0037   JetScapeWriterStream<T>(){};
0038   JetScapeWriterStream<T>(string m_file_name_out);
0039   virtual ~JetScapeWriterStream<T>();
0040 
0041   void Init();
0042   void Exec();
0043 
0044   bool GetStatus() { return output_file.good(); }
0045   void Close() { output_file.close(); }
0046 
0047   void WriteInitFileXMLMain();
0048   void WriteInitFileXMLUser();
0049 
0050   void Write(weak_ptr<PartonShower> ps);
0051   void Write(weak_ptr<Parton> p);
0052   void Write(weak_ptr<Vertex> v);
0053   void Write(weak_ptr<Hadron> h);
0054   void WriteHeaderToFile();
0055 
0056   void Write(string s) { output_file << s << endl; }
0057   void WriteComment(string s) { output_file << "# " << s << endl; }
0058   void WriteWhiteSpace(string s) { output_file << s << " "; }
0059   void WriteEvent();
0060 
0061 protected:
0062   T output_file; //!< Output file
0063   //int m_precision; //!< Output precision
0064 
0065   // Allows the registration of the module so that it is available to be used by the Jetscape framework.
0066   static RegisterJetScapeModule<JetScapeWriterStream<ofstream>> reg;
0067   static RegisterJetScapeModule<JetScapeWriterStream<ogzstream>> regGZ;
0068 };
0069 
0070 typedef JetScapeWriterStream<ofstream> JetScapeWriterAscii;
0071 #ifdef USE_GZIP
0072 typedef JetScapeWriterStream<ogzstream> JetScapeWriterAsciiGZ;
0073 #endif
0074 
0075 } // end namespace Jetscape
0076 
0077 #endif // JETSCAPEWRITERSTREAM_H