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