]>
Commit | Line | Data |
---|---|---|
0b359ada | 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 | ||
88cb7938 | 16 | /* $Id$ */ |
17 | ||
0b359ada | 18 | // |
19 | // Container class for AliGenerator and AfterBurners | |
20 | // (which are AliGenerators as well) through recursion. | |
21 | // The container is itself an AliGenerator a | |
22 | // what is stored are not the pointers to the generators directly | |
23 | // but to objects of type | |
24 | // AliGenCocktailAfterBurner entry. | |
25 | // The class provides also iterator functionality. | |
26 | // Author: andreas.morsch@cern.ch and piotr.skowronski@cern.ch | |
27 | // | |
2b9786f4 | 28 | // 24.09.2001 Piotr Skowronski |
29 | // debug -> gDebug, | |
30 | // fNEvents replaced with gAlice->GetEventsPerRun() | |
31 | // | |
2b9786f4 | 32 | |
88cb7938 | 33 | |
34 | #include <Riostream.h> | |
35 | ||
0b359ada | 36 | #include <TList.h> |
88cb7938 | 37 | #include <TObjArray.h> |
0b359ada | 38 | #include <TParticle.h> |
88cb7938 | 39 | |
40 | #include "AliGenCocktailAfterBurner.h" | |
41 | #include "AliGenCocktailEntry.h" | |
cc41459d | 42 | #include "AliCollisionGeometry.h" |
88cb7938 | 43 | #include "AliStack.h" |
5d12ce38 | 44 | #include "AliMC.h" |
0b359ada | 45 | |
2b9786f4 | 46 | |
0b359ada | 47 | ClassImp(AliGenCocktailAfterBurner) |
2b9786f4 | 48 | /*********************************************************************/ |
49 | /*********************************************************************/ | |
0b359ada | 50 | |
1c56e311 | 51 | AliGenCocktailAfterBurner::AliGenCocktailAfterBurner(): |
52 | fNAfterBurners(0), | |
53 | fAfterBurnerEntries(new TList()), | |
54 | fGenerationDone(kFALSE), | |
55 | fInternalStacks(0), | |
56 | fCollisionGeometries(0), | |
57 | fCurrentEvent(0), | |
58 | fActiveStack(0), | |
59 | fActiveEvent(-1), | |
60 | fCurrentGenerator(0), | |
61 | fNBgEvents(0) | |
0b359ada | 62 | { |
63 | // Constructor | |
2b9786f4 | 64 | if (gDebug > 0) |
1c56e311 | 65 | cout<<"AliGenCocktailAfterBurner::AliGenCocktailAfterBurner()"<<endl; |
0b359ada | 66 | SetName("AliGenCocktailAfterBurner"); |
67 | SetTitle("AliGenCocktailAfterBurner"); | |
0b359ada | 68 | } |
2b9786f4 | 69 | /*********************************************************************/ |
198bb1c7 | 70 | AliGenCocktailAfterBurner::AliGenCocktailAfterBurner(const AliGenCocktailAfterBurner& cocktail): |
1c56e311 | 71 | AliGenCocktail(cocktail), |
72 | fNAfterBurners(0), | |
73 | fAfterBurnerEntries(new TList()), | |
74 | fGenerationDone(kFALSE), | |
75 | fInternalStacks(0), | |
76 | fCollisionGeometries(0), | |
77 | fCurrentEvent(0), | |
78 | fActiveStack(0), | |
79 | fActiveEvent(-1), | |
80 | fCurrentGenerator(0), | |
81 | fNBgEvents(0) | |
20dddfab | 82 | { |
198bb1c7 | 83 | //Copy constructor |
84 | cocktail.Copy(*this); | |
20dddfab | 85 | } |
86 | ||
2b9786f4 | 87 | /*********************************************************************/ |
0b359ada | 88 | |
89 | AliGenCocktailAfterBurner::~AliGenCocktailAfterBurner() | |
90 | { | |
2b9786f4 | 91 | //destructor |
92 | ||
93 | if (fInternalStacks) //delete stacks | |
94 | { | |
95 | fInternalStacks->SetOwner(); | |
96 | delete fInternalStacks; | |
97 | } | |
98 | if (fAfterBurnerEntries) delete fAfterBurnerEntries; //delete entries | |
cc41459d | 99 | delete[] fCollisionGeometries; |
0b359ada | 100 | } |
2b9786f4 | 101 | /*********************************************************************/ |
102 | /*********************************************************************/ | |
0b359ada | 103 | |
104 | void AliGenCocktailAfterBurner:: | |
105 | AddAfterBurner(AliGenerator *AfterBurner, char* Name, Float_t RateExp) | |
106 | { | |
107 | // | |
108 | // Forward parameters to the new AfterBurner | |
109 | ||
2b9786f4 | 110 | if (gDebug>0)cout<<"AliGenCocktailAfterBurner::AddAfterBurner Named "<<Name<<endl; |
0b359ada | 111 | |
112 | if(TestBit(kPtRange)) | |
113 | AfterBurner->SetPtRange(fPtMin,fPtMax); | |
114 | if(TestBit(kMomentumRange)) | |
115 | AfterBurner->SetMomentumRange(fPMin,fPMax); | |
116 | ||
117 | AfterBurner->SetYRange(fYMin,fYMax); | |
466bfded | 118 | AfterBurner->SetPhiRange(fPhiMin*180/TMath::Pi(),fPhiMax*180/TMath::Pi()); |
119 | AfterBurner->SetThetaRange(fThetaMin*180/TMath::Pi(),fThetaMax*180/TMath::Pi()); | |
120 | AfterBurner->SetOrigin(fOrigin[0], fOrigin[1], fOrigin[2]); | |
121 | AfterBurner->SetSigma(fOsigma[0], fOsigma[1], fOsigma[2]); | |
0b359ada | 122 | AfterBurner->SetVertexSmear(fVertexSmear); |
123 | AfterBurner->SetTrackingFlag(fTrackIt); | |
124 | // | |
125 | // Add AfterBurner to list | |
126 | ||
127 | AliGenCocktailEntry *entry = | |
128 | new AliGenCocktailEntry(AfterBurner, Name, RateExp); | |
129 | fAfterBurnerEntries->Add(entry); | |
130 | fNAfterBurners++; | |
984c69bd | 131 | // |
984c69bd | 132 | |
0b359ada | 133 | } |
2b9786f4 | 134 | /*********************************************************************/ |
135 | /*********************************************************************/ | |
0b359ada | 136 | |
137 | void AliGenCocktailAfterBurner::Init() | |
138 | { | |
139 | // Initialisation | |
2b9786f4 | 140 | fGenerationDone = kFALSE; |
466bfded | 141 | if (fInternalStacks) //delete stacks |
142 | { | |
143 | fInternalStacks->SetOwner(); | |
144 | fInternalStacks->Delete(); //clean after previous generation cycle | |
145 | } | |
146 | ||
cc41459d | 147 | // ANDREAS MORSCH ---------------------------------------------------( |
148 | if (fCollisionGeometries) delete[] fCollisionGeometries; | |
149 | // ANDREAS MORSCH ---------------------------------------------------) | |
150 | ||
0b359ada | 151 | this->AliGenCocktail::Init(); |
152 | ||
2b9786f4 | 153 | if (gDebug>0) cout<<"AliGenCocktailAfterBurner::Init"<<endl; |
0b359ada | 154 | TIter next(fAfterBurnerEntries); |
155 | AliGenCocktailEntry *entry; | |
156 | // | |
157 | // Loop over generators and initialize | |
158 | while((entry = (AliGenCocktailEntry*)next())) { | |
159 | entry->Generator()->Init(); | |
160 | } | |
161 | } | |
2b9786f4 | 162 | /*********************************************************************/ |
163 | /*********************************************************************/ | |
0b359ada | 164 | |
165 | void AliGenCocktailAfterBurner::Generate() | |
166 | { | |
167 | // | |
2b9786f4 | 168 | // Generate event |
169 | // Firsts runs each generator for all events | |
170 | // than after burners ones for each event | |
171 | // | |
172 | // It generates and processes all events during | |
173 | // first call only. | |
174 | // In next calls it just returns already generated | |
175 | // and processed events to the gAlice | |
176 | ||
177 | if (gDebug>0) | |
178 | cout<<"#####################################"<<endl | |
179 | <<"#AliGenCocktailAfterBurner::Generate#"<<endl | |
180 | <<"#####################################"<<endl; | |
0b359ada | 181 | |
182 | Int_t i; //iterator | |
183 | AliStack * stack; | |
2b9786f4 | 184 | |
0b359ada | 185 | if (fGenerationDone) |
2b9786f4 | 186 | {//if generation is done (in first call) |
187 | //just copy particles from the stack to the gAlice | |
188 | SetTracks(++fCurrentEvent); | |
189 | cout<<"Returning event "<<fCurrentEvent<<endl; | |
190 | return; | |
0b359ada | 191 | } |
192 | else | |
2b9786f4 | 193 | { //Here we are in the first call of the method |
194 | fCurrentEvent=0; | |
195 | Int_t numberOfEvents = gAlice->GetEventsPerRun(); | |
196 | //Create stacks | |
cc41459d | 197 | fInternalStacks = new TObjArray(numberOfEvents + fNBgEvents); //Create array of internal stacks |
198 | fCollisionGeometries = new AliCollisionGeometry*[numberOfEvents + fNBgEvents]; //Create array of collision geometries | |
466bfded | 199 | for(i=0;i<numberOfEvents + fNBgEvents;i++) |
2b9786f4 | 200 | { |
201 | stack = new AliStack(10000); | |
202 | stack->Reset(); | |
203 | fInternalStacks->Add(stack); | |
204 | } | |
0b359ada | 205 | /*********************************************************************/ |
2b9786f4 | 206 | TIter next(fEntries); |
207 | AliGenCocktailEntry *entry; | |
208 | AliGenCocktailEntry *e1; | |
209 | AliGenCocktailEntry *e2; | |
210 | TObjArray *partArray; | |
211 | // | |
212 | // Loop over generators and generate events | |
213 | Int_t igen=0; | |
214 | while((entry = (AliGenCocktailEntry*)next())) | |
215 | { | |
216 | igen++; | |
217 | cout<<"Generator "<<igen<<" : "<<entry->GetName()<<endl; | |
218 | /***********************************************/ | |
0b359ada | 219 | //First generator for all evenets, than second for all events, etc... |
466bfded | 220 | for(i=0;i<numberOfEvents + fNBgEvents;i++) |
2b9786f4 | 221 | { |
222 | cout<<" EVENT "<<i<<endl; | |
223 | stack = GetStack(i); | |
224 | partArray = stack->Particles(); | |
225 | fCurrentGenerator = entry->Generator(); | |
226 | fCurrentGenerator->SetStack(stack); | |
227 | if (igen ==1) | |
228 | { | |
229 | entry->SetFirst(0); | |
230 | } | |
231 | else | |
232 | { | |
233 | entry->SetFirst((partArray->GetEntriesFast())+1); | |
234 | } | |
235 | fCurrentGenerator->Generate(); | |
236 | entry->SetLast(partArray->GetEntriesFast()); | |
cc41459d | 237 | |
238 | // ANDREAS MORSCH ---------------------------------------------------( | |
239 | if (fCurrentGenerator->ProvidesCollisionGeometry()) fCollisionGeometries[i] = fCurrentGenerator->CollisionGeometry(); | |
240 | // ANDREAS MORSCH ---------------------------------------------------) | |
241 | ||
2b9786f4 | 242 | } |
243 | /***********************************************/ | |
244 | } | |
245 | next.Reset(); | |
246 | while((entry = (AliGenCocktailEntry*)next())) | |
247 | { | |
248 | entry->PrintInfo(); | |
249 | } | |
250 | for ( entry=FirstGenerator();entry;entry=NextGenerator() ) | |
251 | { | |
252 | entry->PrintInfo(); | |
253 | } | |
254 | for (FirstGeneratorPair(e1,e2); (e1&&e2); NextGeneratorPair(e1,e2) ) | |
255 | { | |
256 | printf("\n -----------------------------"); | |
257 | e1->PrintInfo(); | |
258 | e2->PrintInfo(); | |
0b359ada | 259 | } |
260 | ||
0b359ada | 261 | |
2b9786f4 | 262 | /***********************************************/ |
263 | /*******After Burners Processing****************/ | |
264 | /***********************************************/ | |
265 | TIter nextAfterBurner(fAfterBurnerEntries); | |
266 | AliGenCocktailEntry *afterBurnerEntry; | |
267 | Int_t iab =0; //number of current after burner / counter | |
268 | ||
269 | cout<<"\n\nRunning After Burners"<<endl; | |
270 | while((afterBurnerEntry = (AliGenCocktailEntry*)nextAfterBurner())) | |
271 | { | |
272 | cout<<"After Burner "<<iab++<<" :"<<afterBurnerEntry->GetName()<<endl; | |
273 | fCurrentGenerator = afterBurnerEntry->Generator(); | |
274 | fCurrentGenerator->Generate(); | |
275 | } | |
276 | cout<<endl<<"Finished. Processed "<<iab<<" After Burners"<<endl; | |
277 | ||
278 | /***********************************************/ | |
279 | /***********************************************/ | |
280 | /***********************************************/ | |
0b359ada | 281 | |
2b9786f4 | 282 | fGenerationDone=kTRUE; |
283 | SetTracks(0); //copy event 0 to gAlice stack | |
0b359ada | 284 | |
285 | /*********************************************************************/ | |
286 | ||
287 | }//else generated | |
288 | } | |
2b9786f4 | 289 | /*********************************************************************/ |
290 | /*********************************************************************/ | |
0b359ada | 291 | |
292 | AliGenCocktailAfterBurner& AliGenCocktailAfterBurner::operator=(const AliGenCocktailAfterBurner& rhs) | |
293 | { | |
294 | // Assignment operator | |
198bb1c7 | 295 | rhs.Copy(*this); |
296 | return (*this); | |
0b359ada | 297 | } |
2b9786f4 | 298 | /*********************************************************************/ |
299 | /*********************************************************************/ | |
0b359ada | 300 | |
20dddfab | 301 | AliStack* AliGenCocktailAfterBurner::GetStack(Int_t n) const |
0b359ada | 302 | { |
2b9786f4 | 303 | //Returns the pointer to the N'th stack (event) |
304 | if( ( n<0 ) || ( n>=GetNumberOfEvents() ) ) | |
0b359ada | 305 | { |
2b9786f4 | 306 | Fatal("AliGenCocktailAfterBurner::GetStack","Asked for non existing stack (%d)",n); |
307 | return 0; | |
0b359ada | 308 | } |
2682e810 | 309 | return ((AliStack*) fInternalStacks->At(n) ); |
0b359ada | 310 | } |
cc41459d | 311 | |
312 | /*********************************************************************/ | |
313 | /*********************************************************************/ | |
314 | ||
315 | // ANDREAS MORSCH ---------------------------------------------------( | |
316 | ||
317 | AliCollisionGeometry* AliGenCocktailAfterBurner::GetCollisionGeometry(Int_t n) const | |
318 | { | |
319 | //Returns the pointer to the N'th stack (event) | |
320 | if( ( n<0 ) || ( n>=GetNumberOfEvents() ) ) | |
321 | { | |
322 | Fatal("AliGenCocktailAfterBurner::GetCollisionGeometry","Asked for non existing stack (%d)",n); | |
323 | return 0; | |
324 | } | |
325 | return fCollisionGeometries[n]; | |
326 | } | |
327 | ||
328 | // ANDREAS MORSCH ---------------------------------------------------) | |
329 | ||
2b9786f4 | 330 | /*********************************************************************/ |
331 | /*********************************************************************/ | |
0b359ada | 332 | |
333 | void AliGenCocktailAfterBurner::SetActiveEventNumber(Int_t actev) | |
334 | { | |
2b9786f4 | 335 | //Set Active Events Number and Active Stack |
336 | //There is only one active event number | |
337 | //Made fo convinience of work with AfterBurners (HBT processor) | |
338 | ||
0b359ada | 339 | fActiveEvent = actev; |
340 | fActiveStack = GetStack(actev); | |
341 | } | |
2b9786f4 | 342 | /*********************************************************************/ |
343 | /*********************************************************************/ | |
0b359ada | 344 | |
345 | void AliGenCocktailAfterBurner::SetTracks(Int_t stackno) | |
346 | { | |
2b9786f4 | 347 | //Method which copies tracks from given stack to the |
348 | //gAlice's stack | |
0b359ada | 349 | AliStack* instack = GetStack(stackno); |
350 | Int_t done; | |
351 | Int_t parent; | |
352 | Int_t pdg; | |
353 | Double_t px, py, pz, e, vx, vy, vz, tof, polx, poly, polz; | |
acc86a24 | 354 | TMCProcess mech; |
0b359ada | 355 | Int_t ntr; |
356 | Float_t weight; | |
357 | TVector3 pol; | |
358 | ||
359 | TParticle * p; | |
20dddfab | 360 | Int_t n = instack->GetNtrack(); |
2b9786f4 | 361 | if (gDebug) |
0b359ada | 362 | { |
20dddfab | 363 | cout<<"AliGenCocktailAfterBurner::SetTracks("<<stackno<<"). Number of particles is: "<<n<<"\n"; |
0b359ada | 364 | } |
365 | ||
20dddfab | 366 | for(Int_t i = 0; i < n; i++) |
0b359ada | 367 | { |
368 | ||
2b9786f4 | 369 | p = instack->Particle(i); |
370 | done = !p->TestBit(kDoneBit); | |
371 | parent = p->GetMother(0); | |
372 | pdg = p->GetPdgCode(); | |
373 | px = p->Px(); | |
374 | py = p->Py(); | |
375 | pz = p->Pz(); | |
376 | e = p->Energy(); | |
377 | vx = p->Vx(); | |
378 | vy = p->Vy(); | |
379 | vz = p->Vz(); | |
380 | tof = p->T(); | |
381 | p->GetPolarisation(pol); | |
382 | polx = pol.X(); | |
383 | poly = pol.Y(); | |
384 | polz = pol.Z(); | |
385 | mech = AliGenCocktailAfterBurner::IntToMCProcess(p->GetUniqueID()); | |
386 | weight = p->GetWeight(); | |
387 | ||
cc41459d | 388 | gAlice->GetMCApp()->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,polx, poly, polz, mech, ntr, weight); |
389 | ||
390 | // ANDREAS MORSCH ---------------------------------------------------( | |
391 | SetHighWaterMark(ntr) ; | |
392 | // ANDREAS MORSCH ---------------------------------------------------) | |
393 | ||
0b359ada | 394 | } |
395 | } | |
2b9786f4 | 396 | /*********************************************************************/ |
397 | /*********************************************************************/ | |
0b359ada | 398 | |
acc86a24 | 399 | TMCProcess AliGenCocktailAfterBurner::IntToMCProcess(Int_t no) |
0b359ada | 400 | { |
acc86a24 | 401 | //Mothod used to convert uniqueID (integer) to TMCProcess type |
402 | const TMCProcess kMCprocesses[kMaxMCProcess] = | |
2b9786f4 | 403 | { |
404 | kPNoProcess, kPMultipleScattering, kPEnergyLoss, kPMagneticFieldL, | |
0b359ada | 405 | kPDecay, kPPair, kPCompton, kPPhotoelectric, kPBrem, kPDeltaRay, |
406 | kPAnnihilation, kPHadronic, kPNoProcess, kPEvaporation, kPNuclearFission, | |
407 | kPNuclearAbsorption, kPPbarAnnihilation, kPNCapture, kPHElastic, | |
408 | kPHInhelastic, kPMuonNuclear, kPTOFlimit,kPPhotoFission, kPNoProcess, | |
2b9786f4 | 409 | kPRayleigh, kPNoProcess, kPNoProcess, kPNoProcess, kPNull, kPStop |
410 | }; | |
0b359ada | 411 | |
412 | for (Int_t i = 0;i<kMaxMCProcess;i++) | |
413 | { | |
20dddfab | 414 | if (kMCprocesses[i] == no) |
2b9786f4 | 415 | { |
20dddfab | 416 | return kMCprocesses[i]; |
2b9786f4 | 417 | } |
0b359ada | 418 | } |
419 | return kPNoProcess; | |
420 | } | |
198bb1c7 | 421 | |
dc1d768c | 422 | void AliGenCocktailAfterBurner::Copy(TObject &) const |
198bb1c7 | 423 | { |
424 | Fatal("Copy","Not implemented!\n"); | |
425 | } |