#include <TPDGCode.h>
#include "AliConst.h"
#include "AliGenThetaSlice.h"
#include "AliRun.h"
ClassImp(AliGenThetaSlice)
AliGenThetaSlice::AliGenThetaSlice()
:AliGenerator(),
fIpart(0)
{
}
AliGenThetaSlice::AliGenThetaSlice(Int_t npart)
:AliGenerator(npart),
fIpart(kProton)
{
fName = "ThetaSlice";
fTitle = "Particle generator - const. phi, slices in theta";
}
void AliGenThetaSlice::Generate()
{
Float_t polar[3]= {0,0,0};
Float_t origin[3];
Float_t time;
Float_t p[3];
Int_t i, j, nt;
Double_t pmom, theta, phi, pt;
Float_t random[6];
if (fNpart == 0) return;
for (j=0;j<3;j++) origin[j]=fOrigin[j];
time = fTimeOrigin;
if(fVertexSmear==kPerEvent) {
Rndm(random,6);
for (j=0;j<3;j++) {
origin[j]+=fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
}
Rndm(random,2);
time += fOsigma[2]/TMath::Ccgs()*
TMath::Cos(2*random[0]*TMath::Pi())*
TMath::Sqrt(-2*TMath::Log(random[1]));
}
Float_t thetaInterval = 0.;
if (fNpart > 1) {
thetaInterval = (fThetaMax-fThetaMin)/(fNpart-1);
}
Rndm(random,1);
phi=fPhiMin+random[0]*(fPhiMax-fPhiMin);
for(i=0;i<fNpart;i++) {
Rndm(random,1);
theta=fThetaMin+i*thetaInterval;
if(TestBit(kMomentumRange)) {
pmom=fPMin+random[0]*(fPMax-fPMin);
pt=pmom*TMath::Sin(theta);
} else {
pt=fPtMin+random[0]*(fPtMax-fPtMin);
pmom=pt/TMath::Sin(theta);
}
p[0] = pt*TMath::Cos(phi);
p[1] = pt*TMath::Sin(phi);
p[2] = pmom*TMath::Cos(theta);
if(fVertexSmear==kPerTrack) {
Rndm(random,6);
for (j=0;j<3;j++) {
origin[j]=fOrigin[j]+fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
}
Rndm(random,2);
time = fTimeOrigin + fOsigma[2]/TMath::Ccgs()*
TMath::Cos(2*random[0]*TMath::Pi())*
TMath::Sqrt(-2*TMath::Log(random[1]));
}
PushTrack(fTrackIt,-1,fIpart,p,origin,polar,time,kPPrimary,nt);
}
}
void AliGenThetaSlice::Init()
{
if(TestBit(kPtRange)&&TestBit(kMomentumRange))
Fatal("Init","You should not set the momentum range and the pt range!\n");
if((!TestBit(kPtRange))&&(!TestBit(kMomentumRange)))
Fatal("Init","You should set either the momentum or the pt range!\n");
}