From 43034be7861a134edc2ead465988f93039a74a73 Mon Sep 17 00:00:00 2001
From: Elidiano Tronchin <elidiano.tronchin@gmail.com>
Date: Mon, 29 Oct 2018 18:24:35 +0100
Subject: [PATCH] *Added possibility to see histograms of generated random
 angles

---
 .../EventGenerator/EventGeneratorCosmic.cc    | 20 +++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/NPSimulation/EventGenerator/EventGeneratorCosmic.cc b/NPSimulation/EventGenerator/EventGeneratorCosmic.cc
index 8da25d58d..eecf04d59 100644
--- a/NPSimulation/EventGenerator/EventGeneratorCosmic.cc
+++ b/NPSimulation/EventGenerator/EventGeneratorCosmic.cc
@@ -28,6 +28,10 @@
 #include "TRandom.h"
 #include "TFormula.h"
 #include "TF1.h"
+#include "TH1F.h"
+#include "TH2F.h"
+#include "TPad.h"
+#include "TCanvas.h"
 
 // G4 headers
 #include "G4ParticleTable.hh"
@@ -142,7 +146,12 @@ void EventGeneratorCosmic::ReadConfiguration(NPL::InputParser parser){
   G4double randomize1=0, randomize2=0 ;
   G4double momentum_y = 0;
   G4double angle = 0;
-  TF1* cosSq= new TF1("cosSq2", "TMath::Power(cos(x),2)", 0, (TMath::Pi())/2);
+
+  TF1* cosSq= new TF1("cosSq", "TMath::Power(cos(x),2)", 0, (TMath::Pi())/2);
+//TH1F* DistribCosmicAngle= new TH1F("DistribCosmicAngle","DistribCosmicAngle",100, 0, (TMath::Pi())/2);
+//TH2F* DistribMomZMomX= new TH2F("DistribMomZMomX","Horizontals components of Cosmic rays Momentums",50, -1, 1, 50, -1, 1);
+//TCanvas* DisCanva = new TCanvas("DisCanva","Distribution");
+//DisCanva->Divide(1,2);
 
 void EventGeneratorCosmic::GenerateEvent(G4Event*){
 
@@ -173,7 +182,7 @@ void EventGeneratorCosmic::GenerateEvent(G4Event*){
         
 
         angle = RandFlat::shoot()*2*pi;
-        CosmicAngle = cosSq2->GetRandom();
+        CosmicAngle = cosSq->GetRandom();
         randomize1 = RandFlat::shoot()    ;
         randomize2 = RandFlat::shoot()    ;
 
@@ -213,6 +222,9 @@ void EventGeneratorCosmic::GenerateEvent(G4Event*){
         
         momentum_y = -momentum_y;
 
+        //DistribMomZMomX->Fill(momentum_x,momentum_z);
+        //DistribCosmicAngle->Fill(CosmicAngle);
+
 
 
         Particle particle(par.m_particle, 0,particle_energy,G4ThreeVector(momentum_x, momentum_y, momentum_z),G4ThreeVector(x0, par.m_y0, z0));
@@ -222,6 +234,10 @@ void EventGeneratorCosmic::GenerateEvent(G4Event*){
 
       }
     }
+
+    //DisCanva->cd(1); DistribCosmicAngle->Draw();
+    //DisCanva->cd(2); DistribMomZMomX->Draw("SURF3");
+    
   }
 	
 }
-- 
GitLab