1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Authors: Svein Lindal, Daniel Lohner *
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 ////////////////////////////////////////////////
17 //---------------------------------------------
18 // QA Task for V0 Reader V1
19 //---------------------------------------------
20 ////////////////////////////////////////////////
22 #include "AliAnalysisTaskConversionQA.h"
24 #include "AliAnalysisManager.h"
25 #include "TParticle.h"
27 #include "AliPIDResponse.h"
29 #include "AliESDtrackCuts.h"
30 #include "AliAODMCParticle.h"
31 #include "AliAODMCHeader.h"
38 ClassImp(AliAnalysisTaskConversionQA)
40 //________________________________________________________________________
41 AliAnalysisTaskConversionQA::AliAnalysisTaskConversionQA() : AliAnalysisTaskSE(),
43 fConversionGammas(NULL),
44 fConversionCuts(NULL),
46 fNumberOfESDTracks(0),
52 ffillHistograms(kFALSE),
57 hNGoodESDTracks(NULL),
59 hNContributorsVertex(NULL),
64 hGammaChi2perNDF(NULL),
67 hGammaCosinePointingAngle(NULL),
73 hElecNfindableClsTPC(NULL),
74 hPosiNfindableClsTPC(NULL),
77 hTrueResolutionR(NULL),
78 hTrueResolutionZ(NULL),
79 hTrueResolutionPhi(NULL),
84 hTrueGammaChi2perNDF(NULL),
85 hTrueGammaPsiPair(NULL),
87 hTrueGammaCosinePointingAngle(NULL),
93 hTrueElecNfindableClsTPC(NULL),
94 hTruePosiNfindableClsTPC(NULL),
104 fnGammaCandidates(1),
111 AliAnalysisTaskConversionQA::AliAnalysisTaskConversionQA(const char *name) : AliAnalysisTaskSE(name),
113 fConversionGammas(NULL),
114 fConversionCuts(NULL),
116 fNumberOfESDTracks(0),
122 ffillHistograms(kFALSE),
127 hNGoodESDTracks(NULL),
129 hNContributorsVertex(NULL),
130 hITSClusterPhi(NULL),
134 hGammaChi2perNDF(NULL),
137 hGammaCosinePointingAngle(NULL),
143 hElecNfindableClsTPC(NULL),
144 hPosiNfindableClsTPC(NULL),
147 hTrueResolutionR(NULL),
148 hTrueResolutionZ(NULL),
149 hTrueResolutionPhi(NULL),
153 hTrueGammaMass(NULL),
154 hTrueGammaChi2perNDF(NULL),
155 hTrueGammaPsiPair(NULL),
157 hTrueGammaCosinePointingAngle(NULL),
163 hTrueElecNfindableClsTPC(NULL),
164 hTruePosiNfindableClsTPC(NULL),
165 hTrueElecAsymP(NULL),
174 fnGammaCandidates(1),
178 // Default constructor
180 DefineInput(0, TChain::Class());
181 DefineOutput(1, TList::Class());
184 //________________________________________________________________________
185 AliAnalysisTaskConversionQA::~AliAnalysisTaskConversionQA()
187 // default deconstructor
190 //________________________________________________________________________
191 void AliAnalysisTaskConversionQA::UserCreateOutputObjects()
193 // Create User Output Objects
195 if(fOutputList != NULL){
199 if(fOutputList == NULL){
200 fOutputList = new TList();
201 fOutputList->SetOwner(kTRUE);
206 fESDList = new TList();
207 fESDList->SetOwner(kTRUE);
208 fESDList->SetName("ESD QA");
209 fOutputList->Add(fESDList);
211 hVertexZ = new TH1F("Vertex_Z","Vertex_Z",300,-15,15);
212 fESDList->Add(hVertexZ);
213 hNContributorsVertex = new TH1I("ContrVertex_Z","ContrVertex_Z",3000,0,3000);
214 fESDList->Add(hNContributorsVertex);
215 if(fIsHeavyIon) hNGoodESDTracks = new TH1I("GoodESDTracks","GoodESDTracks",3000,0,3000);
216 else hNGoodESDTracks = new TH1I("GoodESDTracks","GoodESDTracks",200,0,200);
217 fESDList->Add(hNGoodESDTracks);
218 if(fIsHeavyIon) hNV0Tracks = new TH1I("V0 Multiplicity","V0 Multiplicity",30000,0,30000);
219 else hNV0Tracks = new TH1I("V0 Multiplicity","V0 Multiplicity",2000,0,2000);
220 fESDList->Add(hNV0Tracks);
222 hITSClusterPhi = new TH2F("ITSClusterPhi","hITSClusterPhi",72,0,2*TMath::Pi(),7,0,7);
223 fESDList->Add(hITSClusterPhi);
224 hGammaPt = new TH1F("Gamma_Pt","Gamma_Pt",250,0,25);
225 fESDList->Add(hGammaPt);
226 hGammaPhi = new TH1F("Gamma_Phi","Gamma_Phi",360,0,2*TMath::Pi());
227 fESDList->Add(hGammaPhi);
228 hGammaEta = new TH1F("Gamma_Eta","Gamma_Eta",600,-1.5,1.5);
229 fESDList->Add(hGammaEta);
230 hGammaChi2perNDF = new TH1F("Gamma_Chi2perNDF","Gamma_Chi2perNDF",500,0,100);
231 fESDList->Add(hGammaChi2perNDF);
232 hGammaPsiPair = new TH1F("Gamma_PsiPair","Gamma_PsiPair",500,0,2);
233 fESDList->Add(hGammaPsiPair);
234 hGammaQt = new TH1F("Gamma_Qt","Gamma_Qt",400,0,0.1);
235 fESDList->Add(hGammaQt);
236 hGammaCosinePointingAngle = new TH1F("Gamma_CosinePointingAngle","Gamma_CosinePointingAngle",900,0.7,1.);
237 fESDList->Add(hGammaCosinePointingAngle);
238 hGammaXY = new TH2F("Gamma_ConversionPoint_XY","Gamma_ConversionPoint_XY",960,-120,120,960,-120,120);
239 fESDList->Add(hGammaXY);
240 hGammaZR= new TH2F("Gamma_ConversionPoint_ZR","Gamma_ConversionPoint_ZR",1200,-150,150,480,0,120);
241 fESDList->Add(hGammaZR);
243 hElecPt = new TH2F("Electron_Positron_Pt","Electron_Positron_Pt",250,0,25,250,0,25);
244 fESDList->Add(hElecPt);
245 hElecEta = new TH2F("Electron_Positron_Eta","Electron_Positron_Eta",600,-1.5,1.5,600,-1.5,1.5);
246 fESDList->Add(hElecEta);
247 hElecPhi = new TH2F("Electron_Positron_Phi","Electron_Positron_Phi",360,0,2*TMath::Pi(),360,0,2*TMath::Pi());
248 fESDList->Add(hElecPhi);
249 hElecNfindableClsTPC = new TH1F("Electron_findableClusterTPC","Electron_findableClusterTPC",100,0,1);
250 fESDList->Add(hElecNfindableClsTPC);
251 hPosiNfindableClsTPC = new TH1F("Positron_findableClusterTPC","Positron_findableClusterTPC",100,0,1);
252 fESDList->Add(hPosiNfindableClsTPC);
253 hElecAsymP = new TH2F("Electron_Asym_vs_P", "Electron_Asym_vs_P",200,0.,20.,200,0.,1.);
254 fESDList->Add(hElecAsymP);
257 fTrueList = new TList();
258 fTrueList->SetOwner(kTRUE);
259 fTrueList->SetName("True QA");
260 fOutputList->Add(fTrueList);
262 hTrueResolutionR = new TH2F("True_ConversionPointResolution_R","True_ConversionPointResolution_R",240,0,120,200,-20,20);
263 fTrueList->Add(hTrueResolutionR);
264 hTrueResolutionZ = new TH2F("True_ConversionPointResolution_Z","True_ConversionPointResolution_Z",480,-120,120,200,-20,20);
265 fTrueList->Add(hTrueResolutionZ);
266 hTrueResolutionPhi = new TH2F("True_ConversionPointResolution_Phi","True_ConversionPointResolution_Phi",360,0,2*TMath::Pi(),200,-TMath::Pi()/30., TMath::Pi()/30.);
267 fTrueList->Add(hTrueResolutionPhi);
269 hTrueGammaPt = new TH1F("True_Gamma_Pt","True_Gamma_Pt",250,0,25);
270 fTrueList->Add(hTrueGammaPt);
271 hTrueGammaPhi = new TH1F("True_Gamma_Phi","True_Gamma_Phi",360,0,2*TMath::Pi());
272 fTrueList->Add(hTrueGammaPhi);
273 hTrueGammaEta = new TH1F("True_Gamma_Eta","True_Gamma_Eta",600,-1.5,1.5);
274 fTrueList->Add(hTrueGammaEta);
275 hTrueGammaMass = new TH1F("True_Gamma_Mass","True_Gamma_Mass",1000,0,0.3);
276 fTrueList->Add(hTrueGammaMass);
277 hTrueGammaChi2perNDF = new TH1F("True_Gamma_Chi2perNDF","True_Gamma_Chi2perNDF",500,0,100);
278 fTrueList->Add(hTrueGammaChi2perNDF);
279 hTrueGammaPsiPair = new TH1F("True_Gamma_PsiPair","True_Gamma_PsiPair",500,0,2);
280 fTrueList->Add(hTrueGammaPsiPair);
281 hTrueGammaQt = new TH1F("True_Gamma_Qt","True_Gamma_Qt",400,0,0.1);
282 fTrueList->Add(hTrueGammaQt);
283 hTrueGammaCosinePointingAngle = new TH1F("True_Gamma_CosinePointingAngle","True_Gamma_CosinePointingAngle",900,0.7,1.);
284 fTrueList->Add(hTrueGammaCosinePointingAngle);
285 hTrueGammaXY = new TH2F("True_Gamma_ConversionPoint_XY","True_Gamma_ConversionPoint_XY",960,-120,120,960,-120,120);
286 fTrueList->Add(hTrueGammaXY);
287 hTrueGammaZR= new TH2F("TrueGamma_ConversionPoint_ZR","TrueGamma_ConversionPoint_ZR",1200,-150,150,480,0,120);
288 fTrueList->Add(hTrueGammaZR);
290 hTrueElecPt = new TH2F("True_Electron_Positron_Pt","True_Electron_Positron_Pt",250,0,25,250,0,25);
291 fTrueList->Add(hTrueElecPt);
292 hTrueElecEta = new TH2F("True_Electron_Positron_Eta","True_Electron_Positron_Eta",600,-1.5,1.5,600,-1.5,1.5);
293 fTrueList->Add(hTrueElecEta);
294 hTrueElecPhi = new TH2F("True_Electron_Positron_Phi","True_Electron_Positron_Phi",360,0,2*TMath::Pi(),360,0,2*TMath::Pi());
295 fTrueList->Add(hTrueElecPhi);
296 hTrueElecNfindableClsTPC = new TH1F("True_Electron_findableClusterTPC","True_Electron_findableClusterTPC",100,0,1);
297 fTrueList->Add(hTrueElecNfindableClsTPC);
298 hTruePosiNfindableClsTPC = new TH1F("True_Positron_findableClusterTPC","True_Positron_findableClusterTPC",100,0,1);
299 fTrueList->Add(hTruePosiNfindableClsTPC);
300 hTrueElecAsymP = new TH2F("True_Electron_Asym_vs_P", "True_Electron_Asym_vs_P",200,0.,20.,200,0.,1.);
301 fTrueList->Add(hTrueElecAsymP);
303 if(fConversionCuts->GetCutHistograms()){
304 fOutputList->Add(fConversionCuts->GetCutHistograms());
309 fTreeList = new TList();
310 fTreeList->SetOwner(kTRUE);
311 fTreeList->SetName("TreeList");
312 fOutputList->Add(fTreeList);
314 fTreeQA = new TTree("PhotonQA","PhotonQA");
316 fTreeQA->Branch("daughterProp",&fDaughterProp);
317 fTreeQA->Branch("recCords",&fGammaConvCoord);
318 fTreeQA->Branch("photonProp",&fGammaPhotonProp);
319 fTreeQA->Branch("pt",&fGammaPt,"fGammaPt/F");
320 fTreeQA->Branch("theta",&fGammaTheta,"fGammaTheta/F");
321 fTreeQA->Branch("chi2ndf",&fGammaChi2NDF,"fGammaChi2NDF/F");
323 fTreeQA->Branch("kind",&fKind,"fKind/b");
325 fTreeList->Add(fTreeQA);
329 fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask("V0ReaderV1");
331 PostData(1, fOutputList);
333 //_____________________________________________________________________________
334 Bool_t AliAnalysisTaskConversionQA::Notify()
336 if(!fConversionCuts->GetDoEtaShift()) return kTRUE;; // No Eta Shift requested, continue
338 if(fConversionCuts->GetEtaShift() == 0.0){ // Eta Shift requested but not set, get shift automatically
339 fConversionCuts->GetCorrectEtaShiftFromPeriod(fV0Reader->GetPeriodName());
340 fConversionCuts->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
344 printf(" Gamma Conversion QA Task %s :: Eta Shift Manually Set to %f \n\n",
345 (fConversionCuts->GetCutNumber()).Data(),fConversionCuts->GetEtaShift());
346 fConversionCuts->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
351 //________________________________________________________________________
352 void AliAnalysisTaskConversionQA::UserExec(Option_t *){
356 Int_t eventQuality = ((AliConversionCuts*)fV0Reader->GetConversionCuts())->GetEventQuality();
357 if(eventQuality != 0){// Event Not Accepted
360 fInputEvent = InputEvent();
361 if(fIsMC) fMCEvent = MCEvent();
362 if(fMCEvent && fInputEvent->IsA()==AliESDEvent::Class()){ fMCStack = fMCEvent->Stack(); }
364 Int_t eventNotAccepted =
365 fConversionCuts->IsEventAcceptedByConversionCut(fV0Reader->GetConversionCuts(),fInputEvent,fMCEvent,fIsHeavyIon);
366 if(eventNotAccepted) return; // Check Centrality, PileUp, SDD and V0AND --> Not Accepted => eventQuality = 1
368 fConversionGammas=fV0Reader->GetReconstructedGammas();
371 if(fConversionCuts->GetSignalRejection() != 0){
372 if(fInputEvent->IsA()==AliESDEvent::Class()){
373 fConversionCuts->GetNotRejectedParticles(fConversionCuts->GetSignalRejection(),
374 fConversionCuts->GetAcceptedHeader(),
377 else if(fInputEvent->IsA()==AliAODEvent::Class()){
378 fConversionCuts->GetNotRejectedParticles(fConversionCuts->GetSignalRejection(),
379 fConversionCuts->GetAcceptedHeader(),
387 hVertexZ->Fill(fInputEvent->GetPrimaryVertex()->GetZ());
388 hNContributorsVertex->Fill(fConversionCuts->GetNumberOfContributorsVtx(fInputEvent));
389 hNGoodESDTracks->Fill(fNumberOfESDTracks);
390 hNV0Tracks->Fill(fInputEvent->GetVZEROData()->GetMTotV0A()+fInputEvent->GetVZEROData()->GetMTotV0C());
393 if(fMCEvent && fInputEvent->IsA()==AliAODEvent::Class())
394 RelabelAODPhotonCandidates(kTRUE); // In case of AODMC relabeling MC
396 for(Int_t firstGammaIndex=0;firstGammaIndex<fConversionGammas->GetEntriesFast();firstGammaIndex++){
397 AliAODConversionPhoton *gamma=dynamic_cast<AliAODConversionPhoton*>(fConversionGammas->At(firstGammaIndex));
398 if (gamma==NULL) continue;
399 if(fMCEvent && fConversionCuts->GetSignalRejection() != 0){
400 if(!fConversionCuts->IsParticleFromBGEvent(gamma->GetMCLabelPositive(), fMCStack, fInputEvent))
402 if(!fConversionCuts->IsParticleFromBGEvent(gamma->GetMCLabelNegative(), fMCStack, fInputEvent))
405 if(!fConversionCuts->PhotonIsSelected(gamma,fInputEvent)){
409 if(ffillTree) ProcessQATree(gamma);
410 if(ffillHistograms) ProcessQA(gamma);
412 if(fMCEvent && fInputEvent->IsA()==AliAODEvent::Class())
413 RelabelAODPhotonCandidates(kFALSE); // In case of AODMC relabeling MC
415 PostData(1, fOutputList);
419 ///________________________________________________________________________
420 void AliAnalysisTaskConversionQA::ProcessQATree(AliAODConversionPhoton *gamma){
422 // Fill Histograms for QA and MC
423 AliVEvent* event = (AliVEvent*) InputEvent();
427 AliPIDResponse* pidResonse = ((AliConversionCuts*)fV0Reader->GetConversionCuts())->GetPIDResponse();
429 fGammaPt = gamma->GetPhotonPt();
431 fGammaTheta = gamma->Theta();
432 fGammaChi2NDF = gamma->GetChi2perNDF();
434 fGammaPhotonProp(0) = gamma->GetArmenterosQt();
435 fGammaPhotonProp(1) = gamma->GetArmenterosAlpha();
436 fGammaPhotonProp(2) = gamma->GetPsiPair();
437 fGammaPhotonProp(3) = fConversionCuts->GetCosineOfPointingAngle(gamma,event);
438 fGammaPhotonProp(4) = gamma->GetMass();
440 fGammaConvCoord(0) = gamma->GetConversionX();
441 fGammaConvCoord(1) = gamma->GetConversionY();
442 fGammaConvCoord(2) = gamma->GetConversionZ();
443 fGammaConvCoord(3) = gamma->GetConversionRadius();
444 fGammaConvCoord(4) = gamma->GetPhotonPhi();
446 AliVTrack * negTrack = fConversionCuts->GetTrack(event, gamma->GetTrackLabelNegative());
447 AliVTrack * posTrack = fConversionCuts->GetTrack(event, gamma->GetTrackLabelPositive());
450 if(!negTrack||!posTrack)return;
453 if(fMCEvent && fInputEvent->IsA()==AliESDEvent::Class()){
454 fKind = IsTruePhotonESD(gamma);
455 } else if (fMCEvent && fInputEvent->IsA()==AliAODEvent::Class()){
456 fKind = IsTruePhotonAOD(gamma);
459 fDaughterProp(0) = posTrack->Pt();
460 fDaughterProp(7) = negTrack->Pt();
461 fDaughterProp(1) = posTrack->Theta();
462 fDaughterProp(8) = negTrack->Theta();
463 Double32_t signalPos[4] = {0,0,0,0};
466 if (posTrack->GetTPCdEdxInfo()) {
467 posTrack->GetTPCdEdxInfo()->GetTPCSignalRegionInfo(signalPos,nclPos,nrowsPos);
468 fDaughterProp(2) = signalPos[0];
469 fDaughterProp(14) = signalPos[1];
470 fDaughterProp(16) = signalPos[2];
472 fDaughterProp(2) = posTrack->GetTPCsignal();
473 fDaughterProp(14) = 0;
474 fDaughterProp(16) = 0;
476 Double32_t signalNeg[4] = {0,0,0,0};
479 if (negTrack->GetTPCdEdxInfo()) {
480 negTrack->GetTPCdEdxInfo()->GetTPCSignalRegionInfo(signalNeg,nclNeg,nrowsNeg);
481 fDaughterProp(9) = signalNeg[0];
482 fDaughterProp(15) = signalNeg[1];
483 fDaughterProp(17) = signalNeg[2];
485 fDaughterProp(9) = negTrack->GetTPCsignal();
486 fDaughterProp(15) = 0;
487 fDaughterProp(17) = 0;
489 fDaughterProp(3) = pidResonse->NumberOfSigmasTPC(posTrack,AliPID::kElectron);
490 fDaughterProp(10) = pidResonse->NumberOfSigmasTPC(negTrack,AliPID::kElectron);
491 if((posTrack->GetStatus() & AliESDtrack::kTOFpid) && !(posTrack->GetStatus() & AliESDtrack::kTOFmismatch)){
492 Double_t t0pos = pidResonse->GetTOFResponse().GetStartTime(posTrack->P());
493 Double_t timesPos[5];
494 posTrack->GetIntegratedTimes(timesPos);
495 Double_t TOFsignalPos = posTrack->GetTOFsignal();
496 Double_t dTpos = TOFsignalPos - t0pos - timesPos[0];
497 fDaughterProp(4) = dTpos;
498 fDaughterProp(5) = pidResonse->NumberOfSigmasTOF(posTrack, AliPID::kElectron);
500 fDaughterProp(4) = 20000;
501 fDaughterProp(5) = -20;
503 if((negTrack->GetStatus() & AliESDtrack::kTOFpid) && !(negTrack->GetStatus() & AliESDtrack::kTOFmismatch)){
504 Double_t t0neg = pidResonse->GetTOFResponse().GetStartTime(negTrack->P());
505 Double_t timesNeg[5];
506 negTrack->GetIntegratedTimes(timesNeg);
507 Double_t TOFsignalNeg = negTrack->GetTOFsignal();
508 Double_t dTneg = TOFsignalNeg - t0neg - timesNeg[0];
509 fDaughterProp(11) = dTneg;
510 fDaughterProp(12) = pidResonse->NumberOfSigmasTOF(negTrack, AliPID::kElectron);
512 fDaughterProp(11) = 20000;
513 fDaughterProp(12) = -20;
516 fDaughterProp(6) = (Float_t)posTrack->GetTPCClusterInfo(2,0,fConversionCuts->GetFirstTPCRow(gamma->GetConversionRadius()));
517 fDaughterProp(18) = posTrack->GetNcls(1);
518 fDaughterProp(13) = (Float_t)negTrack->GetTPCClusterInfo(2,0,fConversionCuts->GetFirstTPCRow(gamma->GetConversionRadius()));
519 fDaughterProp(19) = negTrack->GetNcls(1);
526 //_____________________________________________________________________________________________________
527 void AliAnalysisTaskConversionQA::ProcessQA(AliAODConversionPhoton *gamma){
530 // Fill Histograms for QA and MC
531 hGammaPt->Fill(gamma->GetPhotonPt());
532 hGammaPhi->Fill(gamma->GetPhotonPhi());
533 hGammaEta->Fill(gamma->Eta());
534 hGammaChi2perNDF->Fill(gamma->GetChi2perNDF());
535 hGammaPsiPair->Fill(gamma->GetPsiPair());
536 hGammaQt->Fill(gamma->GetArmenterosQt());
537 hGammaCosinePointingAngle->Fill(fConversionCuts->GetCosineOfPointingAngle(gamma,fInputEvent));
538 hGammaXY->Fill(gamma->GetConversionX(),gamma->GetConversionY());
539 hGammaZR->Fill(gamma->GetConversionZ(),gamma->GetConversionRadius());
541 AliVTrack * negTrack = fConversionCuts->GetTrack(fInputEvent, gamma->GetTrackLabelNegative());
542 AliVTrack * posTrack = fConversionCuts->GetTrack(fInputEvent, gamma->GetTrackLabelPositive());
543 if(!negTrack||!posTrack)return;
545 Double_t negtrackPhi = negTrack->Phi();
546 Double_t postrackPhi = posTrack->Phi();
547 hITSClusterPhi->Fill(negtrackPhi,6);
548 hITSClusterPhi->Fill(postrackPhi,6);
549 for(Int_t itsLayer = 0; itsLayer<6;itsLayer++){
550 if(TESTBIT(negTrack->GetITSClusterMap(),itsLayer)){
551 hITSClusterPhi->Fill(negtrackPhi,itsLayer);
553 if(TESTBIT(posTrack->GetITSClusterMap(),itsLayer)){
554 hITSClusterPhi->Fill(postrackPhi,itsLayer);
558 hElecPt->Fill(negTrack->Pt(),posTrack->Pt());
559 hElecEta->Fill(negTrack->Eta(),posTrack->Eta());
560 hElecPhi->Fill(negTrack->Phi(),posTrack->Phi());
562 hElecNfindableClsTPC->Fill((Float_t)posTrack->GetTPCClusterInfo(2,0,fConversionCuts->GetFirstTPCRow(gamma->GetConversionRadius())));
563 hPosiNfindableClsTPC->Fill((Float_t)negTrack->GetTPCClusterInfo(2,0,fConversionCuts->GetFirstTPCRow(gamma->GetConversionRadius())));
565 hElecAsymP->Fill(gamma->P(),negTrack->P()/gamma->P());
567 // hElecNfindableClsTPC->Fill((Float_t)negTrack->GetNcls(1)/(Float_t)negTrack->GetTPCNclsF());
568 // hPosiNfindableClsTPC->Fill((Float_t)posTrack->GetNcls(1)/(Float_t)posTrack->GetTPCNclsF());
569 if(fMCEvent && fInputEvent->IsA()==AliESDEvent::Class()){
570 ProcessTrueQAESD(gamma,(AliESDtrack*)negTrack,(AliESDtrack*)posTrack);
571 } else if(fMCEvent && fInputEvent->IsA()==AliAODEvent::Class()){
572 ProcessTrueQAAOD(gamma,(AliAODTrack*)negTrack,(AliAODTrack*)posTrack);
576 //________________________________________________________________________
577 void AliAnalysisTaskConversionQA::ProcessTrueQAESD(AliAODConversionPhoton *TruePhotonCandidate, AliESDtrack *elec, AliESDtrack *posi)
580 if(IsTruePhotonESD(TruePhotonCandidate)!=0 && IsTruePhotonESD(TruePhotonCandidate)!=5 ) return;
582 TParticle *negDaughter = TruePhotonCandidate->GetNegativeMCDaughter(fMCStack);
583 TParticle *mcPhoton = TruePhotonCandidate->GetMCParticle(fMCStack);
585 hTrueResolutionR->Fill(TruePhotonCandidate->GetConversionRadius(),
586 TruePhotonCandidate->GetConversionRadius()-negDaughter->R());
587 hTrueResolutionZ->Fill(TruePhotonCandidate->GetConversionZ(),
588 TruePhotonCandidate->GetConversionZ()-negDaughter->Vz());
589 hTrueResolutionPhi->Fill(TruePhotonCandidate->Phi(),
590 TruePhotonCandidate->Phi()-mcPhoton->Phi());
591 hTrueGammaPt->Fill(TruePhotonCandidate->Pt());
592 hTrueGammaPhi->Fill(TruePhotonCandidate->Phi());
593 hTrueGammaEta->Fill(TruePhotonCandidate->Eta());
594 hTrueGammaMass->Fill(TruePhotonCandidate->GetMass());
595 hTrueGammaChi2perNDF->Fill(TruePhotonCandidate->GetChi2perNDF());
596 hTrueGammaPsiPair->Fill(TruePhotonCandidate->GetPsiPair());
597 hTrueGammaQt->Fill(TruePhotonCandidate->GetArmenterosQt());
598 hTrueGammaCosinePointingAngle->Fill(fConversionCuts->GetCosineOfPointingAngle(TruePhotonCandidate,fInputEvent));
599 hTrueGammaXY->Fill(TruePhotonCandidate->GetConversionX(),TruePhotonCandidate->GetConversionY());
600 hTrueGammaZR->Fill(TruePhotonCandidate->GetConversionZ(),TruePhotonCandidate->GetConversionRadius());
601 hTrueElecPt->Fill(elec->Pt(),posi->Pt());
602 hTrueElecEta->Fill(elec->Eta(),posi->Eta());
603 hTrueElecPhi->Fill(elec->Phi(),posi->Phi());
604 hTrueElecNfindableClsTPC
605 ->Fill((Float_t)elec->GetTPCClusterInfo(2,0,fConversionCuts->GetFirstTPCRow(TruePhotonCandidate->GetConversionRadius())));
606 hTruePosiNfindableClsTPC
607 ->Fill((Float_t)posi->GetTPCClusterInfo(2,0,fConversionCuts->GetFirstTPCRow(TruePhotonCandidate->GetConversionRadius())));
608 if(TruePhotonCandidate->P()!=0){
609 hTrueElecAsymP->Fill(TruePhotonCandidate->P(),elec->P()/TruePhotonCandidate->P());
612 // hTrueElecNfindableClsTPC->Fill((Float_t)elec->GetNcls(1)/(Float_t)elec->GetTPCNclsF());
613 // hTruePosiNfindableClsTPC->Fill((Float_t)posi->GetNcls(1)/(Float_t)posi->GetTPCNclsF());
616 //________________________________________________________________________
617 void AliAnalysisTaskConversionQA::ProcessTrueQAAOD(AliAODConversionPhoton *TruePhotonCandidate, AliAODTrack *elec, AliAODTrack *posi)
620 if(IsTruePhotonAOD(TruePhotonCandidate)!=0 && IsTruePhotonESD(TruePhotonCandidate)!=5 ) return;
622 TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
623 AliAODMCParticle *negDaughter = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetMCLabelNegative());
624 AliAODMCParticle *mcPhoton = (AliAODMCParticle*) AODMCTrackArray->At(negDaughter->GetMother());
626 hTrueResolutionR->Fill(TruePhotonCandidate->GetConversionRadius(),
627 TruePhotonCandidate->GetConversionRadius()-(TMath::Sqrt(negDaughter->Xv()*negDaughter->Xv()+negDaughter->Yv()*negDaughter->Yv())));
628 hTrueResolutionZ->Fill(TruePhotonCandidate->GetConversionZ(),
629 TruePhotonCandidate->GetConversionZ()-negDaughter->Zv());
630 hTrueResolutionPhi->Fill(TruePhotonCandidate->Phi(),
631 TruePhotonCandidate->Phi()-mcPhoton->Phi());
632 hTrueGammaPt->Fill(TruePhotonCandidate->Pt());
633 hTrueGammaPhi->Fill(TruePhotonCandidate->Phi());
634 hTrueGammaEta->Fill(TruePhotonCandidate->Eta());
635 hTrueGammaMass->Fill(TruePhotonCandidate->GetMass());
636 hTrueGammaChi2perNDF->Fill(TruePhotonCandidate->GetChi2perNDF());
637 hTrueGammaPsiPair->Fill(TruePhotonCandidate->GetPsiPair());
638 hTrueGammaQt->Fill(TruePhotonCandidate->GetArmenterosQt());
639 hTrueGammaCosinePointingAngle->Fill(fConversionCuts->GetCosineOfPointingAngle(TruePhotonCandidate,fInputEvent));
640 hTrueGammaXY->Fill(TruePhotonCandidate->GetConversionX(),TruePhotonCandidate->GetConversionY());
641 hTrueGammaZR->Fill(TruePhotonCandidate->GetConversionZ(),TruePhotonCandidate->GetConversionRadius());
642 hTrueElecPt->Fill(elec->Pt(),posi->Pt());
643 hTrueElecEta->Fill(elec->Eta(),posi->Eta());
644 hTrueElecPhi->Fill(elec->Phi(),posi->Phi());
645 hTrueElecNfindableClsTPC
646 ->Fill((Float_t)elec->GetTPCClusterInfo(2,0,fConversionCuts->GetFirstTPCRow(TruePhotonCandidate->GetConversionRadius())));
647 hTruePosiNfindableClsTPC
648 ->Fill((Float_t)posi->GetTPCClusterInfo(2,0,fConversionCuts->GetFirstTPCRow(TruePhotonCandidate->GetConversionRadius())));
649 // hTrueElecNfindableClsTPC->Fill((Float_t)elec->GetNcls(1)/(Float_t)elec->GetTPCNclsF());
650 // hTruePosiNfindableClsTPC->Fill((Float_t)posi->GetNcls(1)/(Float_t)posi->GetTPCNclsF());
653 //________________________________________________________________________
654 void AliAnalysisTaskConversionQA::CountTracks(){
656 if(fInputEvent->IsA()==AliESDEvent::Class()){
657 // Using standard function for setting Cuts
658 Bool_t selectPrimaries=kTRUE;
659 AliESDtrackCuts *EsdTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(selectPrimaries);
660 EsdTrackCuts->SetMaxDCAToVertexZ(2);
661 EsdTrackCuts->SetEtaRange(-0.8, 0.8);
662 EsdTrackCuts->SetPtRange(0.15);
663 fNumberOfESDTracks = 0;
664 for(Int_t iTracks = 0; iTracks < fInputEvent->GetNumberOfTracks(); iTracks++){
665 AliESDtrack* curTrack = (AliESDtrack*) fInputEvent->GetTrack(iTracks);
666 if(!curTrack) continue;
667 // if(fMCEvent && ((AliConversionCuts*)fCutArray->At(fiCut))->GetSignalRejection() != 0){
668 // if(!((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(abs(curTrack->GetLabel()), fMCStack)) continue;
670 if(EsdTrackCuts->AcceptTrack(curTrack) ) fNumberOfESDTracks++;
675 else if(fInputEvent->IsA()==AliAODEvent::Class()){
676 fNumberOfESDTracks = 0;
677 for(Int_t iTracks = 0; iTracks<fInputEvent->GetNumberOfTracks(); iTracks++){
678 AliAODTrack* curTrack = (AliAODTrack*) fInputEvent->GetTrack(iTracks);
679 if(!curTrack->IsPrimaryCandidate()) continue;
680 if(abs(curTrack->Eta())>0.8) continue;
681 if(curTrack->Pt()<0.15) continue;
682 if(abs(curTrack->ZAtDCA())>2) continue;
683 fNumberOfESDTracks++;
689 //________________________________________________________________________
691 Bool_t AliAnalysisTaskConversionQA::IsTruePhotonESD(AliAODConversionPhoton *TruePhotonCandidate)
693 TParticle *posDaughter = TruePhotonCandidate->GetPositiveMCDaughter(fMCStack);
694 TParticle *negDaughter = TruePhotonCandidate->GetNegativeMCDaughter(fMCStack);
696 if(posDaughter == NULL || negDaughter == NULL) return kFALSE; // One particle does not exist
697 Int_t pdgCode[2] = {abs(posDaughter->GetPdgCode()),abs(negDaughter->GetPdgCode())};
698 if(posDaughter->GetMother(0) != negDaughter->GetMother(0)) return kFALSE;
699 else if(posDaughter->GetMother(0) == -1) return kFALSE;
701 if(pdgCode[0]!=11 || pdgCode[1]!=11) return kFALSE; //One Particle is not electron
702 if(posDaughter->GetPdgCode()==negDaughter->GetPdgCode()) return kFALSE; // Same Charge
703 if(posDaughter->GetUniqueID() != 5 || negDaughter->GetUniqueID() !=5) return kFALSE;// check if the daughters come from a conversion
705 TParticle *Photon = TruePhotonCandidate->GetMCParticle(fMCStack);
706 if(Photon->GetPdgCode() != 22) return kFALSE; // Mother is no Photon
711 UInt_t AliAnalysisTaskConversionQA::IsTruePhotonESD(AliAODConversionPhoton *TruePhotonCandidate)
716 TParticle *posDaughter = TruePhotonCandidate->GetPositiveMCDaughter(fMCStack);
717 TParticle *negDaughter = TruePhotonCandidate->GetNegativeMCDaughter(fMCStack);
718 TParticle *Photon = TruePhotonCandidate->GetMCParticle(fMCStack);
719 Int_t motherLabelPhoton;
720 Int_t pdgCodePos = 0;
721 Int_t pdgCodeNeg = 0;
725 if(posDaughter == NULL || negDaughter == NULL) {
727 // return kFALSE; // One particle does not exist
729 } else if( posDaughter->GetMother(0) != negDaughter->GetMother(0) || (posDaughter->GetMother(0) == negDaughter->GetMother(0) && posDaughter->GetMother(0) ==-1)) {
732 pdgCodePos=TMath::Abs(posDaughter->GetPdgCode());
733 pdgCodeNeg=TMath::Abs(negDaughter->GetPdgCode());
734 if(pdgCodePos==11 && pdgCodeNeg==11) return 10; //Electron Combinatorial
735 if(pdgCodePos==11 && pdgCodeNeg==11 &&
736 (posDaughter->GetMother(0) == negDaughter->GetMother(0) && posDaughter->GetMother(0) ==-1)) return 15; //direct Electron Combinatorial
738 if(pdgCodePos==211 && pdgCodeNeg==211) return 11; //Pion Combinatorial
739 if((pdgCodePos==211 && pdgCodeNeg==2212) ||(pdgCodePos==2212 && pdgCodeNeg==211)) return 12; //Pion, Proton Combinatorics
740 if((pdgCodePos==211 && pdgCodeNeg==11) ||(pdgCodePos==11 && pdgCodeNeg==211)) return 13; //Pion, Electron Combinatorics
741 if(pdgCodePos==321 || pdgCodeNeg==321) return 14; //Kaon combinatorics
744 pdgCodePos=posDaughter->GetPdgCode();
745 pdgCodeNeg=negDaughter->GetPdgCode();
746 motherLabelPhoton= Photon->GetMother(0);
747 if ( TruePhotonCandidate->GetMCParticle(fMCStack)->GetPdgCode()) pdgCode = TruePhotonCandidate->GetMCParticle(fMCStack)->GetPdgCode();
749 if(TMath::Abs(pdgCodePos)!=11 || TMath::Abs(pdgCodeNeg)!=11) return 2; // true from hadronic decays
750 else if ( !(pdgCodeNeg==pdgCodePos)){
751 if(pdgCode == 111) return 3; // pi0 Dalitz
752 else if (pdgCode == 221) return 4; // eta Dalitz
753 else if (!(negDaughter->GetUniqueID() != 5 || posDaughter->GetUniqueID() !=5)){
754 if(pdgCode == 22 && motherLabelPhoton < fMCStack->GetNprimary()){
755 return 0; // primary photons
756 } else if (pdgCode == 22){
757 return 5; //secondary photons
766 //________________________________________________________________________
767 UInt_t AliAnalysisTaskConversionQA::IsTruePhotonAOD(AliAODConversionPhoton *TruePhotonCandidate)
772 TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
773 AliAODMCParticle *posDaughter = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetMCLabelPositive());
774 AliAODMCParticle *negDaughter = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetMCLabelNegative());
775 AliAODMCParticle *Photon = (AliAODMCParticle*) AODMCTrackArray->At(posDaughter->GetMother());
776 Int_t motherLabelPhoton = Photon->GetMother();
777 Int_t pdgCodePos = 0;
778 Int_t pdgCodeNeg = 0;
781 if(posDaughter == NULL || negDaughter == NULL) {
783 // return kFALSE; // One particle does not exist
785 } else if( posDaughter->GetMother() != negDaughter->GetMother() || (posDaughter->GetMother() == negDaughter->GetMother() && posDaughter->GetMother() ==-1)) {
788 pdgCodePos=TMath::Abs(posDaughter->GetPdgCode());
789 pdgCodeNeg=TMath::Abs(negDaughter->GetPdgCode());
790 if(pdgCodePos==11 && pdgCodeNeg==11) kind = 10; //Electron Combinatorial
791 if(pdgCodePos==11 && pdgCodeNeg==11 &&
792 (posDaughter->GetMother() == negDaughter->GetMother() && posDaughter->GetMother() ==-1))kind = 15; //direct Electron Combinatorial
794 if(pdgCodePos==211 && pdgCodeNeg==211) kind = 11; //Pion Combinatorial
795 if((pdgCodePos==211 && pdgCodeNeg==2212) ||(pdgCodePos==2212 && pdgCodeNeg==211)) kind = 12; //Pion, Proton Combinatorics
796 if((pdgCodePos==211 && pdgCodeNeg==11) ||(pdgCodePos==11 && pdgCodeNeg==211)) kind = 13; //Pion, Electron Combinatorics
797 if(pdgCodePos==321 || pdgCodeNeg==321) kind = 14; //Kaon combinatorics
800 pdgCodePos=posDaughter->GetPdgCode();
801 pdgCodeNeg=negDaughter->GetPdgCode();
803 if ( TruePhotonCandidate->GetMCParticle(fMCStack)->GetPdgCode())
804 pdgCode = TruePhotonCandidate->GetMCParticle(fMCStack)->GetPdgCode();
805 if(TMath::Abs(pdgCodePos)!=11 || TMath::Abs(pdgCodeNeg)!=11) kind = 2; // true from hadronic decays
806 else if ( !(pdgCodeNeg==pdgCodePos)){
807 if(pdgCode == 111) kind = 3; // pi0 Dalitz
808 else if (pdgCode == 221) kind = 4; // eta Dalitz
809 else if (!(negDaughter->GetMCProcessCode() != 5 || posDaughter->GetMCProcessCode() !=5)){
810 if(pdgCode == 22 && motherLabelPhoton < fMCStack->GetNprimary()){
811 kind = 0; // primary photons
812 } else if (pdgCode == 22){
813 kind = 5; //secondary photons
825 //________________________________________________________________________
826 void AliAnalysisTaskConversionQA::RelabelAODPhotonCandidates(Bool_t mode){
828 // Relabeling For AOD Event
830 // MCLabel -> AODMCLabel
833 fMCStackPos = new Int_t[fConversionGammas->GetEntries()];
834 fMCStackNeg = new Int_t[fConversionGammas->GetEntries()];
837 for(Int_t iGamma = 0;iGamma<fConversionGammas->GetEntries();iGamma++){
838 AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) fConversionGammas->At(iGamma);
839 if(!PhotonCandidate) continue;
840 if(!mode){// Back to ESD Labels
841 PhotonCandidate->SetMCLabelPositive(fMCStackPos[iGamma]);
842 PhotonCandidate->SetMCLabelNegative(fMCStackNeg[iGamma]);
843 //PhotonCandidate->IsAODMCLabel(kFALSE);
846 fMCStackPos[iGamma] = PhotonCandidate->GetMCLabelPositive();
847 fMCStackNeg[iGamma] = PhotonCandidate->GetMCLabelNegative();
849 Bool_t AODLabelPos = kFALSE;
850 Bool_t AODLabelNeg = kFALSE;
852 for(Int_t i = 0; i<fInputEvent->GetNumberOfTracks();i++){
853 AliAODTrack *tempDaughter = static_cast<AliAODTrack*>(fInputEvent->GetTrack(i));
855 if( tempDaughter->GetID() == PhotonCandidate->GetTrackLabelPositive() ){
856 PhotonCandidate->SetMCLabelPositive(abs(tempDaughter->GetLabel()));
861 if( tempDaughter->GetID() == PhotonCandidate->GetTrackLabelNegative()){
862 PhotonCandidate->SetMCLabelNegative(abs(tempDaughter->GetLabel()));
866 if(AODLabelNeg && AODLabelPos){
869 } // Both ESD Tracks have AOD Tracks with Positive IDs
870 if(!AODLabelPos || !AODLabelNeg){
871 for(Int_t i = 0; i<fInputEvent->GetNumberOfTracks();i++){
872 AliAODTrack *tempDaughter = static_cast<AliAODTrack*>(fInputEvent->GetTrack(i));
873 if(tempDaughter->GetID()<0){
875 if( (abs(tempDaughter->GetID())-1) == PhotonCandidate->GetTrackLabelPositive()){
876 PhotonCandidate->SetMCLabelPositive(abs(tempDaughter->GetLabel()));
881 if( (abs(tempDaughter->GetID())-1) == PhotonCandidate->GetTrackLabelNegative()){
882 PhotonCandidate->SetMCLabelNegative(abs(tempDaughter->GetLabel()));
887 if(AODLabelNeg && AODLabelPos){
891 if(!AODLabelPos || !AODLabelNeg){
892 cout<<"WARNING!!! AOD TRACKS NOT FOUND FOR"<<endl;
898 delete[] fMCStackPos;
899 delete[] fMCStackNeg;
903 //________________________________________________________________________
904 void AliAnalysisTaskConversionQA::Terminate(Option_t *)