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