@@ -64,7 +64,9 @@ JetScapeWriterFinalStateStream<T>::JetScapeWriterFinalStateStream(string m_file_
64
64
particles{},
65
65
writeCentrality{false },
66
66
writePtHat{false },
67
- particleStatusToSkip{}
67
+ particleStatusToSkip{},
68
+ output_file{},
69
+ headerVersion{2 }
68
70
{
69
71
SetOutputFileName (m_file_name_out);
70
72
}
@@ -130,7 +132,14 @@ template <class T> void JetScapeWriterFinalStateStream<T>::WriteEvent() {
130
132
<< " \t " << " Event\t " << GetCurrentEvent () + 1 // +1 to index the event count from 1
131
133
<< " \t " << " weight\t " << std::setprecision (15 ) << GetHeader ().GetEventWeight () << std::setprecision (6 )
132
134
<< " \t " << " EPangle\t " << (GetHeader ().GetEventPlaneAngle () > -999 ? GetHeader ().GetEventPlaneAngle () : 0 )
133
- << " \t " << " N_" << GetName () << " \t " << ipart
135
+ << " \t " << " N_" << GetName () << " \t " << ipart;
136
+ if (headerVersion == 3 ) {
137
+ output_file
138
+ << " \t " << " vertex_x\t " << GetHeader ().GetVertexX ()
139
+ << " \t " << " vertex_y\t " << GetHeader ().GetVertexY ()
140
+ << " \t " << " vertex_z\t " << GetHeader ().GetVertexZ ();
141
+ }
142
+ output_file
134
143
<< centrality_text
135
144
<< pt_hat_text
136
145
<< " \n " ;
@@ -161,14 +170,23 @@ template <class T> void JetScapeWriterFinalStateStream<T>::InitTask() {
161
170
particleStatusToSkip.erase (std::remove (particleStatusToSkip.begin (), particleStatusToSkip.end (), -9999 ), particleStatusToSkip.end ());
162
171
}
163
172
if (GetActive ()) {
164
- JSINFO << " JetScape Final State " << name << " Stream Writer initialized with output file = "
173
+ // We need the header version to determine how to write.
174
+ // NOTE: Don't require the version. If not specified, defaults to v2.
175
+ int result = GetXMLElementInt ({" Writer" , (std::string (" FinalState" ) + name).c_str (), " headerVersion" }, false );
176
+ // If it fails to retrieve the value, it will return 0. The header version must be >= 2,
177
+ // so only assign if the value is actually set.
178
+ if (result) {
179
+ headerVersion = static_cast <unsigned int >(result);
180
+ }
181
+
182
+ JSINFO << " JetScape Final State " << name << " Stream Writer v" << headerVersion << " initialized with output file = "
165
183
<< GetOutputFileName ();
166
184
output_file.open (GetOutputFileName ().c_str ());
167
185
// NOTE: This header will only be printed once at the beginning on the file.
168
186
output_file << " #"
169
187
// The specifics the version number. For consistency in parsing, the string
170
188
// will always be "v<number>"
171
- << " \t " << " JETSCAPE_FINAL_STATE\t " << " v2 "
189
+ << " \t " << " JETSCAPE_FINAL_STATE\t " << " v " << headerVersion
172
190
<< " \t " << " |" // As a delimiter
173
191
<< " \t " << " N"
174
192
<< " \t " << " pid"
0 commit comments