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