--- PamVMC/src/PamVMCPrimaryGenerator.cxx 2009/02/18 17:38:17 1.2 +++ PamVMC/src/PamVMCPrimaryGenerator.cxx 2009/06/12 18:39:32 1.5 @@ -8,16 +8,11 @@ #include #include #include +#include #include "PamVMCPrimaryGenerator.h" -using TMath::Sqrt; -using TMath::Sin; -using TMath::Cos; -using TMath::ATan; -using TMath::Log; -using TMath::Power; -using TMath::Exp; +using namespace TMath; ClassImp(PamVMCPrimary) @@ -44,12 +39,14 @@ fevno(0), fmass(0.), fcharge(0.), - frnd(0) + frandom(0) { // Standard constructor - fprimColl = new TClonesArray("PamVMCPrimary"); - frnd = new TRandom3(0); + ftheta = new TF1("ftheta","sin(x)*cos(x)",0.,acos(-1.)/4.); + ftheta->SetNpx(1000); + + fprimColl = new TClonesArray("PamVMCPrimary"); fprim.fPDG=kProton; fprim.fX0=1.; fprim.fY0=1.; @@ -67,11 +64,13 @@ fmass(0.), fcharge(0.), fprimColl(0), - frnd(0) + frandom(0) { - frnd = new TRandom3(0); -// Default constructor + // Default constructor //Default primary proton + ftheta = new TF1("ftheta","sin(x)*cos(x)",0.,acos(-1.)/4.); + ftheta->SetNpx(1000); + fprim.fPDG=kProton; fprim.fX0=1.; fprim.fY0=1.; @@ -84,13 +83,12 @@ PamVMCPrimaryGenerator::~PamVMCPrimaryGenerator() { // Destructor - delete frnd; + delete ftheta; delete fprimColl; } // private methods -#include void PamVMCPrimaryGenerator::GeneratePrimary() { @@ -157,9 +155,9 @@ void PamVMCPrimaryGenerator::GenSpe(Double_t PEmin, Double_t PEmax, Bool_t isEnergy) { if(isEnergy) { - fprim.fP0=frnd->Uniform(KinEToMomentum(PEmin),KinEToMomentum(PEmax)); + fprim.fP0=frandom->Uniform(KinEToMomentum(PEmin),KinEToMomentum(PEmax)); } else{ - fprim.fP0=frnd->Uniform(PEmin,PEmax); + fprim.fP0=frandom->Uniform(PEmin,PEmax); } } @@ -168,10 +166,10 @@ { Double_t alpha = 1.+gamma; //integral spectral index if(alpha==0.){ - fprim.fP0=Exp(Log(PEmin)+frnd->Uniform(0.,1.)*(Log(PEmax)-Log(PEmin))); + fprim.fP0=Exp(Log(PEmin)+frandom->Uniform(0.,1.)*(Log(PEmax)-Log(PEmin))); } else { if(PEmin==0.) PEmin=1.E-10; - fprim.fP0=Power((frnd->Uniform(0.,1.)*(Power(PEmax,alpha)-Power(PEmin,alpha))+Power(PEmin,alpha)),1./alpha); + fprim.fP0=Power((frandom->Uniform(0.,1.)*(Power(PEmax,alpha)-Power(PEmin,alpha))+Power(PEmin,alpha)),1./alpha); } if(isEnergy) fprim.fP0=KinEToMomentum(fprim.fP0);