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$ |
699cb625 |
18 | Revision 1.7 2000/10/02 15:15:41 morsch |
19 | Use default streamer for AliGenCocktail |
20 | |
a436e7fc |
21 | Revision 1.6 2000/09/07 17:04:31 morsch |
22 | In Streamer: TIter() after R__b << fEntries (Dmitri Yurevitch Peressounko) |
23 | |
e6e2a20e |
24 | Revision 1.5 2000/06/09 20:28:51 morsch |
25 | All coding rule violations except RS3 corrected (AM) |
26 | |
374924b5 |
27 | Revision 1.4 1999/09/29 09:24:12 fca |
28 | Introduction of the Copyright and cvs Log |
29 | |
4c039060 |
30 | */ |
31 | |
fe4da5cc |
32 | #include "AliGenCocktail.h" |
374924b5 |
33 | #include "AliGenCocktailEntry.h" |
fe4da5cc |
34 | #include "AliRun.h" |
fe4da5cc |
35 | |
36 | ClassImp(AliGenCocktail) |
37 | |
38 | AliGenCocktail::AliGenCocktail() |
39 | :AliGenerator() |
40 | { |
374924b5 |
41 | // Constructor |
fe4da5cc |
42 | fEntries = new TList; |
43 | fNGenerators=0; |
44 | } |
45 | |
374924b5 |
46 | AliGenCocktail::AliGenCocktail(const AliGenCocktail & cocktail) |
47 | { |
48 | // copy constructor |
49 | } |
fe4da5cc |
50 | |
51 | AliGenCocktail::~AliGenCocktail() |
52 | { |
374924b5 |
53 | // Destructor |
fe4da5cc |
54 | delete fEntries; |
55 | } |
56 | |
57 | void AliGenCocktail:: |
a436e7fc |
58 | AddGenerator(AliGenerator *Generator, char* Name, Float_t RateExp) |
fe4da5cc |
59 | { |
60 | // |
61 | // Forward parameters to the new generator |
699cb625 |
62 | if(TestBit(kPtRange)) |
fe4da5cc |
63 | Generator->SetPtRange(fPtMin,fPtMax); |
699cb625 |
64 | if(TestBit(kMomentumRange)) |
fe4da5cc |
65 | Generator->SetMomentumRange(fPMin,fPMax); |
699cb625 |
66 | |
fe4da5cc |
67 | Generator->SetYRange(fYMin,fYMax); |
68 | Generator-> |
69 | SetPhiRange(fPhiMin*180/TMath::Pi(),fPhiMax*180/TMath::Pi()); |
70 | Generator-> |
71 | SetThetaRange(fThetaMin*180/TMath::Pi(),fThetaMax*180/TMath::Pi()); |
72 | Generator-> |
73 | SetOrigin(fOrigin[0], fOrigin[1], fOrigin[2]); |
74 | Generator-> |
75 | SetSigma(fOsigma[0], fOsigma[1], fOsigma[2]); |
7a50a130 |
76 | Generator->SetVertexSmear(fVertexSmear); |
77 | Generator->SetTrackingFlag(fTrackIt); |
fe4da5cc |
78 | // |
79 | // Add generator to list |
a436e7fc |
80 | |
374924b5 |
81 | AliGenCocktailEntry *entry = |
fe4da5cc |
82 | new AliGenCocktailEntry(Generator, Name, RateExp); |
374924b5 |
83 | fEntries->Add(entry); |
fe4da5cc |
84 | fNGenerators++; |
85 | } |
86 | |
87 | void AliGenCocktail::Init() |
374924b5 |
88 | { |
89 | // Initialisation |
90 | TIter next(fEntries); |
91 | AliGenCocktailEntry *entry; |
92 | // |
93 | // Loop over generators and initialize |
94 | while((entry = (AliGenCocktailEntry*)next())) { |
95 | entry->Generator()->Init(); |
96 | } |
97 | } |
fe4da5cc |
98 | |
99 | void AliGenCocktail::Generate() |
374924b5 |
100 | { |
101 | // |
102 | // Generate event |
103 | TIter next(fEntries); |
104 | AliGenCocktailEntry *entry; |
105 | AliGenCocktailEntry *e1; |
106 | AliGenCocktailEntry *e2; |
107 | TClonesArray *partArray = gAlice->Particles(); |
108 | // |
109 | // Loop over generators and generate events |
110 | Int_t igen=0; |
111 | while((entry = (AliGenCocktailEntry*)next())) { |
112 | igen++; |
113 | if (igen ==1) { |
114 | entry->SetFirst(0); |
115 | } else { |
116 | entry->SetFirst((partArray->GetEntriesFast())+1); |
117 | } |
118 | entry->Generator()->Generate(); |
119 | entry->SetLast(partArray->GetEntriesFast()); |
120 | } |
121 | next.Reset(); |
122 | while((entry = (AliGenCocktailEntry*)next())) { |
123 | entry->PrintInfo(); |
124 | } |
125 | for (entry=FirstGenerator(); |
126 | entry; |
127 | entry=NextGenerator() |
128 | ) { |
129 | entry->PrintInfo(); |
130 | } |
131 | for (FirstGeneratorPair(e1,e2); |
132 | (e1&&e2); |
133 | NextGeneratorPair(e1,e2) |
134 | ){ |
135 | printf("\n -----------------------------"); |
136 | e1->PrintInfo(); |
137 | e2->PrintInfo(); |
138 | } |
139 | } |
fe4da5cc |
140 | |
141 | AliGenCocktailEntry * AliGenCocktail::FirstGenerator() |
142 | { |
374924b5 |
143 | // Iterator over generators: Initialisation |
fe4da5cc |
144 | flnk1 = fEntries->FirstLink(); |
145 | if (flnk1) { |
146 | return (AliGenCocktailEntry*) (flnk1->GetObject()); |
147 | } else { |
148 | return 0; |
149 | } |
150 | } |
151 | |
152 | AliGenCocktailEntry* AliGenCocktail::NextGenerator() |
153 | { |
374924b5 |
154 | // Iterator over generators: Increment |
fe4da5cc |
155 | flnk1 = flnk1->Next(); |
156 | if (flnk1) { |
157 | return (AliGenCocktailEntry*) (flnk1->GetObject()); |
158 | } else { |
159 | return 0; |
160 | } |
161 | } |
162 | |
163 | void AliGenCocktail:: |
164 | FirstGeneratorPair(AliGenCocktailEntry*& e1, AliGenCocktailEntry*& e2) |
165 | { |
374924b5 |
166 | // Iterator over generator pairs: Initialisation |
fe4da5cc |
167 | flnk2 = flnk1 = fEntries->FirstLink(); |
168 | if (flnk1) { |
169 | e2 = e1 = (AliGenCocktailEntry*) (flnk1->GetObject()); |
170 | } else { |
171 | e2= e1 = 0; |
172 | } |
173 | } |
174 | |
175 | void AliGenCocktail:: |
176 | NextGeneratorPair(AliGenCocktailEntry*& e1, AliGenCocktailEntry*& e2) |
177 | { |
374924b5 |
178 | // Iterator over generators: Increment |
fe4da5cc |
179 | flnk2 = flnk2->Next(); |
180 | if (flnk2) { |
181 | e1 = (AliGenCocktailEntry*) (flnk1->GetObject()); |
182 | e2 = (AliGenCocktailEntry*) (flnk2->GetObject()); |
183 | } else { |
184 | flnk2 = flnk1 = flnk1->Next(); |
185 | if (flnk1) { |
186 | e1 = (AliGenCocktailEntry*) (flnk1->GetObject()); |
187 | e2 = (AliGenCocktailEntry*) (flnk2->GetObject()); |
188 | } else { |
189 | e1=0; |
190 | e2=0; |
191 | } |
192 | } |
193 | } |
194 | |
a436e7fc |
195 | /* |
fe4da5cc |
196 | void AliGenCocktail::Streamer(TBuffer &R__b) |
197 | { |
374924b5 |
198 | // Stream an object of class AliGenCocktail. |
e6e2a20e |
199 | |
374924b5 |
200 | AliGenCocktailEntry *entry; |
201 | |
202 | if (R__b.IsReading()) { |
203 | Version_t R__v = R__b.ReadVersion(); if (R__v) { } |
204 | AliGenerator::Streamer(R__b); |
205 | R__b >> fNGenerators; |
206 | R__b >> fEntries; |
e6e2a20e |
207 | TIter next(fEntries); |
fe4da5cc |
208 | // Stream generation related information |
374924b5 |
209 | while((entry = (AliGenCocktailEntry*)next())) { |
210 | entry->Streamer(R__b); |
211 | } |
212 | } else { |
213 | R__b.WriteVersion(AliGenCocktail::IsA()); |
214 | AliGenerator::Streamer(R__b); |
215 | R__b << fNGenerators; |
216 | R__b << fEntries; |
e6e2a20e |
217 | TIter next(fEntries); |
fe4da5cc |
218 | // Stream generation related information |
374924b5 |
219 | while((entry = (AliGenCocktailEntry*)next())) { |
220 | entry->Streamer(R__b); |
221 | } |
222 | } |
223 | } |
a436e7fc |
224 | */ |
374924b5 |
225 | |
226 | AliGenCocktail& AliGenCocktail::operator=(const AliGenCocktail& rhs) |
227 | { |
228 | // Assignment operator |
229 | return *this; |
fe4da5cc |
230 | } |
231 | |
232 | |