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