]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TMEVSIM/AliGenMevSim.cxx
Changes related to the initialization of random numbers generators. Now one can use...
[u/mrichter/AliRoot.git] / TMEVSIM / AliGenMevSim.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 //
19 // Wrapper for MEVSIM generator.
20 // It is using TMevSim to comunicate with fortarn code
21 // 
22 //      
23 // Sylwester Radomski <radomski@if.pw.edu.pl>
24 //
25
26 //#include "TSystem.h"
27 //#include "TUnixSystem.h"
28 #include "TParticle.h"
29 #include "TMevSim.h"
30
31 #include "AliGenMevSim.h"
32 #include "AliRun.h"
33
34
35 ClassImp(AliGenMevSim)
36
37 static TRandom * sRandom;
38
39 //____________________________________________________________________________
40 AliGenMevSim::AliGenMevSim() : AliGenerator(-1) 
41 {
42   //
43   // Standard creator
44   //
45   
46   fConfig = new AliMevSimConfig();
47   fMevSim = new TMevSim();
48   sRandom = fRandom;
49   
50 }
51 //____________________________________________________________________________
52 AliGenMevSim::AliGenMevSim(AliMevSimConfig *config): AliGenerator(-1) {
53
54   fConfig = config;
55   fMevSim = new TMevSim(); 
56   sRandom = fRandom;
57 }
58
59 //____________________________________________________________________________
60 AliGenMevSim::~AliGenMevSim() 
61 {
62   //
63   // Standard destructor
64   //
65   if (fMevSim) delete fMevSim;
66 }
67 //____________________________________________________________________________
68 void AliGenMevSim::SetConfig(AliMevSimConfig *config) {
69   
70   fConfig = config;
71 }
72 //____________________________________________________________________________
73 void AliGenMevSim::AddParticleType(AliMevSimParticle *type) {
74
75   fMevSim->AddPartTypeParams((TMevSimPartTypeParams*)type);
76 }
77 //____________________________________________________________________________
78 void AliGenMevSim::Init() 
79 {
80   //
81   // Generator initialisation method
82   //
83
84   // fill data from AliMevSimConfig;
85
86   TMevSim *mevsim = fMevSim;
87
88   // geometry & momentum cut
89
90   if (TestBit(kPtRange))  mevsim->SetPtCutRange(fPtMin, fPtMax);
91   
92   if (TestBit(kPhiRange)) // from radians to 0 - 360 deg
93     mevsim->SetPhiCutRange( fPhiMin * 180 / TMath::Pi() , fPhiMax * 180 / TMath::Pi() );
94   
95   if (TestBit(kThetaRange)) // from theta to eta
96   {
97     mevsim->SetEtaCutRange( -TMath::Log( TMath::Tan(fThetaMax/2)) , -TMath::Log( TMath::Tan(fThetaMin/2)) );
98   }  
99
100   // mevsim specyfic parameters
101   
102   mevsim->SetModelType(fConfig->fModelType);
103   mevsim->SetReacPlaneCntrl(fConfig->fReacPlaneCntrl);
104   mevsim->SetPsiRParams(fConfig->fPsiRMean, fConfig->fPsiRStDev);
105   mevsim->SetMultFacParams(fConfig->fMultFacMean, fConfig->fMultFacStDev);
106   
107   // mevsim initialisation
108
109   mevsim->Initialize();
110 }
111
112 //____________________________________________________________________________
113 void AliGenMevSim::Generate() 
114 {
115   //
116   // Read the formatted output file and load the particles
117   // Temporary solution
118   //
119
120   Int_t i;
121
122   PDG_t pdg;
123   Float_t orgin[3] = {0,0,0};
124   Float_t polar[3] = {0,0,0};
125   Float_t p[3] = {1,1,1};
126   Float_t time = 0;
127   
128   const Int_t parent = -1;
129   Int_t id;
130
131   // vertexing 
132
133   VertexInternal();
134
135   orgin[0] = fVertex[0];
136   orgin[1] = fVertex[1];
137   orgin[2] = fVertex[2];
138
139   cout << "Vertex ";
140   for (i =0; i<3; i++)
141     cout << orgin[i] << "\t";
142   cout << endl;
143
144   Int_t nParticles = 0;
145
146   TClonesArray *particles = new TClonesArray("TParticle");
147   TParticle *particle;
148
149   fMevSim->GenerateEvent();
150   fNpart= fMevSim->ImportParticles(particles,"");
151
152   cout << "Found " << fNpart << " particles ..." << endl;
153   nParticles = fNpart;
154
155   for (i=0; i<nParticles; i++) {
156     
157     particle = (TParticle*) (*particles)[i];
158
159     pdg = (PDG_t) particle->GetPdgCode();
160     p[0] = particle->Px();
161     p[1] = particle->Py();
162     p[2] = particle->Pz();
163     
164     SetTrack(fTrackIt, parent, pdg, p, orgin, polar, time, kPPrimary, id);
165
166   }  
167  
168   particles->Clear();
169   if (particles) delete particles;
170 }
171 //____________________________________________________________________________
172 //____________________________________________________________________________
173
174
175 #ifndef WIN32
176 # define ran ran_
177 # define type_of_call
178 #else
179 # define ran RAN
180 # define type_of_call _stdcall
181 #endif
182
183 extern "C" Float_t type_of_call ran(Int_t &)
184 {
185   return sRandom->Rndm(); 
186 }
187
188 //____________________________________________________________________________