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