]>
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]; | |
09fd3ea2 | 120 | static TClonesArray *particles; |
5be1fe76 | 121 | // converts from mm/c to s |
122 | const Float_t kconv=0.001/2.999792458e8; | |
fe4da5cc | 123 | |
124 | ||
125 | // | |
fe4da5cc | 126 | Int_t nt=0; |
5be1fe76 | 127 | Int_t nt_p=0; |
fe4da5cc | 128 | Int_t jev=0; |
129 | Int_t j; | |
09fd3ea2 | 130 | |
131 | if(!particles) particles=new TClonesArray("TParticle",1000); | |
fe4da5cc | 132 | |
133 | fTrials=0; | |
134 | for (j=0;j<3;j++) origin0[j]=fOrigin[j]; | |
135 | if(fVertexSmear==perEvent) { | |
cfce8870 | 136 | gMC->Rndm(random,6); |
fe4da5cc | 137 | for (j=0;j<3;j++) { |
138 | origin0[j]+=fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())* | |
139 | TMath::Sqrt(-2*TMath::Log(random[2*j+1])); | |
140 | fPythia->SetMSTP(151,0); | |
141 | } | |
142 | } else if (fVertexSmear==perTrack) { | |
143 | fPythia->SetMSTP(151,0); | |
144 | for (j=0;j<3;j++) { | |
145 | fPythia->SetPARP(151+j, fOsigma[j]*10.); | |
146 | } | |
147 | } | |
fe4da5cc | 148 | while(1) |
149 | { | |
150 | fPythia->PyEvnt(); | |
151 | fTrials++; | |
09fd3ea2 | 152 | fPythia->ImportParticles(particles); |
fe4da5cc | 153 | Int_t np = particles->GetEntriesFast(); |
154 | printf("\n **************************************************%d\n",np); | |
155 | Int_t nc=0; | |
156 | if (np == 0 ) continue; | |
5be1fe76 | 157 | if (fProcess != mb) { |
158 | for (Int_t i = 0; i<np; i++) { | |
1578254f | 159 | TParticle * iparticle = (TParticle *) particles->At(i); |
160 | Int_t kf = iparticle->GetPdgCode(); | |
5be1fe76 | 161 | fChildWeight=(fPythia->GetBraPart(kf))*fParentWeight; |
fe4da5cc | 162 | // |
163 | // Parent | |
5be1fe76 | 164 | if (ParentSelected(TMath::Abs(kf))) { |
165 | if (KinematicSelection(iparticle)) { | |
166 | if (nc==0) { | |
167 | // | |
168 | // Store information concerning the hard scattering process | |
169 | // | |
170 | Float_t mass_p = fPythia->GetPARI(13); | |
171 | Float_t pt_p = fPythia->GetPARI(17); | |
172 | Float_t y_p = fPythia->GetPARI(37); | |
173 | Float_t xmt_p = sqrt(pt_p*pt_p+mass_p*mass_p); | |
174 | Float_t ty = Float_t(TMath::TanH(y_p)); | |
175 | p_p[0] = pt_p; | |
176 | p_p[1] = 0; | |
177 | p_p[2] = xmt_p*ty/sqrt(1.-ty*ty); | |
178 | p_p[3] = mass_p; | |
179 | gAlice->SetTrack(0,-1,-1, | |
180 | p_p,origin_p,polar, | |
181 | 0,"Hard Scat.",nt_p,fParentWeight); | |
182 | gAlice->KeepTrack(nt_p); | |
183 | } | |
184 | nc++; | |
fe4da5cc | 185 | // |
186 | // store parent track information | |
1578254f | 187 | p[0]=iparticle->Px(); |
188 | p[1]=iparticle->Py(); | |
189 | p[2]=iparticle->Pz(); | |
190 | origin[0]=origin0[0]+iparticle->Vx()/10; | |
191 | origin[1]=origin0[1]+iparticle->Vy()/10; | |
192 | origin[2]=origin0[2]+iparticle->Vz()/10; | |
fe4da5cc | 193 | |
1578254f | 194 | Int_t ifch=iparticle->GetFirstDaughter(); |
195 | Int_t ilch=iparticle->GetLastDaughter(); | |
5be1fe76 | 196 | if (ifch !=0 && ilch !=0) { |
1578254f | 197 | gAlice->SetTrack(0,nt_p,kf, |
5be1fe76 | 198 | p,origin,polar, |
199 | 0,"Primary",nt,fParentWeight); | |
200 | gAlice->KeepTrack(nt); | |
201 | Int_t iparent = nt; | |
fe4da5cc | 202 | // |
203 | // Children | |
204 | ||
5be1fe76 | 205 | for (Int_t j=ifch; j<=ilch; j++) |
206 | { | |
1578254f | 207 | TParticle * ichild = |
208 | (TParticle *) particles->At(j-1); | |
209 | Int_t kf = ichild->GetPdgCode(); | |
fe4da5cc | 210 | // |
211 | // | |
5be1fe76 | 212 | if (ChildSelected(TMath::Abs(kf))) { |
1578254f | 213 | origin[0]=ichild->Vx(); |
214 | origin[1]=ichild->Vy(); | |
215 | origin[2]=ichild->Vz(); | |
216 | p[0]=ichild->Px(); | |
217 | p[1]=ichild->Py(); | |
218 | p[2]=ichild->Pz(); | |
219 | Float_t tof=kconv*ichild->T(); | |
220 | gAlice->SetTrack(fTrackIt, iparent, kf, | |
5be1fe76 | 221 | p,origin,polar, |
222 | tof,"Decay",nt,fChildWeight); | |
223 | gAlice->KeepTrack(nt); | |
224 | } // select child | |
225 | } // child loop | |
226 | } | |
227 | } // kinematic selection | |
228 | } // select particle | |
229 | } // particle loop | |
230 | } else { | |
231 | for (Int_t i = 0; i<np; i++) { | |
1578254f | 232 | TParticle * iparticle = (TParticle *) particles->At(i); |
233 | Int_t kf = iparticle->GetPdgCode(); | |
234 | Int_t ks = iparticle->GetStatusCode(); | |
235 | if (ks==1 && kf!=0 && KinematicSelection(iparticle)) { | |
5be1fe76 | 236 | nc++; |
237 | // | |
238 | // store track information | |
1578254f | 239 | p[0]=iparticle->Px(); |
240 | p[1]=iparticle->Py(); | |
241 | p[2]=iparticle->Pz(); | |
242 | origin[0]=origin0[0]+iparticle->Vx()/10; | |
243 | origin[1]=origin0[1]+iparticle->Vy()/10; | |
244 | origin[2]=origin0[2]+iparticle->Vz()/10; | |
245 | Float_t tof=kconv*iparticle->T(); | |
246 | gAlice->SetTrack(fTrackIt,-1,kf,p,origin,polar, | |
5be1fe76 | 247 | tof,"Primary",nt); |
248 | gAlice->KeepTrack(nt); | |
249 | } // select particle | |
250 | } // particle loop | |
251 | printf("\n I've put %i particles on the stack \n",nc); | |
252 | } // mb ? | |
fe4da5cc | 253 | if (nc > 0) { |
5be1fe76 | 254 | jev+=nc; |
fe4da5cc | 255 | if (jev >= fNpart) { |
256 | fKineBias=Float_t(fNpart)/Float_t(fTrials); | |
257 | printf("\n Trials: %i\n",fTrials); | |
258 | break; | |
259 | } | |
260 | } | |
261 | } // event loop | |
262 | // adjust weight due to kinematic selection | |
263 | AdjustWeights(); | |
264 | // get cross-section | |
265 | fXsection=fPythia->GetPARI(1); | |
266 | } | |
267 | ||
268 | Bool_t AliGenPythia::ParentSelected(Int_t ip) | |
269 | { | |
270 | for (Int_t i=0; i<5; i++) | |
271 | { | |
272 | if (fParentSelect[i]==ip) return kTRUE; | |
273 | } | |
274 | return kFALSE; | |
275 | } | |
276 | ||
277 | Bool_t AliGenPythia::ChildSelected(Int_t ip) | |
278 | { | |
279 | for (Int_t i=0; i<5; i++) | |
280 | { | |
281 | if (fChildSelect[i]==ip) return kTRUE; | |
282 | } | |
283 | return kFALSE; | |
284 | } | |
285 | ||
1578254f | 286 | Bool_t AliGenPythia::KinematicSelection(TParticle *particle) |
fe4da5cc | 287 | { |
1578254f | 288 | Float_t px=particle->Px(); |
289 | Float_t py=particle->Py(); | |
290 | Float_t pz=particle->Pz(); | |
291 | Float_t e=particle->Energy(); | |
fe4da5cc | 292 | |
293 | // | |
294 | // transverse momentum cut | |
295 | Float_t pt=TMath::Sqrt(px*px+py*py); | |
296 | if (pt > fPtMax || pt < fPtMin) | |
297 | { | |
298 | // printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax); | |
299 | return kFALSE; | |
300 | } | |
301 | // | |
302 | // momentum cut | |
303 | Float_t p=TMath::Sqrt(px*px+py*py+pz*pz); | |
304 | if (p > fPMax || p < fPMin) | |
305 | { | |
306 | // printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax); | |
307 | return kFALSE; | |
308 | } | |
309 | ||
310 | // | |
311 | // theta cut | |
5be1fe76 | 312 | Float_t theta = Float_t(TMath::ATan2(Double_t(pt),Double_t(pz))); |
fe4da5cc | 313 | if (theta > fThetaMax || theta < fThetaMin) |
314 | { | |
315 | // printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax); | |
316 | return kFALSE; | |
317 | } | |
318 | ||
319 | // | |
320 | // rapidity cut | |
321 | Float_t y = 0.5*TMath::Log((e+pz)/(e-pz)); | |
322 | if (y > fYMax || y < fYMin) | |
323 | { | |
324 | // printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax); | |
325 | return kFALSE; | |
326 | } | |
327 | ||
328 | // | |
329 | // phi cut | |
330 | Float_t phi=Float_t(TMath::ATan2(Double_t(py),Double_t(px)))+TMath::Pi(); | |
331 | if (phi > fPhiMax || phi < fPhiMin) | |
332 | { | |
333 | // printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax); | |
334 | return kFALSE; | |
335 | } | |
336 | ||
337 | return kTRUE; | |
338 | } | |
339 | void AliGenPythia::AdjustWeights() | |
340 | { | |
341 | TClonesArray *PartArray = gAlice->Particles(); | |
1578254f | 342 | TParticle *Part; |
fe4da5cc | 343 | Int_t ntrack=gAlice->GetNtrack(); |
344 | for (Int_t i=0; i<ntrack; i++) { | |
1578254f | 345 | Part= (TParticle*) PartArray->UncheckedAt(i); |
346 | Part->SetWeight(Part->GetWeight()*fKineBias); | |
fe4da5cc | 347 | } |
348 | } | |
349 | ||
350 | ||
351 | ||
352 | ||
353 | ||
5be1fe76 | 354 | |
355 | ||
356 | ||
357 |