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