AliPhysics  master (3d17d9d)
AliAnalysisTaskConversionQA.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Authors: Svein Lindal, Daniel Lohner *
5  * Version 1.0 *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 
17 //---------------------------------------------
18 // QA Task for V0 Reader V1
19 //---------------------------------------------
21 
23 #include "TChain.h"
24 #include "TRandom.h"
25 #include "AliAnalysisManager.h"
26 #include "TParticle.h"
27 #include "TVectorF.h"
28 #include "AliPIDResponse.h"
29 #include "TFile.h"
30 #include "AliESDtrackCuts.h"
31 #include "AliAODMCParticle.h"
32 #include "AliAODMCHeader.h"
33 #include "AliAODEvent.h"
34 
35 class iostream;
36 
37 using namespace std;
38 
40 
41 //________________________________________________________________________
43  fV0Reader(NULL),
44  fV0ReaderName("V0ReaderV1"),
45  fConversionGammas(NULL),
46  fConversionCuts(NULL),
47  fEventCuts(NULL),
48  fInputEvent(NULL),
49  fNumberOfESDTracks(0),
50  fMCEvent(NULL),
51  fTreeQA(NULL),
52  fIsHeavyIon(kFALSE),
53  ffillTree(-100),
54  ffillHistograms(kFALSE),
55  fOutputList(NULL),
56  fESDList(NULL),
57  hVertexZ(NULL),
58  hNGoodESDTracks(NULL),
59  hNV0Tracks(NULL),
60  hNContributorsVertex(NULL),
61  hITSClusterPhi(NULL),
62  hGammaPt(NULL),
63  hGammaPhi(NULL),
64  hGammaPhi_Pos(NULL),
65  hGammaPhi_Neg(NULL),
66  hGammaEta(NULL),
67  hGammaChi2perNDF(NULL),
68  hGammaPsiPair(NULL),
69  hGammaArmenteros(NULL),
70  hGammaCosinePointingAngle(NULL),
71  hGammaInvMass(NULL),
72  hElecPt(NULL),
73  hElecEta(NULL),
74  hElecPhi(NULL),
75  hElecNfindableClsTPC(NULL),
76  hPosiNfindableClsTPC(NULL),
77  hElecClsTPC(NULL),
78  hPosiClsTPC(NULL),
79  hElectrondEdxP(NULL),
80  hElectronITSdEdxP(NULL),
81  hElectronTOFP(NULL),
82  hElectronNSigmadEdxP(NULL),
83  hElectronNSigmadEdxEta(NULL),
84  hElectronNSigmaPiondEdxP(NULL),
85  hElectronNSigmaITSP(NULL),
86  hElectronNSigmaTOFP(NULL),
87  hPositrondEdxP(NULL),
88  hPositronITSdEdxP(NULL),
89  hPositronTOFP(NULL),
90  hPositronNSigmadEdxP(NULL),
91  hPositronNSigmadEdxEta(NULL),
92  hPositronNSigmaPiondEdxP(NULL),
93  hPositronNSigmaITSP(NULL),
94  hPositronNSigmaTOFP(NULL),
95  hInvMassPair(NULL),
96  // hElecAsymP(NULL),
97  // fTrueList(NULL),
98  // hTrueResolutionR(NULL),
99  // hTrueResolutionZ(NULL),
100  // hTrueResolutionPhi(NULL),
101  // hTrueGammaPt(NULL),
102  // hTrueGammaPhi(NULL),
103  // hTrueGammaEta(NULL),
104  // hTrueGammaMass(NULL),
105  // hTrueGammaChi2perNDF(NULL),
106  // hTrueGammaPsiPair(NULL),
107  // hTrueGammaQt(NULL),
108  // hTrueGammaCosinePointingAngle(NULL),
109  // hTrueGammaXY(NULL),
110  // hTrueGammaZR(NULL),
111  // hTrueElecPt(NULL),
112  // hTrueElecEta(NULL),
113  // hTrueElecPhi(NULL),
114  // hTrueElecNfindableClsTPC(NULL),
115  // hTruePosiNfindableClsTPC(NULL),
116  // hTrueElecAsymP(NULL),
117  fGammaPt(0),
118  fGammaTheta(0),
119  fGammaChi2NDF(0),
120  fGammaPhotonProp(5),
121  fGammaConvCoord(5),
122  fDaughterProp(24),
123  fKind(0),
124  fIsMC(kFALSE),
125  fnGammaCandidates(1),
126  fMCStackPos(NULL),
127  fMCStackNeg(NULL)
128 {
129 
130 }
131 
133  fV0Reader(NULL),
134  fV0ReaderName("V0ReaderV1"),
135  fConversionGammas(NULL),
136  fConversionCuts(NULL),
137  fEventCuts(NULL),
138  fInputEvent(NULL),
139  fNumberOfESDTracks(0),
140  fMCEvent(NULL),
141  fTreeQA(NULL),
142  fIsHeavyIon(kFALSE),
143  ffillTree(-100),
144  ffillHistograms(kFALSE),
145  fOutputList(NULL),
146  fESDList(NULL),
147  hVertexZ(NULL),
148  hNGoodESDTracks(NULL),
149  hNV0Tracks(NULL),
150  hNContributorsVertex(NULL),
151  hITSClusterPhi(NULL),
152  hGammaPt(NULL),
153  hGammaPhi(NULL),
154  hGammaPhi_Pos(NULL),
155  hGammaPhi_Neg(NULL),
156  hGammaEta(NULL),
157  hGammaChi2perNDF(NULL),
158  hGammaPsiPair(NULL),
159  hGammaArmenteros(NULL),
160  hGammaCosinePointingAngle(NULL),
161  hGammaInvMass(NULL),
162  hElecPt(NULL),
163  hElecEta(NULL),
164  hElecPhi(NULL),
165  hElecNfindableClsTPC(NULL),
166  hPosiNfindableClsTPC(NULL),
167  hElecClsTPC(NULL),
168  hPosiClsTPC(NULL),
169  hElectrondEdxP(NULL),
170  hElectronITSdEdxP(NULL),
171  hElectronTOFP(NULL),
172  hElectronNSigmadEdxP(NULL),
173  hElectronNSigmadEdxEta(NULL),
174  hElectronNSigmaPiondEdxP(NULL),
175  hElectronNSigmaITSP(NULL),
176  hElectronNSigmaTOFP(NULL),
177  hPositrondEdxP(NULL),
178  hPositronITSdEdxP(NULL),
179  hPositronTOFP(NULL),
180  hPositronNSigmadEdxP(NULL),
181  hPositronNSigmadEdxEta(NULL),
182  hPositronNSigmaPiondEdxP(NULL),
183  hPositronNSigmaITSP(NULL),
184  hPositronNSigmaTOFP(NULL),
185  hInvMassPair(NULL),
186  // hGammaXY(NULL),
187  // hGammaZR(NULL),
188  // hElecAsymP(NULL),
189  // fTrueList(NULL),
190  // hTrueResolutionR(NULL),
191  // hTrueResolutionZ(NULL),
192  // hTrueResolutionPhi(NULL),
193  // hTrueGammaPt(NULL),
194  // hTrueGammaPhi(NULL),
195  // hTrueGammaEta(NULL),
196  // hTrueGammaMass(NULL),
197  // hTrueGammaChi2perNDF(NULL),
198  // hTrueGammaPsiPair(NULL),
199  // hTrueGammaQt(NULL),
200  // hTrueGammaCosinePointingAngle(NULL),
201  // hTrueGammaXY(NULL),
202  // hTrueGammaZR(NULL),
203  // hTrueElecPt(NULL),
204  // hTrueElecEta(NULL),
205  // hTrueElecPhi(NULL),
206  // hTrueElecNfindableClsTPC(NULL),
207  // hTruePosiNfindableClsTPC(NULL),
208  // hTrueElecAsymP(NULL),
209  fGammaPt(0),
210  fGammaTheta(0),
211  fGammaChi2NDF(0),
212  fGammaPhotonProp(5),
213  fGammaConvCoord(5),
214  fDaughterProp(24),
215  fKind(0),
216  fIsMC(kFALSE),
217  fnGammaCandidates(1),
218  fMCStackPos(NULL),
219  fMCStackNeg(NULL)
220 {
221  // Default constructor
222 
223  DefineInput(0, TChain::Class());
224  DefineOutput(1, TList::Class());
225  DefineOutput(2, TTree::Class());
226 }
227 
228 //________________________________________________________________________
230 {
231  // default deconstructor
232 
233 }
234 //________________________________________________________________________
236 {
237  // Create User Output Objects
238 
239  if(fOutputList != NULL){
240  delete fOutputList;
241  fOutputList = NULL;
242  }
243  if(fOutputList == NULL){
244  fOutputList = new TList();
245  fOutputList->SetOwner(kTRUE);
246  }
247 
248  if(ffillHistograms){
249  fESDList = new TList();
250  fESDList->SetOwner(kTRUE);
251  fESDList->SetName("ESD QA");
252  fOutputList->Add(fESDList);
253 
254  hVertexZ = new TH1F("Vertex_Z","Vertex_Z",300,-15,15);
255  fESDList->Add(hVertexZ);
256  hNContributorsVertex = new TH1I("ContrVertex_Z","ContrVertex_Z",3000,0,3000);
258  if(fIsHeavyIon) hNGoodESDTracks = new TH1I("GoodESDTracks","GoodESDTracks",4000,0,4000);
259  else hNGoodESDTracks = new TH1I("GoodESDTracks","GoodESDTracks",200,0,200);
261  if(fIsHeavyIon) hNV0Tracks = new TH1I("V0 Multiplicity","V0 Multiplicity",30000,0,30000);
262  else hNV0Tracks = new TH1I("V0 Multiplicity","V0 Multiplicity",2000,0,2000);
263  fESDList->Add(hNV0Tracks);
264 
265  hITSClusterPhi = new TH2F("ITSClusterPhi","hITSClusterPhi",72,0,2*TMath::Pi(),7,0,7);
266  fESDList->Add(hITSClusterPhi);
267  hGammaPt = new TH1F("Gamma_Pt","Gamma_Pt",250,0,25);
268  fESDList->Add(hGammaPt);
269  hGammaPhi = new TH1F("Gamma_Phi","Gamma_Phi",360,0,2*TMath::Pi());
270  fESDList->Add(hGammaPhi);
271  hGammaPhi_Pos = new TH1F("GammaPhi_EtaPos","GammaPhi_EtaPos",360,0,2*TMath::Pi());
272  fESDList->Add(hGammaPhi_Pos);
273  hGammaPhi_Neg = new TH1F("GammaPhi_EtaNeg","GammaPhi_EtaNeg",360,0,2*TMath::Pi());
274  fESDList->Add(hGammaPhi_Neg);
275 
276  hGammaEta = new TH1F("Gamma_Eta","Gamma_Eta",600,-1.5,1.5);
277  fESDList->Add(hGammaEta);
278  hGammaChi2perNDF = new TH1F("Gamma_Chi2perNDF","Gamma_Chi2perNDF",500,0,100);
280  hGammaPsiPair = new TH1F("Gamma_PsiPair","Gamma_PsiPair",500,0,2);
281  fESDList->Add(hGammaPsiPair);
282  hGammaArmenteros = new TH2F("Gamma_Armenteros","Gamma_Armenteros",200,-1,1,400,0,0.1);
284  hGammaCosinePointingAngle = new TH1F("Gamma_CosinePointingAngle","Gamma_CosinePointingAngle",1000,-1.,1.);
286  hGammaInvMass = new TH1F( "Gamma_InvMass","",200, 0, 0.2);
287  fESDList->Add(hGammaInvMass);
288 
289  hElecPt = new TH2F("Electron_Positron_Pt","Electron_Positron_Pt",250,0,25,250,0,25);
290  fESDList->Add(hElecPt);
291  hElecEta = new TH2F("Electron_Positron_Eta","Electron_Positron_Eta",600,-1.5,1.5,600,-1.5,1.5);
292  fESDList->Add(hElecEta);
293  hElecPhi = new TH2F("Electron_Positron_Phi","Electron_Positron_Phi",360,0,2*TMath::Pi(),360,0,2*TMath::Pi());
294  fESDList->Add(hElecPhi);
295  hElecClsTPC = new TH1F("Electron_ClusterTPC","Electron_ClusterTPC",200,0,200);
296  fESDList->Add(hElecClsTPC);
297  hPosiClsTPC = new TH1F("Positron_ClusterTPC","Positron_ClusterTPC",200,0,200);
298  fESDList->Add(hPosiClsTPC);
299 
300  hElecNfindableClsTPC = new TH1F("Electron_findableClusterTPC","Electron_findableClusterTPC",100,0,1);
302  hPosiNfindableClsTPC = new TH1F("Positron_findableClusterTPC","Positron_findableClusterTPC",100,0,1);
304 
305  hElectrondEdxP = new TH2F("Electron_dEdx_P","Electron_dEdx_P",100, 0.05, 20, 200, 0, 200);
307  fESDList->Add(hElectrondEdxP);
308  hPositrondEdxP = new TH2F("Positron_dEdx_P","Positron_dEdx_P",100, 0.05, 20, 200, 0, 200);
310  fESDList->Add(hPositrondEdxP);
311  hElectronNSigmadEdxP = new TH2F("Electron_NSigmadEdx_P","Electron_NSigmadEdx_P",100, 0.05, 20, 200, -10, 10);
314  hElectronNSigmadEdxEta = new TH2F("Electron_NSigmadEdx_Eta","Electron_NSigmadEdx_Eta",140, -1.4, 1.4, 200, -10, 10);
316  hPositronNSigmadEdxP = new TH2F("Positron_NSigmadEdx_P","Positron_NSigmadEdx_P",100, 0.05, 20, 200, -10, 10);
319  hPositronNSigmadEdxEta = new TH2F("Positron_NSigmadEdx_Eta","Positron_NSigmadEdx_Eta",140, -1.4, 1.4, 200, -10, 10);
321  hElectronNSigmaPiondEdxP = new TH2F("Electron_NSigmaPiondEdx_P","Electron_NSigmaPiondEdx_P",100, 0.05, 20, 200, -10, 10);
324  hPositronNSigmaPiondEdxP = new TH2F("Positron_NSigmaPiondEdx_P","Positron_NSigmaPiondEdx_P",100, 0.05, 20, 200, -10, 10);
327 
328  hElectronTOFP = new TH2F("Electron_TOF_P","Electron_TOF_P",100, 0.05, 20, 600, -1000, 29000);
330  fESDList->Add(hElectronTOFP);
331  hPositronTOFP = new TH2F("Positron_TOF_P","Positron_TOF_P",100, 0.05, 20, 600, -1000, 29000);
333  fESDList->Add(hPositronTOFP);
334  hElectronNSigmaTOFP = new TH2F("Electron_NSigmaTOF_P","Electron_NSigmaTOF_P",100, 0.05, 20, 200, -10, 10);
337  hPositronNSigmaTOFP = new TH2F("Positron_NSigmaTOF_P","Positron_NSigmaTOF_P",100, 0.05, 20, 200, -10, 10);
340 
341  hElectronITSdEdxP = new TH2F("Electron_ITSdEdx_P","Electron_ITSdEdx_P",100, 0.05, 20, 200, 0, 200);
344  hPositronITSdEdxP = new TH2F("Positron_ITSdEdx_P","Positron_ITSdEdx_P",100, 0.05, 20, 200, 0, 200);
347  hElectronNSigmaITSP = new TH2F("Electron_NSigmaITS_P","Electron_NSigmaITS_P",100, 0.05, 20, 200, -10, 10);
350  hPositronNSigmaITSP = new TH2F("Positron_NSigmaITS_P","Positron_NSigmaITS_P",100, 0.05, 20, 200, -10, 10);
353 
354  hInvMassPair = new TH2F("Gamma_InvMassPair_Pt","Gamma invariant mass vs Pt",200,0,0.2,250,0,25);
355  hInvMassPair->SetXTitle("mass (GeV/c)");
356  hInvMassPair->SetYTitle("p_{T} (GeV/c)");
357  fESDList->Add(hInvMassPair);
358 
359  // hGammaXY = new TH2F("Gamma_ConversionPoint_XY","Gamma_ConversionPoint_XY",960,-120,120,960,-120,120);
360  // fESDList->Add(hGammaXY);
361  // hGammaZR= new TH2F("Gamma_ConversionPoint_ZR","Gamma_ConversionPoint_ZR",1200,-150,150,480,0,120);
362  // fESDList->Add(hGammaZR);
363 
364 
365  // hElecAsymP = new TH2F("Electron_Asym_vs_P", "Electron_Asym_vs_P",200,0.,20.,200,0.,1.);
366  // fESDList->Add(hElecAsymP);
367 
368  // if(fIsMC){
369  // fTrueList = new TList();
370  // fTrueList->SetOwner(kTRUE);
371  // fTrueList->SetName("True QA");
372  // fOutputList->Add(fTrueList);
373  //
374  // hTrueResolutionR = new TH2F("True_ConversionPointResolution_R","True_ConversionPointResolution_R",240,0,120,200,-20,20);
375  // fTrueList->Add(hTrueResolutionR);
376  // hTrueResolutionZ = new TH2F("True_ConversionPointResolution_Z","True_ConversionPointResolution_Z",480,-120,120,200,-20,20);
377  // fTrueList->Add(hTrueResolutionZ);
378  // hTrueResolutionPhi = new TH2F("True_ConversionPointResolution_Phi","True_ConversionPointResolution_Phi",360,0,2*TMath::Pi(),200,-TMath::Pi()/30., TMath::Pi()/30.);
379  // fTrueList->Add(hTrueResolutionPhi);
380  //
381  // hTrueGammaPt = new TH1F("True_Gamma_Pt","True_Gamma_Pt",250,0,25);
382  // fTrueList->Add(hTrueGammaPt);
383  // hTrueGammaPhi = new TH1F("True_Gamma_Phi","True_Gamma_Phi",360,0,2*TMath::Pi());
384  // fTrueList->Add(hTrueGammaPhi);
385  // hTrueGammaEta = new TH1F("True_Gamma_Eta","True_Gamma_Eta",600,-1.5,1.5);
386  // fTrueList->Add(hTrueGammaEta);
387  // hTrueGammaMass = new TH1F("True_Gamma_Mass","True_Gamma_Mass",1000,0,0.3);
388  // fTrueList->Add(hTrueGammaMass);
389  // hTrueGammaChi2perNDF = new TH1F("True_Gamma_Chi2perNDF","True_Gamma_Chi2perNDF",500,0,100);
390  // fTrueList->Add(hTrueGammaChi2perNDF);
391  // hTrueGammaPsiPair = new TH1F("True_Gamma_PsiPair","True_Gamma_PsiPair",500,0,2);
392  // fTrueList->Add(hTrueGammaPsiPair);
393  // hTrueGammaQt = new TH1F("True_Gamma_Qt","True_Gamma_Qt",400,0,0.1);
394  // fTrueList->Add(hTrueGammaQt);
395  // hTrueGammaCosinePointingAngle = new TH1F("True_Gamma_CosinePointingAngle","True_Gamma_CosinePointingAngle",900,0.7,1.);
396  // fTrueList->Add(hTrueGammaCosinePointingAngle);
397  // hTrueGammaXY = new TH2F("True_Gamma_ConversionPoint_XY","True_Gamma_ConversionPoint_XY",960,-120,120,960,-120,120);
398  // fTrueList->Add(hTrueGammaXY);
399  // hTrueGammaZR= new TH2F("TrueGamma_ConversionPoint_ZR","TrueGamma_ConversionPoint_ZR",1200,-150,150,480,0,120);
400  // fTrueList->Add(hTrueGammaZR);
401  //
402  // hTrueElecPt = new TH2F("True_Electron_Positron_Pt","True_Electron_Positron_Pt",250,0,25,250,0,25);
403  // fTrueList->Add(hTrueElecPt);
404  // hTrueElecEta = new TH2F("True_Electron_Positron_Eta","True_Electron_Positron_Eta",600,-1.5,1.5,600,-1.5,1.5);
405  // fTrueList->Add(hTrueElecEta);
406  // hTrueElecPhi = new TH2F("True_Electron_Positron_Phi","True_Electron_Positron_Phi",360,0,2*TMath::Pi(),360,0,2*TMath::Pi());
407  // fTrueList->Add(hTrueElecPhi);
408  // hTrueElecNfindableClsTPC = new TH1F("True_Electron_findableClusterTPC","True_Electron_findableClusterTPC",100,0,1);
409  // fTrueList->Add(hTrueElecNfindableClsTPC);
410  // hTruePosiNfindableClsTPC = new TH1F("True_Positron_findableClusterTPC","True_Positron_findableClusterTPC",100,0,1);
411  // fTrueList->Add(hTruePosiNfindableClsTPC);
412  // hTrueElecAsymP = new TH2F("True_Electron_Asym_vs_P", "True_Electron_Asym_vs_P",200,0.,20.,200,0.,1.);
413  // fTrueList->Add(hTrueElecAsymP);
414  // }
415  if(fConversionCuts->GetCutHistograms()){
416  fOutputList->Add(fConversionCuts->GetCutHistograms());
417  }
418  }
419 
420  if(ffillTree>=1.0){
421  fTreeQA = new TTree(Form("PhotonQA_%s_%s",(fEventCuts->GetCutNumber()).Data(),(fConversionCuts->GetCutNumber()).Data()),Form("PhotonQA_%s_%s",(fEventCuts->GetCutNumber()).Data(),(fConversionCuts->GetCutNumber()).Data()));
422 
423  fTreeQA->Branch("daughterProp",&fDaughterProp);
424  fTreeQA->Branch("recCords",&fGammaConvCoord);
425  fTreeQA->Branch("photonProp",&fGammaPhotonProp);
426  fTreeQA->Branch("pt",&fGammaPt,"fGammaPt/F");
427  fTreeQA->Branch("theta",&fGammaTheta,"fGammaTheta/F");
428  fTreeQA->Branch("chi2ndf",&fGammaChi2NDF,"fGammaChi2NDF/F");
429  if (fIsMC) {
430  fTreeQA->Branch("kind",&fKind,"fKind/b");
431  }
432  }
433 
434  fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data());
435 
436  if(fV0Reader && fV0Reader->GetProduceV0FindingEfficiency())
437  if (fV0Reader->GetV0FindingEfficiencyHistograms())
438  fOutputList->Add(fV0Reader->GetV0FindingEfficiencyHistograms());
439 
440 
441  PostData(1, fOutputList);
442  if(ffillTree>=1.0){
443  OpenFile(2);
444  PostData(2, fTreeQA);
445  }
446 }
447 //_____________________________________________________________________________
449 {
450  if (fEventCuts->GetPeriodEnum() == AliConvEventCuts::kNoPeriod && ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum() != AliConvEventCuts::kNoPeriod){
451  fEventCuts->SetPeriodEnumExplicit(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum());
452  } else if (fEventCuts->GetPeriodEnum() == AliConvEventCuts::kNoPeriod ){
453  fEventCuts->SetPeriodEnum(fV0Reader->GetPeriodName());
454  }
455 
456 
457  if(!fEventCuts->GetDoEtaShift()) return kTRUE; // No Eta Shift requested, continue
458 
459  if(fEventCuts->GetEtaShift() == 0.0){ // Eta Shift requested but not set, get shift automatically
460  fEventCuts->GetCorrectEtaShiftFromPeriod();
461  fEventCuts->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
462  return kTRUE;
463  }
464  else{
465  printf(" Gamma Conversion QA Task %s :: Eta Shift Manually Set to %f \n\n",
466  (fEventCuts->GetCutNumber()).Data(),fEventCuts->GetEtaShift());
467  fEventCuts->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
468  }
469 
470  return kTRUE;
471 }
472 //________________________________________________________________________
474 
475  Int_t eventQuality = ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEventQuality();
476  if(eventQuality != 0){// Event Not Accepted
477  return;
478  }
479  fInputEvent = InputEvent();
480  if(fIsMC) fMCEvent = MCEvent();
481 
482  Int_t eventNotAccepted =
483  fEventCuts->IsEventAcceptedByCut(fV0Reader->GetEventCuts(),fInputEvent,fMCEvent,fIsHeavyIon,kFALSE);
484  if(eventNotAccepted) return; // Check Centrality, PileUp, SDD and V0AND --> Not Accepted => eventQuality = 1
485 
486  fConversionGammas=fV0Reader->GetReconstructedGammas();
487 
488  if(fMCEvent){
489  if(fEventCuts->GetSignalRejection() != 0){
490  if(fInputEvent->IsA()==AliESDEvent::Class()){
491  fEventCuts->GetNotRejectedParticles(fEventCuts->GetSignalRejection(),
492  fEventCuts->GetAcceptedHeader(),
493  fMCEvent);
494  }
495  else if(fInputEvent->IsA()==AliAODEvent::Class()){
496  fEventCuts->GetNotRejectedParticles(fEventCuts->GetSignalRejection(),
497  fEventCuts->GetAcceptedHeader(),
498  fInputEvent);
499  }
500  }
501  }
502 
503  if(ffillHistograms){
504  CountTracks();
505  hVertexZ->Fill(fInputEvent->GetPrimaryVertex()->GetZ());
506  hNContributorsVertex->Fill(fEventCuts->GetNumberOfContributorsVtx(fInputEvent));
508  hNV0Tracks->Fill(fInputEvent->GetVZEROData()->GetMTotV0A()+fInputEvent->GetVZEROData()->GetMTotV0C());
509  }
510 
511  if(fMCEvent && fInputEvent->IsA()==AliAODEvent::Class() && !(fV0Reader->AreAODsRelabeled())){
512  RelabelAODPhotonCandidates(kTRUE); // In case of AODMC relabeling MC
513  fV0Reader->RelabelAODs(kTRUE);
514  }
515 
516  // reduce event statistics in the tree by a factor ffilltree
517  Bool_t ffillTreeNew = kFALSE;
518  if(ffillTree>=1.0) {
519  ffillTreeNew = kTRUE;
520  if (ffillTree>1.0) {
521  gRandom->SetSeed(0);
522  if(gRandom->Uniform(ffillTree)>1.0) {
523  ffillTreeNew = kFALSE;
524  }
525  }
526  }
527 
528  if(fConversionCuts->GetDoElecDeDxPostCalibration()){
529  if(!fConversionCuts->LoadElecDeDxPostCalibration(fInputEvent->GetRunNumber())){
530  AliFatal(Form("ERROR: LoadElecDeDxPostCalibration returned kFALSE for %d despite being requested!",fInputEvent->GetRunNumber()));
531  }
532  }
533 
534  for(Int_t firstGammaIndex=0;firstGammaIndex<fConversionGammas->GetEntriesFast();firstGammaIndex++){
535  AliAODConversionPhoton *gamma=dynamic_cast<AliAODConversionPhoton*>(fConversionGammas->At(firstGammaIndex));
536  if (gamma==NULL) continue;
537  if(fMCEvent && fEventCuts->GetSignalRejection() != 0){
538  if(!fEventCuts->IsParticleFromBGEvent(gamma->GetMCLabelPositive(), fMCEvent, fInputEvent))
539  continue;
540  if(!fEventCuts->IsParticleFromBGEvent(gamma->GetMCLabelNegative(), fMCEvent, fInputEvent))
541  continue;
542  }
543  if(!fConversionCuts->PhotonIsSelected(gamma,fInputEvent)){
544  continue;
545  }
546 
547  if(ffillTreeNew) ProcessQATree(gamma);
548  if(ffillHistograms) ProcessQA(gamma);
549  }
550 
551  if(fMCEvent && fInputEvent->IsA()==AliAODEvent::Class() && !(fV0Reader->AreAODsRelabeled())){
552  RelabelAODPhotonCandidates(kFALSE); // Back to ESDMC Label
553  fV0Reader->RelabelAODs(kFALSE);
554  }
555 
556  PostData(1, fOutputList);
557 }
558 
559 
561 void AliAnalysisTaskConversionQA::ProcessQATree(AliAODConversionPhoton *gamma){
562 
563  // Fill Histograms for QA and MC
564  AliVEvent* event = (AliVEvent*) InputEvent();
565 
566  AliPIDResponse* pidResonse = ((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetPIDResponse();
567 
568  fGammaPt = gamma->GetPhotonPt();
569 
570  fGammaTheta = gamma->Theta();
571  fGammaChi2NDF = gamma->GetChi2perNDF();
572 
573  fGammaPhotonProp(0) = gamma->GetArmenterosQt();
574  fGammaPhotonProp(1) = gamma->GetArmenterosAlpha();
575  fGammaPhotonProp(2) = gamma->GetPsiPair();
576  fGammaPhotonProp(3) = fConversionCuts->GetCosineOfPointingAngle(gamma,event);
577  fGammaPhotonProp(4) = gamma->GetInvMassPair();
578 
579  fGammaConvCoord(0) = gamma->GetConversionX();
580  fGammaConvCoord(1) = gamma->GetConversionY();
581  fGammaConvCoord(2) = gamma->GetConversionZ();
582  fGammaConvCoord(3) = gamma->GetConversionRadius();
583  fGammaConvCoord(4) = gamma->GetPhotonPhi();
584 
585  AliVTrack * negTrack = fConversionCuts->GetTrack(event, gamma->GetTrackLabelNegative());
586  AliVTrack * posTrack = fConversionCuts->GetTrack(event, gamma->GetTrackLabelPositive());
587 
588 
589  if(!negTrack||!posTrack)return;
590 
591  fKind = 9;
592  if(fMCEvent && fInputEvent->IsA()==AliESDEvent::Class()){
593  fKind = IsTruePhotonESD(gamma);
594  } else if (fMCEvent && fInputEvent->IsA()==AliAODEvent::Class()){
595  // cout << "entering IsTruePhotonAOD" << endl;
596  fKind = IsTruePhotonAOD(gamma);
597  }
598 
599  fDaughterProp(0) = posTrack->Pt();
600  fDaughterProp(7) = negTrack->Pt();
601  fDaughterProp(1) = posTrack->Theta();
602  fDaughterProp(8) = negTrack->Theta();
603  // dEdx TPC
604  Double_t electronNSigmaTPC = pidResonse->NumberOfSigmasTPC(negTrack,AliPID::kElectron);
605  Double_t electronNSigmaTPCCor=0.;
606  Double_t positronNSigmaTPC = pidResonse->NumberOfSigmasTPC(posTrack,AliPID::kElectron);
607  Double_t positronNSigmaTPCCor=0.;
608  if(fConversionCuts->GetDoElecDeDxPostCalibration()){
609  electronNSigmaTPCCor = fConversionCuts->GetCorrectedElectronTPCResponse(negTrack->Charge(),electronNSigmaTPC,negTrack->P(),negTrack->Eta(),negTrack->GetNcls(1),gamma->GetConversionRadius());
610  positronNSigmaTPCCor = fConversionCuts->GetCorrectedElectronTPCResponse(posTrack->Charge(),positronNSigmaTPC,posTrack->P(),posTrack->Eta(),posTrack->GetNcls(1),gamma->GetConversionRadius());
611  fDaughterProp(3) = positronNSigmaTPCCor;
612  fDaughterProp(10) = electronNSigmaTPCCor;
613  } else {
614  fDaughterProp(3) = pidResonse->NumberOfSigmasTPC(posTrack,AliPID::kElectron);
615  fDaughterProp(10) = pidResonse->NumberOfSigmasTPC(negTrack,AliPID::kElectron);
616  }
617  fDaughterProp(2) = posTrack->GetTPCsignal();
618  fDaughterProp(22) = pidResonse->NumberOfSigmasTPC(posTrack,AliPID::kPion);
619  fDaughterProp(9) = negTrack->GetTPCsignal();
620  fDaughterProp(23) = pidResonse->NumberOfSigmasTPC(negTrack,AliPID::kPion);
621  Int_t nPosClusterITS = 0;
622  Int_t nNegClusterITS = 0;
623  for(Int_t itsLayer = 0; itsLayer<6;itsLayer++){
624  if(TESTBIT(negTrack->GetITSClusterMap(),itsLayer)){
625  nNegClusterITS++;
626  }
627  if(TESTBIT(posTrack->GetITSClusterMap(),itsLayer)){
628  nPosClusterITS++;
629  }
630  }
631 
632  // ITS signal
633  fDaughterProp(14) = (Float_t)nPosClusterITS;
634  fDaughterProp(15) = (Float_t)nNegClusterITS;
635  if (nPosClusterITS > 0 ){
636  fDaughterProp(16) = posTrack->GetITSsignal();
637  fDaughterProp(20) = pidResonse->NumberOfSigmasITS(posTrack,AliPID::kElectron);
638  } else {
639  fDaughterProp(16) = 1000;
640  fDaughterProp(20) = 20;
641  }
642  if (nNegClusterITS > 0 ){
643  fDaughterProp(17) = negTrack->GetITSsignal();
644  fDaughterProp(21) = pidResonse->NumberOfSigmasITS(negTrack,AliPID::kElectron);
645  } else {
646  fDaughterProp(17) = 1000;
647  fDaughterProp(21) = 20;
648  }
649 
650 
651  // if((posTrack->GetStatus() & AliESDtrack::kTOFpid) && !(posTrack->GetStatus() & AliESDtrack::kTOFmismatch)){
652  if((posTrack->GetStatus() & AliVTrack::kTOFout) && (posTrack->GetStatus() & AliVTrack::kTIME) ){
653  Double_t t0pos = pidResonse->GetTOFResponse().GetStartTime(posTrack->P());
654  Double_t timesPos[9];
655  posTrack->GetIntegratedTimes(timesPos,9);
656  Double_t TOFsignalPos = posTrack->GetTOFsignal();
657  Double_t dTpos = TOFsignalPos - t0pos - timesPos[0];
658  fDaughterProp(4) = dTpos;
659  fDaughterProp(5) = pidResonse->NumberOfSigmasTOF(posTrack, AliPID::kElectron);
660  } else {
661  fDaughterProp(4) = 20000;
662  fDaughterProp(5) = -20;
663  }
664  //if((negTrack->GetStatus() & AliESDtrack::kTOFpid) && !(negTrack->GetStatus() & AliESDtrack::kTOFmismatch)){
665  if((negTrack->GetStatus() & AliVTrack::kTOFout) && (negTrack->GetStatus() & AliVTrack::kTIME) ){
666  Double_t t0neg = pidResonse->GetTOFResponse().GetStartTime(negTrack->P());
667  Double_t timesNeg[9];
668  negTrack->GetIntegratedTimes(timesNeg,9);
669  Double_t TOFsignalNeg = negTrack->GetTOFsignal();
670  Double_t dTneg = TOFsignalNeg - t0neg - timesNeg[0];
671  fDaughterProp(11) = dTneg;
672  fDaughterProp(12) = pidResonse->NumberOfSigmasTOF(negTrack, AliPID::kElectron);
673  } else {
674  fDaughterProp(11) = 20000;
675  fDaughterProp(12) = -20;
676  }
677 
678  fDaughterProp(6) = (Float_t)posTrack->GetTPCClusterInfo(2,0,fConversionCuts->GetFirstTPCRow(gamma->GetConversionRadius()));
679  fDaughterProp(18) = posTrack->GetNcls(1);
680  fDaughterProp(13) = (Float_t)negTrack->GetTPCClusterInfo(2,0,fConversionCuts->GetFirstTPCRow(gamma->GetConversionRadius()));
681  fDaughterProp(19) = negTrack->GetNcls(1);
682 
683  if (fTreeQA){
684  fTreeQA->Fill();
685  }
686 }
687 
688 //_____________________________________________________________________________________________________
689 void AliAnalysisTaskConversionQA::ProcessQA(AliAODConversionPhoton *gamma){
690 
691  AliPIDResponse* pidResonse = ((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetPIDResponse();
692 
693  // Fill Histograms for QA and MC
694 
695  hGammaPt->Fill(gamma->GetPhotonPt());
696  hGammaPhi->Fill(gamma->GetPhotonPhi());
697  if(gamma->Eta() >= 0.00001){hGammaPhi_Pos->Fill(gamma->Phi());}
698  if(gamma->Eta() <= 0.00001){hGammaPhi_Neg->Fill(gamma->Phi());}
699  hGammaEta->Fill(gamma->Eta());
700  hGammaChi2perNDF->Fill(gamma->GetChi2perNDF());
701  hGammaPsiPair->Fill(gamma->GetPsiPair());
702  hGammaArmenteros->Fill(gamma->GetArmenterosAlpha(),gamma->GetArmenterosQt());
703  hGammaCosinePointingAngle->Fill(fConversionCuts->GetCosineOfPointingAngle(gamma,fInputEvent));
704  hGammaInvMass->Fill(gamma->GetMass());
705  hInvMassPair->Fill(gamma->GetInvMassPair(),gamma->GetPhotonPt());
706  // hGammaXY->Fill(gamma->GetConversionX(),gamma->GetConversionY());
707  // hGammaZR->Fill(gamma->GetConversionZ(),gamma->GetConversionRadius());
708 
709  AliVTrack * negTrack = fConversionCuts->GetTrack(fInputEvent, gamma->GetTrackLabelNegative());
710  AliVTrack * posTrack = fConversionCuts->GetTrack(fInputEvent, gamma->GetTrackLabelPositive());
711  if(!negTrack||!posTrack)return;
712 
713 
714  hElecPt->Fill(negTrack->Pt(),posTrack->Pt());
715  hElecEta->Fill(negTrack->Eta(),posTrack->Eta());
716  hElecPhi->Fill(negTrack->Phi(),posTrack->Phi());
717 
718  hElecNfindableClsTPC->Fill((Float_t)posTrack->GetTPCClusterInfo(2,0,fConversionCuts->GetFirstTPCRow(gamma->GetConversionRadius())));
719  hPosiNfindableClsTPC->Fill((Float_t)negTrack->GetTPCClusterInfo(2,0,fConversionCuts->GetFirstTPCRow(gamma->GetConversionRadius())));
720  hElecClsTPC->Fill(negTrack->GetNcls(1));
721  hPosiClsTPC->Fill(posTrack->GetNcls(1));
722  //TPC dEdx
723  hElectrondEdxP->Fill(negTrack->P() ,negTrack->GetTPCsignal());
724  hElectronNSigmadEdxP->Fill(negTrack->P() ,pidResonse->NumberOfSigmasTPC(negTrack, AliPID::kElectron));
725  hElectronNSigmadEdxEta->Fill(negTrack->Eta() ,pidResonse->NumberOfSigmasTPC(negTrack, AliPID::kElectron));
726  hElectronNSigmaPiondEdxP->Fill(negTrack->P() ,pidResonse->NumberOfSigmasTPC(negTrack, AliPID::kPion));
727  hPositrondEdxP->Fill(posTrack->P() ,posTrack->GetTPCsignal());
728  hPositronNSigmadEdxP->Fill(posTrack->P() ,pidResonse->NumberOfSigmasTPC(posTrack, AliPID::kElectron));
729  hPositronNSigmadEdxEta->Fill(posTrack->Eta() ,pidResonse->NumberOfSigmasTPC(posTrack, AliPID::kElectron));
730  hPositronNSigmaPiondEdxP->Fill(posTrack->P() ,pidResonse->NumberOfSigmasTPC(posTrack, AliPID::kPion));
731 
732  //TOF signal
733  if((negTrack->GetStatus() & AliVTrack::kTOFout) && (negTrack->GetStatus() & AliVTrack::kTIME) ){
734  //if((negTrack->GetStatus() & AliESDtrack::kTOFpid)==0 && !(negTrack->GetStatus() & AliESDtrack::kTOFmismatch)){
735  Double_t t0neg = pidResonse->GetTOFResponse().GetStartTime(negTrack->P());
736  Double_t timesNeg[9];
737  negTrack->GetIntegratedTimes(timesNeg,9);
738  Double_t TOFsignalNeg = negTrack->GetTOFsignal();
739  Double_t dTneg = TOFsignalNeg - t0neg - timesNeg[0];
740  hElectronTOFP->Fill(negTrack->P() ,dTneg);
741  hElectronNSigmaTOFP->Fill(negTrack->P() ,pidResonse->NumberOfSigmasTOF(negTrack, AliPID::kElectron));
742  }
743  if((posTrack->GetStatus() & AliVTrack::kTOFout) && (posTrack->GetStatus() & AliVTrack::kTIME) ){
744  //if((posTrack->GetStatus() & AliESDtrack::kTOFpid)==0 && !(posTrack->GetStatus() & AliESDtrack::kTOFmismatch)){
745  Double_t t0pos = pidResonse->GetTOFResponse().GetStartTime(posTrack->P());
746  Double_t timesPos[9];
747  posTrack->GetIntegratedTimes(timesPos,9);
748  Double_t TOFsignalPos = posTrack->GetTOFsignal();
749  Double_t dTpos = TOFsignalPos - t0pos - timesPos[0];
750  hPositronTOFP->Fill(posTrack->P() ,dTpos);
751  hPositronNSigmaTOFP->Fill(posTrack->P() ,pidResonse->NumberOfSigmasTOF(posTrack, AliPID::kElectron));
752  }
753 
754  Int_t nPosClusterITS = 0;
755  Int_t nNegClusterITS = 0;
756  for(Int_t itsLayer = 0; itsLayer<6;itsLayer++){
757  if(TESTBIT(negTrack->GetITSClusterMap(),itsLayer)){
758  nNegClusterITS++;
759  }
760  if(TESTBIT(posTrack->GetITSClusterMap(),itsLayer)){
761  nPosClusterITS++;
762  }
763  }
764  Double_t negtrackPhi = negTrack->Phi();
765  Double_t postrackPhi = posTrack->Phi();
766  hITSClusterPhi->Fill(negtrackPhi,nNegClusterITS);
767  hITSClusterPhi->Fill(postrackPhi,nPosClusterITS);
768 
769  // ITS signal
770  if (nPosClusterITS > 0 ){
771  hPositronITSdEdxP->Fill(posTrack->P() ,posTrack->GetITSsignal());
772  hPositronNSigmaITSP->Fill(posTrack->P() ,pidResonse->NumberOfSigmasITS(posTrack,AliPID::kElectron));
773  }
774  if (nNegClusterITS > 0 ){
775  hElectronITSdEdxP->Fill(negTrack->P() ,negTrack->GetITSsignal());
776  hElectronNSigmaITSP->Fill(negTrack->P() ,pidResonse->NumberOfSigmasITS(negTrack,AliPID::kElectron));
777  }
778 
779 
780 }
781 
782 
783 //________________________________________________________________________
785 
786  if(fInputEvent->IsA()==AliESDEvent::Class()){
787  // Using standard function for setting Cuts
788  Bool_t selectPrimaries=kTRUE;
789  AliESDtrackCuts *EsdTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(selectPrimaries);
790  EsdTrackCuts->SetMaxDCAToVertexZ(2);
791  EsdTrackCuts->SetEtaRange(-0.8, 0.8);
792  EsdTrackCuts->SetPtRange(0.15);
793  fNumberOfESDTracks = 0;
794  for(Int_t iTracks = 0; iTracks < fInputEvent->GetNumberOfTracks(); iTracks++){
795  AliESDtrack* curTrack = (AliESDtrack*) fInputEvent->GetTrack(iTracks);
796  if(!curTrack) continue;
797  if(EsdTrackCuts->AcceptTrack(curTrack) ) fNumberOfESDTracks++;
798  }
799  delete EsdTrackCuts;
800  EsdTrackCuts=0x0;
801  }
802  else if(fInputEvent->IsA()==AliAODEvent::Class()){
803  fNumberOfESDTracks = 0;
804  for(Int_t iTracks = 0; iTracks<fInputEvent->GetNumberOfTracks(); iTracks++){
805  AliAODTrack* curTrack = (AliAODTrack*) fInputEvent->GetTrack(iTracks);
806  if(curTrack->GetID()<0) continue; // Avoid double counting of tracks
807  if(!curTrack->IsHybridGlobalConstrainedGlobal()) continue;
808  if(TMath::Abs(curTrack->Eta())>0.8) continue;
809  if(curTrack->Pt()<0.15) continue;
811  }
812  }
813  return;
814 }
815 
816 UInt_t AliAnalysisTaskConversionQA::IsTruePhotonESD(AliAODConversionPhoton *TruePhotonCandidate)
817 {
818  UInt_t kind = 9;
819  TParticle *posDaughter = TruePhotonCandidate->GetPositiveMCDaughter(fMCEvent);
820  TParticle *negDaughter = TruePhotonCandidate->GetNegativeMCDaughter(fMCEvent);
821  Int_t pdgCodePos = 0;
822  Int_t pdgCodeNeg = 0;
823  Int_t pdgCode = 0;
824 
825  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
826  Double_t mcProdVtxX = primVtxMC->GetX();
827  Double_t mcProdVtxY = primVtxMC->GetY();
828  Double_t mcProdVtxZ = primVtxMC->GetZ();
829 
830 
831  if(posDaughter == NULL || negDaughter == NULL) {
832  kind = 9;
833  // return kFALSE; // One particle does not exist
834 
835  } else if( posDaughter->GetMother(0) != negDaughter->GetMother(0) || (posDaughter->GetMother(0) == negDaughter->GetMother(0) && posDaughter->GetMother(0) ==-1)) {
836  kind = 1;
837  // return 1;
838  pdgCodePos=TMath::Abs(posDaughter->GetPdgCode());
839  pdgCodeNeg=TMath::Abs(negDaughter->GetPdgCode());
840  if(pdgCodePos==11 && pdgCodeNeg==11) return 10; //Electron Combinatorial
841  if(pdgCodePos==11 && pdgCodeNeg==11 &&
842  (posDaughter->GetMother(0) == negDaughter->GetMother(0) && posDaughter->GetMother(0) ==-1)) return 15; //direct Electron Combinatorial
843 
844  if(pdgCodePos==211 && pdgCodeNeg==211) kind = 11; //Pion Combinatorial
845  if((pdgCodePos==211 && pdgCodeNeg==2212) ||(pdgCodePos==2212 && pdgCodeNeg==211)) kind = 12; //Pion, Proton Combinatorics
846  if((pdgCodePos==11 && pdgCodeNeg==2212) ||(pdgCodePos==2212 && pdgCodeNeg==11)) kind = 16; //electron, Proton Combinatorics
847  if((pdgCodePos==11 && pdgCodeNeg==321) ||(pdgCodePos==321 && pdgCodeNeg==11)) kind = 17; //electron, kaon
848  if((pdgCodePos==211 && pdgCodeNeg==321) ||(pdgCodePos==321 && pdgCodeNeg==211)) kind = 18; //pion, kaon
849  if((pdgCodePos==211 && pdgCodeNeg==11) ||(pdgCodePos==11 && pdgCodeNeg==211)) kind = 13; //Pion, Electron Combinatorics
850  if(pdgCodePos==321 && pdgCodeNeg==321) kind = 14; //Kaon,Kaon combinatorics
851  }else{
852  pdgCodePos=posDaughter->GetPdgCode();
853  pdgCodeNeg=negDaughter->GetPdgCode();
854  Bool_t gammaIsPrimary = fEventCuts->IsConversionPrimaryESD( fMCEvent, posDaughter->GetMother(0), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
855  if ( TruePhotonCandidate->GetMCParticle(fMCEvent)->GetPdgCode()) pdgCode = TruePhotonCandidate->GetMCParticle(fMCEvent)->GetPdgCode();
856 
857  if(TMath::Abs(pdgCodePos)!=11 || TMath::Abs(pdgCodeNeg)!=11) return 2; // true from hadronic decays
858  else if ( !(pdgCodeNeg==pdgCodePos)){
859  if(pdgCode == 111) return 3; // pi0 Dalitz
860  else if (pdgCode == 221) return 4; // eta Dalitz
861  else if (!(negDaughter->GetUniqueID() != 5 || posDaughter->GetUniqueID() !=5)){
862  if(pdgCode == 22 && gammaIsPrimary){
863  return 0; // primary photons
864  } else if (pdgCode == 22){
865  return 5; //secondary photons
866  }
867  }
868  }
869  }
870 
871  return kind;
872 }
873 
874 //________________________________________________________________________
875 UInt_t AliAnalysisTaskConversionQA::IsTruePhotonAOD(AliAODConversionPhoton *TruePhotonCandidate)
876 {
877 
878  UInt_t kind = 9;
879  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
880  if (AODMCTrackArray!=NULL && TruePhotonCandidate!=NULL){
881  AliAODMCParticle *posDaughter = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetMCLabelPositive());
882  AliAODMCParticle *negDaughter = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetMCLabelNegative());
883  Int_t pdgCodePos = 0;
884  Int_t pdgCodeNeg = 0;
885  Int_t pdgCode = 0;
886  if(posDaughter == NULL || negDaughter == NULL) {
887  kind = 9;
888  } else if( posDaughter->GetMother() != negDaughter->GetMother() || (posDaughter->GetMother() == negDaughter->GetMother() && posDaughter->GetMother() ==-1)) {
889  kind = 1;
890  pdgCodePos=TMath::Abs(posDaughter->GetPdgCode());
891  pdgCodeNeg=TMath::Abs(negDaughter->GetPdgCode());
892  if(pdgCodePos==11 && pdgCodeNeg==11) kind = 10; //Electron Combinatorial
893  if(pdgCodePos==11 && pdgCodeNeg==11 &&
894  (posDaughter->GetMother() == negDaughter->GetMother() && posDaughter->GetMother() ==-1))kind = 15; //direct Electron Combinatorial
895 
896  if(pdgCodePos==211 && pdgCodeNeg==211) kind = 11; //Pion Combinatorial
897  if((pdgCodePos==211 && pdgCodeNeg==2212) ||(pdgCodePos==2212 && pdgCodeNeg==211)) kind = 12; //Pion, Proton Combinatorics
898  if((pdgCodePos==11 && pdgCodeNeg==2212) ||(pdgCodePos==2212 && pdgCodeNeg==11)) kind = 16; //electron, Proton Combinatorics
899  if((pdgCodePos==11 && pdgCodeNeg==321) ||(pdgCodePos==321 && pdgCodeNeg==11)) kind = 17; //electron, kaon
900  if((pdgCodePos==211 && pdgCodeNeg==321) ||(pdgCodePos==321 && pdgCodeNeg==211)) kind = 18; //pion, kaon
901  if((pdgCodePos==211 && pdgCodeNeg==11) ||(pdgCodePos==11 && pdgCodeNeg==211)) kind = 13; //Pion, Electron Combinatorics
902  if(pdgCodePos==321 && pdgCodeNeg==321) kind = 14; //Kaon,Kaon combinatorics
903  }else{
904  AliAODMCParticle *Photon = (AliAODMCParticle*) AODMCTrackArray->At(posDaughter->GetMother());
905  pdgCodePos=posDaughter->GetPdgCode();
906  pdgCodeNeg=negDaughter->GetPdgCode();
907 
908  if ( Photon->GetPdgCode())
909  pdgCode = Photon->GetPdgCode();
910  if(TMath::Abs(pdgCodePos)!=11 || TMath::Abs(pdgCodeNeg)!=11) kind = 2; // true from hadronic decays
911  else if ( !(pdgCodeNeg==pdgCodePos)){
912  if(pdgCode == 111) kind = 3; // pi0 Dalitz
913  else if (pdgCode == 221) kind = 4; // eta Dalitz
914  else if (!(negDaughter->GetMCProcessCode() != 5 || posDaughter->GetMCProcessCode() !=5)){
915  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
916  Double_t mcProdVtxX = primVtxMC->GetX();
917  Double_t mcProdVtxY = primVtxMC->GetY();
918  Double_t mcProdVtxZ = primVtxMC->GetZ();
919  Bool_t isPrimary = fEventCuts->IsConversionPrimaryAOD(fInputEvent, Photon, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
920 
921  if(pdgCode == 22 && isPrimary){
922  kind = 0; // primary photons
923  } else if (pdgCode == 22){
924  kind = 5; //secondary photons
925  }
926  }
927  }
928  }
929 
930  return kind;
931  }
932  return kind;
933 }
934 
935 //________________________________________________________________________
937 
938  // Relabeling For AOD Event
939  // ESDiD -> AODiD
940  // MCLabel -> AODMCLabel
941 
942  if(mode){
943  fMCStackPos = new Int_t[fConversionGammas->GetEntries()];
944  fMCStackNeg = new Int_t[fConversionGammas->GetEntries()];
945  }
946 
947  for(Int_t iGamma = 0;iGamma<fConversionGammas->GetEntries();iGamma++){
948  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) fConversionGammas->At(iGamma);
949  if(!PhotonCandidate) continue;
950  if(!mode){// Back to ESD Labels
951  PhotonCandidate->SetMCLabelPositive(fMCStackPos[iGamma]);
952  PhotonCandidate->SetMCLabelNegative(fMCStackNeg[iGamma]);
953  //PhotonCandidate->IsAODMCLabel(kFALSE);
954  continue;
955  }
956  fMCStackPos[iGamma] = PhotonCandidate->GetMCLabelPositive();
957  fMCStackNeg[iGamma] = PhotonCandidate->GetMCLabelNegative();
958 
959  Bool_t AODLabelPos = kFALSE;
960  Bool_t AODLabelNeg = kFALSE;
961 
962  for(Int_t i = 0; i<fInputEvent->GetNumberOfTracks();i++){
963  AliAODTrack *tempDaughter = static_cast<AliAODTrack*>(fInputEvent->GetTrack(i));
964  if(!AODLabelPos){
965  if( tempDaughter->GetID() == PhotonCandidate->GetTrackLabelPositive() ){
966  PhotonCandidate->SetMCLabelPositive(TMath::Abs(tempDaughter->GetLabel()));
967  AODLabelPos = kTRUE;
968  }
969  }
970  if(!AODLabelNeg){
971  if( tempDaughter->GetID() == PhotonCandidate->GetTrackLabelNegative()){
972  PhotonCandidate->SetMCLabelNegative(TMath::Abs(tempDaughter->GetLabel()));
973  AODLabelNeg = kTRUE;
974  }
975  }
976  if(AODLabelNeg && AODLabelPos){
977  break;
978  }
979  } // Both ESD Tracks have AOD Tracks with Positive IDs
980  if(!AODLabelPos || !AODLabelNeg){
981  for(Int_t i = 0; i<fInputEvent->GetNumberOfTracks();i++){
982  AliAODTrack *tempDaughter = static_cast<AliAODTrack*>(fInputEvent->GetTrack(i));
983  if(tempDaughter->GetID()<0){
984  if(!AODLabelPos){
985  if( (TMath::Abs(tempDaughter->GetID())-1) == PhotonCandidate->GetTrackLabelPositive()){
986  PhotonCandidate->SetMCLabelPositive(TMath::Abs(tempDaughter->GetLabel()));
987  AODLabelPos = kTRUE;
988  }
989  }
990  if(!AODLabelNeg){
991  if( (TMath::Abs(tempDaughter->GetID())-1) == PhotonCandidate->GetTrackLabelNegative()){
992  PhotonCandidate->SetMCLabelNegative(TMath::Abs(tempDaughter->GetLabel()));
993  AODLabelNeg = kTRUE;
994  }
995  }
996  }
997  if(AODLabelNeg && AODLabelPos){
998  break;
999  }
1000  }
1001  if(!AODLabelPos || !AODLabelNeg){
1002  cout<<"WARNING!!! AOD TRACKS NOT FOUND FOR"<<endl;
1003  if(!AODLabelNeg){
1004  PhotonCandidate->SetMCLabelNegative(-999999);
1005  PhotonCandidate->SetLabelNegative(-999999);
1006  }
1007  if(!AODLabelPos){
1008  PhotonCandidate->SetMCLabelPositive(-999999);
1009  PhotonCandidate->SetLabelPositive(-999999);
1010  }
1011  }
1012  }
1013  }
1014 
1015  if(!mode){
1016  delete[] fMCStackPos;
1017  delete[] fMCStackNeg;
1018  }
1019 }
1020 
1022  TAxis *axisafter = histoRebin->GetXaxis();
1023  Int_t bins = axisafter->GetNbins();
1024  Double_t from = axisafter->GetXmin();
1025  Double_t to = axisafter->GetXmax();
1026  Double_t *newbins = new Double_t[bins+1];
1027  newbins[0] = from;
1028  Double_t factor = TMath::Power(to/from, 1./bins);
1029  for(Int_t i=1; i<=bins; ++i) newbins[i] = factor * newbins[i-1];
1030  axisafter->Set(bins, newbins);
1031  delete [] newbins;
1032 
1033 }
1034 
1035 //________________________________________________________________________
1037 {
1038 
1039 }
double Double_t
Definition: External.C:58
Definition: External.C:236
TRandom * gRandom
AliConversionPhotonCuts * fConversionCuts
int Int_t
Definition: External.C:63
virtual void UserExec(Option_t *option)
Definition: External.C:204
unsigned int UInt_t
Definition: External.C:33
float Float_t
Definition: External.C:68
UInt_t IsTruePhotonESD(AliAODConversionPhoton *TruePhotonCandidate)
Int_t mode
Definition: anaM.C:41
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
UInt_t IsTruePhotonAOD(AliAODConversionPhoton *TruePhotonCandidate)
Definition: External.C:220
const char Option_t
Definition: External.C:48
void ProcessQATree(AliAODConversionPhoton *gamma)
bool Bool_t
Definition: External.C:53
void ProcessQA(AliAODConversionPhoton *gamma)
TList * OpenFile(const char *fname)
Definition: DrawAnaELoss.C:65