]>
Commit | Line | Data |
---|---|---|
fe4da5cc | 1 | #include "AliGenerator.h" |
2 | #include "AliGenPythia.h" | |
fe4da5cc | 3 | #include "AliRun.h" |
4 | #include "AliPythia.h" | |
5 | #include <TDirectory.h> | |
6 | #include <TFile.h> | |
7 | #include <TTree.h> | |
8 | #include <stdlib.h> | |
9 | #include <AliPythia.h> | |
1578254f | 10 | #include <TParticle.h> |
11 | //#include <GParticle.h> | |
fe4da5cc | 12 | ClassImp(AliGenPythia) |
13 | ||
14 | AliGenPythia::AliGenPythia() | |
15 | :AliGenerator() | |
16 | { | |
17 | } | |
18 | ||
19 | AliGenPythia::AliGenPythia(Int_t npart) | |
20 | :AliGenerator(npart) | |
21 | { | |
22 | // default charm production at 5. 5 TeV | |
23 | // semimuonic decay | |
24 | // structure function GRVHO | |
25 | // | |
26 | fXsection = 0.; | |
27 | fParentSelect.Set(5); | |
28 | fChildSelect.Set(5); | |
29 | for (Int_t i=0; i<5; i++) fParentSelect[i]=fChildSelect[i]=0; | |
30 | SetProcess(); | |
31 | SetStrucFunc(); | |
32 | ForceDecay(); | |
33 | SetPtHard(); | |
34 | SetEnergyCMS(); | |
35 | } | |
36 | ||
37 | AliGenPythia::~AliGenPythia() | |
38 | { | |
39 | } | |
40 | ||
41 | void AliGenPythia::Init() | |
42 | { | |
43 | SetMC(new AliPythia()); | |
44 | fPythia=(AliPythia*) fgMCEvGen; | |
45 | // | |
46 | fParentWeight=1./Float_t(fNpart); | |
47 | // | |
48 | // Forward Paramters to the AliPythia object | |
49 | fPythia->DefineParticles(); | |
fe4da5cc | 50 | fPythia->SetCKIN(3,fPtHardMin); |
51 | fPythia->SetCKIN(4,fPtHardMax); | |
52 | fPythia->ProcInit(fProcess,fEnergyCMS,fStrucFunc); | |
5be1fe76 | 53 | fPythia->ForceDecay(fForceDecay); |
fe4da5cc | 54 | fPythia->LuList(0); |
55 | fPythia->PyStat(2); | |
56 | // Parent and Children Selection | |
57 | switch (fProcess) | |
58 | { | |
59 | case charm: | |
60 | ||
61 | fParentSelect[0]=411; | |
62 | fParentSelect[1]=421; | |
63 | fParentSelect[2]=431; | |
64 | fParentSelect[3]=4122; | |
65 | break; | |
66 | case charm_unforced: | |
67 | ||
68 | fParentSelect[0]=411; | |
69 | fParentSelect[1]=421; | |
70 | fParentSelect[2]=431; | |
71 | fParentSelect[3]=4122; | |
72 | break; | |
73 | case beauty: | |
74 | fParentSelect[0]=511; | |
75 | fParentSelect[1]=521; | |
76 | fParentSelect[2]=531; | |
77 | fParentSelect[3]=5122; | |
78 | break; | |
79 | case beauty_unforced: | |
80 | fParentSelect[0]=511; | |
81 | fParentSelect[1]=521; | |
82 | fParentSelect[2]=531; | |
83 | fParentSelect[3]=5122; | |
84 | break; | |
85 | case jpsi_chi: | |
86 | case jpsi: | |
87 | fParentSelect[0]=443; | |
88 | break; | |
5be1fe76 | 89 | case mb: |
90 | break; | |
fe4da5cc | 91 | } |
92 | ||
93 | switch (fForceDecay) | |
94 | { | |
95 | case semielectronic: | |
96 | case dielectron: | |
97 | case b_jpsi_dielectron: | |
98 | case b_psip_dielectron: | |
99 | fChildSelect[0]=11; | |
100 | break; | |
101 | case semimuonic: | |
102 | case dimuon: | |
103 | case b_jpsi_dimuon: | |
104 | case b_psip_dimuon: | |
5be1fe76 | 105 | case pitomu: |
106 | case katomu: | |
fe4da5cc | 107 | fChildSelect[0]=13; |
108 | break; | |
109 | } | |
110 | } | |
111 | ||
112 | void AliGenPythia::Generate() | |
113 | { | |
fe4da5cc | 114 | |
5be1fe76 | 115 | Float_t polar[3] = {0,0,0}; |
116 | Float_t origin[3]= {0,0,0}; | |
117 | Float_t origin_p[3]= {0,0,0}; | |
118 | Float_t origin0[3]= {0,0,0}; | |
119 | Float_t p[3], p_p[4], random[6]; | |
120 | // converts from mm/c to s | |
121 | const Float_t kconv=0.001/2.999792458e8; | |
fe4da5cc | 122 | |
123 | ||
124 | // | |
fe4da5cc | 125 | Int_t nt=0; |
5be1fe76 | 126 | Int_t nt_p=0; |
fe4da5cc | 127 | Int_t jev=0; |
128 | Int_t j; | |
129 | ||
130 | fTrials=0; | |
131 | for (j=0;j<3;j++) origin0[j]=fOrigin[j]; | |
132 | if(fVertexSmear==perEvent) { | |
cfce8870 | 133 | gMC->Rndm(random,6); |
fe4da5cc | 134 | for (j=0;j<3;j++) { |
135 | origin0[j]+=fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())* | |
136 | TMath::Sqrt(-2*TMath::Log(random[2*j+1])); | |
137 | fPythia->SetMSTP(151,0); | |
138 | } | |
139 | } else if (fVertexSmear==perTrack) { | |
140 | fPythia->SetMSTP(151,0); | |
141 | for (j=0;j<3;j++) { | |
142 | fPythia->SetPARP(151+j, fOsigma[j]*10.); | |
143 | } | |
144 | } | |
fe4da5cc | 145 | while(1) |
146 | { | |
147 | fPythia->PyEvnt(); | |
148 | fTrials++; | |
1578254f | 149 | TObjArray* particles = fPythia->ImportParticles(); |
fe4da5cc | 150 | Int_t np = particles->GetEntriesFast(); |
151 | printf("\n **************************************************%d\n",np); | |
152 | Int_t nc=0; | |
153 | if (np == 0 ) continue; | |
5be1fe76 | 154 | if (fProcess != mb) { |
155 | for (Int_t i = 0; i<np; i++) { | |
1578254f | 156 | TParticle * iparticle = (TParticle *) particles->At(i); |
157 | Int_t kf = iparticle->GetPdgCode(); | |
5be1fe76 | 158 | fChildWeight=(fPythia->GetBraPart(kf))*fParentWeight; |
fe4da5cc | 159 | // |
160 | // Parent | |
5be1fe76 | 161 | if (ParentSelected(TMath::Abs(kf))) { |
162 | if (KinematicSelection(iparticle)) { | |
163 | if (nc==0) { | |
164 | // | |
165 | // Store information concerning the hard scattering process | |
166 | // | |
167 | Float_t mass_p = fPythia->GetPARI(13); | |
168 | Float_t pt_p = fPythia->GetPARI(17); | |
169 | Float_t y_p = fPythia->GetPARI(37); | |
170 | Float_t xmt_p = sqrt(pt_p*pt_p+mass_p*mass_p); | |
171 | Float_t ty = Float_t(TMath::TanH(y_p)); | |
172 | p_p[0] = pt_p; | |
173 | p_p[1] = 0; | |
174 | p_p[2] = xmt_p*ty/sqrt(1.-ty*ty); | |
175 | p_p[3] = mass_p; | |
176 | gAlice->SetTrack(0,-1,-1, | |
177 | p_p,origin_p,polar, | |
178 | 0,"Hard Scat.",nt_p,fParentWeight); | |
179 | gAlice->KeepTrack(nt_p); | |
180 | } | |
181 | nc++; | |
fe4da5cc | 182 | // |
183 | // store parent track information | |
1578254f | 184 | p[0]=iparticle->Px(); |
185 | p[1]=iparticle->Py(); | |
186 | p[2]=iparticle->Pz(); | |
187 | origin[0]=origin0[0]+iparticle->Vx()/10; | |
188 | origin[1]=origin0[1]+iparticle->Vy()/10; | |
189 | origin[2]=origin0[2]+iparticle->Vz()/10; | |
fe4da5cc | 190 | |
1578254f | 191 | Int_t ifch=iparticle->GetFirstDaughter(); |
192 | Int_t ilch=iparticle->GetLastDaughter(); | |
5be1fe76 | 193 | if (ifch !=0 && ilch !=0) { |
1578254f | 194 | gAlice->SetTrack(0,nt_p,kf, |
5be1fe76 | 195 | p,origin,polar, |
196 | 0,"Primary",nt,fParentWeight); | |
197 | gAlice->KeepTrack(nt); | |
198 | Int_t iparent = nt; | |
fe4da5cc | 199 | // |
200 | // Children | |
201 | ||
5be1fe76 | 202 | for (Int_t j=ifch; j<=ilch; j++) |
203 | { | |
1578254f | 204 | TParticle * ichild = |
205 | (TParticle *) particles->At(j-1); | |
206 | Int_t kf = ichild->GetPdgCode(); | |
fe4da5cc | 207 | // |
208 | // | |
5be1fe76 | 209 | if (ChildSelected(TMath::Abs(kf))) { |
1578254f | 210 | origin[0]=ichild->Vx(); |
211 | origin[1]=ichild->Vy(); | |
212 | origin[2]=ichild->Vz(); | |
213 | p[0]=ichild->Px(); | |
214 | p[1]=ichild->Py(); | |
215 | p[2]=ichild->Pz(); | |
216 | Float_t tof=kconv*ichild->T(); | |
217 | gAlice->SetTrack(fTrackIt, iparent, kf, | |
5be1fe76 | 218 | p,origin,polar, |
219 | tof,"Decay",nt,fChildWeight); | |
220 | gAlice->KeepTrack(nt); | |
221 | } // select child | |
222 | } // child loop | |
223 | } | |
224 | } // kinematic selection | |
225 | } // select particle | |
226 | } // particle loop | |
227 | } else { | |
228 | for (Int_t i = 0; i<np; i++) { | |
1578254f | 229 | TParticle * iparticle = (TParticle *) particles->At(i); |
230 | Int_t kf = iparticle->GetPdgCode(); | |
231 | Int_t ks = iparticle->GetStatusCode(); | |
232 | if (ks==1 && kf!=0 && KinematicSelection(iparticle)) { | |
5be1fe76 | 233 | nc++; |
234 | // | |
235 | // store track information | |
1578254f | 236 | p[0]=iparticle->Px(); |
237 | p[1]=iparticle->Py(); | |
238 | p[2]=iparticle->Pz(); | |
239 | origin[0]=origin0[0]+iparticle->Vx()/10; | |
240 | origin[1]=origin0[1]+iparticle->Vy()/10; | |
241 | origin[2]=origin0[2]+iparticle->Vz()/10; | |
242 | Float_t tof=kconv*iparticle->T(); | |
243 | gAlice->SetTrack(fTrackIt,-1,kf,p,origin,polar, | |
5be1fe76 | 244 | tof,"Primary",nt); |
245 | gAlice->KeepTrack(nt); | |
246 | } // select particle | |
247 | } // particle loop | |
248 | printf("\n I've put %i particles on the stack \n",nc); | |
249 | } // mb ? | |
fe4da5cc | 250 | if (nc > 0) { |
5be1fe76 | 251 | jev+=nc; |
fe4da5cc | 252 | if (jev >= fNpart) { |
253 | fKineBias=Float_t(fNpart)/Float_t(fTrials); | |
254 | printf("\n Trials: %i\n",fTrials); | |
255 | break; | |
256 | } | |
257 | } | |
258 | } // event loop | |
259 | // adjust weight due to kinematic selection | |
260 | AdjustWeights(); | |
261 | // get cross-section | |
262 | fXsection=fPythia->GetPARI(1); | |
263 | } | |
264 | ||
265 | Bool_t AliGenPythia::ParentSelected(Int_t ip) | |
266 | { | |
267 | for (Int_t i=0; i<5; i++) | |
268 | { | |
269 | if (fParentSelect[i]==ip) return kTRUE; | |
270 | } | |
271 | return kFALSE; | |
272 | } | |
273 | ||
274 | Bool_t AliGenPythia::ChildSelected(Int_t ip) | |
275 | { | |
276 | for (Int_t i=0; i<5; i++) | |
277 | { | |
278 | if (fChildSelect[i]==ip) return kTRUE; | |
279 | } | |
280 | return kFALSE; | |
281 | } | |
282 | ||
1578254f | 283 | Bool_t AliGenPythia::KinematicSelection(TParticle *particle) |
fe4da5cc | 284 | { |
1578254f | 285 | Float_t px=particle->Px(); |
286 | Float_t py=particle->Py(); | |
287 | Float_t pz=particle->Pz(); | |
288 | Float_t e=particle->Energy(); | |
fe4da5cc | 289 | |
290 | // | |
291 | // transverse momentum cut | |
292 | Float_t pt=TMath::Sqrt(px*px+py*py); | |
293 | if (pt > fPtMax || pt < fPtMin) | |
294 | { | |
295 | // printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax); | |
296 | return kFALSE; | |
297 | } | |
298 | // | |
299 | // momentum cut | |
300 | Float_t p=TMath::Sqrt(px*px+py*py+pz*pz); | |
301 | if (p > fPMax || p < fPMin) | |
302 | { | |
303 | // printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax); | |
304 | return kFALSE; | |
305 | } | |
306 | ||
307 | // | |
308 | // theta cut | |
5be1fe76 | 309 | Float_t theta = Float_t(TMath::ATan2(Double_t(pt),Double_t(pz))); |
fe4da5cc | 310 | if (theta > fThetaMax || theta < fThetaMin) |
311 | { | |
312 | // printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax); | |
313 | return kFALSE; | |
314 | } | |
315 | ||
316 | // | |
317 | // rapidity cut | |
318 | Float_t y = 0.5*TMath::Log((e+pz)/(e-pz)); | |
319 | if (y > fYMax || y < fYMin) | |
320 | { | |
321 | // printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax); | |
322 | return kFALSE; | |
323 | } | |
324 | ||
325 | // | |
326 | // phi cut | |
327 | Float_t phi=Float_t(TMath::ATan2(Double_t(py),Double_t(px)))+TMath::Pi(); | |
328 | if (phi > fPhiMax || phi < fPhiMin) | |
329 | { | |
330 | // printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax); | |
331 | return kFALSE; | |
332 | } | |
333 | ||
334 | return kTRUE; | |
335 | } | |
336 | void AliGenPythia::AdjustWeights() | |
337 | { | |
338 | TClonesArray *PartArray = gAlice->Particles(); | |
1578254f | 339 | TParticle *Part; |
fe4da5cc | 340 | Int_t ntrack=gAlice->GetNtrack(); |
341 | for (Int_t i=0; i<ntrack; i++) { | |
1578254f | 342 | Part= (TParticle*) PartArray->UncheckedAt(i); |
343 | Part->SetWeight(Part->GetWeight()*fKineBias); | |
fe4da5cc | 344 | } |
345 | } | |
346 | ||
347 | ||
348 | ||
349 | ||
350 | ||
5be1fe76 | 351 | |
352 | ||
353 | ||
354 |