From 2f59ddecd552c8c4cb0c7166694f0edf1a13f2ad Mon Sep 17 00:00:00 2001
From: Elidiano Tronchin <elidiano.tronchin@gmail.com>
Date: Wed, 3 Oct 2018 15:37:34 +0200
Subject: [PATCH] * Changed event selection

---
 .../EventGenerator/EventGeneratorCosmic.cc         | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/NPSimulation/EventGenerator/EventGeneratorCosmic.cc b/NPSimulation/EventGenerator/EventGeneratorCosmic.cc
index 8f12946b4..298f9239b 100644
--- a/NPSimulation/EventGenerator/EventGeneratorCosmic.cc
+++ b/NPSimulation/EventGenerator/EventGeneratorCosmic.cc
@@ -172,15 +172,15 @@ void EventGeneratorCosmic::GenerateEvent(G4Event*){
         G4double randomize = .5-RandFlat::shoot();
 
 
-        
-        if(randomize>0){          
+        /* //Putting a cylinder
+        if(randomize>0){          //top
         momentum_x = cos(angle)*dis;
         momentum_z = sin(angle)*dis;
           
         x0 = cos(shift*2)*R*(randomize*2);
         z0 = sin(shift*2)*R*(randomize*2);
         par.m_y0 = H/2;
-        } else {
+        } else {                  //lateral surface
           
           x0 = cos(angle)*R;
           z0 = sin(angle)*R;
@@ -189,7 +189,15 @@ void EventGeneratorCosmic::GenerateEvent(G4Event*){
           momentum_x = -cos(angle+shift)*dis;
           momentum_z = -sin(angle+shift)*dis;
         }
+        */
 
+        // Constrain to pass in a circle with radius 2R
+        momentum_x = cos(angle)*dis;
+        momentum_z = sin(angle)*dis;
+        x0 = cos(shift*2)*R*2*(randomize*2)-momentum_x*( H/2 / momentum_y);
+        z0 = sin(shift*2)*R*2*(randomize*2)-momentum_z*( H/2 / momentum_y);
+        par.m_y0 = H/2;
+        
         
         momentum_y = -momentum_y;
 
-- 
GitLab