From 1841dce8ccbc79c2947b236d3979bc326f6dcf53 Mon Sep 17 00:00:00 2001
From: morfouace <pierre.morfouace@cea.fr>
Date: Thu, 3 Oct 2024 10:29:26 +0200
Subject: [PATCH] Adding EnergyToEnergyImpulsion

---
 NPLib/Physics/NPParticle.cxx | 7 +++++++
 NPLib/Physics/NPParticle.h   | 7 +++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/NPLib/Physics/NPParticle.cxx b/NPLib/Physics/NPParticle.cxx
index c34b283b7..255dba7ac 100644
--- a/NPLib/Physics/NPParticle.cxx
+++ b/NPLib/Physics/NPParticle.cxx
@@ -509,6 +509,13 @@ void Particle::EnergyToBrho(double Q){
   fBrho = 3.107*GetA()/Q*fBeta*fGamma;
 }
 
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 
+void Particle::EnergyToEnergyImpulsion(double energy, double ThetaLab, double PhiLab){
+  double p = sqrt(pow(energy,2) + 2*Mass()*energy);
+  TVector3 Impulsion = TVector3(p*sin(ThetaLab)*cos(PhiLab), p*sin(ThetaLab)*sin(PhiLab), p*cos(ThetaLab));
+
+  fEnergyImpulsion = TLorentzVector(Impulsion, energy+Mass());
+}
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 
 void Particle::EnergyToTof(){
diff --git a/NPLib/Physics/NPParticle.h b/NPLib/Physics/NPParticle.h
index 0f31c179b..c4caec7c4 100644
--- a/NPLib/Physics/NPParticle.h
+++ b/NPLib/Physics/NPParticle.h
@@ -93,6 +93,7 @@ namespace NPL {
       void TofToEnergy();
       void TofToBrho(){TofToEnergy(); EnergyToBrho();}
       void EnergyToBeta();
+      void EnergyToEnergyImpulsion(double, double, double);
       void BetaToEnergy();
       void BetaToGamma();
       double DopplerCorrection(double EnergyLabGamma, double ThetaLabGamma);
@@ -130,13 +131,15 @@ namespace NPL {
       void SetParity(const char* parity)	{fParity = parity;}
       void SetLifeTime(double LifeTime) {fLifeTime=LifeTime;}
       void SetLifeTimeError(double LifeTimeErr) {fLifeTimeErr=LifeTimeErr;}
-      void SetKineticEnergy(double energy){
+      void SetKineticEnergy(double energy, double ThetaLab=0, double PhiLab=0){
         fKineticEnergy = energy; 
         EnergyToBrho(); 
         EnergyToTof(); 
         EnergyToBeta(); 
         BetaToGamma();
-        BetaToVelocity();}
+        BetaToVelocity();
+        EnergyToEnergyImpulsion(energy,ThetaLab,PhiLab);
+      }
       void SetBrho(double brho){
         fBrho = brho; 
         BrhoToEnergy(); 
-- 
GitLab