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