Generate on a three dimensional grid to simulate test-beam situation
[u/mrichter/AliRoot.git] / EVGEN / AliGenScan.cxx
CommitLineData
b0418df4 1#include "AliGenScan.h"
2#include <stdlib.h>
3#include "AliRun.h"
4 ClassImp(AliGenScan)
5
6 AliGenScan::AliGenScan()
7 :AliGenerator(-1)
8{
9//
10 fXmin=0;
11 fXmax=0;
12 fNx=1;
13 fYmin=0;
14 fYmax=0;
15 fNy=1;
16 fZmin=0;
17 fZmax=0;
18 fNz=1;
19//
20// Read all particles
21 fNpart=-1;
22}
23
24AliGenScan::AliGenScan(Int_t npart)
25 :AliGenerator(npart)
26{
27 fXmin=0;
28 fXmax=0;
29 fNx=1;
30 fYmin=0;
31 fYmax=0;
32 fNy=1;
33 fZmin=0;
34 fZmax=0;
35 fNz=1;
36}
37
38//____________________________________________________________
39AliGenScan::~AliGenScan()
40{}
41
42void AliGenScan::SetRange(Int_t nx, Float_t xmin, Float_t xmax,
43 Int_t ny, Float_t ymin, Float_t ymax,
44 Int_t nz, Float_t zmin, Float_t zmax)
45{
46 fXmin=xmin;
47 fXmax=xmax;
48 fNx=nx;
49 fYmin=ymin;
50 fYmax=ymax;
51 fNy=ny;
52 fZmin=zmin;
53 fZmax=zmax;
54 fNz=nz;
55}
56
57//____________________________________________________________
58void AliGenScan::Generate()
59{
60 //
61 // Generate one trigger
62 //
63 AliMC* pMC = AliMC::GetMC();
64
65 Float_t polar[3]= {0,0,0};
66 //
67 Float_t origin[3];
68 Float_t p[3];
69 Int_t nt;
70 Float_t pmom, theta, phi;
71 //
72 Float_t random[6];
73 Float_t dx,dy,dz;
74
75 //
76 if (fNy > 0) {
77 dx=(fXmax-fXmin)/fNx;
78 } else {
79 dx=1e10;
80 }
81
82 if (fNy > 0) {
83 dy=(fYmax-fYmin)/fNy;
84 } else {
85 dy=1e10;
86 }
87
88 if (fNz > 0) {
89 dz=(fZmax-fZmin)/fNz;
90 } else {
91 dz=1e10;
92 }
93 for (Int_t ix=0; ix<fNx; ix++) {
94 for (Int_t iy=0; iy<fNy; iy++) {
95 for (Int_t iz=0; iz<fNz; iz++){
96 pMC->Rndm(random,6);
97 origin[0]=fXmin+ix*dx+2*(random[0]-0.5)*fOsigma[0];
98 origin[1]=fYmin+iy*dy+2*(random[1]-0.5)*fOsigma[1];
99 origin[2]=fZmin+iz*dz+2*(random[2]-0.5)*fOsigma[2];
100 pmom=fPMin+random[3]*(fPMax-fPMin);
101 theta=fThetaMin+random[4]*(fThetaMax-fThetaMin);
102 phi=fPhiMin+random[5]*(fPhiMax-fPhiMin);
103 p[0] = pmom*TMath::Cos(phi)*TMath::Sin(theta);
104 p[1] = pmom*TMath::Sin(phi)*TMath::Sin(theta);
105 p[2] = pmom*TMath::Cos(theta);
106 gAlice->SetTrack(1,-1,fIpart,p,origin,polar,0,"Primary",nt);
107 }
108 }
109 }
110}
111
112
113
114
115
116
117
118
119