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