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