]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVGEN/AliGenCocktail.cxx
Gfpart call replaced by using TDataBasePDG.
[u/mrichter/AliRoot.git] / EVGEN / AliGenCocktail.cxx
CommitLineData
4c039060 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
88cb7938 16/* $Id$ */
4c039060 17
675e9664 18// Container class for AliGenerator through recursion.
19// Container is itself an AliGenerator.
20// What is stored are not the pointers to the generators directly but to objects of type
21// AliGenCocktail entry.
22// The class provides also iterator functionality.
23// Author: andreas.morsch@cern.ch
24//
25
116cbefd 26#include <TList.h>
27#include <TObjArray.h>
28
fe4da5cc 29#include "AliGenCocktail.h"
374924b5 30#include "AliGenCocktailEntry.h"
09e2e187 31#include "AliCollisionGeometry.h"
fe4da5cc 32#include "AliRun.h"
fe4da5cc 33
34ClassImp(AliGenCocktail)
35
36AliGenCocktail::AliGenCocktail()
37 :AliGenerator()
38{
374924b5 39// Constructor
8b31bfac 40 fName = "Cocktail";
41 fTitle= "Particle Generator using cocktail of generators";
2685bf00 42 flnk1 = 0;
43 flnk2 = 0;
fe4da5cc 44 fNGenerators=0;
b1403e15 45 fEntries = 0;
46
fe4da5cc 47}
48
198bb1c7 49AliGenCocktail::AliGenCocktail(const AliGenCocktail & cocktail):
50 AliGenerator(cocktail)
374924b5 51{
198bb1c7 52// Copy constructor
53 cocktail.Copy(*this);
374924b5 54}
fe4da5cc 55
56AliGenCocktail::~AliGenCocktail()
57{
374924b5 58// Destructor
fe4da5cc 59 delete fEntries;
60}
61
62void AliGenCocktail::
a436e7fc 63AddGenerator(AliGenerator *Generator, char* Name, Float_t RateExp)
fe4da5cc 64{
b1403e15 65//
66// Add a generator to the list
67// First check that list exists
68 if (!fEntries) fEntries = new TList();
69
fe4da5cc 70//
71// Forward parameters to the new generator
212bcf04 72 if(TestBit(kPtRange) && !(Generator->TestBit(kPtRange)) && !(Generator->TestBit(kMomentumRange)))
73 Generator->SetPtRange(fPtMin,fPtMax);
74 if(TestBit(kMomentumRange) && !(Generator->TestBit(kPtRange)) && !(Generator->TestBit(kMomentumRange)))
75 Generator->SetMomentumRange(fPMin,fPMax);
76
77 if (!(Generator->TestBit(kYRange)))
78 Generator->SetYRange(fYMin,fYMax);
79 if (!(Generator->TestBit(kPhiRange)))
80 Generator->SetPhiRange(fPhiMin*180/TMath::Pi(),fPhiMax*180/TMath::Pi());
81 if (!(Generator->TestBit(kThetaRange)))
82 Generator->SetThetaRange(fThetaMin*180/TMath::Pi(),fThetaMax*180/TMath::Pi());
83 if (!(Generator->TestBit(kVertexRange)))
84 Generator->SetOrigin(fOrigin[0], fOrigin[1], fOrigin[2]);
c8f7f6f9 85
86 Generator->SetSigma(fOsigma[0], fOsigma[1], fOsigma[2]);
7a50a130 87 Generator->SetVertexSmear(fVertexSmear);
c8f7f6f9 88 Generator->SetVertexSource(kContainer);
89 Generator->SetTrackingFlag(fTrackIt);
fe4da5cc 90//
91// Add generator to list
a436e7fc 92
374924b5 93 AliGenCocktailEntry *entry =
fe4da5cc 94 new AliGenCocktailEntry(Generator, Name, RateExp);
374924b5 95 fEntries->Add(entry);
fe4da5cc 96 fNGenerators++;
97 }
98
99 void AliGenCocktail::Init()
374924b5 100{
101// Initialisation
102 TIter next(fEntries);
103 AliGenCocktailEntry *entry;
104 //
105 // Loop over generators and initialize
106 while((entry = (AliGenCocktailEntry*)next())) {
107 entry->Generator()->Init();
108 }
109}
fe4da5cc 110
09e2e187 111 void AliGenCocktail::FinishRun()
112{
113// Initialisation
114 TIter next(fEntries);
115 AliGenCocktailEntry *entry;
116 //
117 // Loop over generators and initialize
118 while((entry = (AliGenCocktailEntry*)next())) {
119 entry->Generator()->FinishRun();
120 }
121}
122
fe4da5cc 123 void AliGenCocktail::Generate()
374924b5 124{
125//
126// Generate event
127 TIter next(fEntries);
a8408367 128 AliGenCocktailEntry *entry = 0;
129 AliGenCocktailEntry *preventry = 0;
130 AliGenerator* gen = 0;
09e2e187 131
2ab0c725 132 TObjArray *partArray = gAlice->Particles();
c8f7f6f9 133
134//
135// Generate the vertex position used by all generators
136//
137 if(fVertexSmear == kPerEvent) Vertex();
138
139
140 //
374924b5 141 // Loop over generators and generate events
142 Int_t igen=0;
a8408367 143
374924b5 144 while((entry = (AliGenCocktailEntry*)next())) {
145 igen++;
146 if (igen ==1) {
147 entry->SetFirst(0);
148 } else {
149 entry->SetFirst((partArray->GetEntriesFast())+1);
150 }
a8408367 151//
152// Handle case in which current generator needs collision geometry from previous generator
153//
154 gen = entry->Generator();
155 if (gen->NeedsCollisionGeometry())
156 {
157 if (preventry && preventry->Generator()->ProvidesCollisionGeometry())
158 {
159 gen->SetCollisionGeometry(preventry->Generator()->CollisionGeometry());
160 } else {
161 Fatal("Generate()", "No Collision Geometry Provided");
162 }
163 }
c8f7f6f9 164 entry->Generator()->SetVertex(fVertex.At(0), fVertex.At(1), fVertex.At(2));
374924b5 165 entry->Generator()->Generate();
166 entry->SetLast(partArray->GetEntriesFast());
a8408367 167 preventry = entry;
374924b5 168 }
169 next.Reset();
374924b5 170}
fe4da5cc 171
172AliGenCocktailEntry * AliGenCocktail::FirstGenerator()
173{
374924b5 174// Iterator over generators: Initialisation
fe4da5cc 175 flnk1 = fEntries->FirstLink();
176 if (flnk1) {
177 return (AliGenCocktailEntry*) (flnk1->GetObject());
178 } else {
179 return 0;
180 }
181}
182
183AliGenCocktailEntry* AliGenCocktail::NextGenerator()
184{
374924b5 185// Iterator over generators: Increment
fe4da5cc 186 flnk1 = flnk1->Next();
187 if (flnk1) {
188 return (AliGenCocktailEntry*) (flnk1->GetObject());
189 } else {
190 return 0;
191 }
192}
193
194void AliGenCocktail::
195FirstGeneratorPair(AliGenCocktailEntry*& e1, AliGenCocktailEntry*& e2)
196{
374924b5 197// Iterator over generator pairs: Initialisation
fe4da5cc 198 flnk2 = flnk1 = fEntries->FirstLink();
199 if (flnk1) {
200 e2 = e1 = (AliGenCocktailEntry*) (flnk1->GetObject());
201 } else {
202 e2= e1 = 0;
203 }
204}
205
206void AliGenCocktail::
207NextGeneratorPair(AliGenCocktailEntry*& e1, AliGenCocktailEntry*& e2)
208{
374924b5 209// Iterator over generators: Increment
fe4da5cc 210 flnk2 = flnk2->Next();
211 if (flnk2) {
212 e1 = (AliGenCocktailEntry*) (flnk1->GetObject());
213 e2 = (AliGenCocktailEntry*) (flnk2->GetObject());
214 } else {
215 flnk2 = flnk1 = flnk1->Next();
216 if (flnk1) {
217 e1 = (AliGenCocktailEntry*) (flnk1->GetObject());
218 e2 = (AliGenCocktailEntry*) (flnk2->GetObject());
219 } else {
220 e1=0;
221 e2=0;
222 }
223 }
224}
225
374924b5 226AliGenCocktail& AliGenCocktail::operator=(const AliGenCocktail& rhs)
227{
228// Assignment operator
198bb1c7 229 rhs.Copy(*this);
230 return (*this);
fe4da5cc 231}
232
198bb1c7 233void AliGenCocktail::Copy(AliGenCocktail &) const
234{
235 Fatal("Copy","Not implemented!\n");
236}
237
238
fe4da5cc 239