]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TMEVSIM/AliGenMevSim.cxx
- The default value of useFastDecoder in ctor changed to kFALSE,
[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
73968a51 26#include <Riostream.h>
37b09b91 27#include <TClonesArray.h>
28#include <TParticle.h>
36b81802 29
30#include "AliGenMevSim.h"
73968a51 31#include "AliMevSimConfig.h"
32#include "AliMevSimParticle.h"
33//#include "AliRun.h"
34#include "TMevSim.h"
36b81802 35
73968a51 36static TRandom * gAliRandom;
36b81802 37
38ClassImp(AliGenMevSim)
39
40//____________________________________________________________________________
41AliGenMevSim::AliGenMevSim() : AliGenerator(-1)
42{
43 //
73968a51 44 // Default ctor
36b81802 45 //
36b81802 46 fConfig = new AliMevSimConfig();
47 fMevSim = new TMevSim();
73968a51 48 gAliRandom = fRandom;
36b81802 49
50}
51//____________________________________________________________________________
73968a51 52AliGenMevSim::AliGenMevSim(AliMevSimConfig *config): AliGenerator(-1)
53{
54 //
55 // Standard ctor
56 //
36b81802 57 fConfig = config;
58 fMevSim = new TMevSim();
73968a51 59 gAliRandom = fRandom;
36b81802 60}
61
62//____________________________________________________________________________
63AliGenMevSim::~AliGenMevSim()
64{
65 //
66 // Standard destructor
67 //
68 if (fMevSim) delete fMevSim;
69}
70//____________________________________________________________________________
73968a51 71void AliGenMevSim::SetConfig(AliMevSimConfig *config)
72{
73 //
74 // Sets the MevSim configuration
75 //
36b81802 76 fConfig = config;
77}
36b81802 78
73968a51 79//____________________________________________________________________________
80void AliGenMevSim::AddParticleType(AliMevSimParticle *type)
81{
82 //
83 // Add one particle type to MevSim
84 //
36b81802 85 fMevSim->AddPartTypeParams((TMevSimPartTypeParams*)type);
86}
73968a51 87
36b81802 88//____________________________________________________________________________
89void AliGenMevSim::Init()
90{
91 //
92 // Generator initialisation method
93 //
94
95 // fill data from AliMevSimConfig;
96
97 TMevSim *mevsim = fMevSim;
98
99 // geometry & momentum cut
100
101 if (TestBit(kPtRange)) mevsim->SetPtCutRange(fPtMin, fPtMax);
102
103 if (TestBit(kPhiRange)) // from radians to 0 - 360 deg
104 mevsim->SetPhiCutRange( fPhiMin * 180 / TMath::Pi() , fPhiMax * 180 / TMath::Pi() );
105
106 if (TestBit(kThetaRange)) // from theta to eta
107 {
108 mevsim->SetEtaCutRange( -TMath::Log( TMath::Tan(fThetaMax/2)) , -TMath::Log( TMath::Tan(fThetaMin/2)) );
109 }
110
111 // mevsim specyfic parameters
112
bb52edc0 113 mevsim->SetModelType(fConfig->GetModelType());
114 Int_t ctrl; Float_t psiRMean = 0; Float_t psiRStDev = 0;
115 fConfig->GetRectPlane(ctrl,psiRMean,psiRStDev);
116 mevsim->SetReacPlaneCntrl(ctrl);
117 mevsim->SetPsiRParams(psiRMean, psiRStDev);
118 Float_t mean; Float_t stDev;
119 fConfig->GetMultFac(mean,stDev);
120 mevsim->SetMultFacParams(mean,stDev);
36b81802 121 // mevsim initialisation
122
123 mevsim->Initialize();
124}
125
126//____________________________________________________________________________
127void AliGenMevSim::Generate()
128{
129 //
130 // Read the formatted output file and load the particles
131 // Temporary solution
132 //
133
134 Int_t i;
135
136 PDG_t pdg;
137 Float_t orgin[3] = {0,0,0};
138 Float_t polar[3] = {0,0,0};
139 Float_t p[3] = {1,1,1};
140 Float_t time = 0;
141
73968a51 142 const Int_t kParent = -1;
36b81802 143 Int_t id;
144
145 // vertexing
146
147 VertexInternal();
148
149 orgin[0] = fVertex[0];
150 orgin[1] = fVertex[1];
151 orgin[2] = fVertex[2];
152
153 cout << "Vertex ";
154 for (i =0; i<3; i++)
155 cout << orgin[i] << "\t";
156 cout << endl;
157
158 Int_t nParticles = 0;
159
160 TClonesArray *particles = new TClonesArray("TParticle");
161 TParticle *particle;
162
163 fMevSim->GenerateEvent();
164 fNpart= fMevSim->ImportParticles(particles,"");
165
166 cout << "Found " << fNpart << " particles ..." << endl;
167 nParticles = fNpart;
168
169 for (i=0; i<nParticles; i++) {
170
171 particle = (TParticle*) (*particles)[i];
172
173 pdg = (PDG_t) particle->GetPdgCode();
174 p[0] = particle->Px();
175 p[1] = particle->Py();
176 p[2] = particle->Pz();
177
73968a51 178 PushTrack(fTrackIt, kParent, pdg, p, orgin, polar, time, kPPrimary, id);
36b81802 179
180 }
181
182 particles->Clear();
183 if (particles) delete particles;
184}
36b81802 185
73968a51 186//____________________________________________________________________________
36b81802 187#ifndef WIN32
188# define ran ran_
189# define type_of_call
190#else
191# define ran RAN
192# define type_of_call _stdcall
193#endif
194
195extern "C" Float_t type_of_call ran(Int_t &)
196{
73968a51 197 //
198 // Replacement for package random number generator
199 //
200 return gAliRandom->Rndm();
36b81802 201}
202