]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVGEN/AliGenScan.cxx
c540cab0d7b805029af67558c4563806d2231d71
[u/mrichter/AliRoot.git] / EVGEN / AliGenScan.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 // Realisation of AliGenerator that generates particles with
19 // vertices on a user defined grid.
20 // The vertex positions can be smeared. 
21 // Momentum vectors are defined through the methods provided by AliGenerator.
22 // Author: andreas.morsch@cern.ch
23
24 #include "AliGenScan.h"
25 #include "AliRun.h"
26
27  ClassImp(AliGenScan)
28     
29  AliGenScan::AliGenScan()
30          :AliGenerator(-1)
31 {
32 // Constructor
33     fXCmin=0;
34     fXCmax=0;
35     fNx=1;
36     fYCmin=0;
37     fYCmax=0;
38     fNy=1;
39     fZmin=0;
40     fZmax=0;
41     fNz=1;
42 //
43 //  Read all particles
44     fNpart=-1;
45 }
46
47 AliGenScan::AliGenScan(Int_t npart)
48     :AliGenerator(npart)
49 {
50 // Constructor
51     fName  = "Scan";
52     fTitle = "Generator for particles on a grid";
53
54
55     fXCmin=0;
56     fXCmax=0;
57     fNx=1;
58     fYCmin=0;
59     fYCmax=0;
60     fNy=1;
61     fZmin=0;
62     fZmax=0;
63     fNz=1;
64 }
65
66 //____________________________________________________________
67 AliGenScan::~AliGenScan()
68 {
69 // Destructor
70 }
71
72 void AliGenScan::SetRange(Int_t nx, Float_t xmin, Float_t xmax,
73                      Int_t ny, Float_t ymin, Float_t ymax,
74                      Int_t nz, Float_t zmin, Float_t zmax)
75 {
76 // Define the grid
77     fXCmin=xmin;
78     fXCmax=xmax;
79     fNx=nx;
80     fYCmin=ymin;
81     fYCmax=ymax;
82     fNy=ny;
83     fZmin=zmin;
84     fZmax=zmax;
85     fNz=nz;
86 }
87
88 //____________________________________________________________
89 void AliGenScan::Generate()
90 {
91   //
92   // Generate one trigger
93   //
94   
95   Float_t polar[3]= {0,0,0};
96   //
97   Float_t origin[3];
98   Float_t p[3];
99   Int_t nt;
100   Float_t pmom, theta, phi;
101   //
102   Float_t random[6];
103   Float_t dx,dy,dz;
104   
105   //
106   if (fNx > 0) {
107       dx=(fXCmax-fXCmin)/fNx;
108   } else {
109       dx=1e10;
110   }
111
112   if (fNy > 0) {
113       dy=(fYCmax-fYCmin)/fNy;
114   } else {
115       dy=1e10;
116   }
117
118   if (fNz > 0) {
119       dz=(fZmax-fZmin)/fNz;
120   } else {
121       dz=1e10;
122   }
123   for (Int_t ix=0; ix<fNx; ix++) {
124       for (Int_t iy=0; iy<fNy; iy++) {
125           for (Int_t iz=0; iz<fNz; iz++){
126               Rndm(random,6);
127               origin[0]=fXCmin+ix*dx+2*(random[0]-0.5)*fOsigma[0];
128               origin[1]=fYCmin+iy*dy+2*(random[1]-0.5)*fOsigma[1];
129               origin[2]=fZmin+iz*dz+2*(random[2]-0.5)*fOsigma[2];            
130               pmom=fPMin+random[3]*(fPMax-fPMin);
131               theta=fThetaMin+random[4]*(fThetaMax-fThetaMin);
132               phi=fPhiMin+random[5]*(fPhiMax-fPhiMin);
133               p[0] = pmom*TMath::Cos(phi)*TMath::Sin(theta);
134               p[1] = pmom*TMath::Sin(phi)*TMath::Sin(theta);
135               p[2] = pmom*TMath::Cos(theta);
136               PushTrack(fTrackIt,-1,fIpart,p,origin,polar,0,kPPrimary,nt);
137           }
138       }
139   }
140 }
141
142
143
144
145
146
147
148
149