From 0344fb1c66fc3ad4c0494f8fbd7a5d2a56ab8edb Mon Sep 17 00:00:00 2001
From: Adrien Matta <matta@lpccaen.in2p3.fr>
Date: Fri, 29 May 2020 15:54:08 +0200
Subject: [PATCH] * adding reaction vertex to Example1 display results

---
 Examples/Example1/Analysis.cxx  |  6 ++++++
 Examples/Example1/Analysis.h    |  3 +++
 Examples/Example1/ShowResults.C | 14 +++++++++++++-
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/Examples/Example1/Analysis.cxx b/Examples/Example1/Analysis.cxx
index fa8554aeb..0a60fe37d 100644
--- a/Examples/Example1/Analysis.cxx
+++ b/Examples/Example1/Analysis.cxx
@@ -75,6 +75,9 @@ void Analysis::TreatEvent(){
   OriginalELab = ReactionConditions->GetKineticEnergy(0);
   OriginalThetaLab = ReactionConditions->GetTheta(0);
   OriginalBeamEnergy = ReactionConditions->GetBeamEnergy();
+  ReactionVertexX = ReactionConditions->GetVertexPositionX(); 
+  ReactionVertexY = ReactionConditions->GetVertexPositionY(); 
+  ReactionVertexZ = ReactionConditions->GetVertexPositionZ(); 
   // Get the Init information on beam position and energy
   // and apply by hand the experimental resolution
   // This is because the beam diagnosis are not simulated
@@ -207,6 +210,9 @@ void Analysis::InitOutputBranch() {
   RootOutput::getInstance()->GetTree()->Branch("OriginalELab",&OriginalELab,"OriginalELab/D");
   RootOutput::getInstance()->GetTree()->Branch("OriginalThetaLab",&OriginalThetaLab,"OriginalThetaLab/D");
   RootOutput::getInstance()->GetTree()->Branch("OriginalBeamEnergy",&OriginalBeamEnergy,"OriginalBeamEnergy/D");
+  RootOutput::getInstance()->GetTree()->Branch("ReactionVertexX",&ReactionVertexX,"ReactionVertexX/D");
+  RootOutput::getInstance()->GetTree()->Branch("ReactionVertexY",&ReactionVertexY,"ReactionVertexY/D");
+  RootOutput::getInstance()->GetTree()->Branch("ReactionVertexZ",&ReactionVertexZ,"ReactionVertexZ/D");
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/Examples/Example1/Analysis.h b/Examples/Example1/Analysis.h
index 908a9f782..7c2408efc 100644
--- a/Examples/Example1/Analysis.h
+++ b/Examples/Example1/Analysis.h
@@ -54,6 +54,9 @@ class Analysis: public NPL::VAnalysis{
     double OriginalELab;
     double OriginalThetaLab;
     double OriginalBeamEnergy;
+    double ReactionVertexX;
+    double ReactionVertexY;
+    double ReactionVertexZ;
     NPL::Reaction* He10Reaction;
 
     // intermediate variable
diff --git a/Examples/Example1/ShowResults.C b/Examples/Example1/ShowResults.C
index 8ea68944e..3c8f9dfa9 100644
--- a/Examples/Example1/ShowResults.C
+++ b/Examples/Example1/ShowResults.C
@@ -86,7 +86,7 @@ void ShowResults(){
     f->SetNpx(1000);
     
     TCanvas* c2 = new TCanvas("Simulated","Simulated",600,0,600,600);
-    c2->Divide(2,2);
+    c2->Divide(2,3);
     
     c2->cd(1);
     chain->Draw("OriginalELab:OriginalThetaLab>>hS(1000,0,90,1000,0,30)","","col");
@@ -110,6 +110,7 @@ void ShowResults(){
     
     TLine* lT = new TLine(0,0,90,90);
     lT->Draw();
+
     c2->cd(4);
     chain->Draw("OriginalBeamEnergy:BeamEnergy>>hS4(1000,500,600,1000,500,600)","BeamEnergy>0","col");
     TH1F* hS4 = (TH1F*) gDirectory->FindObjectAny("hS4"); 
@@ -120,5 +121,16 @@ void ShowResults(){
     lB->Draw();
     
 
+    c2->cd(5);
+    chain->Draw("ReactionVertexY:ReactionVertexX>>hVXY(1000,-20,20,1000,-20,20)","","col");
+    TH2F* hVXY = (TH2F*) gDirectory->FindObjectAny("hVXY"); 
+    hVXY->GetYaxis()->SetTitle("Reaction vertex Y (mm)");
+    hVXY->GetXaxis()->SetTitle("Reaction vertex X (mm)");  
+
+    c2->cd(6);
+    chain->Draw("ReactionVertexX:ReactionVertexZ*1000.>>hVXZ(1000,-15,15,1000,-20,20)","","col");
+    TH2F* hVXZ = (TH2F*) gDirectory->FindObjectAny("hVXZ"); 
+    hVXZ->GetZaxis()->SetTitle("Reaction vertex X (mm)");
+    hVXZ->GetXaxis()->SetTitle("Reaction vertex Z (um)");  
 
 }
-- 
GitLab