1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 // QA class of Heavy Flavor quark and fragmeted/decayed particles
17 // -Check kinematics of Heavy Quarks/hadrons, and decayed leptons
19 // decay lepton kinematics w/wo acceptance
20 // heavy hadron decay length, electron pT fraction carried from decay
21 // -Check yield of Heavy Quarks/hadrons
22 // Number of produced heavy quark
23 // Number of produced hadron of given pdg code
27 // MinJung Kweon <minjung@physi.uni-heidelberg.de>
34 #include <TParticle.h>
37 #include <AliMCEvent.h>
38 #include <AliGenEventHeader.h>
39 #include <AliAODMCParticle.h>
42 #include "AliHFEmcQA.h"
43 #include "AliHFEtools.h"
44 #include "AliHFEcollection.h"
48 //_______________________________________________________________________________________________
49 AliHFEmcQA::AliHFEmcQA() :
54 ,fMCQACollection(NULL)
58 ,fIsppMultiBin(kFALSE)
60 // Default constructor
61 for(Int_t mom = 0; mom < 9; mom++){
63 fhDLogbin[mom] = NULL;
65 for(Int_t mom = 0; mom < 50; mom++){
66 fHeavyQuark[mom] = NULL;
68 for(Int_t mom = 0; mom < 2; mom++){
71 memset(fElecBackgroundFactor, 0, sizeof(Double_t) * kElecBgSpecies * kBgPtBins * kCentBins * kBgLevels);
72 memset(fBinLimit, 0, sizeof(Double_t) * (kBgPtBins+1));
75 //_______________________________________________________________________________________________
76 AliHFEmcQA::AliHFEmcQA(const AliHFEmcQA&p):
81 ,fQAhistos(p.fQAhistos)
82 ,fMCQACollection(p.fMCQACollection)
83 ,fNparents(p.fNparents)
86 ,fIsppMultiBin(kFALSE)
89 for(Int_t mom = 0; mom < 9; mom++){
91 fhDLogbin[mom] = NULL;
93 for(Int_t mom = 0; mom < 50; mom++){
94 fHeavyQuark[mom] = NULL;
96 for(Int_t mom = 0; mom < 2; mom++){
99 memset(fElecBackgroundFactor, 0, sizeof(Double_t) * kElecBgSpecies * kBgPtBins * kCentBins * kBgLevels);
100 memset(fBinLimit, 0, sizeof(Double_t) * (kBgPtBins+1));
103 //_______________________________________________________________________________________________
105 AliHFEmcQA::operator=(const AliHFEmcQA &)
107 // Assignment operator
109 AliInfo("Not yet implemented.");
113 //_______________________________________________________________________________________________
114 AliHFEmcQA::~AliHFEmcQA()
118 AliInfo("Analysis Done.");
121 //_______________________________________________________________________________________________
122 void AliHFEmcQA::PostAnalyze() const
129 //_______________________________________________________________________________________________
130 void AliHFEmcQA::SetBackgroundWeightFactor(Double_t *elecBackgroundFactor, Double_t *binLimit)
133 // copy background weighting factors into data member
136 memcpy(fElecBackgroundFactor,elecBackgroundFactor,sizeof(Double_t) * kElecBgSpecies * kBgPtBins * kCentBins * kBgLevels);
137 memcpy(fBinLimit,binLimit,sizeof(Double_t) * (kBgPtBins+1));
140 //__________________________________________
141 void AliHFEmcQA::CreatDefaultHistograms(TList * const qaList)
144 // make default histograms
150 fQAhistos->SetName("MCqa");
152 CreateHistograms(AliHFEmcQA::kCharm,0,"mcqa_"); // create histograms for charm
153 CreateHistograms(AliHFEmcQA::kBeauty,0,"mcqa_"); // create histograms for beauty
154 CreateHistograms(AliHFEmcQA::kOthers,0,"mcqa_"); // create histograms for beauty
155 CreateHistograms(AliHFEmcQA::kCharm,1,"mcqa_barrel_"); // create histograms for charm
156 CreateHistograms(AliHFEmcQA::kBeauty,1,"mcqa_barrel_"); // create histograms for beauty
157 CreateHistograms(AliHFEmcQA::kOthers,1,"mcqa_barrel_"); // create histograms for beauty
158 CreateHistograms(AliHFEmcQA::kCharm,2,"mcqa_unitY_"); // create histograms for charm
159 CreateHistograms(AliHFEmcQA::kBeauty,2,"mcqa_unitY_"); // create histograms for beauty
160 CreateHistograms(AliHFEmcQA::kOthers,2,"mcqa_unitY_"); // create histograms for beauty
163 TString kDspecies[9];
174 const Double_t kPtbound[2] = {0.1, 20.}; //bin taken for considering inclusive e analysis binning
176 iBin[0] = 44; // bins in pt
177 iBin[1] = 23; // bins in pt
178 Double_t* binEdges[1];
179 binEdges[0] = AliHFEtools::MakeLogarithmicBinning(iBin[0], kPtbound[0], kPtbound[1]);
181 // bin size is chosen to consider ALICE D measurement
182 Double_t xbins[15]={0,0.5,1.0,2.0,3.0,4.0,5.0,6.0,8.0,12,16,20,30,40,50};
183 Double_t ybins[10]={-7.5,-1.0,-0.9,-0.8,-0.5,0.5,0.8,0.9,1.0,7.5};
185 for (Int_t iDmeson=0; iDmeson<9; iDmeson++){
186 hname = "Dmeson"+kDspecies[iDmeson];
187 fhD[iDmeson] = new TH2F(hname,hname+";p_{T} (GeV/c)",14,xbins,9,ybins);
188 hname = "DmesonLogbin"+kDspecies[iDmeson];
189 fhDLogbin[iDmeson] = new TH1F(hname,hname+";p_{T} (GeV/c)",iBin[0],binEdges[0]);
190 if(fQAhistos) fQAhistos->Add(fhD[iDmeson]);
191 if(fQAhistos) fQAhistos->Add(fhDLogbin[iDmeson]);
194 const Double_t kPtRange[24] = {0.,0.3,0.4,0.5,0.6,0.8,1.,1.2,1.4,1.6,1.8,2.,2.2,2.4,2.6,2.8,3.,3.5,4.,5.,6.,7.,20.,30.}; // to cope with Ana's bin
197 if(fIsPbPb) kNcent=11;
200 if(fIsppMultiBin) kNcent=8;
204 fMCQACollection = new AliHFEcollection("TaskMCQA", "MC QA histos for meason pt spectra");
206 for(Int_t centbin=0; centbin<kNcent; centbin++)
208 fMCQACollection->CreateTH1Farray(Form("pionspectra_centrbin%i",centbin), "pion yields: MC p_{t} ", iBin[1],kPtRange);
209 fMCQACollection->CreateTH1Farray(Form("etaspectra_centrbin%i",centbin), "eta yields: MC p_{t} ", iBin[1],kPtRange);
210 fMCQACollection->CreateTH1Farray(Form("omegaspectra_centrbin%i",centbin), "omega yields: MC p_{t} ", iBin[1],kPtRange);
211 fMCQACollection->CreateTH1Farray(Form("phispectra_centrbin%i",centbin), "phi yields: MC p_{t} ", iBin[1],kPtRange);
212 fMCQACollection->CreateTH1Farray(Form("etapspectra_centrbin%i",centbin), "etap yields: MC p_{t} ", iBin[1],kPtRange);
213 fMCQACollection->CreateTH1Farray(Form("rhospectra_centrbin%i",centbin), "rho yields: MC p_{t} ", iBin[1],kPtRange);
215 fMCQACollection->CreateTH1F(Form("pionspectraLog_centrbin%i",centbin), "pion yields: MC p_{t} ", iBin[0],kPtbound[0], kPtbound[1], 1);
216 fMCQACollection->CreateTH1F(Form("etaspectraLog_centrbin%i",centbin), "eta yields: MC p_{t} ", iBin[0],kPtbound[0], kPtbound[1], 1);
217 fMCQACollection->CreateTH1F(Form("omegaspectraLog_centrbin%i",centbin), "omega yields: MC p_{t} ", iBin[0],kPtbound[0], kPtbound[1], 1);
218 fMCQACollection->CreateTH1F(Form("phispectraLog_centrbin%i",centbin), "phi yields: MC p_{t} ", iBin[0],kPtbound[0], kPtbound[1], 1);
219 fMCQACollection->CreateTH1F(Form("etapspectraLog_centrbin%i",centbin), "etap yields: MC p_{t} ", iBin[0],kPtbound[0], kPtbound[1], 1);
220 fMCQACollection->CreateTH1F(Form("rhospectraLog_centrbin%i",centbin), "rho yields: MC p_{t} ", iBin[0],kPtbound[0], kPtbound[1], 1);
221 fMCQACollection->CreateTH1F(Form("kaonspectraLog_centrbin%i",centbin), "kaon yields: MC p_{t} ", iBin[0],kPtbound[0], kPtbound[1], 1);
222 fMCQACollection->CreateTH1F(Form("k0LspectraLog_centrbin%i",centbin), "k0L yields: MC p_{t} ", iBin[0],kPtbound[0], kPtbound[1], 1);
224 fMCQACollection->CreateTH1F(Form("piondaughters_centrbin%i",centbin), "pion yields: MC p_{t} ", iBin[0],kPtbound[0], kPtbound[1], 1);
225 fMCQACollection->CreateTH1F(Form("etadaughters_centrbin%i",centbin), "eta yields: MC p_{t} ", iBin[0],kPtbound[0], kPtbound[1], 1);
226 fMCQACollection->CreateTH1F(Form("omegadaughters_centrbin%i",centbin), "omega yields: MC p_{t} ", iBin[0],kPtbound[0], kPtbound[1], 1);
227 fMCQACollection->CreateTH1F(Form("phidaughters_centrbin%i",centbin), "phi yields: MC p_{t} ", iBin[0],kPtbound[0], kPtbound[1], 1);
228 fMCQACollection->CreateTH1F(Form("etapdaughters_centrbin%i",centbin), "etap yields: MC p_{t} ", iBin[0],kPtbound[0], kPtbound[1], 1);
229 fMCQACollection->CreateTH1F(Form("rhodaughters_centrbin%i",centbin), "rho yields: MC p_{t} ", iBin[0],kPtbound[0], kPtbound[1], 1);
232 fQAhistos->Add(fMCQACollection->GetList());
236 //__________________________________________
237 void AliHFEmcQA::CreateHistograms(const Int_t kquark, Int_t icut, TString hnopt)
241 if (!(kquark == kCharm || kquark == kBeauty || kquark == kOthers)) {
242 AliDebug(1, "This task is only for heavy quark QA, return\n");
245 Int_t iq = kquark - kCharm;
247 TString kqTypeLabel[fgkqType];
248 if (kquark == kCharm){
249 kqTypeLabel[kQuark]="c";
250 kqTypeLabel[kantiQuark]="cbar";
251 kqTypeLabel[kHadron]="cHadron";
252 kqTypeLabel[keHadron]="ceHadron";
253 kqTypeLabel[kDeHadron]="nullHadron";
254 kqTypeLabel[kElectron]="ce";
255 kqTypeLabel[kElectron2nd]="nulle";
256 } else if (kquark == kBeauty){
257 kqTypeLabel[kQuark]="b";
258 kqTypeLabel[kantiQuark]="bbar";
259 kqTypeLabel[kHadron]="bHadron";
260 kqTypeLabel[keHadron]="beHadron";
261 kqTypeLabel[kDeHadron]="bDeHadron";
262 kqTypeLabel[kElectron]="be";
263 kqTypeLabel[kElectron2nd]="bce";
264 } else if (kquark == kOthers){
265 kqTypeLabel[kGamma-4]="gammae";
266 kqTypeLabel[kPi0-4]="pi0e";
267 kqTypeLabel[kElse-4]="elsee";
268 kqTypeLabel[kMisID-4]="miside";
271 const Double_t kPtbound[2] = {0.1, 20.}; //bin taken for considering inclusive e analysis binning
273 iBin[0] = 44; // bins in pt
274 Double_t* binEdges[1];
275 binEdges[0] = AliHFEtools::MakeLogarithmicBinning(iBin[0], kPtbound[0], kPtbound[1]);
278 Double_t xcorrbin[501];
279 for (int icorrbin = 0; icorrbin< 501; icorrbin++){
280 xcorrbin[icorrbin]=icorrbin*0.1;
284 if(kquark == kOthers){
285 for (Int_t iqType = 0; iqType < 4; iqType++ ){
286 hname = hnopt+"Pt_"+kqTypeLabel[iqType];
287 //fHist[iq][iqType][icut].fPt = new TH1F(hname,hname+";p_{T} (GeV/c)",iBin[0],binEdges[0]); //mj to compare with FONLL
288 fHist[iq][iqType][icut].fPt = new TH1F(hname,hname+";p_{T} (GeV/c)",60,0.25,30.25);
289 hname = hnopt+"Y_"+kqTypeLabel[iqType];
290 fHist[iq][iqType][icut].fY = new TH1F(hname,hname,150,-7.5,7.5);
291 hname = hnopt+"Eta_"+kqTypeLabel[iqType];
292 fHist[iq][iqType][icut].fEta = new TH1F(hname,hname,150,-7.5,7.5);
294 if(fQAhistos) fHist[iq][iqType][icut].FillList(fQAhistos);
298 for (Int_t iqType = 0; iqType < fgkqType; iqType++ ){
299 if (iqType < keHadron && icut > 0) continue; // don't duplicate histogram for quark and hadron
300 hname = hnopt+"PdgCode_"+kqTypeLabel[iqType];
301 fHist[iq][iqType][icut].fPdgCode = new TH1F(hname,hname,20001,-10000.5,10000.5);
302 hname = hnopt+"Pt_"+kqTypeLabel[iqType];
303 fHist[iq][iqType][icut].fPt = new TH1F(hname,hname+";p_{T} (GeV/c)",iBin[0],binEdges[0]);
304 //fHist[iq][iqType][icut].fPt = new TH1F(hname,hname+";p_{T} (GeV/c)",60,0.,30.); // mj to compare with FONLL
305 //fHist[iq][iqType][icut].fPt = new TH1F(hname,hname+";p_{T} (GeV/c)",60,0.25,30.25); // mj to compare with FONLL
306 hname = hnopt+"Y_"+kqTypeLabel[iqType];
307 fHist[iq][iqType][icut].fY = new TH1F(hname,hname,150,-7.5,7.5);
308 hname = hnopt+"Eta_"+kqTypeLabel[iqType];
309 fHist[iq][iqType][icut].fEta = new TH1F(hname,hname,150,-7.5,7.5);
311 if(fQAhistos) fHist[iq][iqType][icut].FillList(fQAhistos);
315 hname = hnopt+"Nq_"+kqTypeLabel[kQuark];
316 fHistComm[iq][icut].fNq = new TH1F(hname,hname,50,-0.5,49.5);
317 hname = hnopt+"ProcessID_"+kqTypeLabel[kQuark];
318 fHistComm[iq][icut].fProcessID = new TH1F(hname,hname,21,-10.5,10.5);
320 hname = hnopt+"ePtRatio_"+kqTypeLabel[kQuark];
321 fHistComm[iq][icut].fePtRatio = new TH2F(hname,hname+";p_{T} (GeV/c);momentum fraction",200,0,20,100,0,1);
322 hname = hnopt+"PtCorr_"+kqTypeLabel[kQuark];
323 fHistComm[iq][icut].fPtCorr = new TH2F(hname,hname+";D p_{T} (GeV/c);e p_{T} (GeV/c)",500,xcorrbin,44,binEdges[0]);
324 //fHistComm[iq][icut].fPtCorr = new TH2F(hname,hname+";D p_{T} (GeV/c);e p_{T} (GeV/c)",200,0,20,200,0,20);
325 hname = hnopt+"PtCorrDp_"+kqTypeLabel[kQuark];
326 fHistComm[iq][icut].fPtCorrDp= new TH2F(hname,hname+";D p_{T} (GeV/c);e p_{T} (GeV/c)",500,xcorrbin,44,binEdges[0]);
327 //fHistComm[iq][icut].fPtCorrDp= new TH2F(hname,hname+";D p_{T} (GeV/c);e p_{T} (GeV/c)",200,0,20,200,0,20);
328 hname = hnopt+"PtCorrD0_"+kqTypeLabel[kQuark];
329 fHistComm[iq][icut].fPtCorrD0 = new TH2F(hname,hname+";D p_{T} (GeV/c);e p_{T} (GeV/c)",500,xcorrbin,44,binEdges[0]);
330 //fHistComm[iq][icut].fPtCorrD0 = new TH2F(hname,hname+";D p_{T} (GeV/c);e p_{T} (GeV/c)",200,0,20,200,0,20);
331 hname = hnopt+"PtCorrDrest_"+kqTypeLabel[kQuark];
332 fHistComm[iq][icut].fPtCorrDrest = new TH2F(hname,hname+";D p_{T} (GeV/c);e p_{T} (GeV/c)",500,xcorrbin,44,binEdges[0]);
333 //fHistComm[iq][icut].fPtCorrDrest = new TH2F(hname,hname+";D p_{T} (GeV/c);e p_{T} (GeV/c)",200,0,20,200,0,20);
334 hname = hnopt+"DePtRatio_"+kqTypeLabel[kQuark];
335 fHistComm[iq][icut].fDePtRatio = new TH2F(hname,hname+";p_{T} (GeV/c);momentum fraction",100,0,20,100,0,1);
336 hname = hnopt+"eDistance_"+kqTypeLabel[kQuark];
337 fHistComm[iq][icut].feDistance= new TH2F(hname,hname+";p_{T} (GeV/c);distance (cm)",100,0,20,200,0,2);
338 hname = hnopt+"DeDistance_"+kqTypeLabel[kQuark];
339 fHistComm[iq][icut].fDeDistance= new TH2F(hname,hname+";p_{T} (GeV/c);distance (cm)",100,0,20,200,0,2);
340 if(fQAhistos) fHistComm[iq][icut].FillList(fQAhistos);
343 //__________________________________________
344 void AliHFEmcQA::Init()
346 // called at begining every event
348 for (Int_t i=0; i<2; i++){
354 fParentSelect[0][0] = 411;
355 fParentSelect[0][1] = 421;
356 fParentSelect[0][2] = 431;
357 fParentSelect[0][3] = 4122;
358 fParentSelect[0][4] = 4132;
359 fParentSelect[0][5] = 4232;
360 fParentSelect[0][6] = 4332;
362 fParentSelect[1][0] = 511;
363 fParentSelect[1][1] = 521;
364 fParentSelect[1][2] = 531;
365 fParentSelect[1][3] = 5122;
366 fParentSelect[1][4] = 5132;
367 fParentSelect[1][5] = 5232;
368 fParentSelect[1][6] = 5332;
372 //__________________________________________
373 void AliHFEmcQA::GetMesonKine()
376 // get meson pt spectra
379 AliVParticle *mctrack2 = NULL;
380 AliMCParticle *mctrack0 = NULL;
381 AliVParticle *mctrackdaugt= NULL;
382 AliMCParticle *mctrackd= NULL;
386 if(fCentrality>11) printf("warning centrality out of histogram array limits \n");
389 for(Int_t imc = 0; imc <fMCEvent->GetNumberOfPrimaries(); imc++){
390 if(!(mctrack2 = fMCEvent->GetTrack(imc))) continue;
391 TParticle* mcpart0 = fMCEvent->Stack()->Particle(imc);
392 if(!mcpart0) continue;
393 mctrack0 = dynamic_cast<AliMCParticle *>(mctrack2);
394 if(!mctrack0) continue;
396 if(!fIsPbPb&&!fIsppMultiBin) fCentrality=0;
398 if(abs(mctrack0->PdgCode()) == 111) // pi0
400 if(TMath::Abs(AliHFEtools::GetRapidity(mcpart0))<0.8) {
401 fMCQACollection->Fill(Form("pionspectra_centrbin%i",fCentrality),mctrack0->Pt());
402 fMCQACollection->Fill(Form("pionspectraLog_centrbin%i",fCentrality),mctrack0->Pt());
404 id1=mctrack0->GetFirstDaughter();
405 id2=mctrack0->GetLastDaughter();
406 if(!((id2-id1)==2)) continue;
407 for(int idx=id1; idx<=id2; idx++){
408 if(!(mctrackdaugt = fMCEvent->GetTrack(idx))) continue;
409 if(!(mctrackd = dynamic_cast<AliMCParticle *>(mctrackdaugt))) continue;
410 if(abs(mctrackd->PdgCode()) == 11 && TMath::Abs(mctrackd->Eta())<0.8)
411 fMCQACollection->Fill(Form("piondaughters_centrbin%i",fCentrality),mctrackd->Pt());
414 else if(abs(mctrack0->PdgCode()) == 221) // eta
416 if(TMath::Abs(AliHFEtools::GetRapidity(mcpart0))<0.8) {
417 fMCQACollection->Fill(Form("etaspectra_centrbin%i",fCentrality),mctrack0->Pt());
418 fMCQACollection->Fill(Form("etaspectraLog_centrbin%i",fCentrality),mctrack0->Pt());
420 id1=mctrack0->GetFirstDaughter();
421 id2=mctrack0->GetLastDaughter();
422 if(!((id2-id1)==2||(id2-id1)==3)) continue;
423 for(int idx=id1; idx<=id2; idx++){
424 if(!(mctrackdaugt = fMCEvent->GetTrack(idx))) continue;
425 if(!(mctrackd = dynamic_cast<AliMCParticle *>(mctrackdaugt))) continue;
426 if(abs(mctrackd->PdgCode()) == 11 && TMath::Abs(mctrackd->Eta())<0.8)
427 fMCQACollection->Fill(Form("etadaughters_centrbin%i",fCentrality),mctrackd->Pt());
430 else if(abs(mctrack0->PdgCode()) == 223) // omega
432 if(TMath::Abs(AliHFEtools::GetRapidity(mcpart0))<0.8) {
433 fMCQACollection->Fill(Form("omegaspectra_centrbin%i",fCentrality),mctrack0->Pt());
434 fMCQACollection->Fill(Form("omegaspectraLog_centrbin%i",fCentrality),mctrack0->Pt());
436 id1=mctrack0->GetFirstDaughter();
437 id2=mctrack0->GetLastDaughter();
438 if(!((id2-id1)==1||(id2-id1)==2)) continue;
439 for(int idx=id1; idx<=id2; idx++){
440 if(!(mctrackdaugt = fMCEvent->GetTrack(idx))) continue;
441 if(!(mctrackd = dynamic_cast<AliMCParticle *>(mctrackdaugt))) continue;
442 if(abs(mctrackd->PdgCode()) == 11 && TMath::Abs(mctrackd->Eta())<0.8)
443 fMCQACollection->Fill(Form("omegadaughters_centrbin%i",fCentrality),mctrackd->Pt());
446 else if(abs(mctrack0->PdgCode()) == 333) // phi
448 if(TMath::Abs(AliHFEtools::GetRapidity(mcpart0))<0.8) {
449 fMCQACollection->Fill(Form("phispectra_centrbin%i",fCentrality),mctrack0->Pt());
450 fMCQACollection->Fill(Form("phispectraLog_centrbin%i",fCentrality),mctrack0->Pt());
452 id1=mctrack0->GetFirstDaughter();
453 id2=mctrack0->GetLastDaughter();
454 if(!((id2-id1)==1)) continue;
455 for(int idx=id1; idx<=id2; idx++){
456 if(!(mctrackdaugt = fMCEvent->GetTrack(idx))) continue;
457 if(!(mctrackd = dynamic_cast<AliMCParticle *>(mctrackdaugt))) continue;
458 if(abs(mctrackd->PdgCode()) == 11 && TMath::Abs(mctrackd->Eta())<0.8)
459 fMCQACollection->Fill(Form("phidaughters_centrbin%i",fCentrality),mctrackd->Pt());
462 else if(abs(mctrack0->PdgCode()) == 331) // eta prime
464 if(TMath::Abs(AliHFEtools::GetRapidity(mcpart0))<0.8) {
465 fMCQACollection->Fill(Form("etapspectra_centrbin%i",fCentrality),mctrack0->Pt());
466 fMCQACollection->Fill(Form("etapspectraLog_centrbin%i",fCentrality),mctrack0->Pt());
468 id1=mctrack0->GetFirstDaughter();
469 id2=mctrack0->GetLastDaughter();
470 if(!((id2-id1)==2||(id2-id1)==3)) continue;
471 for(int idx=id1; idx<=id2; idx++){
472 if(!(mctrackdaugt = fMCEvent->GetTrack(idx))) continue;
473 if(!(mctrackd = dynamic_cast<AliMCParticle *>(mctrackdaugt))) continue;
474 if(abs(mctrackd->PdgCode()) == 11 && TMath::Abs(mctrackd->Eta())<0.8)
475 fMCQACollection->Fill(Form("etapdaughters_centrbin%i",fCentrality),mctrackd->Pt());
478 else if(abs(mctrack0->PdgCode()) == 113) // rho
480 if(TMath::Abs(AliHFEtools::GetRapidity(mcpart0))<0.8) {
481 fMCQACollection->Fill(Form("rhospectra_centrbin%i",fCentrality),mctrack0->Pt());
482 fMCQACollection->Fill(Form("rhospectraLog_centrbin%i",fCentrality),mctrack0->Pt());
484 id1=mctrack0->GetFirstDaughter();
485 id2=mctrack0->GetLastDaughter();
486 if(!((id2-id1)==1)) continue;
487 for(int idx=id1; idx<=id2; idx++){
488 if(!(mctrackdaugt = fMCEvent->GetTrack(idx))) continue;
489 if(!(mctrackd = dynamic_cast<AliMCParticle *>(mctrackdaugt))) continue;
490 if(abs(mctrackd->PdgCode()) == 11 && TMath::Abs(mctrackd->Eta())<0.8)
491 fMCQACollection->Fill(Form("rhodaughters_centrbin%i",fCentrality),mctrackd->Pt());
494 else if(abs(mctrack0->PdgCode()) == 321) // kaon+-
496 if(TMath::Abs(AliHFEtools::GetRapidity(mcpart0))<0.8) {
497 fMCQACollection->Fill(Form("kaonspectraLog_centrbin%i",fCentrality),mctrack0->Pt());
500 else if(abs(mctrack0->PdgCode()) == 130) // k0L
502 if(TMath::Abs(AliHFEtools::GetRapidity(mcpart0))<0.8) {
503 fMCQACollection->Fill(Form("k0LspectraLog_centrbin%i",fCentrality),mctrack0->Pt());
509 //__________________________________________
510 void AliHFEmcQA::GetQuarkKine(TParticle *part, Int_t iTrack, const Int_t kquark)
512 // get heavy quark kinematics
514 if (kquark != kCharm && kquark != kBeauty) {
515 AliDebug(1, "This task is only for heavy quark QA, return\n");
518 Int_t iq = kquark - kCharm;
520 if (iTrack < 0 || !part) {
521 AliDebug(1, "Stack label is negative or no mcparticle, return\n");
525 AliMCParticle *mctrack = NULL;
526 Int_t partPdgcode = TMath::Abs(part->GetPdgCode());
528 // select heavy hadron or not fragmented heavy quark
529 if ( int(partPdgcode/100.)==kquark || int(partPdgcode/1000.)==kquark || (partPdgcode==kquark && (part->GetNDaughters()==0 && iTrack>5)) ){
531 TParticle *partMother;
534 if (partPdgcode == kquark){ // in case of not fragmented heavy quark
537 } else{ // in case of heavy hadron, start to search for mother heavy parton
538 iLabel = part->GetFirstMother();
539 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(iLabel))))) return;
540 if (iLabel>-1) { partMother = mctrack->Particle(); }
542 AliDebug(1, "Stack label is negative, return\n");
547 // heavy parton selection as a mother of heavy hadron
548 // if the heavy particle comes from string which is denoted as particle status 12|12|12...12|11,[PYTHIA p.60]
549 // in this case, the mother of heavy particle can be one of the fragmented parton of the string
550 // should I make a condition that partMother should be quark or diquark? -> not necessary
551 if ( abs(partMother->GetPdgCode()) == kquark || (partMother->GetStatusCode() == 11) ){
552 //if ( abs(partMother->GetPdgCode()) == kquark || (partMother->GetStatusCode() == 11 || partMother->GetStatusCode() == 12) ){
554 if ( abs(partMother->GetPdgCode()) != kquark ){
555 // search fragmented partons in the same string
556 Bool_t isSameString = kTRUE;
557 for (Int_t i=1; i<fgkMaxIter; i++){
559 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(iLabel))))) return;
560 if (iLabel>-1) { partMother = mctrack->Particle(); }
562 AliDebug(1, "Stack label is negative, return\n");
565 if ( abs(partMother->GetPdgCode()) == kquark ) break;
566 if ( partMother->GetStatusCode() != 12 ) isSameString = kFALSE;
567 if (!isSameString) return;
570 AliDebug(1, "Can not find heavy parton of this heavy hadron in the string, return\n");
571 if (abs(partMother->GetPdgCode()) != kquark) return;
573 if (fIsHeavy[iq] >= 50) return;
574 fHeavyQuark[fIsHeavy[iq]] = partMother;
577 // fill kinematics for heavy parton
578 if (partMother->GetPdgCode() > 0) { // quark
579 fHist[iq][kQuark][0].fPdgCode->Fill(partMother->GetPdgCode());
580 fHist[iq][kQuark][0].fPt->Fill(partMother->Pt());
581 fHist[iq][kQuark][0].fY->Fill(AliHFEtools::GetRapidity(partMother));
582 fHist[iq][kQuark][0].fEta->Fill(partMother->Eta());
584 fHist[iq][kantiQuark][0].fPdgCode->Fill(partMother->GetPdgCode());
585 fHist[iq][kantiQuark][0].fPt->Fill(partMother->Pt());
586 fHist[iq][kantiQuark][0].fY->Fill(AliHFEtools::GetRapidity(partMother));
587 fHist[iq][kantiQuark][0].fEta->Fill(partMother->Eta());
590 } // end of heavy parton slection loop
592 } // end of heavy hadron or quark selection
596 //__________________________________________
597 void AliHFEmcQA::EndOfEventAna(const Int_t kquark)
599 // end of event analysis
601 if (kquark != kCharm && kquark != kBeauty) {
602 AliDebug(1, "This task is only for heavy quark QA, return\n");
605 Int_t iq = kquark - kCharm;
608 // # of heavy quark per event
609 AliDebug(1,Form("Number of heavy quark in this event = %d \n",fIsHeavy[iq]));
610 fHistComm[iq][0].fNq->Fill(fIsHeavy[iq]);
612 Int_t motherID[fgkMaxGener];
613 Int_t motherType[fgkMaxGener];
614 Int_t motherLabel[fgkMaxGener];
615 Int_t ancestorPdg[fgkMaxGener];
616 Int_t ancestorLabel[fgkMaxGener];
618 for (Int_t i = 0; i < fgkMaxGener; i++){ // initialization
623 ancestorLabel[i] = 0;
627 // check history of found heavy quarks
628 for (Int_t i = 0; i < fIsHeavy[iq]; i++){
630 if(!fHeavyQuark[i]) return;
632 ancestorLabel[0] = i;
633 ancestorPdg[0] = fHeavyQuark[i]->GetPdgCode();
634 ancestorLabel[1] = fHeavyQuark[i]->GetFirstMother();
636 AliDebug(1,Form("pdg code= %d\n",ancestorPdg[0]));
637 AliDebug(1,Form("ancestor label= %d\n",ancestorLabel[1]));
640 while (ancestorLabel[ig] != -1){
641 // in case there is mother, get mother's pdg code and grandmother's label
642 IdentifyMother(ancestorLabel[ig], ancestorPdg[ig], ancestorLabel[ig+1]);
643 // if mother is still heavy, find again mother's ancestor
644 if (ancestorPdg[ig-1] == ancestorPdg[ig]) {
646 continue; // if it is from same heavy
648 // if the heavy's mother is not heavy, check the mother's label to know if it comes from inital or final parton shower
649 if (IsFromInitialShower(ancestorLabel[ig],motherID[i],motherType[i],motherLabel[i])) break;
650 if (IsFromFinalParton(ancestorLabel[ig],motherID[i],motherType[i],motherLabel[i])) break;
651 // if it is not the above case, something is strange
652 ReportStrangeness(motherID[i],motherType[i],motherLabel[i]);
655 if (ancestorLabel[ig] == -1){ // from hard scattering
656 HardScattering(kquark, motherID[i],motherType[i], motherLabel[i]);
659 } // end of found heavy quark loop
662 // check process type
664 for (Int_t i = 0; i < fIsHeavy[iq]; i++){
665 AliDebug(1,Form("Mother ID= %d type= %d label= %d\n",motherID[i],motherType[i],motherLabel[i]));
669 Int_t nheavypair = Int_t(fIsHeavy[iq]/2.);
670 for (Int_t ipair = 0; ipair < nheavypair; ipair++){
673 Int_t id2 = ipair*2 + 1;
675 if (motherType[id1] == 2 && motherType[id2] == 2){
676 if (motherLabel[id1] == motherLabel[id2]) processID = kGluonSplitting; // gluon spliting
679 else if (motherType[id1] == -1 && motherType[id2] == -1) {
680 if (motherLabel[id1] == -1 && motherLabel[id2] == -1) {
681 if (motherID[id1] == fgkGluon) processID = kPairCreationFromg; // gluon fusion
682 else processID = kPairCreationFromq; // q-qbar pair creation
686 else if (motherType[id1] == -1 || motherType[id2] == -1) {
687 if ((motherLabel[id1] == -1 || motherLabel[id2] == -1) && (motherLabel[id1]*motherLabel[id2] == -2 || motherLabel[id1]*motherLabel[id2] == -3)) {
688 if(motherID[id1]*motherID[id2] == kquark*fgkGluon) processID = kFlavourExitation; // flavour exitation
689 else processID = kLightQuarkShower;
693 else if (motherType[id1] == -2 || motherType[id2] == -2) {
694 if (motherLabel[id1] == motherLabel[id2]) processID = kInitialPartonShower; // initial parton shower
700 if (nheavypair >1) AliDebug(1,Form("Multi pair found : process ID = %d\n",processID));
701 else fHistComm[iq][0].fProcessID->Fill(processID);
702 AliDebug(1,Form("Process ID = %d\n",processID));
703 } // end of # heavy quark pair loop
707 //__________________________________________
708 void AliHFEmcQA::GetHadronKine(TParticle* mcpart, const Int_t kquark)
710 // decay electron kinematics
712 if (kquark != kCharm && kquark != kBeauty) {
713 AliDebug(1, "This task is only for heavy quark QA, return\n");
716 Int_t iq = kquark - kCharm;
719 AliDebug(1, "no mc particle, return\n");
723 Int_t iLabel = mcpart->GetFirstMother();
725 AliDebug(1, "Stack label is negative, return\n");
729 TParticle *partCopy = mcpart;
730 Int_t pdgcode = mcpart->GetPdgCode();
731 Int_t pdgcodeCopy = pdgcode;
733 AliMCParticle *mctrack = NULL;
735 // if the mother is charmed hadron
736 Bool_t isDirectCharm = kFALSE;
737 if ( int(abs(pdgcode)/100.) == kCharm || int(abs(pdgcode)/1000.) == kCharm ) {
739 // iterate until you find B hadron as a mother or become top ancester
740 for (Int_t i=1; i<fgkMaxIter; i++){
742 Int_t jLabel = mcpart->GetFirstMother();
744 isDirectCharm = kTRUE;
745 break; // if there is no ancester
747 if (jLabel < 0){ // safety protection
748 AliDebug(1, "Stack label is negative, return\n");
751 // if there is an ancester
752 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(jLabel))))) return;
753 TParticle* mother = mctrack->Particle();
754 Int_t motherPDG = mother->GetPdgCode();
756 for (Int_t j=0; j<fNparents; j++){
757 if (abs(motherPDG)==fParentSelect[1][j]) return; // return if this hadron is originated from b
761 } // end of iteration
763 if((isDirectCharm == kTRUE && kquark == kCharm) || kquark == kBeauty) {
764 for (Int_t i=0; i<fNparents; i++){
765 if (abs(pdgcodeCopy)==fParentSelect[iq][i]){
767 // fill hadron kinematics
768 fHist[iq][kHadron][0].fPdgCode->Fill(pdgcodeCopy);
769 fHist[iq][kHadron][0].fPt->Fill(partCopy->Pt());
770 fHist[iq][kHadron][0].fY->Fill(AliHFEtools::GetRapidity(partCopy));
771 fHist[iq][kHadron][0].fEta->Fill(partCopy->Eta());
774 fhD[i]->Fill(partCopy->Pt(),AliHFEtools::GetRapidity(partCopy));
775 if(TMath::Abs(AliHFEtools::GetRapidity(partCopy))<0.5) fhDLogbin[i]->Fill(partCopy->Pt());
779 // I also want to store D* info to compare with D* measurement
780 if (abs(pdgcodeCopy)==413 && iq==0) { //D*+
781 fhD[7]->Fill(partCopy->Pt(),AliHFEtools::GetRapidity(partCopy));
782 if(TMath::Abs(AliHFEtools::GetRapidity(partCopy))<0.5) fhDLogbin[7]->Fill(partCopy->Pt());
784 if (abs(pdgcodeCopy)==423 && iq==0) { //D*0
785 fhD[8]->Fill(partCopy->Pt(),AliHFEtools::GetRapidity(partCopy));
786 if(TMath::Abs(AliHFEtools::GetRapidity(partCopy))<0.5) fhDLogbin[8]->Fill(partCopy->Pt());
791 //__________________________________________
792 void AliHFEmcQA::GetDecayedKine(TParticle* mcpart, const Int_t kquark, Int_t kdecayed, Int_t icut)
794 // decay electron kinematics
796 if (!(kquark == kCharm || kquark == kBeauty || kquark == kOthers)){
797 AliDebug(1, "This task is only for heavy quark QA, return\n");
800 Int_t iq = kquark - kCharm;
801 Bool_t isFinalOpenCharm = kFALSE;
804 AliDebug(1, "no mcparticle, return\n");
810 if ( abs(mcpart->GetPdgCode()) != kdecayed ) esource = kMisID-4;
811 else esource =GetSource(mcpart)-4; // return for the cases kGamma=4, kPi0=5, kElse=6
812 if(esource==0|| esource==1 || esource==2 || esource==3){
813 fHist[iq][esource][icut].fPt->Fill(mcpart->Pt());
814 fHist[iq][esource][icut].fY->Fill(AliHFEtools::GetRapidity(mcpart));
815 fHist[iq][esource][icut].fEta->Fill(mcpart->Eta());
819 AliDebug(1, "e source is out of defined ranges, return\n");
824 if ( abs(mcpart->GetPdgCode()) != kdecayed ) return;
826 Int_t iLabel = mcpart->GetFirstMother();
828 AliDebug(1, "Stack label is negative, return\n");
832 AliMCParticle *mctrack = NULL;
833 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(iLabel))))) return;
834 TParticle *partMother = mctrack->Particle();
835 TParticle *partMotherCopy = partMother;
836 Int_t maPdgcode = partMother->GetPdgCode();
837 Int_t maPdgcodeCopy = maPdgcode;
839 // get mc primary vertex
842 if(fMCHeader) fMCHeader->PrimaryVertex(mcPrimVtx);
844 // get electron production vertex
845 TLorentzVector ePoint;
846 mcpart->ProductionVertex(ePoint);
848 // calculated production vertex to primary vertex (in xy plane)
849 Float_t decayLxy = TMath::Sqrt((mcPrimVtx[0]-ePoint[0])*(mcPrimVtx[0]-ePoint[0])+(mcPrimVtx[1]-ePoint[1])*(mcPrimVtx[1]-ePoint[1]));
851 Float_t decayLxy = 0;
853 // if the mother is charmed hadron
854 Bool_t isMotherDirectCharm = kFALSE;
855 if ( int(abs(maPdgcode)/100.) == kCharm || int(abs(maPdgcode)/1000.) == kCharm ) {
857 for (Int_t i=0; i<fNparents; i++){
858 if (abs(maPdgcode)==fParentSelect[0][i]){
859 isFinalOpenCharm = kTRUE;
862 if (!isFinalOpenCharm) return ;
864 // iterate until you find B hadron as a mother or become top ancester
865 for (Int_t i=1; i<fgkMaxIter; i++){
867 Int_t jLabel = partMother->GetFirstMother();
869 isMotherDirectCharm = kTRUE;
870 break; // if there is no ancester
872 if (jLabel < 0){ // safety protection
873 AliDebug(1, "Stack label is negative, return\n");
877 // if there is an ancester
878 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(jLabel))))) return;
879 TParticle* grandMa = mctrack->Particle();
880 Int_t grandMaPDG = grandMa->GetPdgCode();
882 for (Int_t j=0; j<fNparents; j++){
883 if (abs(grandMaPDG)==fParentSelect[1][j]){
885 if (kquark == kCharm) return;
886 // fill electron kinematics
887 fHist[iq][kElectron2nd][icut].fPdgCode->Fill(mcpart->GetPdgCode());
888 fHist[iq][kElectron2nd][icut].fPt->Fill(mcpart->Pt());
889 fHist[iq][kElectron2nd][icut].fY->Fill(AliHFEtools::GetRapidity(mcpart));
890 fHist[iq][kElectron2nd][icut].fEta->Fill(mcpart->Eta());
892 // fill mother hadron kinematics
893 fHist[iq][kDeHadron][icut].fPdgCode->Fill(grandMaPDG);
894 fHist[iq][kDeHadron][icut].fPt->Fill(grandMa->Pt());
895 fHist[iq][kDeHadron][icut].fY->Fill(AliHFEtools::GetRapidity(grandMa));
896 fHist[iq][kDeHadron][icut].fEta->Fill(grandMa->Eta());
898 // ratio between pT of electron and pT of mother B hadron
899 if(grandMa->Pt()) fHistComm[iq][icut].fDePtRatio->Fill(grandMa->Pt(),mcpart->Pt()/grandMa->Pt());
901 // distance between electron production point and primary vertex
902 fHistComm[iq][icut].fDeDistance->Fill(grandMa->Pt(),decayLxy);
907 partMother = grandMa;
908 } // end of iteration
910 if((isMotherDirectCharm == kTRUE && kquark == kCharm) || kquark == kBeauty) {
911 for (Int_t i=0; i<fNparents; i++){
912 if (abs(maPdgcodeCopy)==fParentSelect[iq][i]){
914 //mj weighting to consider measured spectra!!!
915 Double_t mpt=partMotherCopy->Pt();
916 Double_t wfactor=2*(703.681*mpt/TMath::Power((1+TMath::Power(mpt/1.73926,2)),2.34821))/(368.608*mpt/TMath::Power((1+TMath::Power(mpt/2.74868,2)),2.34225)); // 2* considering in pythia I used particle + antiparticle differently from the measurement
917 //Double_t wfactor=(703.681*mpt/TMath::Power((1+TMath::Power(mpt/1.73926,2)),2.34821))/(368.608*mpt/TMath::Power((1+TMath::Power(mpt/2.74868,2)),2.34225));
918 // fill electron kinematics
920 fHist[iq][kElectron2nd][icut].fPdgCode->Fill(mcpart->GetPdgCode(),wfactor);
921 fHist[iq][kElectron2nd][icut].fPt->Fill(mcpart->Pt(),wfactor);
922 fHist[iq][kElectron2nd][icut].fY->Fill(AliHFEtools::GetRapidity(mcpart),wfactor);
923 fHist[iq][kElectron2nd][icut].fEta->Fill(mcpart->Eta(),wfactor);
925 fHist[iq][kElectron][icut].fPdgCode->Fill(mcpart->GetPdgCode());
926 fHist[iq][kElectron][icut].fPt->Fill(mcpart->Pt());
927 fHist[iq][kElectron][icut].fY->Fill(AliHFEtools::GetRapidity(mcpart));
928 fHist[iq][kElectron][icut].fEta->Fill(mcpart->Eta());
931 fHist[iq][kElectron][icut].fPdgCode->Fill(mcpart->GetPdgCode());
932 fHist[iq][kElectron][icut].fPt->Fill(mcpart->Pt());
933 fHist[iq][kElectron][icut].fY->Fill(AliHFEtools::GetRapidity(mcpart));
934 fHist[iq][kElectron][icut].fEta->Fill(mcpart->Eta());
937 // fill mother hadron kinematics
938 fHist[iq][keHadron][icut].fPdgCode->Fill(maPdgcodeCopy);
939 fHist[iq][keHadron][icut].fPt->Fill(partMotherCopy->Pt());
940 fHist[iq][keHadron][icut].fY->Fill(AliHFEtools::GetRapidity(partMotherCopy));
941 fHist[iq][keHadron][icut].fEta->Fill(partMotherCopy->Eta());
943 // ratio between pT of electron and pT of mother B or direct D hadron
944 if(partMotherCopy->Pt()) fHistComm[iq][icut].fePtRatio->Fill(partMotherCopy->Pt(),mcpart->Pt()/partMotherCopy->Pt());
945 fHistComm[iq][icut].fPtCorr->Fill(partMotherCopy->Pt(),mcpart->Pt());
946 if(TMath::Abs(partMotherCopy->GetPdgCode())==411) fHistComm[iq][icut].fPtCorrDp->Fill(partMotherCopy->Pt(),mcpart->Pt());
947 else if(TMath::Abs(partMotherCopy->GetPdgCode())==421) fHistComm[iq][icut].fPtCorrD0->Fill(partMotherCopy->Pt(),mcpart->Pt());
948 else fHistComm[iq][icut].fPtCorrDrest->Fill(partMotherCopy->Pt(),mcpart->Pt());
950 // distance between electron production point and primary vertex
951 fHistComm[iq][icut].feDistance->Fill(partMotherCopy->Pt(),decayLxy);
957 //____________________________________________________________________
958 void AliHFEmcQA::GetDecayedKine(AliAODMCParticle *mcpart, const Int_t kquark, Int_t kdecayed, Int_t icut)
960 // decay electron kinematics
962 if (kquark != kCharm && kquark != kBeauty) {
963 AliDebug(1, "This task is only for heavy quark QA, return\n");
967 Int_t iq = kquark - kCharm;
968 Bool_t isFinalOpenCharm = kFALSE;
971 AliDebug(1, "no mcparticle, return\n");
975 if ( abs(mcpart->GetPdgCode()) != kdecayed ) return;
978 Int_t iLabel = mcpart->GetMother();
980 AliDebug(1, "Stack label is negative, return\n");
984 AliAODMCParticle *partMother = (AliAODMCParticle*)fMCArray->At(iLabel);
985 AliAODMCParticle *partMotherCopy = partMother;
986 Int_t maPdgcode = partMother->GetPdgCode();
987 Int_t maPdgcodeCopy = maPdgcode;
989 Bool_t isMotherDirectCharm = kFALSE;
990 if ( int(abs(maPdgcode)/100.) == kCharm || int(abs(maPdgcode)/1000.) == kCharm ) {
992 for (Int_t i=0; i<fNparents; i++){
993 if (abs(maPdgcode)==fParentSelect[0][i]){
994 isFinalOpenCharm = kTRUE;
997 if (!isFinalOpenCharm) return;
999 for (Int_t i=1; i<fgkMaxIter; i++){
1001 Int_t jLabel = partMother->GetMother();
1003 isMotherDirectCharm = kTRUE;
1004 break; // if there is no ancester
1006 if (jLabel < 0){ // safety protection
1007 AliDebug(1, "Stack label is negative, return\n");
1011 // if there is an ancester
1012 AliAODMCParticle* grandMa = (AliAODMCParticle*)fMCArray->At(jLabel);
1013 Int_t grandMaPDG = grandMa->GetPdgCode();
1015 for (Int_t j=0; j<fNparents; j++){
1016 if (abs(grandMaPDG)==fParentSelect[1][j]){
1018 if (kquark == kCharm) return;
1019 // fill electron kinematics
1020 fHist[iq][kElectron2nd][icut].fPdgCode->Fill(mcpart->GetPdgCode());
1021 fHist[iq][kElectron2nd][icut].fPt->Fill(mcpart->Pt());
1022 fHist[iq][kElectron2nd][icut].fY->Fill(AliHFEtools::GetRapidity(mcpart));
1023 fHist[iq][kElectron2nd][icut].fEta->Fill(mcpart->Eta());
1025 // fill mother hadron kinematics
1026 fHist[iq][kDeHadron][icut].fPdgCode->Fill(grandMaPDG);
1027 fHist[iq][kDeHadron][icut].fPt->Fill(grandMa->Pt());
1028 fHist[iq][kDeHadron][icut].fY->Fill(AliHFEtools::GetRapidity(grandMa));
1029 fHist[iq][kDeHadron][icut].fEta->Fill(grandMa->Eta());
1035 partMother = grandMa;
1036 } // end of iteration
1038 if ((isMotherDirectCharm == kTRUE && kquark == kCharm) || kquark == kBeauty) {
1039 for (Int_t i=0; i<fNparents; i++){
1040 if (abs(maPdgcodeCopy)==fParentSelect[iq][i]){
1042 // fill electron kinematics
1043 fHist[iq][kElectron][icut].fPdgCode->Fill(mcpart->GetPdgCode());
1044 fHist[iq][kElectron][icut].fPt->Fill(mcpart->Pt());
1045 fHist[iq][kElectron][icut].fY->Fill(AliHFEtools::GetRapidity(mcpart));
1046 fHist[iq][kElectron][icut].fEta->Fill(mcpart->Eta());
1048 // fill mother hadron kinematics
1049 fHist[iq][keHadron][icut].fPdgCode->Fill(maPdgcodeCopy);
1050 fHist[iq][keHadron][icut].fPt->Fill(partMotherCopy->Pt());
1051 fHist[iq][keHadron][icut].fY->Fill(AliHFEtools::GetRapidity(partMotherCopy));
1052 fHist[iq][keHadron][icut].fEta->Fill(partMotherCopy->Eta());
1060 //__________________________________________
1061 void AliHFEmcQA::IdentifyMother(Int_t motherlabel, Int_t &motherpdg, Int_t &grandmotherlabel)
1063 // find mother pdg code and label
1065 if (motherlabel < 0) {
1066 AliDebug(1, "Stack label is negative, return\n");
1069 AliMCParticle *mctrack = NULL;
1070 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(motherlabel))))) return;
1071 TParticle *heavysMother = mctrack->Particle();
1072 motherpdg = heavysMother->GetPdgCode();
1073 grandmotherlabel = heavysMother->GetFirstMother();
1074 AliDebug(1,Form("ancestor pdg code= %d\n",motherpdg));
1077 //__________________________________________
1078 void AliHFEmcQA::HardScattering(const Int_t kquark, Int_t &motherID, Int_t &mothertype, Int_t &motherlabel)
1080 // mothertype -1 means this heavy quark coming from hard vertex
1082 AliMCParticle *mctrack1 = NULL;
1083 AliMCParticle *mctrack2 = NULL;
1084 if(!(mctrack1 = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(4))))) return;
1085 if(!(mctrack2 = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(5))))) return;
1086 TParticle *afterinitialrad1 = mctrack1->Particle();
1087 TParticle *afterinitialrad2 = mctrack2->Particle();
1091 if (abs(afterinitialrad1->GetPdgCode()) == fgkGluon && abs(afterinitialrad2->GetPdgCode()) == fgkGluon){
1092 AliDebug(1,"heavy from gluon gluon pair creation!\n");
1094 motherID = fgkGluon;
1096 else if (abs(afterinitialrad1->GetPdgCode()) == kquark || abs(afterinitialrad2->GetPdgCode()) == kquark){ // one from Q and the other from g
1097 AliDebug(1,"heavy from flavor exitation!\n");
1101 else if (abs(afterinitialrad1->GetPdgCode()) == abs(afterinitialrad2->GetPdgCode())){
1102 AliDebug(1,"heavy from q-qbar pair creation!\n");
1107 AliDebug(1,"something strange!\n");
1114 //__________________________________________
1115 Bool_t AliHFEmcQA::IsFromInitialShower(Int_t inputmotherlabel, Int_t &motherID, Int_t &mothertype, Int_t &motherlabel)
1117 // mothertype -2 means this heavy quark coming from initial state
1119 AliMCParticle *mctrack = NULL;
1120 if (inputmotherlabel==2 || inputmotherlabel==3){ // mother exist before initial state radiation
1121 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(inputmotherlabel))))) return kFALSE;
1122 TParticle *heavysMother = mctrack->Particle();
1123 motherID = heavysMother->GetPdgCode();
1124 mothertype = -2; // there is mother before initial state radiation
1125 motherlabel = inputmotherlabel;
1126 AliDebug(1,"initial parton shower! \n");
1134 //__________________________________________
1135 Bool_t AliHFEmcQA::IsFromFinalParton(Int_t inputmotherlabel, Int_t &motherID, Int_t &mothertype, Int_t &motherlabel)
1137 // mothertype 2 means this heavy quark coming from final state
1139 AliMCParticle *mctrack = NULL;
1140 if (inputmotherlabel > 5){ // mother exist after hard scattering
1141 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(inputmotherlabel))))) return kFALSE;
1142 TParticle *heavysMother = mctrack->Particle();
1143 motherID = heavysMother->GetPdgCode();
1145 motherlabel = inputmotherlabel;
1146 AliDebug(1,Form("heavy quark from %d after hard scattering! \n",motherID));
1153 //__________________________________________
1154 void AliHFEmcQA::ReportStrangeness(Int_t &motherID, Int_t &mothertype, Int_t &motherlabel)
1156 // mark strange behavior
1161 AliDebug(1,"something strange!\n");
1164 //__________________________________________
1165 Int_t AliHFEmcQA::GetSource(const AliAODMCParticle * const mcpart)
1167 // decay particle's origin
1169 //if ( abs(mcpart->GetPdgCode()) != AliHFEmcQA::kElectronPDG ) return -1;
1172 Bool_t isFinalOpenCharm = kFALSE;
1175 AliDebug(1, "Stack label is negative or no mcparticle, return\n");
1180 Int_t iLabel = mcpart->GetMother();
1182 AliDebug(1, "Stack label is negative, return\n");
1186 AliAODMCParticle *partMother = (AliAODMCParticle*)fMCArray->At(iLabel);
1187 Int_t maPdgcode = partMother->GetPdgCode();
1189 // if the mother is charmed hadron
1190 if ( int(abs(maPdgcode)/100.) == kCharm || int(abs(maPdgcode)/1000.) == kCharm ) {
1192 for (Int_t i=0; i<fNparents; i++){
1193 if (abs(maPdgcode)==fParentSelect[0][i]){
1194 isFinalOpenCharm = kTRUE;
1197 if (!isFinalOpenCharm) return -1;
1199 // iterate until you find B hadron as a mother or become top ancester
1200 for (Int_t i=1; i<fgkMaxIter; i++){
1202 Int_t jLabel = partMother->GetMother();
1204 origin = kDirectCharm;
1207 if (jLabel < 0){ // safety protection
1208 AliDebug(1, "Stack label is negative, return\n");
1212 // if there is an ancester
1213 AliAODMCParticle* grandMa = (AliAODMCParticle*)fMCArray->At(jLabel);
1214 Int_t grandMaPDG = grandMa->GetPdgCode();
1216 for (Int_t j=0; j<fNparents; j++){
1217 if (abs(grandMaPDG)==fParentSelect[1][j]){
1218 origin = kBeautyCharm;
1223 partMother = grandMa;
1224 } // end of iteration
1226 else if ( int(abs(maPdgcode)/100.) == kBeauty || int(abs(maPdgcode)/1000.) == kBeauty ) {
1227 for (Int_t i=0; i<fNparents; i++){
1228 if (abs(maPdgcode)==fParentSelect[1][i]){
1229 origin = kDirectBeauty;
1234 else if ( abs(maPdgcode) == 22 ) {
1238 else if ( abs(maPdgcode) == 111 ) {
1246 //__________________________________________
1247 Int_t AliHFEmcQA::GetSource(const TParticle * const mcpart)
1249 // decay particle's origin
1251 //if ( abs(mcpart->GetPdgCode()) != AliHFEmcQA::kElectronPDG ) return -1;
1254 Bool_t isFinalOpenCharm = kFALSE;
1257 AliDebug(1, "no mcparticle, return\n");
1261 Int_t iLabel = mcpart->GetFirstMother();
1263 AliDebug(1, "Stack label is negative, return\n");
1267 AliMCParticle *mctrack = NULL;
1268 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(iLabel))))) return -1;
1269 TParticle *partMother = mctrack->Particle();
1270 Int_t maPdgcode = partMother->GetPdgCode();
1272 // if the mother is charmed hadron
1273 if ( int(abs(maPdgcode)/100.) == kCharm || int(abs(maPdgcode)/1000.) == kCharm ) {
1275 for (Int_t i=0; i<fNparents; i++){
1276 if (abs(maPdgcode)==fParentSelect[0][i]){
1277 isFinalOpenCharm = kTRUE;
1280 if (!isFinalOpenCharm) return -1;
1282 // iterate until you find B hadron as a mother or become top ancester
1283 for (Int_t i=1; i<fgkMaxIter; i++){
1285 Int_t jLabel = partMother->GetFirstMother();
1287 origin = kDirectCharm;
1290 if (jLabel < 0){ // safety protection
1291 AliDebug(1, "Stack label is negative, return\n");
1295 // if there is an ancester
1296 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(jLabel))))) return -1;
1297 TParticle* grandMa = mctrack->Particle();
1298 Int_t grandMaPDG = grandMa->GetPdgCode();
1300 for (Int_t j=0; j<fNparents; j++){
1301 if (abs(grandMaPDG)==fParentSelect[1][j]){
1302 origin = kBeautyCharm;
1307 partMother = grandMa;
1308 } // end of iteration
1310 else if ( int(abs(maPdgcode)/100.) == kBeauty || int(abs(maPdgcode)/1000.) == kBeauty ) {
1311 for (Int_t i=0; i<fNparents; i++){
1312 if (abs(maPdgcode)==fParentSelect[1][i]){
1313 origin = kDirectBeauty;
1318 else if ( abs(maPdgcode) == 22 ) {
1322 else if ( abs(maPdgcode) == 111 ) {
1326 else origin = kElse;
1331 //__________________________________________
1332 Int_t AliHFEmcQA::GetElecSource(TParticle * const mcpart)
1334 // decay particle's origin
1337 AliDebug(1, "no mcparticle, return\n");
1341 if ( abs(mcpart->GetPdgCode()) != AliHFEmcQA::kElectronPDG ) return kMisID;
1344 Bool_t isFinalOpenCharm = kFALSE;
1346 Int_t iLabel = mcpart->GetFirstMother();
1348 AliDebug(1, "Stack label is negative, return\n");
1352 AliMCParticle *mctrack = NULL;
1353 Int_t tmpMomLabel=0;
1354 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(iLabel))))) return -1;
1355 TParticle *partMother = mctrack->Particle();
1356 TParticle *partMotherCopy = mctrack->Particle();
1357 Int_t maPdgcode = partMother->GetPdgCode();
1359 // if the mother is charmed hadron
1360 if ( int(abs(maPdgcode)/100.) == kCharm || int(abs(maPdgcode)/1000.) == kCharm ) {
1362 for (Int_t i=0; i<fNparents; i++){
1363 if (abs(maPdgcode)==fParentSelect[0][i]){
1364 isFinalOpenCharm = kTRUE;
1367 if (!isFinalOpenCharm) return -1;
1369 // iterate until you find B hadron as a mother or become top ancester
1370 for (Int_t i=1; i<fgkMaxIter; i++){
1372 Int_t jLabel = partMother->GetFirstMother();
1374 origin = kDirectCharm;
1377 if (jLabel < 0){ // safety protection
1378 AliDebug(1, "Stack label is negative, return\n");
1382 // if there is an ancester
1383 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(jLabel))))) return -1;
1384 TParticle* grandMa = mctrack->Particle();
1385 Int_t grandMaPDG = grandMa->GetPdgCode();
1387 for (Int_t j=0; j<fNparents; j++){
1388 if (abs(grandMaPDG)==fParentSelect[1][j]){
1389 origin = kBeautyCharm;
1394 partMother = grandMa;
1395 } // end of iteration
1397 else if ( int(abs(maPdgcode)/100.) == kBeauty || int(abs(maPdgcode)/1000.) == kBeauty ) {
1398 for (Int_t i=0; i<fNparents; i++){
1399 if (abs(maPdgcode)==fParentSelect[1][i]){
1400 origin = kDirectBeauty;
1405 else if ( abs(maPdgcode) == 22 ) { //conversion
1407 tmpMomLabel = partMotherCopy->GetFirstMother();
1408 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(tmpMomLabel))))) return -1;
1409 partMother = mctrack->Particle();
1410 maPdgcode = partMother->GetPdgCode();
1411 if ( abs(maPdgcode) == 111 ) {
1415 else if ( abs(maPdgcode) == 221 ) {
1419 else if ( abs(maPdgcode) == 223 ) {
1420 origin = kGammaOmega;
1423 else if ( abs(maPdgcode) == 333 ) {
1427 else if ( abs(maPdgcode) == 331 ) {
1428 origin = kGammaEtaPrime;
1431 else if ( abs(maPdgcode) == 113 ) {
1432 origin = kGammaRho0;
1435 else origin = kElse;
1436 //origin = kGamma; // finer category above
1440 else if ( abs(maPdgcode) == 111 ) {
1444 else if ( abs(maPdgcode) == 221 ) {
1448 else if ( abs(maPdgcode) == 223 ) {
1452 else if ( abs(maPdgcode) == 333 ) {
1456 else if ( abs(maPdgcode) == 331 ) {
1460 else if ( abs(maPdgcode) == 113 ) {
1464 else origin = kElse;
1468 //__________________________________________
1469 Double_t AliHFEmcQA::GetWeightFactor(AliMCParticle *mctrack, const Int_t iBgLevel){
1471 // Get weighting factor for the realistic background estimation, for three possible background yield levels, indicated by the argument "iLevel": the best estimate (0), the lower uncertainty level (1), and the upper uncertainty level (2)
1473 AliMCParticle *mctrackmother = NULL;
1474 Double_t weightElecBg = 0.;
1475 Double_t mesonPt = 0.;
1476 Double_t bgcategory = 0.;
1478 Int_t mesonID = GetElecSource(mctrack->Particle());
1479 if(mesonID==kGammaPi0 || mesonID==kPi0) mArr=0; //pion
1480 else if(mesonID==kGammaEta || mesonID==kEta) mArr=1; //eta
1481 else if(mesonID==kGammaOmega || mesonID==kOmega) mArr=2; //omega
1482 else if(mesonID==kGammaPhi || mesonID==kPhi) mArr=3; //phi
1483 else if(mesonID==kGammaEtaPrime || mesonID==kEtaPrime) mArr=4; //etaprime
1484 else if(mesonID==kGammaRho0 || mesonID==kRho0) mArr=5; //rho
1487 if(mesonID>=kGammaPi0) { // conversion electron, be careful with the enum odering
1488 Int_t glabel=TMath::Abs(mctrack->GetMother()); // gamma label
1489 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
1490 glabel=TMath::Abs(mctrackmother->GetMother()); // gamma's mother's label
1491 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
1492 mesonPt = mctrackmother->Pt(); //meson pt
1497 else{ // nonHFE except for the conversion electron
1498 Int_t glabel=TMath::Abs(mctrack->GetMother());
1499 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
1500 mesonPt=mctrackmother->Pt(); //meson pt
1506 if(fCentrality < 0)return 0.;
1507 weightElecBg=fElecBackgroundFactor[iBgLevel][fCentrality][mArr][kBgPtBins-1];
1508 for(int ii=0; ii<kBgPtBins; ii++){
1509 if((mesonPt > fBinLimit[ii]) && (mesonPt < fBinLimit[ii+1])){
1510 weightElecBg = fElecBackgroundFactor[iBgLevel][fCentrality][mArr][ii];
1516 weightElecBg=fElecBackgroundFactor[iBgLevel][0][mArr][kBgPtBins-1];
1517 for(int ii=0; ii<kBgPtBins; ii++){
1518 if((mesonPt > fBinLimit[ii]) && (mesonPt < fBinLimit[ii+1])){
1519 weightElecBg = fElecBackgroundFactor[iBgLevel][0][mArr][ii];
1525 return bgcategory*weightElecBg;
1528 //__________________________________________
1529 void AliHFEmcQA::AliHists::FillList(TList *l) const {
1531 // Fill Histos into a list for output
1533 if(fPdgCode) l->Add(fPdgCode);
1534 if(fPt) l->Add(fPt);
1536 if(fEta) l->Add(fEta);
1539 //__________________________________________
1540 void AliHFEmcQA::AliHistsComm::FillList(TList *l) const {
1542 // Fill Histos into a list for output
1544 if(fNq) l->Add(fNq);
1545 if(fProcessID) l->Add(fProcessID);
1546 if(fePtRatio) l->Add(fePtRatio);
1547 if(fPtCorr) l->Add(fPtCorr);
1548 if(fPtCorrDp) l->Add(fPtCorrDp);
1549 if(fPtCorrD0) l->Add(fPtCorrD0);
1550 if(fPtCorrDrest) l->Add(fPtCorrDrest);
1551 if(fDePtRatio) l->Add(fDePtRatio);
1552 if(feDistance) l->Add(feDistance);
1553 if(fDeDistance) l->Add(fDeDistance);