1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 // Wrapper for MEVSIM generator.
20 // It is using TMevSim to comunicate with fortarn code
23 // Sylwester Radomski <radomski@if.pw.edu.pl>
26 #include <Riostream.h>
27 #include <TClonesArray.h>
28 #include <TParticle.h>
30 #include "AliGenMevSim.h"
31 #include "AliMevSimConfig.h"
32 #include "AliMevSimParticle.h"
36 static TRandom * gAliRandom;
38 ClassImp(AliGenMevSim)
40 //____________________________________________________________________________
41 AliGenMevSim::AliGenMevSim() : AliGenerator(-1)
46 fConfig = new AliMevSimConfig();
47 fMevSim = new TMevSim();
51 //____________________________________________________________________________
52 AliGenMevSim::AliGenMevSim(AliMevSimConfig *config): AliGenerator(-1)
58 fMevSim = new TMevSim();
62 //____________________________________________________________________________
63 AliGenMevSim::~AliGenMevSim()
66 // Standard destructor
68 if (fMevSim) delete fMevSim;
70 //____________________________________________________________________________
71 void AliGenMevSim::SetConfig(AliMevSimConfig *config)
74 // Sets the MevSim configuration
79 //____________________________________________________________________________
80 void AliGenMevSim::AddParticleType(AliMevSimParticle *type)
83 // Add one particle type to MevSim
85 fMevSim->AddPartTypeParams((TMevSimPartTypeParams*)type);
88 //____________________________________________________________________________
89 void AliGenMevSim::Init()
92 // Generator initialisation method
95 // fill data from AliMevSimConfig;
97 TMevSim *mevsim = fMevSim;
99 // geometry & momentum cut
101 if (TestBit(kPtRange)) mevsim->SetPtCutRange(fPtMin, fPtMax);
103 if (TestBit(kPhiRange)) // from radians to 0 - 360 deg
104 mevsim->SetPhiCutRange( fPhiMin * 180 / TMath::Pi() , fPhiMax * 180 / TMath::Pi() );
106 if (TestBit(kThetaRange)) // from theta to eta
108 mevsim->SetEtaCutRange( -TMath::Log( TMath::Tan(fThetaMax/2)) , -TMath::Log( TMath::Tan(fThetaMin/2)) );
111 // mevsim specyfic parameters
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);
121 // mevsim initialisation
123 mevsim->Initialize();
126 //____________________________________________________________________________
127 void AliGenMevSim::Generate()
130 // Read the formatted output file and load the particles
131 // Temporary solution
137 Float_t orgin[3] = {0,0,0};
138 Float_t polar[3] = {0,0,0};
139 Float_t p[3] = {1,1,1};
142 const Int_t kParent = -1;
149 orgin[0] = fVertex[0];
150 orgin[1] = fVertex[1];
151 orgin[2] = fVertex[2];
155 cout << orgin[i] << "\t";
158 Int_t nParticles = 0;
160 TClonesArray *particles = new TClonesArray("TParticle");
163 fMevSim->GenerateEvent();
164 fNpart= fMevSim->ImportParticles(particles,"");
166 cout << "Found " << fNpart << " particles ..." << endl;
169 for (i=0; i<nParticles; i++) {
171 particle = (TParticle*) (*particles)[i];
173 pdg = (PDG_t) particle->GetPdgCode();
174 p[0] = particle->Px();
175 p[1] = particle->Py();
176 p[2] = particle->Pz();
178 PushTrack(fTrackIt, kParent, pdg, p, orgin, polar, time, kPPrimary, id);
183 if (particles) delete particles;
186 //____________________________________________________________________________
189 # define type_of_call
192 # define type_of_call _stdcall
195 extern "C" Float_t type_of_call ran(Int_t &)
198 // Replacement for package random number generator
200 return gAliRandom->Rndm();