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