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