fHijing->Initialize(); after change of parameters. (Dmitri Yurevitch Peressounko)
[u/mrichter/AliRoot.git] / EVGEN / AliGenCocktail.cxx
CommitLineData
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$
374924b5 18Revision 1.4 1999/09/29 09:24:12 fca
19Introduction of the Copyright and cvs Log
20
4c039060 21*/
22
fe4da5cc 23#include "AliGenCocktail.h"
374924b5 24#include "AliGenCocktailEntry.h"
fe4da5cc 25#include "AliRun.h"
fe4da5cc 26#include <stdlib.h>
fe4da5cc 27
28ClassImp(AliGenCocktail)
29
30AliGenCocktail::AliGenCocktail()
31 :AliGenerator()
32{
374924b5 33// Constructor
fe4da5cc 34 fEntries = new TList;
35 fNGenerators=0;
36}
37
374924b5 38AliGenCocktail::AliGenCocktail(const AliGenCocktail & cocktail)
39{
40// copy constructor
41}
fe4da5cc 42
43AliGenCocktail::~AliGenCocktail()
44{
374924b5 45// Destructor
fe4da5cc 46 delete fEntries;
47}
48
49void AliGenCocktail::
50AddGenerator(AliGenerator *Generator, TString Name, Float_t RateExp)
51{
52//
53// Forward parameters to the new generator
54 Generator->SetPtRange(fPtMin,fPtMax);
55 Generator->SetMomentumRange(fPMin,fPMax);
56 Generator->SetYRange(fYMin,fYMax);
57 Generator->
58 SetPhiRange(fPhiMin*180/TMath::Pi(),fPhiMax*180/TMath::Pi());
59 Generator->
60 SetThetaRange(fThetaMin*180/TMath::Pi(),fThetaMax*180/TMath::Pi());
61 Generator->
62 SetOrigin(fOrigin[0], fOrigin[1], fOrigin[2]);
63 Generator->
64 SetSigma(fOsigma[0], fOsigma[1], fOsigma[2]);
7a50a130 65 Generator->SetVertexSmear(fVertexSmear);
66 Generator->SetTrackingFlag(fTrackIt);
fe4da5cc 67//
68// Add generator to list
374924b5 69 AliGenCocktailEntry *entry =
fe4da5cc 70 new AliGenCocktailEntry(Generator, Name, RateExp);
374924b5 71 fEntries->Add(entry);
fe4da5cc 72 fNGenerators++;
73 }
74
75 void AliGenCocktail::Init()
374924b5 76{
77// Initialisation
78 TIter next(fEntries);
79 AliGenCocktailEntry *entry;
80 //
81 // Loop over generators and initialize
82 while((entry = (AliGenCocktailEntry*)next())) {
83 entry->Generator()->Init();
84 }
85}
fe4da5cc 86
87 void AliGenCocktail::Generate()
374924b5 88{
89//
90// Generate event
91 TIter next(fEntries);
92 AliGenCocktailEntry *entry;
93 AliGenCocktailEntry *e1;
94 AliGenCocktailEntry *e2;
95 TClonesArray *partArray = gAlice->Particles();
96 //
97 // Loop over generators and generate events
98 Int_t igen=0;
99 while((entry = (AliGenCocktailEntry*)next())) {
100 igen++;
101 if (igen ==1) {
102 entry->SetFirst(0);
103 } else {
104 entry->SetFirst((partArray->GetEntriesFast())+1);
105 }
106 entry->Generator()->Generate();
107 entry->SetLast(partArray->GetEntriesFast());
108 }
109 next.Reset();
110 while((entry = (AliGenCocktailEntry*)next())) {
111 entry->PrintInfo();
112 }
113 for (entry=FirstGenerator();
114 entry;
115 entry=NextGenerator()
116 ) {
117 entry->PrintInfo();
118 }
119 for (FirstGeneratorPair(e1,e2);
120 (e1&&e2);
121 NextGeneratorPair(e1,e2)
122 ){
123 printf("\n -----------------------------");
124 e1->PrintInfo();
125 e2->PrintInfo();
126 }
127}
fe4da5cc 128
129AliGenCocktailEntry * AliGenCocktail::FirstGenerator()
130{
374924b5 131// Iterator over generators: Initialisation
fe4da5cc 132 flnk1 = fEntries->FirstLink();
133 if (flnk1) {
134 return (AliGenCocktailEntry*) (flnk1->GetObject());
135 } else {
136 return 0;
137 }
138}
139
140AliGenCocktailEntry* AliGenCocktail::NextGenerator()
141{
374924b5 142// Iterator over generators: Increment
fe4da5cc 143 flnk1 = flnk1->Next();
144 if (flnk1) {
145 return (AliGenCocktailEntry*) (flnk1->GetObject());
146 } else {
147 return 0;
148 }
149}
150
151void AliGenCocktail::
152FirstGeneratorPair(AliGenCocktailEntry*& e1, AliGenCocktailEntry*& e2)
153{
374924b5 154// Iterator over generator pairs: Initialisation
fe4da5cc 155 flnk2 = flnk1 = fEntries->FirstLink();
156 if (flnk1) {
157 e2 = e1 = (AliGenCocktailEntry*) (flnk1->GetObject());
158 } else {
159 e2= e1 = 0;
160 }
161}
162
163void AliGenCocktail::
164NextGeneratorPair(AliGenCocktailEntry*& e1, AliGenCocktailEntry*& e2)
165{
374924b5 166// Iterator over generators: Increment
fe4da5cc 167 flnk2 = flnk2->Next();
168 if (flnk2) {
169 e1 = (AliGenCocktailEntry*) (flnk1->GetObject());
170 e2 = (AliGenCocktailEntry*) (flnk2->GetObject());
171 } else {
172 flnk2 = flnk1 = flnk1->Next();
173 if (flnk1) {
174 e1 = (AliGenCocktailEntry*) (flnk1->GetObject());
175 e2 = (AliGenCocktailEntry*) (flnk2->GetObject());
176 } else {
177 e1=0;
178 e2=0;
179 }
180 }
181}
182
183
184void AliGenCocktail::Streamer(TBuffer &R__b)
185{
374924b5 186 // Stream an object of class AliGenCocktail.
187 TIter next(fEntries);
188 AliGenCocktailEntry *entry;
189
190 if (R__b.IsReading()) {
191 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
192 AliGenerator::Streamer(R__b);
193 R__b >> fNGenerators;
194 R__b >> fEntries;
fe4da5cc 195// Stream generation related information
374924b5 196 while((entry = (AliGenCocktailEntry*)next())) {
197 entry->Streamer(R__b);
198 }
199 } else {
200 R__b.WriteVersion(AliGenCocktail::IsA());
201 AliGenerator::Streamer(R__b);
202 R__b << fNGenerators;
203 R__b << fEntries;
fe4da5cc 204// Stream generation related information
374924b5 205 while((entry = (AliGenCocktailEntry*)next())) {
206 entry->Streamer(R__b);
207 }
208 }
209}
210
211AliGenCocktail& AliGenCocktail::operator=(const AliGenCocktail& rhs)
212{
213// Assignment operator
214 return *this;
fe4da5cc 215}
216
217