AliPhysics  421aab4 (421aab4)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskGammaConvFlow.cxx
Go to the documentation of this file.
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: Andrea Dubla, Redmer Alexander Bertens, Friederike Bock *
5 * *
6 * Permission to use, copy, modify and distribute this software and its *
7 * documentation strictly for non-commercial purposes is hereby granted *
8 * without fee, provided that the above copyright notice appears in all *
9 * copies and that both the copyright notice and this permission notice *
10 * appear in the supporting documentation. The authors make no claims *
11 * about the suitability of this software for any purpose. It is *
12 * provided "as is" without express or implied warranty. *
13 **************************************************************************/
14 
16 //---------------------------------------------
17 
18 // Class used to do analysis on conversion pairs
19 //---------------------------------------------
21 #include "TChain.h"
22 #include "TTree.h"
23 #include "TBranch.h"
24 #include "TFile.h"
25 #include "TH1F.h"
26 #include "TH2F.h"
27 #include "TH3F.h"
28 #include "THnSparse.h"
29 #include "TCanvas.h"
30 #include "TNtuple.h"
31 #include "AliAnalysisTask.h"
32 #include "AliAnalysisManager.h"
33 #include "AliESDEvent.h"
34 #include "AliESDInputHandler.h"
35 #include "AliMCEventHandler.h"
36 #include "AliMCEvent.h"
37 #include "AliMCParticle.h"
38 #include "AliCentrality.h"
39 #include "AliESDVZERO.h"
40 #include "AliESDpid.h"
42 #include "AliVParticle.h"
43 #include "AliESDtrack.h"
44 #include "AliESDtrackCuts.h"
45 #include "AliKFVertex.h"
46 #include "AliV0ReaderV1.h"
47 #include "AliGenCocktailEventHeader.h"
49 #include "AliAODMCParticle.h"
50 #include "AliAODMCHeader.h"
51 #include "AliEventplane.h"
52 
53 #include "AliFlowCandidateTrack.h"
54 #include "AliFlowTrackCuts.h"
55 #include "AliFlowEventSimple.h"
56 #include "AliFlowCommonConstants.h"
57 #include "AliFlowEvent.h"
58 #include "AliFlowTrack.h"
59 
60 class AliFlowTrackCuts;
61 
62 using namespace std;
63 
65 
66 //________________________________________________________________________
68 fV0Reader(NULL),
69 fV0ReaderName("V0ReaderV1"),
70 fBGHandler(NULL),
71 fBGHandlerRP(NULL),
72 fInputEvent(NULL),
73 
74 fCutFolder(NULL),
75 fESDList(NULL),
76 fBackList(NULL),
77 fMotherList(NULL),
78 fPhotonDCAList(NULL),
79 fMesonDCAList(NULL),
80 //fTrueList(NULL),
81 //fMCList(NULL),
82 fHeaderNameList(NULL),
83 fOutputContainer(0),
84 fReaderGammas(NULL),
85 fGammaCandidates(NULL),
86 fEventCutArray(NULL),
87 fEventCuts(NULL),
88 fCutArray(NULL),
89 fConversionCuts(NULL),
90 fMesonCutArray(NULL),
91 fMesonCuts(NULL),
92 hESDConvGammaPt(NULL),
93 hInvMassPair(NULL),
94 hLTMPt(NULL),
95 hLTMPt_MC(NULL),
96 hPt_TruePt(NULL),
97 hdPhidRcandidates(NULL),
98 hdPhidRcandidates_MCsigsig(NULL),
99 hdPhidRcandidates_MCbkgsig(NULL),
100 hdPhidRcandidates_MCbkgbkg(NULL),
101 hKappaTPC(NULL),
102 hKappaTPC_after(NULL),
103 hKappaTPC_Temp0(NULL),
104 hKappaTPC_Temp1(NULL),
105 hKappaTPC_Temp2(NULL),
106 hKappaTPC_Temp3(NULL),
107 hKappaTPC_Temp4(NULL),
108 hKappaTPC_Temp5(NULL),
109 hKappaTPC_Temp6(NULL),
110 hKappaTPC_Temp7(NULL),
111 hKappaTPC_Temp8(NULL),
112 hKappaTPC_Temp9(NULL),
113 hKappaTPC_Temp10(NULL),
114 hESDConvGammaR(NULL),
115 hESDConvGammaEta(NULL),
116 //tESDConvGammaPtDcazCat(NULL),
117 fPtGamma(0),
118 fDCAzPhoton(0),
119 fRConvPhoton(0),
120 fEtaPhoton(0),
121 iCatPhoton(0),
122 iPhotonMCInfo(0),
123 hESDMotherInvMassPt(NULL),
124 //sESDMotherInvMassPtZM(NULL),
125 hESDMotherBackInvMassPt(NULL),
126 //sESDMotherBackInvMassPtZM(NULL),
127 hESDMotherInvMassEalpha(NULL),
128 hESDMotherPi0PtY(NULL),
129 hESDMotherEtaPtY(NULL),
130 hESDMotherPi0PtAlpha(NULL),
131 hESDMotherEtaPtAlpha(NULL),
132 hESDMotherPi0PtOpenAngle(NULL),
133 hESDMotherEtaPtOpenAngle(NULL),
134 
135 hNEvents(NULL),
136 hNGoodESDTracks(NULL),
137 hNGammaCandidates(NULL),
138 hNGoodESDTracksVsNGammaCanditates(NULL),
139 hNV0Tracks(NULL),
140 hEtaShift(NULL),
141 tESDMesonsInvMassPtDcazMinDcazMaxFlag(NULL),
142 fInvMass(0),
143 fPt(0),
144 fDCAzGammaMin(0),
145 fDCAzGammaMax(0),
146 iFlag(0),
147 iMesonMCInfo(0),
148 fEventPlaneAngle(-100),
149 fRandom(0),
150 fnGammaCandidates(0),
151 fUnsmearedPx(NULL),
152 fUnsmearedPy(NULL),
153 fUnsmearedPz(NULL),
154 fUnsmearedE(NULL),
155 fMCEventPos(NULL),
156 fMCEventNeg(NULL),
157 fESDArrayPos(NULL),
158 fESDArrayNeg(NULL),
159 fnCuts(0),
160 fiCut(0),
161 fMoveParticleAccordingToVertex(kTRUE),
162 fIsHeavyIon(0),
163 fDoMesonAnalysis(kTRUE),
164 fDoMesonQA(0),
165 fDoPhotonQA(0),
166 fIsFromMBHeader(kTRUE),
167 fhistoEPVZ(NULL),
168 fMinMass(-1),
169 fMaxMass(10),
170 fMinKappa(-1),
171 fMaxKappa(100),
172 fFilterVariable(1),
173 fMinFilter(0),
174 fMaxFilter(0.2),
175 fApplydPhidRCut(0),
176 fPerformExtraStudies(0),
177 fDebug(0),
178 fCutsRP(0),
179 fNullCuts(0),
180 fFlowEvent(NULL),
181 fIsMC(0),
182 fMCEvent(NULL)
183 {
184  // DefineOutput(1, TList::Class());
185  // DefineOutput(2, AliFlowEventSimple::Class());
186 }
187 
188 //________________________________________________________________________
190 AliAnalysisTaskSE(name),
191 fV0Reader(NULL),
192 fV0ReaderName("V0ReaderV1"),
193 fBGHandler(NULL),
194 fBGHandlerRP(NULL),
195 fInputEvent(NULL),
196 fCutFolder(NULL),
197 fESDList(NULL),
198 fBackList(NULL),
199 fMotherList(NULL),
200 fPhotonDCAList(NULL),
201 fMesonDCAList(NULL),
202 //fTrueList(NULL),
203 //fMCList(NULL),
204 fHeaderNameList(NULL),
205 fOutputContainer(0),
206 fReaderGammas(NULL),
207 fGammaCandidates(NULL),
208 fEventCutArray(NULL),
209 fEventCuts(NULL),
210 fCutArray(NULL),
211 fConversionCuts(NULL),
212 fMesonCutArray(NULL),
213 fMesonCuts(NULL),
214 hESDConvGammaPt(NULL),
215 hInvMassPair(NULL),
216 hLTMPt(NULL),
217 hLTMPt_MC(NULL),
218 hPt_TruePt(NULL),
219 hdPhidRcandidates(NULL),
220 hdPhidRcandidates_MCsigsig(NULL),
221 hdPhidRcandidates_MCbkgsig(NULL),
222 hdPhidRcandidates_MCbkgbkg(NULL),
223 hKappaTPC(NULL),
224 hKappaTPC_after(NULL),
225 hKappaTPC_Temp0(NULL),
226 hKappaTPC_Temp1(NULL),
227 hKappaTPC_Temp2(NULL),
228 hKappaTPC_Temp3(NULL),
229 hKappaTPC_Temp4(NULL),
230 hKappaTPC_Temp5(NULL),
231 hKappaTPC_Temp6(NULL),
232 hKappaTPC_Temp7(NULL),
233 hKappaTPC_Temp8(NULL),
234 hKappaTPC_Temp9(NULL),
235 hKappaTPC_Temp10(NULL),
236 hESDConvGammaR(NULL),
237 hESDConvGammaEta(NULL),
238 //tESDConvGammaPtDcazCat(NULL),
239 fPtGamma(0),
240 fDCAzPhoton(0),
241 fRConvPhoton(0),
242 fEtaPhoton(0),
243 iCatPhoton(0),
244 iPhotonMCInfo(0),
245 hESDMotherInvMassPt(NULL),
246 //sESDMotherInvMassPtZM(NULL),
247 hESDMotherBackInvMassPt(NULL),
248 //sESDMotherBackInvMassPtZM(NULL),
249 hESDMotherInvMassEalpha(NULL),
250 hESDMotherPi0PtY(NULL),
251 hESDMotherEtaPtY(NULL),
252 hESDMotherPi0PtAlpha(NULL),
253 hESDMotherEtaPtAlpha(NULL),
254 hESDMotherPi0PtOpenAngle(NULL),
255 hESDMotherEtaPtOpenAngle(NULL),
256 hNEvents(NULL),
257 hNGoodESDTracks(NULL),
258 hNGammaCandidates(NULL),
259 hNGoodESDTracksVsNGammaCanditates(NULL),
260 hNV0Tracks(NULL),
261 hEtaShift(NULL),
262 tESDMesonsInvMassPtDcazMinDcazMaxFlag(NULL),
263 fInvMass(0),
264 fPt(0),
265 fDCAzGammaMin(0),
266 fDCAzGammaMax(0),
267 iFlag(0),
268 iMesonMCInfo(0),
269 fEventPlaneAngle(-100),
270 fRandom(0),
271 fnGammaCandidates(0),
272 fUnsmearedPx(NULL),
273 fUnsmearedPy(NULL),
274 fUnsmearedPz(NULL),
275 fUnsmearedE(NULL),
276 fMCEventPos(NULL),
277 fMCEventNeg(NULL),
278 fESDArrayPos(NULL),
279 fESDArrayNeg(NULL),
280 fnCuts(0),
281 fiCut(0),
282 fMoveParticleAccordingToVertex(kTRUE),
283 fIsHeavyIon(0),
284 fDoMesonAnalysis(kTRUE),
285 fDoMesonQA(0),
286 fDoPhotonQA(0),
287 fIsFromMBHeader(kTRUE),
288 fhistoEPVZ(NULL),
289 fMinMass(-1),
290 fMaxMass(10),
291 fMinKappa(-1),
292 fMaxKappa(100),
293 fFilterVariable(1),
294 fMinFilter(0),
295 fMaxFilter(0.2),
296 fApplydPhidRCut(0),
297 fPerformExtraStudies(0),
298 fDebug(0),
299 fCutsRP(0),
300 fNullCuts(0),
301 fFlowEvent(NULL),
302 fIsMC(0),
303 fMCEvent(NULL)
304 
305 {
306  // Define output slots here
307  DefineOutput(1, TList::Class());
308  DefineOutput(2, AliFlowEventSimple::Class());
309  DefineOutput(3, AliFlowEventSimple::Class());
310  DefineOutput(4, AliFlowEventSimple::Class());
311  DefineOutput(5, AliFlowEventSimple::Class());
312  DefineOutput(6, AliFlowEventSimple::Class());
313 
314 }
315 
316 
317 //________________________________________________________________________
319 AliAnalysisTaskSE(name),
320 fV0Reader(NULL),
321 fV0ReaderName("V0ReaderV1"),
322 fBGHandler(NULL),
323 fBGHandlerRP(NULL),
324 fInputEvent(NULL),
325 fCutFolder(NULL),
326 fESDList(NULL),
327 fBackList(NULL),
328 fMotherList(NULL),
329 fPhotonDCAList(NULL),
330 fMesonDCAList(NULL),
331 //fTrueList(NULL),
332 //fMCList(NULL),
333 fHeaderNameList(NULL),
334 fOutputContainer(0),
335 fReaderGammas(NULL),
336 fGammaCandidates(NULL),
337 fEventCutArray(NULL),
338 fEventCuts(NULL),
339 fCutArray(NULL),
340 fConversionCuts(NULL),
341 fMesonCutArray(NULL),
342 fMesonCuts(NULL),
343 hESDConvGammaPt(NULL),
344 hInvMassPair(NULL),
345 hLTMPt(NULL),
346 hLTMPt_MC(NULL),
347 hPt_TruePt(NULL),
348 hdPhidRcandidates(NULL),
349 hdPhidRcandidates_MCsigsig(NULL),
350 hdPhidRcandidates_MCbkgsig(NULL),
351 hdPhidRcandidates_MCbkgbkg(NULL),
352 hKappaTPC(NULL),
353 hKappaTPC_after(NULL),
354 hKappaTPC_Temp0(NULL),
355 hKappaTPC_Temp1(NULL),
356 hKappaTPC_Temp2(NULL),
357 hKappaTPC_Temp3(NULL),
358 hKappaTPC_Temp4(NULL),
359 hKappaTPC_Temp5(NULL),
360 hKappaTPC_Temp6(NULL),
361 hKappaTPC_Temp7(NULL),
362 hKappaTPC_Temp8(NULL),
363 hKappaTPC_Temp9(NULL),
364 hKappaTPC_Temp10(NULL),
365 hESDConvGammaR(NULL),
366 hESDConvGammaEta(NULL),
367 //tESDConvGammaPtDcazCat(NULL),
368 fPtGamma(0),
369 fDCAzPhoton(0),
370 fRConvPhoton(0),
371 fEtaPhoton(0),
372 iCatPhoton(0),
373 iPhotonMCInfo(0),
374 hESDMotherInvMassPt(NULL),
375 //sESDMotherInvMassPtZM(NULL),
376 hESDMotherBackInvMassPt(NULL),
377 //sESDMotherBackInvMassPtZM(NULL),
378 hESDMotherInvMassEalpha(NULL),
379 hESDMotherPi0PtY(NULL),
380 hESDMotherEtaPtY(NULL),
381 hESDMotherPi0PtAlpha(NULL),
382 hESDMotherEtaPtAlpha(NULL),
383 hESDMotherPi0PtOpenAngle(NULL),
384 hESDMotherEtaPtOpenAngle(NULL),
385 hNEvents(NULL),
386 hNGoodESDTracks(NULL),
387 hNGammaCandidates(NULL),
388 hNGoodESDTracksVsNGammaCanditates(NULL),
389 hNV0Tracks(NULL),
390 hEtaShift(NULL),
391 tESDMesonsInvMassPtDcazMinDcazMaxFlag(NULL),
392 fInvMass(0),
393 fPt(0),
394 fDCAzGammaMin(0),
395 fDCAzGammaMax(0),
396 iFlag(0),
397 iMesonMCInfo(0),
398 fEventPlaneAngle(-100),
399 fRandom(0),
400 fnGammaCandidates(0),
401 fUnsmearedPx(NULL),
402 fUnsmearedPy(NULL),
403 fUnsmearedPz(NULL),
404 fUnsmearedE(NULL),
405 fMCEventPos(NULL),
406 fMCEventNeg(NULL),
407 fESDArrayPos(NULL),
408 fESDArrayNeg(NULL),
409 fnCuts(nCuts),
410 fiCut(0),
411 fMoveParticleAccordingToVertex(kTRUE),
412 fIsHeavyIon(0),
413 fDoMesonAnalysis(kTRUE),
414 fDoMesonQA(0),
415 fDoPhotonQA(0),
416 fIsFromMBHeader(kTRUE),
417 fhistoEPVZ(NULL),
418 fMinMass(-1),
419 fMaxMass(10),
420 fMinKappa(-1),
421 fMaxKappa(100),
422 fFilterVariable(1),
423 fMinFilter(0),
424 fMaxFilter(0.2),
425 fApplydPhidRCut(0),
426 fPerformExtraStudies(0),
427 fDebug(0),
428 fCutsRP(0),
429 fNullCuts(0),
430 fFlowEvent(NULL),
431 fIsMC(0),
432 fMCEvent(NULL)
433 
434 {
435  // Define output slots here
436  DefineOutput(1, TList::Class());
437  for (Int_t i = 0; i<nCuts; i++){
438  DefineOutput(2+i, AliFlowEventSimple::Class());
439  }
440 
441 }
442 //___________________________________________________________
444 {
445  if(fGammaCandidates){
446  delete fGammaCandidates;
447  fGammaCandidates = 0x0;
448  }
449  if(fBGHandler){
450  delete[] fBGHandler;
451  fBGHandler = 0x0;
452  }
453  if(fBGHandlerRP){
454  delete[] fBGHandlerRP;
455  fBGHandlerRP = 0x0;
456  }
457 
458  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
459  if (fFlowEvent[iCut]) delete fFlowEvent[iCut];
460  }
461 
462 }
463 
464 //________________________________________________________________________
466 
467  // Create histograms
468  if(fOutputContainer != NULL){
469  delete fOutputContainer;
470  fOutputContainer = NULL;
471  }
472  if(fOutputContainer == NULL){
473  fOutputContainer = new TList();
474  fOutputContainer->SetOwner(kTRUE);
475  }
476 
477  //========================= again flow setting==========================
478  //Create histograms
479  //----------hfe initialising begin---------
480  fNullCuts = new AliFlowTrackCuts("null_cuts");
481 
483  cc->SetNbinsMult(10000);
484  cc->SetMultMin(0);
485  cc->SetMultMax(10000);
486 
487  cc->SetNbinsPt(200);
488  cc->SetPtMin(0);
489  cc->SetPtMax(20);
490 
491  cc->SetNbinsPhi(180);
492  cc->SetPhiMin(0.0);
493  cc->SetPhiMax(TMath::TwoPi());
494 
495  cc->SetNbinsEta(40);
496  cc->SetEtaMin(-2.0);
497  cc->SetEtaMax(+2.0);
498 
499  cc->SetNbinsQ(500);
500  cc->SetQMin(0.0);
501  cc->SetQMax(3.0);
502 
503  cc->SetMassMin(fMinFilter);
504  cc->SetMassMax(fMaxFilter);
505  cc->SetNbinsMass(100);
506 
507  // Array of current cut's gammas
508  fGammaCandidates = new TList();
509 
510  fCutFolder = new TList*[fnCuts];
511  fESDList = new TList*[fnCuts];
512  fBackList = new TList*[fnCuts];
513  fMotherList = new TList*[fnCuts];
514  hNEvents = new TH1I*[fnCuts];
515  hNGoodESDTracks = new TH1I*[fnCuts];
516  hNGammaCandidates = new TH1I*[fnCuts];
518  hNV0Tracks = new TH1I*[fnCuts];
519  hEtaShift = new TProfile*[fnCuts];
520  hESDConvGammaPt = new TH1F*[fnCuts];
521  hInvMassPair = new TH2F*[fnCuts];
522  hLTMPt = new TH2F*[fnCuts];
523  hLTMPt_MC = new TH2F*[fnCuts];
524  hPt_TruePt = new TH2F*[fnCuts];
525  hdPhidRcandidates = new TH2F*[fnCuts];
529  hKappaTPC = new TH2F*[fnCuts];
530  hKappaTPC_after = new TH2F*[fnCuts];
531  hKappaTPC_Temp0 = new TH2F*[fnCuts];
532  hKappaTPC_Temp1 = new TH2F*[fnCuts];
533  hKappaTPC_Temp2 = new TH2F*[fnCuts];
534  hKappaTPC_Temp3 = new TH2F*[fnCuts];
535  hKappaTPC_Temp4 = new TH2F*[fnCuts];
536  hKappaTPC_Temp5 = new TH2F*[fnCuts];
537  hKappaTPC_Temp6 = new TH2F*[fnCuts];
538  hKappaTPC_Temp7 = new TH2F*[fnCuts];
539  hKappaTPC_Temp8 = new TH2F*[fnCuts];
540  hKappaTPC_Temp9 = new TH2F*[fnCuts];
541  hKappaTPC_Temp10 = new TH2F*[fnCuts];
542 
543  if (fDoPhotonQA == 2){
544  fPhotonDCAList = new TList*[fnCuts];
545 // tESDConvGammaPtDcazCat = new TTree*[fnCuts];
546  }
547  if (fDoPhotonQA > 0){
548  hESDConvGammaR = new TH1F*[fnCuts];
549  hESDConvGammaEta = new TH1F*[fnCuts];
550  }
551 
552  if(fDoMesonAnalysis){
556  if (fDoMesonQA == 2){
557  fMesonDCAList = new TList*[fnCuts];
559  }
560  if (fDoMesonQA > 0){
561  hESDMotherPi0PtY = new TH2F*[fnCuts];
562  hESDMotherEtaPtY = new TH2F*[fnCuts];
567  }
568  }
569 
570  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
571 
572  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
573  TString cutstringPhoton = ((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutNumber();
574  TString cutstringMeson = "NoMesonCut";
575  if(fDoMesonAnalysis)cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
576 
577  fCutFolder[iCut] = new TList();
578  fCutFolder[iCut]->SetName(Form("Cut Number %s_%s",cutstringEvent.Data() ,cutstringPhoton.Data()));
579  fCutFolder[iCut]->SetOwner(kTRUE);
580  fOutputContainer->Add(fCutFolder[iCut]);
581  fESDList[iCut] = new TList();
582  fESDList[iCut]->SetName(Form("%s_%s ESD histograms",cutstringEvent.Data() ,cutstringPhoton.Data()));
583  fESDList[iCut]->SetOwner(kTRUE);
584  fCutFolder[iCut]->Add(fESDList[iCut]);
585 
586  hNEvents[iCut] = new TH1I("NEvents","NEvents",13,-0.5,12.5);
587  hNEvents[iCut]->GetXaxis()->SetBinLabel(1,"Accepted");
588  hNEvents[iCut]->GetXaxis()->SetBinLabel(2,"Centrality");
589  hNEvents[iCut]->GetXaxis()->SetBinLabel(3,"Missing MC");
590  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->IsSpecialTrigger() > 1 ){
591  TString TriggerNames = "Not Trigger: ";
592  TriggerNames = TriggerNames+ ( (AliConvEventCuts*)fEventCutArray->At(iCut))->GetSpecialTriggerName();
593  hNEvents[iCut]->GetXaxis()->SetBinLabel(4,TriggerNames.Data());
594  } else {
595  hNEvents[iCut]->GetXaxis()->SetBinLabel(4,"Trigger");
596  }
597  hNEvents[iCut]->GetXaxis()->SetBinLabel(5,"Vertex Z");
598  hNEvents[iCut]->GetXaxis()->SetBinLabel(6,"Cont. Vertex");
599  hNEvents[iCut]->GetXaxis()->SetBinLabel(7,"Pile-Up");
600  hNEvents[iCut]->GetXaxis()->SetBinLabel(8,"no SDD");
601  hNEvents[iCut]->GetXaxis()->SetBinLabel(9,"no V0AND");
602  hNEvents[iCut]->GetXaxis()->SetBinLabel(10,"EMCAL problem");
603  hNEvents[iCut]->GetXaxis()->SetBinLabel(12,"SPD hits vs tracklet");
604  hNEvents[iCut]->GetXaxis()->SetBinLabel(13,"Out-of-Bunch pileup Past-Future");
605  fESDList[iCut]->Add(hNEvents[iCut]);
606 
607  if(fIsHeavyIon == 1) hNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",4000,0,4000);
608  else if(fIsHeavyIon == 2) hNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",400,0,400);
609  else hNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",200,0,200);
610  fESDList[iCut]->Add(hNGoodESDTracks[iCut]);
611  if(fIsHeavyIon == 1) hNGammaCandidates[iCut] = new TH1I("GammaCandidates","GammaCandidates",100,0,100);
612  else if(fIsHeavyIon == 2) hNGammaCandidates[iCut] = new TH1I("GammaCandidates","GammaCandidates",50,0,50);
613  else hNGammaCandidates[iCut] = new TH1I("GammaCandidates","GammaCandidates",50,0,50);
614  fESDList[iCut]->Add(hNGammaCandidates[iCut]);
615  if(fIsHeavyIon == 1) hNGoodESDTracksVsNGammaCanditates[iCut] = new TH2F("GoodESDTracksVsGammaCandidates","GoodESDTracksVsGammaCandidates",4000,0,4000,100,0,100);
616  else if(fIsHeavyIon == 2) hNGoodESDTracksVsNGammaCanditates[iCut] = new TH2F("GoodESDTracksVsGammaCandidates","GoodESDTracksVsGammaCandidates",400,0,400,50,0,50);
617  else hNGoodESDTracksVsNGammaCanditates[iCut] = new TH2F("GoodESDTracksVsGammaCandidates","GoodESDTracksVsGammaCandidates",200,0,200,50,0,50);
619 
620 
621  if(fIsHeavyIon == 1) hNV0Tracks[iCut] = new TH1I("V0 Multiplicity","V0 Multiplicity",30000,0,30000);
622  else if(fIsHeavyIon == 2) hNV0Tracks[iCut] = new TH1I("V0 Multiplicity","V0 Multiplicity",2500,0,2500);
623  else hNV0Tracks[iCut] = new TH1I("V0 Multiplicity","V0 Multiplicity",1500,0,1500);
624  fESDList[iCut]->Add(hNV0Tracks[iCut]);
625  hEtaShift[iCut] = new TProfile("Eta Shift","Eta Shift",1, -0.5,0.5);
626  fESDList[iCut]->Add(hEtaShift[iCut]);
627  hESDConvGammaPt[iCut] = new TH1F("ESD_ConvGamma_Pt","ESD_ConvGamma_Pt",250,0,25);
628  fESDList[iCut]->Add(hESDConvGammaPt[iCut]);
629 
630  hInvMassPair[iCut]= new TH2F("InvMassPair_Pt","Gamma invariant mass vs Pt",200,0,0.2,250,0,25);
631  fESDList[iCut]->Add(hInvMassPair[iCut]);
632 
633  hLTMPt[iCut]= new TH2F("LTM_Pt","LTM vs Pt",200,0,200,250,0,25);
634  fESDList[iCut]->Add(hLTMPt[iCut]);
635  hLTMPt_MC[iCut]= new TH2F("LTM_Pt_MCgen","LTM vs Pt (MC)",200,0,200,250,0,25);
636  fESDList[iCut]->Add(hLTMPt_MC[iCut]);
637 
638  hPt_TruePt[iCut]= new TH2F("hPt_TruePt","Pt vs TruePt (MC)",250,0,25,250,0,25);
639  fESDList[iCut]->Add(hPt_TruePt[iCut]);
640  hdPhidRcandidates[iCut]= new TH2F("hdPhidRcandidates","dPhi vs dRconvVtx",400,0,4,300,0,300);
641  fESDList[iCut]->Add(hdPhidRcandidates[iCut]);
642  hdPhidRcandidates_MCsigsig[iCut]= new TH2F("hdPhidRcandidates_MCsigsig","dPhi vs dRconvVtx",400,0,4,300,0,300);
643  fESDList[iCut]->Add(hdPhidRcandidates_MCsigsig[iCut]);
644  hdPhidRcandidates_MCbkgsig[iCut]= new TH2F("hdPhidRcandidates_MCbkgsig","dPhi vs dRconvVtx",400,0,4,300,0,300);
645  fESDList[iCut]->Add(hdPhidRcandidates_MCbkgsig[iCut]);
646  hdPhidRcandidates_MCbkgbkg[iCut]= new TH2F("hdPhidRcandidates_MCbkgbkg","dPhi vs dRconvVtx",400,0,4,300,0,300);
647  fESDList[iCut]->Add(hdPhidRcandidates_MCbkgbkg[iCut]);
648 
649 
650 
651  hKappaTPC[iCut]= new TH2F("KappaTPC_Pt","Gamma KappaTPC vs Pt",200,-20,20,250,0,25);
652  fESDList[iCut]->Add(hKappaTPC[iCut]);
653 
654  hKappaTPC_after[iCut]= new TH2F("KappaTPC_Pt_after","Gamma KappaTPC vs Pt after cuts",200,-20,20,250,0,25);
655  fESDList[iCut]->Add(hKappaTPC_after[iCut]);
656 
657  hKappaTPC_Temp0[iCut]= new TH2F("hKappaTPC_Temp0_ee","Gamma KappaTPC vs Pt Template 0",200,-20,20,250,0,25);
658  fESDList[iCut]->Add(hKappaTPC_Temp0[iCut]);
659 
660  hKappaTPC_Temp1[iCut]= new TH2F("hKappaTPC_Temp1_pipi","Gamma KappaTPC vs Pt Template 1",200,-20,20,250,0,25);
661  fESDList[iCut]->Add(hKappaTPC_Temp1[iCut]);
662 
663  hKappaTPC_Temp2[iCut]= new TH2F("hKappaTPC_Temp2_pie","Gamma KappaTPC vs Pt Template 2",200,-20,20,250,0,25);
664  fESDList[iCut]->Add(hKappaTPC_Temp2[iCut]);
665 
666  hKappaTPC_Temp3[iCut]= new TH2F("hKappaTPC_Temp3_piK","Gamma KappaTPC vs Pt Template 3",200,-20,20,250,0,25);
667  fESDList[iCut]->Add(hKappaTPC_Temp3[iCut]);
668 
669  hKappaTPC_Temp4[iCut]= new TH2F("hKappaTPC_Temp4_pip","Gamma KappaTPC vs Pt Template 4",200,-20,20,250,0,25);
670  fESDList[iCut]->Add(hKappaTPC_Temp4[iCut]);
671 
672  hKappaTPC_Temp5[iCut]= new TH2F("hKappaTPC_Temp5_eK","Gamma KappaTPC vs Pt Template 5",200,-20,20,250,0,25);
673  fESDList[iCut]->Add(hKappaTPC_Temp5[iCut]);
674 
675  hKappaTPC_Temp6[iCut]= new TH2F("hKappaTPC_Temp6_ep","Gamma KappaTPC vs Pt Template 6",200,-20,20,250,0,25);
676  fESDList[iCut]->Add(hKappaTPC_Temp6[iCut]);
677 
678  hKappaTPC_Temp7[iCut]= new TH2F("hKappaTPC_Temp7_KK","Gamma KappaTPC vs Pt Template 7",200,-20,20,250,0,25);
679  fESDList[iCut]->Add(hKappaTPC_Temp7[iCut]);
680 
681  hKappaTPC_Temp8[iCut]= new TH2F("hKappaTPC_Temp8_had","Gamma KappaTPC vs Pt Template 8",200,-20,20,250,0,25);
682  fESDList[iCut]->Add(hKappaTPC_Temp8[iCut]);
683 
684  hKappaTPC_Temp9[iCut]= new TH2F("hKappaTPC_Temp9_rem4","Gamma KappaTPC vs Pt Template 9",200,-20,20,250,0,25);
685  fESDList[iCut]->Add(hKappaTPC_Temp9[iCut]);
686 
687  hKappaTPC_Temp10[iCut]= new TH2F("hKappaTPC_Temp10_rem10","Gamma KappaTPC vs Pt Template 10",200,-20,20,250,0,25);
688  fESDList[iCut]->Add(hKappaTPC_Temp10[iCut]);
689 
690  //2d histogram filling the cut and value - control check for selections
691 
692  if (fDoPhotonQA == 2){
693  fPhotonDCAList[iCut] = new TList();
694  fPhotonDCAList[iCut]->SetName(Form("%s_%s_%s Photon DCA tree",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringMeson.Data()));
695  fPhotonDCAList[iCut]->SetOwner(kTRUE);
696  fCutFolder[iCut]->Add(fPhotonDCAList[iCut]);
697 
698 // tESDConvGammaPtDcazCat[iCut] = new TTree("ESD_ConvGamma_Pt_Dcaz_R_Eta","ESD_ConvGamma_Pt_Dcaz_R_Eta_Cat");
699 // tESDConvGammaPtDcazCat[iCut]->Branch("Pt",&fPtGamma,"fPtGamma/F");
700 // tESDConvGammaPtDcazCat[iCut]->Branch("DcaZPhoton",&fDCAzPhoton,"fDCAzPhoton/F");
701  // tESDConvGammaPtDcazCat[iCut]->Branch("R",&fRConvPhoton,"fRConvPhoton/F");
702  // tESDConvGammaPtDcazCat[iCut]->Branch("Eta",&fEtaPhoton,"fEtaPhoton/F");
703 
704  // tESDConvGammaPtDcazCat[iCut]->Branch("cat",&iCatPhoton,"iCatPhoton/b");
705 
706  // fPhotonDCAList[iCut]->Add(tESDConvGammaPtDcazCat[iCut]);
707  }
708 
709  if (fDoPhotonQA > 0){
710  hESDConvGammaR[iCut] = new TH1F("ESD_ConvGamma_R","ESD_ConvGamma_R",800,0,200);
711  fESDList[iCut]->Add(hESDConvGammaR[iCut]);
712  hESDConvGammaEta[iCut] = new TH1F("ESD_ConvGamma_Eta","ESD_ConvGamma_Eta",2000,-2,2);
713  fESDList[iCut]->Add(hESDConvGammaEta[iCut]);
714  }
715 
716  if(fDoMesonAnalysis){
717  hESDMotherInvMassPt[iCut] = new TH2F("ESD_Mother_InvMass_Pt","ESD_Mother_InvMass_Pt",800,0,0.8,250,0,25);
718  fESDList[iCut]->Add(hESDMotherInvMassPt[iCut]);
719  hESDMotherBackInvMassPt[iCut] = new TH2F("ESD_Background_InvMass_Pt","ESD_Background_InvMass_Pt",800,0,0.8,250,0,25);
720  fESDList[iCut]->Add(hESDMotherBackInvMassPt[iCut]);
721  hESDMotherInvMassEalpha[iCut] = new TH2F("ESD_Mother_InvMass_vs_E_alpha","ESD_Mother_InvMass_vs_E_alpha",800,0,0.8,250,0,25);
722  fESDList[iCut]->Add(hESDMotherInvMassEalpha[iCut]);
723  if (fDoMesonQA == 2){
724  fMesonDCAList[iCut] = new TList();
725  fMesonDCAList[iCut]->SetName(Form("%s_%s_%s Meson DCA tree",cutstringEvent.Data() ,cutstringPhoton.Data(),cutstringMeson.Data()));
726  fMesonDCAList[iCut]->SetOwner(kTRUE);
727  fCutFolder[iCut]->Add(fMesonDCAList[iCut]);
728 
729  tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut] = new TTree("ESD_Mesons_InvMass_Pt_DcazMin_DcazMax_Flag","ESD_Mesons_InvMass_Pt_DcazMin_DcazMax_Flag");
730  tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]->Branch("InvMass",&fInvMass,"fInvMass/F");
731  tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]->Branch("Pt",&fPt,"fPt/F");
732  tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]->Branch("DcaZMin",&fDCAzGammaMin,"fDCAzGammaMin/F");
733  tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]->Branch("DcaZMax",&fDCAzGammaMax,"fDCAzGammaMax/F");
734 
736 
737  }
738  if (fDoMesonQA > 0 ){
739  hESDMotherPi0PtY[iCut] = new TH2F("ESD_MotherPi0_Pt_Y","ESD_MotherPi0_Pt_Y",150,0.03,15.,150,-1.5,1.5);
741  fESDList[iCut]->Add(hESDMotherPi0PtY[iCut]);
742  hESDMotherEtaPtY[iCut] = new TH2F("ESD_MotherEta_Pt_Y","ESD_MotherEta_Pt_Y",150,0.03,15.,150,-1.5,1.5);
744  fESDList[iCut]->Add(hESDMotherEtaPtY[iCut]);
745  hESDMotherPi0PtAlpha[iCut] = new TH2F("ESD_MotherPi0_Pt_Alpha","ESD_MotherPi0_Pt_Alpha",150,0.03,15.,100,0,1);
747  fESDList[iCut]->Add(hESDMotherPi0PtAlpha[iCut]);
748  hESDMotherEtaPtAlpha[iCut] = new TH2F("ESD_MotherEta_Pt_Alpha","ESD_MotherEta_Pt_Alpha",150,0.03,15.,100,0,1);
750  fESDList[iCut]->Add(hESDMotherEtaPtAlpha[iCut]);
751  hESDMotherPi0PtOpenAngle[iCut] = new TH2F("ESD_MotherPi0_Pt_OpenAngle","ESD_MotherPi0_Pt_OpenAngle",150,0.03,15.,100,0,TMath::Pi());
753  fESDList[iCut]->Add(hESDMotherPi0PtOpenAngle[iCut]);
754  hESDMotherEtaPtOpenAngle[iCut] = new TH2F("ESD_MotherEta_Pt_OpenAngle","ESD_MotherEta_Pt_OpenAngle",150,0.03,15.,100,0,TMath::Pi());
756  fESDList[iCut]->Add(hESDMotherEtaPtOpenAngle[iCut]);
757  }
758 
759 
760  }
761 
762 
763  }
764 // if(fDoMesonAnalysis){
765 // InitBack(); // Init Background Handler
766 // }
767 
768 
769 
770  fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data());
771  if(!fV0Reader){printf("Error: No V0 Reader");return;} // GetV0Reader
772 
773  if(fV0Reader)
775  if(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms())
776  fOutputContainer->Add(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms());
777 
778  if(fV0Reader)
780  if(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms())
781  fOutputContainer->Add(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms());
782 
783  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
784  if(!((AliConvEventCuts*)fEventCutArray->At(iCut))) continue;
785  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms()){
786  fCutFolder[iCut]->Add(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms());
787  }
788  if(!((AliConversionPhotonCuts*)fCutArray->At(iCut))) continue;
789  if(((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutHistograms()){
790  fCutFolder[iCut]->Add(((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutHistograms());
791  }
792  if(fDoMesonAnalysis){
793  if(!((AliConversionMesonCuts*)fMesonCutArray->At(iCut))) continue;
794  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms()){
795  fCutFolder[iCut]->Add(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms());
796  }
797  }
798  }
799 
800  fhistoEPVZ = new TH1D("EPVZ", "EPVZ", 60, -TMath::Pi()/2, TMath::Pi()/2);
802 
803 
804 
805  PostData(1, fOutputContainer);
806 
808 
809  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
810  fFlowEvent[iCut] = new AliFlowEvent(10000);
811  if (fIsHeavyIon == 1){
812  PostData(2+iCut, fFlowEvent[iCut]);
813  }
814  }
815 }
816 
817 //_____________________________________________________________________________
819 {
820  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
821  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod && ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum() != AliConvEventCuts::kNoPeriod){
822  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnumExplicit(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum());
823  } else if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod ){
824  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnum(fV0Reader->GetPeriodName());
825  }
826 
827  if(!((AliConvEventCuts*)fEventCutArray->At(iCut))->GetDoEtaShift()){
828  hEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
829  continue; // No Eta Shift requested, continue
830  }
831  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift() == 0.0){ // Eta Shift requested but not set, get shift automatically
832  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCorrectEtaShiftFromPeriod();
833  hEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
834  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
835  continue;
836  }
837  else{
838  printf(" Gamma Conversion Task %s :: Eta Shift Manually Set to %f \n\n",
839  (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber()).Data(),((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift());
840  hEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
841  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
842  }
843  }
844  return kTRUE;
845 }
846 //_____________________________________________________________________________
848 {
849  //
850  // Called for each event
851  //
852  Int_t eventQuality = ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEventQuality();
853  if(eventQuality == 2 || eventQuality == 3){// Event Not Accepted due to MC event missing or wrong trigger for V0ReaderV1
854  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
855  hNEvents[iCut]->Fill(eventQuality);
856  }
857  return;
858  }
859 
860  fInputEvent = InputEvent();
861  if(fIsMC) fMCEvent = MCEvent();
862 
863  fReaderGammas = fV0Reader->GetReconstructedGammas(); // Gammas from default Cut
864 
865  // ------------------- BeginEvent ----------------------------
866 
867  AliEventplane *EventPlane = fInputEvent->GetEventplane();
868  if(fIsHeavyIon ==1)fEventPlaneAngle = EventPlane->GetEventplane("V0",fInputEvent,2);
869  else fEventPlaneAngle=0.0;
870 
872 
873  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
874 // cout << "event cut array = " << fEventCutArray->At(iCut) << endl;
875  PrepareFlowEvent(fInputEvent->GetNumberOfTracks(),fFlowEvent[iCut]); //Calculate event plane Qvector and EP resolution for inclusive
876 // Int_t iCut = 0;
877  fiCut = iCut;
878  Int_t eventNotAccepted =
879  ((AliConvEventCuts*)fEventCutArray->At(iCut))
880  ->IsEventAcceptedByCut(fV0Reader->GetEventCuts(),fInputEvent,fMCEvent,fIsHeavyIon,kFALSE);
881  if(eventNotAccepted){
882  // cout << "event rejected due to wrong trigger: " <<eventNotAccepted << endl;
883  hNEvents[iCut]->Fill(eventNotAccepted); // Check Centrality, PileUp, SDD and V0AND --> Not Accepted => eventQuality = 1
884  continue;
885  }
886 
887  if(eventQuality != 0){// Event Not Accepted
888  // cout << "event rejected due to: " <<eventQuality << endl;
889  hNEvents[iCut]->Fill(eventQuality);
890  continue;
891  }
892 
893  hNEvents[iCut]->Fill(eventQuality); // Should be 0 here
895  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->IsHeavyIon() == 2) hNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A());
896  else hNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A()+fInputEvent->GetVZEROData()->GetMTotV0C());
897 
898  ProcessPhotonCandidates(); // Process this cuts gammas
899  ProcessPhotonCandidatesforV2(); // Process this cuts gammas and do v2
900 
902  ProcessPhotonCandidatesforLTM(); // calculate the Local Track Multiplicity in a jet cone around the candidates
903  GetdPhidRtoCandidate(); // calculate the distances to other conversions in the event for each selected candidate
904  }
905 
906  hNGammaCandidates[iCut]->Fill(fGammaCandidates->GetEntries());
908  if (fIsHeavyIon == 1){
909  PostData(2+iCut, fFlowEvent[iCut]);
910  }
911  fGammaCandidates->Clear(); // delete this cuts good gammas
912  }
913 
915 
916  PostData(1, fOutputContainer);
917 
918 
919 }
920 //________________________________________________________________________
922 {
923  Int_t nV0 = 0;
924  TList *GammaCandidatesStepOne = new TList();
925  TList *GammaCandidatesStepTwo = new TList();
926  Int_t PhotonTemplateID;
927  // Loop over Photon Candidates allocated by ReaderV1
928  for(Int_t i = 0; i < fReaderGammas->GetEntriesFast(); i++){
929  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) fReaderGammas->At(i);
930  if(!PhotonCandidate) continue;
931  fIsFromMBHeader = kTRUE;
932 
933  hKappaTPC[fiCut]->Fill(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetKappaTPC(PhotonCandidate,fInputEvent),PhotonCandidate->Pt());
934  if (PhotonCandidate->GetInvMassPair() < fMinMass || PhotonCandidate->GetInvMassPair() > fMaxMass) continue;
935  if (((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetKappaTPC(PhotonCandidate,fInputEvent) < fMinKappa || ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetKappaTPC(PhotonCandidate,fInputEvent) > fMaxKappa) continue;
936  if(fApplydPhidRCut==1){ if(GetdPhidRtoCandidate(PhotonCandidate,i)==1) continue; }
937  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelected(PhotonCandidate,fInputEvent)) continue;
938  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(PhotonCandidate->GetPhotonPhi(),fEventPlaneAngle)) continue;
939  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut() &&
940  !((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){
941  fGammaCandidates->Add(PhotonCandidate); // if no second loop is required add to events good gammas
942 // cout << "IS IT MC? " << fIsMC << endl;
943  if(fIsMC){
944  PhotonTemplateID = GetTemplateID(PhotonCandidate);
945  if(PhotonTemplateID == 0) hKappaTPC_Temp0[fiCut]->Fill(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetKappaTPC(PhotonCandidate,fInputEvent),PhotonCandidate->Pt());
946  if(PhotonTemplateID == 1) hKappaTPC_Temp1[fiCut]->Fill(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetKappaTPC(PhotonCandidate,fInputEvent),PhotonCandidate->Pt());
947  if(PhotonTemplateID == 2) hKappaTPC_Temp2[fiCut]->Fill(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetKappaTPC(PhotonCandidate,fInputEvent),PhotonCandidate->Pt());
948  if(PhotonTemplateID == 3) hKappaTPC_Temp3[fiCut]->Fill(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetKappaTPC(PhotonCandidate,fInputEvent),PhotonCandidate->Pt());
949  if(PhotonTemplateID == 4) hKappaTPC_Temp4[fiCut]->Fill(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetKappaTPC(PhotonCandidate,fInputEvent),PhotonCandidate->Pt());
950  if(PhotonTemplateID == 5) hKappaTPC_Temp5[fiCut]->Fill(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetKappaTPC(PhotonCandidate,fInputEvent),PhotonCandidate->Pt());
951  if(PhotonTemplateID == 6) hKappaTPC_Temp6[fiCut]->Fill(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetKappaTPC(PhotonCandidate,fInputEvent),PhotonCandidate->Pt());
952  if(PhotonTemplateID == 7) hKappaTPC_Temp7[fiCut]->Fill(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetKappaTPC(PhotonCandidate,fInputEvent),PhotonCandidate->Pt());
953  if(PhotonTemplateID == 8) hKappaTPC_Temp8[fiCut]->Fill(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetKappaTPC(PhotonCandidate,fInputEvent),PhotonCandidate->Pt());
954  if(PhotonTemplateID != 0 && PhotonTemplateID != 1 && PhotonTemplateID != 2) hKappaTPC_Temp9[fiCut]->Fill(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetKappaTPC(PhotonCandidate,fInputEvent),PhotonCandidate->Pt());
955  if(PhotonTemplateID != 0 && PhotonTemplateID != 1 && PhotonTemplateID != 2 &&
956  PhotonTemplateID != 3 && PhotonTemplateID != 4 && PhotonTemplateID != 5 &&
957  PhotonTemplateID != 6 && PhotonTemplateID != 7 && PhotonTemplateID != 8) hKappaTPC_Temp10[fiCut]->Fill(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetKappaTPC(PhotonCandidate,fInputEvent),PhotonCandidate->Pt());
958 
959  TParticle *TRUEPhoton = PhotonCandidate->GetMCParticle(fMCEvent);
960  if(TRUEPhoton) hPt_TruePt[fiCut]->Fill(PhotonCandidate->Pt(),TRUEPhoton->Pt());
961  }
962 
963  if(fIsFromMBHeader){
964  hESDConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
965  hInvMassPair[fiCut]->Fill(PhotonCandidate->GetInvMassPair(),PhotonCandidate->Pt());
966  hKappaTPC_after[fiCut]->Fill(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetKappaTPC(PhotonCandidate,fInputEvent),PhotonCandidate->Pt());
967  if (fDoPhotonQA > 0){
968  hESDConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius());
969  hESDConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
970  }
971  }
972 
973 
974  if (fIsFromMBHeader && fDoPhotonQA == 2){
975  if (fIsHeavyIon == 1 && PhotonCandidate->Pt() > 0.399 && PhotonCandidate->Pt() < 12.){
976  fPtGamma = PhotonCandidate->Pt();
977  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
978  fRConvPhoton = PhotonCandidate->GetConversionRadius();
979  fEtaPhoton = PhotonCandidate->GetPhotonEta();
980  iCatPhoton = PhotonCandidate->GetPhotonQuality();
981  // tESDConvGammaPtDcazCat[fiCut]->Fill();
982  } else if ( PhotonCandidate->Pt() > 0.299 && PhotonCandidate->Pt() < 16.){
983  fPtGamma = PhotonCandidate->Pt();
984  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
985  fRConvPhoton = PhotonCandidate->GetConversionRadius();
986  fEtaPhoton = PhotonCandidate->GetPhotonEta();
987  iCatPhoton = PhotonCandidate->GetPhotonQuality();
988  // tESDConvGammaPtDcazCat[fiCut]->Fill();
989  }
990  }
991  } else if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut()){ // if Shared Electron cut is enabled, Fill array, add to step one
992  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->FillElectonLabelArray(PhotonCandidate,nV0);
993  nV0++;
994  GammaCandidatesStepOne->Add(PhotonCandidate);
995  } else if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut() &&
996  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){ // shared electron is disabled, step one not needed -> step two
997  GammaCandidatesStepTwo->Add(PhotonCandidate);
998  }
999  }
1000 
1001 
1002 
1003  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut()){
1004  for(Int_t i = 0;i<GammaCandidatesStepOne->GetEntries();i++){
1005  AliAODConversionPhoton *PhotonCandidate= (AliAODConversionPhoton*) GammaCandidatesStepOne->At(i);
1006  if(!PhotonCandidate) continue;
1007  fIsFromMBHeader = kTRUE;
1008 
1009  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->RejectSharedElectronV0s(PhotonCandidate,i,GammaCandidatesStepOne->GetEntries())) continue;
1010  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){ // To Colse v0s cut diabled, step two not needed
1011  fGammaCandidates->Add(PhotonCandidate);
1012  if(fIsFromMBHeader){
1013  hESDConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
1014  hInvMassPair[fiCut]->Fill(PhotonCandidate->GetInvMassPair(),PhotonCandidate->Pt());
1015  hKappaTPC_after[fiCut]->Fill(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetKappaTPC(PhotonCandidate,fInputEvent),PhotonCandidate->Pt());
1016  if (fDoPhotonQA > 0){
1017  hESDConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius());
1018  hESDConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
1019  }
1020  }
1021  }
1022 
1023 
1024  GammaCandidatesStepTwo->Add(PhotonCandidate); // Close v0s cut enabled -> add to list two
1025 
1026  if (fIsFromMBHeader && fDoPhotonQA == 2){
1027  if (fIsHeavyIon ==1 && PhotonCandidate->Pt() > 0.399 && PhotonCandidate->Pt() < 12.){
1028  fPtGamma = PhotonCandidate->Pt();
1029  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
1030  fRConvPhoton = PhotonCandidate->GetConversionRadius();
1031  fEtaPhoton = PhotonCandidate->GetPhotonEta();
1032  iCatPhoton = PhotonCandidate->GetPhotonQuality();
1033  // tESDConvGammaPtDcazCat[fiCut]->Fill();
1034  } else if ( PhotonCandidate->Pt() > 0.299 && PhotonCandidate->Pt() < 16.){
1035  fPtGamma = PhotonCandidate->Pt();
1036  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
1037  fRConvPhoton = PhotonCandidate->GetConversionRadius();
1038  fEtaPhoton = PhotonCandidate->GetPhotonEta();
1039  iCatPhoton = PhotonCandidate->GetPhotonQuality();
1040  // tESDConvGammaPtDcazCat[fiCut]->Fill();
1041  }
1042  }
1043  }
1044  }
1045  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){
1046  for(Int_t i = 0;i<GammaCandidatesStepTwo->GetEntries();i++){
1047  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) GammaCandidatesStepTwo->At(i);
1048  if(!PhotonCandidate) continue;
1049  fIsFromMBHeader = kTRUE;
1050 
1051  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->RejectToCloseV0s(PhotonCandidate,GammaCandidatesStepTwo,i)) continue;
1052  fGammaCandidates->Add(PhotonCandidate); // Add gamma to current cut TList
1053  if(fIsFromMBHeader){
1054  hESDConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
1055  hInvMassPair[fiCut]->Fill(PhotonCandidate->GetInvMassPair(),PhotonCandidate->Pt());
1056  hKappaTPC_after[fiCut]->Fill(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetKappaTPC(PhotonCandidate,fInputEvent),PhotonCandidate->Pt());
1057  if (fDoPhotonQA > 0){
1058  hESDConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius());
1059  hESDConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
1060  }
1061  }
1062 
1063  if (fIsFromMBHeader){
1064  if (fIsHeavyIon == 1 && PhotonCandidate->Pt() > 0.399 && PhotonCandidate->Pt() < 12.){
1065  fPtGamma = PhotonCandidate->Pt();
1066  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
1067  fRConvPhoton = PhotonCandidate->GetConversionRadius();
1068  fEtaPhoton = PhotonCandidate->GetPhotonEta();
1069  iCatPhoton = PhotonCandidate->GetPhotonQuality();
1070  // tESDConvGammaPtDcazCat[fiCut]->Fill();
1071  } else if ( PhotonCandidate->Pt() > 0.299 && PhotonCandidate->Pt() < 16.){
1072  fPtGamma = PhotonCandidate->Pt();
1073  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
1074  fRConvPhoton = PhotonCandidate->GetConversionRadius();
1075  fEtaPhoton = PhotonCandidate->GetPhotonEta();
1076  iCatPhoton = PhotonCandidate->GetPhotonQuality();
1077  // tESDConvGammaPtDcazCat[fiCut]->Fill();
1078  }
1079  }
1080  }
1081  }
1082 
1083  delete GammaCandidatesStepOne;
1084  GammaCandidatesStepOne = 0x0;
1085  delete GammaCandidatesStepTwo;
1086  GammaCandidatesStepTwo = 0x0;
1087 
1088 }
1089 //________________________________________________________________________
1091  //see header file for documentation
1092  if(fGammaCandidates->GetEntries() >0 ){
1093  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
1094  fBGHandler[fiCut]->AddEvent(fGammaCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fV0Reader->GetNumberOfPrimaryTracks(),fEventPlaneAngle);
1095  }
1096  else{ // means we use #V0s for multiplicity
1097  fBGHandler[fiCut]->AddEvent(fGammaCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fGammaCandidates->GetEntries(),fEventPlaneAngle);
1098  }
1099  }
1100 }
1101 //________________________________________________________________________
1103  TAxis *axisafter = histoRebin->GetXaxis();
1104  Int_t bins = axisafter->GetNbins();
1105  Double_t from = axisafter->GetXmin();
1106  Double_t to = axisafter->GetXmax();
1107  Double_t *newbins = new Double_t[bins+1];
1108  newbins[0] = from;
1109  Double_t factor = TMath::Power(to/from, 1./bins);
1110  for(Int_t i=1; i<=bins; ++i) newbins[i] = factor * newbins[i-1];
1111  axisafter->Set(bins, newbins);
1112  delete [] newbins;
1113 }
1114 
1115 //________________________________________________________________________
1117 {
1118 
1119  //fOutputContainer->Print(); // Will crash on GRID
1120 }
1121 
1122 //________________________________________________________________________
1124 {
1125 
1126  // Loop over Photon Candidates allocated by ReaderV1
1127 // cout << "number of gamma's: " << fGammaCandidates->GetEntries() << endl;
1128  for(Int_t i = 0; i < fGammaCandidates->GetEntries(); i++){
1129 
1130  AliAODConversionPhoton *gammaForv2=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(i));
1131  if (gammaForv2 == NULL) return;
1132  AliFlowTrack *sTrack = new AliFlowTrack();
1133  sTrack->SetForRPSelection(kFALSE);
1134  sTrack->SetForPOISelection(kTRUE);
1135 
1136  if(fFilterVariable==1){//using mass for POI selections
1137  sTrack->SetMass(gammaForv2->GetInvMassPair());
1138  }else if(fFilterVariable==2){//using Kappa for POI selections
1139  sTrack->SetMass(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetKappaTPC(gammaForv2,fInputEvent));
1140  }else if(fFilterVariable==3 && fIsMC){//MC ElectronElectron + mass
1141  if(!MCElectronElectron(gammaForv2)) return;
1142  sTrack->SetMass(gammaForv2->GetInvMassPair());
1143  }else if(fFilterVariable==4 && fIsMC){//MC ElectronElectron + kappa
1144  if(!MCElectronElectron(gammaForv2)) return;
1145  sTrack->SetMass(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetKappaTPC(gammaForv2,fInputEvent));
1146  }else if(fFilterVariable==5 && fIsMC){//MC Not ElectronElectron + mass
1147  if(MCElectronElectron(gammaForv2)) return;
1148  sTrack->SetMass(gammaForv2->GetInvMassPair());
1149  }else if(fFilterVariable==6 && fIsMC){//MC Not ElectronElectron + kappa
1150  if(MCElectronElectron(gammaForv2)) return;
1151  sTrack->SetMass(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetKappaTPC(gammaForv2,fInputEvent));
1152  }else{//no additional POI selection
1153  sTrack->SetMass(123456);
1154  }
1155  sTrack->SetPt(gammaForv2->Pt());
1156  sTrack->SetPhi(gammaForv2->GetPhotonPhi());
1157  sTrack->SetEta(gammaForv2->GetPhotonEta());
1158 
1159  /* for(int iRPs=0; iRPs!=fFlowEvent->NumberOfTracks(); ++iRPs)
1160  {
1161  // cout << " no of rps " << iRPs << endl;
1162  AliFlowTrack *iRP = dynamic_cast<AliFlowTrack*>(fFlowEvent->GetTrack( iRPs ));
1163  if (!iRP) continue;
1164  if (!iRP->InRPSelection()) continue;
1165  if( sTrack->GetID() == iRP->GetID())
1166  {
1167  if(fDebug) printf(" was in RP set");
1168  // cout << sTrack->GetID() <<" == " << iRP->GetID() << " was in RP set====REMOVED" <<endl;
1169  iRP->SetForRPSelection(kFALSE);
1170  // fFlowEvent->SetNumberOfRPs(fFlowEvent->GetNumberOfRPs() - 1);
1171  }
1172  } //end of for loop on RPs*/
1173  fFlowEvent[fiCut]->InsertTrack(((AliFlowTrack*) sTrack));
1174  fFlowEvent[fiCut]->SetNumberOfPOIs(fFlowEvent[fiCut]->GetNumberOfPOIs()+1);
1175 // cout << "cutnumber: " << fiCut << " nPoi " << fFlowEvent[fiCut]->GetNumberOfPOIs() << " ntracks " << fFlowEvent[fiCut]->NumberOfTracks() << endl;
1176  }
1177 }
1178 //________________________________________________________________________
1180 {
1181 
1182  Float_t gamma_Eta = 0;
1183  Float_t gamma_Phi = 0;
1184  Float_t gamma_Pt = 0;
1185 
1186  Float_t LTMpart_Eta = 0;
1187  Float_t LTMpart_Phi = 0;
1188  Float_t LTMpart_Pt = 0;
1189 
1190  Float_t dPhi = 0;
1191 
1192  Float_t nCloseByTracks = 0;
1193 
1194  if(fIsMC){
1195  // Loop over Photon Candidates allocated by MCstack
1196  for(Int_t i = 0; i < fMCEvent->GetNumberOfPrimaries(); i++){
1197  TParticle* gammaForLTM = (TParticle *)fMCEvent->Particle(i);
1198  if(!gammaForLTM) return;
1199  if(!MCConversionPhotonCheck(gammaForLTM)) continue;
1200  gamma_Eta = gammaForLTM->Eta(); gamma_Phi = gammaForLTM->Phi(); gamma_Pt = gammaForLTM->Pt();
1201  if( gamma_Eta > 0.9 || gamma_Eta < -0.9 ) continue;
1202  if(gamma_Eta==0 || gamma_Phi==0 || gamma_Pt==0)continue;
1203  nCloseByTracks = 0;
1204  for(Int_t j = 0; j < fInputEvent->GetNumberOfTracks(); j++){
1205  AliVParticle *LTMpart = fInputEvent->GetTrack(j);
1206  if (LTMpart == NULL) return;
1207  LTMpart_Eta = LTMpart->Eta(); LTMpart_Phi = LTMpart->Phi(); LTMpart_Pt = LTMpart->Pt();
1208  if(LTMpart_Eta==0 || LTMpart_Phi==0 || LTMpart_Pt==0)continue;
1209  dPhi = TMath::Abs(LTMpart_Phi-gamma_Phi);
1210  if(dPhi > TMath::Pi()) dPhi = TMath::Abs(dPhi-2.0*TMath::Pi());
1211  if(TMath::Sqrt(pow((LTMpart_Eta-gamma_Eta),2)+pow(dPhi,2))<0.2) nCloseByTracks+=1;
1212  }
1213 // cout << "nCloseByTracks MCgen= " << nCloseByTracks << " with pt= " << gamma_Pt << endl;
1214  hLTMPt_MC[fiCut]->Fill(nCloseByTracks,gamma_Pt);
1215  }
1216  }
1217  // Loop over Photon Candidates allocated by ReaderV1
1218  for(Int_t i = 0; i < fGammaCandidates->GetEntries(); i++){
1219  AliAODConversionPhoton *gammaForLTM=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(i));
1220  if(!gammaForLTM) return;
1221  gamma_Eta = gammaForLTM->GetPhotonEta(); gamma_Phi = gammaForLTM->GetPhotonPhi(); gamma_Pt = gammaForLTM->GetPhotonPt();
1222  if(gamma_Eta==0 || gamma_Phi==0 || gamma_Pt==0)continue;
1223  nCloseByTracks = 0;
1224  for(Int_t j = 0; j < fInputEvent->GetNumberOfTracks(); j++){
1225  AliVParticle *LTMpart = fInputEvent->GetTrack(j);
1226  if (LTMpart == NULL) return;
1227  LTMpart_Eta = LTMpart->Eta(); LTMpart_Phi = LTMpart->Phi(); LTMpart_Pt = LTMpart->Pt();
1228  if(LTMpart_Eta==0 || LTMpart_Phi==0 || LTMpart_Pt==0)continue;
1229  dPhi = TMath::Abs(LTMpart_Phi-gamma_Phi);
1230  if(dPhi > TMath::Pi()) dPhi = TMath::Abs(dPhi-2.0*TMath::Pi());
1231  if(TMath::Sqrt(pow((LTMpart_Eta-gamma_Eta),2)+pow(dPhi,2))<0.2) nCloseByTracks+=1;
1232  }
1233 // cout << "nCloseByTracks= " << nCloseByTracks << " with pt= " << gamma_Pt << endl;
1234  hLTMPt[fiCut]->Fill(nCloseByTracks,gamma_Pt);
1235  }
1236 }
1237 
1238 //_____________________________________________________________________________
1239 template <typename T> void AliAnalysisTaskGammaConvFlow::SetNullCuts(T* event)
1240 {
1241  // Set null cuts
1242  if (fDebug) cout << " fCutsRP " << fCutsRP << endl;
1243  fCutsRP->SetEvent(event, MCEvent());
1245  fNullCuts->SetPtRange(+1, -1); // select nothing QUICK
1246  fNullCuts->SetEtaRange(+1, -1); // select nothing VZERO
1247  fNullCuts->SetEvent(event, MCEvent());
1248 }
1249 
1250 //_____________________________________________________________________________
1252 {
1253  //Prepare flow events
1254  FlowEv->ClearFast();
1255  FlowEv->Fill(fCutsRP, fNullCuts);
1256  FlowEv->SetReferenceMultiplicity(iMulti);
1257  FlowEv->DefineDeadZone(0, 0, 0, 0);
1258  // FlowEv->TagSubeventsInEta(-0.7, 0, 0, 0.7);
1259 }
1260 //_____________________________________________________________________________
1262 
1263 
1264  TParticle *posDaughter = MCPhoton->GetPositiveMCDaughter(fMCEvent);
1265  TParticle *negDaughter = MCPhoton->GetNegativeMCDaughter(fMCEvent);
1266  if(posDaughter==NULL || negDaughter==NULL) return kFALSE;
1267  Int_t pdgCodePos = 0;
1268  Int_t pdgCodeNeg = 0;
1269  Bool_t IsItGammaSignal = kFALSE;
1270 
1271  if( (posDaughter->GetMother(0) == negDaughter->GetMother(0)) ) {
1272  pdgCodePos=TMath::Abs(posDaughter->GetPdgCode());
1273  pdgCodeNeg=TMath::Abs(negDaughter->GetPdgCode());
1274  if(pdgCodePos==11 && pdgCodeNeg==11) IsItGammaSignal = kTRUE;
1275  }else{
1276  IsItGammaSignal = kFALSE;
1277  }
1278 
1279  return IsItGammaSignal;
1280 
1281 }
1282 //_____________________________________________________________________________
1284 
1285 
1286  TParticle *posDaughter = MCPhoton->GetPositiveMCDaughter(fMCEvent);
1287  TParticle *negDaughter = MCPhoton->GetNegativeMCDaughter(fMCEvent);
1288  if(posDaughter==NULL || negDaughter==NULL) return kFALSE;
1289  Int_t pdgCodePos = 0;
1290  Int_t pdgCodeNeg = 0;
1291  Bool_t IsItElectronElectron = kFALSE;
1292 
1293  if( (posDaughter->GetMother(0) != negDaughter->GetMother(0)) || (posDaughter->GetMother(0) == negDaughter->GetMother(0) && posDaughter->GetMother(0) ==-1) ) {
1294  pdgCodePos=TMath::Abs(posDaughter->GetPdgCode());
1295  pdgCodeNeg=TMath::Abs(negDaughter->GetPdgCode());
1296  if(pdgCodePos==11 && pdgCodeNeg==11) IsItElectronElectron = kTRUE;
1297  }else{
1298  IsItElectronElectron = kFALSE;
1299  }
1300 
1301  return IsItElectronElectron;
1302 
1303 }
1304 //_____________________________________________________________________________
1306 
1307  if(MCPhoton->GetPdgCode()!=22) return kFALSE;
1308  if(MCPhoton->GetNDaughters() != 2) return kFALSE;
1309  TParticle *posDaughter = (TParticle*)fMCEvent->Particle(MCPhoton->GetFirstDaughter());
1310  TParticle *negDaughter = (TParticle*)fMCEvent->Particle(MCPhoton->GetLastDaughter());
1311  if(posDaughter==NULL || negDaughter==NULL) return kFALSE;
1312  if(posDaughter->GetUniqueID() != 5 || negDaughter->GetUniqueID() != 5) return kFALSE;
1313  Int_t pdgCodePos = 0;
1314  Int_t pdgCodeNeg = 0;
1315  Bool_t IsItPhoton = kFALSE;
1316 
1317  if(posDaughter->GetMother(0) == negDaughter->GetMother(0)) {
1318  pdgCodePos=TMath::Abs(posDaughter->GetPdgCode());
1319  pdgCodeNeg=TMath::Abs(negDaughter->GetPdgCode());
1320  if(pdgCodePos==11 && pdgCodeNeg==11) IsItPhoton = kTRUE;
1321  }else{
1322  IsItPhoton = kFALSE;
1323  }
1324 
1325  return IsItPhoton;
1326 
1327 }
1328 //_____________________________________________________________________________
1330 
1331 
1332  TParticle *posDaughter = MCPhoton->GetPositiveMCDaughter(fMCEvent);
1333  TParticle *negDaughter = MCPhoton->GetNegativeMCDaughter(fMCEvent);
1334  if(posDaughter==NULL || negDaughter==NULL) return kFALSE;
1335 
1336  Int_t pdgCodePos = 0;
1337  Int_t pdgCodeNeg = 0;
1338  Int_t TemplateID = -1;
1339 
1340  pdgCodePos=TMath::Abs(posDaughter->GetPdgCode());
1341  pdgCodeNeg=TMath::Abs(negDaughter->GetPdgCode());
1342 
1343  if(pdgCodePos==11 && pdgCodeNeg==11) TemplateID = 0; //signal -> e+ e-
1344  if(pdgCodePos==211 && pdgCodeNeg==211) TemplateID = 1; //pi pi 211 211
1345  if((pdgCodePos==211 && pdgCodeNeg==11) || (pdgCodePos==11 && pdgCodeNeg==211)) TemplateID = 2; //pi e 211 11
1346  if((pdgCodePos==211 && pdgCodeNeg==321) || (pdgCodePos==321 && pdgCodeNeg==211)) TemplateID = 3; //pi K 211 321
1347  if((pdgCodePos==211 && pdgCodeNeg==2212) || (pdgCodePos==2212 && pdgCodeNeg==211))TemplateID = 4; //pi p 211 2212
1348  if((pdgCodePos==11 && pdgCodeNeg==321) || (pdgCodePos==321 && pdgCodeNeg==11)) TemplateID = 5; //e K 11 321
1349  if((pdgCodePos==11 && pdgCodeNeg==2212) || (pdgCodePos==2212 && pdgCodeNeg==11)) TemplateID = 6; //e p 11 2212
1350  if(pdgCodePos==321 && pdgCodeNeg==321) TemplateID = 7; //K K 321 321
1351  if(pdgCodePos!=11 && pdgCodeNeg!=11 && TemplateID == -1) TemplateID = 8; //hadronic not 11 11
1352 
1353 // cout << "TEMPLATE ID IS: " << TemplateID << endl;
1354  return TemplateID;
1355 
1356 }
1357 //_____________________________________________________________________________
1359 
1360  Float_t gamma1_Eta = 0; Float_t gamma1_Phi = 0; Float_t gamma1_Pt = 0;
1361  Float_t gamma2_Eta = 0; Float_t gamma2_Phi = 0; Float_t gamma2_Pt = 0;
1362 
1363  Float_t dPhi = 0; Float_t dRconvVtx = 0;
1364 
1365  Float_t gamma1_Vtx_x = 0; Float_t gamma1_Vtx_y = 0; Float_t gamma1_Vtx_z = 0;
1366  Float_t gamma2_Vtx_x = 0; Float_t gamma2_Vtx_y = 0; Float_t gamma2_Vtx_z = 0;
1367 
1368  for(Int_t i = 0; i < fGammaCandidates->GetEntries(); i++){
1369  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(i));
1370  if(!gamma1) return;
1371  gamma1_Eta = gamma1->GetPhotonEta(); gamma1_Phi = gamma1->GetPhotonPhi(); gamma1_Pt = gamma1->GetPhotonPt();
1372  if(gamma1_Eta==0 || gamma1_Phi==0 || gamma1_Pt==0)continue;
1373  gamma1_Vtx_x = gamma1->GetConversionX(); gamma1_Vtx_y = gamma1->GetConversionY(); gamma1_Vtx_z = gamma1->GetConversionZ();
1374  for(Int_t j = i+1; j < fGammaCandidates->GetEntries(); j++){
1375  AliAODConversionPhoton *gamma2=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(j));
1376  if(!gamma2) continue;
1377  gamma2_Eta = gamma2->GetPhotonEta(); gamma2_Phi = gamma2->GetPhotonPhi(); gamma2_Pt = gamma2->GetPhotonPt();
1378  if(gamma2_Eta==0 || gamma2_Phi==0 || gamma2_Pt==0)continue;
1379  gamma2_Vtx_x = gamma2->GetConversionX(); gamma2_Vtx_y = gamma2->GetConversionY(); gamma2_Vtx_z = gamma2->GetConversionZ();
1380  dPhi = TMath::Abs(gamma2_Phi-gamma1_Phi);
1381  if(dPhi > TMath::Pi()) dPhi = TMath::Abs(dPhi-2.0*TMath::Pi());
1382  dRconvVtx = TMath::Sqrt(pow(gamma2_Vtx_x-gamma1_Vtx_x,2)+pow(gamma2_Vtx_y-gamma1_Vtx_y,2)+pow(gamma2_Vtx_z-gamma1_Vtx_z,2));
1383  hdPhidRcandidates[fiCut]->Fill(dPhi,dRconvVtx);
1384  if(fIsMC){
1385  // gamma1 = signal, gamma2 = signal => sigsig
1386  if( MCGammaSignal(gamma1) && MCGammaSignal(gamma2) ) hdPhidRcandidates_MCsigsig[fiCut]->Fill(dPhi,dRconvVtx);
1387  // gamma1 = bkg, gamma2 = signal => bkgsig
1388  if( (MCElectronElectron(gamma1) && MCGammaSignal(gamma2)) || (MCElectronElectron(gamma2) && MCGammaSignal(gamma1)) ) hdPhidRcandidates_MCbkgsig[fiCut]->Fill(dPhi,dRconvVtx);
1389  // gamma1 = bkg, gamma2 = bkg => bkgbkg
1390  if( MCElectronElectron(gamma1) && MCElectronElectron(gamma2) ) hdPhidRcandidates_MCbkgbkg[fiCut]->Fill(dPhi,dRconvVtx);
1391  }
1392  }
1393  }
1394 }
1395 //_____________________________________________________________________________
1397 
1398  Float_t gamma1_Eta = 0; Float_t gamma1_Phi = 0; Float_t gamma1_Pt = 0;
1399  Float_t gamma2_Eta = 0; Float_t gamma2_Phi = 0; Float_t gamma2_Pt = 0;
1400 
1401  Float_t dPhi = 0; Float_t dRconvVtx = 0;
1402 
1403  Float_t gamma1_Vtx_x = 0; Float_t gamma1_Vtx_y = 0; Float_t gamma1_Vtx_z = 0;
1404  Float_t gamma2_Vtx_x = 0; Float_t gamma2_Vtx_y = 0; Float_t gamma2_Vtx_z = 0;
1405 
1406  if(!gamma) return -1;
1407  gamma1_Eta = gamma->GetPhotonEta(); gamma1_Phi = gamma->GetPhotonPhi(); gamma1_Pt = gamma->GetPhotonPt();
1408  if(gamma1_Eta==0 || gamma1_Phi==0 || gamma1_Pt==0) return -1;
1409  gamma1_Vtx_x = gamma->GetConversionX(); gamma1_Vtx_y = gamma->GetConversionY(); gamma1_Vtx_z = gamma->GetConversionZ();
1410  for(Int_t i = 0; i < fReaderGammas->GetEntries(); i++){
1411  if(i==PhotonID) continue;
1412  AliAODConversionPhoton *gamma2=dynamic_cast<AliAODConversionPhoton*>(fReaderGammas->At(i));
1413  if(!gamma2) continue;
1414  gamma2_Eta = gamma2->GetPhotonEta(); gamma2_Phi = gamma2->GetPhotonPhi(); gamma2_Pt = gamma2->GetPhotonPt();
1415  if(gamma2_Eta==0 || gamma2_Phi==0 || gamma2_Pt==0)continue;
1416  gamma2_Vtx_x = gamma2->GetConversionX(); gamma2_Vtx_y = gamma2->GetConversionY(); gamma2_Vtx_z = gamma2->GetConversionZ();
1417  dPhi = TMath::Abs(gamma2_Phi-gamma1_Phi);
1418  if(dPhi > TMath::Pi()) dPhi = TMath::Abs(dPhi-2.0*TMath::Pi());
1419  dRconvVtx = TMath::Sqrt(pow(gamma2_Vtx_x-gamma1_Vtx_x,2)+pow(gamma2_Vtx_y-gamma1_Vtx_y,2)+pow(gamma2_Vtx_z-gamma1_Vtx_z,2));
1420  if(dPhi < 0.04 && dRconvVtx < 7.5) return 1;
1421  }
1422  return 0;
1423 }
TParticle * GetMCParticle(AliMCEvent *mcEvent)
virtual Double_t GetPhotonPhi() const
const Color_t cc[]
Definition: DrawKs.C:1
double Double_t
Definition: External.C:58
void SetEta(Double_t eta)
Definition: External.C:236
Bool_t MCElectronElectron(AliAODConversionPhoton *MCPhoton)
flow events Inclusive e
AliGammaConversionAODBGHandler ** fBGHandler
Bool_t MCConversionPhotonCheck(TParticle *MCPhoton)
Int_t GetNumberOfPrimaryTracks()
Float_t GetDCAzToPrimVtx() const
TString GetPeriodName()
void SetMass(Double_t mass)
TParticle * GetPositiveMCDaughter(AliMCEvent *mcEvent)
void SetParamType(trackParameterType paramType)
void SetReferenceMultiplicity(Int_t m)
UShort_t T(UShort_t m, UShort_t t)
Definition: RingBits.C:60
ClassImp(AliAnalysisTaskGammaConvFlow) AliAnalysisTaskGammaConvFlow
void SetForRPSelection(Bool_t b=kTRUE)
TParticle * GetNegativeMCDaughter(AliMCEvent *mcEvent)
void SetPtRange(Float_t r1, Float_t r2)
void Fill(AliFlowTrackCuts *rpCuts, AliFlowTrackCuts *poiCuts)
AliConversionAODBGHandlerRP ** fBGHandlerRP
int Int_t
Definition: External.C:63
Definition: External.C:204
float Float_t
Definition: External.C:68
void AddEvent(TList *const eventGammas, Double_t xvalue, Double_t yvalue, Double_t zvalue, Int_t multiplicity, Double_t epvalue=-100)
void SetNumberOfPOIs(Int_t nubmerOfPOIs, Int_t poiType=1)
AliConversionPhotonCuts * GetConversionCuts()
Definition: AliV0ReaderV1.h:79
virtual void Terminate(const Option_t *)
Definition: External.C:212
static AliFlowCommonConstants * GetMaster()
Class handling all kinds of selection cuts for Gamma Conversion analysis.
virtual Double_t GetPhotonEta() const
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
void SetPhi(Double_t phi)
void DefineDeadZone(Double_t etaMin, Double_t etaMax, Double_t phiMin, Double_t phiMax)
void SetPt(Double_t pt)
void SetEvent(AliVEvent *event, AliMCEvent *mcEvent=NULL)
Bool_t MCGammaSignal(AliAODConversionPhoton *MCPhoton)
Definition: External.C:220
Class handling all kinds of selection cuts for Gamma Conversion analysis.
void PrepareFlowEvent(Int_t iMulti, AliFlowEvent *FlowEv) const
TClonesArray * GetReconstructedGammas() const
Definition: AliV0ReaderV1.h:75
void SetForPOISelection(Bool_t b=kTRUE)
virtual Double_t GetPhotonPt() const
AliFlowTrackCuts * fCutsRP
enable debug mode
Class handling all kinds of selection cuts for Gamma Conversion analysis.
AliConvEventCuts * GetEventCuts()
Definition: AliV0ReaderV1.h:80
const char Option_t
Definition: External.C:48
bool Bool_t
Definition: External.C:53
void InsertTrack(AliFlowTrack *)
virtual void ClearFast()
Int_t GetTemplateID(AliAODConversionPhoton *MCPhoton)
Double_t GetConversionRadius() const
void SetEtaRange(Float_t r1, Float_t r2)