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