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