changed Resolution, Material, and PhotonQA task to be able to run on the grid
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / AliAnalysisTaskGammaConvV1.cxx
CommitLineData
2bb2434e 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
0a2b2b4b 4 * Author: Martin Wilde, Daniel Lohner, Friederike Bock *
2bb2434e 5 * Version 1.0 *
6 * *
0a2b2b4b 7 * based on: on older version (see aliroot up to v5-04-42-AN) *
8 * AliAnalysisTaskGammaConversion.cxx *
9 * Authors: Kathrin Koch, Kenneth Aamodt, Ana Marin *
10 * *
2bb2434e 11 * Permission to use, copy, modify and distribute this software and its *
12 * documentation strictly for non-commercial purposes is hereby granted *
13 * without fee, provided that the above copyright notice appears in all *
14 * copies and that both the copyright notice and this permission notice *
15 * appear in the supporting documentation. The authors make no claims *
16 * about the suitability of this software for any purpose. It is *
17 * provided "as is" without express or implied warranty. *
18 **************************************************************************/
19
20////////////////////////////////////////////////
21//---------------------------------------------
ae947965 22
2bb2434e 23// Class used to do analysis on conversion pairs
24//---------------------------------------------
25///////////////////////////////////////////////
26#include "TChain.h"
27#include "TTree.h"
4803eb1f 28#include "TBranch.h"
29#include "TFile.h"
2bb2434e 30#include "TH1F.h"
31#include "TH2F.h"
32#include "TH3F.h"
33#include "THnSparse.h"
34#include "TCanvas.h"
35#include "TNtuple.h"
36#include "AliAnalysisTask.h"
37#include "AliAnalysisManager.h"
38#include "AliESDEvent.h"
39#include "AliESDInputHandler.h"
40#include "AliMCEventHandler.h"
41#include "AliMCEvent.h"
42#include "AliMCParticle.h"
43#include "AliCentrality.h"
44#include "AliESDVZERO.h"
45#include "AliESDpid.h"
46#include "AliAnalysisTaskGammaConvV1.h"
47#include "AliVParticle.h"
1390f698 48#include "AliESDtrack.h"
2bb2434e 49#include "AliESDtrackCuts.h"
50#include "AliKFVertex.h"
51#include "AliV0ReaderV1.h"
ca91a3e1 52#include "AliGenCocktailEventHeader.h"
e5b6e8a6 53#include "AliConversionAODBGHandlerRP.h"
ae947965 54#include "AliAODMCParticle.h"
55#include "AliAODMCHeader.h"
2bb2434e 56
57ClassImp(AliAnalysisTaskGammaConvV1)
58
59//________________________________________________________________________
60AliAnalysisTaskGammaConvV1::AliAnalysisTaskGammaConvV1(): AliAnalysisTaskSE(),
61 fV0Reader(NULL),
62 fBGHandler(NULL),
e5b6e8a6 63 fBGHandlerRP(NULL),
64 fInputEvent(NULL),
2bb2434e 65 fMCEvent(NULL),
66 fMCStack(NULL),
67 fCutFolder(NULL),
68 fESDList(NULL),
69 fBackList(NULL),
ca91a3e1 70 fMotherList(NULL),
4803eb1f 71 fPhotonDCAList(NULL),
72 fMesonDCAList(NULL),
2bb2434e 73 fTrueList(NULL),
0a2b2b4b 74 fTrueMotherRapList(NULL),
2bb2434e 75 fMCList(NULL),
ca91a3e1 76 fHeaderNameList(NULL),
2bb2434e 77 fOutputContainer(0),
78 fReaderGammas(NULL),
a280ac15 79 fGammaCandidates(NULL),
2bb2434e 80 fCutArray(NULL),
81 fConversionCuts(NULL),
ca91a3e1 82 fMesonCutArray(NULL),
83 fMesonCuts(NULL),
2bb2434e 84 hESDConvGammaPt(NULL),
4803eb1f 85 tESDConvGammaPtDcazCat(NULL),
86 fPtGamma(0),
87 fDCAzPhoton(0),
88 fRConvPhoton(0),
89 fEtaPhoton(0),
90 iCatPhoton(0),
91 iPhotonMCInfo(0),
2bb2434e 92 hESDMotherInvMassPt(NULL),
93 sESDMotherInvMassPtZM(NULL),
94 hESDMotherBackInvMassPt(NULL),
95 sESDMotherBackInvMassPtZM(NULL),
96 hESDMotherInvMassEalpha(NULL),
1186afd2 97 hMCHeaders(NULL),
2bb2434e 98 hMCAllGammaPt(NULL),
2bb2434e 99 hMCDecayGammaPi0Pt(NULL),
2bb2434e 100 hMCDecayGammaRhoPt(NULL),
2bb2434e 101 hMCDecayGammaEtaPt(NULL),
2bb2434e 102 hMCDecayGammaOmegaPt(NULL),
2bb2434e 103 hMCDecayGammaEtapPt(NULL),
2bb2434e 104 hMCDecayGammaPhiPt(NULL),
e5b6e8a6 105 hMCDecayGammaSigmaPt(NULL),
2bb2434e 106 hMCConvGammaPt(NULL),
ca91a3e1 107 hMCConvGammaR(NULL),
108 hMCConvGammaEta(NULL),
e5b6e8a6 109 hMCConvGammaRSPt(NULL),
110 hMCConvGammaRSR(NULL),
111 hMCConvGammaRSEta(NULL),
2bb2434e 112 hMCPi0Pt(NULL),
ae947965 113 hMCPi0WOWeightPt(NULL),
2bb2434e 114 hMCEtaPt(NULL),
115 hMCPi0InAccPt(NULL),
116 hMCEtaInAccPt(NULL),
0a2b2b4b 117 hMCPi0PtY(NULL),
118 hMCEtaPtY(NULL),
ae947965 119 hMCK0sPt(NULL),
120 hMCK0sWOWeightPt(NULL),
121 hMCK0sPtY(NULL),
2bb2434e 122 hESDTrueMotherInvMassPt(NULL),
a280ac15 123 hESDTruePrimaryMotherInvMassPt(NULL),
526074e4 124 hESDTruePrimaryMotherW0WeightingInvMassPt(NULL),
125 pESDTruePrimaryMotherWeightsInvMassPt(NULL),
0a2b2b4b 126 hESDTruePrimaryPi0MCPtResolPt(NULL),
127 hESDTruePrimaryEtaMCPtResolPt(NULL),
2bb2434e 128 hESDTrueSecondaryMotherInvMassPt(NULL),
2bb2434e 129 hESDTrueSecondaryMotherFromK0sInvMassPt(NULL),
e5b6e8a6 130 hESDTrueK0sWithPi0DaughterMCPt(NULL),
131 hESDTrueSecondaryMotherFromEtaInvMassPt(NULL),
132 hESDTrueEtaWithPi0DaughterMCPt(NULL),
2bb2434e 133 hESDTrueBckGGInvMassPt(NULL),
134 hESDTrueBckContInvMassPt(NULL),
135 hESDTrueMotherDalitzInvMassPt(NULL),
2bb2434e 136 hESDTrueConvGammaPt(NULL),
e5b6e8a6 137 hESDCombinatorialPt(NULL),
2bb2434e 138 hESDTruePrimaryConvGammaPt(NULL),
2bb2434e 139 hESDTruePrimaryConvGammaESDPtMCPt(NULL),
e5b6e8a6 140 hESDTruePrimaryConvGammaRSESDPtMCPt(NULL),
2bb2434e 141 hESDTrueSecondaryConvGammaPt(NULL),
2bb2434e 142 hESDTrueSecondaryConvGammaFromXFromK0sPt(NULL),
4803eb1f 143 hESDTrueSecondaryConvGammaFromXFromLambdaPt(NULL),
1390f698 144 hESDTrueDalitzPsiPairDeltaPhi(NULL),
145 hESDTrueGammaPsiPairDeltaPhi(NULL),
2bb2434e 146 hNEvents(NULL),
147 hNGoodESDTracks(NULL),
a280ac15 148 hNGammaCandidates(NULL),
2bb2434e 149 hNV0Tracks(NULL),
ae947965 150 hEtaShift(NULL),
4803eb1f 151 tESDMesonsInvMassPtDcazMinDcazMaxFlag(NULL),
152 fInvMass(0),
153 fPt(0),
154 fDCAzGammaMin(0),
155 fDCAzGammaMax(0),
156 iFlag(0),
157 iMesonMCInfo(0),
2bb2434e 158 fRandom(0),
a280ac15 159 fnGammaCandidates(0),
2bb2434e 160 fUnsmearedPx(NULL),
161 fUnsmearedPy(NULL),
162 fUnsmearedPz(NULL),
163 fUnsmearedE(NULL),
ae947965 164 fMCStackPos(NULL),
165 fMCStackNeg(NULL),
1186afd2 166 fESDArrayPos(NULL),
167 fESDArrayNeg(NULL),
e5b6e8a6 168 fnCuts(0),
169 fiCut(0),
e5b6e8a6 170 fMoveParticleAccordingToVertex(kTRUE),
2bb2434e 171 fIsHeavyIon(kFALSE),
e5b6e8a6 172 fDoMesonAnalysis(kTRUE),
0a2b2b4b 173 fDoMesonQA(kFALSE),
174 fDoPhotonQA(kFALSE),
ae947965 175 fIsFromMBHeader(kTRUE),
176 fIsMC(kFALSE)
2bb2434e 177{
a280ac15 178
2bb2434e 179}
180
181//________________________________________________________________________
182AliAnalysisTaskGammaConvV1::AliAnalysisTaskGammaConvV1(const char *name):
183 AliAnalysisTaskSE(name),
184 fV0Reader(NULL),
185 fBGHandler(NULL),
e5b6e8a6 186 fBGHandlerRP(NULL),
187 fInputEvent(NULL),
2bb2434e 188 fMCEvent(NULL),
189 fMCStack(NULL),
190 fCutFolder(NULL),
191 fESDList(NULL),
192 fBackList(NULL),
ca91a3e1 193 fMotherList(NULL),
4803eb1f 194 fPhotonDCAList(NULL),
195 fMesonDCAList(NULL),
2bb2434e 196 fTrueList(NULL),
0a2b2b4b 197 fTrueMotherRapList(NULL),
2bb2434e 198 fMCList(NULL),
ca91a3e1 199 fHeaderNameList(NULL),
2bb2434e 200 fOutputContainer(0),
201 fReaderGammas(NULL),
a280ac15 202 fGammaCandidates(NULL),
2bb2434e 203 fCutArray(NULL),
204 fConversionCuts(NULL),
ca91a3e1 205 fMesonCutArray(NULL),
206 fMesonCuts(NULL),
2bb2434e 207 hESDConvGammaPt(NULL),
4803eb1f 208 tESDConvGammaPtDcazCat(NULL),
209 fPtGamma(0),
210 fDCAzPhoton(0),
211 fRConvPhoton(0),
212 fEtaPhoton(0),
213 iCatPhoton(0),
214 iPhotonMCInfo(0),
2bb2434e 215 hESDMotherInvMassPt(NULL),
216 sESDMotherInvMassPtZM(NULL),
217 hESDMotherBackInvMassPt(NULL),
218 sESDMotherBackInvMassPtZM(NULL),
219 hESDMotherInvMassEalpha(NULL),
1186afd2 220 hMCHeaders(NULL),
2bb2434e 221 hMCAllGammaPt(NULL),
2bb2434e 222 hMCDecayGammaPi0Pt(NULL),
2bb2434e 223 hMCDecayGammaRhoPt(NULL),
2bb2434e 224 hMCDecayGammaEtaPt(NULL),
2bb2434e 225 hMCDecayGammaOmegaPt(NULL),
2bb2434e 226 hMCDecayGammaEtapPt(NULL),
2bb2434e 227 hMCDecayGammaPhiPt(NULL),
e5b6e8a6 228 hMCDecayGammaSigmaPt(NULL),
2bb2434e 229 hMCConvGammaPt(NULL),
ca91a3e1 230 hMCConvGammaR(NULL),
231 hMCConvGammaEta(NULL),
e5b6e8a6 232 hMCConvGammaRSPt(NULL),
233 hMCConvGammaRSR(NULL),
234 hMCConvGammaRSEta(NULL),
2bb2434e 235 hMCPi0Pt(NULL),
ae947965 236 hMCPi0WOWeightPt(NULL),
2bb2434e 237 hMCEtaPt(NULL),
238 hMCPi0InAccPt(NULL),
239 hMCEtaInAccPt(NULL),
0a2b2b4b 240 hMCPi0PtY(NULL),
241 hMCEtaPtY(NULL),
ae947965 242 hMCK0sPt(NULL),
243 hMCK0sWOWeightPt(NULL),
244 hMCK0sPtY(NULL),
2bb2434e 245 hESDTrueMotherInvMassPt(NULL),
a280ac15 246 hESDTruePrimaryMotherInvMassPt(NULL),
526074e4 247 hESDTruePrimaryMotherW0WeightingInvMassPt(NULL),
248 pESDTruePrimaryMotherWeightsInvMassPt(NULL),
0a2b2b4b 249 hESDTruePrimaryPi0MCPtResolPt(NULL),
250 hESDTruePrimaryEtaMCPtResolPt(NULL),
2bb2434e 251 hESDTrueSecondaryMotherInvMassPt(NULL),
2bb2434e 252 hESDTrueSecondaryMotherFromK0sInvMassPt(NULL),
e5b6e8a6 253 hESDTrueK0sWithPi0DaughterMCPt(NULL),
254 hESDTrueSecondaryMotherFromEtaInvMassPt(NULL),
255 hESDTrueEtaWithPi0DaughterMCPt(NULL),
2bb2434e 256 hESDTrueBckGGInvMassPt(NULL),
257 hESDTrueBckContInvMassPt(NULL),
258 hESDTrueMotherDalitzInvMassPt(NULL),
2bb2434e 259 hESDTrueConvGammaPt(NULL),
e5b6e8a6 260 hESDCombinatorialPt(NULL),
2bb2434e 261 hESDTruePrimaryConvGammaPt(NULL),
2bb2434e 262 hESDTruePrimaryConvGammaESDPtMCPt(NULL),
e5b6e8a6 263 hESDTruePrimaryConvGammaRSESDPtMCPt(NULL),
2bb2434e 264 hESDTrueSecondaryConvGammaPt(NULL),
2bb2434e 265 hESDTrueSecondaryConvGammaFromXFromK0sPt(NULL),
4803eb1f 266 hESDTrueSecondaryConvGammaFromXFromLambdaPt(NULL),
1390f698 267 hESDTrueDalitzPsiPairDeltaPhi(NULL),
268 hESDTrueGammaPsiPairDeltaPhi(NULL),
2bb2434e 269 hNEvents(NULL),
270 hNGoodESDTracks(NULL),
a280ac15 271 hNGammaCandidates(NULL),
2bb2434e 272 hNV0Tracks(NULL),
ae947965 273 hEtaShift(NULL),
4803eb1f 274 tESDMesonsInvMassPtDcazMinDcazMaxFlag(NULL),
275 fInvMass(0),
276 fPt(0),
277 fDCAzGammaMin(0),
278 fDCAzGammaMax(0),
279 iFlag(0),
280 iMesonMCInfo(0),
2bb2434e 281 fRandom(0),
a280ac15 282 fnGammaCandidates(0),
2bb2434e 283 fUnsmearedPx(NULL),
284 fUnsmearedPy(NULL),
285 fUnsmearedPz(NULL),
286 fUnsmearedE(NULL),
ae947965 287 fMCStackPos(NULL),
288 fMCStackNeg(NULL),
1186afd2 289 fESDArrayPos(NULL),
290 fESDArrayNeg(NULL),
e5b6e8a6 291 fnCuts(0),
292 fiCut(0),
e5b6e8a6 293 fMoveParticleAccordingToVertex(kTRUE),
2bb2434e 294 fIsHeavyIon(kFALSE),
e5b6e8a6 295 fDoMesonAnalysis(kTRUE),
0a2b2b4b 296 fDoMesonQA(kFALSE),
297 fDoPhotonQA(kFALSE),
ae947965 298 fIsFromMBHeader(kTRUE),
299 fIsMC(kFALSE)
2bb2434e 300{
a280ac15 301 // Define output slots here
2bb2434e 302 DefineOutput(1, TList::Class());
303}
304
305AliAnalysisTaskGammaConvV1::~AliAnalysisTaskGammaConvV1()
306{
a280ac15 307 if(fGammaCandidates){
308 delete fGammaCandidates;
309 fGammaCandidates = 0x0;
2bb2434e 310 }
311 if(fBGHandler){
312 delete[] fBGHandler;
313 fBGHandler = 0x0;
314 }
e5b6e8a6 315 if(fBGHandlerRP){
316 delete[] fBGHandlerRP;
317 fBGHandlerRP = 0x0;
318 }
2bb2434e 319}
320//___________________________________________________________
321void AliAnalysisTaskGammaConvV1::InitBack(){
322
2bb2434e 323 const Int_t nDim = 4;
11c1e680 324 Int_t nBins[nDim] = {800,250,7,4};
2bb2434e 325 Double_t xMin[nDim] = {0,0, 0,0};
11c1e680 326 Double_t xMax[nDim] = {0.8,25,7,4};
4803eb1f 327
2bb2434e 328 sESDMotherInvMassPtZM = new THnSparseF*[fnCuts];
329 sESDMotherBackInvMassPtZM = new THnSparseF*[fnCuts];
330
331 fBGHandler = new AliGammaConversionAODBGHandler*[fnCuts];
e5b6e8a6 332 fBGHandlerRP = new AliConversionAODBGHandlerRP*[fnCuts];
2bb2434e 333 for(Int_t iCut = 0; iCut<fnCuts;iCut++){
e5b6e8a6 334 if (((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->DoBGCalculation()){
335 TString cutstring = ((AliConversionCuts*)fCutArray->At(iCut))->GetCutNumber();
336 TString cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
11c1e680 337
338 Int_t collisionSystem = atoi((TString)(((AliConversionCuts*)fCutArray->At(iCut))->GetCutNumber())(0,1));
339 Int_t centMin = atoi((TString)(((AliConversionCuts*)fCutArray->At(iCut))->GetCutNumber())(1,1));
340 Int_t centMax = atoi((TString)(((AliConversionCuts*)fCutArray->At(iCut))->GetCutNumber())(2,1));
341
342 if(collisionSystem == 1 || collisionSystem == 2 ||
343 collisionSystem == 5 || collisionSystem == 8 ||
344 collisionSystem == 9){
345 centMin = centMin*10;
346 centMax = centMax*10;
347 }
348 else if(collisionSystem == 3 || collisionSystem == 6){
349 centMin = centMin*5;
350 centMax = centMax*5;
351 }
352 else if(collisionSystem == 4 || collisionSystem == 7){
353 centMin = ((centMin*5)+45);
354 centMax = ((centMax*5)+45);
355 }
356
e5b6e8a6 357 fBackList[iCut] = new TList();
358 fBackList[iCut]->SetName(Form("%s_%s Back histograms",cutstring.Data(),cutstringMeson.Data()));
359 fBackList[iCut]->SetOwner(kTRUE);
360 fCutFolder[iCut]->Add(fBackList[iCut]);
361
362 sESDMotherBackInvMassPtZM[iCut] = new THnSparseF("Back_Back_InvMass_Pt_z_m","Back_Back_InvMass_Pt_z_m",nDim,nBins,xMin,xMax);
e5b6e8a6 363 fBackList[iCut]->Add(sESDMotherBackInvMassPtZM[iCut]);
364
365 fMotherList[iCut] = new TList();
366 fMotherList[iCut]->SetName(Form("%s_%s Mother histograms",cutstring.Data(),cutstringMeson.Data()));
367 fMotherList[iCut]->SetOwner(kTRUE);
368 fCutFolder[iCut]->Add(fMotherList[iCut]);
369
370 sESDMotherInvMassPtZM[iCut] = new THnSparseF("Back_Mother_InvMass_Pt_z_m","Back_Mother_InvMass_Pt_z_m",nDim,nBins,xMin,xMax);
e5b6e8a6 371 fMotherList[iCut]->Add(sESDMotherInvMassPtZM[iCut]);
372
373 if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->BackgroundHandlerType() == 0){
11c1e680 374 fBGHandler[iCut] = new AliGammaConversionAODBGHandler(
375 collisionSystem,centMin,centMax,
376 ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetNumberOfBGEvents(),
377 ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseTrackMultiplicity());
378 fBGHandlerRP[iCut] = NULL;
e5b6e8a6 379 }
380 else{
381 fBGHandlerRP[iCut] = new AliConversionAODBGHandlerRP(
382 ((AliConversionCuts*)fCutArray->At(fiCut))->IsHeavyIon(),
383 ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity(),
384 ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetNumberOfBGEvents());
385 fBGHandler[iCut] = NULL;
386 }
2bb2434e 387 }
388 }
389}
390//________________________________________________________________________
391void AliAnalysisTaskGammaConvV1::UserCreateOutputObjects()
392{
393
394 // Create histograms
395 if(fOutputContainer != NULL){
396 delete fOutputContainer;
397 fOutputContainer = NULL;
398 }
399 if(fOutputContainer == NULL){
400 fOutputContainer = new TList();
401 fOutputContainer->SetOwner(kTRUE);
402 }
403
404 // Array of current cut's gammas
a280ac15 405 fGammaCandidates = new TList();
2bb2434e 406
407 fCutFolder = new TList*[fnCuts];
408 fESDList = new TList*[fnCuts];
409 fBackList = new TList*[fnCuts];
ca91a3e1 410 fMotherList = new TList*[fnCuts];
2bb2434e 411 hNEvents = new TH1I*[fnCuts];
412 hNGoodESDTracks = new TH1I*[fnCuts];
a280ac15 413 hNGammaCandidates = new TH1I*[fnCuts];
ca91a3e1 414 hNV0Tracks = new TH1I*[fnCuts];
4803eb1f 415 hEtaShift = new TProfile*[fnCuts];
0a2b2b4b 416 hESDConvGammaPt = new TH1F*[fnCuts];
ae947965 417
0a2b2b4b 418 if (fDoPhotonQA){
4803eb1f 419 fPhotonDCAList = new TList*[fnCuts];
420 tESDConvGammaPtDcazCat = new TTree*[fnCuts];
0a2b2b4b 421 }
4803eb1f 422
2bb2434e 423 if(fDoMesonAnalysis){
424 hESDMotherInvMassPt = new TH2F*[fnCuts];
425 hESDMotherBackInvMassPt = new TH2F*[fnCuts];
426 hESDMotherInvMassEalpha = new TH2F*[fnCuts];
0a2b2b4b 427 if (fDoMesonQA){
4803eb1f 428 fMesonDCAList = new TList*[fnCuts];
429 tESDMesonsInvMassPtDcazMinDcazMaxFlag = new TTree*[fnCuts];
0a2b2b4b 430 }
2bb2434e 431 }
0a2b2b4b 432
2bb2434e 433 for(Int_t iCut = 0; iCut<fnCuts;iCut++){
434
435 TString cutstring = ((AliConversionCuts*)fCutArray->At(iCut))->GetCutNumber();
4803eb1f 436 TString cutstringMeson = "NoMesonCut";
437 if(fDoMesonAnalysis)cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
e5b6e8a6 438
2bb2434e 439 fCutFolder[iCut] = new TList();
ca91a3e1 440 fCutFolder[iCut]->SetName(Form("Cut Number %s_%s",cutstring.Data(),cutstringMeson.Data()));
2bb2434e 441 fCutFolder[iCut]->SetOwner(kTRUE);
442 fOutputContainer->Add(fCutFolder[iCut]);
443 fESDList[iCut] = new TList();
ca91a3e1 444 fESDList[iCut]->SetName(Form("%s_%s ESD histograms",cutstring.Data(),cutstringMeson.Data()));
2bb2434e 445 fESDList[iCut]->SetOwner(kTRUE);
a280ac15 446 fCutFolder[iCut]->Add(fESDList[iCut]);
2bb2434e 447
e5b6e8a6 448 hNEvents[iCut] = new TH1I("NEvents","NEvents",9,-0.5,8.5);
449 hNEvents[iCut]->GetXaxis()->SetBinLabel(1,"Accepted");
450 hNEvents[iCut]->GetXaxis()->SetBinLabel(2,"Centrality");
451 hNEvents[iCut]->GetXaxis()->SetBinLabel(3,"Missing MC");
1186afd2 452 if (((AliConversionCuts*)fCutArray->At(iCut))->IsSpecialTrigger() == 4 ){
453 TString TriggerNames = "Not Trigger: ";
454 TriggerNames = TriggerNames+ ( (AliConversionCuts*)fCutArray->At(iCut))->GetSpecialTriggerName();
455 hNEvents[iCut]->GetXaxis()->SetBinLabel(4,TriggerNames.Data());
456 } else {
457 hNEvents[iCut]->GetXaxis()->SetBinLabel(4,"Trigger");
458 }
e5b6e8a6 459 hNEvents[iCut]->GetXaxis()->SetBinLabel(5,"Vertex Z");
460 hNEvents[iCut]->GetXaxis()->SetBinLabel(6,"Cont. Vertex");
461 hNEvents[iCut]->GetXaxis()->SetBinLabel(7,"Pile-Up");
462 hNEvents[iCut]->GetXaxis()->SetBinLabel(8,"no SDD");
463 hNEvents[iCut]->GetXaxis()->SetBinLabel(9,"no V0AND");
2bb2434e 464 fESDList[iCut]->Add(hNEvents[iCut]);
4803eb1f 465 if(fIsHeavyIon) hNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",4000,0,4000);
2bb2434e 466 else hNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",200,0,200);
467 fESDList[iCut]->Add(hNGoodESDTracks[iCut]);
a280ac15 468 if(fIsHeavyIon) hNGammaCandidates[iCut] = new TH1I("GammaCandidates","GammaCandidates",100,0,100);
469 else hNGammaCandidates[iCut] = new TH1I("GammaCandidates","GammaCandidates",50,0,50);
470 fESDList[iCut]->Add(hNGammaCandidates[iCut]);
e5b6e8a6 471 if(fIsHeavyIon) hNV0Tracks[iCut] = new TH1I("V0 Multiplicity","V0 Multiplicity",30000,0,30000);
2bb2434e 472 else hNV0Tracks[iCut] = new TH1I("V0 Multiplicity","V0 Multiplicity",2000,0,2000);
473 fESDList[iCut]->Add(hNV0Tracks[iCut]);
4803eb1f 474 hEtaShift[iCut] = new TProfile("Eta Shift","Eta Shift",1, -0.5,0.5);
ae947965 475 fESDList[iCut]->Add(hEtaShift[iCut]);
2bb2434e 476 hESDConvGammaPt[iCut] = new TH1F("ESD_ConvGamma_Pt","ESD_ConvGamma_Pt",250,0,25);
477 fESDList[iCut]->Add(hESDConvGammaPt[iCut]);
0a2b2b4b 478
479 if (fDoPhotonQA){
4803eb1f 480 fPhotonDCAList[iCut] = new TList();
481 fPhotonDCAList[iCut]->SetName(Form("%s_%s Photon DCA tree",cutstring.Data(),cutstringMeson.Data()));
482 fPhotonDCAList[iCut]->SetOwner(kTRUE);
483 fCutFolder[iCut]->Add(fPhotonDCAList[iCut]);
484
485 tESDConvGammaPtDcazCat[iCut] = new TTree("ESD_ConvGamma_Pt_Dcaz_R_Eta","ESD_ConvGamma_Pt_Dcaz_R_Eta_Cat");
486 tESDConvGammaPtDcazCat[iCut]->Branch("Pt",&fPtGamma,"fPtGamma/F");
487 tESDConvGammaPtDcazCat[iCut]->Branch("DcaZPhoton",&fDCAzPhoton,"fDCAzPhoton/F");
488// tESDConvGammaPtDcazCat[iCut]->Branch("R",&fRConvPhoton,"fRConvPhoton/F");
489// tESDConvGammaPtDcazCat[iCut]->Branch("Eta",&fEtaPhoton,"fEtaPhoton/F");
490
491 tESDConvGammaPtDcazCat[iCut]->Branch("cat",&iCatPhoton,"iCatPhoton/b");
492 if(fIsMC){
493 tESDConvGammaPtDcazCat[iCut]->Branch("photonMCInfo",&iPhotonMCInfo,"iPhotonMCInfo/b");
494 }
495 fPhotonDCAList[iCut]->Add(tESDConvGammaPtDcazCat[iCut]);
0a2b2b4b 496 }
2bb2434e 497
498 if(fDoMesonAnalysis){
e5b6e8a6 499 hESDMotherInvMassPt[iCut] = new TH2F("ESD_Mother_InvMass_Pt","ESD_Mother_InvMass_Pt",800,0,0.8,250,0,25);
2bb2434e 500 fESDList[iCut]->Add(hESDMotherInvMassPt[iCut]);
e5b6e8a6 501 hESDMotherBackInvMassPt[iCut] = new TH2F("ESD_Background_InvMass_Pt","ESD_Background_InvMass_Pt",800,0,0.8,250,0,25);
2bb2434e 502 fESDList[iCut]->Add(hESDMotherBackInvMassPt[iCut]);
e5b6e8a6 503 hESDMotherInvMassEalpha[iCut] = new TH2F("ESD_Mother_InvMass_vs_E_alpha","ESD_Mother_InvMass_vs_E_alpha",800,0,0.8,250,0,25);
2bb2434e 504 fESDList[iCut]->Add(hESDMotherInvMassEalpha[iCut]);
4803eb1f 505 if (fDoMesonQA){
506 fMesonDCAList[iCut] = new TList();
507 fMesonDCAList[iCut]->SetName(Form("%s_%s Meson DCA tree",cutstring.Data(),cutstringMeson.Data()));
508 fMesonDCAList[iCut]->SetOwner(kTRUE);
509 fCutFolder[iCut]->Add(fMesonDCAList[iCut]);
510
511 tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut] = new TTree("ESD_Mesons_InvMass_Pt_DcazMin_DcazMax_Flag","ESD_Mesons_InvMass_Pt_DcazMin_DcazMax_Flag");
512 tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]->Branch("InvMass",&fInvMass,"fInvMass/F");
513 tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]->Branch("Pt",&fPt,"fPt/F");
514 tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]->Branch("DcaZMin",&fDCAzGammaMin,"fDCAzGammaMin/F");
515 tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]->Branch("DcaZMax",&fDCAzGammaMax,"fDCAzGammaMax/F");
516 tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]->Branch("kind",&iFlag,"iFlag/b");
517 if(fIsMC){
518 tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]->Branch("mesonMCInfo",&iMesonMCInfo,"iMesonMCInfo/b");
519 }
520 fMesonDCAList[iCut]->Add(tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]);
521
0a2b2b4b 522 }
2bb2434e 523 }
524
0a2b2b4b 525
2bb2434e 526 }
2bb2434e 527 if(fDoMesonAnalysis){
528 InitBack(); // Init Background Handler
529 }
530
ae947965 531 if(fIsMC){
2bb2434e 532 // MC Histogramms
533 fMCList = new TList*[fnCuts];
534 // True Histogramms
535 fTrueList = new TList*[fnCuts];
ca91a3e1 536 // Selected Header List
537 fHeaderNameList = new TList*[fnCuts];
1186afd2 538 hMCHeaders = new TH1I*[fnCuts];
2bb2434e 539 hMCAllGammaPt = new TH1F*[fnCuts];
2bb2434e 540 hMCDecayGammaPi0Pt = new TH1F*[fnCuts];
2bb2434e 541 hMCDecayGammaRhoPt = new TH1F*[fnCuts];
ca91a3e1 542 hMCDecayGammaEtaPt = new TH1F*[fnCuts];
2bb2434e 543 hMCDecayGammaOmegaPt = new TH1F*[fnCuts];
2bb2434e 544 hMCDecayGammaEtapPt = new TH1F*[fnCuts];
2bb2434e 545 hMCDecayGammaPhiPt = new TH1F*[fnCuts];
e5b6e8a6 546 hMCDecayGammaSigmaPt = new TH1F*[fnCuts];
2bb2434e 547 hMCConvGammaPt = new TH1F*[fnCuts];
e5b6e8a6 548 hMCConvGammaRSPt = new TH1F*[fnCuts];
2bb2434e 549 hESDTrueConvGammaPt = new TH1F*[fnCuts];
e5b6e8a6 550
551 hESDCombinatorialPt = new TH2F*[fnCuts];
ca91a3e1 552 hESDTruePrimaryConvGammaPt = new TH1F*[fnCuts];
2bb2434e 553 hESDTruePrimaryConvGammaESDPtMCPt = new TH2F*[fnCuts];
e5b6e8a6 554 hESDTruePrimaryConvGammaRSESDPtMCPt = new TH2F*[fnCuts];
2bb2434e 555 hESDTrueSecondaryConvGammaPt = new TH1F*[fnCuts];
2bb2434e 556 hESDTrueSecondaryConvGammaFromXFromK0sPt = new TH1F*[fnCuts];
4803eb1f 557 hESDTrueSecondaryConvGammaFromXFromLambdaPt = new TH1F*[fnCuts];
ca91a3e1 558
1390f698 559 hESDTrueDalitzPsiPairDeltaPhi= new TH2F*[fnCuts];
560 hESDTrueGammaPsiPairDeltaPhi= new TH2F*[fnCuts];
561
0a2b2b4b 562 if (fDoPhotonQA){
563 hMCConvGammaR = new TH1F*[fnCuts];
564 hMCConvGammaEta = new TH1F*[fnCuts];
565 hMCConvGammaRSR = new TH1F*[fnCuts];
566 hMCConvGammaRSEta = new TH1F*[fnCuts];
0a2b2b4b 567 }
568
2bb2434e 569 if(fDoMesonAnalysis){
570 hMCPi0Pt = new TH1F*[fnCuts];
ae947965 571 hMCPi0WOWeightPt = new TH1F*[fnCuts];
2bb2434e 572 hMCEtaPt = new TH1F*[fnCuts];
573 hMCPi0InAccPt = new TH1F*[fnCuts];
574 hMCEtaInAccPt = new TH1F*[fnCuts];
2bb2434e 575
576 hESDTrueMotherInvMassPt = new TH2F*[fnCuts];
a280ac15 577 hESDTruePrimaryMotherInvMassPt = new TH2F*[fnCuts];
526074e4 578 hESDTruePrimaryMotherW0WeightingInvMassPt = new TH2F*[fnCuts];
579 pESDTruePrimaryMotherWeightsInvMassPt = new TProfile2D*[fnCuts];
2bb2434e 580 hESDTrueSecondaryMotherInvMassPt = new TH2F*[fnCuts];
2bb2434e 581 hESDTrueSecondaryMotherFromK0sInvMassPt = new TH2F*[fnCuts];
e5b6e8a6 582 hESDTrueSecondaryMotherFromEtaInvMassPt = new TH2F*[fnCuts];
86eaf9ae 583 hESDTrueMotherDalitzInvMassPt = new TH2F*[fnCuts];
0a2b2b4b 584 if (fDoMesonQA){
585 hMCPi0PtY = new TH2F*[fnCuts];
586 hMCEtaPtY = new TH2F*[fnCuts];
ae947965 587 hMCK0sPt = new TH1F*[fnCuts];
588 hMCK0sWOWeightPt = new TH1F*[fnCuts];
589 hMCK0sPtY = new TH2F*[fnCuts];
0a2b2b4b 590 hESDTruePrimaryPi0MCPtResolPt = new TH2F*[fnCuts];
591 hESDTruePrimaryEtaMCPtResolPt = new TH2F*[fnCuts];
592 hESDTrueK0sWithPi0DaughterMCPt = new TH1F*[fnCuts];
593 hESDTrueEtaWithPi0DaughterMCPt = new TH1F*[fnCuts];
594 hESDTrueBckGGInvMassPt = new TH2F*[fnCuts];
595 hESDTrueBckContInvMassPt = new TH2F*[fnCuts];
0a2b2b4b 596 fTrueMotherRapList = new TList*[fnCuts];
0a2b2b4b 597 }
2bb2434e 598 }
599
600 for(Int_t iCut = 0; iCut<fnCuts;iCut++){
601 TString cutstring = ((AliConversionCuts*)fCutArray->At(iCut))->GetCutNumber();
4803eb1f 602 TString cutstringMeson = "NoMesonCut";
603 if(fDoMesonAnalysis)cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
e5b6e8a6 604
605 fMCList[iCut] = new TList();
ca91a3e1 606 fMCList[iCut]->SetName(Form("%s_%s MC histograms",cutstring.Data(),cutstringMeson.Data()));
2bb2434e 607 fMCList[iCut]->SetOwner(kTRUE);
608 fCutFolder[iCut]->Add(fMCList[iCut]);
1186afd2 609 hMCHeaders[iCut] = new TH1I("MC_Headers","MC_Headers",20,0,20);
610 fMCList[iCut]->Add(hMCHeaders[iCut]);
2bb2434e 611 hMCAllGammaPt[iCut] = new TH1F("MC_AllGamma_Pt","MC_AllGamma_Pt",250,0,25);
612 fMCList[iCut]->Add(hMCAllGammaPt[iCut]);
2bb2434e 613 hMCDecayGammaPi0Pt[iCut] = new TH1F("MC_DecayGammaPi0_Pt","MC_DecayGammaPi0_Pt",250,0,25);
614 fMCList[iCut]->Add(hMCDecayGammaPi0Pt[iCut]);
2bb2434e 615 hMCDecayGammaRhoPt[iCut] = new TH1F("MC_DecayGammaRho_Pt","MC_DecayGammaRho_Pt",250,0,25);
616 fMCList[iCut]->Add(hMCDecayGammaRhoPt[iCut]);
2bb2434e 617 hMCDecayGammaEtaPt[iCut] = new TH1F("MC_DecayGammaEta_Pt","MC_DecayGammaEta_Pt",250,0,25);
618 fMCList[iCut]->Add(hMCDecayGammaEtaPt[iCut]);
2bb2434e 619 hMCDecayGammaOmegaPt[iCut] = new TH1F("MC_DecayGammaOmega_Pt","MC_DecayGammaOmmega_Pt",250,0,25);
620 fMCList[iCut]->Add(hMCDecayGammaOmegaPt[iCut]);
2bb2434e 621 hMCDecayGammaEtapPt[iCut] = new TH1F("MC_DecayGammaEtap_Pt","MC_DecayGammaEtap_Pt",250,0,25);
622 fMCList[iCut]->Add(hMCDecayGammaEtapPt[iCut]);
2bb2434e 623 hMCDecayGammaPhiPt[iCut] = new TH1F("MC_DecayGammaPhi_Pt","MC_DecayGammaPhi_Pt",250,0,25);
624 fMCList[iCut]->Add(hMCDecayGammaPhiPt[iCut]);
e5b6e8a6 625 hMCDecayGammaSigmaPt[iCut] = new TH1F("MC_DecayGammaSigma_Pt","MC_DecayGammaSigma_Pt",250,0,25);
626 fMCList[iCut]->Add(hMCDecayGammaSigmaPt[iCut]);
2bb2434e 627 hMCConvGammaPt[iCut] = new TH1F("MC_ConvGamma_Pt","MC_ConvGamma_Pt",250,0,25);
628 fMCList[iCut]->Add(hMCConvGammaPt[iCut]);
e5b6e8a6 629 hMCConvGammaRSPt[iCut] = new TH1F("MC_ConvGamma_RS_Pt","MC_ConvGamma_RS_Pt",250,0,25);
630 fMCList[iCut]->Add(hMCConvGammaRSPt[iCut]);
0a2b2b4b 631
632 if (fDoPhotonQA){
633 hMCConvGammaR[iCut] = new TH1F("MC_ConvGamma_R","MC_ConvGamma_R",800,0,200);
634 fMCList[iCut]->Add(hMCConvGammaR[iCut]);
635 hMCConvGammaEta[iCut] = new TH1F("MC_ConvGamma_Eta","MC_ConvGamma_Eta",100,-4,4);
636 fMCList[iCut]->Add(hMCConvGammaEta[iCut]);
637 hMCConvGammaRSR[iCut] = new TH1F("MC_ConvGamma_RS_R","MC_ConvGamma_RS_R",800,0,200);
638 fMCList[iCut]->Add(hMCConvGammaRSR[iCut]);
639 hMCConvGammaRSEta[iCut] = new TH1F("MC_ConvGamma_RS_Eta","MC_ConvGamma_RS_Eta",100,-4,4);
640 fMCList[iCut]->Add(hMCConvGammaRSEta[iCut]);
641 }
e5b6e8a6 642
2bb2434e 643 if(fDoMesonAnalysis){
644 hMCPi0Pt[iCut] = new TH1F("MC_Pi0_Pt","MC_Pi0_Pt",250,0,25);
0a2b2b4b 645 hMCPi0Pt[iCut]->Sumw2();
2bb2434e 646 fMCList[iCut]->Add(hMCPi0Pt[iCut]);
ae947965 647 hMCPi0WOWeightPt[iCut] = new TH1F("MC_Pi0_WOWeights_Pt","MC_Pi0_WOWeights_Pt",250,0,25);
648 hMCPi0WOWeightPt[iCut]->Sumw2();
649 fMCList[iCut]->Add(hMCPi0WOWeightPt[iCut]);
650
2bb2434e 651 hMCEtaPt[iCut] = new TH1F("MC_Eta_Pt","MC_Eta_Pt",250,0,25);
0a2b2b4b 652 hMCEtaPt[iCut]->Sumw2();
2bb2434e 653 fMCList[iCut]->Add(hMCEtaPt[iCut]);
654 hMCPi0InAccPt[iCut] = new TH1F("MC_Pi0InAcc_Pt","MC_Pi0InAcc_Pt",250,0,25);
0a2b2b4b 655 hMCPi0InAccPt[iCut]->Sumw2();
2bb2434e 656 fMCList[iCut]->Add(hMCPi0InAccPt[iCut]);
657 hMCEtaInAccPt[iCut] = new TH1F("MC_EtaInAcc_Pt","MC_EtaInAcc_Pt",250,0,25);
0a2b2b4b 658 hMCEtaInAccPt[iCut]->Sumw2();
2bb2434e 659 fMCList[iCut]->Add(hMCEtaInAccPt[iCut]);
0a2b2b4b 660 if (fDoMesonQA){
661 hMCPi0PtY[iCut] = new TH2F("MC_Pi0_Pt_Y","MC_Pi0_Pt_Y",250,0,25,20,-1,1);
662 hMCPi0PtY[iCut]->Sumw2();
663 fMCList[iCut]->Add(hMCPi0PtY[iCut]);
664 hMCEtaPtY[iCut] = new TH2F("MC_Eta_Pt_Y","MC_Eta_Pt_Y",250,0,25,20,-1,1);
665 hMCEtaPtY[iCut]->Sumw2();
666 fMCList[iCut]->Add(hMCEtaPtY[iCut]);
ae947965 667 hMCK0sPt[iCut] = new TH1F("MC_K0s_Pt","MC_K0s_Pt",250,0,25);
668 hMCK0sPt[iCut]->Sumw2();
669 fMCList[iCut]->Add(hMCK0sPt[iCut]);
670 hMCK0sWOWeightPt[iCut] = new TH1F("MC_K0s_WOWeights_Pt","MC_K0s_WOWeights_Pt",250,0,25);
671 hMCK0sWOWeightPt[iCut]->Sumw2();
672 fMCList[iCut]->Add(hMCK0sWOWeightPt[iCut]);
673 hMCK0sPtY[iCut] = new TH2F("MC_K0s_Pt_Y","MC_K0s_Pt_Y",250,0,25,20,-1,1);
674 hMCK0sPtY[iCut]->Sumw2();
675 fMCList[iCut]->Add(hMCK0sPtY[iCut]);
676
0a2b2b4b 677 }
678
2bb2434e 679 }
680 fTrueList[iCut] = new TList();
ca91a3e1 681 fTrueList[iCut]->SetName(Form("%s_%s True histograms",cutstring.Data(),cutstringMeson.Data()));
2bb2434e 682 fTrueList[iCut]->SetOwner(kTRUE);
683 fCutFolder[iCut]->Add(fTrueList[iCut]);
684
685 hESDTrueConvGammaPt[iCut] = new TH1F("ESD_TrueConvGamma_Pt","ESD_TrueConvGamma_Pt",250,0,25);
686 fTrueList[iCut]->Add(hESDTrueConvGammaPt[iCut]);
e5b6e8a6 687
688 hESDCombinatorialPt[iCut] = new TH2F("ESD_TrueCombinatorial_Pt","ESD_TrueCombinatorial_Pt",250,0,25,16,-0.5,15.5);
689 hESDCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 1,"Elec+Elec");
690 hESDCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 2,"Elec+Pion");
691 hESDCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 3,"Elec+Kaon");
692 hESDCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 4,"Elec+Proton");
693 hESDCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 5,"Elec+Muon");
694 hESDCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 6,"Pion+Pion");
695 hESDCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 7,"Pion+Kaon");
696 hESDCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 8,"Pion+Proton");
697 hESDCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 9,"Pion+Muon");
698 hESDCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(10,"Kaon+Kaon");
699 hESDCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(11,"Kaon+Proton");
700 hESDCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(12,"Kaon+Muon");
701 hESDCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(13,"Proton+Proton");
702 hESDCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(14,"Proton+Muon");
703 hESDCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(15,"Muon+Muon");
704 hESDCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(16,"Rest");
705 fTrueList[iCut]->Add(hESDCombinatorialPt[iCut]);
2bb2434e 706 hESDTruePrimaryConvGammaPt[iCut] = new TH1F("ESD_TruePrimaryConvGamma_Pt","ESD_TruePrimaryConvGamma_Pt",250,0,25);
707 fTrueList[iCut]->Add(hESDTruePrimaryConvGammaPt[iCut]);
2bb2434e 708 hESDTrueSecondaryConvGammaPt[iCut] = new TH1F("ESD_TrueSecondaryConvGamma_Pt","ESD_TrueSecondaryConvGamma_Pt",250,0,25);
709 fTrueList[iCut]->Add(hESDTrueSecondaryConvGammaPt[iCut]);
0a2b2b4b 710
e5b6e8a6 711 hESDTrueSecondaryConvGammaFromXFromK0sPt[iCut]
712 = new TH1F("ESD_TrueSecondaryConvGammaFromXFromK0s_Pt", "ESD_TrueSecondaryConvGammaFromXFromK0s_Pt",250,0,25);
2bb2434e 713 fTrueList[iCut]->Add(hESDTrueSecondaryConvGammaFromXFromK0sPt[iCut]);
4803eb1f 714 hESDTrueSecondaryConvGammaFromXFromLambdaPt[iCut]
715 = new TH1F("ESD_TrueSecondaryConvGammaFromXFromLambda_Pt", "ESD_TrueSecondaryConvGammaFromXFromLambda_Pt",250,0,25);
716 fTrueList[iCut]->Add(hESDTrueSecondaryConvGammaFromXFromLambdaPt[iCut]);
717
1390f698 718 hESDTrueDalitzPsiPairDeltaPhi[iCut]
719 = new TH2F("ESD_TrueDalitzPsiPairDeltaPhi_Pt", "ESD_TrueDalitzPsiPairDeltaPhi_Pt",400,-2,2,400,-2,2);
720 fTrueList[iCut]->Add(hESDTrueDalitzPsiPairDeltaPhi[iCut]);
721
722 hESDTrueGammaPsiPairDeltaPhi[iCut]
723 = new TH2F("ESD_TrueGammaPsiPairDeltaPhi_Pt", "ESD_TrueGammaPsiPairDeltaPhi_Pt",200,-2,2,400,-2,2);
724 fTrueList[iCut]->Add(hESDTrueGammaPsiPairDeltaPhi[iCut]);
725
726
2bb2434e 727 hESDTruePrimaryConvGammaESDPtMCPt[iCut] = new TH2F("ESD_TruePrimaryConvGammaESD_PtMCPt", "ESD_TruePrimaryConvGammaESD_PtMCPt",250,0,25,250,0,25);
728 fTrueList[iCut]->Add(hESDTruePrimaryConvGammaESDPtMCPt[iCut]);
e5b6e8a6 729 hESDTruePrimaryConvGammaRSESDPtMCPt[iCut]
730 = new TH2F("ESD_TruePrimaryConvGammaESD_RS_PtMCPt", "ESD_TruePrimaryConvGammaESD_RS_PtMCPt",250,0,25,250,0,25);
731 fTrueList[iCut]->Add(hESDTruePrimaryConvGammaRSESDPtMCPt[iCut]);
732
2bb2434e 733 if(fDoMesonAnalysis){
e5b6e8a6 734 hESDTrueMotherInvMassPt[iCut] = new TH2F("ESD_TrueMother_InvMass_Pt","ESD_TrueMother_InvMass_Pt",800,0,0.8,250,0,25);
2bb2434e 735 fTrueList[iCut]->Add(hESDTrueMotherInvMassPt[iCut]);
a280ac15 736 hESDTruePrimaryMotherInvMassPt[iCut]
737 = new TH2F("ESD_TruePrimaryMother_InvMass_Pt", "ESD_TruePrimaryMother_InvMass_Pt", 800,0,0.8,250,0,25);
0a2b2b4b 738 hESDTruePrimaryMotherInvMassPt[iCut]->Sumw2();
a280ac15 739 fTrueList[iCut]->Add(hESDTruePrimaryMotherInvMassPt[iCut]);
526074e4 740 hESDTruePrimaryMotherW0WeightingInvMassPt[iCut]
741 = new TH2F("ESD_TruePrimaryMotherW0Weights_InvMass_Pt", "ESD_TruePrimaryMotherW0Weights_InvMass_Pt", 800,0,0.8,250,0,25);
742 hESDTruePrimaryMotherW0WeightingInvMassPt[iCut]->Sumw2();
743 fTrueList[iCut]->Add(hESDTruePrimaryMotherW0WeightingInvMassPt[iCut]);
744 pESDTruePrimaryMotherWeightsInvMassPt[iCut]
745 = new TProfile2D("ESD_TruePrimaryMotherWeights_InvMass_Pt", "ESD_TruePrimaryMotherWeights_InvMass_Pt", 800,0,0.8,250,0,25);
746 pESDTruePrimaryMotherWeightsInvMassPt[iCut]->Sumw2();
747 fTrueList[iCut]->Add(pESDTruePrimaryMotherWeightsInvMassPt[iCut]);
e5b6e8a6 748 hESDTrueSecondaryMotherInvMassPt[iCut]
749 = new TH2F("ESD_TrueSecondaryMother_InvMass_Pt", "ESD_TrueSecondaryMother_InvMass_Pt", 800,0,0.8,250,0,25);
ae947965 750 hESDTrueSecondaryMotherInvMassPt[iCut]->Sumw2();
2bb2434e 751 fTrueList[iCut]->Add(hESDTrueSecondaryMotherInvMassPt[iCut]);
e5b6e8a6 752 hESDTrueSecondaryMotherFromK0sInvMassPt[iCut]
753 = new TH2F("ESD_TrueSecondaryMotherFromK0s_InvMass_Pt","ESD_TrueSecondaryMotherFromK0s_InvMass_Pt",800,0,0.8,250,0,25);
ae947965 754 hESDTrueSecondaryMotherFromK0sInvMassPt[iCut]->Sumw2();
2bb2434e 755 fTrueList[iCut]->Add(hESDTrueSecondaryMotherFromK0sInvMassPt[iCut]);
e5b6e8a6 756 hESDTrueSecondaryMotherFromEtaInvMassPt[iCut]
757 = new TH2F("ESD_TrueSecondaryMotherFromEta_InvMass_Pt","ESD_TrueSecondaryMotherFromEta_InvMass_Pt",800,0,0.8,250,0,25);
758 fTrueList[iCut]->Add(hESDTrueSecondaryMotherFromEtaInvMassPt[iCut]);
86eaf9ae 759 hESDTrueMotherDalitzInvMassPt[iCut] = new TH2F("ESD_TrueDalitz_InvMass_Pt","ESD_TrueDalitz_InvMass_Pt",800,0,0.8,250,0,25);
760 fTrueList[iCut]->Add(hESDTrueMotherDalitzInvMassPt[iCut]);
0a2b2b4b 761 if (fDoMesonQA){
762 hESDTruePrimaryPi0MCPtResolPt[iCut] = new TH2F("ESD_TruePrimaryPi0_MCPt_ResolPt","ESD_TruePrimaryPi0_ResolPt_MCPt",500,0,25,1000,-1.,1.);
763 hESDTruePrimaryPi0MCPtResolPt[iCut]->Sumw2();
764 fTrueList[iCut]->Add(hESDTruePrimaryPi0MCPtResolPt[iCut]);
765 hESDTruePrimaryEtaMCPtResolPt[iCut] = new TH2F("ESD_TruePrimaryEta_MCPt_ResolPt","ESD_TruePrimaryEta_ResolPt_MCPt",500,0,25,1000,-1.,1.);
766 hESDTruePrimaryEtaMCPtResolPt[iCut]->Sumw2();
767 fTrueList[iCut]->Add(hESDTruePrimaryEtaMCPtResolPt[iCut]);
768 hESDTrueBckGGInvMassPt[iCut] = new TH2F("ESD_TrueBckGG_InvMass_Pt","ESD_TrueBckGG_InvMass_Pt",800,0,0.8,250,0,25);
769 fTrueList[iCut]->Add(hESDTrueBckGGInvMassPt[iCut]);
770 hESDTrueBckContInvMassPt[iCut] = new TH2F("ESD_TrueBckCont_InvMass_Pt","ESD_TrueBckCont_InvMass_Pt",800,0,0.8,250,0,25);
771 fTrueList[iCut]->Add(hESDTrueBckContInvMassPt[iCut]);
0a2b2b4b 772 hESDTrueK0sWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueK0sWithPi0Daughter_MCPt","ESD_TrueK0sWithPi0Daughter_MCPt",250,0,25);
773 fTrueList[iCut]->Add(hESDTrueK0sWithPi0DaughterMCPt[iCut]);
774 hESDTrueEtaWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueEtaWithPi0Daughter_MCPt","ESD_TrueEtaWithPi0Daughter_MCPt",250,0,25);
775 fTrueList[iCut]->Add(hESDTrueEtaWithPi0DaughterMCPt[iCut]);
0a2b2b4b 776 }
ca91a3e1 777 }
a280ac15 778 }
779 }
780
a280ac15 781 fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask("V0ReaderV1");
782 if(!fV0Reader){printf("Error: No V0 Reader");return;} // GetV0Reader
e5b6e8a6 783
a280ac15 784 if(fV0Reader)
785 if((AliConversionCuts*)fV0Reader->GetConversionCuts())
786 if(((AliConversionCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms())
787 fOutputContainer->Add(((AliConversionCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms());
e5b6e8a6 788
a280ac15 789 for(Int_t iCut = 0; iCut<fnCuts;iCut++){
790 if(!((AliConversionCuts*)fCutArray->At(iCut))) continue;
791 if(((AliConversionCuts*)fCutArray->At(iCut))->GetCutHistograms()){
792 fCutFolder[iCut]->Add(((AliConversionCuts*)fCutArray->At(iCut))->GetCutHistograms());
793 }
4803eb1f 794 if(fDoMesonAnalysis){
795 if(!((AliConversionMesonCuts*)fMesonCutArray->At(iCut))) continue;
796 if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms()){
797 fCutFolder[iCut]->Add(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms());
798 }
2bb2434e 799 }
800 }
2bb2434e 801 PostData(1, fOutputContainer);
802}
11c1e680 803//_____________________________________________________________________________
804Bool_t AliAnalysisTaskGammaConvV1::Notify()
805{
ccfa8c0d 806 for(Int_t iCut = 0; iCut<fnCuts;iCut++){
4803eb1f 807 if(!((AliConversionCuts*)fCutArray->At(iCut))->GetDoEtaShift()){
1390f698 808 hEtaShift[iCut]->Fill(0.,(((AliConversionCuts*)fCutArray->At(iCut))->GetEtaShift()));
4803eb1f 809 continue; // No Eta Shift requested, continue
810 }
ccfa8c0d 811 if(((AliConversionCuts*)fCutArray->At(iCut))->GetEtaShift() == 0.0){ // Eta Shift requested but not set, get shift automatically
4803eb1f 812 ((AliConversionCuts*)fCutArray->At(iCut))->GetCorrectEtaShiftFromPeriod(fV0Reader->GetPeriodName());
813 hEtaShift[iCut]->Fill(0.,(((AliConversionCuts*)fCutArray->At(iCut))->GetEtaShift()));
ccfa8c0d 814 ((AliConversionCuts*)fCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
815 continue;
816 }
817 else{
818 printf(" Gamma Conversion Task %s :: Eta Shift Manually Set to %f \n\n",
819 (((AliConversionCuts*)fCutArray->At(iCut))->GetCutNumber()).Data(),((AliConversionCuts*)fCutArray->At(iCut))->GetEtaShift());
4803eb1f 820 hEtaShift[iCut]->Fill(0.,(((AliConversionCuts*)fCutArray->At(iCut))->GetEtaShift()));
ccfa8c0d 821 ((AliConversionCuts*)fCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
11c1e680 822 }
823 }
ccfa8c0d 824
11c1e680 825 return kTRUE;
826}
2bb2434e 827//_____________________________________________________________________________
828void AliAnalysisTaskGammaConvV1::UserExec(Option_t *)
829{
830 //
831 // Called for each event
832 //
2bb2434e 833 Int_t eventQuality = ((AliConversionCuts*)fV0Reader->GetConversionCuts())->GetEventQuality();
e5b6e8a6 834 if(eventQuality == 2 || eventQuality == 3){// Event Not Accepted due to MC event missing or wrong trigger for V0ReaderV1
2bb2434e 835 for(Int_t iCut = 0; iCut<fnCuts; iCut++){
836 hNEvents[iCut]->Fill(eventQuality);
837 }
838 return;
839 }
840
ae947965 841 if(fIsMC) fMCEvent = MCEvent();
4803eb1f 842 if(fMCEvent == NULL) fIsMC = kFALSE;
843
ae947965 844 fInputEvent = InputEvent();
845
4803eb1f 846 if(fIsMC && fInputEvent->IsA()==AliESDEvent::Class()){
e5b6e8a6 847 fMCStack = fMCEvent->Stack();
4803eb1f 848 if(fMCStack == NULL) fIsMC = kFALSE;
e5b6e8a6 849 }
e5b6e8a6 850
2bb2434e 851 fReaderGammas = fV0Reader->GetReconstructedGammas(); // Gammas from default Cut
4803eb1f 852
e5b6e8a6 853 // ------------------- BeginEvent ----------------------------
854
4803eb1f 855 if(fIsMC && fInputEvent->IsA()==AliAODEvent::Class() && !(fV0Reader->AreAODsRelabeled())){
ae947965 856 RelabelAODPhotonCandidates(kTRUE); // In case of AODMC relabeling MC
1186afd2 857 fV0Reader->RelabelAODs(kTRUE);
858 }
2bb2434e 859 for(Int_t iCut = 0; iCut<fnCuts; iCut++){
860 fiCut = iCut;
e5b6e8a6 861 Int_t eventNotAccepted =
862 ((AliConversionCuts*)fCutArray->At(iCut))
863 ->IsEventAcceptedByConversionCut(fV0Reader->GetConversionCuts(),fInputEvent,fMCEvent,fIsHeavyIon);
864 if(eventNotAccepted){
ccfa8c0d 865 // cout << "event rejected due to wrong trigger: " <<eventNotAccepted << endl;
e5b6e8a6 866 hNEvents[iCut]->Fill(eventNotAccepted); // Check Centrality, PileUp, SDD and V0AND --> Not Accepted => eventQuality = 1
2bb2434e 867 continue;
868 }
e5b6e8a6 869
870 if(eventQuality != 0){// Event Not Accepted
ccfa8c0d 871 // cout << "event rejected due to: " <<eventQuality << endl;
e5b6e8a6 872 hNEvents[iCut]->Fill(eventQuality);
873 continue;
874 }
2bb2434e 875
a280ac15 876 hNEvents[iCut]->Fill(eventQuality); // Should be 0 here
4803eb1f 877 hNGoodESDTracks[iCut]->Fill(fV0Reader->GetNumberOfPrimaryTracks());
ccfa8c0d 878 if(((AliConversionCuts*)fCutArray->At(iCut))->IsHeavyIon() == 2) hNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A());
879 else hNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A()+fInputEvent->GetVZEROData()->GetMTotV0C());
e5b6e8a6 880
4803eb1f 881 if(fIsMC){
ae947965 882 // Process MC Particle
ca91a3e1 883 if(((AliConversionCuts*)fCutArray->At(iCut))->GetSignalRejection() != 0){
ae947965 884 if(fInputEvent->IsA()==AliESDEvent::Class()){
885 ((AliConversionCuts*)fCutArray->At(iCut))->GetNotRejectedParticles(((AliConversionCuts*)fCutArray->At(iCut))->GetSignalRejection(),
886 ((AliConversionCuts*)fCutArray->At(iCut))->GetAcceptedHeader(),
887 fMCEvent);
888 }
889 else if(fInputEvent->IsA()==AliAODEvent::Class()){
890 ((AliConversionCuts*)fCutArray->At(iCut))->GetNotRejectedParticles(((AliConversionCuts*)fCutArray->At(iCut))->GetSignalRejection(),
891 ((AliConversionCuts*)fCutArray->At(iCut))->GetAcceptedHeader(),
892 fInputEvent);
893 }
1186afd2 894
4803eb1f 895 if(((AliConversionCuts*)fCutArray->At(iCut))->GetAcceptedHeader()){
896 for(Int_t i = 0;i<(((AliConversionCuts*)fCutArray->At(iCut))->GetAcceptedHeader())->GetEntries();i++){
897 TString nameBin= hMCHeaders[iCut]->GetXaxis()->GetBinLabel(i+1);
898 if (nameBin.CompareTo("")== 0){
899 TString nameHeader = ((TObjString*)((TList*)((AliConversionCuts*)fCutArray->At(iCut))
900 ->GetAcceptedHeader())->At(i))->GetString();
901 hMCHeaders[iCut]->GetXaxis()->SetBinLabel(i+1,nameHeader.Data());
902 }
1186afd2 903 }
904 }
ca91a3e1 905 }
ae947965 906 }
4803eb1f 907 if(fIsMC){
ae947965 908 if(fInputEvent->IsA()==AliESDEvent::Class())
909 ProcessMCParticles();
910 if(fInputEvent->IsA()==AliAODEvent::Class())
911 ProcessAODMCParticles();
2bb2434e 912 }
a280ac15 913
2bb2434e 914 ProcessPhotonCandidates(); // Process this cuts gammas
915
a280ac15 916 hNGammaCandidates[iCut]->Fill(fGammaCandidates->GetEntries());
2bb2434e 917 if(fDoMesonAnalysis){ // Meson Analysis
4803eb1f 918 if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseMCPSmearing() && fIsMC){
a280ac15 919 fUnsmearedPx = new Double_t[fGammaCandidates->GetEntries()]; // Store unsmeared Momenta
920 fUnsmearedPy = new Double_t[fGammaCandidates->GetEntries()];
921 fUnsmearedPz = new Double_t[fGammaCandidates->GetEntries()];
922 fUnsmearedE = new Double_t[fGammaCandidates->GetEntries()];
923
924 for(Int_t gamma=0;gamma<fGammaCandidates->GetEntries();gamma++){ // Smear the AODPhotons in MC
925 fUnsmearedPx[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->Px();
926 fUnsmearedPy[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->Py();
927 fUnsmearedPz[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->Pz();
928 fUnsmearedE[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->E();
929 ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->SmearParticle(dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(gamma)));
2bb2434e 930 }
931 }
ca91a3e1 932
2bb2434e 933 CalculatePi0Candidates(); // Combine Gammas
e5b6e8a6 934 if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->DoBGCalculation()){
935 if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->BackgroundHandlerType() == 0){
936 CalculateBackground(); // Combinatorial Background
937 UpdateEventByEventData(); // Store Event for mixed Events
938 }
939 else{
940 CalculateBackgroundRP(); // Combinatorial Background
a280ac15 941 fBGHandlerRP[iCut]->AddEvent(fGammaCandidates,fInputEvent); // Store Event for mixed Events
e5b6e8a6 942 }
943 }
4803eb1f 944 if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseMCPSmearing() && fIsMC){
a280ac15 945 for(Int_t gamma=0;gamma<fGammaCandidates->GetEntries();gamma++){ // Smear the AODPhotons in MC
946 ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetPx(fUnsmearedPx[gamma]); // Reset Unsmeared Momenta
947 ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetPy(fUnsmearedPy[gamma]);
948 ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetPz(fUnsmearedPz[gamma]);
949 ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetE(fUnsmearedE[gamma]);
2bb2434e 950 }
951 delete[] fUnsmearedPx; fUnsmearedPx = 0x0;
952 delete[] fUnsmearedPy; fUnsmearedPy = 0x0;
953 delete[] fUnsmearedPz; fUnsmearedPz = 0x0;
954 delete[] fUnsmearedE; fUnsmearedE = 0x0;
955 }
956 }
a280ac15 957 fGammaCandidates->Clear(); // delete this cuts good gammas
ca91a3e1 958 }
e5b6e8a6 959
4803eb1f 960 if(fIsMC && fInputEvent->IsA()==AliAODEvent::Class() && !(fV0Reader->AreAODsRelabeled())){
ae947965 961 RelabelAODPhotonCandidates(kFALSE); // Back to ESDMC Label
1186afd2 962 fV0Reader->RelabelAODs(kFALSE);
963 }
964
2bb2434e 965 PostData(1, fOutputContainer);
966}
967//________________________________________________________________________
968void AliAnalysisTaskGammaConvV1::ProcessPhotonCandidates()
969{
970 Int_t nV0 = 0;
a280ac15 971 TList *GammaCandidatesStepOne = new TList();
972 TList *GammaCandidatesStepTwo = new TList();
2bb2434e 973 // Loop over Photon Candidates allocated by ReaderV1
974 for(Int_t i = 0; i < fReaderGammas->GetEntriesFast(); i++){
975 AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) fReaderGammas->At(i);
976 if(!PhotonCandidate) continue;
a280ac15 977 fIsFromMBHeader = kTRUE;
4803eb1f 978 if(fIsMC && ((AliConversionCuts*)fCutArray->At(fiCut))->GetSignalRejection() != 0){
a280ac15 979 Int_t isPosFromMBHeader
ae947965 980 = ((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCStack, fInputEvent);
a280ac15 981 if(isPosFromMBHeader == 0 && ((AliConversionCuts*)fCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
982 Int_t isNegFromMBHeader
ae947965 983 = ((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCStack, fInputEvent);
a280ac15 984 if(isNegFromMBHeader == 0 && ((AliConversionCuts*)fCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
985
986 if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
ca91a3e1 987 }
988
e5b6e8a6 989 if(!((AliConversionCuts*)fCutArray->At(fiCut))->PhotonIsSelected(PhotonCandidate,fInputEvent)) continue;
ca91a3e1 990 if(!((AliConversionCuts*)fCutArray->At(fiCut))->UseElecSharingCut() &&
e5b6e8a6 991 !((AliConversionCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){
a280ac15 992 fGammaCandidates->Add(PhotonCandidate); // if no second loop is required add to events good gammas
e5b6e8a6 993
a280ac15 994 if(fIsFromMBHeader){
e5b6e8a6 995 hESDConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
e5b6e8a6 996 }
4803eb1f 997 if(fIsMC){
ae947965 998 if(fInputEvent->IsA()==AliESDEvent::Class())
999 ProcessTruePhotonCandidates(PhotonCandidate);
1000 if(fInputEvent->IsA()==AliAODEvent::Class())
1001 ProcessTruePhotonCandidatesAOD(PhotonCandidate);
2bb2434e 1002 }
4803eb1f 1003 if (fIsFromMBHeader && fDoPhotonQA){
1004 if (fIsHeavyIon && PhotonCandidate->Pt() > 0.399 && PhotonCandidate->Pt() < 12.){
1005 fPtGamma = PhotonCandidate->Pt();
1006 fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
1007 fRConvPhoton = PhotonCandidate->GetConversionRadius();
1008 fEtaPhoton = PhotonCandidate->GetPhotonEta();
1009 iCatPhoton = PhotonCandidate->GetPhotonQuality();
1010 tESDConvGammaPtDcazCat[fiCut]->Fill();
1011 } else if ( PhotonCandidate->Pt() > 0.299 && PhotonCandidate->Pt() < 16.){
1012 fPtGamma = PhotonCandidate->Pt();
1013 fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
1014 fRConvPhoton = PhotonCandidate->GetConversionRadius();
1015 fEtaPhoton = PhotonCandidate->GetPhotonEta();
1016 iCatPhoton = PhotonCandidate->GetPhotonQuality();
1017 tESDConvGammaPtDcazCat[fiCut]->Fill();
1018 }
1019 }
1020 } else if(((AliConversionCuts*)fCutArray->At(fiCut))->UseElecSharingCut()){ // if Shared Electron cut is enabled, Fill array, add to step one
2bb2434e 1021 ((AliConversionCuts*)fCutArray->At(fiCut))->FillElectonLabelArray(PhotonCandidate,nV0);
1022 nV0++;
a280ac15 1023 GammaCandidatesStepOne->Add(PhotonCandidate);
4803eb1f 1024 } else if(!((AliConversionCuts*)fCutArray->At(fiCut))->UseElecSharingCut() &&
2bb2434e 1025 ((AliConversionCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){ // shared electron is disabled, step one not needed -> step two
a280ac15 1026 GammaCandidatesStepTwo->Add(PhotonCandidate);
2bb2434e 1027 }
1028 }
1029 if(((AliConversionCuts*)fCutArray->At(fiCut))->UseElecSharingCut()){
a280ac15 1030 for(Int_t i = 0;i<GammaCandidatesStepOne->GetEntries();i++){
1031 AliAODConversionPhoton *PhotonCandidate= (AliAODConversionPhoton*) GammaCandidatesStepOne->At(i);
2bb2434e 1032 if(!PhotonCandidate) continue;
a280ac15 1033 fIsFromMBHeader = kTRUE;
ae947965 1034 if(fMCStack && ((AliConversionCuts*)fCutArray->At(fiCut))->GetSignalRejection() != 0){
a280ac15 1035 Int_t isPosFromMBHeader
ae947965 1036 = ((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCStack, fInputEvent);
a280ac15 1037 Int_t isNegFromMBHeader
ae947965 1038 = ((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCStack, fInputEvent);
a280ac15 1039 if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
e5b6e8a6 1040 }
a280ac15 1041 if(!((AliConversionCuts*)fCutArray->At(fiCut))->RejectSharedElectronV0s(PhotonCandidate,i,GammaCandidatesStepOne->GetEntries())) continue;
ca91a3e1 1042 if(!((AliConversionCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){ // To Colse v0s cut diabled, step two not needed
a280ac15 1043 fGammaCandidates->Add(PhotonCandidate);
1044 if(fIsFromMBHeader){
e5b6e8a6 1045 hESDConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
e5b6e8a6 1046 }
ae947965 1047 }
4803eb1f 1048 if(fIsMC){
ae947965 1049 if(fInputEvent->IsA()==AliESDEvent::Class())
2bb2434e 1050 ProcessTruePhotonCandidates(PhotonCandidate);
ae947965 1051 if(fInputEvent->IsA()==AliAODEvent::Class())
1052 ProcessTruePhotonCandidatesAOD(PhotonCandidate);
4803eb1f 1053 } else GammaCandidatesStepTwo->Add(PhotonCandidate); // Close v0s cut enabled -> add to list two
1054
1055 if (fIsFromMBHeader && fDoPhotonQA){
1056 if (fIsHeavyIon && PhotonCandidate->Pt() > 0.399 && PhotonCandidate->Pt() < 12.){
1057 fPtGamma = PhotonCandidate->Pt();
1058 fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
1059 fRConvPhoton = PhotonCandidate->GetConversionRadius();
1060 fEtaPhoton = PhotonCandidate->GetPhotonEta();
1061 iCatPhoton = PhotonCandidate->GetPhotonQuality();
1062 tESDConvGammaPtDcazCat[fiCut]->Fill();
1063 } else if ( PhotonCandidate->Pt() > 0.299 && PhotonCandidate->Pt() < 16.){
1064 fPtGamma = PhotonCandidate->Pt();
1065 fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
1066 fRConvPhoton = PhotonCandidate->GetConversionRadius();
1067 fEtaPhoton = PhotonCandidate->GetPhotonEta();
1068 iCatPhoton = PhotonCandidate->GetPhotonQuality();
1069 tESDConvGammaPtDcazCat[fiCut]->Fill();
1070 }
2bb2434e 1071 }
2bb2434e 1072 }
1073 }
1074 if(((AliConversionCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){
a280ac15 1075 for(Int_t i = 0;i<GammaCandidatesStepTwo->GetEntries();i++){
1076 AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) GammaCandidatesStepTwo->At(i);
2bb2434e 1077 if(!PhotonCandidate) continue;
a280ac15 1078 fIsFromMBHeader = kTRUE;
ae947965 1079 if(fMCStack && ((AliConversionCuts*)fCutArray->At(fiCut))->GetSignalRejection() != 0){
a280ac15 1080 Int_t isPosFromMBHeader
ae947965 1081 = ((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCStack, fInputEvent);
a280ac15 1082 Int_t isNegFromMBHeader
ae947965 1083 = ((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCStack, fInputEvent);
a280ac15 1084 if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
e5b6e8a6 1085 }
a280ac15 1086 if(!((AliConversionCuts*)fCutArray->At(fiCut))->RejectToCloseV0s(PhotonCandidate,GammaCandidatesStepTwo,i)) continue;
1087 fGammaCandidates->Add(PhotonCandidate); // Add gamma to current cut TList
1088 if(fIsFromMBHeader){
e5b6e8a6 1089 hESDConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
e5b6e8a6 1090 }
4803eb1f 1091 if(fIsMC){
ae947965 1092 if(fInputEvent->IsA()==AliESDEvent::Class())
1093 ProcessTruePhotonCandidates(PhotonCandidate);
1094 if(fInputEvent->IsA()==AliAODEvent::Class())
1095 ProcessTruePhotonCandidatesAOD(PhotonCandidate);
2bb2434e 1096 }
4803eb1f 1097 if (fIsFromMBHeader){
1098 if (fIsHeavyIon == 1 && PhotonCandidate->Pt() > 0.399 && PhotonCandidate->Pt() < 12.){
1099 fPtGamma = PhotonCandidate->Pt();
1100 fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
1101 fRConvPhoton = PhotonCandidate->GetConversionRadius();
1102 fEtaPhoton = PhotonCandidate->GetPhotonEta();
1103 iCatPhoton = PhotonCandidate->GetPhotonQuality();
1104 tESDConvGammaPtDcazCat[fiCut]->Fill();
1105 } else if ( PhotonCandidate->Pt() > 0.299 && PhotonCandidate->Pt() < 16.){
1106 fPtGamma = PhotonCandidate->Pt();
1107 fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
1108 fRConvPhoton = PhotonCandidate->GetConversionRadius();
1109 fEtaPhoton = PhotonCandidate->GetPhotonEta();
1110 iCatPhoton = PhotonCandidate->GetPhotonQuality();
1111 tESDConvGammaPtDcazCat[fiCut]->Fill();
1112 }
1113 }
2bb2434e 1114 }
1115 }
1116
a280ac15 1117 delete GammaCandidatesStepOne;
1118 GammaCandidatesStepOne = 0x0;
1119 delete GammaCandidatesStepTwo;
1120 GammaCandidatesStepTwo = 0x0;
2bb2434e 1121
1122}
1123//________________________________________________________________________
ae947965 1124void AliAnalysisTaskGammaConvV1::ProcessTruePhotonCandidatesAOD(AliAODConversionPhoton *TruePhotonCandidate)
1125{
1126
1390f698 1127 Double_t magField = fInputEvent->GetMagneticField();
1128 if( magField < 0.0 ){
1129 magField = 1.0;
1130 }
1131 else {
1132 magField = -1.0;
1133 }
1134
ae947965 1135 TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
1136 AliAODMCParticle *posDaughter = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetMCLabelPositive());
1137 AliAODMCParticle *negDaughter = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetMCLabelNegative());
4803eb1f 1138 iPhotonMCInfo = 0;
ae947965 1139
1140 if(posDaughter == NULL || negDaughter == NULL) return; // One particle does not exist
1141 Int_t pdgCode[2] = {abs(posDaughter->GetPdgCode()),abs(negDaughter->GetPdgCode())};
1142
1143 if(posDaughter->GetMother() != negDaughter->GetMother()){
1144 FillPhotonCombinatorialBackgroundHist(TruePhotonCandidate, pdgCode);
4803eb1f 1145 iPhotonMCInfo = 1;
ae947965 1146 return;
1147 }
1148 else if(posDaughter->GetMother() == -1){
1149 FillPhotonCombinatorialBackgroundHist(TruePhotonCandidate, pdgCode);
4803eb1f 1150 iPhotonMCInfo = 1;
ae947965 1151 return;
1152 }
1153
4803eb1f 1154 if(pdgCode[0]!=11 || pdgCode[1]!=11){
1155 iPhotonMCInfo = 1;
1156 return; //One Particle is not a electron
1157 }
1158 if(posDaughter->GetPdgCode()==negDaughter->GetPdgCode()){
1159 iPhotonMCInfo = 1;
1160 return; // Same Charge
1161 }
1162
1390f698 1163 AliAODMCParticle *Photon = (AliAODMCParticle*) AODMCTrackArray->At(posDaughter->GetMother());
1164 AliVTrack * electronCandidate = ((AliConversionCuts*)fCutArray->At(fiCut))->GetTrack(fInputEvent,TruePhotonCandidate->GetTrackLabelNegative() );
1165 AliVTrack * positronCandidate = ((AliConversionCuts*)fCutArray->At(fiCut))->GetTrack(fInputEvent,TruePhotonCandidate->GetTrackLabelPositive() );
1166 Double_t deltaPhi = magField * TVector2::Phi_mpi_pi( electronCandidate->Phi()-positronCandidate->Phi());
1167
1168 if(Photon->GetPdgCode() != 22){
1169 hESDTrueDalitzPsiPairDeltaPhi[fiCut]->Fill(deltaPhi,TruePhotonCandidate->GetPsiPair());
1170 iPhotonMCInfo = 1;
1171 return; // Mother is no Photon
1172 }
1173
4803eb1f 1174 if(((posDaughter->GetMCProcessCode())) != 5 || ((negDaughter->GetMCProcessCode())) != 5){
1175 iPhotonMCInfo = 1;
1176 return;// check if the daughters come from a conversion
1177 }
ae947965 1178 // STILL A BUG IN ALIROOT >>8 HAS TPO BE REMOVED AFTER FIX
1179
1390f698 1180
1181
ae947965 1182 // True Photon
1183 if(fIsFromMBHeader)hESDTrueConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
1390f698 1184 hESDTrueGammaPsiPairDeltaPhi[fiCut]->Fill(deltaPhi,TruePhotonCandidate->GetPsiPair());
4803eb1f 1185 if(Photon->IsPrimary()){
ae947965 1186 // Count just primary MC Gammas as true --> For Ratio esdtruegamma / mcconvgamma
1187 if(fIsFromMBHeader){
4803eb1f 1188 iPhotonMCInfo = 6;
ae947965 1189 hESDTruePrimaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
ae947965 1190 hESDTruePrimaryConvGammaRSESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt()); // Allways Filled
1191 }
1192 hESDTruePrimaryConvGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt()); // Allways Filled
1193 // (Not Filled for i6, Extra Signal Gamma (parambox) are secondary)
1194 }
1195 else{
1196 if(fIsFromMBHeader){
1197 hESDTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
4803eb1f 1198 iPhotonMCInfo = 2;
1199 if(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother() > -1 &&
1200 ((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 3122){
1201 iPhotonMCInfo = 5;
1202 hESDTrueSecondaryConvGammaFromXFromLambdaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
1203 }
ae947965 1204 if(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother() > -1 &&
1205 ((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 310){
4803eb1f 1206 iPhotonMCInfo = 4;
ae947965 1207 hESDTrueSecondaryConvGammaFromXFromK0sPt[fiCut]->Fill(TruePhotonCandidate->Pt());
1208 }
4803eb1f 1209 if(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother() > -1 &&
1210 ((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 221){
1211 iPhotonMCInfo = 3;
1212 }
ae947965 1213 }
1214 }
4803eb1f 1215
ae947965 1216}
1217//________________________________________________________________________
2bb2434e 1218void AliAnalysisTaskGammaConvV1::ProcessTruePhotonCandidates(AliAODConversionPhoton *TruePhotonCandidate)
1219{
1390f698 1220
1221 Double_t magField = fInputEvent->GetMagneticField();
1222 if( magField < 0.0 ){
1223 magField = 1.0;
1224 }
1225 else {
1226 magField = -1.0;
1227 }
1228
2bb2434e 1229 // Process True Photons
ae947965 1230 TParticle *posDaughter = TruePhotonCandidate->GetPositiveMCDaughter(fMCStack);
1231 TParticle *negDaughter = TruePhotonCandidate->GetNegativeMCDaughter(fMCStack);
2bb2434e 1232
4803eb1f 1233 iPhotonMCInfo = 0;
1234
2bb2434e 1235 if(posDaughter == NULL || negDaughter == NULL) return; // One particle does not exist
e5b6e8a6 1236 Int_t pdgCode[2] = {abs(posDaughter->GetPdgCode()),abs(negDaughter->GetPdgCode())};
4803eb1f 1237 iPhotonMCInfo = 1;
e5b6e8a6 1238 if(posDaughter->GetMother(0) != negDaughter->GetMother(0)){
ae947965 1239 FillPhotonCombinatorialBackgroundHist(TruePhotonCandidate, pdgCode);
ca91a3e1 1240 return;
1241 }
1242 else if(posDaughter->GetMother(0) == -1){
ae947965 1243 FillPhotonCombinatorialBackgroundHist(TruePhotonCandidate, pdgCode);
2bb2434e 1244 return;
1245 }
e5b6e8a6 1246
1247 if(pdgCode[0]!=11 || pdgCode[1]!=11) return; //One Particle is not a electron
1390f698 1248
2bb2434e 1249 if(posDaughter->GetPdgCode()==negDaughter->GetPdgCode()) return; // Same Charge
e5b6e8a6 1250
ae947965 1251 TParticle *Photon = TruePhotonCandidate->GetMCParticle(fMCStack);
1390f698 1252 AliVTrack * electronCandidate = ((AliConversionCuts*)fCutArray->At(fiCut))->GetTrack(fInputEvent,TruePhotonCandidate->GetTrackLabelNegative() );
1253 AliVTrack * positronCandidate = ((AliConversionCuts*)fCutArray->At(fiCut))->GetTrack(fInputEvent,TruePhotonCandidate->GetTrackLabelPositive() );
1254 Double_t deltaPhi = magField * TVector2::Phi_mpi_pi( electronCandidate->Phi()-positronCandidate->Phi());
1255
1256 if(Photon->GetPdgCode() != 22){
1257 hESDTrueDalitzPsiPairDeltaPhi[fiCut]->Fill(deltaPhi,TruePhotonCandidate->GetPsiPair());
1258 return; // Mother is no Photon
1259 }
1260
1261 if(posDaughter->GetUniqueID() != 5 || negDaughter->GetUniqueID() !=5) return;// check if the daughters come from a conversion
2bb2434e 1262
1390f698 1263
1264
ca91a3e1 1265 // True Photon
1390f698 1266 if(fIsFromMBHeader){
1267 hESDTrueConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
1268 }
1269 hESDTrueGammaPsiPairDeltaPhi[fiCut]->Fill(deltaPhi,TruePhotonCandidate->GetPsiPair());
ae947965 1270 if(posDaughter->GetMother(0) <= fMCStack->GetNprimary()){
ca91a3e1 1271 // Count just primary MC Gammas as true --> For Ratio esdtruegamma / mcconvgamma
a280ac15 1272 if(fIsFromMBHeader){
4803eb1f 1273 iPhotonMCInfo = 6;
e5b6e8a6 1274 hESDTruePrimaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
e5b6e8a6 1275 hESDTruePrimaryConvGammaRSESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt()); // Allways Filled
1276 }
1277 hESDTruePrimaryConvGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt()); // Allways Filled
1278 // (Not Filled for i6, Extra Signal Gamma (parambox) are secondary)
ca91a3e1 1279 }
1280 else{
a280ac15 1281 if(fIsFromMBHeader){
4803eb1f 1282 iPhotonMCInfo = 2;
e5b6e8a6 1283 hESDTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
4803eb1f 1284 if(fMCStack->Particle(Photon->GetMother(0))->GetMother(0) > -1 &&
1285 fMCStack->Particle(fMCStack->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 3122){
1286 hESDTrueSecondaryConvGammaFromXFromLambdaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
1287 iPhotonMCInfo = 5;
1288 }
ae947965 1289 if(fMCStack->Particle(Photon->GetMother(0))->GetMother(0) > -1 &&
1290 fMCStack->Particle(fMCStack->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 310){
e5b6e8a6 1291 hESDTrueSecondaryConvGammaFromXFromK0sPt[fiCut]->Fill(TruePhotonCandidate->Pt());
4803eb1f 1292 iPhotonMCInfo = 4;
1293 }
1294 if(fMCStack->Particle(Photon->GetMother(0))->GetMother(0) > -1 &&
1295 fMCStack->Particle(fMCStack->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 221){
1296 iPhotonMCInfo = 3;
e5b6e8a6 1297 }
ca91a3e1 1298 }
1299 }
2bb2434e 1300}
1301//________________________________________________________________________
ae947965 1302void AliAnalysisTaskGammaConvV1::ProcessAODMCParticles()
1303{
1304
1305 TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
1306
1307 // Loop over all primary MC particle
1308 for(Int_t i = 0; i < AODMCTrackArray->GetEntriesFast(); i++) {
1309
1310 AliAODMCParticle* particle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(i));
1311 if (!particle) continue;
1312 if (!particle->IsPrimary()) continue;
1313
1314 Bool_t mcIsFromMB = kTRUE;
1315 Int_t isMCFromMBHeader = -1;
1316 if(((AliConversionCuts*)fCutArray->At(fiCut))->GetSignalRejection() != 0){
1317 isMCFromMBHeader
1318 = ((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack, fInputEvent);
1319 if(isMCFromMBHeader == 0 && ((AliConversionCuts*)fCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
1320 if(isMCFromMBHeader != 2) mcIsFromMB = kFALSE;
1321 }
1322
1323 if(((AliConversionCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(particle,AODMCTrackArray,kFALSE)){
1324 hMCAllGammaPt[fiCut]->Fill(particle->Pt()); // All MC Gamma
1325 if(particle->GetMother() >-1){ // Meson Decay Gamma
1326 switch((static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother())))->GetPdgCode()){
1327 case 111: // Pi0
1328 hMCDecayGammaPi0Pt[fiCut]->Fill(particle->Pt());
1329 break;
1330 case 113: // Rho0
1331 hMCDecayGammaRhoPt[fiCut]->Fill(particle->Pt());
1332 break;
1333 case 221: // Eta
1334 hMCDecayGammaEtaPt[fiCut]->Fill(particle->Pt());
1335 break;
1336 case 223: // Omega
1337 hMCDecayGammaOmegaPt[fiCut]->Fill(particle->Pt());
1338 break;
1339 case 331: // Eta'
1340 hMCDecayGammaEtapPt[fiCut]->Fill(particle->Pt());
1341 break;
1342 case 333: // Phi
1343 hMCDecayGammaPhiPt[fiCut]->Fill(particle->Pt());
1344 break;
1345 case 3212: // Sigma
1346 hMCDecayGammaSigmaPt[fiCut]->Fill(particle->Pt());
1347 break;
1348 }
1349 }
1350 }
1351 if(((AliConversionCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(particle,AODMCTrackArray,kTRUE)){
1352 Double_t rConv = 0;
1353 for(Int_t daughterIndex=particle->GetDaughter(0);daughterIndex<=particle->GetDaughter(1);daughterIndex++){
1354 AliAODMCParticle *tmpDaughter = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(daughterIndex));
1355 if(!tmpDaughter) continue;
1356 if(abs(tmpDaughter->GetPdgCode()) == 11){
1357 rConv = sqrt( (tmpDaughter->Xv()*tmpDaughter->Xv()) + (tmpDaughter->Yv()*tmpDaughter->Yv()) );
1358 }
1359 }
1360 hMCConvGammaPt[fiCut]->Fill(particle->Pt());
1361 if (fDoPhotonQA){
1362 hMCConvGammaR[fiCut]->Fill(rConv);
1363 hMCConvGammaEta[fiCut]->Fill(particle->Eta());
1364 }
1365 if(mcIsFromMB){
1366 hMCConvGammaRSPt[fiCut]->Fill(particle->Pt());
1367 if (fDoPhotonQA){
1368 hMCConvGammaRSR[fiCut]->Fill(rConv);
1369 hMCConvGammaRSEta[fiCut]->Fill(particle->Eta());
1370 }
1371 }
1372 }
1373 // Converted MC Gamma
1374 if(fDoMesonAnalysis){
1375 if(particle->GetPdgCode() == 310 && fDoMesonQA){
1376 Double_t mesonY = 10.;
1377 if(particle->E() - particle->Pz() == 0 || particle->E() + particle->Pz() == 0){
1378 mesonY=10.-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift();
1379 } else{
4803eb1f 1380 mesonY = 0.5*(TMath::Log((particle->E()+particle->Pz()) / (particle->E()-particle->Pz())))
1381 -((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift();
ae947965 1382 }
1383 Float_t weightedK0s= 1;
1384 if(((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack, fInputEvent)){
1385 if (particle->Pt()>0.005){
1386 weightedK0s= ((AliConversionCuts*)fCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),i, 0x0, fInputEvent);
1387 //cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
1388 }
1389 }
1390 hMCK0sPt[fiCut]->Fill(particle->Pt(),weightedK0s);
1391 hMCK0sWOWeightPt[fiCut]->Fill(particle->Pt());
1392 hMCK0sPtY[fiCut]->Fill(particle->Pt(),mesonY,weightedK0s);
1393 }
4803eb1f 1394 if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))
1395 ->MesonIsSelectedAODMC(particle,AODMCTrackArray,((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift())){
ae947965 1396 AliAODMCParticle* daughter0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(0)));
1397 AliAODMCParticle* daughter1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(1)));
1398 Float_t weighted= 1;
1399 if(((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack, fInputEvent)){
1400 if (particle->Pt()>0.005){
1401 weighted= ((AliConversionCuts*)fCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),i, 0x0, fInputEvent);
1402 //cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
1403 }
1404 }
1405 Double_t mesonY = 10.;
1406 if(particle->E() - particle->Pz() == 0 || particle->E() + particle->Pz() == 0){
1407 mesonY=10.-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift();
1408 } else{
4803eb1f 1409 mesonY = 0.5*(TMath::Log((particle->E()+particle->Pz()) / (particle->E()-particle->Pz())))
1410 -((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift();
ae947965 1411 }
1412
1413 if(particle->GetPdgCode() == 111){
1414 hMCPi0Pt[fiCut]->Fill(particle->Pt(),weighted); // All MC Pi0
1415 hMCPi0WOWeightPt[fiCut]->Fill(particle->Pt());
1416 if (fDoMesonQA) hMCPi0PtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
1417 } else if(particle->GetPdgCode() == 221){
1418 hMCEtaPt[fiCut]->Fill(particle->Pt(),weighted); // All MC Eta
1419 if (fDoMesonQA) hMCEtaPtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
1420 }
1421
1422 // Check the acceptance for both gammas
1423 if(((AliConversionCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter0,AODMCTrackArray,kFALSE) &&
1424 ((AliConversionCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter1,AODMCTrackArray,kFALSE) ){
1425
1426 if(particle->GetPdgCode() == 111){
1427 hMCPi0InAccPt[fiCut]->Fill(particle->Pt(),weighted); // MC Pi0 with gamma in acc
1428 } else if(particle->GetPdgCode() == 221){
1429 hMCEtaInAccPt[fiCut]->Fill(particle->Pt(),weighted); // MC Eta with gamma in acc
1430 }
1431 }
1432 }
1433 }
1434 }
1435}
1436//________________________________________________________________________
2bb2434e 1437void AliAnalysisTaskGammaConvV1::ProcessMCParticles()
1438{
2bb2434e 1439 // Loop over all primary MC particle
1440 for(Int_t i = 0; i < fMCStack->GetNprimary(); i++) {
1441 TParticle* particle = (TParticle *)fMCStack->Particle(i);
1442 if (!particle) continue;
1443
a280ac15 1444 Bool_t mcIsFromMB = kTRUE;
1445 Int_t isMCFromMBHeader = -1;
ca91a3e1 1446 if(((AliConversionCuts*)fCutArray->At(fiCut))->GetSignalRejection() != 0){
a280ac15 1447 isMCFromMBHeader
ae947965 1448 = ((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack, fInputEvent);
a280ac15 1449 if(isMCFromMBHeader == 0 && ((AliConversionCuts*)fCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
1450 if(isMCFromMBHeader != 2) mcIsFromMB = kFALSE;
ca91a3e1 1451 }
1452
1453 if(((AliConversionCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCStack,kFALSE)){
1454 hMCAllGammaPt[fiCut]->Fill(particle->Pt()); // All MC Gamma
1455 if(particle->GetMother(0) >-1){ // Meson Decay Gamma
1456 switch(fMCStack->Particle(particle->GetMother(0))->GetPdgCode()){
1457 case 111: // Pi0
1458 hMCDecayGammaPi0Pt[fiCut]->Fill(particle->Pt());
1459 break;
1460 case 113: // Rho0
1461 hMCDecayGammaRhoPt[fiCut]->Fill(particle->Pt());
1462 break;
1463 case 221: // Eta
1464 hMCDecayGammaEtaPt[fiCut]->Fill(particle->Pt());
1465 break;
1466 case 223: // Omega
1467 hMCDecayGammaOmegaPt[fiCut]->Fill(particle->Pt());
1468 break;
1469 case 331: // Eta'
1470 hMCDecayGammaEtapPt[fiCut]->Fill(particle->Pt());
1471 break;
1472 case 333: // Phi
1473 hMCDecayGammaPhiPt[fiCut]->Fill(particle->Pt());
1474 break;
e5b6e8a6 1475 case 3212: // Sigma
a280ac15 1476 hMCDecayGammaSigmaPt[fiCut]->Fill(particle->Pt());
e5b6e8a6 1477 break;
ca91a3e1 1478 }
1479 }
1480 }
1481 if(((AliConversionCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCStack,kTRUE)){
1482 hMCConvGammaPt[fiCut]->Fill(particle->Pt());
0a2b2b4b 1483 if (fDoPhotonQA){
1484 hMCConvGammaR[fiCut]->Fill(((TParticle*)fMCStack->Particle(particle->GetFirstDaughter()))->R());
1485 hMCConvGammaEta[fiCut]->Fill(particle->Eta());
1486 }
a280ac15 1487 if(mcIsFromMB){
e5b6e8a6 1488 hMCConvGammaRSPt[fiCut]->Fill(particle->Pt());
0a2b2b4b 1489 if (fDoPhotonQA){
1490 hMCConvGammaRSR[fiCut]->Fill(((TParticle*)fMCStack->Particle(particle->GetFirstDaughter()))->R());
1491 hMCConvGammaRSEta[fiCut]->Fill(particle->Eta());
1492 }
e5b6e8a6 1493 }
ca91a3e1 1494 } // Converted MC Gamma
1495 if(fDoMesonAnalysis){
ae947965 1496 if(particle->GetPdgCode() == 310 && fDoMesonQA){
1497 Double_t mesonY = 10.;
1498 if(particle->Energy() - particle->Pz() == 0 || particle->Energy() + particle->Pz() == 0){
1499 mesonY=10.-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift();
1500 } else{
4803eb1f 1501 mesonY = 0.5*(TMath::Log((particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz())))
1502 -((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift();
ae947965 1503 }
1504 Float_t weightedK0s= 1;
1505 if(((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack, fInputEvent)){
1506 if (particle->Pt()>0.005){
1507 weightedK0s= ((AliConversionCuts*)fCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),i, fMCStack, fInputEvent);
1508 //cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
1509 }
1510 }
1511 hMCK0sPt[fiCut]->Fill(particle->Pt(),weightedK0s);
1512 hMCK0sWOWeightPt[fiCut]->Fill(particle->Pt());
1513 hMCK0sPtY[fiCut]->Fill(particle->Pt(),mesonY,weightedK0s);
1514 }
4803eb1f 1515 if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))
1516 ->MesonIsSelectedMC(particle,fMCStack,((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift())){
e5b6e8a6 1517 TParticle* daughter0 = (TParticle*)fMCStack->Particle(particle->GetFirstDaughter());
1518 TParticle* daughter1 = (TParticle*)fMCStack->Particle(particle->GetLastDaughter());
1519
a280ac15 1520 Float_t weighted= 1;
ae947965 1521 if(((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack, fInputEvent)){
a280ac15 1522 if (particle->Pt()>0.005){
ae947965 1523 weighted= ((AliConversionCuts*)fCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),i, fMCStack, fInputEvent);
1524 //cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
a280ac15 1525 }
1526 }
0a2b2b4b 1527 Double_t mesonY = 10.;
1528 if(particle->Energy() - particle->Pz() == 0 || particle->Energy() + particle->Pz() == 0){
11c1e680 1529 mesonY=10.-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift();
0a2b2b4b 1530 } else{
4803eb1f 1531 mesonY = 0.5*(TMath::Log((particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz())))
1532 -((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift();
0a2b2b4b 1533 }
1534
a280ac15 1535 if(particle->GetPdgCode() == 111){
1536 hMCPi0Pt[fiCut]->Fill(particle->Pt(),weighted); // All MC Pi0
ae947965 1537 hMCPi0WOWeightPt[fiCut]->Fill(particle->Pt());
0a2b2b4b 1538 if (fDoMesonQA) hMCPi0PtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
a280ac15 1539 } else if(particle->GetPdgCode() == 221){
1540 hMCEtaPt[fiCut]->Fill(particle->Pt(),weighted); // All MC Eta
0a2b2b4b 1541 if (fDoMesonQA) hMCEtaPtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
ae947965 1542 }
e5b6e8a6 1543
ca91a3e1 1544 // Check the acceptance for both gammas
e5b6e8a6 1545 if(((AliConversionCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(daughter0,fMCStack,kFALSE) &&
1546 ((AliConversionCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(daughter1,fMCStack,kFALSE) ){
0a2b2b4b 1547
a280ac15 1548 if(particle->GetPdgCode() == 111){
1549 hMCPi0InAccPt[fiCut]->Fill(particle->Pt(),weighted); // MC Pi0 with gamma in acc
1550 } else if(particle->GetPdgCode() == 221){
1551 hMCEtaInAccPt[fiCut]->Fill(particle->Pt(),weighted); // MC Eta with gamma in acc
1552 }
ca91a3e1 1553 }
1554 }
1555 }
2bb2434e 1556 }
1557}
1558//________________________________________________________________________
1559void AliAnalysisTaskGammaConvV1::CalculatePi0Candidates(){
1560
1561 // Conversion Gammas
a280ac15 1562 if(fGammaCandidates->GetEntries()>1){
1563 for(Int_t firstGammaIndex=0;firstGammaIndex<fGammaCandidates->GetEntries()-1;firstGammaIndex++){
1564 AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(firstGammaIndex));
0a2b2b4b 1565 if (gamma0==NULL) continue;
a280ac15 1566 for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fGammaCandidates->GetEntries();secondGammaIndex++){
1567 AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(secondGammaIndex));
2bb2434e 1568 //Check for same Electron ID
0a2b2b4b 1569 if (gamma1==NULL) continue;
2bb2434e 1570 if(gamma0->GetTrackLabelPositive() == gamma1->GetTrackLabelPositive() ||
1571 gamma0->GetTrackLabelNegative() == gamma1->GetTrackLabelNegative() ||
1572 gamma0->GetTrackLabelNegative() == gamma1->GetTrackLabelPositive() ||
1573 gamma0->GetTrackLabelPositive() == gamma1->GetTrackLabelNegative() ) continue;
1574
1575 AliAODConversionMother *pi0cand = new AliAODConversionMother(gamma0,gamma1);
1576 pi0cand->SetLabels(firstGammaIndex,secondGammaIndex);
1577
4803eb1f 1578 pi0cand->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
1579 if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))
1580 ->MesonIsSelected(pi0cand,kTRUE,((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift()))){
2bb2434e 1581 hESDMotherInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt());
e5b6e8a6 1582 if(pi0cand->GetAlpha()<0.1)
2bb2434e 1583 hESDMotherInvMassEalpha[fiCut]->Fill(pi0cand->M(),pi0cand->E());
e5b6e8a6 1584 if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->DoBGCalculation()){
1585 Int_t zbin = 0;
1586 Int_t mbin = 0;
a280ac15 1587
e5b6e8a6 1588 if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->BackgroundHandlerType() == 0){
1589 zbin = fBGHandler[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
1590 if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
4803eb1f 1591 mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fV0Reader->GetNumberOfPrimaryTracks());
e5b6e8a6 1592 } else {
a280ac15 1593 mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fGammaCandidates->GetEntries());
e5b6e8a6 1594 }
1595 }
1596 else{
1597 zbin = fBGHandlerRP[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
1598 if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
4803eb1f 1599 mbin = fBGHandlerRP[fiCut]->GetMultiplicityBinIndex(fV0Reader->GetNumberOfPrimaryTracks());
e5b6e8a6 1600 } else {
a280ac15 1601 mbin = fBGHandlerRP[fiCut]->GetMultiplicityBinIndex(fGammaCandidates->GetEntries());
e5b6e8a6 1602 }
1603 }
1604 Double_t sparesFill[4] = {pi0cand->M(),pi0cand->Pt(),(Double_t)zbin,(Double_t)mbin};
1605 sESDMotherInvMassPtZM[fiCut]->Fill(sparesFill,1);
2bb2434e 1606 }
ae947965 1607
1608
4803eb1f 1609 if(fIsMC){
ae947965 1610 if(fInputEvent->IsA()==AliESDEvent::Class())
1611 ProcessTrueMesonCandidates(pi0cand,gamma0,gamma1);
1612 if(fInputEvent->IsA()==AliAODEvent::Class())
1613 ProcessTrueMesonCandidatesAOD(pi0cand,gamma0,gamma1);
2bb2434e 1614 }
4803eb1f 1615 if (fDoMesonQA){
1616 fInvMass = pi0cand->M();
1617 fPt = pi0cand->Pt();
1618 if (abs(gamma0->GetDCAzToPrimVtx()) < abs(gamma1->GetDCAzToPrimVtx())){
1619 fDCAzGammaMin = gamma0->GetDCAzToPrimVtx();
1620 fDCAzGammaMax = gamma1->GetDCAzToPrimVtx();
1621 } else {
1622 fDCAzGammaMin = gamma1->GetDCAzToPrimVtx();
1623 fDCAzGammaMax = gamma0->GetDCAzToPrimVtx();
1624 }
1625 iFlag = pi0cand->GetMesonQuality();
1626// cout << "gamma 0: " << gamma0->GetV0Index()<< "\t" << gamma0->GetPx() << "\t" << gamma0->GetPy() << "\t" << gamma0->GetPz() << "\t" << endl;
1627// cout << "gamma 1: " << gamma1->GetV0Index()<< "\t"<< gamma1->GetPx() << "\t" << gamma1->GetPy() << "\t" << gamma1->GetPz() << "\t" << endl;
1628// cout << "pi0: "<<fInvMass << "\t" << fPt <<"\t" << fDCAzGammaMin << "\t" << fDCAzGammaMax << "\t" << (Int_t)iFlag << "\t" << (Int_t)iMesonMCInfo <<endl;
39e8c2ce 1629 if (fIsHeavyIon == 1 && fPt > 0.399 && fPt < 20. ) {
1630 if (fInvMass > 0.08 && fInvMass < 0.2) tESDMesonsInvMassPtDcazMinDcazMaxFlag[fiCut]->Fill();
1631 if ((fInvMass > 0.45 && fInvMass < 0.6) && (fPt > 0.999 && fPt < 20.) )tESDMesonsInvMassPtDcazMinDcazMaxFlag[fiCut]->Fill();
1632 } else if (fPt > 0.299 && fPt < 20. ) {
4803eb1f 1633 if ( (fInvMass > 0.08 && fInvMass < 0.2) || (fInvMass > 0.45 && fInvMass < 0.6)) tESDMesonsInvMassPtDcazMinDcazMaxFlag[fiCut]->Fill();
1634 }
1635 }
2bb2434e 1636 }
1637 delete pi0cand;
1638 pi0cand=0x0;
1639 }
1640 }
1641 }
1642}
1643//______________________________________________________________________
1644void AliAnalysisTaskGammaConvV1::ProcessTrueMesonCandidates(AliAODConversionMother *Pi0Candidate, AliAODConversionPhoton *TrueGammaCandidate0, AliAODConversionPhoton *TrueGammaCandidate1)
1645{
1646 // Process True Mesons
1647 AliStack *MCStack = fMCEvent->Stack();
4803eb1f 1648 iMesonMCInfo = 0;
e5b6e8a6 1649 if(TrueGammaCandidate0->GetV0Index()<fInputEvent->GetNumberOfV0s()){
2bb2434e 1650 Bool_t isTruePi0 = kFALSE;
1651 Bool_t isTrueEta = kFALSE;
86eaf9ae 1652 Bool_t isTruePi0Dalitz = kFALSE;
1653 Bool_t isTrueEtaDalitz = kFALSE;
1654 Bool_t gamma0DalitzCand = kFALSE;
1655 Bool_t gamma1DalitzCand = kFALSE;
2bb2434e 1656 Int_t gamma0MCLabel = TrueGammaCandidate0->GetMCParticleLabel(MCStack);
1657 Int_t gamma0MotherLabel = -1;
1658 if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
1659 // Daughters Gamma 0
1660 TParticle * negativeMC = (TParticle*)TrueGammaCandidate0->GetNegativeMCDaughter(MCStack);
1661 TParticle * positiveMC = (TParticle*)TrueGammaCandidate0->GetPositiveMCDaughter(MCStack);
1662 TParticle * gammaMC0 = (TParticle*)MCStack->Particle(gamma0MCLabel);
e5b6e8a6 1663 if(abs(negativeMC->GetPdgCode())==11 && abs(positiveMC->GetPdgCode())==11){ // Electrons ...
2bb2434e 1664 if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
1665 if(gammaMC0->GetPdgCode() == 22){ // ... with Gamma Mother
1666 gamma0MotherLabel=gammaMC0->GetFirstMother();
1667 }
1668 }
86eaf9ae 1669 if(gammaMC0->GetPdgCode() ==111){ // Dalitz candidate
1670 gamma0DalitzCand = kTRUE;
2bb2434e 1671 gamma0MotherLabel=-111;
1672 }
86eaf9ae 1673 if(gammaMC0->GetPdgCode() ==221){ // Dalitz candidate
1674 gamma0DalitzCand = kTRUE;
2bb2434e 1675 gamma0MotherLabel=-221;
1676 }
1677 }
1678 }
e5b6e8a6 1679 if(TrueGammaCandidate1->GetV0Index()<fInputEvent->GetNumberOfV0s()){
2bb2434e 1680 Int_t gamma1MCLabel = TrueGammaCandidate1->GetMCParticleLabel(MCStack);
1681 Int_t gamma1MotherLabel = -1;
1682 if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
1683 // Daughters Gamma 1
1684 TParticle * negativeMC = (TParticle*)TrueGammaCandidate1->GetNegativeMCDaughter(MCStack);
1685 TParticle * positiveMC = (TParticle*)TrueGammaCandidate1->GetPositiveMCDaughter(MCStack);
1686 TParticle * gammaMC1 = (TParticle*)MCStack->Particle(gamma1MCLabel);
e5b6e8a6 1687 if(abs(negativeMC->GetPdgCode())==11 && abs(positiveMC->GetPdgCode())==11){ // Electrons ...
2bb2434e 1688 if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
1689 if(gammaMC1->GetPdgCode() == 22){ // ... with Gamma Mother
1690 gamma1MotherLabel=gammaMC1->GetFirstMother();
1691 }
1692 }
86eaf9ae 1693 if(gammaMC1->GetPdgCode() ==111 ){ // Dalitz candidate
1694 gamma1DalitzCand = kTRUE;
1695 gamma1MotherLabel=-111;
2bb2434e 1696 }
86eaf9ae 1697 if(gammaMC1->GetPdgCode() ==221){ // Dalitz candidate
1698 gamma1DalitzCand = kTRUE;
1699 gamma1MotherLabel=-221;
2bb2434e 1700 }
1701 }
1702 }
1703 if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
1704 if(((TParticle*)MCStack->Particle(gamma1MotherLabel))->GetPdgCode() == 111){
1705 isTruePi0=kTRUE;
1706 }
1707 if(((TParticle*)MCStack->Particle(gamma1MotherLabel))->GetPdgCode() == 221){
1708 isTrueEta=kTRUE;
1709 }
1710 }
86eaf9ae 1711
1712 //Identify Dalitz candidate
1713 if (gamma1DalitzCand || gamma0DalitzCand){
1714 if (gamma0DalitzCand && gamma0MCLabel >=0 && gamma0MCLabel==gamma1MotherLabel){
1715 if (gamma0MotherLabel == -111) isTruePi0Dalitz = kTRUE;
1716 if (gamma0MotherLabel == -221) isTrueEtaDalitz = kTRUE;
1717 }
1718 if (gamma1DalitzCand && gamma1MCLabel >=0 && gamma1MCLabel==gamma0MotherLabel){
1719 if (gamma1MotherLabel == -111) isTruePi0Dalitz = kTRUE;
1720 if (gamma1MotherLabel == -221) isTrueEtaDalitz = kTRUE;
1721 }
1722 }
1723
1724
e5b6e8a6 1725 if(isTruePi0 || isTrueEta){// True Pion or Eta
4803eb1f 1726 hESDTrueMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
e5b6e8a6 1727 if(gamma0MotherLabel >= MCStack->GetNprimary()){ // Secondary Meson
ae947965 1728 Int_t secMotherLabel = ((TParticle*)MCStack->Particle(gamma1MotherLabel))->GetMother(0);
1729 Float_t weightedSec= 1;
1730 if(((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(secMotherLabel, fMCStack, fInputEvent) && MCStack->Particle(secMotherLabel)->GetPdgCode()==310){
1731 weightedSec= ((AliConversionCuts*)fCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),secMotherLabel, fMCStack, fInputEvent)/2.; //invariant mass is additive thus the weight for the daughters has to be devide by two for the K0s at a certain pt
1732 //cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
1733 }
1734 hESDTrueSecondaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
4803eb1f 1735 iMesonMCInfo = 2;
ae947965 1736 if (secMotherLabel >-1){
1737 if(MCStack->Particle(secMotherLabel)->GetPdgCode()==310){
4803eb1f 1738 iMesonMCInfo = 4;
ae947965 1739 hESDTrueSecondaryMotherFromK0sInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
0a2b2b4b 1740 if (fDoMesonQA)hESDTrueK0sWithPi0DaughterMCPt[fiCut]
ae947965 1741 ->Fill(MCStack->Particle(secMotherLabel)->Pt());
e5b6e8a6 1742 }
ae947965 1743 if(MCStack->Particle(secMotherLabel)->GetPdgCode()==221){
4803eb1f 1744 iMesonMCInfo = 3;
ae947965 1745 hESDTrueSecondaryMotherFromEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
0a2b2b4b 1746 if (fDoMesonQA)hESDTrueEtaWithPi0DaughterMCPt[fiCut]
ae947965 1747 ->Fill(MCStack->Particle(secMotherLabel)->Pt());
ca91a3e1 1748 }
1749 }
0a2b2b4b 1750 }else{ // Only primary pi0 for efficiency calculation
4803eb1f 1751 iMesonMCInfo = 6;
a280ac15 1752 Float_t weighted= 1;
ae947965 1753 if(((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(gamma1MotherLabel, fMCStack, fInputEvent)){
a280ac15 1754 if (((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt()>0.005){
ae947965 1755 weighted= ((AliConversionCuts*)fCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),gamma1MotherLabel, fMCStack, fInputEvent);
1756// cout << "rec \t " <<gamma1MotherLabel << "\t" << weighted << endl;
a280ac15 1757 }
1758 }
1759 hESDTruePrimaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
526074e4 1760 hESDTruePrimaryMotherW0WeightingInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
1761 pESDTruePrimaryMotherWeightsInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
0a2b2b4b 1762 if (fDoMesonQA){
0a2b2b4b 1763 if(isTruePi0){ // Only primary pi0 for resolution
1764 hESDTruePrimaryPi0MCPtResolPt[fiCut]->Fill(((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt(),(Pi0Candidate->Pt()-((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt())/((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt(),weighted);
1765 }
1766 if (isTrueEta){ // Only primary eta for resolution
1767 hESDTruePrimaryEtaMCPtResolPt[fiCut]->Fill(((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt(),(Pi0Candidate->Pt()-((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt())/((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt(),weighted);
1768 }
ca91a3e1 1769 }
1770 }
86eaf9ae 1771 } else if(!isTruePi0 && !isTrueEta){ // Background
1772 if (fDoMesonQA){
1773 if(gamma0MotherLabel>-1 && gamma1MotherLabel>-1){ // Both Tracks are Photons and have a mother but not Pi0 or Eta
1774 hESDTrueBckGGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
1775 iMesonMCInfo = 1;
1776 } else { // No photon or without mother
1777 hESDTrueBckContInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
1778 }
2bb2434e 1779 }
86eaf9ae 1780 if( isTruePi0Dalitz || isTrueEtaDalitz ){
2bb2434e 1781 // Dalitz
4803eb1f 1782 iMesonMCInfo = 5;
2bb2434e 1783 hESDTrueMotherDalitzInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
86eaf9ae 1784 } else if (gamma0DalitzCand || gamma1DalitzCand){
1785 if (fDoMesonQA)hESDTrueBckContInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
1786 }
2bb2434e 1787 }
1788 }
1789 }
1790}
ae947965 1791//______________________________________________________________________
1792void AliAnalysisTaskGammaConvV1::ProcessTrueMesonCandidatesAOD(AliAODConversionMother *Pi0Candidate, AliAODConversionPhoton *TrueGammaCandidate0, AliAODConversionPhoton *TrueGammaCandidate1)
1793{
1794
1795 // Process True Mesons
1796 TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
1797 Bool_t isTruePi0 = kFALSE;
1798 Bool_t isTrueEta = kFALSE;
86eaf9ae 1799 Bool_t isTruePi0Dalitz = kFALSE;
1800 Bool_t isTrueEtaDalitz = kFALSE;
1801 Bool_t gamma0DalitzCand = kFALSE;
1802 Bool_t gamma1DalitzCand = kFALSE;
ae947965 1803
1804 AliAODMCParticle *positiveMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelPositive()));
1805 AliAODMCParticle *negativeMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelNegative()));
2bb2434e 1806
4803eb1f 1807 iMesonMCInfo = 0;
ae947965 1808 Int_t gamma0MCLabel = -1;
1809 Int_t gamma0MotherLabel = -1;
1810 if(!positiveMC||!negativeMC)
1811 return;
1812
1813 if(positiveMC->GetMother()>-1&&(negativeMC->GetMother() == positiveMC->GetMother())){
1814 gamma0MCLabel = positiveMC->GetMother();
1815 }
1816
1817 if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
1818 // Daughters Gamma 0
1819 AliAODMCParticle * gammaMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MCLabel));
1820 if(abs(negativeMC->GetPdgCode())==11 && abs(positiveMC->GetPdgCode())==11){ // Electrons ...
86eaf9ae 1821 if(((positiveMC->GetMCProcessCode())) == 5 && ((negativeMC->GetMCProcessCode())) == 5){ // ... From Conversion ...
ae947965 1822 if(gammaMC0->GetPdgCode() == 22){ // ... with Gamma Mother
1823 gamma0MotherLabel=gammaMC0->GetMother();
1824 }
1825 }
86eaf9ae 1826 if(gammaMC0->GetPdgCode() ==111){ // Dalitz candidate
1827 gamma0DalitzCand = kTRUE;
ae947965 1828 gamma0MotherLabel=-111;
1829 }
86eaf9ae 1830 if(gammaMC0->GetPdgCode() ==221){ // Dalitz candidate
1831 gamma0DalitzCand = kTRUE;
ae947965 1832 gamma0MotherLabel=-221;
1833 }
1834 }
1835 }
1836 positiveMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate1->GetMCLabelPositive()));
1837 negativeMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate1->GetMCLabelNegative()));
1838
1839 Int_t gamma1MCLabel = -1;
1840 Int_t gamma1MotherLabel = -1;
1841 if(!positiveMC||!negativeMC)
1842 return;
1843
1844 if(positiveMC->GetMother()>-1&&(negativeMC->GetMother() == positiveMC->GetMother())){
1845 gamma1MCLabel = positiveMC->GetMother();
1846 }
1847 if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
1848 // Daughters Gamma 1
1849 AliAODMCParticle * gammaMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MCLabel));
1850 if(abs(negativeMC->GetPdgCode())==11 && abs(positiveMC->GetPdgCode())==11){ // Electrons ...
86eaf9ae 1851 if(((positiveMC->GetMCProcessCode())) == 5 && ((negativeMC->GetMCProcessCode())) == 5){ // ... From Conversion ...
ae947965 1852 if(gammaMC1->GetPdgCode() == 22){ // ... with Gamma Mother
1853 gamma1MotherLabel=gammaMC1->GetMother();
1854 }
1855 }
86eaf9ae 1856 if(gammaMC1->GetPdgCode() ==111 ){ // Dalitz candidate
1857 gamma1DalitzCand = kTRUE;
1858 gamma1MotherLabel=-111;
ae947965 1859 }
86eaf9ae 1860 if(gammaMC1->GetPdgCode() ==221){ // Dalitz candidate
1861 gamma1DalitzCand = kTRUE;
ae947965 1862 gamma1MotherLabel=-221;
1863 }
1864 }
1865 }
1866 if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
1867 if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == 111){
1868 isTruePi0=kTRUE;
1869 }
1870 if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == 221){
1871 isTrueEta=kTRUE;
1872 }
1873 }
86eaf9ae 1874
1875 //Identify Dalitz candidate
1876 if (gamma1DalitzCand || gamma0DalitzCand){
1877 if (gamma0DalitzCand && gamma0MCLabel >=0 && gamma0MCLabel==gamma1MotherLabel){
1878 if (gamma0MotherLabel == -111) isTruePi0Dalitz = kTRUE;
1879 if (gamma0MotherLabel == -221) isTrueEtaDalitz = kTRUE;
1880 }
1881 if (gamma1DalitzCand && gamma1MCLabel >=0 && gamma1MCLabel==gamma0MotherLabel){
1882 if (gamma1MotherLabel == -111) isTruePi0Dalitz = kTRUE;
1883 if (gamma1MotherLabel == -221) isTrueEtaDalitz = kTRUE;
1884 }
1885 }
1886
ae947965 1887 if(isTruePi0 || isTrueEta){// True Pion or Eta
1888 hESDTrueMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
1889
1890 if(!(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MotherLabel))->IsPrimary())){ // Secondary Meson
1891 Int_t secMotherLabel = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->GetMother();
1892 Float_t weightedSec= 1;
1893 if(((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(secMotherLabel, 0x0, fInputEvent) && static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==310){
1894 weightedSec= ((AliConversionCuts*)fCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),secMotherLabel, 0x0, fInputEvent)/2.; //invariant mass is additive thus the weight for the daughters has to be devide by two for the K0s at a certain pt
1895 //cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
1896 }
1897 hESDTrueSecondaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
4803eb1f 1898 iMesonMCInfo = 2;
ae947965 1899 if (secMotherLabel >-1){
1900 if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==310){
4803eb1f 1901 iMesonMCInfo = 4;
ae947965 1902 hESDTrueSecondaryMotherFromK0sInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
1903 if (fDoMesonQA)hESDTrueK0sWithPi0DaughterMCPt[fiCut]
1904 ->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
1905 }
1906 if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==221){
4803eb1f 1907 iMesonMCInfo = 3;
ae947965 1908 hESDTrueSecondaryMotherFromEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
1909 if (fDoMesonQA)hESDTrueEtaWithPi0DaughterMCPt[fiCut]
1910 ->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
1911 }
1912 }
1913 }else{ // Only primary pi0 for efficiency calculation
1914 Float_t weighted= 1;
4803eb1f 1915 iMesonMCInfo = 6;
ae947965 1916 if(((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(gamma1MotherLabel, 0x0, fInputEvent)){
1917 if (static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt()>0.005){
1918 weighted= ((AliConversionCuts*)fCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),gamma1MotherLabel, 0x0, fInputEvent);
1919 // cout << "rec \t " <<gamma1MotherLabel << "\t" << weighted << endl;
1920 }
1921 }
1922 hESDTruePrimaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
4803eb1f 1923 hESDTruePrimaryMotherW0WeightingInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
1924 pESDTruePrimaryMotherWeightsInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
1925
ae947965 1926 if (fDoMesonQA){
ae947965 1927 if(isTruePi0){ // Only primary pi0 for resolution
1928 hESDTruePrimaryPi0MCPtResolPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),
1929 (Pi0Candidate->Pt()-static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt())/static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),weighted);
1930 }
1931 if (isTrueEta){ // Only primary eta for resolution
1932 hESDTruePrimaryEtaMCPtResolPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),
1933 (Pi0Candidate->Pt()-static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt())/static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),weighted);
1934 }
1935 }
1936 }
86eaf9ae 1937 } else if(!isTruePi0 && !isTrueEta) { // Background
1938 if (fDoMesonQA){
1939 if(gamma0MotherLabel>-1 && gamma1MotherLabel>-1){ // Both Tracks are Photons and have a mother but not Pi0 or Eta
1940 hESDTrueBckGGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
1941 iMesonMCInfo = 1;
1942 } else { // No photon or without mother
1943 hESDTrueBckContInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
1944 }
ae947965 1945 }
86eaf9ae 1946 if( isTruePi0Dalitz || isTrueEtaDalitz ){
ae947965 1947 // Dalitz
4803eb1f 1948 iMesonMCInfo = 5;
ae947965 1949 hESDTrueMotherDalitzInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
86eaf9ae 1950 } else if (gamma0DalitzCand || gamma1DalitzCand){
1951 if (fDoMesonQA)hESDTrueBckContInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
ae947965 1952 }
1953 }
1954}
2bb2434e 1955//________________________________________________________________________
1956void AliAnalysisTaskGammaConvV1::CalculateBackground(){
1957
e5b6e8a6 1958 Int_t zbin= fBGHandler[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
2bb2434e 1959 Int_t mbin = 0;
1960
ca91a3e1 1961 if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
4803eb1f 1962 mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fV0Reader->GetNumberOfPrimaryTracks());
2bb2434e 1963 } else {
a280ac15 1964 mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fGammaCandidates->GetEntries());
2bb2434e 1965 }
1966
ca91a3e1 1967 if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseRotationMethod()){
2bb2434e 1968
a280ac15 1969 for(Int_t iCurrent=0;iCurrent<fGammaCandidates->GetEntries();iCurrent++){
1970 AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fGammaCandidates->At(iCurrent));
1971 for(Int_t iCurrent2=iCurrent+1;iCurrent2<fGammaCandidates->GetEntries();iCurrent2++){
e5b6e8a6 1972 for(Int_t nRandom=0;nRandom<((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetNumberOfBGEvents();nRandom++){
a280ac15 1973 AliAODConversionPhoton currentEventGoodV02 = *(AliAODConversionPhoton*)(fGammaCandidates->At(iCurrent2));
2bb2434e 1974
ca91a3e1 1975 if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->DoBGProbability()){
2bb2434e 1976 AliAODConversionMother *backgroundCandidateProb = new AliAODConversionMother(&currentEventGoodV0,&currentEventGoodV02);
1977 Double_t massBGprob = backgroundCandidateProb->M();
1978 if(massBGprob>0.1 && massBGprob<0.14){
1979 if(fRandom.Rndm()>fBGHandler[fiCut]->GetBGProb(zbin,mbin)){
1980 delete backgroundCandidateProb;
1981 continue;
1982 }
1983 }
1984 delete backgroundCandidateProb;
1985 backgroundCandidateProb = 0x0;
1986 }
1987
1988 RotateParticle(&currentEventGoodV02);
1989 AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&currentEventGoodV02);
4803eb1f 1990 backgroundCandidate->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
1991 if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))
1992 ->MesonIsSelected(backgroundCandidate,kFALSE,((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift()))){
2bb2434e 1993 hESDMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt());
e5b6e8a6 1994 Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
2bb2434e 1995 sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,1);
1996 }
1997 delete backgroundCandidate;
1998 backgroundCandidate = 0x0;
1999 }
2000 }
2001 }
ca91a3e1 2002 }else{
2bb2434e 2003 AliGammaConversionAODBGHandler::GammaConversionVertex *bgEventVertex = NULL;
2004
ca91a3e1 2005 if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
2bb2434e 2006 for(Int_t nEventsInBG=0;nEventsInBG<fBGHandler[fiCut]->GetNBGEvents();nEventsInBG++){
2007 AliGammaConversionAODVector *previousEventV0s = fBGHandler[fiCut]->GetBGGoodV0s(zbin,mbin,nEventsInBG);
2008 if(fMoveParticleAccordingToVertex == kTRUE){
2009 bgEventVertex = fBGHandler[fiCut]->GetBGEventVertex(zbin,mbin,nEventsInBG);
2010 }
2011
a280ac15 2012 for(Int_t iCurrent=0;iCurrent<fGammaCandidates->GetEntries();iCurrent++){
2013 AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fGammaCandidates->At(iCurrent));
2bb2434e 2014 for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
2015 AliAODConversionPhoton previousGoodV0 = (AliAODConversionPhoton)(*(previousEventV0s->at(iPrevious)));
2016 if(fMoveParticleAccordingToVertex == kTRUE){
2017 MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
2018 }
2019
2020 AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&previousGoodV0);
4803eb1f 2021 backgroundCandidate->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
2022 if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))
2023 ->MesonIsSelected(backgroundCandidate,kFALSE,((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift()))){
2bb2434e 2024 hESDMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt());
e5b6e8a6 2025 Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
2bb2434e 2026 sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,1);
2027 }
2028 delete backgroundCandidate;
2029 backgroundCandidate = 0x0;
2030 }
2031 }
2032 }
2033 }
2034 else{
2035 for(Int_t nEventsInBG=0;nEventsInBG <fBGHandler[fiCut]->GetNBGEvents();nEventsInBG++){
2036 AliGammaConversionAODVector *previousEventV0s = fBGHandler[fiCut]->GetBGGoodV0s(zbin,mbin,nEventsInBG);
2037 if(previousEventV0s){
2038 if(fMoveParticleAccordingToVertex == kTRUE){
2039 bgEventVertex = fBGHandler[fiCut]->GetBGEventVertex(zbin,mbin,nEventsInBG);
2040 }
a280ac15 2041 for(Int_t iCurrent=0;iCurrent<fGammaCandidates->GetEntries();iCurrent++){
2042 AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fGammaCandidates->At(iCurrent));
2bb2434e 2043 for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
2044
2045 AliAODConversionPhoton previousGoodV0 = (AliAODConversionPhoton)(*(previousEventV0s->at(iPrevious)));
2046
2047 if(fMoveParticleAccordingToVertex == kTRUE){
2048 MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
2049 }
2050
2051 AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&previousGoodV0);
4803eb1f 2052 backgroundCandidate->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
2053 if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))
2054 ->MesonIsSelected(backgroundCandidate,kFALSE,((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift()))){
2bb2434e 2055 hESDMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt());
e5b6e8a6 2056 Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
2bb2434e 2057 sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,1);
2058 }
2059 delete backgroundCandidate;
2060 backgroundCandidate = 0x0;
2061 }
2062 }
2063 }
2064 }
2065 }
2066 }
2067}
e5b6e8a6 2068//________________________________________________________________________
2069void AliAnalysisTaskGammaConvV1::CalculateBackgroundRP(){
2070
2071 Int_t zbin= fBGHandlerRP[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
2072 Int_t mbin = 0;
2073 if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
4803eb1f 2074 mbin = fBGHandlerRP[fiCut]->GetMultiplicityBinIndex(fV0Reader->GetNumberOfPrimaryTracks());
e5b6e8a6 2075 } else {
a280ac15 2076 mbin = fBGHandlerRP[fiCut]->GetMultiplicityBinIndex(fGammaCandidates->GetEntries());
e5b6e8a6 2077 }
2078
2079
2080 //Rotation Method
2081 if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseRotationMethod()){
2082 // Correct for the number of rotations
2083 // BG is for rotation the same, except for factor NRotations
2084 Double_t weight=1./Double_t(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetNumberOfBGEvents());
2085
a280ac15 2086 for(Int_t firstGammaIndex=0;firstGammaIndex<fGammaCandidates->GetEntries();firstGammaIndex++){
e5b6e8a6 2087
a280ac15 2088 AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(firstGammaIndex));
0a2b2b4b 2089 if (gamma0==NULL) continue;
a280ac15 2090 for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fGammaCandidates->GetEntries();secondGammaIndex++){
2091 AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(secondGammaIndex));
0a2b2b4b 2092 if (gamma1 == NULL) continue;
e5b6e8a6 2093 if(!((AliConversionCuts*)fCutArray->At(fiCut))->PhotonIsSelected(gamma1,fInputEvent))continue;
2094 for(Int_t nRandom=0;nRandom<((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetNumberOfBGEvents();nRandom++){
2095
2096 RotateParticle(gamma1);
2097
2098 AliAODConversionMother backgroundCandidate(gamma0,gamma1);
4803eb1f 2099 backgroundCandidate.CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
2100 if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))
2101 ->MesonIsSelected(&backgroundCandidate,kFALSE,((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift())){
e5b6e8a6 2102 hESDMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate.M(),backgroundCandidate.Pt());
2103 Double_t sparesFill[4] = {backgroundCandidate.M(),backgroundCandidate.Pt(),(Double_t)zbin,(Double_t)mbin};
2104 sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,weight);
e5b6e8a6 2105 }
2106 }
2107 }
2108 }
2109 }
2110 else{
2111 // Do Event Mixing
a280ac15 2112 for(Int_t nEventsInBG=0;nEventsInBG <fBGHandlerRP[fiCut]->GetNBGEvents(fGammaCandidates,fInputEvent);nEventsInBG++){
e5b6e8a6 2113
a280ac15 2114 AliGammaConversionPhotonVector *previousEventGammas = fBGHandlerRP[fiCut]->GetBGGoodGammas(fGammaCandidates,fInputEvent,nEventsInBG);
e5b6e8a6 2115
2116 if(previousEventGammas){
2117 // test weighted background
2118 Double_t weight=1.0;
2119 // Correct for the number of eventmixing:
2120 // N gammas -> (N-1) + (N-2) +(N-3) ...+ (N-(N-1)) using sum formula sum(i)=N*(N-1)/2 -> N*(N-1)/2
2121 // real combinations (since you cannot combine a photon with its own)
2122 // but BG leads to N_{a}*N_{b} combinations
a280ac15 2123 weight*=0.5*(Double_t(fGammaCandidates->GetEntries()-1))/Double_t(previousEventGammas->size());
e5b6e8a6 2124
a280ac15 2125 for(Int_t iCurrent=0;iCurrent<fGammaCandidates->GetEntries();iCurrent++){
e5b6e8a6 2126
a280ac15 2127 AliAODConversionPhoton *gamma0 = (AliAODConversionPhoton*)(fGammaCandidates->At(iCurrent));
e5b6e8a6 2128
2129 for(UInt_t iPrevious=0;iPrevious<previousEventGammas->size();iPrevious++){
ca91a3e1 2130
e5b6e8a6 2131 AliAODConversionPhoton *gamma1 = (AliAODConversionPhoton*)(previousEventGammas->at(iPrevious));
2132
2133 AliAODConversionMother backgroundCandidate(gamma0,gamma1);
4803eb1f 2134 backgroundCandidate.CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
2135 if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))
2136 ->MesonIsSelected(&backgroundCandidate,kFALSE,((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift())){
e5b6e8a6 2137 hESDMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate.M(),backgroundCandidate.Pt());
2138 Double_t sparesFill[4] = {backgroundCandidate.M(),backgroundCandidate.Pt(),(Double_t)zbin,(Double_t)mbin};
2139 sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,weight);
e5b6e8a6 2140 }
2141 }
2142 }
2143 }
2144 }
2145 }
2146}
2bb2434e 2147//________________________________________________________________________
2148void AliAnalysisTaskGammaConvV1::RotateParticle(AliAODConversionPhoton *gamma){
ca91a3e1 2149 Int_t fNDegreesPMBackground= ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->NDegreesRotation();
2bb2434e 2150 Double_t nRadiansPM = fNDegreesPMBackground*TMath::Pi()/180;
2151 Double_t rotationValue = fRandom.Rndm()*2*nRadiansPM + TMath::Pi()-nRadiansPM;
2152 gamma->RotateZ(rotationValue);
2153}
2154//________________________________________________________________________
2155void AliAnalysisTaskGammaConvV1::MoveParticleAccordingToVertex(AliAODConversionPhoton* particle,const AliGammaConversionAODBGHandler::GammaConversionVertex *vertex){
2156 //see header file for documentation
2157
e5b6e8a6 2158 Double_t dx = vertex->fX - fInputEvent->GetPrimaryVertex()->GetX();
2159 Double_t dy = vertex->fY - fInputEvent->GetPrimaryVertex()->GetY();
2160 Double_t dz = vertex->fZ - fInputEvent->GetPrimaryVertex()->GetZ();
2bb2434e 2161
2162 Double_t movedPlace[3] = {particle->GetConversionX() - dx,particle->GetConversionY() - dy,particle->GetConversionZ() - dz};
2163 particle->SetConversionPoint(movedPlace);
2164}
2165//________________________________________________________________________
2166void AliAnalysisTaskGammaConvV1::UpdateEventByEventData(){
2167 //see header file for documentation
a280ac15 2168 if(fGammaCandidates->GetEntries() >0 ){
ca91a3e1 2169 if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
4803eb1f 2170 fBGHandler[fiCut]->AddEvent(fGammaCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fV0Reader->GetNumberOfPrimaryTracks());
2bb2434e 2171 }
2172 else{ // means we use #V0s for multiplicity
a280ac15 2173 fBGHandler[fiCut]->AddEvent(fGammaCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fGammaCandidates->GetEntries());
2bb2434e 2174 }
2175 }
2176}
2177
2bb2434e 2178
2bb2434e 2179//________________________________________________________________________
ae947965 2180void AliAnalysisTaskGammaConvV1::FillPhotonCombinatorialBackgroundHist(AliAODConversionPhoton *TruePhotonCandidate, Int_t pdgCode[])
2181{
2182 // Combinatorial Bck = 0 ee, 1 ep,i 2 ek, 3 ep, 4 emu, 5 pipi, 6 pik, 7 pip, 8 pimu, 9 kk, 10 kp, 11 kmu, 12 pp, 13 pmu, 14 mumu, 15 Rest
2183 if(pdgCode[0]==11 && pdgCode[1]==11){if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),0);}
2184 else if( (pdgCode[0]==11 && pdgCode[1]==211) || (pdgCode[0]==211 && pdgCode[1]==11) )
2185 {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),1);}
2186 else if( (pdgCode[0]==11 && pdgCode[1]==321) || (pdgCode[0]==321 && pdgCode[1]==11) )
2187 {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),2);}
2188 else if( (pdgCode[0]==11 && pdgCode[1]==2212) || (pdgCode[0]==2212 && pdgCode[1]==11) )
2189 {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3);}
2190 else if( (pdgCode[0]==11 && pdgCode[1]==13) || (pdgCode[0]==13 && pdgCode[1]==11) )
2191 {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),4);}
2192 else if( pdgCode[0]==211 && pdgCode[1]==211 ){if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),5);}
2193 else if( (pdgCode[0]==211 && pdgCode[1]==321) || (pdgCode[0]==321 && pdgCode[1]==211) )
2194 {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),6);}
2195 else if( (pdgCode[0]==211 && pdgCode[1]==2212) || (pdgCode[0]==2212 && pdgCode[1]==211) )
2196 {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),7);}
2197 else if( (pdgCode[0]==211 && pdgCode[1]==13) || (pdgCode[0]==13 && pdgCode[1]==211) )
2198 {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),8);}
2199 else if( pdgCode[0]==321 && pdgCode[1]==321 ){if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),9);}
2200 else if( (pdgCode[0]==321 && pdgCode[1]==2212) || (pdgCode[0]==2212 && pdgCode[1]==321) )
2201 {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),10);}
2202 else if( (pdgCode[0]==321 && pdgCode[1]==13) || (pdgCode[0]==13 && pdgCode[1]==321) )
2203 {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),11);}
2204 else if( pdgCode[0]==2212 && pdgCode[1]==2212 ){if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),12);}
2205 else if( (pdgCode[0]==2212 && pdgCode[1]==13) || (pdgCode[0]==13 && pdgCode[1]==2212) )
2206 {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),13);}
2207 else if( pdgCode[0]==13 && pdgCode[1]==13 ){if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),14);}
2208 else {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),15);}
2209}
2210//________________________________________________________________________
2211void AliAnalysisTaskGammaConvV1::RelabelAODPhotonCandidates(Bool_t mode){
2212
2213 // Relabeling For AOD Event
2214 // ESDiD -> AODiD
2215 // MCLabel -> AODMCLabel
2216
2217 if(mode){
2218 fMCStackPos = new Int_t[fReaderGammas->GetEntries()];
2219 fMCStackNeg = new Int_t[fReaderGammas->GetEntries()];
1186afd2 2220 fESDArrayPos = new Int_t[fReaderGammas->GetEntries()];
2221 fESDArrayNeg = new Int_t[fReaderGammas->GetEntries()];
ae947965 2222 }
2223
2224 for(Int_t iGamma = 0;iGamma<fReaderGammas->GetEntries();iGamma++){
2225 AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) fReaderGammas->At(iGamma);
2226 if(!PhotonCandidate) continue;
2227 if(!mode){// Back to ESD Labels
2228 PhotonCandidate->SetMCLabelPositive(fMCStackPos[iGamma]);
2229 PhotonCandidate->SetMCLabelNegative(fMCStackNeg[iGamma]);
1186afd2 2230 PhotonCandidate->SetLabelPositive(fESDArrayPos[iGamma]);
2231 PhotonCandidate->SetLabelNegative(fESDArrayNeg[iGamma]);
ae947965 2232 continue;
2233 }
2234 fMCStackPos[iGamma] = PhotonCandidate->GetMCLabelPositive();
2235 fMCStackNeg[iGamma] = PhotonCandidate->GetMCLabelNegative();
1186afd2 2236 fESDArrayPos[iGamma] = PhotonCandidate->GetTrackLabelPositive();
2237 fESDArrayNeg[iGamma] = PhotonCandidate->GetTrackLabelNegative();
ae947965 2238
2239 Bool_t AODLabelPos = kFALSE;
2240 Bool_t AODLabelNeg = kFALSE;
2241
2242 for(Int_t i = 0; i<fInputEvent->GetNumberOfTracks();i++){
2243 AliAODTrack *tempDaughter = static_cast<AliAODTrack*>(fInputEvent->GetTrack(i));
2244 if(!AODLabelPos){
2245 if( tempDaughter->GetID() == PhotonCandidate->GetTrackLabelPositive() ){
2246 PhotonCandidate->SetMCLabelPositive(abs(tempDaughter->GetLabel()));
1186afd2 2247 PhotonCandidate->SetLabelPositive(i);
ae947965 2248 AODLabelPos = kTRUE;
2249 }
2250 }
2251 if(!AODLabelNeg){
2252 if( tempDaughter->GetID() == PhotonCandidate->GetTrackLabelNegative()){
2253 PhotonCandidate->SetMCLabelNegative(abs(tempDaughter->GetLabel()));
1186afd2 2254 PhotonCandidate->SetLabelNegative(i);
ae947965 2255 AODLabelNeg = kTRUE;
2256 }
2257 }
2258 if(AODLabelNeg && AODLabelPos){
2259 break;
2260 }
1186afd2 2261 }
ae947965 2262 if(!AODLabelPos || !AODLabelNeg){
1186afd2 2263 cout<<"WARNING!!! AOD TRACKS NOT FOUND FOR"<<endl;
ae947965 2264 }
2265 }
2266
1186afd2 2267
ae947965 2268 if(!mode){
2269 delete[] fMCStackPos;
2270 delete[] fMCStackNeg;
1186afd2 2271 delete[] fESDArrayPos;
2272 delete[] fESDArrayNeg;
ae947965 2273 }
2274}
2275//________________________________________________________________________
2bb2434e 2276void AliAnalysisTaskGammaConvV1::Terminate(const Option_t *)
2277{
e5b6e8a6 2278
a280ac15 2279 //fOutputContainer->Print(); // Will crash on GRID
2bb2434e 2280}