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>
35 #include "TTreeStream.h"
38 #include <AliMCEvent.h>
39 #include <AliGenEventHeader.h>
40 #include <AliAODMCParticle.h>
43 #include "AliHFEmcQA.h"
44 #include "AliHFEtools.h"
45 #include "AliHFEcollection.h"
49 //_______________________________________________________________________________________________
50 AliHFEmcQA::AliHFEmcQA() :
55 ,fMCQACollection(NULL)
60 ,fIsppMultiBin(kFALSE)
62 ,fIsDebugStreamerON(kFALSE)
69 ,fHfeImpactnsigmaR(-999)
72 // Default constructor
73 for(Int_t mom = 0; mom < 9; mom++){
76 for(Int_t mom = 0; mom < 50; mom++){
77 fHeavyQuark[mom] = NULL;
79 for(Int_t mom = 0; mom < 2; mom++){
82 memset(fElecBackgroundFactor, 0, sizeof(Double_t) * kElecBgSpecies * kBgPtBins * kCentBins * kBgLevels);
83 memset(fBinLimit, 0, sizeof(Double_t) * (kBgPtBins+1));
86 //_______________________________________________________________________________________________
87 AliHFEmcQA::AliHFEmcQA(const AliHFEmcQA&p):
92 ,fQAhistos(p.fQAhistos)
93 ,fMCQACollection(p.fMCQACollection)
94 ,fNparents(p.fNparents)
98 ,fIsppMultiBin(kFALSE)
100 ,fIsDebugStreamerON(kFALSE)
107 ,fHfeImpactnsigmaR(0)
111 for(Int_t mom = 0; mom < 9; mom++){
114 for(Int_t mom = 0; mom < 50; mom++){
115 fHeavyQuark[mom] = NULL;
117 for(Int_t mom = 0; mom < 2; mom++){
120 memset(fElecBackgroundFactor, 0, sizeof(Double_t) * kElecBgSpecies * kBgPtBins * kCentBins * kBgLevels);
121 memset(fBinLimit, 0, sizeof(Double_t) * (kBgPtBins+1));
124 //_______________________________________________________________________________________________
126 AliHFEmcQA::operator=(const AliHFEmcQA &)
128 // Assignment operator
130 AliInfo("Not yet implemented.");
134 //_______________________________________________________________________________________________
135 AliHFEmcQA::~AliHFEmcQA()
139 if(fTreeStream && fIsDebugStreamerON) delete fTreeStream;
140 AliInfo("Analysis Done.");
143 //_______________________________________________________________________________________________
144 void AliHFEmcQA::PostAnalyze() const
151 //_______________________________________________________________________________________________
152 void AliHFEmcQA::SetBackgroundWeightFactor(Double_t *elecBackgroundFactor, Double_t *binLimit)
155 // copy background weighting factors into data member
158 memcpy(fElecBackgroundFactor,elecBackgroundFactor,sizeof(Double_t) * kElecBgSpecies * kBgPtBins * kCentBins * kBgLevels);
159 memcpy(fBinLimit,binLimit,sizeof(Double_t) * (kBgPtBins+1));
162 //__________________________________________
163 void AliHFEmcQA::CreatDefaultHistograms(TList * const qaList)
166 // make default histograms
172 fQAhistos->SetName("MCqa");
174 CreateHistograms(AliHFEmcQA::kCharm); // create histograms for charm
175 CreateHistograms(AliHFEmcQA::kBeauty); // create histograms for beauty
176 CreateHistograms(AliHFEmcQA::kOthers); // create histograms for beauty
178 // prepare 2D(pt vs Y) histogram for D spectra, we consider following 9 particles
179 const Int_t nbspecies = 9;
180 TString kDspecies[nbspecies];
181 kDspecies[0]="411"; //D+
182 kDspecies[1]="421"; //D0
183 kDspecies[2]="431"; //Ds+
184 kDspecies[3]="4122"; //Lambdac+
185 kDspecies[4]="4132"; //Ksic0
186 kDspecies[5]="4232"; //Ksic+
187 kDspecies[6]="4332"; //OmegaC0
188 kDspecies[7]="413"; //D*(2010)+
189 kDspecies[8]="423"; //D*(2007)0
191 const Double_t kPtbound[2] = {0.1, 20.}; //bin taken for considering inclusive e analysis binning
193 iBin[0] = 44; // bins in pt for log binning
194 iBin[1] = 23; // bins in pt for pi0 measurement binning
195 Double_t* binEdges[1];
196 binEdges[0] = AliHFEtools::MakeLogarithmicBinning(iBin[0], kPtbound[0], kPtbound[1]);
198 // bin size is chosen to consider ALICE D measurement
199 const Int_t nptbins = 15;
200 const Int_t nybins = 9;
201 Double_t xbins[nptbins+1]={0,0.5,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,12,16,24,32,40,50}; //pt binning for the final 7 TeV D measurement
202 Double_t ybins[nybins+1]={-7.5,-1.0,-0.9,-0.8,-0.5,0.5,0.8,0.9,1.0,7.5}; // y binning
204 for (Int_t iDmeson=0; iDmeson<nbspecies; iDmeson++){
205 hname = "Dmeson"+kDspecies[iDmeson];
206 fhD[iDmeson] = new TH2F(hname,hname+";p_{T} (GeV/c)",nptbins,xbins,nybins,ybins);
207 if(fQAhistos) fQAhistos->Add(fhD[iDmeson]);
210 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
213 if(fIsPbPb) kNcent=11;
216 if(fIsppMultiBin) kNcent=8;
220 fMCQACollection = new AliHFEcollection("TaskMCQA", "MC QA histos for meason pt spectra");
222 for(Int_t centbin=0; centbin<kNcent; centbin++)
224 fMCQACollection->CreateTH1Farray(Form("pionspectra_centrbin%i",centbin), "pion yields: MC p_{t} ", iBin[1],kPtRange);
225 fMCQACollection->CreateTH1Farray(Form("etaspectra_centrbin%i",centbin), "eta yields: MC p_{t} ", iBin[1],kPtRange);
226 fMCQACollection->CreateTH1Farray(Form("omegaspectra_centrbin%i",centbin), "omega yields: MC p_{t} ", iBin[1],kPtRange);
227 fMCQACollection->CreateTH1Farray(Form("phispectra_centrbin%i",centbin), "phi yields: MC p_{t} ", iBin[1],kPtRange);
228 fMCQACollection->CreateTH1Farray(Form("etapspectra_centrbin%i",centbin), "etap yields: MC p_{t} ", iBin[1],kPtRange);
229 fMCQACollection->CreateTH1Farray(Form("rhospectra_centrbin%i",centbin), "rho yields: MC p_{t} ", iBin[1],kPtRange);
231 fMCQACollection->CreateTH1F(Form("pionspectraLog_centrbin%i",centbin), "pion yields: MC p_{t} ", iBin[0],kPtbound[0], kPtbound[1], 1);
232 fMCQACollection->CreateTH1F(Form("etaspectraLog_centrbin%i",centbin), "eta yields: MC p_{t} ", iBin[0],kPtbound[0], kPtbound[1], 1);
233 fMCQACollection->CreateTH1F(Form("omegaspectraLog_centrbin%i",centbin), "omega yields: MC p_{t} ", iBin[0],kPtbound[0], kPtbound[1], 1);
234 fMCQACollection->CreateTH1F(Form("phispectraLog_centrbin%i",centbin), "phi yields: MC p_{t} ", iBin[0],kPtbound[0], kPtbound[1], 1);
235 fMCQACollection->CreateTH1F(Form("etapspectraLog_centrbin%i",centbin), "etap yields: MC p_{t} ", iBin[0],kPtbound[0], kPtbound[1], 1);
236 fMCQACollection->CreateTH1F(Form("rhospectraLog_centrbin%i",centbin), "rho yields: MC p_{t} ", iBin[0],kPtbound[0], kPtbound[1], 1);
237 fMCQACollection->CreateTH1F(Form("kaonspectraLog_centrbin%i",centbin), "kaon yields: MC p_{t} ", iBin[0],kPtbound[0], kPtbound[1], 1);
238 fMCQACollection->CreateTH1F(Form("k0LspectraLog_centrbin%i",centbin), "k0L yields: MC p_{t} ", iBin[0],kPtbound[0], kPtbound[1], 1);
240 fMCQACollection->CreateTH1F(Form("piondaughters_centrbin%i",centbin), "pion yields: MC p_{t} ", iBin[0],kPtbound[0], kPtbound[1], 1);
241 fMCQACollection->CreateTH1F(Form("etadaughters_centrbin%i",centbin), "eta yields: MC p_{t} ", iBin[0],kPtbound[0], kPtbound[1], 1);
242 fMCQACollection->CreateTH1F(Form("omegadaughters_centrbin%i",centbin), "omega yields: MC p_{t} ", iBin[0],kPtbound[0], kPtbound[1], 1);
243 fMCQACollection->CreateTH1F(Form("phidaughters_centrbin%i",centbin), "phi yields: MC p_{t} ", iBin[0],kPtbound[0], kPtbound[1], 1);
244 fMCQACollection->CreateTH1F(Form("etapdaughters_centrbin%i",centbin), "etap yields: MC p_{t} ", iBin[0],kPtbound[0], kPtbound[1], 1);
245 fMCQACollection->CreateTH1F(Form("rhodaughters_centrbin%i",centbin), "rho yields: MC p_{t} ", iBin[0],kPtbound[0], kPtbound[1], 1);
248 fQAhistos->Add(fMCQACollection->GetList());
250 if(!fTreeStream && fIsDebugStreamerON){
251 fTreeStream = new TTreeSRedirector(Form("HFEmcqadebugTree%s.root", GetName()));
256 //__________________________________________
257 void AliHFEmcQA::CreateHistograms(const Int_t kquark)
261 if (!(kquark == kCharm || kquark == kBeauty || kquark == kOthers)) {
262 AliDebug(1, "This task is only for heavy quark QA, return\n");
265 Int_t iq = kquark - kCharm;
267 TString kqTypeLabel[fgkqType];
268 if (kquark == kCharm){
269 kqTypeLabel[kQuark]="c";
270 kqTypeLabel[kantiQuark]="cbar";
271 kqTypeLabel[kHadron]="cHadron";
272 kqTypeLabel[keHadron]="ceHadron";
273 kqTypeLabel[kDeHadron]="nullHadron";
274 kqTypeLabel[kElectron]="ce";
275 kqTypeLabel[kElectron2nd]="nulle";
276 } else if (kquark == kBeauty){
277 kqTypeLabel[kQuark]="b";
278 kqTypeLabel[kantiQuark]="bbar";
279 kqTypeLabel[kHadron]="bHadron";
280 kqTypeLabel[keHadron]="beHadron";
281 kqTypeLabel[kDeHadron]="bDeHadron";
282 kqTypeLabel[kElectron]="be";
283 kqTypeLabel[kElectron2nd]="bce";
284 } else if (kquark == kOthers){
285 kqTypeLabel[kGamma-4]="gammae";
286 kqTypeLabel[kPi0-4]="pi0e";
287 kqTypeLabel[kElse-4]="elsee";
288 kqTypeLabel[kMisID-4]="miside";
291 TString kqEtaRangeLabel[fgkEtaRanges];
292 kqEtaRangeLabel[0] = "mcqa_";
293 kqEtaRangeLabel[1] = "mcqa_barrel_";
294 kqEtaRangeLabel[2] = "mcqa_unitY_";
296 const Double_t kPtbound[2] = {0.1, 20.}; //bin taken for considering inclusive e analysis binning
297 const Int_t nptbinning1 = 35;
299 iBin[0] = 44; // bins in pt
300 iBin[1] = nptbinning1; // bins in pt
301 Double_t* binEdges[1];
302 binEdges[0] = AliHFEtools::MakeLogarithmicBinning(iBin[0], kPtbound[0], kPtbound[1]);
304 // new binning for final electron analysis
305 const Double_t kPtbinning1[nptbinning1+1] = {0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1., 1.1, 1.2, 1.3, 1.4, 1.5, 1.75, 2., 2.25, 2.5, 2.75, 3., 3.5, 4., 4.5, 5., 5.5, 6., 7., 8., 10., 12., 14., 16., 18., 20.};
307 const Int_t ndptbins = 500;
308 Double_t xcorrbin[ndptbins+1];
309 for (int icorrbin = 0; icorrbin< ndptbins+1; icorrbin++){
310 xcorrbin[icorrbin]=icorrbin*0.1;
314 if(!fIsPbPb&&!fIsppMultiBin) fCentrmax=0;
315 else fCentrmax = kCentBins;
317 if(kquark == kOthers){
318 for (Int_t icut = 0; icut < fgkEtaRanges; icut++ ){
319 for (Int_t iqType = 0; iqType < 4; iqType++ ){
320 for(Int_t icentr = 0; icentr < (fCentrmax+1); icentr++)
322 hname = kqEtaRangeLabel[icut]+"Pt_"+kqTypeLabel[iqType];
323 fHist[iq][iqType][icut][icentr].fPt = new TH1F(Form("%sCentr_%i",hname.Data(),icentr),Form("%sCentr_%i;p_{T} (GeV/c)",hname.Data(),icentr),60,0.25,30.25);
324 hname = kqEtaRangeLabel[icut]+"Y_"+kqTypeLabel[iqType];
325 fHist[iq][iqType][icut][icentr].fY = new TH1F(Form("%sCentr_%i",hname.Data(),icentr),Form("%sCentr_%i;y",hname.Data(),icentr),150,-7.5,7.5);
326 hname = kqEtaRangeLabel[icut]+"Eta_"+kqTypeLabel[iqType];
327 fHist[iq][iqType][icut][icentr].fEta = new TH1F(Form("%sCentr_%i",hname.Data(),icentr),Form("%sCentr_%i;eta",hname.Data(),icentr),150,-7.5,7.5);
329 if(fQAhistos) fHist[iq][iqType][icut][icentr].FillList(fQAhistos);
335 for (Int_t icut = 0; icut < fgkEtaRanges; icut++ ){
336 for (Int_t iqType = 0; iqType < fgkqType; iqType++ ){
337 if (iqType < keHadron && icut > 0) continue; // don't duplicate histogram for quark and hadron
338 for(Int_t icentr = 0; icentr<(fCentrmax+1); icentr++)
340 hname = kqEtaRangeLabel[icut]+"PdgCode_"+kqTypeLabel[iqType];
341 fHist[iq][iqType][icut][icentr].fPdgCode = new TH1F(Form("%sCentr_%i",hname.Data(),icentr),Form("%sCentr_%i;PdgCode",hname.Data(),icentr),20001,-10000.5,10000.5);
342 hname = kqEtaRangeLabel[icut]+"Pt_"+kqTypeLabel[iqType];
343 fHist[iq][iqType][icut][icentr].fPt = new TH1F(Form("%sCentr_%i",hname.Data(),icentr),Form("%sCentr_%i;p_{T} (GeV/c)",hname.Data(),icentr),iBin[1],kPtbinning1); // new binning
344 hname = kqEtaRangeLabel[icut]+"Y_"+kqTypeLabel[iqType];
345 fHist[iq][iqType][icut][icentr].fY = new TH1F(Form("%sCentr_%i",hname.Data(),icentr),Form("%sCentr_%i;y",hname.Data(),icentr),150,-7.5,7.5);
346 hname = kqEtaRangeLabel[icut]+"Eta_"+kqTypeLabel[iqType];
347 fHist[iq][iqType][icut][icentr].fEta = new TH1F(Form("%sCentr_%i",hname.Data(),icentr),Form("%sCentr_%i;eta",hname.Data(),icentr),150,-7.5,7.5);
349 if(fQAhistos) fHist[iq][iqType][icut][icentr].FillList(fQAhistos);
354 for (Int_t icut = 0; icut < fgkEtaRanges; icut++ ){
355 hname = kqEtaRangeLabel[icut]+"PtCorr_"+kqTypeLabel[kQuark];
356 fHistComm[iq][icut].fPtCorr = new TH2F(hname,hname+";D p_{T} (GeV/c);e p_{T} (GeV/c)",ndptbins,xcorrbin,iBin[1],kPtbinning1);
357 hname = kqEtaRangeLabel[icut]+"PtCorrDp_"+kqTypeLabel[kQuark];
358 fHistComm[iq][icut].fPtCorrDp= new TH2F(hname,hname+";D p_{T} (GeV/c);e p_{T} (GeV/c)",ndptbins,xcorrbin,iBin[1],kPtbinning1);
359 hname = kqEtaRangeLabel[icut]+"PtCorrD0_"+kqTypeLabel[kQuark];
360 fHistComm[iq][icut].fPtCorrD0 = new TH2F(hname,hname+";D p_{T} (GeV/c);e p_{T} (GeV/c)",ndptbins,xcorrbin,iBin[1],kPtbinning1);
361 hname = kqEtaRangeLabel[icut]+"PtCorrDrest_"+kqTypeLabel[kQuark];
362 fHistComm[iq][icut].fPtCorrDrest = new TH2F(hname,hname+";D p_{T} (GeV/c);e p_{T} (GeV/c)",ndptbins,xcorrbin,iBin[1],kPtbinning1);
364 hname = kqEtaRangeLabel[icut]+"ePtRatio_"+kqTypeLabel[kQuark];
365 fHistComm[iq][icut].fePtRatio = new TH2F(hname,hname+";p_{T} (GeV/c);momentum fraction",200,0,20,100,0,1);
366 hname = kqEtaRangeLabel[icut]+"DePtRatio_"+kqTypeLabel[kQuark];
367 fHistComm[iq][icut].fDePtRatio = new TH2F(hname,hname+";p_{T} (GeV/c);momentum fraction",100,0,20,100,0,1);
368 hname = kqEtaRangeLabel[icut]+"eDistance_"+kqTypeLabel[kQuark];
369 fHistComm[iq][icut].feDistance= new TH2F(hname,hname+";p_{T} (GeV/c);distance (cm)",100,0,20,200,0,2);
370 hname = kqEtaRangeLabel[icut]+"DeDistance_"+kqTypeLabel[kQuark];
371 fHistComm[iq][icut].fDeDistance= new TH2F(hname,hname+";p_{T} (GeV/c);distance (cm)",100,0,20,200,0,2);
372 if(fQAhistos) fHistComm[iq][icut].FillList(fQAhistos);
375 hname = kqEtaRangeLabel[0]+"Nq_"+kqTypeLabel[kQuark];
376 fHistComm[iq][0].fNq = new TH1F(hname,hname,50,-0.5,49.5);
377 hname = kqEtaRangeLabel[0]+"ProcessID_"+kqTypeLabel[kQuark];
378 fHistComm[iq][0].fProcessID = new TH1F(hname,hname,21,-10.5,10.5);
382 //__________________________________________
383 void AliHFEmcQA::Init()
385 // called at begining every event
387 for (Int_t i=0; i<2; i++){
393 fParentSelect[0][0] = 411; //D+
394 fParentSelect[0][1] = 421; //D0
395 fParentSelect[0][2] = 431; //Ds+
396 fParentSelect[0][3] = 4122; //Lambdac+
397 fParentSelect[0][4] = 4132; //Ksic0
398 fParentSelect[0][5] = 4232; //Ksic+
399 fParentSelect[0][6] = 4332; //OmegaC0
401 fParentSelect[1][0] = 511; //B0
402 fParentSelect[1][1] = 521; //B+
403 fParentSelect[1][2] = 531; //Bs0
404 fParentSelect[1][3] = 5122; //Lambdab0
405 fParentSelect[1][4] = 5132; //Ksib-
406 fParentSelect[1][5] = 5232; //Ksib0
407 fParentSelect[1][6] = 5332; //Omegab-
412 //__________________________________________
413 void AliHFEmcQA::GetMesonKine()
416 // get meson pt spectra
419 AliVParticle *mctrack2 = NULL;
420 AliMCParticle *mctrack0 = NULL;
421 AliVParticle *mctrackdaugt= NULL;
422 AliMCParticle *mctrackd= NULL;
426 if(fCentrality>11) printf("warning centrality out of histogram array limits \n");
427 if(!fIsPbPb&&!fIsppMultiBin) fCentrality=0;
429 for(Int_t imc = 0; imc <fMCEvent->GetNumberOfPrimaries(); imc++){
430 if(!(mctrack2 = fMCEvent->GetTrack(imc))) continue;
431 TParticle* mcpart0 = fMCEvent->Stack()->Particle(imc);
432 if(!mcpart0) continue;
433 mctrack0 = dynamic_cast<AliMCParticle *>(mctrack2);
434 if(!mctrack0) continue;
436 // if(!fIsPbPb&&!fIsppMultiBin) fCentrality=0;
438 if(abs(mctrack0->PdgCode()) == 111) // pi0
440 if(TMath::Abs(AliHFEtools::GetRapidity(mcpart0))<0.8) {
441 fMCQACollection->Fill(Form("pionspectra_centrbin%i",fCentrality),mctrack0->Pt());
442 fMCQACollection->Fill(Form("pionspectraLog_centrbin%i",fCentrality),mctrack0->Pt());
444 id1=mctrack0->GetFirstDaughter();
445 id2=mctrack0->GetLastDaughter();
446 if(!((id2-id1)==2)) continue;
447 for(int idx=id1; idx<=id2; idx++){
448 if(!(mctrackdaugt = fMCEvent->GetTrack(idx))) continue;
449 if(!(mctrackd = dynamic_cast<AliMCParticle *>(mctrackdaugt))) continue;
450 if(abs(mctrackd->PdgCode()) == 11 && TMath::Abs(mctrackd->Eta())<0.8)
451 fMCQACollection->Fill(Form("piondaughters_centrbin%i",fCentrality),mctrackd->Pt());
454 else if(abs(mctrack0->PdgCode()) == 221) // eta
456 if(TMath::Abs(AliHFEtools::GetRapidity(mcpart0))<0.8) {
457 fMCQACollection->Fill(Form("etaspectra_centrbin%i",fCentrality),mctrack0->Pt());
458 fMCQACollection->Fill(Form("etaspectraLog_centrbin%i",fCentrality),mctrack0->Pt());
460 id1=mctrack0->GetFirstDaughter();
461 id2=mctrack0->GetLastDaughter();
462 if(!((id2-id1)==2||(id2-id1)==3)) continue;
463 for(int idx=id1; idx<=id2; idx++){
464 if(!(mctrackdaugt = fMCEvent->GetTrack(idx))) continue;
465 if(!(mctrackd = dynamic_cast<AliMCParticle *>(mctrackdaugt))) continue;
466 if(abs(mctrackd->PdgCode()) == 11 && TMath::Abs(mctrackd->Eta())<0.8)
467 fMCQACollection->Fill(Form("etadaughters_centrbin%i",fCentrality),mctrackd->Pt());
470 else if(abs(mctrack0->PdgCode()) == 223) // omega
472 if(TMath::Abs(AliHFEtools::GetRapidity(mcpart0))<0.8) {
473 fMCQACollection->Fill(Form("omegaspectra_centrbin%i",fCentrality),mctrack0->Pt());
474 fMCQACollection->Fill(Form("omegaspectraLog_centrbin%i",fCentrality),mctrack0->Pt());
476 id1=mctrack0->GetFirstDaughter();
477 id2=mctrack0->GetLastDaughter();
478 if(!((id2-id1)==1||(id2-id1)==2)) continue;
479 for(int idx=id1; idx<=id2; idx++){
480 if(!(mctrackdaugt = fMCEvent->GetTrack(idx))) continue;
481 if(!(mctrackd = dynamic_cast<AliMCParticle *>(mctrackdaugt))) continue;
482 if(abs(mctrackd->PdgCode()) == 11 && TMath::Abs(mctrackd->Eta())<0.8)
483 fMCQACollection->Fill(Form("omegadaughters_centrbin%i",fCentrality),mctrackd->Pt());
486 else if(abs(mctrack0->PdgCode()) == 333) // phi
488 if(TMath::Abs(AliHFEtools::GetRapidity(mcpart0))<0.8) {
489 fMCQACollection->Fill(Form("phispectra_centrbin%i",fCentrality),mctrack0->Pt());
490 fMCQACollection->Fill(Form("phispectraLog_centrbin%i",fCentrality),mctrack0->Pt());
492 id1=mctrack0->GetFirstDaughter();
493 id2=mctrack0->GetLastDaughter();
494 if(!((id2-id1)==1)) continue;
495 for(int idx=id1; idx<=id2; idx++){
496 if(!(mctrackdaugt = fMCEvent->GetTrack(idx))) continue;
497 if(!(mctrackd = dynamic_cast<AliMCParticle *>(mctrackdaugt))) continue;
498 if(abs(mctrackd->PdgCode()) == 11 && TMath::Abs(mctrackd->Eta())<0.8)
499 fMCQACollection->Fill(Form("phidaughters_centrbin%i",fCentrality),mctrackd->Pt());
502 else if(abs(mctrack0->PdgCode()) == 331) // eta prime
504 if(TMath::Abs(AliHFEtools::GetRapidity(mcpart0))<0.8) {
505 fMCQACollection->Fill(Form("etapspectra_centrbin%i",fCentrality),mctrack0->Pt());
506 fMCQACollection->Fill(Form("etapspectraLog_centrbin%i",fCentrality),mctrack0->Pt());
508 id1=mctrack0->GetFirstDaughter();
509 id2=mctrack0->GetLastDaughter();
510 if(!((id2-id1)==2||(id2-id1)==3)) continue;
511 for(int idx=id1; idx<=id2; idx++){
512 if(!(mctrackdaugt = fMCEvent->GetTrack(idx))) continue;
513 if(!(mctrackd = dynamic_cast<AliMCParticle *>(mctrackdaugt))) continue;
514 if(abs(mctrackd->PdgCode()) == 11 && TMath::Abs(mctrackd->Eta())<0.8)
515 fMCQACollection->Fill(Form("etapdaughters_centrbin%i",fCentrality),mctrackd->Pt());
518 else if(abs(mctrack0->PdgCode()) == 113) // rho
520 if(TMath::Abs(AliHFEtools::GetRapidity(mcpart0))<0.8) {
521 fMCQACollection->Fill(Form("rhospectra_centrbin%i",fCentrality),mctrack0->Pt());
522 fMCQACollection->Fill(Form("rhospectraLog_centrbin%i",fCentrality),mctrack0->Pt());
524 id1=mctrack0->GetFirstDaughter();
525 id2=mctrack0->GetLastDaughter();
526 if(!((id2-id1)==1)) continue;
527 for(int idx=id1; idx<=id2; idx++){
528 if(!(mctrackdaugt = fMCEvent->GetTrack(idx))) continue;
529 if(!(mctrackd = dynamic_cast<AliMCParticle *>(mctrackdaugt))) continue;
530 if(abs(mctrackd->PdgCode()) == 11 && TMath::Abs(mctrackd->Eta())<0.8)
531 fMCQACollection->Fill(Form("rhodaughters_centrbin%i",fCentrality),mctrackd->Pt());
534 else if(abs(mctrack0->PdgCode()) == 321) // kaon+-
536 if(TMath::Abs(AliHFEtools::GetRapidity(mcpart0))<0.8) {
537 fMCQACollection->Fill(Form("kaonspectraLog_centrbin%i",fCentrality),mctrack0->Pt());
540 else if(abs(mctrack0->PdgCode()) == 130) // k0L
542 if(TMath::Abs(AliHFEtools::GetRapidity(mcpart0))<0.8) {
543 fMCQACollection->Fill(Form("k0LspectraLog_centrbin%i",fCentrality),mctrack0->Pt());
549 //__________________________________________
550 void AliHFEmcQA::GetQuarkKine(TParticle *part, Int_t iTrack, const Int_t kquark)
552 // get heavy quark kinematics
554 if (kquark != kCharm && kquark != kBeauty) {
555 AliDebug(1, "This task is only for heavy quark QA, return\n");
558 Int_t iq = kquark - kCharm;
560 if (iTrack < 0 || !part) {
561 AliDebug(1, "Stack label is negative or no mcparticle, return\n");
565 if(!fIsPbPb&&!fIsppMultiBin) fCentrality=0;
567 AliMCParticle *mctrack = NULL;
568 Int_t partPdgcode = TMath::Abs(part->GetPdgCode());
570 // select heavy hadron or not fragmented heavy quark
571 if ( int(partPdgcode/100.)==kquark || int(partPdgcode/1000.)==kquark || (partPdgcode==kquark && (part->GetNDaughters()==0 && iTrack>5)) ){
573 TParticle *partMother;
576 if (partPdgcode == kquark){ // in case of not fragmented heavy quark
579 } else{ // in case of heavy hadron, start to search for mother heavy parton
580 iLabel = part->GetFirstMother();
581 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(iLabel))))) return;
582 if (iLabel>-1) { partMother = mctrack->Particle(); }
584 AliDebug(1, "Stack label is negative, return\n");
589 // heavy parton selection as a mother of heavy hadron
590 // if the heavy particle comes from string which is denoted as particle status 12|12|12...12|11,[PYTHIA p.60]
591 // in this case, the mother of heavy particle can be one of the fragmented parton of the string
592 // should I make a condition that partMother should be quark or diquark? -> not necessary
593 if ( abs(partMother->GetPdgCode()) == kquark || (partMother->GetStatusCode() == 11) ){
594 //if ( abs(partMother->GetPdgCode()) == kquark || (partMother->GetStatusCode() == 11 || partMother->GetStatusCode() == 12) ){
596 if ( abs(partMother->GetPdgCode()) != kquark ){
597 // search fragmented partons in the same string
598 Bool_t isSameString = kTRUE;
599 for (Int_t i=1; i<fgkMaxIter; i++){
601 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(iLabel))))) return;
602 if (iLabel>-1) { partMother = mctrack->Particle(); }
604 AliDebug(1, "Stack label is negative, return\n");
607 if ( abs(partMother->GetPdgCode()) == kquark ) break;
608 if ( partMother->GetStatusCode() != 12 ) isSameString = kFALSE;
609 if (!isSameString) return;
612 AliDebug(1, "Can not find heavy parton of this heavy hadron in the string, return\n");
613 if (abs(partMother->GetPdgCode()) != kquark) return;
615 if (fIsHeavy[iq] >= 50) return;
616 fHeavyQuark[fIsHeavy[iq]] = partMother;
619 // fill kinematics for heavy parton
620 if (partMother->GetPdgCode() > 0) { // quark
621 fHist[iq][kQuark][0][fCentrality].fPdgCode->Fill(partMother->GetPdgCode());
622 fHist[iq][kQuark][0][fCentrality].fPt->Fill(partMother->Pt());
623 fHist[iq][kQuark][0][fCentrality].fY->Fill(AliHFEtools::GetRapidity(partMother));
624 fHist[iq][kQuark][0][fCentrality].fEta->Fill(partMother->Eta());
626 fHist[iq][kantiQuark][0][fCentrality].fPdgCode->Fill(partMother->GetPdgCode());
627 fHist[iq][kantiQuark][0][fCentrality].fPt->Fill(partMother->Pt());
628 fHist[iq][kantiQuark][0][fCentrality].fY->Fill(AliHFEtools::GetRapidity(partMother));
629 fHist[iq][kantiQuark][0][fCentrality].fEta->Fill(partMother->Eta());
632 } // end of heavy parton slection loop
634 } // end of heavy hadron or quark selection
638 //__________________________________________
639 void AliHFEmcQA::EndOfEventAna(const Int_t kquark)
641 // end of event analysis
643 if (kquark != kCharm && kquark != kBeauty) {
644 AliDebug(1, "This task is only for heavy quark QA, return\n");
647 Int_t iq = kquark - kCharm;
650 // # of heavy quark per event
651 AliDebug(1,Form("Number of heavy quark in this event = %d \n",fIsHeavy[iq]));
652 fHistComm[iq][0].fNq->Fill(fIsHeavy[iq]);
654 Int_t motherID[fgkMaxGener];
655 Int_t motherType[fgkMaxGener];
656 Int_t motherLabel[fgkMaxGener];
657 Int_t ancestorPdg[fgkMaxGener];
658 Int_t ancestorLabel[fgkMaxGener];
660 for (Int_t i = 0; i < fgkMaxGener; i++){ // initialization
665 ancestorLabel[i] = 0;
669 // check history of found heavy quarks
670 for (Int_t i = 0; i < fIsHeavy[iq]; i++){
672 if(!fHeavyQuark[i]) return;
674 ancestorLabel[0] = i;
675 ancestorPdg[0] = fHeavyQuark[i]->GetPdgCode();
676 ancestorLabel[1] = fHeavyQuark[i]->GetFirstMother();
678 AliDebug(1,Form("pdg code= %d\n",ancestorPdg[0]));
679 AliDebug(1,Form("ancestor label= %d\n",ancestorLabel[1]));
682 while (ancestorLabel[ig] != -1){
683 // in case there is mother, get mother's pdg code and grandmother's label
684 IdentifyMother(ancestorLabel[ig], ancestorPdg[ig], ancestorLabel[ig+1]);
685 // if mother is still heavy, find again mother's ancestor
686 if (ancestorPdg[ig-1] == ancestorPdg[ig]) {
688 continue; // if it is from same heavy
690 // if the heavy's mother is not heavy, check the mother's label to know if it comes from inital or final parton shower
691 if (IsFromInitialShower(ancestorLabel[ig],motherID[i],motherType[i],motherLabel[i])) break;
692 if (IsFromFinalParton(ancestorLabel[ig],motherID[i],motherType[i],motherLabel[i])) break;
693 // if it is not the above case, something is strange
694 ReportStrangeness(motherID[i],motherType[i],motherLabel[i]);
697 if (ancestorLabel[ig] == -1){ // from hard scattering
698 HardScattering(kquark, motherID[i],motherType[i], motherLabel[i]);
701 } // end of found heavy quark loop
704 // check process type
706 for (Int_t i = 0; i < fIsHeavy[iq]; i++){
707 AliDebug(1,Form("Mother ID= %d type= %d label= %d\n",motherID[i],motherType[i],motherLabel[i]));
711 Int_t nheavypair = Int_t(fIsHeavy[iq]/2.);
712 for (Int_t ipair = 0; ipair < nheavypair; ipair++){
715 Int_t id2 = ipair*2 + 1;
717 if (motherType[id1] == 2 && motherType[id2] == 2){
718 if (motherLabel[id1] == motherLabel[id2]) processID = kGluonSplitting; // gluon spliting
721 else if (motherType[id1] == -1 && motherType[id2] == -1) {
722 if (motherLabel[id1] == -1 && motherLabel[id2] == -1) {
723 if (motherID[id1] == fgkGluon) processID = kPairCreationFromg; // gluon fusion
724 else processID = kPairCreationFromq; // q-qbar pair creation
728 else if (motherType[id1] == -1 || motherType[id2] == -1) {
729 if ((motherLabel[id1] == -1 || motherLabel[id2] == -1) && (motherLabel[id1]*motherLabel[id2] == -2 || motherLabel[id1]*motherLabel[id2] == -3)) {
730 if(motherID[id1]*motherID[id2] == kquark*fgkGluon) processID = kFlavourExitation; // flavour exitation
731 else processID = kLightQuarkShower;
735 else if (motherType[id1] == -2 || motherType[id2] == -2) {
736 if (motherLabel[id1] == motherLabel[id2]) processID = kInitialPartonShower; // initial parton shower
742 if (nheavypair >1) AliDebug(1,Form("Multi pair found : process ID = %d\n",processID));
743 else fHistComm[iq][0].fProcessID->Fill(processID);
744 AliDebug(1,Form("Process ID = %d\n",processID));
745 } // end of # heavy quark pair loop
749 //__________________________________________
750 void AliHFEmcQA::GetHadronKine(TParticle* mcpart, const Int_t kquark)
752 // decay electron kinematics
754 if (kquark != kCharm && kquark != kBeauty) {
755 AliDebug(1, "This task is only for heavy quark QA, return\n");
758 Int_t iq = kquark - kCharm;
761 AliDebug(1, "no mc particle, return\n");
765 Int_t iLabel = mcpart->GetFirstMother();
767 AliDebug(1, "Stack label is negative, return\n");
771 if(!fIsPbPb&&!fIsppMultiBin) fCentrality=0;
773 TParticle *partCopy = mcpart;
774 Int_t pdgcode = mcpart->GetPdgCode();
775 Int_t pdgcodeCopy = pdgcode;
777 AliMCParticle *mctrack = NULL;
779 // if the mother is charmed hadron
780 Bool_t isDirectCharm = kFALSE;
781 if ( int(abs(pdgcode)/100.) == kCharm || int(abs(pdgcode)/1000.) == kCharm ) {
783 // iterate until you find B hadron as a mother or become top ancester
784 for (Int_t i=1; i<fgkMaxIter; i++){
786 Int_t jLabel = mcpart->GetFirstMother();
788 isDirectCharm = kTRUE;
789 break; // if there is no ancester
791 if (jLabel < 0){ // safety protection
792 AliDebug(1, "Stack label is negative, return\n");
795 // if there is an ancester
796 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(jLabel))))) return;
797 TParticle* mother = mctrack->Particle();
798 Int_t motherPDG = mother->GetPdgCode();
800 for (Int_t j=0; j<fNparents; j++){
801 if (abs(motherPDG)==fParentSelect[1][j]) return; // return if this hadron is originated from b
805 } // end of iteration
807 if((isDirectCharm == kTRUE && kquark == kCharm) || kquark == kBeauty) {
808 for (Int_t i=0; i<fNparents; i++){
809 if (abs(pdgcodeCopy)==fParentSelect[iq][i]){
811 // fill hadron kinematics
812 fHist[iq][kHadron][0][fCentrality].fPdgCode->Fill(pdgcodeCopy);
813 fHist[iq][kHadron][0][fCentrality].fPt->Fill(partCopy->Pt());
814 fHist[iq][kHadron][0][fCentrality].fY->Fill(AliHFEtools::GetRapidity(partCopy));
815 fHist[iq][kHadron][0][fCentrality].fEta->Fill(partCopy->Eta());
818 fhD[i]->Fill(partCopy->Pt(),AliHFEtools::GetRapidity(partCopy));
822 // I also want to store D* info to compare with D* measurement
823 if (abs(pdgcodeCopy)==413 && iq==0) { //D*+
824 fhD[7]->Fill(partCopy->Pt(),AliHFEtools::GetRapidity(partCopy));
826 if (abs(pdgcodeCopy)==423 && iq==0) { //D*0
827 fhD[8]->Fill(partCopy->Pt(),AliHFEtools::GetRapidity(partCopy));
832 //__________________________________________
833 void AliHFEmcQA::GetDecayedKine(TParticle* mcpart, const Int_t kquark, Int_t kdecayed)
835 // decay electron kinematics
837 if (!(kquark == kCharm || kquark == kBeauty || kquark == kOthers)){
838 AliDebug(1, "This task is only for heavy quark QA, return\n");
841 Int_t iq = kquark - kCharm;
842 Bool_t isFinalOpenCharm = kFALSE;
845 AliDebug(1, "no mcparticle, return\n");
849 if(!fIsPbPb&&!fIsppMultiBin) fCentrality=0;
851 Double_t eabsEta = TMath::Abs(mcpart->Eta());
852 Double_t eabsY = TMath::Abs(AliHFEtools::GetRapidity(mcpart));
856 if ( abs(mcpart->GetPdgCode()) != kdecayed ) esource = kMisID-4;
857 else esource =GetSource(mcpart)-4; // return for the cases kGamma=4, kPi0=5, kElse=6
858 if(esource==0|| esource==1 || esource==2 || esource==3){
859 fHist[iq][esource][0][fCentrality].fPt->Fill(mcpart->Pt());
860 fHist[iq][esource][0][fCentrality].fY->Fill(AliHFEtools::GetRapidity(mcpart));
861 fHist[iq][esource][0][fCentrality].fEta->Fill(mcpart->Eta());
863 fHist[iq][esource][1][fCentrality].fPt->Fill(mcpart->Pt());
864 fHist[iq][esource][1][fCentrality].fY->Fill(AliHFEtools::GetRapidity(mcpart));
865 fHist[iq][esource][1][fCentrality].fEta->Fill(mcpart->Eta());
868 fHist[iq][esource][2][fCentrality].fPt->Fill(mcpart->Pt());
869 fHist[iq][esource][2][fCentrality].fY->Fill(AliHFEtools::GetRapidity(mcpart));
870 fHist[iq][esource][2][fCentrality].fEta->Fill(mcpart->Eta());
875 AliDebug(1, "e source is out of defined ranges, return\n");
880 if ( abs(mcpart->GetPdgCode()) != kdecayed ) return;
882 Int_t iLabel = mcpart->GetFirstMother();
884 AliDebug(1, "Stack label is negative, return\n");
888 AliMCParticle *mctrack = NULL;
889 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(iLabel))))) return;
890 TParticle *partMother = mctrack->Particle();
891 TParticle *partMotherCopy = partMother;
892 Int_t maPdgcode = partMother->GetPdgCode();
893 Int_t maPdgcodeCopy = maPdgcode;
895 // get mc primary vertex
898 if(fMCHeader) fMCHeader->PrimaryVertex(mcPrimVtx);
900 // get electron production vertex
901 TLorentzVector ePoint;
902 mcpart->ProductionVertex(ePoint);
904 // calculated production vertex to primary vertex (in xy plane)
905 Float_t decayLxy = TMath::Sqrt((mcPrimVtx[0]-ePoint[0])*(mcPrimVtx[0]-ePoint[0])+(mcPrimVtx[1]-ePoint[1])*(mcPrimVtx[1]-ePoint[1]));
907 Float_t decayLxy = 0;
909 // if the mother is charmed hadron
910 Bool_t isMotherDirectCharm = kFALSE;
911 if ( int(abs(maPdgcode)/100.) == kCharm || int(abs(maPdgcode)/1000.) == kCharm ) {
913 for (Int_t i=0; i<fNparents; i++){
914 if (abs(maPdgcode)==fParentSelect[0][i]){
915 isFinalOpenCharm = kTRUE;
918 if (!isFinalOpenCharm) return ;
920 // iterate until you find B hadron as a mother or become top ancester
921 for (Int_t i=1; i<fgkMaxIter; i++){
923 Int_t jLabel = partMother->GetFirstMother();
925 isMotherDirectCharm = kTRUE;
926 break; // if there is no ancester
928 if (jLabel < 0){ // safety protection
929 AliDebug(1, "Stack label is negative, return\n");
933 // if there is an ancester
934 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(jLabel))))) return;
935 TParticle* grandMa = mctrack->Particle();
936 Int_t grandMaPDG = grandMa->GetPdgCode();
938 for (Int_t j=0; j<fNparents; j++){
939 if (abs(grandMaPDG)==fParentSelect[1][j]){
941 if (kquark == kCharm) return;
942 // fill electron kinematics
943 fHist[iq][kElectron2nd][0][fCentrality].fPdgCode->Fill(mcpart->GetPdgCode());
944 fHist[iq][kElectron2nd][0][fCentrality].fPt->Fill(mcpart->Pt());
945 fHist[iq][kElectron2nd][0][fCentrality].fY->Fill(AliHFEtools::GetRapidity(mcpart));
946 fHist[iq][kElectron2nd][0][fCentrality].fEta->Fill(mcpart->Eta());
948 // fill mother hadron kinematics
949 fHist[iq][kDeHadron][0][fCentrality].fPdgCode->Fill(grandMaPDG);
950 fHist[iq][kDeHadron][0][fCentrality].fPt->Fill(grandMa->Pt());
951 fHist[iq][kDeHadron][0][fCentrality].fY->Fill(AliHFEtools::GetRapidity(grandMa));
952 fHist[iq][kDeHadron][0][fCentrality].fEta->Fill(grandMa->Eta());
955 fHist[iq][kElectron2nd][1][fCentrality].fPdgCode->Fill(mcpart->GetPdgCode());
956 fHist[iq][kElectron2nd][1][fCentrality].fPt->Fill(mcpart->Pt());
957 fHist[iq][kElectron2nd][1][fCentrality].fY->Fill(AliHFEtools::GetRapidity(mcpart));
958 fHist[iq][kElectron2nd][1][fCentrality].fEta->Fill(mcpart->Eta());
960 // fill mother hadron kinematics
961 fHist[iq][kDeHadron][1][fCentrality].fPdgCode->Fill(grandMaPDG);
962 fHist[iq][kDeHadron][1][fCentrality].fPt->Fill(grandMa->Pt());
963 fHist[iq][kDeHadron][1][fCentrality].fY->Fill(AliHFEtools::GetRapidity(grandMa));
964 fHist[iq][kDeHadron][1][fCentrality].fEta->Fill(grandMa->Eta());
968 fHist[iq][kElectron2nd][2][fCentrality].fPdgCode->Fill(mcpart->GetPdgCode());
969 fHist[iq][kElectron2nd][2][fCentrality].fPt->Fill(mcpart->Pt());
970 fHist[iq][kElectron2nd][2][fCentrality].fY->Fill(AliHFEtools::GetRapidity(mcpart));
971 fHist[iq][kElectron2nd][2][fCentrality].fEta->Fill(mcpart->Eta());
973 // fill mother hadron kinematics
974 fHist[iq][kDeHadron][2][fCentrality].fPdgCode->Fill(grandMaPDG);
975 fHist[iq][kDeHadron][2][fCentrality].fPt->Fill(grandMa->Pt());
976 fHist[iq][kDeHadron][2][fCentrality].fY->Fill(AliHFEtools::GetRapidity(grandMa));
977 fHist[iq][kDeHadron][2][fCentrality].fEta->Fill(grandMa->Eta());
980 // ratio between pT of electron and pT of mother B hadron
982 fHistComm[iq][0].fDePtRatio->Fill(grandMa->Pt(),mcpart->Pt()/grandMa->Pt());
984 fHistComm[iq][1].fDePtRatio->Fill(grandMa->Pt(),mcpart->Pt()/grandMa->Pt());
987 fHistComm[iq][2].fDePtRatio->Fill(grandMa->Pt(),mcpart->Pt()/grandMa->Pt());
991 // distance between electron production point and primary vertex
992 fHistComm[iq][0].fDeDistance->Fill(grandMa->Pt(),decayLxy);
994 fHistComm[iq][1].fDeDistance->Fill(grandMa->Pt(),decayLxy);
997 fHistComm[iq][2].fDeDistance->Fill(grandMa->Pt(),decayLxy);
1003 partMother = grandMa;
1004 } // end of iteration
1006 if((isMotherDirectCharm == kTRUE && kquark == kCharm) || kquark == kBeauty) {
1007 for (Int_t i=0; i<fNparents; i++){
1008 if (abs(maPdgcodeCopy)==fParentSelect[iq][i]){
1010 fHist[iq][kElectron][0][fCentrality].fPdgCode->Fill(mcpart->GetPdgCode());
1011 fHist[iq][kElectron][0][fCentrality].fPt->Fill(mcpart->Pt());
1012 fHist[iq][kElectron][0][fCentrality].fY->Fill(AliHFEtools::GetRapidity(mcpart));
1013 fHist[iq][kElectron][0][fCentrality].fEta->Fill(mcpart->Eta());
1015 // fill mother hadron kinematics
1016 fHist[iq][keHadron][0][fCentrality].fPdgCode->Fill(maPdgcodeCopy);
1017 fHist[iq][keHadron][0][fCentrality].fPt->Fill(partMotherCopy->Pt());
1018 fHist[iq][keHadron][0][fCentrality].fY->Fill(AliHFEtools::GetRapidity(partMotherCopy));
1019 fHist[iq][keHadron][0][fCentrality].fEta->Fill(partMotherCopy->Eta());
1022 fHist[iq][kElectron][1][fCentrality].fPdgCode->Fill(mcpart->GetPdgCode());
1023 fHist[iq][kElectron][1][fCentrality].fPt->Fill(mcpart->Pt());
1024 fHist[iq][kElectron][1][fCentrality].fY->Fill(AliHFEtools::GetRapidity(mcpart));
1025 fHist[iq][kElectron][1][fCentrality].fEta->Fill(mcpart->Eta());
1027 // fill mother hadron kinematics
1028 fHist[iq][keHadron][1][fCentrality].fPdgCode->Fill(maPdgcodeCopy);
1029 fHist[iq][keHadron][1][fCentrality].fPt->Fill(partMotherCopy->Pt());
1030 fHist[iq][keHadron][1][fCentrality].fY->Fill(AliHFEtools::GetRapidity(partMotherCopy));
1031 fHist[iq][keHadron][1][fCentrality].fEta->Fill(partMotherCopy->Eta());
1035 fHist[iq][kElectron][2][fCentrality].fPdgCode->Fill(mcpart->GetPdgCode());
1036 fHist[iq][kElectron][2][fCentrality].fPt->Fill(mcpart->Pt());
1037 fHist[iq][kElectron][2][fCentrality].fY->Fill(AliHFEtools::GetRapidity(mcpart));
1038 fHist[iq][kElectron][2][fCentrality].fEta->Fill(mcpart->Eta());
1040 // fill mother hadron kinematics
1041 fHist[iq][keHadron][2][fCentrality].fPdgCode->Fill(maPdgcodeCopy);
1042 fHist[iq][keHadron][2][fCentrality].fPt->Fill(partMotherCopy->Pt());
1043 fHist[iq][keHadron][2][fCentrality].fY->Fill(AliHFEtools::GetRapidity(partMotherCopy));
1044 fHist[iq][keHadron][2][fCentrality].fEta->Fill(partMotherCopy->Eta());
1047 // ratio between pT of electron and pT of mother B or direct D hadron
1048 if(partMotherCopy->Pt()) {
1049 fHistComm[iq][0].fePtRatio->Fill(partMotherCopy->Pt(),mcpart->Pt()/partMotherCopy->Pt());
1051 fHistComm[iq][1].fePtRatio->Fill(partMotherCopy->Pt(),mcpart->Pt()/partMotherCopy->Pt());
1054 fHistComm[iq][2].fePtRatio->Fill(partMotherCopy->Pt(),mcpart->Pt()/partMotherCopy->Pt());
1057 fHistComm[iq][0].fPtCorr->Fill(partMotherCopy->Pt(),mcpart->Pt());
1059 fHistComm[iq][1].fPtCorr->Fill(partMotherCopy->Pt(),mcpart->Pt());
1062 fHistComm[iq][2].fPtCorr->Fill(partMotherCopy->Pt(),mcpart->Pt());
1064 if(TMath::Abs(partMotherCopy->GetPdgCode())==411) {
1065 fHistComm[iq][0].fPtCorrDp->Fill(partMotherCopy->Pt(),mcpart->Pt());
1067 fHistComm[iq][1].fPtCorrDp->Fill(partMotherCopy->Pt(),mcpart->Pt());
1070 fHistComm[iq][2].fPtCorrDp->Fill(partMotherCopy->Pt(),mcpart->Pt());
1073 else if(TMath::Abs(partMotherCopy->GetPdgCode())==421) {
1074 fHistComm[iq][0].fPtCorrD0->Fill(partMotherCopy->Pt(),mcpart->Pt());
1076 fHistComm[iq][1].fPtCorrD0->Fill(partMotherCopy->Pt(),mcpart->Pt());
1079 fHistComm[iq][2].fPtCorrD0->Fill(partMotherCopy->Pt(),mcpart->Pt());
1083 fHistComm[iq][0].fPtCorrDrest->Fill(partMotherCopy->Pt(),mcpart->Pt());
1085 fHistComm[iq][1].fPtCorrDrest->Fill(partMotherCopy->Pt(),mcpart->Pt());
1088 fHistComm[iq][2].fPtCorrDrest->Fill(partMotherCopy->Pt(),mcpart->Pt());
1092 // distance between electron production point and primary vertex
1093 fHistComm[iq][0].feDistance->Fill(partMotherCopy->Pt(),decayLxy);
1095 fHistComm[iq][1].feDistance->Fill(partMotherCopy->Pt(),decayLxy);
1098 fHistComm[iq][2].feDistance->Fill(partMotherCopy->Pt(),decayLxy);
1105 //____________________________________________________________________
1106 void AliHFEmcQA::GetDecayedKine(AliAODMCParticle *mcpart, const Int_t kquark, Int_t kdecayed)
1108 // decay electron kinematics
1110 if (kquark != kCharm && kquark != kBeauty) {
1111 AliDebug(1, "This task is only for heavy quark QA, return\n");
1115 Int_t iq = kquark - kCharm;
1116 Bool_t isFinalOpenCharm = kFALSE;
1119 AliDebug(1, "no mcparticle, return\n");
1123 if ( abs(mcpart->GetPdgCode()) != kdecayed ) return;
1125 Double_t eabsEta = TMath::Abs(mcpart->Eta());
1126 Double_t eabsY = TMath::Abs(AliHFEtools::GetRapidity(mcpart));
1129 Int_t iLabel = mcpart->GetMother();
1131 AliDebug(1, "Stack label is negative, return\n");
1135 if(!fIsPbPb&&!fIsppMultiBin) fCentrality=0;
1137 AliAODMCParticle *partMother = (AliAODMCParticle*)fMCArray->At(iLabel);
1138 AliAODMCParticle *partMotherCopy = partMother;
1139 Int_t maPdgcode = partMother->GetPdgCode();
1140 Int_t maPdgcodeCopy = maPdgcode;
1142 Bool_t isMotherDirectCharm = kFALSE;
1143 if ( int(abs(maPdgcode)/100.) == kCharm || int(abs(maPdgcode)/1000.) == kCharm ) {
1145 for (Int_t i=0; i<fNparents; i++){
1146 if (abs(maPdgcode)==fParentSelect[0][i]){
1147 isFinalOpenCharm = kTRUE;
1150 if (!isFinalOpenCharm) return;
1152 for (Int_t i=1; i<fgkMaxIter; i++){
1154 Int_t jLabel = partMother->GetMother();
1156 isMotherDirectCharm = kTRUE;
1157 break; // if there is no ancester
1159 if (jLabel < 0){ // safety protection
1160 AliDebug(1, "Stack label is negative, return\n");
1164 // if there is an ancester
1165 AliAODMCParticle* grandMa = (AliAODMCParticle*)fMCArray->At(jLabel);
1166 Int_t grandMaPDG = grandMa->GetPdgCode();
1168 for (Int_t j=0; j<fNparents; j++){
1169 if (abs(grandMaPDG)==fParentSelect[1][j]){
1171 if (kquark == kCharm) return;
1172 // fill electron kinematics
1173 fHist[iq][kElectron2nd][0][fCentrality].fPdgCode->Fill(mcpart->GetPdgCode());
1174 fHist[iq][kElectron2nd][0][fCentrality].fPt->Fill(mcpart->Pt());
1175 fHist[iq][kElectron2nd][0][fCentrality].fY->Fill(AliHFEtools::GetRapidity(mcpart));
1176 fHist[iq][kElectron2nd][0][fCentrality].fEta->Fill(mcpart->Eta());
1178 // fill mother hadron kinematics
1179 fHist[iq][kDeHadron][0][fCentrality].fPdgCode->Fill(grandMaPDG);
1180 fHist[iq][kDeHadron][0][fCentrality].fPt->Fill(grandMa->Pt());
1181 fHist[iq][kDeHadron][0][fCentrality].fY->Fill(AliHFEtools::GetRapidity(grandMa));
1182 fHist[iq][kDeHadron][0][fCentrality].fEta->Fill(grandMa->Eta());
1185 // fill electron kinematics
1186 fHist[iq][kElectron2nd][1][fCentrality].fPdgCode->Fill(mcpart->GetPdgCode());
1187 fHist[iq][kElectron2nd][1][fCentrality].fPt->Fill(mcpart->Pt());
1188 fHist[iq][kElectron2nd][1][fCentrality].fY->Fill(AliHFEtools::GetRapidity(mcpart));
1189 fHist[iq][kElectron2nd][1][fCentrality].fEta->Fill(mcpart->Eta());
1191 // fill mother hadron kinematics
1192 fHist[iq][kDeHadron][1][fCentrality].fPdgCode->Fill(grandMaPDG);
1193 fHist[iq][kDeHadron][1][fCentrality].fPt->Fill(grandMa->Pt());
1194 fHist[iq][kDeHadron][1][fCentrality].fY->Fill(AliHFEtools::GetRapidity(grandMa));
1195 fHist[iq][kDeHadron][1][fCentrality].fEta->Fill(grandMa->Eta());
1198 // fill electron kinematics
1199 fHist[iq][kElectron2nd][2][fCentrality].fPdgCode->Fill(mcpart->GetPdgCode());
1200 fHist[iq][kElectron2nd][2][fCentrality].fPt->Fill(mcpart->Pt());
1201 fHist[iq][kElectron2nd][2][fCentrality].fY->Fill(AliHFEtools::GetRapidity(mcpart));
1202 fHist[iq][kElectron2nd][2][fCentrality].fEta->Fill(mcpart->Eta());
1204 // fill mother hadron kinematics
1205 fHist[iq][kDeHadron][2][fCentrality].fPdgCode->Fill(grandMaPDG);
1206 fHist[iq][kDeHadron][2][fCentrality].fPt->Fill(grandMa->Pt());
1207 fHist[iq][kDeHadron][2][fCentrality].fY->Fill(AliHFEtools::GetRapidity(grandMa));
1208 fHist[iq][kDeHadron][2][fCentrality].fEta->Fill(grandMa->Eta());
1215 partMother = grandMa;
1216 } // end of iteration
1218 if ((isMotherDirectCharm == kTRUE && kquark == kCharm) || kquark == kBeauty) {
1219 for (Int_t i=0; i<fNparents; i++){
1220 if (abs(maPdgcodeCopy)==fParentSelect[iq][i]){
1222 // fill electron kinematics
1223 fHist[iq][kElectron][0][fCentrality].fPdgCode->Fill(mcpart->GetPdgCode());
1224 fHist[iq][kElectron][0][fCentrality].fPt->Fill(mcpart->Pt());
1225 fHist[iq][kElectron][0][fCentrality].fY->Fill(AliHFEtools::GetRapidity(mcpart));
1226 fHist[iq][kElectron][0][fCentrality].fEta->Fill(mcpart->Eta());
1228 // fill mother hadron kinematics
1229 fHist[iq][keHadron][0][fCentrality].fPdgCode->Fill(maPdgcodeCopy);
1230 fHist[iq][keHadron][0][fCentrality].fPt->Fill(partMotherCopy->Pt());
1231 fHist[iq][keHadron][0][fCentrality].fY->Fill(AliHFEtools::GetRapidity(partMotherCopy));
1232 fHist[iq][keHadron][0][fCentrality].fEta->Fill(partMotherCopy->Eta());
1235 // fill electron kinematics
1236 fHist[iq][kElectron][1][fCentrality].fPdgCode->Fill(mcpart->GetPdgCode());
1237 fHist[iq][kElectron][1][fCentrality].fPt->Fill(mcpart->Pt());
1238 fHist[iq][kElectron][1][fCentrality].fY->Fill(AliHFEtools::GetRapidity(mcpart));
1239 fHist[iq][kElectron][1][fCentrality].fEta->Fill(mcpart->Eta());
1241 // fill mother hadron kinematics
1242 fHist[iq][keHadron][1][fCentrality].fPdgCode->Fill(maPdgcodeCopy);
1243 fHist[iq][keHadron][1][fCentrality].fPt->Fill(partMotherCopy->Pt());
1244 fHist[iq][keHadron][1][fCentrality].fY->Fill(AliHFEtools::GetRapidity(partMotherCopy));
1245 fHist[iq][keHadron][1][fCentrality].fEta->Fill(partMotherCopy->Eta());
1248 // fill electron kinematics
1249 fHist[iq][kElectron][2][fCentrality].fPdgCode->Fill(mcpart->GetPdgCode());
1250 fHist[iq][kElectron][2][fCentrality].fPt->Fill(mcpart->Pt());
1251 fHist[iq][kElectron][2][fCentrality].fY->Fill(AliHFEtools::GetRapidity(mcpart));
1252 fHist[iq][kElectron][2][fCentrality].fEta->Fill(mcpart->Eta());
1254 // fill mother hadron kinematics
1255 fHist[iq][keHadron][2][fCentrality].fPdgCode->Fill(maPdgcodeCopy);
1256 fHist[iq][keHadron][2][fCentrality].fPt->Fill(partMotherCopy->Pt());
1257 fHist[iq][keHadron][2][fCentrality].fY->Fill(AliHFEtools::GetRapidity(partMotherCopy));
1258 fHist[iq][keHadron][2][fCentrality].fEta->Fill(partMotherCopy->Eta());
1267 //__________________________________________
1268 void AliHFEmcQA::IdentifyMother(Int_t motherlabel, Int_t &motherpdg, Int_t &grandmotherlabel)
1270 // find mother pdg code and label
1272 if (motherlabel < 0) {
1273 AliDebug(1, "Stack label is negative, return\n");
1276 AliMCParticle *mctrack = NULL;
1277 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(motherlabel))))) return;
1278 TParticle *heavysMother = mctrack->Particle();
1279 motherpdg = heavysMother->GetPdgCode();
1280 grandmotherlabel = heavysMother->GetFirstMother();
1281 AliDebug(1,Form("ancestor pdg code= %d\n",motherpdg));
1284 //__________________________________________
1285 void AliHFEmcQA::HardScattering(const Int_t kquark, Int_t &motherID, Int_t &mothertype, Int_t &motherlabel)
1287 // mothertype -1 means this heavy quark coming from hard vertex
1289 AliMCParticle *mctrack1 = NULL;
1290 AliMCParticle *mctrack2 = NULL;
1291 if(!(mctrack1 = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(4))))) return;
1292 if(!(mctrack2 = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(5))))) return;
1293 TParticle *afterinitialrad1 = mctrack1->Particle();
1294 TParticle *afterinitialrad2 = mctrack2->Particle();
1298 if (abs(afterinitialrad1->GetPdgCode()) == fgkGluon && abs(afterinitialrad2->GetPdgCode()) == fgkGluon){
1299 AliDebug(1,"heavy from gluon gluon pair creation!\n");
1301 motherID = fgkGluon;
1303 else if (abs(afterinitialrad1->GetPdgCode()) == kquark || abs(afterinitialrad2->GetPdgCode()) == kquark){ // one from Q and the other from g
1304 AliDebug(1,"heavy from flavor exitation!\n");
1308 else if (abs(afterinitialrad1->GetPdgCode()) == abs(afterinitialrad2->GetPdgCode())){
1309 AliDebug(1,"heavy from q-qbar pair creation!\n");
1314 AliDebug(1,"something strange!\n");
1321 //__________________________________________
1322 Bool_t AliHFEmcQA::IsFromInitialShower(Int_t inputmotherlabel, Int_t &motherID, Int_t &mothertype, Int_t &motherlabel)
1324 // mothertype -2 means this heavy quark coming from initial state
1326 AliMCParticle *mctrack = NULL;
1327 if (inputmotherlabel==2 || inputmotherlabel==3){ // mother exist before initial state radiation
1328 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(inputmotherlabel))))) return kFALSE;
1329 TParticle *heavysMother = mctrack->Particle();
1330 motherID = heavysMother->GetPdgCode();
1331 mothertype = -2; // there is mother before initial state radiation
1332 motherlabel = inputmotherlabel;
1333 AliDebug(1,"initial parton shower! \n");
1341 //__________________________________________
1342 Bool_t AliHFEmcQA::IsFromFinalParton(Int_t inputmotherlabel, Int_t &motherID, Int_t &mothertype, Int_t &motherlabel)
1344 // mothertype 2 means this heavy quark coming from final state
1346 AliMCParticle *mctrack = NULL;
1347 if (inputmotherlabel > 5){ // mother exist after hard scattering
1348 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(inputmotherlabel))))) return kFALSE;
1349 TParticle *heavysMother = mctrack->Particle();
1350 motherID = heavysMother->GetPdgCode();
1352 motherlabel = inputmotherlabel;
1353 AliDebug(1,Form("heavy quark from %d after hard scattering! \n",motherID));
1360 //__________________________________________
1361 void AliHFEmcQA::ReportStrangeness(Int_t &motherID, Int_t &mothertype, Int_t &motherlabel)
1363 // mark strange behavior
1368 AliDebug(1,"something strange!\n");
1371 //__________________________________________
1372 Int_t AliHFEmcQA::GetSource(const AliVParticle* const mcpart)
1374 // decay particle's origin
1376 //if ( abs(mcpart->GetPdgCode()) != AliHFEmcQA::kElectronPDG ) return -1;
1379 Bool_t isFinalOpenCharm = kFALSE;
1382 AliDebug(1, "Stack label is negative or no mcparticle, return\n");
1387 // Information not in the base class, cast necessary
1388 Int_t iLabel = GetMother(mcpart);
1390 AliDebug(1, "Stack label is negative, return\n");
1394 const AliVParticle *partMother = fMCEvent->GetTrack(iLabel);
1395 Int_t maPdgcode = partMother->PdgCode();
1397 // if the mother is charmed hadron
1398 if ( int(abs(maPdgcode)/100.) == kCharm || int(abs(maPdgcode)/1000.) == kCharm ) {
1400 for (Int_t i=0; i<fNparents; i++){
1401 if (abs(maPdgcode)==fParentSelect[0][i]){
1402 isFinalOpenCharm = kTRUE;
1405 if (!isFinalOpenCharm) return -1;
1407 // iterate until you find B hadron as a mother or become top ancester
1408 for (Int_t i=1; i<fgkMaxIter; i++){
1410 Int_t jLabel = GetMother(partMother);
1412 origin = kDirectCharm;
1415 if (jLabel < 0){ // safety protection
1416 AliDebug(1, "Stack label is negative, return\n");
1420 // if there is an ancester
1421 const AliVParticle* grandMa = fMCEvent->GetTrack(jLabel);
1422 Int_t grandMaPDG = grandMa->PdgCode();
1424 for (Int_t j=0; j<fNparents; j++){
1425 if (abs(grandMaPDG)==fParentSelect[1][j]){
1426 origin = kBeautyCharm;
1431 partMother = grandMa;
1432 } // end of iteration
1434 else if ( int(abs(maPdgcode)/100.) == kBeauty || int(abs(maPdgcode)/1000.) == kBeauty ) {
1435 for (Int_t i=0; i<fNparents; i++){
1436 if (abs(maPdgcode)==fParentSelect[1][i]){
1437 origin = kDirectBeauty;
1442 else if ( abs(maPdgcode) == 22 ) {
1446 else if ( abs(maPdgcode) == 111 ) {
1454 //__________________________________________
1455 Int_t AliHFEmcQA::GetSource(const TParticle * const mcpart)
1457 // decay particle's origin
1459 //if ( abs(mcpart->GetPdgCode()) != AliHFEmcQA::kElectronPDG ) return -1;
1462 Bool_t isFinalOpenCharm = kFALSE;
1465 AliDebug(1, "no mcparticle, return\n");
1469 Int_t iLabel = mcpart->GetFirstMother();
1471 AliDebug(1, "Stack label is negative, return\n");
1475 AliMCParticle *mctrack = NULL;
1476 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(iLabel))))) return -1;
1477 TParticle *partMother = mctrack->Particle();
1478 Int_t maPdgcode = partMother->GetPdgCode();
1480 // if the mother is charmed hadron
1481 if ( int(abs(maPdgcode)/100.) == kCharm || int(abs(maPdgcode)/1000.) == kCharm ) {
1483 for (Int_t i=0; i<fNparents; i++){
1484 if (abs(maPdgcode)==fParentSelect[0][i]){
1485 isFinalOpenCharm = kTRUE;
1488 if (!isFinalOpenCharm) return -1;
1490 // iterate until you find B hadron as a mother or become top ancester
1491 for (Int_t i=1; i<fgkMaxIter; i++){
1493 Int_t jLabel = partMother->GetFirstMother();
1495 origin = kDirectCharm;
1498 if (jLabel < 0){ // safety protection
1499 AliDebug(1, "Stack label is negative, return\n");
1503 // if there is an ancester
1504 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(jLabel))))) return -1;
1505 TParticle* grandMa = mctrack->Particle();
1506 Int_t grandMaPDG = grandMa->GetPdgCode();
1508 for (Int_t j=0; j<fNparents; j++){
1509 if (abs(grandMaPDG)==fParentSelect[1][j]){
1510 origin = kBeautyCharm;
1515 partMother = grandMa;
1516 } // end of iteration
1518 else if ( int(abs(maPdgcode)/100.) == kBeauty || int(abs(maPdgcode)/1000.) == kBeauty ) {
1519 for (Int_t i=0; i<fNparents; i++){
1520 if (abs(maPdgcode)==fParentSelect[1][i]){
1521 origin = kDirectBeauty;
1526 else if ( abs(maPdgcode) == 22 ) {
1530 else if ( abs(maPdgcode) == 111 ) {
1534 else origin = kElse;
1539 //__________________________________________
1540 Int_t AliHFEmcQA::GetElecSource(TParticle * const mcpart)
1542 // decay particle's origin
1545 AliDebug(1, "no mcparticle, return\n");
1549 if ( abs(mcpart->GetPdgCode()) != AliHFEmcQA::kElectronPDG ) return kMisID;
1552 Bool_t isFinalOpenCharm = kFALSE;
1554 Int_t iLabel = mcpart->GetFirstMother();
1556 AliDebug(1, "Stack label is negative, return\n");
1560 AliMCParticle *mctrack = NULL;
1561 Int_t tmpMomLabel=0;
1562 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(iLabel))))) return -1;
1563 TParticle *partMother = mctrack->Particle();
1564 TParticle *partMotherCopy = mctrack->Particle();
1565 Int_t maPdgcode = partMother->GetPdgCode();
1567 // if the mother is charmed hadron
1569 if(abs(maPdgcode)==443){ // J/spi
1570 Int_t jLabel = partMother->GetFirstMother();
1571 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(jLabel))))) return kJpsi;
1572 TParticle* grandMa = mctrack->Particle();
1573 Int_t grandMaPDG = grandMa->GetPdgCode();
1574 if((int(abs(grandMaPDG)/100.)%10) == kBeauty || (int(abs(grandMaPDG)/1000.)%10) == kBeauty) return kB2Jpsi;
1577 else if ( (int(abs(maPdgcode)/100.)%10) == kCharm || (int(abs(maPdgcode)/1000.)%10) == kCharm ) {
1579 for (Int_t i=0; i<fNparents; i++){
1580 if (abs(maPdgcode)==fParentSelect[0][i]){
1581 isFinalOpenCharm = kTRUE;
1584 if (!isFinalOpenCharm) return -1;
1586 // iterate until you find B hadron as a mother or become top ancester
1587 for (Int_t i=1; i<fgkMaxIter; i++){
1589 Int_t jLabel = partMother->GetFirstMother();
1591 return kDirectCharm;
1593 if (jLabel < 0){ // safety protection
1594 AliDebug(1, "Stack label is negative, return\n");
1598 // if there is an ancester
1599 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(jLabel))))) return -1;
1600 TParticle* grandMa = mctrack->Particle();
1601 Int_t grandMaPDG = grandMa->GetPdgCode();
1603 for (Int_t j=0; j<fNparents; j++){
1604 if (abs(grandMaPDG)==fParentSelect[1][j]){
1605 return kBeautyCharm;
1609 partMother = grandMa;
1610 } // end of iteration
1612 else if ( (int(abs(maPdgcode)/100.)%10) == kBeauty || (int(abs(maPdgcode)/1000.)%10) == kBeauty ) {
1613 for (Int_t i=0; i<fNparents; i++){
1614 if (abs(maPdgcode)==fParentSelect[1][i]){
1615 return kDirectBeauty;
1619 else if ( abs(maPdgcode) == 22 ) { //conversion
1621 tmpMomLabel = partMotherCopy->GetFirstMother();
1622 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(tmpMomLabel))))) return -1;
1623 partMother = mctrack->Particle();
1624 maPdgcode = partMother->GetPdgCode();
1625 if ( abs(maPdgcode) == 111 ) {
1628 else if ( abs(maPdgcode) == 221 ) {
1631 else if ( abs(maPdgcode) == 223 ) {
1634 else if ( abs(maPdgcode) == 333 ) {
1637 else if ( abs(maPdgcode) == 331 ) {
1638 return kGammaEtaPrime;
1640 else if ( abs(maPdgcode) == 113 ) {
1643 else origin = kElse;
1647 else if ( abs(maPdgcode) == 111 ) {
1650 else if ( abs(maPdgcode) == 221 ) {
1653 else if ( abs(maPdgcode) == 223 ) {
1656 else if ( abs(maPdgcode) == 333 ) {
1659 else if ( abs(maPdgcode) == 331 ) {
1662 else if ( abs(maPdgcode) == 113 ) {
1665 else if ( abs(maPdgcode) == 321 || abs(maPdgcode) == 130 ) {
1673 //__________________________________________
1674 Double_t AliHFEmcQA::GetWeightFactor(AliMCParticle *mctrack, const Int_t iBgLevel){
1676 // 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)
1678 AliMCParticle *mctrackmother = NULL;
1679 Double_t weightElecBg = 0.;
1680 Double_t mesonPt = 0.;
1681 Double_t bgcategory = 0.;
1683 Int_t mesonID = GetElecSource(mctrack->Particle());
1684 if(mesonID==kGammaPi0 || mesonID==kPi0) mArr=0; //pion
1685 else if(mesonID==kGammaEta || mesonID==kEta) mArr=1; //eta
1686 else if(mesonID==kGammaOmega || mesonID==kOmega) mArr=2; //omega
1687 else if(mesonID==kGammaPhi || mesonID==kPhi) mArr=3; //phi
1688 else if(mesonID==kGammaEtaPrime || mesonID==kEtaPrime) mArr=4; //etaprime
1689 else if(mesonID==kGammaRho0 || mesonID==kRho0) mArr=5; //rho
1691 Double_t datamc[25]={-999,-999,-999,-999,-999,-999,-999,-999,-999,-999,-999,-999,-999,-999,-999,-999, -999, -999, -999, -999, -999, -999, -999, -999, -999};
1692 Double_t xr[3]={-999,-999,-999};
1693 datamc[0] = mesonID;
1694 datamc[17] = mctrack->Pt(); //electron pt
1695 datamc[18] = mctrack->Eta(); //electron eta
1697 mctrack->XvYvZv(xr);
1698 datamc[9] = TMath::Sqrt(xr[0]*xr[0]+xr[1]*xr[1]);
1701 TParticle *mcpart = mctrack->Particle();
1703 datamc[14] = mcpart->GetUniqueID();
1707 if(mesonID>=kGammaPi0) { // conversion electron, be careful with the enum odering
1708 Int_t glabel=TMath::Abs(mctrack->GetMother()); // gamma label
1709 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
1710 glabel=TMath::Abs(mctrackmother->GetMother()); // gamma's mother's label
1711 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
1712 mesonPt = mctrackmother->Pt(); //meson pt
1714 datamc[1] = bgcategory;
1715 datamc[2] = mesonPt;
1716 mctrackmother->XvYvZv(xr);
1717 datamc[11] = TMath::Sqrt(xr[0]*xr[0]+xr[1]*xr[1]);
1720 mcpart = mctrackmother->Particle();
1722 datamc[15] = mcpart->GetUniqueID();
1724 if(glabel>fMCEvent->GetNumberOfPrimaries()) {
1726 datamc[1] = bgcategory;
1727 //printf("I should be gamma meson = %d mesonlabel= %d NumberOfPrimaries= %d \n",mctrackmother->PdgCode(),glabel,fMCEvent->GetNumberOfPrimaries());
1728 glabel=TMath::Abs(mctrackmother->GetMother()); // gamma's mother's mother
1729 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
1730 datamc[3]=mctrackmother->PdgCode();
1731 datamc[4]=mctrackmother->Pt();
1732 if(TMath::Abs(mctrackmother->PdgCode())==310){
1734 glabel=TMath::Abs(mctrackmother->GetMother()); // gamma's mother's mother's mother
1735 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
1736 datamc[5]=mctrackmother->PdgCode();
1737 glabel=TMath::Abs(mctrackmother->GetMother()); // gamma's mother's mother
1738 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
1739 datamc[6]=mctrackmother->PdgCode();
1748 else{ // nonHFE except for the conversion electron
1749 Int_t glabel=TMath::Abs(mctrack->GetMother());
1750 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
1751 mesonPt=mctrackmother->Pt(); //meson pt
1753 datamc[1] = bgcategory;
1754 datamc[2] = mesonPt;
1755 mctrackmother->XvYvZv(xr);
1756 datamc[11] = TMath::Sqrt(xr[0]*xr[0]+xr[1]*xr[1]);
1759 mcpart = mctrackmother->Particle();
1761 datamc[15] = mcpart->GetUniqueID();
1763 if(glabel>fMCEvent->GetNumberOfPrimaries()) {
1765 datamc[1] = bgcategory;
1766 glabel=TMath::Abs(mctrackmother->GetMother()); // gamma's mother's mother
1767 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
1768 datamc[3]=mctrackmother->PdgCode();
1769 datamc[4]=mctrackmother->Pt();
1770 if(TMath::Abs(mctrackmother->PdgCode())==310){
1772 glabel=TMath::Abs(mctrackmother->GetMother()); // gamma's mother's mother's mother
1773 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
1774 datamc[5]=mctrackmother->PdgCode();
1775 glabel=TMath::Abs(mctrackmother->GetMother()); // gamma's mother's mother
1776 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
1777 datamc[6]=mctrackmother->PdgCode();
1788 Int_t centBin = GetWeightCentralityBin(fPerCentrality);
1789 if(centBin < 0)return 0.;
1790 weightElecBg=fElecBackgroundFactor[iBgLevel][centBin][mArr][kBgPtBins-1];
1791 for(int ii=0; ii<kBgPtBins; ii++){
1792 if((mesonPt > fBinLimit[ii]) && (mesonPt < fBinLimit[ii+1])){
1793 weightElecBg = fElecBackgroundFactor[iBgLevel][centBin][mArr][ii];
1799 weightElecBg=fElecBackgroundFactor[iBgLevel][0][mArr][kBgPtBins-1];
1800 for(int ii=0; ii<kBgPtBins; ii++){
1801 if((mesonPt > fBinLimit[ii]) && (mesonPt < fBinLimit[ii+1])){
1802 weightElecBg = fElecBackgroundFactor[iBgLevel][0][mArr][ii];
1809 datamc[13] = weightElecBg;
1810 datamc[16] = Double_t(fContainerStep);
1812 datamc[7] = fHfeImpactR;
1813 datamc[8] = fHfeImpactnsigmaR;
1815 datamc[19] = fRecPt;
1816 datamc[20] = fRecEta;
1817 datamc[21] = fRecPhi;
1818 datamc[22] = fLyrhit;
1819 datamc[23] = fLyrstat;
1820 datamc[24] = fCentrality;
1822 if(fIsDebugStreamerON && fTreeStream){
1824 (*fTreeStream)<<"nonhfeQA"<<
1825 "mesonID="<<datamc[0]<<
1826 "bgcategory="<<datamc[1]<<
1827 "mesonPt="<<datamc[2]<<
1828 "mesonMomPdg="<<datamc[3]<<
1829 "mesonMomPt="<<datamc[4]<<
1830 "mesonGMomPdg="<<datamc[5]<<
1831 "mesonGGMomPdg="<<datamc[6]<<
1832 "eIPAbs="<<datamc[7]<<
1833 "eIPSig="<<datamc[8]<<
1836 "mesonR="<<datamc[11]<<
1837 "mesonZ="<<datamc[12]<<
1838 "weightElecBg="<<datamc[13]<<
1839 "eUniqID="<<datamc[14]<<
1840 "mesonUniqID="<<datamc[15]<<
1841 "containerStep="<<datamc[16]<<
1842 "emcpt="<<datamc[17]<<
1843 "emceta="<<datamc[18]<<
1844 "erecpt="<<datamc[19]<<
1845 "ereceta="<<datamc[20]<<
1846 "erecphi="<<datamc[21]<<
1847 "itshit="<<datamc[22]<<
1848 "itsstat="<<datamc[23]<<
1849 "centrality="<<datamc[24]
1854 Double_t returnval = bgcategory*weightElecBg;
1855 if(TMath::Abs(bgcategory)>1) returnval = bgcategory/2.;
1860 //__________________________________________
1861 Int_t AliHFEmcQA::GetMother(const AliVParticle * const mcpart){
1863 // Wrapper to get the mother label
1866 TClass *type = mcpart->IsA();
1867 if(type == AliMCParticle::Class()){
1869 const AliMCParticle *emcpart = static_cast<const AliMCParticle *>(mcpart);
1870 label = emcpart->GetMother();
1871 } else if(type == AliAODMCParticle::Class()){
1873 const AliAODMCParticle *amcpart = static_cast<const AliAODMCParticle *>(mcpart);
1874 label = amcpart->GetMother();
1878 //__________________________________________
1879 Int_t AliHFEmcQA::GetWeightCentralityBin(const Float_t percentile) const {
1881 //translate the centrality percentile into the centrality bin of the reference weighting histograms for electron background
1884 Float_t centralityLimits[12]= {0.,5.,10., 20., 30., 40., 50., 60.,70.,80., 90., 100.};
1886 for(Int_t ibin = 0; ibin < 11; ibin++){
1887 if(percentile >= centralityLimits[ibin] && percentile < centralityLimits[ibin+1]){
1894 //__________________________________________
1895 void AliHFEmcQA::AliHists::FillList(TList *l) const {
1897 // Fill Histos into a list for output
1899 if(fPdgCode) l->Add(fPdgCode);
1900 if(fPt) l->Add(fPt);
1902 if(fEta) l->Add(fEta);
1905 //__________________________________________
1906 void AliHFEmcQA::AliHistsComm::FillList(TList *l) const {
1908 // Fill Histos into a list for output
1910 if(fNq) l->Add(fNq);
1911 if(fProcessID) l->Add(fProcessID);
1912 if(fePtRatio) l->Add(fePtRatio);
1913 if(fPtCorr) l->Add(fPtCorr);
1914 if(fPtCorrDp) l->Add(fPtCorrDp);
1915 if(fPtCorrD0) l->Add(fPtCorrD0);
1916 if(fPtCorrDrest) l->Add(fPtCorrDrest);
1917 if(fDePtRatio) l->Add(fDePtRatio);
1918 if(feDistance) l->Add(feDistance);
1919 if(fDeDistance) l->Add(fDeDistance);