]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVGEN/AliGenCorrHF.cxx
bug fix in the vertex selection
[u/mrichter/AliRoot.git] / EVGEN / AliGenCorrHF.cxx
CommitLineData
2c890605 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/* $Id$ */
17
18// Class to generate correlated Heavy Flavor hadron pairs (one or several pairs
19// per event) using paramtrized kinematics of quark pairs from some generator
20// and quark fragmentation functions.
21// Is a generalisation of AliGenParam class for correlated pairs of hadrons.
22// In this version quark pairs and fragmentation functions are obtained from
b33adf51 23// ~2.10^6 Pythia6.214 events generated with kCharmppMNRwmi & kBeautyppMNRwmi,
9fd56238 24// CTEQ5L PDF and Pt_hard = 2.76 GeV/c for p-p collisions at 7, 10 and 14 TeV,
25// and with kCharmppMNR (Pt_hard = 2.10 GeV/c) & kBeautyppMNR (Pt_hard = 2.75 GeV/c),
26// CTEQ4L PDF for Pb-Pb at 3.94 TeV, for p-Pb & Pb-p at 8.8 TeV.
b33adf51 27// Decays are performed by Pythia.
2c890605 28// Author: S. Grigoryan, LPC Clermont-Fd & YerPhI, Smbat.Grigoryan@cern.ch
b44c3901 29// July 07: added quarks in the stack (B. Vulpescu)
b33adf51 30// April 09: added energy choice between 10 and 14 TeV (S. Grigoryan)
9fd56238 31// Sept 09: added hadron pair composition probabilities via 2D histo (X.M. Zhang)
32// Oct 09: added energy choice between 7, 10, 14 TeV (for p-p), 4 TeV (for Pb-Pb),
33// 9 TeV (for p-Pb) and -9 TeV (for Pb-p) (S. Grigoryan)
2c890605 34//-------------------------------------------------------------------------
b33adf51 35// How it works (for the given flavor and p-p energy):
2c890605 36//
37// 1) Reads QQbar kinematical grid from the Input file and generates
38// quark pairs according to the weights of the cells.
39// It is a 5D grid in y1,y2,pt1,pt2 and deltaphi, with occupancy weights
40// of the cells obtained from Pythia (see details in GetQuarkPair).
41// 2) Reads "soft" and "hard" fragmentation functions (12 2D-histograms each,
42// for 12 pt bins) from the Input file, applies to quarks and produces hadrons
43// (only lower states, with proportions of species obtained from Pythia).
44// Fragmentation functions are the same for all hadron species and depend
45// on 2 variables - light cone energy-momentum fractions:
46// z1=(E_H + Pz_H)/(E_Q + Pz_Q), z2=(E_H - Pz_H)/(E_Q - Pz_Q).
47// "soft" & "hard" FFs correspond to "slower" & "faster" quark of a pair
b33adf51 48// (see details in GetHadronPair). Fragmentation does not depend on p-p energy.
2c890605 49// 3) Decays the hadrons and saves all the particles in the event stack in the
50// following order: HF hadron from Q, then its decay products, then HF hadron
51// from Qbar, then its decay productes, then next HF hadon pair (if any)
52// in the same way, etc...
53// 4) It is fast, e.g., generates the same number of events with a beauty pair
54// ~15 times faster than AliGenPythia with kBeautyppMNRwmi (w/o tracking)
55//
b33adf51 56// An Input file for each quark flavor and p-p energy is in EVGEN/dataCorrHF/
2c890605 57// One can use also user-defined Input files.
58//
59// More details could be found in my presentation at DiMuonNet Workshop, Dec 2006:
b33adf51 60// http://www-dapnia.cea.fr/Sphn/Alice/DiMuonNet.
2c890605 61//
62//-------------------------------------------------------------------------
63// How to use it:
64//
65// add the following typical lines in Config.C
66/*
67 if (!strcmp(option,"corr")) {
9fd56238 68 // An example for correlated charm or beauty hadron pair production at 14 TeV
2c890605 69
b33adf51 70 // AliGenCorrHF *gener = new AliGenCorrHF(1, 4, 14); // for charm, 1 pair per event
71 AliGenCorrHF *gener = new AliGenCorrHF(1, 5, 14); // for beauty, 1 pair per event
2c890605 72
73 gener->SetMomentumRange(0,9999);
9fd56238 74 gener->SetCutOnChild(0); // 1/0 means cuts on children enable/disable
2c890605 75 gener->SetChildThetaRange(171.0,178.0);
76 gener->SetOrigin(0,0,0); //vertex position
77 gener->SetSigma(0,0,0); //Sigma in (X,Y,Z) (cm) on IP position
78 gener->SetForceDecay(kSemiMuonic);
79 gener->SetTrackingFlag(0);
80 gener->Init();
81}
82*/
83// and in aliroot do e.g. gAlice->Run(10,"Config.C") to produce 10 events.
84// One can include AliGenCorrHF in an AliGenCocktail generator.
85//--------------------------------------------------------------------------
86
7ca4655f 87#include <Riostream.h>
88#include <TCanvas.h>
89#include <TClonesArray.h>
90#include <TDatabasePDG.h>
2c890605 91#include <TFile.h>
2c890605 92#include <TH2F.h>
2c890605 93#include <TLorentzVector.h>
7ca4655f 94#include <TMath.h>
2c890605 95#include <TParticle.h>
96#include <TParticlePDG.h>
7ca4655f 97#include <TROOT.h>
98#include <TRandom.h>
99#include <TTree.h>
2c890605 100#include <TVirtualMC.h>
b44c3901 101#include <TVector3.h>
2c890605 102
103#include "AliGenCorrHF.h"
104#include "AliLog.h"
105#include "AliConst.h"
106#include "AliDecayer.h"
107#include "AliMC.h"
108#include "AliRun.h"
84555c93 109#include "AliGenEventHeader.h"
2c890605 110
111ClassImp(AliGenCorrHF)
112
113 //Begin_Html
114 /*
115 <img src="picts/AliGenCorrHF.gif">
116 */
117 //End_Html
118
119Double_t AliGenCorrHF::fgdph[19] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180};
120Double_t AliGenCorrHF::fgy[31] = {-10,-7, -6.5, -6, -5.5, -5, -4.5, -4, -3.5, -3, -2.5, -2,- 1.5, -1, -0.5, 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 10};
b33adf51 121Double_t AliGenCorrHF::fgpt[51] = {0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.6, 7.2, 7.8, 8.4, 9, 9.6, 10.3, 11.1, 12, 13, 14, 15, 16, 17, 18, 19, 20.1, 21.5, 23, 24.5, 26, 27.5, 29.1, 31, 33, 35, 37, 39.2, 42, 45, 48, 51, 55.2, 60, 65, 71, 81, 100};
2c890605 122Int_t AliGenCorrHF::fgnptbins = 12;
123Double_t AliGenCorrHF::fgptbmin[12] = {0, 0.5, 1, 1.5, 2, 2.5, 3, 4, 5, 6, 7, 9};
124Double_t AliGenCorrHF::fgptbmax[12] = {0.5, 1, 1.5, 2, 2.5, 3, 4, 5, 6, 7, 9, 100};
125
126Double_t* AliGenCorrHF::fgIntegral = 0;
127
128//____________________________________________________________
129 AliGenCorrHF::AliGenCorrHF():
130 fFileName(0),
131 fFile(0),
132 fQuark(0),
b33adf51 133 fEnergy(0),
2c890605 134 fBias(0.),
135 fTrials(0),
136 fDecayer(0)
137{
138// Default constructor
139}
140
141//____________________________________________________________
b33adf51 142AliGenCorrHF::AliGenCorrHF(Int_t npart, Int_t idquark, Int_t energy):
2c890605 143 AliGenMC(npart),
144 fFileName(0),
145 fFile(0),
b33adf51 146 fQuark(idquark),
147 fEnergy(energy),
2c890605 148 fBias(0.),
149 fTrials(0),
150 // fDecayer(new AliDecayerPythia())
151 fDecayer(0)
152{
b33adf51 153// Constructor using particle number, quark type, energy & default InputFile
2c890605 154//
b33adf51 155 if (fQuark == 5) {
9fd56238 156 if (fEnergy == 7)
157 fFileName = "$ALICE_ROOT/EVGEN/dataCorrHF/BeautyPP7PythiaMNRwmi.root";
158 else if (fEnergy == 10)
159 fFileName = "$ALICE_ROOT/EVGEN/dataCorrHF/BeautyPP10PythiaMNRwmi.root";
160 else if (fEnergy == 14)
161 fFileName = "$ALICE_ROOT/EVGEN/dataCorrHF/BeautyPP14PythiaMNRwmi.root";
162 else if (fEnergy == 4)
163 fFileName = "$ALICE_ROOT/EVGEN/dataCorrHF/BeautyPbPb394PythiaMNR.root";
164 else if (fEnergy == 9 || fEnergy == -9)
165 fFileName = "$ALICE_ROOT/EVGEN/dataCorrHF/BeautyPPb88PythiaMNR.root";
166 else fFileName = "$ALICE_ROOT/EVGEN/dataCorrHF/BeautyPbPb394PythiaMNR.root";
b33adf51 167 }
168 else {
169 fQuark = 4;
9fd56238 170 if (fEnergy == 7)
171 fFileName = "$ALICE_ROOT/EVGEN/dataCorrHF/CharmPP7PythiaMNRwmi.root";
172 else if (fEnergy == 10)
173 fFileName = "$ALICE_ROOT/EVGEN/dataCorrHF/CharmPP10PythiaMNRwmi.root";
174 else if (fEnergy == 14)
175 fFileName = "$ALICE_ROOT/EVGEN/dataCorrHF/CharmPP14PythiaMNRwmi.root";
176 else if (fEnergy == 4)
177 fFileName = "$ALICE_ROOT/EVGEN/dataCorrHF/CharmPbPb394PythiaMNR.root";
178 else if (fEnergy == 9 || fEnergy == -9)
179 fFileName = "$ALICE_ROOT/EVGEN/dataCorrHF/CharmPPb88PythiaMNR.root";
180 else fFileName = "$ALICE_ROOT/EVGEN/dataCorrHF/CharmPbPb394PythiaMNR.root";
b33adf51 181 }
2c890605 182 fName = "Default";
183 fTitle= "Generator for correlated pairs of HF hadrons";
184
185 fChildSelect.Set(5);
186 for (Int_t i=0; i<5; i++) fChildSelect[i]=0;
187 SetForceDecay();
188 SetCutOnChild();
189 SetChildMomentumRange();
190 SetChildPtRange();
191 SetChildPhiRange();
192 SetChildThetaRange();
193}
194
195//___________________________________________________________________
b33adf51 196AliGenCorrHF::AliGenCorrHF(char* tname, Int_t npart, Int_t idquark, Int_t energy):
2c890605 197 AliGenMC(npart),
198 fFileName(tname),
199 fFile(0),
b33adf51 200 fQuark(idquark),
201 fEnergy(energy),
2c890605 202 fBias(0.),
203 fTrials(0),
204 // fDecayer(new AliDecayerPythia())
205 fDecayer(0)
206{
b33adf51 207// Constructor using particle number, quark type, energy & user-defined InputFile
2c890605 208//
209 if (fQuark != 5) fQuark = 4;
210 fName = "UserDefined";
211 fTitle= "Generator for correlated pairs of HF hadrons";
212
213 fChildSelect.Set(5);
214 for (Int_t i=0; i<5; i++) fChildSelect[i]=0;
215 SetForceDecay();
216 SetCutOnChild();
217 SetChildMomentumRange();
218 SetChildPtRange();
219 SetChildPhiRange();
220 SetChildThetaRange();
221}
222
2c890605 223//____________________________________________________________
224AliGenCorrHF::~AliGenCorrHF()
225{
226// Destructor
227 delete fFile;
228}
229
230//____________________________________________________________
231void AliGenCorrHF::Init()
232{
233// Initialisation
234
235 AliInfo(Form(" QQbar kinematics and fragm. functions from: %s",fFileName.Data() ));
236 fFile = TFile::Open(fFileName.Data());
237 if(!fFile->IsOpen()){
238 AliError(Form("Could not open file %s",fFileName.Data() ));
239 }
240
241 ComputeIntegral(fFile);
b44c3901 242
2c890605 243 fParentWeight = 1./fNpart; // fNpart is number of HF-hadron pairs
244
245// particle decay related initialization
246
247 if (gMC) fDecayer = gMC->GetDecayer();
248 fDecayer->SetForceDecay(fForceDecay);
249 fDecayer->Init();
250
251//
252 AliGenMC::Init();
253}
2c890605 254//____________________________________________________________
255void AliGenCorrHF::Generate()
256{
257//
cb11fd27 258// Generate fNpart of correlated HF hadron pairs per event
259// in the the desired theta and momentum windows (phi = 0 - 2pi).
84555c93 260//
cb11fd27 261
84555c93 262// Reinitialize decayer
2c890605 263
84555c93 264 fDecayer->SetForceDecay(fForceDecay);
265 fDecayer->Init();
266
267 //
2c890605 268 Float_t polar[3]= {0,0,0}; // Polarisation of the parent particle (for GEANT tracking)
269 Float_t origin0[3]; // Origin of the generated parent particle (for GEANT tracking)
270 Float_t pt, pl, ptot; // Transverse, logitudinal and total momenta of the parent particle
271 Float_t phi, theta; // Phi and theta spherical angles of the parent particle momentum
272 Float_t p[3], pc[3], och[3];// Momentum, polarisation and origin of the children particles from lujet
84555c93 273 Int_t nt, i, j, ipa, ihadron[2], iquark[2];
274 Float_t wgtp, wgtch, random[6];
275 Float_t pq[2][3]; // Momenta of the two quarks
276 Int_t ntq[2] = {-1, -1};
cb11fd27 277 Double_t tanhy2, qm = 0;
2c890605 278
b44c3901 279 Double_t dphi=0, ptq[2], yq[2], pth[2], plh[2], ph[2], phih[2], phiq[2];
2c890605 280 for (i=0; i<2; i++) {
b44c3901 281 ptq[i] =0;
282 yq[i] =0;
283 pth[i] =0;
284 plh[i] =0;
285 phih[i] =0;
286 phiq[i] =0;
2c890605 287 ihadron[i] =0;
84555c93 288 iquark[i] =0;
2c890605 289 }
290
cb11fd27 291 // same quarks mass as in the fragmentation functions
292 if (fQuark == 4) qm = 1.20;
293 else qm = 4.75;
294
2c890605 295 static TClonesArray *particles;
296 //
297 if(!particles) particles = new TClonesArray("TParticle",1000);
298
84555c93 299 TDatabasePDG *pDataBase = TDatabasePDG::Instance();
300 //
301
302 // Calculating vertex position per event
2c890605 303 for (j=0;j<3;j++) origin0[j]=fOrigin[j];
b33adf51 304 if (fVertexSmear==kPerEvent) {
84555c93 305 Vertex();
306 for (j=0;j<3;j++) origin0[j]=fVertex[j];
2c890605 307 }
308
84555c93 309 ipa=0;
310
9fd56238 311 // Generating fNpart HF-hadron pairs
84555c93 312 fNprimaries = 0;
313
314 while (ipa<2*fNpart) {
315
316 GetQuarkPair(fFile, fgIntegral, yq[0], yq[1], ptq[0], ptq[1], dphi);
317
318 GetHadronPair(fFile, fQuark, yq[0], yq[1], ptq[0], ptq[1], ihadron[0], ihadron[1], plh[0], plh[1], pth[0], pth[1]);
319
9fd56238 320 if (fEnergy == 9 || fEnergy == -9) { // boost particles from c.m.s. to ALICE lab frame
321 Double_t dyBoost = 0.47;
322 Double_t beta = TMath::TanH(dyBoost);
323 Double_t gamma = 1./TMath::Sqrt((1.-beta)*(1.+beta));
324 Double_t gb = gamma * beta;
325 yq[0] += dyBoost;
326 yq[1] += dyBoost;
327 plh[0] = gb * TMath::Sqrt(plh[0]*plh[0] + pth[0]*pth[0]) + gamma * plh[0];
328 plh[1] = gb * TMath::Sqrt(plh[1]*plh[1] + pth[1]*pth[1]) + gamma * plh[1];
329 if (fEnergy == 9) {
330 yq[0] *= -1;
331 yq[1] *= -1;
332 plh[0] *= -1;
333 plh[1] *= -1;
334 }
335 }
336
84555c93 337 // Cuts from AliGenerator
338
339 // Cut on theta
340 theta=TMath::ATan2(pth[0],plh[0]);
b33adf51 341 if (theta<fThetaMin || theta>fThetaMax) continue;
84555c93 342 theta=TMath::ATan2(pth[1],plh[1]);
b33adf51 343 if (theta<fThetaMin || theta>fThetaMax) continue;
84555c93 344
345 // Cut on momentum
346 ph[0]=TMath::Sqrt(pth[0]*pth[0]+plh[0]*plh[0]);
347 if (ph[0]<fPMin || ph[0]>fPMax) continue;
348 ph[1]=TMath::Sqrt(pth[1]*pth[1]+plh[1]*plh[1]);
349 if (ph[1]<fPMin || ph[1]>fPMax) continue;
350
351 // Add the quarks in the stack
352
353 phiq[0] = Rndm()*k2PI;
354 if (Rndm() < 0.5) {
b44c3901 355 phiq[1] = phiq[0] + dphi*kDegrad;
84555c93 356 } else {
357 phiq[1] = phiq[0] - dphi*kDegrad;
358 }
359 if (phiq[1] > k2PI) phiq[1] -= k2PI;
360 if (phiq[1] < 0 ) phiq[1] += k2PI;
361
362 // quarks pdg
363 iquark[0] = +fQuark;
364 iquark[1] = -fQuark;
365
366 // px and py
367 TVector2 qvect1 = TVector2();
368 TVector2 qvect2 = TVector2();
369 qvect1.SetMagPhi(ptq[0],phiq[0]);
370 qvect2.SetMagPhi(ptq[1],phiq[1]);
371 pq[0][0] = qvect1.Px();
372 pq[0][1] = qvect1.Py();
373 pq[1][0] = qvect2.Px();
374 pq[1][1] = qvect2.Py();
375
376 // pz
cb11fd27 377 tanhy2 = TMath::TanH(yq[0]);
378 tanhy2 *= tanhy2;
379 pq[0][2] = TMath::Sqrt((ptq[0]*ptq[0]+qm*qm)*tanhy2/(1-tanhy2));
380 pq[0][2] = TMath::Sign((Double_t)pq[0][2],yq[0]);
381 tanhy2 = TMath::TanH(yq[1]);
382 tanhy2 *= tanhy2;
383 pq[1][2] = TMath::Sqrt((ptq[1]*ptq[1]+qm*qm)*tanhy2/(1-tanhy2));
384 pq[1][2] = TMath::Sign((Double_t)pq[1][2],yq[1]);
84555c93 385
386 // Here we assume that |phi_H1 - phi_H2| = |phi_Q1 - phi_Q2| = dphi
387 // which is a good approximation for heavy flavors in Pythia
388 // ... moreover, same phi angles as for the quarks ...
389
390 phih[0] = phiq[0];
391 phih[1] = phiq[1];
b44c3901 392
84555c93 393 for (Int_t ihad = 0; ihad < 2; ihad++) {
394 while(1) {
395 //
396 // particle type
397 Int_t iPart = ihadron[ihad];
398 fChildWeight=(fDecayer->GetPartialBranchingRatio(iPart))*fParentWeight;
399 wgtp=fParentWeight;
400 wgtch=fChildWeight;
401 TParticlePDG *particle = pDataBase->GetParticle(iPart);
402 Float_t am = particle->Mass();
403 phi = phih[ihad];
404 pt = pth[ihad];
405 pl = plh[ihad];
406 ptot=TMath::Sqrt(pt*pt+pl*pl);
407
408 p[0]=pt*TMath::Cos(phi);
409 p[1]=pt*TMath::Sin(phi);
410 p[2]=pl;
b44c3901 411
2c890605 412 if(fVertexSmear==kPerTrack) {
84555c93 413 Rndm(random,6);
414 for (j=0;j<3;j++) {
415 origin0[j]=
416 fOrigin[j]+fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
417 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
2c890605 418 }
419 }
84555c93 420
421 // Looking at fForceDecay :
422 // if fForceDecay != none Primary particle decays using
423 // AliPythia and children are tracked by GEANT
424 //
425 // if fForceDecay == none Primary particle is tracked by GEANT
426 // (In the latest, make sure that GEANT actually does all the decays you want)
427 //
428
429 if (fForceDecay != kNoDecay) {
430 // Using lujet to decay particle
431 Float_t energy=TMath::Sqrt(ptot*ptot+am*am);
432 TLorentzVector pmom(p[0], p[1], p[2], energy);
433 fDecayer->Decay(iPart,&pmom);
434 //
435 // select decay particles
436 Int_t np=fDecayer->ImportParticles(particles);
437
438 // Selecting GeometryAcceptance for particles fPdgCodeParticleforAcceptanceCut;
439 if (fGeometryAcceptance)
440 if (!CheckAcceptanceGeometry(np,particles)) continue;
441 Int_t ncsel=0;
442 Int_t* pFlag = new Int_t[np];
443 Int_t* pParent = new Int_t[np];
444 Int_t* pSelected = new Int_t[np];
445 Int_t* trackIt = new Int_t[np];
446
447 for (i=0; i<np; i++) {
448 pFlag[i] = 0;
449 pSelected[i] = 0;
450 pParent[i] = -1;
451 }
452
453 if (np >1) {
454 TParticle* iparticle = (TParticle *) particles->At(0);
455 Int_t ipF, ipL;
456 for (i = 1; i<np ; i++) {
457 trackIt[i] = 1;
458 iparticle = (TParticle *) particles->At(i);
459 Int_t kf = iparticle->GetPdgCode();
460 Int_t ks = iparticle->GetStatusCode();
461 // flagged particle
462
463 if (pFlag[i] == 1) {
464 ipF = iparticle->GetFirstDaughter();
465 ipL = iparticle->GetLastDaughter();
466 if (ipF > 0) for (j=ipF-1; j<ipL; j++) pFlag[j]=1;
467 continue;
468 }
469
470 // flag decay products of particles with long life-time (c tau > .3 mum)
471
472 if (ks != 1) {
473 //TParticlePDG *particle = pDataBase->GetParticle(kf);
474
475 Double_t lifeTime = fDecayer->GetLifetime(kf);
476 //Double_t mass = particle->Mass();
477 //Double_t width = particle->Width();
478 if (lifeTime > (Double_t) fMaxLifeTime) {
479 ipF = iparticle->GetFirstDaughter();
480 ipL = iparticle->GetLastDaughter();
481 if (ipF > 0) for (j=ipF-1; j<ipL; j++) pFlag[j]=1;
b33adf51 482 } else {
84555c93 483 trackIt[i] = 0;
484 pSelected[i] = 1;
2c890605 485 }
84555c93 486 } // ks==1 ?
487 //
488 // children
489
f7b22746 490 if ((ChildSelected(TMath::Abs(kf)) || fForceDecay == kAll) && trackIt[i])
84555c93 491 {
492 if (fCutOnChild) {
493 pc[0]=iparticle->Px();
494 pc[1]=iparticle->Py();
495 pc[2]=iparticle->Pz();
496 Bool_t childok = KinematicSelection(iparticle, 1);
497 if(childok) {
498 pSelected[i] = 1;
499 ncsel++;
500 } else {
501 ncsel=-1;
502 break;
503 } // child kine cuts
504 } else {
505 pSelected[i] = 1;
506 ncsel++;
507 } // if child selection
508 } // select muon
509 } // decay particle loop
510 } // if decay products
511
512 Int_t iparent;
513 if ((fCutOnChild && ncsel >0) || !fCutOnChild){
514 ipa++;
515 //
516 // Parent
517 // quark
518 PushTrack(0, -1, iquark[ihad], pq[ihad], origin0, polar, 0, kPPrimary, nt, wgtp);
519 KeepTrack(nt);
520 ntq[ihad] = nt;
84555c93 521 // hadron
522 PushTrack(0, ntq[ihad], iPart, p, origin0, polar, 0, kPDecay, nt, wgtp);
523 pParent[0] = nt;
524 KeepTrack(nt);
525 fNprimaries++;
84555c93 526
527 //
528 // Decay Products
529 //
530 for (i = 1; i < np; i++) {
531 if (pSelected[i]) {
532 TParticle* iparticle = (TParticle *) particles->At(i);
533 Int_t kf = iparticle->GetPdgCode();
7f11c778 534 Int_t jpa = iparticle->GetFirstMother()-1;
2c890605 535
84555c93 536 och[0] = origin0[0]+iparticle->Vx()/10;
537 och[1] = origin0[1]+iparticle->Vy()/10;
538 och[2] = origin0[2]+iparticle->Vz()/10;
539 pc[0] = iparticle->Px();
540 pc[1] = iparticle->Py();
541 pc[2] = iparticle->Pz();
2c890605 542
7f11c778 543 if (jpa > -1) {
544 iparent = pParent[jpa];
84555c93 545 } else {
546 iparent = -1;
547 }
548
549 PushTrack(fTrackIt*trackIt[i], iparent, kf,
550 pc, och, polar,
551 0, kPDecay, nt, wgtch);
84555c93 552 pParent[i] = nt;
553 KeepTrack(nt);
554 fNprimaries++;
555 } // Selected
556 } // Particle loop
557 } // Decays by Lujet
558 particles->Clear();
559 if (pFlag) delete[] pFlag;
560 if (pParent) delete[] pParent;
561 if (pSelected) delete[] pSelected;
562 if (trackIt) delete[] trackIt;
563 } // kinematic selection
564 else // nodecay option, so parent will be tracked by GEANT (pions, kaons, eta, omegas, baryons)
565 {
566 gAlice->GetMCApp()->
567 PushTrack(fTrackIt,-1,iPart,p,origin0,polar,0,kPPrimary,nt,wgtp);
568 ipa++;
569 fNprimaries++;
570 }
2c890605 571 break;
9fd56238 572 } // while(1) loop
84555c93 573 } // hadron pair loop
9fd56238 574 } // while (ipa<2*fNpart) loop
575
2c890605 576 SetHighWaterMark(nt);
84555c93 577
cb11fd27 578 AliGenEventHeader* header = new AliGenEventHeader("CorrHF");
84555c93 579 header->SetPrimaryVertex(fVertex);
580 header->SetNProduced(fNprimaries);
581 AddHeader(header);
2c890605 582
84555c93 583}
2c890605 584//____________________________________________________________________________________
9fd56238 585void AliGenCorrHF::IpCharm(TH2F *hProbHH, Int_t &pdg3, Int_t &pdg4)
2c890605 586{
9fd56238 587// Composition of a lower state charm hadron pair from a ccbar quark pair
588 Int_t pdgH[] = {411, 421, 431, 4122, 4132, 4232, 4332};
589
590 Double_t id3, id4;
591 hProbHH->GetRandom2(id3, id4);
592 pdg3 = pdgH[(Int_t)TMath::Floor(id3)];
593 pdg4 = -1*pdgH[(Int_t)TMath::Floor(id4)];
594
595 return;
2c890605 596}
597
9fd56238 598void AliGenCorrHF::IpBeauty(TH2F *hProbHH, Int_t &pdg3, Int_t &pdg4)
2c890605 599{
9fd56238 600// Composition of a lower state beauty hadron pair from a bbbar quark pair
601 // B-Bbar mixing will be done by Pythia at their decay point
602 Int_t pdgH[] = {511, 521, 531, 5122, 5132, 5232, 5332};
603
604 Double_t id3, id4;
605 hProbHH->GetRandom2(id3, id4);
606 pdg3 = pdgH[(Int_t)TMath::Floor(id3)];
607 pdg4 = -1*pdgH[(Int_t)TMath::Floor(id4)];
608
609 if ( (pdg3== 511) || (pdg3== 521) || (pdg3== 531) ) pdg3 *= -1;
610 if ( (pdg4==-511) || (pdg4==-521) || (pdg4==-531) ) pdg4 *= -1;
611
612 return;
2c890605 613}
614
615//____________________________________________________________________________________
616Double_t AliGenCorrHF::ComputeIntegral(TFile* fG) // needed by GetQuarkPair
617{
618 // Read QQbar kinematical 5D grid's cell occupancy weights
4c111067 619 Int_t cell[6]; // cell[6]={wght,iy1,iy2,ipt1,ipt2,idph}
2c890605 620 TTree* tG = (TTree*) fG->Get("tGqq");
4c111067 621 tG->GetBranch("cell")->SetAddress(&cell);
2c890605 622 Int_t nbins = tG->GetEntries();
623
624 // delete previously computed integral (if any)
625 if(fgIntegral) delete [] fgIntegral;
626
627 fgIntegral = new Double_t[nbins+1];
628 fgIntegral[0] = 0;
629 Int_t bin;
630 for(bin=0;bin<nbins;bin++) {
631 tG->GetEvent(bin);
632 fgIntegral[bin+1] = fgIntegral[bin] + cell[0];
633 }
634 // Normalize integral to 1
635 if (fgIntegral[nbins] == 0 ) {
636 return 0;
637 }
638 for (bin=1;bin<=nbins;bin++) fgIntegral[bin] /= fgIntegral[nbins];
639
640 return fgIntegral[nbins];
641}
642
643//____________________________________________________________________________________
644void AliGenCorrHF::GetQuarkPair(TFile* fG, Double_t* fInt, Double_t &y1, Double_t &y2, Double_t &pt1, Double_t &pt2, Double_t &dphi)
645 // modification of ROOT's TH3::GetRandom3 for 5D
646{
647 // Read QQbar kinematical 5D grid's cell coordinates
4c111067 648 Int_t cell[6]; // cell[6]={wght,iy1,iy2,ipt1,ipt2,idph}
2c890605 649 TTree* tG = (TTree*) fG->Get("tGqq");
4c111067 650 tG->GetBranch("cell")->SetAddress(&cell);
2c890605 651 Int_t nbins = tG->GetEntries();
652 Double_t rand[6];
653 gRandom->RndmArray(6,rand);
654 Int_t ibin = TMath::BinarySearch(nbins,fInt,rand[0]);
655 tG->GetEvent(ibin);
656 y1 = fgy[cell[1]] + (fgy[cell[1]+1]-fgy[cell[1]])*rand[1];
657 y2 = fgy[cell[2]] + (fgy[cell[2]+1]-fgy[cell[2]])*rand[2];
658 pt1 = fgpt[cell[3]] + (fgpt[cell[3]+1]-fgpt[cell[3]])*rand[3];
659 pt2 = fgpt[cell[4]] + (fgpt[cell[4]+1]-fgpt[cell[4]])*rand[4];
660 dphi = fgdph[cell[5]]+ (fgdph[cell[5]+1]-fgdph[cell[5]])*rand[5];
661}
662
663//____________________________________________________________________________________
664void AliGenCorrHF::GetHadronPair(TFile* fG, Int_t idq, Double_t y1, Double_t y2, Double_t pt1, Double_t pt2, Int_t &id3, Int_t &id4, Double_t &pz3, Double_t &pz4, Double_t &pt3, Double_t &pt4)
665{
666 // Generate a hadron pair
9fd56238 667 void (*fIpParaFunc)(TH2F *, Int_t &, Int_t &);//Pointer to hadron pair composition function
2c890605 668 fIpParaFunc = IpCharm;
669 Double_t mq = 1.2; // c & b quark masses (used in AliPythia)
670 if (idq == 5) {
671 fIpParaFunc = IpBeauty;
672 mq = 4.75;
673 }
674 Double_t z11, z12, z21, z22, pz1, pz2, e1, e2, mh, ptemp, rand[2];
675 char tag[100];
9fd56238 676 TH2F *h2h[12], *h2s[12], *hProbHH; // hard & soft fragmentation and HH-probability functions
2c890605 677 for (Int_t ipt = 0; ipt<fgnptbins; ipt++) {
678 sprintf(tag,"h2h_pt%d",ipt);
679 h2h[ipt] = (TH2F*) fG->Get(tag);
680 sprintf(tag,"h2s_pt%d",ipt);
681 h2s[ipt] = (TH2F*) fG->Get(tag);
682 }
683
684 if (y1*y2 < 0) {
685 for (Int_t ipt = 0; ipt<fgnptbins; ipt++) {
686 if(pt1 >= fgptbmin[ipt] && pt1 < fgptbmax[ipt])
687 h2h[ipt]->GetRandom2(z11, z21);
688 if(pt2 >= fgptbmin[ipt] && pt2 < fgptbmax[ipt])
689 h2h[ipt]->GetRandom2(z12, z22);
690 }
691 }
692 else {
693 if (TMath::Abs(y1) > TMath::Abs(y2)) {
694 for (Int_t ipt = 0; ipt<fgnptbins; ipt++) {
695 if(pt1 >= fgptbmin[ipt] && pt1 < fgptbmax[ipt])
696 h2h[ipt]->GetRandom2(z11, z21);
697 if(pt2 >= fgptbmin[ipt] && pt2 < fgptbmax[ipt])
698 h2s[ipt]->GetRandom2(z12, z22);
699 }
700 }
701 else {
702 for (Int_t ipt = 0; ipt<fgnptbins; ipt++) {
703 if(pt1 >= fgptbmin[ipt] && pt1 < fgptbmax[ipt])
704 h2s[ipt]->GetRandom2(z11, z21);
705 if(pt2 >= fgptbmin[ipt] && pt2 < fgptbmax[ipt])
706 h2h[ipt]->GetRandom2(z12, z22);
707 }
708 }
709 }
710 gRandom->RndmArray(2,rand);
711 ptemp = TMath::Sqrt(pt1*pt1 + mq*mq);
712 pz1 = ptemp*TMath::SinH(y1);
713 e1 = ptemp*TMath::CosH(y1);
714 ptemp = TMath::Sqrt(pt2*pt2 + mq*mq);
715 pz2 = ptemp*TMath::SinH(y2);
716 e2 = ptemp*TMath::CosH(y2);
717
9fd56238 718 hProbHH = (TH2F*)fG->Get("hProbHH");
719 fIpParaFunc(hProbHH, id3, id4);
2c890605 720 mh = TDatabasePDG::Instance()->GetParticle(id3)->Mass();
721 ptemp = z11*z21*(e1*e1-pz1*pz1) - mh*mh;
b33adf51 722 if (idq==5) pt3 = pt1; // an approximation at low pt, try better
9fd56238 723 else pt3 = rand[0]; // pt3=pt1 gives less D-hadrons at low pt
2c890605 724 if (ptemp > 0) pt3 = TMath::Sqrt(ptemp);
725 if (pz1 > 0) pz3 = (z11*(e1 + pz1) - z21*(e1 - pz1)) / 2;
726 else pz3 = (z21*(e1 + pz1) - z11*(e1 - pz1)) / 2;
727 e1 = TMath::Sqrt(pz3*pz3 + pt3*pt3 + mh*mh);
728
2c890605 729 mh = TDatabasePDG::Instance()->GetParticle(id4)->Mass();
730 ptemp = z12*z22*(e2*e2-pz2*pz2) - mh*mh;
b33adf51 731 if (idq==5) pt4 = pt2; // an approximation at low pt, try better
732 else pt4 = rand[1];
2c890605 733 if (ptemp > 0) pt4 = TMath::Sqrt(ptemp);
734 if (pz2 > 0) pz4 = (z12*(e2 + pz2) - z22*(e2 - pz2)) / 2;
735 else pz4 = (z22*(e2 + pz2) - z12*(e2 - pz2)) / 2;
736 e2 = TMath::Sqrt(pz4*pz4 + pt4*pt4 + mh*mh);
737
738 // small corr. instead of using Frag. Func. depending on yQ (in addition to ptQ)
739 Float_t ycorr = 0.2, y3, y4;
740 gRandom->RndmArray(2,rand);
741 y3 = 0.5 * TMath::Log((e1 + pz3 + 1.e-13)/(e1 - pz3 + 1.e-13));
742 y4 = 0.5 * TMath::Log((e2 + pz4 + 1.e-13)/(e2 - pz4 + 1.e-13));
743 if(TMath::Abs(y3)<ycorr && TMath::Abs(y4)<ycorr && rand[0]>0.5) {
bfd20868 744 ptemp = TMath::Sqrt((e1-pz3)*(e1+pz3));
2c890605 745 y3 = 4*(1 - 2*rand[1]);
746 pz3 = ptemp*TMath::SinH(y3);
747 pz4 = pz3;
748 }
749}