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