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