1 #include "AliAnalysisTaskSE.h"
2 #include "AliAnalysisManager.h"
3 #include "AliAnalysisDataContainer.h"
4 #include "AliESDEvent.h"
5 #include "AliESDtrackCuts.h"
7 #include "AliCentrality.h"
8 #include "AliMCEventHandler.h"
9 #include "AliMCEvent.h"
10 #include "AliHeader.h"
11 #include "AliGenCocktailEventHeader.h"
12 #include "AliGenEventHeader.h"
13 #include "AliGenerator.h"
14 #include "AliVertexingHFUtils.h"
15 #include "AliMultiplicity.h"
16 #include <TParticle.h>
24 #include "AliESDInputHandlerRP.h"
25 #include "AliAnalysisTaskCheckHFMCProd.h"
27 /**************************************************************************
28 * Copyright(c) 1998-2012, ALICE Experiment at CERN, All rights reserved. *
30 * Author: The ALICE Off-line Project. *
31 * Contributors are mentioned in the code where appropriate. *
33 * Permission to use, copy, modify and distribute this software and its *
34 * documentation strictly for non-commercial purposes is hereby granted *
35 * without fee, provided that the above copyright notice appears in all *
36 * copies and that both the copyright notice and this permission notice *
37 * appear in the supporting documentation. The authors make no claims *
38 * about the suitability of this software for any purpose. It is *
39 * provided "as is" without express or implied warranty. *
40 **************************************************************************/
44 //*************************************************************************
45 // Implementation of class AliAnalysisTaskCheckHFMCProd
46 // AliAnalysisTask to check MC production at ESD+Kine level
49 // Authors: F. Prino, prino@to.infn.it
51 //*************************************************************************
53 ClassImp(AliAnalysisTaskCheckHFMCProd)
54 //______________________________________________________________________________
55 AliAnalysisTaskCheckHFMCProd::AliAnalysisTaskCheckHFMCProd() : AliAnalysisTaskSE("HFMCChecks"),
62 fHistoTrackletsEta1(0),
77 fHistOriginFeeddown(0),
83 fHistEtaPhiPtGenEle(0),
84 fHistEtaPhiPtGenPi(0),
86 fHistEtaPhiPtGenPro(0),
87 fHistEtaPhiPtRecEle(0),
88 fHistEtaPhiPtRecPi(0),
90 fHistEtaPhiPtRecPro(0),
91 fSearchUpToQuark(kFALSE),
97 DefineInput(0, TChain::Class());
98 DefineOutput(1, TList::Class());
102 //___________________________________________________________________________
103 AliAnalysisTaskCheckHFMCProd::~AliAnalysisTaskCheckHFMCProd(){
105 if (AliAnalysisManager::GetAnalysisManager()->IsProofMode()) return;
110 delete fESDtrackCuts;
114 //___________________________________________________________________________
115 void AliAnalysisTaskCheckHFMCProd::UserCreateOutputObjects() {
116 // create output histos
118 fOutput = new TList();
120 fOutput->SetName("OutputHistos");
122 fHistoNEvents = new TH1F("hNEvents", "Number of processed events",3,-0.5,2.5);
123 fHistoNEvents->Sumw2();
124 fHistoNEvents->SetMinimum(0);
125 fOutput->Add(fHistoNEvents);
127 Double_t maxMult=100.;
128 if(fSystem==1) maxMult=10000.;
129 if(fSystem==2) maxMult=500.;
130 fHistoPhysPrim = new TH1F("hPhysPrim","",100,-0.5,maxMult-0.5);
131 fHistoPhysPrim->Sumw2();
132 fOutput->Add(fHistoPhysPrim);
133 fHistoTracks = new TH1F("hTracks","",100,-0.5,maxMult*2-0.5);
134 fHistoTracks->Sumw2();
135 fOutput->Add(fHistoTracks);
136 fHistoSelTracks = new TH1F("hSelTracks","",100,-0.5,maxMult-0.5);
137 fHistoSelTracks->Sumw2();
138 fOutput->Add(fHistoSelTracks);
139 fHistoTracklets = new TH1F("hTracklets","",100,-0.5,maxMult-0.5);
140 fHistoTracklets->Sumw2();
141 fOutput->Add(fHistoTracklets);
142 fHistoTrackletsEta1 = new TH1F("hTrackletsEta1","",100,-0.5,maxMult-0.5);
143 fHistoTrackletsEta1->Sumw2();
144 fOutput->Add(fHistoTrackletsEta1);
145 fHistoPtPhysPrim = new TH1F("hPtPhysPrim","",100,0.,20.);
146 fHistoPtPhysPrim->Sumw2();
147 fOutput->Add(fHistoPtPhysPrim);
148 fHistoEtaPhysPrim = new TH1F("hEtaPhysPrim","",100,-10.,10.);
149 fHistoEtaPhysPrim->Sumw2();
150 fOutput->Add(fHistoEtaPhysPrim);
152 fHistoSPD3DVtxX = new TH1F("hSPD3DvX","",100,-1.,1.);
153 fHistoSPD3DVtxX->Sumw2();
154 fOutput->Add(fHistoSPD3DVtxX);
155 fHistoSPD3DVtxY = new TH1F("hSPD3DvY","",100,-1.,1.);
156 fHistoSPD3DVtxY->Sumw2();
157 fOutput->Add(fHistoSPD3DVtxY);
158 fHistoSPD3DVtxZ = new TH1F("hSPD3DvZ","",100,-15.,15.);
159 fHistoSPD3DVtxZ->Sumw2();
160 fOutput->Add(fHistoSPD3DVtxZ);
162 fHistoSPDZVtxX = new TH1F("hSPDZvX","",100,-1.,1.);
163 fHistoSPDZVtxX->Sumw2();
164 fOutput->Add(fHistoSPDZVtxX);
165 fHistoSPDZVtxY = new TH1F("hSPDZvY","",100,-1.,1.);
166 fHistoSPDZVtxY->Sumw2();
167 fOutput->Add(fHistoSPDZVtxY);
168 fHistoSPDZVtxZ = new TH1F("hSPDZvZ","",100,-15.,15.);
169 fHistoSPDZVtxZ->Sumw2();
170 fOutput->Add(fHistoSPDZVtxZ);
173 fHistoTRKVtxX = new TH1F("hTRKvX","",100,-1.,1.);
174 fHistoTRKVtxX->Sumw2();
175 fOutput->Add(fHistoTRKVtxX);
176 fHistoTRKVtxY = new TH1F("hTRKvY","",100,-1.,1.);
177 fHistoTRKVtxY->Sumw2();
178 fOutput->Add(fHistoTRKVtxY);
179 fHistoTRKVtxZ = new TH1F("hTRKvZ","",100,-15.,15.);
180 fHistoTRKVtxZ->Sumw2();
181 fOutput->Add(fHistoTRKVtxZ);
184 if(fSystem==1) nBinscb=200;
185 if(fSystem==2) nBinscb=21;
186 Double_t maxncn=nBinscb-0.5;
187 fHistoNcharmed = new TH2F("hncharmed","",100,-0.5,maxMult-0.5,nBinscb,-0.5,maxncn);
188 fHistoNcharmed->Sumw2();
189 fOutput->Add(fHistoNcharmed);
190 fHistoNbVsNc = new TH2F("hnbvsnc","",nBinscb,-0.5,maxncn,nBinscb,-0.5,maxncn);
191 fHistoNbVsNc->Sumw2();
192 fOutput->Add(fHistoNbVsNc);
194 fHistYPtPrompt[0] = new TH2F("hyptD0prompt","D0 - Prompt",40,0.,40.,20,-2.,2.);
195 fHistYPtPrompt[1] = new TH2F("hyptDplusprompt","Dplus - Prompt",40,0.,40.,20,-2.,2.);
196 fHistYPtPrompt[2] = new TH2F("hyptDstarprompt","Dstar - Prompt",40,0.,40.,20,-2.,2.);
197 fHistYPtPrompt[3] = new TH2F("hyptDsprompt","Ds - Prompt",40,0.,40.,20,-2.,2.);
198 fHistYPtPrompt[4] = new TH2F("hyptLcprompt","Lc - Prompt",40,0.,40.,20,-2.,2.);
200 fHistBYPtAllDecay[0] = new TH2F("hyptB0AllDecay","B0 - All",40,0.,40.,40,-2.,2.);
201 fHistBYPtAllDecay[1] = new TH2F("hyptBplusAllDecay","Bplus - All",40,0.,40.,40,-2.,2.);
202 fHistBYPtAllDecay[2] = new TH2F("hyptBstarAllDecay","Bstar - All",40,0.,40.,40,-2.,2.);
203 fHistBYPtAllDecay[3] = new TH2F("hyptBsAllDecay","Bs - All",40,0.,40.,40,-2.,2.);
204 fHistBYPtAllDecay[4] = new TH2F("hyptLbAllDecay","LB - All",40,0.,40.,40,-2.,2.);
206 fHistYPtAllDecay[0] = new TH2F("hyptD0AllDecay","D0 - All",40,0.,40.,40,-2.,2.);
207 fHistYPtAllDecay[1] = new TH2F("hyptDplusAllDecay","Dplus - All",40,0.,40.,40,-2.,2.);
208 fHistYPtAllDecay[2] = new TH2F("hyptDstarAllDecay","Dstar - All",40,0.,40.,40,-2.,2.);
209 fHistYPtAllDecay[3] = new TH2F("hyptDsAllDecay","Ds - All",40,0.,40.,40,-2.,2.);
210 fHistYPtAllDecay[4] = new TH2F("hyptLcAllDecay","Lc - All",40,0.,40.,40,-2.,2.);
212 fHistYPtPromptAllDecay[0] = new TH2F("hyptD0promptAllDecay","D0 - Prompt",40,0.,40.,40,-2.,2.);
213 fHistYPtPromptAllDecay[1] = new TH2F("hyptDpluspromptAllDecay","Dplus - Prompt",40,0.,40.,40,-2.,2.);
214 fHistYPtPromptAllDecay[2] = new TH2F("hyptDstarpromptAllDecay","Dstar - Prompt",40,0.,40.,40,-2.,2.);
215 fHistYPtPromptAllDecay[3] = new TH2F("hyptDspromptAllDecay","Ds - Prompt",40,0.,40.,40,-2.,2.);
216 fHistYPtPromptAllDecay[4] = new TH2F("hyptLcpromptAllDecay","Lc - Prompt",40,0.,40.,40,-2.,2.);
218 fHistYPtFeeddownAllDecay[0] = new TH2F("hyptD0feeddownAllDecay","D0 - FromB",40,0.,40.,40,-2.,2.);
219 fHistYPtFeeddownAllDecay[1] = new TH2F("hyptDplusfeeddownAllDecay","Dplus - FromB",40,0.,40.,40,-2.,2.);
220 fHistYPtFeeddownAllDecay[2] = new TH2F("hyptDstarfeeddownAllDecay","Dstar - FromB",40,0.,40.,40,-2.,2.);
221 fHistYPtFeeddownAllDecay[3] = new TH2F("hyptDsfeeddownAllDecay","Ds - FromB",40,0.,40.,40,-2.,2.);
222 fHistYPtFeeddownAllDecay[4] = new TH2F("hyptLcfeeddownAllDecay","Lc - FromB",40,0.,40.,40,-2.,2.);
225 fHistYPtFeeddown[0] = new TH2F("hyptD0feeddown","D0 - Feeddown",40,0.,40.,20,-2.,2.);
226 fHistYPtFeeddown[1] = new TH2F("hyptDplusfeeddown","Dplus - Feeddown",40,0.,40.,20,-2.,2.);
227 fHistYPtFeeddown[2] = new TH2F("hyptDstarfeedown","Dstar - Feeddown",40,0.,40.,20,-2.,2.);
228 fHistYPtFeeddown[3] = new TH2F("hyptDsfeedown","Ds - Feeddown",40,0.,40.,20,-2.,2.);
229 fHistYPtFeeddown[4] = new TH2F("hyptLcfeedown","Lc - Feeddown",40,0.,40.,20,-2.,2.);
231 for(Int_t ih=0; ih<5; ih++){
232 fHistBYPtAllDecay[ih]->Sumw2();
233 fHistBYPtAllDecay[ih]->SetMinimum(0);
234 fOutput->Add(fHistBYPtAllDecay[ih]);
235 fHistYPtAllDecay[ih]->Sumw2();
236 fHistYPtAllDecay[ih]->SetMinimum(0);
237 fOutput->Add(fHistYPtAllDecay[ih]);
238 fHistYPtPromptAllDecay[ih]->Sumw2();
239 fHistYPtPromptAllDecay[ih]->SetMinimum(0);
240 fOutput->Add(fHistYPtPromptAllDecay[ih]);
241 fHistYPtFeeddownAllDecay[ih]->Sumw2();
242 fHistYPtFeeddownAllDecay[ih]->SetMinimum(0);
243 fOutput->Add(fHistYPtFeeddownAllDecay[ih]);
244 fHistYPtPrompt[ih]->Sumw2();
245 fHistYPtPrompt[ih]->SetMinimum(0);
246 fOutput->Add(fHistYPtPrompt[ih]);
247 fHistYPtFeeddown[ih]->Sumw2();
248 fHistYPtFeeddown[ih]->SetMinimum(0);
249 fOutput->Add(fHistYPtFeeddown[ih]);
252 fHistYPtD0byDecChannel[0] = new TH2F("hyptD02","D0 - 2prong",40,0.,40.,20,-2.,2.);
253 fHistYPtD0byDecChannel[1] = new TH2F("hyptD04","D0 - 4prong",40,0.,40.,20,-2.,2.);
254 fHistYPtDplusbyDecChannel[0] = new TH2F("hyptDplusnonreson","Dplus - non reson",40,0.,40.,20,-2.,2.);
255 fHistYPtDplusbyDecChannel[1] = new TH2F("hyptDplusreson","Dplus - reson via K0*",40,0.,40.,20,-2.,2.);
256 fHistYPtDplusbyDecChannel[2] = new TH2F("hyptDplusKKpi","Dplus -> KKpi",40,0.,40.,20,-2.,2.);
257 fHistYPtDsbyDecChannel[0] = new TH2F("hyptDsphi","Ds - vis Phi",40,0.,40.,20,-2.,2.);
258 fHistYPtDsbyDecChannel[1] = new TH2F("hyptDsk0st","Ds - via k0*",40,0.,40.,20,-2.,2.);
260 for(Int_t ih=0; ih<2; ih++){
262 fHistYPtD0byDecChannel[ih]->Sumw2();
263 fHistYPtD0byDecChannel[ih]->SetMinimum(0);
264 fOutput->Add(fHistYPtD0byDecChannel[ih]);
265 fHistYPtDplusbyDecChannel[ih]->Sumw2();
266 fHistYPtDplusbyDecChannel[ih]->SetMinimum(0);
267 fOutput->Add(fHistYPtDplusbyDecChannel[ih]);
268 fHistYPtDsbyDecChannel[ih]->Sumw2();
269 fHistYPtDsbyDecChannel[ih]->SetMinimum(0);
270 fOutput->Add(fHistYPtDsbyDecChannel[ih]);
272 fHistYPtDplusbyDecChannel[2]->Sumw2();
273 fHistYPtDplusbyDecChannel[2]->SetMinimum(0);
274 fOutput->Add(fHistYPtDplusbyDecChannel[2]);
276 fHistOriginPrompt=new TH1F("hOriginPrompt","",100,0.,0.5);
277 fHistOriginPrompt->Sumw2();
278 fHistOriginPrompt->SetMinimum(0);
279 fOutput->Add(fHistOriginPrompt);
280 fHistOriginFeeddown=new TH1F("hOriginFeeddown","",100,0.,0.5);
281 fHistOriginFeeddown->Sumw2();
282 fHistOriginFeeddown->SetMinimum(0);
283 fOutput->Add(fHistOriginFeeddown);
284 fHistMotherID=new TH1F("hMotherID","",1000,-1.5,998.5);
285 fHistMotherID->SetMinimum(0);
286 fOutput->Add(fHistMotherID);
287 fHistDSpecies=new TH1F("hDSpecies","",10,-0.5,9.5);
288 fHistDSpecies->GetXaxis()->SetBinLabel(1,"D0");
289 fHistDSpecies->GetXaxis()->SetBinLabel(2,"D0bar");
290 fHistDSpecies->GetXaxis()->SetBinLabel(3,"D+");
291 fHistDSpecies->GetXaxis()->SetBinLabel(4,"D-");
292 fHistDSpecies->GetXaxis()->SetBinLabel(5,"D*+");
293 fHistDSpecies->GetXaxis()->SetBinLabel(6,"D*-");
294 fHistDSpecies->GetXaxis()->SetBinLabel(7,"Ds+");
295 fHistDSpecies->GetXaxis()->SetBinLabel(8,"Ds-");
296 fHistDSpecies->GetXaxis()->SetBinLabel(9,"Lc+");
297 fHistDSpecies->GetXaxis()->SetBinLabel(10,"Lc-");
298 fHistDSpecies->SetMinimum(0);
299 fOutput->Add(fHistDSpecies);
300 fHistBSpecies=new TH1F("hBSpecies","",10,-0.5,9.5);
301 fHistBSpecies->GetXaxis()->SetBinLabel(1,"B0");
302 fHistBSpecies->GetXaxis()->SetBinLabel(2,"B0bar");
303 fHistBSpecies->GetXaxis()->SetBinLabel(3,"B+");
304 fHistBSpecies->GetXaxis()->SetBinLabel(4,"B-");
305 fHistBSpecies->GetXaxis()->SetBinLabel(5,"B*+");
306 fHistBSpecies->GetXaxis()->SetBinLabel(6,"B*-");
307 fHistBSpecies->GetXaxis()->SetBinLabel(7,"Bs+");
308 fHistBSpecies->GetXaxis()->SetBinLabel(8,"Bs-");
309 fHistBSpecies->GetXaxis()->SetBinLabel(9,"Lb+");
310 fHistBSpecies->GetXaxis()->SetBinLabel(10,"Lb-");
311 fHistBSpecies->SetMinimum(0);
312 fOutput->Add(fHistBSpecies);
313 fHistLcDecayChan=new TH1F("hLcDecayChan","",9,-2.5,6.5);
314 fHistLcDecayChan->GetXaxis()->SetBinLabel(1,"Violates p cons");
315 fHistLcDecayChan->GetXaxis()->SetBinLabel(2,"Other decay");
316 fHistLcDecayChan->GetXaxis()->SetBinLabel(3,"Error");
317 fHistLcDecayChan->GetXaxis()->SetBinLabel(4,"pK#pi non res");
318 fHistLcDecayChan->GetXaxis()->SetBinLabel(5,"pK#pi via K*0");
319 fHistLcDecayChan->GetXaxis()->SetBinLabel(6,"pK#pi via #Delta++");
320 fHistLcDecayChan->GetXaxis()->SetBinLabel(7,"pK#pi via #Lambda1520");
321 fHistLcDecayChan->GetXaxis()->SetBinLabel(8,"pK0s#rightarrowp#pi#pi");
322 fHistLcDecayChan->GetXaxis()->SetBinLabel(9,"#pi#Lambda#rightarrowp#pi#pi");
323 fHistLcDecayChan->SetMinimum(0);
324 fOutput->Add(fHistLcDecayChan);
326 fHistNcollHFtype=new TH2F("hNcollHFtype","",5,-1.5,3.5,30,-0.5,29.5);
327 fOutput->Add(fHistNcollHFtype);
329 Double_t binseta[11]={-1.0,-0.8,-0.6,-0.4,-0.2,0.,0.2,0.4,0.6,0.8,1.0};
330 const Int_t nBinsPhi=40;
331 Double_t binsphi[nBinsPhi+1];
332 for(Int_t ib=0; ib<=nBinsPhi; ib++) binsphi[ib]=ib*TMath::Pi()/20.;
333 const Int_t nBinsPt=24;
334 Double_t binspt[nBinsPt+1]={0.,0.10,0.15,0.2,0.25,
340 fHistEtaPhiPtGenEle=new TH3F("hEtaPhiPtGenEle","",10,binseta,nBinsPhi,binsphi,nBinsPt,binspt);
341 fOutput->Add(fHistEtaPhiPtGenEle);
342 fHistEtaPhiPtGenPi=new TH3F("hEtaPhiPtGenPi","",10,binseta,nBinsPhi,binsphi,nBinsPt,binspt);
343 fOutput->Add(fHistEtaPhiPtGenPi);
344 fHistEtaPhiPtGenK=new TH3F("hEtaPhiPtGenK","",10,binseta,nBinsPhi,binsphi,nBinsPt,binspt);
345 fOutput->Add(fHistEtaPhiPtGenK);
346 fHistEtaPhiPtGenPro=new TH3F("hEtaPhiPtGenPro","",10,binseta,nBinsPhi,binsphi,nBinsPt,binspt);
347 fOutput->Add(fHistEtaPhiPtGenPro);
350 fHistEtaPhiPtRecEle=new TH3F("hEtaPhiPtRecEle","",10,binseta,nBinsPhi,binsphi,nBinsPt,binspt);
351 fOutput->Add(fHistEtaPhiPtRecEle);
352 fHistEtaPhiPtRecPi=new TH3F("hEtaPhiPtRecPi","",10,binseta,nBinsPhi,binsphi,nBinsPt,binspt);
353 fOutput->Add(fHistEtaPhiPtRecPi);
354 fHistEtaPhiPtRecK=new TH3F("hEtaPhiPtRecK","",10,binseta,nBinsPhi,binsphi,nBinsPt,binspt);
355 fOutput->Add(fHistEtaPhiPtRecK);
356 fHistEtaPhiPtRecPro=new TH3F("hEtaPhiPtRecPro","",10,binseta,nBinsPhi,binsphi,nBinsPt,binspt);
357 fOutput->Add(fHistEtaPhiPtRecPro);
364 //______________________________________________________________________________
365 void AliAnalysisTaskCheckHFMCProd::UserExec(Option_t *)
369 AliESDEvent *esd = (AliESDEvent*) (InputEvent());
373 printf("AliAnalysisTaskSDDRP::Exec(): bad ESD\n");
377 fHistoNEvents->Fill(0);
381 if(esd->GetRunNumber()<=139517) year=2010;
382 if(year==2010) fESDtrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kFALSE);
383 else fESDtrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kFALSE);
384 fESDtrackCuts->SetMaxDCAToVertexXY(2.4);
385 fESDtrackCuts->SetMaxDCAToVertexZ(3.2);
386 fESDtrackCuts->SetDCAToVertex2D(kTRUE);
387 fESDtrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,
388 AliESDtrackCuts::kAny);
391 Int_t nTracks=esd->GetNumberOfTracks();
392 fHistoTracks->Fill(nTracks);
394 for(Int_t it=0; it<nTracks; it++){
395 AliESDtrack* tr=esd->GetTrack(it);
396 UInt_t status=tr->GetStatus();
397 if(!(status&AliESDtrack::kITSrefit)) continue;
398 if(!(status&AliESDtrack::kTPCin)) continue;
401 fHistoSelTracks->Fill(nSelTracks);
403 const AliMultiplicity* mult=esd->GetMultiplicity();
404 Int_t nTracklets=mult->GetNumberOfTracklets();
406 for(Int_t it=0; it<nTracklets; it++){
407 Double_t eta=TMath::Abs(mult->GetEta(it));
408 if(eta<1) nTracklets1++;
410 fHistoTracklets->Fill(nTracklets);
411 fHistoTrackletsEta1->Fill(nTracklets1);
413 const AliESDVertex *spdv=esd->GetVertex();
414 if(spdv && spdv->IsFromVertexer3D()){
415 fHistoSPD3DVtxX->Fill(spdv->GetX());
416 fHistoSPD3DVtxY->Fill(spdv->GetY());
417 fHistoSPD3DVtxZ->Fill(spdv->GetZ());
419 if(spdv && spdv->IsFromVertexerZ()){
420 fHistoSPDZVtxX->Fill(spdv->GetX());
421 fHistoSPDZVtxY->Fill(spdv->GetY());
422 fHistoSPDZVtxZ->Fill(spdv->GetZ());
424 const AliESDVertex *trkv=esd->GetPrimaryVertex();
425 if(trkv && trkv->GetNContributors()>1){
426 fHistoTRKVtxX->Fill(trkv->GetX());
427 fHistoTRKVtxY->Fill(trkv->GetY());
428 fHistoTRKVtxZ->Fill(trkv->GetZ());
433 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
435 Printf("ERROR: Could not retrieve MC event handler");
438 AliMCEvent* mcEvent = eventHandler->MCEvent();
440 Printf("ERROR: Could not retrieve MC event");
443 stack = mcEvent->Stack();
445 Printf("ERROR: stack not available");
448 const AliVVertex* mcVert=mcEvent->GetPrimaryVertex();
450 Printf("ERROR: generated vertex not available");
453 if(TMath::Abs(mcVert->GetZ())>10) return;
455 // const AliHeader* h=(AliHeader*)mcEvent->GetHeader();
457 TString genname=mcEvent->GenEventHeader()->ClassName();
461 if(genname.Contains("CocktailEventHeader")){
462 AliGenCocktailEventHeader *cockhead=(AliGenCocktailEventHeader*)mcEvent->GenEventHeader();
463 lgen=cockhead->GetHeaders();
464 for(Int_t ig=0; ig<lgen->GetEntries(); ig++){
465 AliGenerator* gen=(AliGenerator*)lgen->At(ig);
466 TString title=gen->GetName();
467 if(title.Contains("bchadr")) typeHF=1;
468 else if(title.Contains("chadr")) typeHF=0;
469 else if(title.Contains("bele")) typeHF=3;
470 else if(title.Contains("cele")) typeHF=2;
472 nColl=lgen->GetEntries();
473 fHistNcollHFtype->Fill(typeHF,nColl);
475 TString genTitle=mcEvent->GenEventHeader()->GetTitle();
476 if(genTitle.Contains("bchadr")) typeHF=1;
477 else if(genTitle.Contains("chadr")) typeHF=0;
478 else if(genTitle.Contains("bele")) typeHF=3;
479 else if(genTitle.Contains("cele")) typeHF=2;
480 fHistNcollHFtype->Fill(typeHF,1.);
482 Int_t nParticles=stack->GetNtrack();
483 Double_t dNchdy = 0.;
487 for (Int_t i=0;i<nParticles;i++){
488 TParticle* part = (TParticle*)stack->Particle(i);
489 Int_t absPdg=TMath::Abs(part->GetPdgCode());
490 Int_t pdg=part->GetPdgCode();
493 if(stack->IsPhysicalPrimary(i)){
494 Double_t eta=part->Eta();
495 fHistoEtaPhysPrim->Fill(eta);
496 if(absPdg==11) fHistEtaPhiPtGenEle->Fill(eta,part->Phi(),part->Pt());
497 else if(absPdg==211) fHistEtaPhiPtGenPi->Fill(eta,part->Phi(),part->Pt());
498 else if(absPdg==321) fHistEtaPhiPtGenK->Fill(eta,part->Phi(),part->Pt());
499 else if(absPdg==2212) fHistEtaPhiPtGenPro->Fill(eta,part->Phi(),part->Pt());
501 if(TMath::Abs(eta)<0.5){
502 dNchdy+=0.6666; // 2/3 for the ratio charged/all
505 if(TMath::Abs(eta)<0.9){
506 fHistoPtPhysPrim->Fill(part->Pt());
510 if (part->Energy() != TMath::Abs(part->Pz())){
511 rapid=0.5*TMath::Log((part->Energy()+part->Pz())/(part->Energy()-part->Pz()));
521 iType=AliVertexingHFUtils::CheckD0Decay(stack,i,dummy);
524 else if(absPdg==411){
526 iType=AliVertexingHFUtils::CheckDplusDecay(stack,i,dummy);
528 Int_t iTypeKKpi=AliVertexingHFUtils::CheckDplusKKpiDecay(stack,i,dummy);
529 if(iTypeKKpi>0) iType=3;
533 else if(absPdg==413){
535 iType=AliVertexingHFUtils::CheckDstarDecay(stack,i,dummy);
538 else if(absPdg==431){
540 iType=AliVertexingHFUtils::CheckDsDecay(stack,i,dummy);
541 if(iType==1 || iType==2) iPart=3;
543 else if(absPdg==4122){
545 iType=AliVertexingHFUtils::CheckLcpKpiDecay(stack,i,dummy);
547 Int_t iTypeV0=AliVertexingHFUtils::CheckLcV0bachelorDecay(stack,i,dummy);
548 if(iTypeV0==1) iType=5;
549 if(iTypeV0==2) iType=6;
551 fHistLcDecayChan->Fill(iType);
552 if(iType>=0) iPart=4;
554 if(iSpecies>=0) fHistYPtAllDecay[iSpecies]->Fill(part->Pt(),rapid);
556 // check beauty mesons
557 if(absPdg==511) fHistBYPtAllDecay[0]->Fill(part->Pt(),rapid);
558 else if(absPdg==521) fHistBYPtAllDecay[1]->Fill(part->Pt(),rapid);
559 else if(absPdg==513) fHistBYPtAllDecay[2]->Fill(part->Pt(),rapid);
560 else if(absPdg==531) fHistBYPtAllDecay[3]->Fill(part->Pt(),rapid);
561 else if(absPdg==5122) fHistBYPtAllDecay[4]->Fill(part->Pt(),rapid);
563 if(pdg==511) fHistBSpecies->Fill(0);
564 else if(pdg==-511) fHistBSpecies->Fill(1);
565 else if(pdg==521) fHistBSpecies->Fill(2);
566 else if(pdg==-521) fHistBSpecies->Fill(3);
567 else if(pdg==513) fHistBSpecies->Fill(4);
568 else if(pdg==-513) fHistBSpecies->Fill(5);
569 else if(pdg==531) fHistBSpecies->Fill(6);
570 else if(pdg==-531) fHistBSpecies->Fill(7);
571 else if(pdg==5122) fHistBSpecies->Fill(8);
572 else if(pdg==-5122) fHistBSpecies->Fill(9);
574 if(iSpecies<0) continue; // not a charm meson
576 if(pdg==421) fHistDSpecies->Fill(0);
577 else if(pdg==-421) fHistDSpecies->Fill(1);
578 else if(pdg==411) fHistDSpecies->Fill(2);
579 else if(pdg==-411) fHistDSpecies->Fill(3);
580 else if(pdg==413) fHistDSpecies->Fill(4);
581 else if(pdg==-413) fHistDSpecies->Fill(5);
582 else if(pdg==431) fHistDSpecies->Fill(6);
583 else if(pdg==-431) fHistDSpecies->Fill(7);
584 else if(pdg==4122) fHistDSpecies->Fill(8);
585 else if(pdg==-4122) fHistDSpecies->Fill(9);
587 Double_t distx=part->Vx()-mcVert->GetX();
588 Double_t disty=part->Vy()-mcVert->GetY();
589 Double_t distz=part->Vz()-mcVert->GetZ();
590 Double_t distToVert=TMath::Sqrt(distx*distx+disty*disty+distz*distz);
591 fHistMotherID->Fill(part->GetFirstMother());
592 Int_t iFromB=AliVertexingHFUtils::CheckOrigin(stack,part,fSearchUpToQuark);
594 fHistYPtPromptAllDecay[iSpecies]->Fill(part->Pt(),rapid);
595 fHistOriginPrompt->Fill(distToVert);
598 fHistYPtFeeddownAllDecay[iSpecies]->Fill(part->Pt(),rapid);
599 fHistOriginFeeddown->Fill(distToVert);
602 if(iPart<0) continue;
603 if(iType<0) continue;
605 if(iPart==0 && iType>0 && iType<=2){
606 fHistYPtD0byDecChannel[iType-1]->Fill(part->Pt(),rapid);
607 }else if(iPart==1 && iType>0 && iType<=3){
608 fHistYPtDplusbyDecChannel[iType-1]->Fill(part->Pt(),rapid);
609 }else if(iPart==3 && iType>0 && iType<=2){
610 fHistYPtDsbyDecChannel[iType-1]->Fill(part->Pt(),rapid);
613 if(iFromB==4 && iPart>=0 && iPart<5) fHistYPtPrompt[iPart]->Fill(part->Pt(),rapid);
614 else if(iFromB==5 && iPart>=0 && iPart<5) fHistYPtFeeddown[iPart]->Fill(part->Pt(),rapid);
617 for(Int_t i=0; i<nTracks; i++){
618 AliESDtrack* track=esd->GetTrack(i);
619 if(fESDtrackCuts->AcceptTrack(track)){
620 Int_t label=TMath::Abs(track->GetLabel());
621 if(stack->IsPhysicalPrimary(label)){
622 TParticle* part = (TParticle*)stack->Particle(label);
623 Int_t absPdg=TMath::Abs(part->GetPdgCode());
624 Double_t eta=part->Eta();
625 if(absPdg==11) fHistEtaPhiPtRecEle->Fill(eta,part->Phi(),part->Pt());
626 else if(absPdg==211) fHistEtaPhiPtRecPi->Fill(eta,part->Phi(),part->Pt());
627 else if(absPdg==321) fHistEtaPhiPtRecK->Fill(eta,part->Phi(),part->Pt());
628 else if(absPdg==2212) fHistEtaPhiPtRecPro->Fill(eta,part->Phi(),part->Pt());
632 fHistoNcharmed->Fill(dNchdy,nCharmed);
633 fHistoNbVsNc->Fill(nc,nb);
634 fHistoPhysPrim->Fill(nPhysPrim);
640 //______________________________________________________________________________
641 void AliAnalysisTaskCheckHFMCProd::Terminate(Option_t */*option*/)
643 // Terminate analysis
644 fOutput = dynamic_cast<TList*> (GetOutputData(1));
646 printf("ERROR: fOutput not available\n");
656 //______________________________________________________________________________
657 Int_t AliAnalysisTaskCheckHFMCProd::CheckLcDecay(Int_t labLc, AliStack* stack) const{
658 if(labLc<0) return -1;
659 TParticle* dp = (TParticle*)stack->Particle(labLc);
660 Int_t pdgdp=dp->GetPdgCode();
661 Int_t nDau=dp->GetNDaughters();
667 for(Int_t iDau=dp->GetFirstDaughter(); iDau<=dp->GetLastDaughter(); iDau++){
668 if(iDau<0) return -1;
669 TParticle* dau=(TParticle*)stack->Particle(iDau);
670 Int_t pdgdau=dau->GetPdgCode();
671 if(TMath::Abs(pdgdau)==321){
672 if(pdgdp>0 && pdgdau>0) return -1;
673 if(pdgdp<0 && pdgdau<0) return -1;
675 }else if(TMath::Abs(pdgdau)==211){
676 if(pdgdp<0 && pdgdau>0) return -1;
677 if(pdgdp>0 && pdgdau<0) return -1;
679 }else if(TMath::Abs(pdgdau)==2212){
680 if(pdgdp<0 && pdgdau>0) return -1;
681 if(pdgdp>0 && pdgdau<0) return -1;
687 if(nPions!=1) return -1;
688 if(nKaons!=1) return -1;
689 if(nProtons!=1) return -1;
690 for(Int_t iDau=dp->GetFirstDaughter(); iDau<=dp->GetLastDaughter(); iDau++){
691 if(iDau<0) return -1;
700 for(Int_t iDau=dp->GetFirstDaughter(); iDau<=dp->GetLastDaughter(); iDau++){
701 if(iDau<0) return -1;
702 TParticle* dau=(TParticle*)stack->Particle(iDau);
703 Int_t pdgdau=dau->GetPdgCode();
704 if(TMath::Abs(pdgdau)==313 || TMath::Abs(pdgdau)==3124 || TMath::Abs(pdgdau)==2224
705 || TMath::Abs(pdgdau)==3122 || TMath::Abs(pdgdau)==311){
706 Int_t nDauRes=dau->GetNDaughters();
707 if(nDauRes!=2) return -1;
708 for(Int_t resDau=dau->GetFirstDaughter(); resDau<=dau->GetLastDaughter(); resDau++){
709 if(resDau<0) return -1;
710 TParticle* resdau=(TParticle*)stack->Particle(resDau);
711 Int_t pdgresdau=resdau->GetPdgCode();
712 if(TMath::Abs(pdgresdau)==321){
713 if(pdgdp>0 && pdgresdau>0) return -1;
714 if(pdgdp<0 && pdgresdau<0) return -1;
717 if(TMath::Abs(pdgresdau)==211){
718 if(pdgdp<0 && pdgresdau>0) return -1;
719 if(pdgdp>0 && pdgresdau<0) return -1;
722 if(TMath::Abs(pdgresdau)==2212){
723 if(pdgdp<0 && pdgresdau>0) return -1;
724 if(pdgdp>0 && pdgresdau<0) return -1;
728 }else if(TMath::Abs(pdgdau)==321){
729 if(pdgdp>0 && pdgdau>0) return -1;
730 if(pdgdp<0 && pdgdau<0) return -1;
732 }else if(TMath::Abs(pdgdau)==211){
733 if(pdgdp<0 && pdgdau>0) return -1;
734 if(pdgdp>0 && pdgdau<0) return -1;
736 }else if(TMath::Abs(pdgdau)==2212){
737 if(pdgdp<0 && pdgdau>0) return -1;
738 if(pdgdp>0 && pdgdau<0) return -1;
744 if(nPions!=1) return -1;
745 if(nKaons!=1) return -1;
746 if(nProtons!=1) return -1;
747 for(Int_t iDau=dp->GetFirstDaughter(); iDau<=dp->GetLastDaughter(); iDau++){
748 if(iDau<0) return -1;