File indexing completed on 2025-08-03 08:19:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "JetScapeWriterAsciiGZ.h"
0011 #include "JetScapeLogger.h"
0012 #include "JetScapeXML.h"
0013
0014 namespace Jetscape {
0015
0016 JetScapeWriterAsciiGZ::JetScapeWriterAsciiGZ(string m_file_name_out)
0017 {
0018 SetOutputFileName(m_file_name_out);
0019 }
0020
0021 JetScapeWriterAsciiGZ::~JetScapeWriterAsciiGZ()
0022 {
0023 if (GetActive())
0024 Close();
0025 }
0026
0027 void JetScapeWriterAsciiGZ::WriteHeaderToFile()
0028 {
0029 INFO<<"Run JetScapeWriterAsciiGZ: Write header of event # "<<GetCurrentEvent()<<" ...";
0030 Write(to_string(GetCurrentEvent()) + " Event");
0031
0032 std::ostringstream oss;
0033 oss.str(""); oss << GetId() << "sigmaGen " << GetHeader().GetSigmaGen();
0034 WriteComment ( oss.str() );
0035 oss.str(""); oss << GetId() << "sigmaErr " << GetHeader().GetSigmaErr();
0036 WriteComment ( oss.str() );
0037 oss.str(""); oss << GetId() << "weight " << GetHeader().GetEventWeight();
0038 WriteComment ( oss.str() );
0039 }
0040
0041 void JetScapeWriterAsciiGZ::WriteEvent()
0042 {
0043
0044
0045 }
0046
0047 void JetScapeWriterAsciiGZ::Write(weak_ptr<Parton> p)
0048 {
0049 auto pp = p.lock();
0050 if ( pp ) {
0051 output_file << *pp << endl;
0052 }
0053 }
0054
0055 void JetScapeWriterAsciiGZ::Write(weak_ptr<Vertex> v)
0056 {
0057 auto vv = v.lock();
0058 if ( vv ){
0059 output_file << *vv << endl;
0060 }
0061 }
0062
0063 void JetScapeWriterAsciiGZ::Write(weak_ptr<PartonShower> ps){
0064 auto pShower = ps.lock();
0065 if ( !pShower) return;
0066
0067 WriteComment("Parton Shower in JetScape format to be used later by GTL graph:");
0068
0069
0070 PartonShower::node_iterator nIt,nEnd;
0071
0072 for (nIt = pShower->nodes_begin(), nEnd = pShower->nodes_end(); nIt != nEnd; ++nIt){
0073 WriteWhiteSpace("["+to_string(nIt->id())+"] V");
0074 Write(pShower->GetVertex(*nIt));
0075 }
0076
0077 PartonShower::edge_iterator eIt,eEnd;
0078 for (eIt = pShower->edges_begin(), eEnd = pShower->edges_end(); eIt != eEnd; ++eIt) {
0079 WriteWhiteSpace("["+to_string(eIt->source().id())+"]=>["+to_string(eIt->target().id())+"] P");
0080 Write(pShower->GetParton(*eIt));
0081 }
0082
0083 }
0084
0085
0086 void JetScapeWriterAsciiGZ::Write(weak_ptr<Hadron> h)
0087 {
0088 auto hh = h.lock();
0089 if ( hh ){
0090 output_file << *hh << endl;
0091 }
0092 }
0093
0094 void JetScapeWriterAsciiGZ::Init()
0095 {
0096 if (GetActive())
0097 {
0098 INFO<<"JetScape (gzip) Writer initialized with output file = "<<GetOutputFileName();
0099 output_file.open(GetOutputFileName().c_str());
0100 }
0101 }
0102
0103 void JetScapeWriterAsciiGZ::Exec()
0104 {
0105
0106
0107 }
0108
0109 }