From 90aaf935619ec94792af54ff2cc4718b2a5c13f4 Mon Sep 17 00:00:00 2001
From: Oleg Kalashev <oleg.kalashev@gmail.com>
Date: Sat, 20 May 2023 23:39:16 +0300
Subject: [PATCH] save particle production time in output3d

---
 src/app/crbeam/CRbeam.cpp | 3 ++-
 src/lib/Output.cpp        | 6 ++++++
 src/lib/Output.h          | 5 +++--
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/app/crbeam/CRbeam.cpp b/src/app/crbeam/CRbeam.cpp
index 6974283..981b1fe 100644
--- a/src/app/crbeam/CRbeam.cpp
+++ b/src/app/crbeam/CRbeam.cpp
@@ -346,7 +346,8 @@ int CRbeam::run()
 		outputDir += suffix;
 	}
     std::cout << "output dir: " << outputDir << std::endl;
-    SmartPtr<RawOutput3D> pOutput = new RawOutput3D(outputDir, fOverwriteOutput, fMz!=M_POINT_SOURCE, fPowerLaw>0, fTrajectoryLogging);//this creates folder outputDir, later we will set output to outputDir/z0
+    bool saveZprod = true;
+    SmartPtr<RawOutput3D> pOutput = new RawOutput3D(outputDir, fOverwriteOutput, fMz!=M_POINT_SOURCE, fPowerLaw>0, fTrajectoryLogging, saveZprod);//this creates folder outputDir, later we will set output to outputDir/z0
 	if(fLogging){
 		debug.SetOutputFile(outputDir + "/log.txt");
 		debug.EnableTimestamp();
diff --git a/src/lib/Output.cpp b/src/lib/Output.cpp
index 3eddf84..ea09af2 100644
--- a/src/lib/Output.cpp
+++ b/src/lib/Output.cpp
@@ -253,6 +253,9 @@ void RawOutput::LookForRepetitions(std::vector<Particle>* aParticles)
 		if(fSaveId){
 			aOut << "\t" << aParticle.id;
 		}
+        if(fSaveZprod){
+            aOut << "\t" << aParticle.fProductionTime.z();
+        }
 	}
 
 	void RawOutput3D::WriteHeader(std::ostream& aOut, const Particle& aFirstParticle){
@@ -274,6 +277,9 @@ void RawOutput::LookForRepetitions(std::vector<Particle>* aParticles)
 		if(fSaveId){
 			aOut << "\tId";
 		}
+		if(fSaveZprod){
+            aOut << "\tz_prod";
+		}
 	}
 
 } /* namespace mcray */
diff --git a/src/lib/Output.h b/src/lib/Output.h
index 851c024..daf3cb5 100644
--- a/src/lib/Output.h
+++ b/src/lib/Output.h
@@ -79,14 +79,15 @@ private:
 
 	class RawOutput3D : public RawOutput{
 	public:
-		RawOutput3D(std::string aDir, bool aOverwriteExisting = false, bool aSaveSourceZ=false, bool aSaveSourceE=false, bool aSaveId=false):
-				RawOutput(aDir, false, aOverwriteExisting),fSaveSourceZ(aSaveSourceZ), fSaveSourceE(aSaveSourceE), fSaveId(aSaveId){ }
+		RawOutput3D(std::string aDir, bool aOverwriteExisting = false, bool aSaveSourceZ=false, bool aSaveSourceE=false, bool aSaveId=false, bool aSaveZprod=false):
+				RawOutput(aDir, false, aOverwriteExisting),fSaveSourceZ(aSaveSourceZ), fSaveSourceE(aSaveSourceE), fSaveId(aSaveId), fSaveZprod(aSaveZprod){ }
 		void WriteHeader(std::ostream& aOut, const Particle& aFirstParticle);
 		void Write(std::ostream& aOut, const Particle& aParticle);
 	private:
 		bool fSaveSourceZ;
 		bool fSaveSourceE;
 		bool fSaveId;
+        bool fSaveZprod;
 	};
 
 	class TotalEnergyOutput : public TSmartReferencedObj<IOutput> {
-- 
GitLab