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