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() :
43 fMevSim(new TMevSim()),
44 fConfig(new AliMevSimConfig())
52 //____________________________________________________________________________
53 AliGenMevSim::AliGenMevSim(AliMevSimConfig *config):
55 fMevSim(new TMevSim()),
64 //____________________________________________________________________________
65 AliGenMevSim::~AliGenMevSim()
68 // Standard destructor
70 if (fMevSim) delete fMevSim;
72 //____________________________________________________________________________
73 void AliGenMevSim::SetConfig(AliMevSimConfig *config)
76 // Sets the MevSim configuration
81 //____________________________________________________________________________
82 void AliGenMevSim::AddParticleType(AliMevSimParticle *type)
85 // Add one particle type to MevSim
87 fMevSim->AddPartTypeParams((TMevSimPartTypeParams*)type);
90 //____________________________________________________________________________
91 void AliGenMevSim::Init()
94 // Generator initialisation method
97 // fill data from AliMevSimConfig;
99 TMevSim *mevsim = fMevSim;
101 // geometry & momentum cut
103 if (TestBit(kPtRange)) mevsim->SetPtCutRange(fPtMin, fPtMax);
105 if (TestBit(kPhiRange)) // from radians to 0 - 360 deg
106 mevsim->SetPhiCutRange( fPhiMin * 180 / TMath::Pi() , fPhiMax * 180 / TMath::Pi() );
108 if (TestBit(kThetaRange)) // from theta to eta
110 mevsim->SetEtaCutRange( -TMath::Log( TMath::Tan(fThetaMax/2)) , -TMath::Log( TMath::Tan(fThetaMin/2)) );
113 // mevsim specyfic parameters
115 mevsim->SetModelType(fConfig->GetModelType());
116 Int_t ctrl; Float_t psiRMean = 0; Float_t psiRStDev = 0;
117 fConfig->GetRectPlane(ctrl,psiRMean,psiRStDev);
118 mevsim->SetReacPlaneCntrl(ctrl);
119 mevsim->SetPsiRParams(psiRMean, psiRStDev);
120 Float_t mean; Float_t stDev;
121 fConfig->GetMultFac(mean,stDev);
122 mevsim->SetMultFacParams(mean,stDev);
123 // mevsim initialisation
125 mevsim->Initialize();
128 //____________________________________________________________________________
129 void AliGenMevSim::Generate()
132 // Read the formatted output file and load the particles
133 // Temporary solution
139 Float_t orgin[3] = {0,0,0};
140 Float_t polar[3] = {0,0,0};
141 Float_t p[3] = {1,1,1};
144 const Int_t kParent = -1;
151 orgin[0] = fVertex[0];
152 orgin[1] = fVertex[1];
153 orgin[2] = fVertex[2];
157 cout << orgin[i] << "\t";
160 Int_t nParticles = 0;
162 TClonesArray *particles = new TClonesArray("TParticle");
165 fMevSim->GenerateEvent();
166 fNpart= fMevSim->ImportParticles(particles,"");
168 cout << "Found " << fNpart << " particles ..." << endl;
171 for (i=0; i<nParticles; i++) {
173 particle = (TParticle*) (*particles)[i];
175 pdg = (PDG_t) particle->GetPdgCode();
176 p[0] = particle->Px();
177 p[1] = particle->Py();
178 p[2] = particle->Pz();
180 PushTrack(fTrackIt, kParent, pdg, p, orgin, polar, time, kPPrimary, id);
185 if (particles) delete particles;
188 //____________________________________________________________________________
191 # define type_of_call
194 # define type_of_call _stdcall
197 extern "C" Float_t type_of_call ran(Int_t &)
200 // Replacement for package random number generator
202 return gAliRandom->Rndm();