Provides collision geometry.
[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
16/*
17$Log$
8b31bfac 18Revision 1.13 2001/10/21 18:35:56 hristov
19Several pointers were set to zero in the default constructors to avoid memory management problems
20
2685bf00 21Revision 1.12 2001/06/18 13:07:30 morsch
22Forward kinematic ranges to entries only if not set by user.
23
212bcf04 24Revision 1.11 2001/01/30 09:23:12 hristov
25Streamers removed (R.Brun)
26
a8a6107b 27Revision 1.10 2001/01/26 19:55:49 hristov
28Major upgrade of AliRoot code
29
2ab0c725 30Revision 1.9 2000/12/21 16:24:06 morsch
31Coding convention clean-up
32
675e9664 33Revision 1.8 2000/10/27 13:53:29 morsch
34AddGenerator: check testbit before setting the pT and momentum range
35(D.Y. Peressounko)
36
699cb625 37Revision 1.7 2000/10/02 15:15:41 morsch
38Use default streamer for AliGenCocktail
39
a436e7fc 40Revision 1.6 2000/09/07 17:04:31 morsch
41In Streamer: TIter() after R__b << fEntries (Dmitri Yurevitch Peressounko)
42
e6e2a20e 43Revision 1.5 2000/06/09 20:28:51 morsch
44All coding rule violations except RS3 corrected (AM)
45
374924b5 46Revision 1.4 1999/09/29 09:24:12 fca
47Introduction of the Copyright and cvs Log
48
4c039060 49*/
50
675e9664 51// Container class for AliGenerator through recursion.
52// Container is itself an AliGenerator.
53// What is stored are not the pointers to the generators directly but to objects of type
54// AliGenCocktail entry.
55// The class provides also iterator functionality.
56// Author: andreas.morsch@cern.ch
57//
58
fe4da5cc 59#include "AliGenCocktail.h"
374924b5 60#include "AliGenCocktailEntry.h"
fe4da5cc 61#include "AliRun.h"
675e9664 62#include <TList.h>
fe4da5cc 63
64ClassImp(AliGenCocktail)
65
66AliGenCocktail::AliGenCocktail()
67 :AliGenerator()
68{
374924b5 69// Constructor
8b31bfac 70 fName = "Cocktail";
71 fTitle= "Particle Generator using cocktail of generators";
fe4da5cc 72 fEntries = new TList;
2685bf00 73 flnk1 = 0;
74 flnk2 = 0;
fe4da5cc 75 fNGenerators=0;
76}
77
374924b5 78AliGenCocktail::AliGenCocktail(const AliGenCocktail & cocktail)
79{
80// copy constructor
81}
fe4da5cc 82
83AliGenCocktail::~AliGenCocktail()
84{
374924b5 85// Destructor
fe4da5cc 86 delete fEntries;
87}
88
89void AliGenCocktail::
a436e7fc 90AddGenerator(AliGenerator *Generator, char* Name, Float_t RateExp)
fe4da5cc 91{
92//
93// Forward parameters to the new generator
212bcf04 94 if(TestBit(kPtRange) && !(Generator->TestBit(kPtRange)) && !(Generator->TestBit(kMomentumRange)))
95 Generator->SetPtRange(fPtMin,fPtMax);
96 if(TestBit(kMomentumRange) && !(Generator->TestBit(kPtRange)) && !(Generator->TestBit(kMomentumRange)))
97 Generator->SetMomentumRange(fPMin,fPMax);
98
99 if (!(Generator->TestBit(kYRange)))
100 Generator->SetYRange(fYMin,fYMax);
101 if (!(Generator->TestBit(kPhiRange)))
102 Generator->SetPhiRange(fPhiMin*180/TMath::Pi(),fPhiMax*180/TMath::Pi());
103 if (!(Generator->TestBit(kThetaRange)))
104 Generator->SetThetaRange(fThetaMin*180/TMath::Pi(),fThetaMax*180/TMath::Pi());
105 if (!(Generator->TestBit(kVertexRange)))
106 Generator->SetOrigin(fOrigin[0], fOrigin[1], fOrigin[2]);
fe4da5cc 107 Generator->
108 SetSigma(fOsigma[0], fOsigma[1], fOsigma[2]);
7a50a130 109 Generator->SetVertexSmear(fVertexSmear);
110 Generator->SetTrackingFlag(fTrackIt);
fe4da5cc 111//
112// Add generator to list
a436e7fc 113
374924b5 114 AliGenCocktailEntry *entry =
fe4da5cc 115 new AliGenCocktailEntry(Generator, Name, RateExp);
374924b5 116 fEntries->Add(entry);
fe4da5cc 117 fNGenerators++;
118 }
119
120 void AliGenCocktail::Init()
374924b5 121{
122// Initialisation
123 TIter next(fEntries);
124 AliGenCocktailEntry *entry;
125 //
126 // Loop over generators and initialize
127 while((entry = (AliGenCocktailEntry*)next())) {
128 entry->Generator()->Init();
129 }
130}
fe4da5cc 131
132 void AliGenCocktail::Generate()
374924b5 133{
134//
135// Generate event
136 TIter next(fEntries);
137 AliGenCocktailEntry *entry;
138 AliGenCocktailEntry *e1;
139 AliGenCocktailEntry *e2;
2ab0c725 140 TObjArray *partArray = gAlice->Particles();
374924b5 141 //
142 // Loop over generators and generate events
143 Int_t igen=0;
144 while((entry = (AliGenCocktailEntry*)next())) {
145 igen++;
146 if (igen ==1) {
147 entry->SetFirst(0);
148 } else {
149 entry->SetFirst((partArray->GetEntriesFast())+1);
150 }
151 entry->Generator()->Generate();
152 entry->SetLast(partArray->GetEntriesFast());
153 }
154 next.Reset();
155 while((entry = (AliGenCocktailEntry*)next())) {
156 entry->PrintInfo();
157 }
158 for (entry=FirstGenerator();
159 entry;
160 entry=NextGenerator()
161 ) {
162 entry->PrintInfo();
163 }
164 for (FirstGeneratorPair(e1,e2);
165 (e1&&e2);
166 NextGeneratorPair(e1,e2)
167 ){
168 printf("\n -----------------------------");
169 e1->PrintInfo();
170 e2->PrintInfo();
171 }
172}
fe4da5cc 173
174AliGenCocktailEntry * AliGenCocktail::FirstGenerator()
175{
374924b5 176// Iterator over generators: Initialisation
fe4da5cc 177 flnk1 = fEntries->FirstLink();
178 if (flnk1) {
179 return (AliGenCocktailEntry*) (flnk1->GetObject());
180 } else {
181 return 0;
182 }
183}
184
185AliGenCocktailEntry* AliGenCocktail::NextGenerator()
186{
374924b5 187// Iterator over generators: Increment
fe4da5cc 188 flnk1 = flnk1->Next();
189 if (flnk1) {
190 return (AliGenCocktailEntry*) (flnk1->GetObject());
191 } else {
192 return 0;
193 }
194}
195
196void AliGenCocktail::
197FirstGeneratorPair(AliGenCocktailEntry*& e1, AliGenCocktailEntry*& e2)
198{
374924b5 199// Iterator over generator pairs: Initialisation
fe4da5cc 200 flnk2 = flnk1 = fEntries->FirstLink();
201 if (flnk1) {
202 e2 = e1 = (AliGenCocktailEntry*) (flnk1->GetObject());
203 } else {
204 e2= e1 = 0;
205 }
206}
207
208void AliGenCocktail::
209NextGeneratorPair(AliGenCocktailEntry*& e1, AliGenCocktailEntry*& e2)
210{
374924b5 211// Iterator over generators: Increment
fe4da5cc 212 flnk2 = flnk2->Next();
213 if (flnk2) {
214 e1 = (AliGenCocktailEntry*) (flnk1->GetObject());
215 e2 = (AliGenCocktailEntry*) (flnk2->GetObject());
216 } else {
217 flnk2 = flnk1 = flnk1->Next();
218 if (flnk1) {
219 e1 = (AliGenCocktailEntry*) (flnk1->GetObject());
220 e2 = (AliGenCocktailEntry*) (flnk2->GetObject());
221 } else {
222 e1=0;
223 e2=0;
224 }
225 }
226}
227
374924b5 228AliGenCocktail& AliGenCocktail::operator=(const AliGenCocktail& rhs)
229{
230// Assignment operator
231 return *this;
fe4da5cc 232}
233
234