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