TENDER becomes Tender, removing .so
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / AliAnalysisTaskEtaToPiPlPiMiGamma.cxx
CommitLineData
209b710e 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
e13e00c9 4 * Author: Friederike Bock *
5 * Version 1 *
209b710e 6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
e13e00c9 16// Analysis task for eta->pi+ +pi- gamma (pion Dalitz decay)
209b710e 17
18#include <vector>
19
20#include "TParticle.h"
21#include "TPDGCode.h"
22#include "TMCProcess.h"
23#include "TDatabasePDG.h"
24#include "TList.h"
25#include "TChain.h"
26#include "TDirectory.h"
27#include "TTree.h"
28#include "TH1.h"
29#include "TH1F.h"
30#include "THnSparse.h"
31#include "TH2F.h"
32#include "AliStack.h"
33#include "AliAnalysisManager.h"
34#include "AliESDInputHandler.h"
35#include "AliESDtrack.h"
36#include "AliMCEvent.h"
37#include "AliStack.h"
38#include "AliMCEventHandler.h"
39#include "AliPID.h"
40#include "AliLog.h"
41#include "AliESDtrackCuts.h"
42#include "AliESDpidCuts.h"
43#include "AliMCEvent.h"
44#include "AliESDv0.h"
45#include "AliESDEvent.h"
46#include "AliESDpid.h"
47#include "AliKFParticle.h"
48#include "AliMCEventHandler.h"
49#include "AliKFVertex.h"
50#include "AliTriggerAnalysis.h"
51#include "AliCentrality.h"
52#include "AliMultiplicity.h"
53#include "AliAnalysisTaskEtaToPiPlPiMiGamma.h"
54
55
56ClassImp( AliAnalysisTaskEtaToPiPlPiMiGamma )
57
58//-----------------------------------------------------------------------------------------------
59AliAnalysisTaskEtaToPiPlPiMiGamma::AliAnalysisTaskEtaToPiPlPiMiGamma():
60 fV0Reader(NULL),
61 fPionSelector(NULL),
62 fBGHandler(NULL),
63 fESDEvent(NULL),
64 fMCEvent(NULL),
65 fMCStack(NULL),
66 fCutFolder(NULL),
67 fESDList(NULL),
68 fBackList(NULL),
69 fMotherList(NULL),
70 fTrueList(NULL),
71 fMCList(NULL),
72 fOutputContainer(0),
73 fReaderGammas(NULL),
74 fSelectorNegPionIndex(0),
75 fSelectorPosPionIndex(0),
76 fGoodGammas(NULL),
77 fGoodVirtualParticles(NULL),
344100c4 78 fEventCutArray(NULL),
209b710e 79 fGammaCutArray(NULL),
80 fPionCutArray(NULL),
81 fMesonCutArray(NULL),
344100c4 82 fEventCuts(NULL),
209b710e 83 fConversionCuts(NULL),
84 fHistoConvGammaPt(NULL),
85 fHistoConvGammaEta(NULL),
86 fHistoNegPionPt(NULL),
87 fHistoPosPionPt(NULL),
88 fHistoNegPionPhi(NULL),
89 fHistoPosPionPhi(NULL),
90 fHistoNegPionEta(NULL),
91 fHistoPosPionEta(NULL),
92 fHistoNegPionClsTPC(NULL),
93 fHistoPosPionClsTPC(NULL),
94 fHistoPionDCAxy(NULL),
95 fHistoPionDCAz(NULL),
96 fHistoPionTPCdEdxNSigma(NULL),
97 fHistoPionTPCdEdx(NULL),
899d014b 98 fHistoPionPionInvMassPt(NULL),
209b710e 99 fHistoMotherInvMassPt(NULL),
100 fTHnSparseMotherInvMassPtZM(NULL),
101 fHistoMotherBackInvMassPt(NULL),
102 fTHnSparseMotherBackInvMassPtZM(NULL),
103 fHistoMCAllGammaPt(NULL),
104 fHistoMCConvGammaPt(NULL),
105 fHistoMCAllPosPionsPt(NULL),
106 fHistoMCAllNegPionsPt(NULL),
107 fHistoMCGammaFromEtaPt(NULL),
108 fHistoMCPosPionsFromEtaPt(NULL),
109 fHistoMCNegPionsFromEtaPt(NULL),
110 fHistoMCEtaPiPlPiMiGammaPt(NULL),
111 fHistoMCEtaGGPt(NULL),
112 fHistoMCEtaDalitzPt(NULL),
113 fHistoMCEtaPiPlPiMiGammaInAccPt(NULL),
114 fHistoTrueMotherPiPlPiMiGammaInvMassPt(NULL),
115 fHistoTrueMotherGammaGammaInvMassPt(NULL),
116 fHistoTrueMotherDalitzInvMassPt(NULL),
117 fHistoTrueConvGammaPt(NULL),
118 fHistoTrueConvGammaFromEtaPt(NULL),
119 fHistoTruePosPionPt(NULL),
120 fHistoTruePosPionFromEtaPt(NULL),
121 fHistoTrueNegPionPt(NULL),
122 fHistoTrueNegPionFromEtaPt(NULL),
899d014b 123 fHistoTruePionPionInvMassPt(NULL),
124 fHistoTruePionPionFromEtaInvMassPt(NULL),
209b710e 125 fHistoNEvents(NULL),
126 fHistoNGoodESDTracks(NULL),
127 fProfileEtaShift(NULL),
128 fRandom(0),
129 fnCuts(0),
130 fiCut(0),
131 fNumberOfESDTracks(0),
132 fMoveParticleAccordingToVertex(kFALSE),
133 fIsHeavyIon(kFALSE),
134 fDoMesonAnalysis(kTRUE),
135 fDoMesonQA(kFALSE),
136 fIsFromMBHeader(kTRUE),
d9d6352b 137 fIsMC(kFALSE),
138 fIsGammaEtaCand(kFALSE)
209b710e 139{
140
141}
142
143//-----------------------------------------------------------------------------------------------
144AliAnalysisTaskEtaToPiPlPiMiGamma::AliAnalysisTaskEtaToPiPlPiMiGamma( const char* name ):
145 AliAnalysisTaskSE(name),
146 fV0Reader(NULL),
147 fPionSelector(NULL),
148 fBGHandler(NULL),
149 fESDEvent(NULL),
150 fMCEvent(NULL),
151 fMCStack(NULL),
152 fCutFolder(NULL),
153 fESDList(NULL),
154 fBackList(NULL),
155 fMotherList(NULL),
156 fTrueList(NULL),
157 fMCList(NULL),
158 fOutputContainer(0),
159 fReaderGammas(NULL),
160 fSelectorNegPionIndex(0),
161 fSelectorPosPionIndex(0),
162 fGoodGammas(NULL),
163 fGoodVirtualParticles(NULL),
344100c4 164 fEventCutArray(NULL),
209b710e 165 fGammaCutArray(NULL),
166 fPionCutArray(NULL),
167 fMesonCutArray(NULL),
344100c4 168 fEventCuts(NULL),
209b710e 169 fConversionCuts(NULL),
170 fHistoConvGammaPt(NULL),
171 fHistoConvGammaEta(NULL),
172 fHistoNegPionPt(NULL),
173 fHistoPosPionPt(NULL),
174 fHistoNegPionPhi(NULL),
175 fHistoPosPionPhi(NULL),
176 fHistoNegPionEta(NULL),
177 fHistoPosPionEta(NULL),
178 fHistoNegPionClsTPC(NULL),
179 fHistoPosPionClsTPC(NULL),
180 fHistoPionDCAxy(NULL),
181 fHistoPionDCAz(NULL),
182 fHistoPionTPCdEdxNSigma(NULL),
183 fHistoPionTPCdEdx(NULL),
899d014b 184 fHistoPionPionInvMassPt(NULL),
209b710e 185 fHistoMotherInvMassPt(NULL),
186 fTHnSparseMotherInvMassPtZM(NULL),
187 fHistoMotherBackInvMassPt(NULL),
188 fTHnSparseMotherBackInvMassPtZM(NULL),
189 fHistoMCAllGammaPt(NULL),
190 fHistoMCConvGammaPt(NULL),
191 fHistoMCAllPosPionsPt(NULL),
192 fHistoMCAllNegPionsPt(NULL),
193 fHistoMCGammaFromEtaPt(NULL),
194 fHistoMCPosPionsFromEtaPt(NULL),
195 fHistoMCNegPionsFromEtaPt(NULL),
196 fHistoMCEtaPiPlPiMiGammaPt(NULL),
197 fHistoMCEtaGGPt(NULL),
198 fHistoMCEtaDalitzPt(NULL),
199 fHistoMCEtaPiPlPiMiGammaInAccPt(NULL),
200 fHistoTrueMotherPiPlPiMiGammaInvMassPt(NULL),
201 fHistoTrueMotherGammaGammaInvMassPt(NULL),
202 fHistoTrueMotherDalitzInvMassPt(NULL),
203 fHistoTrueConvGammaPt(NULL),
204 fHistoTrueConvGammaFromEtaPt(NULL),
205 fHistoTruePosPionPt(NULL),
206 fHistoTruePosPionFromEtaPt(NULL),
207 fHistoTrueNegPionPt(NULL),
208 fHistoTrueNegPionFromEtaPt(NULL),
899d014b 209 fHistoTruePionPionInvMassPt(NULL),
210 fHistoTruePionPionFromEtaInvMassPt(NULL),
209b710e 211 fHistoNEvents(NULL),
212 fHistoNGoodESDTracks(NULL),
213 fProfileEtaShift(NULL),
214 fRandom(0),
215 fnCuts(0),
216 fiCut(0),
217 fNumberOfESDTracks(0),
218 fMoveParticleAccordingToVertex(kFALSE),
219 fIsHeavyIon(kFALSE),
220 fDoMesonAnalysis(kTRUE),
221 fDoMesonQA(kFALSE),
222 fIsFromMBHeader(kTRUE),
d9d6352b 223 fIsMC(kFALSE),
224 fIsGammaEtaCand(kFALSE)
209b710e 225{
226 DefineOutput(1, TList::Class());
227}
228
229//-----------------------------------------------------------------------------------------------
230AliAnalysisTaskEtaToPiPlPiMiGamma::~AliAnalysisTaskEtaToPiPlPiMiGamma()
231{
232 //
233 // virtual destructor
234 //
235 cout<<"Destructor"<<endl;
236 if(fGoodGammas){
237 delete fGoodGammas;
238 fGoodGammas = 0x0;
239 }
240 if(fGoodVirtualParticles){
241 delete fGoodVirtualParticles;
242 fGoodGammas = 0x0;
243 }
244 if(fBGHandler){
245 delete[] fBGHandler;
246 fBGHandler = 0x0;
247 }
248}
249//___________________________________________________________
250void AliAnalysisTaskEtaToPiPlPiMiGamma::InitBack(){
251
252 const Int_t nDim = 4;
899d014b 253 Int_t nBins[nDim] = {450,250,7,4};
254 Double_t xMin[nDim] = {0.3,0, 0,0};
255 Double_t xMax[nDim] = {0.75,25,7,4};
209b710e 256
257 fTHnSparseMotherInvMassPtZM = new THnSparseF*[fnCuts];
258 fTHnSparseMotherBackInvMassPtZM = new THnSparseF*[fnCuts];
259
260 fBGHandler = new AliGammaConversionAODBGHandler*[fnCuts];
261 for(Int_t iCut = 0; iCut<fnCuts;iCut++){
262
344100c4 263 TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
264 TString cutstringPion = ((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->GetCutNumber();
265 TString cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
266 TString cutstringGamma = ((AliConversionPhotonCuts*)fGammaCutArray->At(iCut))->GetCutNumber();
209b710e 267
344100c4 268 Int_t collisionSystem = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(0,1));
269 Int_t centMin = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(1,1));
270 Int_t centMax = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(2,1));
209b710e 271
272 if(collisionSystem == 1 || collisionSystem == 2 ||
273 collisionSystem == 5 || collisionSystem == 8 ||
274 collisionSystem == 9){
275 centMin = centMin*10;
276 centMax = centMax*10;
277 }
278 else if(collisionSystem == 3 || collisionSystem == 6){
279 centMin = centMin*5;
280 centMax = centMax*5;
281 }
282 else if(collisionSystem == 4 || collisionSystem == 7){
283 centMin = ((centMin*5)+45);
284 centMax = ((centMax*5)+45);
285 }
286
287
288 fBackList[iCut] = new TList();
344100c4 289 fBackList[iCut]->SetName(Form("%s_%s_%s_%s Back histograms",cutstringEvent.Data(),cutstringGamma.Data(),cutstringPion.Data(),cutstringMeson.Data()));
209b710e 290 fBackList[iCut]->SetOwner(kTRUE);
291 fCutFolder[iCut]->Add(fBackList[iCut]);
292
293 fTHnSparseMotherBackInvMassPtZM[iCut] = new THnSparseF("Back_Back_InvMass_Pt_z_m","Back_Back_InvMass_Pt_z_m",nDim,nBins,xMin,xMax);
294 fBackList[iCut]->Add(fTHnSparseMotherBackInvMassPtZM[iCut]);
295
296 fMotherList[iCut] = new TList();
344100c4 297 fMotherList[iCut]->SetName(Form("%s_%s_%s_%s Mother histograms",cutstringEvent.Data(),cutstringGamma.Data(),cutstringPion.Data(),cutstringMeson.Data()));
209b710e 298 fMotherList[iCut]->SetOwner(kTRUE);
299 fCutFolder[iCut]->Add(fMotherList[iCut]);
300
301 fTHnSparseMotherInvMassPtZM[iCut] = new THnSparseF("Back_Mother_InvMass_Pt_z_m","Back_Mother_InvMass_Pt_z_m",nDim,nBins,xMin,xMax);
302 fMotherList[iCut]->Add(fTHnSparseMotherInvMassPtZM[iCut]);
303
304
305 fBGHandler[iCut] = new AliGammaConversionAODBGHandler( collisionSystem,centMin,centMax,
306 ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetNumberOfBGEvents(),
cfd87ccd 307 ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity(),
308 0,8,5);
209b710e 309
310 }
311}
312
313//______________________________________________________________________
314void AliAnalysisTaskEtaToPiPlPiMiGamma::UserCreateOutputObjects()
315{
316 //
317 // Create ouput objects
318 //
319
320 // Create the output container
321 if(fOutputContainer != NULL){
322 delete fOutputContainer;
323 fOutputContainer = NULL;
324 }
325 if(fOutputContainer == NULL){
326 fOutputContainer = new TList();
327 fOutputContainer->SetOwner(kTRUE);
328 }
329
330 fGoodGammas = new TList();
331 //fGoodGammas->SetOwner(kTRUE);
332
333 fGoodVirtualParticles = new TList();
334 //fGoodVirtualParticles->SetOwner(kTRUE);
335
336 fCutFolder = new TList*[fnCuts];
337 fESDList = new TList*[fnCuts];
338 fBackList = new TList*[fnCuts];
339 fMotherList = new TList*[fnCuts];
340 fHistoNEvents = new TH1I*[fnCuts];
341 fHistoNGoodESDTracks = new TH1I*[fnCuts];
342 fProfileEtaShift = new TProfile*[fnCuts];
343 fHistoConvGammaPt = new TH1F*[fnCuts];
344 fHistoConvGammaEta = new TH1F*[fnCuts];
345 fHistoNegPionPt = new TH1F*[fnCuts];
346 fHistoPosPionPt = new TH1F*[fnCuts];
347 fHistoNegPionPhi = new TH1F*[fnCuts];
348 fHistoPosPionPhi = new TH1F*[fnCuts];
349
350 if( fDoMesonQA ) {
351 fHistoNegPionEta = new TH1F*[fnCuts];
352 fHistoPosPionEta = new TH1F*[fnCuts];
353 fHistoNegPionClsTPC = new TH2F*[fnCuts];
354 fHistoPosPionClsTPC = new TH2F*[fnCuts];
355 fHistoPionDCAxy = new TH2F*[fnCuts];
356 fHistoPionDCAz = new TH2F*[fnCuts];
357 fHistoPionTPCdEdxNSigma = new TH2F*[fnCuts];
358 fHistoPionTPCdEdx = new TH2F*[fnCuts];
899d014b 359 fHistoPionPionInvMassPt = new TH2F*[fnCuts];
360
209b710e 361 }
362
363 fHistoMotherInvMassPt = new TH2F*[fnCuts];
364 fHistoMotherBackInvMassPt = new TH2F*[fnCuts];
365
366 for(Int_t iCut = 0; iCut<fnCuts;iCut++){
344100c4 367 TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
368 TString cutstringPion = ((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->GetCutNumber();
369 TString cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
370 TString cutstringGamma = ((AliConversionPhotonCuts*)fGammaCutArray->At(iCut))->GetCutNumber();
209b710e 371
372 fCutFolder[iCut] = new TList();
344100c4 373 fCutFolder[iCut]->SetName(Form("Cut Number %s_%s_%s_%s",cutstringEvent.Data(),cutstringGamma.Data(),cutstringPion.Data(),cutstringMeson.Data()));
209b710e 374 fCutFolder[iCut]->SetOwner(kTRUE);
375 fOutputContainer->Add(fCutFolder[iCut]);
376
377 fESDList[iCut] = new TList();
344100c4 378 fESDList[iCut]->SetName(Form("%s_%s_%s_%s ESD histograms",cutstringEvent.Data(),cutstringGamma.Data(),cutstringPion.Data(),cutstringMeson.Data()));
209b710e 379 fESDList[iCut]->SetOwner(kTRUE);
380
7f070437 381 fHistoNEvents[iCut] = new TH1I("NEvents","NEvents",10,-0.5,9.5);
209b710e 382 fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(1,"Accepted");
383 fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(2,"Centrality");
384 fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(3,"Missing MC");
385 fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(4,"Trigger");
386 fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(5,"Vertex Z");
387 fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(6,"Cont. Vertex");
388 fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(7,"Pile-Up");
389 fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(8,"no SDD");
390 fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(9,"no V0AND");
7f070437 391 fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(10,"EMCAL problems");
209b710e 392 fESDList[iCut]->Add(fHistoNEvents[iCut]);
393
394 if(fIsHeavyIon) fHistoNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",3000,0,3000);
395 else fHistoNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",200,0,200);
396 fESDList[iCut]->Add(fHistoNGoodESDTracks[iCut]);
397
398 fProfileEtaShift[iCut] = new TProfile("Eta Shift","Eta Shift",1, -0.5,0.5);
399 fESDList[iCut]->Add(fProfileEtaShift[iCut]);
400 fHistoConvGammaPt[iCut] = new TH1F("ESD_ConvGamma_Pt","ESD_ConvGamma_Pt",250,0,25);
401 fESDList[iCut]->Add(fHistoConvGammaPt[iCut]);
402 fHistoConvGammaEta[iCut] = new TH1F("ESD_ConvGamma_Eta","ESD_ConvGamma_Eta",600,-1.5,1.5);
403 fESDList[iCut]->Add(fHistoConvGammaEta[iCut]);
404 fHistoNegPionPt[iCut] = new TH1F("ESD_PrimaryNegPions_Pt","ESD_PrimaryNegPions_Pt",1000,0,25);
405 fESDList[iCut]->Add(fHistoNegPionPt[iCut]);
406 fHistoPosPionPt[iCut] = new TH1F("ESD_PrimaryPosPions_Pt","ESD_PrimaryPosPions_Pt",1000,0,25);
407 fESDList[iCut]->Add(fHistoPosPionPt[iCut]);
408 fHistoNegPionPhi[iCut] = new TH1F("ESD_PrimaryNegPions_Phi","ESD_PrimaryNegPions_Phi",360,0,2*TMath::Pi());
409 fESDList[iCut]->Add(fHistoNegPionPhi[iCut]);
410 fHistoPosPionPhi[iCut] = new TH1F("ESD_PrimaryPosPions_Phi","ESD_PrimaryPosPions_Phi",360,0,2*TMath::Pi());
411 fESDList[iCut]->Add(fHistoPosPionPhi[iCut]);
412
413 if ( fDoMesonQA ) {
414 fHistoNegPionEta[iCut] = new TH1F("ESD_PrimaryNegPions_Eta","ESD_PrimaryNegPions_Eta",600,-1.5,1.5);
415 fESDList[iCut]->Add(fHistoNegPionEta[iCut]);
416 fHistoPosPionEta[iCut] = new TH1F("ESD_PrimaryPosPions_Eta","ESD_PrimaryPosPions_Eta",600,-1.5,1.5);
417 fESDList[iCut]->Add(fHistoPosPionEta[iCut]);
418 fHistoNegPionClsTPC[iCut] = new TH2F("ESD_PrimaryNegPions_ClsTPC","ESD_PrimaryNegPions_ClsTPC",100,0,1,400,0.,10.);
419 fESDList[iCut]->Add(fHistoNegPionClsTPC[iCut]);
420 fHistoPosPionClsTPC[iCut] = new TH2F("ESD_PrimaryPosPions_ClsTPC","ESD_PrimaryPosPions_ClsTPC",100,0,1,400,0.,10.);
421 fESDList[iCut]->Add(fHistoPosPionClsTPC[iCut]);
422 fHistoPionDCAxy[iCut] = new TH2F("ESD_PrimaryPions_DCAxy","ESD_PrimaryPions_DCAxy",800,-4.0,4.0,400,0.,10.);
423 fESDList[iCut]->Add(fHistoPionDCAxy[iCut]);
424 fHistoPionDCAz[iCut] = new TH2F("ESD_PrimaryPions_DCAz","ESD_PrimaryPions_DCAz",800,-4.0,4.0,400,0.,10.);
425 fESDList[iCut]->Add(fHistoPionDCAz[iCut]);
426 fHistoPionTPCdEdxNSigma[iCut] = new TH2F("ESD_PrimaryPions_TPCdEdx","ESD_PrimaryPions_TPCdEdx",150,0.05,20,400,-10,10);
427 fESDList[iCut]->Add(fHistoPionTPCdEdxNSigma[iCut]);
428 fHistoPionTPCdEdx[iCut] =new TH2F("ESD_PrimaryPions_TPCdEdxSignal","ESD_PrimaryPions_TPCdEdxSignal" ,150,0.05,20.0,800,0.0,200);
429 fESDList[iCut]->Add(fHistoPionTPCdEdx[iCut]);
899d014b 430 fHistoPionPionInvMassPt[iCut] = new TH2F("ESD_PiPlusPiNeg_InvMassPt","ESD_PiPlusPiNeg_InvMassPt",2000,0.,2.,200,0.,20.);
431 fESDList[iCut]->Add(fHistoPionPionInvMassPt[iCut]);
209b710e 432 }
433
d9d6352b 434 fHistoMotherInvMassPt[iCut] = new TH2F("ESD_Mother_InvMass_Pt","ESD_Mother_InvMass_Pt",450,0.3,0.75,250,0,25);
209b710e 435 fESDList[iCut]->Add(fHistoMotherInvMassPt[iCut]);
d9d6352b 436 fHistoMotherBackInvMassPt[iCut] = new TH2F("ESD_Background_InvMass_Pt","ESD_Background_InvMass_Pt",450,0.3,0.75,250,0,25);
209b710e 437 fESDList[iCut]->Add(fHistoMotherBackInvMassPt[iCut]);
438
439 if ( fDoMesonQA ) {
440 TAxis *AxisAfter = fHistoPionTPCdEdxNSigma[iCut]->GetXaxis();
441 Int_t bins = AxisAfter->GetNbins();
442 Double_t from = AxisAfter->GetXmin();
443 Double_t to = AxisAfter->GetXmax();
444 Double_t *newBins = new Double_t[bins+1];
445 newBins[0] = from;
446 Double_t factor = TMath::Power(to/from, 1./bins);
447 for(Int_t i=1; i<=bins; ++i) newBins[i] = factor * newBins[i-1];
448
449 AxisAfter->Set(bins, newBins);
450 AxisAfter = fHistoPionTPCdEdx[iCut]->GetXaxis();
451 AxisAfter->Set(bins, newBins);
452
453 delete [] newBins;
454 }
455
456 fCutFolder[iCut]->Add(fESDList[iCut]);
457
458 }
459
460 if( fIsMC ){
461 // MC Histogramms
462 fMCList = new TList*[fnCuts];
463 // True Histogramms
464 fTrueList = new TList*[fnCuts];
465 fHistoTrueConvGammaPt = new TH1F*[fnCuts];
466 fHistoTrueConvGammaFromEtaPt = new TH1F*[fnCuts];
467 fHistoTruePosPionPt = new TH1F*[fnCuts];
468 fHistoTrueNegPionPt = new TH1F*[fnCuts];
469 fHistoTruePosPionFromEtaPt = new TH1F*[fnCuts];
470 fHistoTrueNegPionFromEtaPt = new TH1F*[fnCuts];
471
472
473 fHistoMCAllGammaPt = new TH1F*[fnCuts];
474 fHistoMCConvGammaPt = new TH1F*[fnCuts];
475 fHistoMCAllPosPionsPt = new TH1F*[fnCuts];
476 fHistoMCAllNegPionsPt = new TH1F*[fnCuts];
477 fHistoMCGammaFromEtaPt = new TH1F*[fnCuts];
478 fHistoMCPosPionsFromEtaPt = new TH1F*[fnCuts];
479 fHistoMCNegPionsFromEtaPt = new TH1F*[fnCuts];
480
481// hMCPi0DalitzGammaPt = new TH1F*[fnCuts];
482// hMCPi0DalitzElectronPt = new TH1F*[fnCuts];
483// hMCPi0DalitzPositronPt = new TH1F*[fnCuts];
484
485 fHistoMCEtaPiPlPiMiGammaPt = new TH1F*[fnCuts];
486 fHistoMCEtaDalitzPt = new TH1F*[fnCuts];
487 fHistoMCEtaGGPt = new TH1F*[fnCuts];
488 fHistoMCEtaPiPlPiMiGammaInAccPt = new TH1F*[fnCuts];
489//
490 fHistoTrueMotherPiPlPiMiGammaInvMassPt = new TH2F*[fnCuts];
491 fHistoTrueMotherDalitzInvMassPt = new TH2F*[fnCuts];
492 fHistoTrueMotherGammaGammaInvMassPt = new TH2F*[fnCuts];
493
899d014b 494 if (fDoMesonQA){
495 fHistoTruePionPionInvMassPt = new TH2F*[fnCuts];
496 fHistoTruePionPionFromEtaInvMassPt = new TH2F*[fnCuts];
497 }
498
209b710e 499 for(Int_t iCut = 0; iCut<fnCuts;iCut++){
344100c4 500 TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
501 TString cutstringPion = ((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->GetCutNumber();
502 TString cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
503 TString cutstringGamma = ((AliConversionPhotonCuts*)fGammaCutArray->At(iCut))->GetCutNumber();
209b710e 504
505 fMCList[iCut] = new TList();
344100c4 506 fMCList[iCut]->SetName(Form("%s_%s_%s_%s MC histograms",cutstringEvent.Data(),cutstringGamma.Data(),cutstringPion.Data(),cutstringMeson.Data()));
209b710e 507 fMCList[iCut]->SetOwner(kTRUE);
508 fCutFolder[iCut]->Add(fMCList[iCut]);
509
510 fHistoMCAllGammaPt[iCut] = new TH1F("MC_AllGamma_Pt","MC_AllGamma_Pt",250,0,25);
511 fMCList[iCut]->Add(fHistoMCAllGammaPt[iCut]);
512 fHistoMCConvGammaPt[iCut] = new TH1F("MC_ConvGamma_Pt","MC_ConvGamma_Pt",250,0,25);
513 fMCList[iCut]->Add(fHistoMCConvGammaPt[iCut]);
514 fHistoMCAllPosPionsPt[iCut] = new TH1F("MC_AllPosPions_Pt","MC_AllPosPions_Pt",1000,0,25);
515 fMCList[iCut]->Add(fHistoMCAllPosPionsPt[iCut]);
516 fHistoMCAllNegPionsPt[iCut] = new TH1F("MC_AllNegPions_Pt","MC_AllNegPions_Pt",1000,0,25);
517 fMCList[iCut]->Add(fHistoMCAllNegPionsPt[iCut]);
518 fHistoMCGammaFromEtaPt[iCut] = new TH1F("MC_GammaFromEta_Pt","MC_GammaFromEta_Pt",250,0,25);
519 fMCList[iCut]->Add(fHistoMCGammaFromEtaPt[iCut]);
520 fHistoMCPosPionsFromEtaPt[iCut] = new TH1F("MC_PosPionsFromEta_Pt","MC_PosPionsFromEta_Pt",1000,0,25);
521 fMCList[iCut]->Add(fHistoMCPosPionsFromEtaPt[iCut]);
522 fHistoMCNegPionsFromEtaPt[iCut] = new TH1F("MC_NegPionsFromEta_Pt","MC_NegPionsFromEta_Pt",1000,0,25);
523 fMCList[iCut]->Add(fHistoMCNegPionsFromEtaPt[iCut]);
524
525 fHistoMCEtaPiPlPiMiGammaPt[iCut] = new TH1F("MC_Eta_Pt","MC_Eta_Pt",250,0,25);
526 fHistoMCEtaPiPlPiMiGammaPt[iCut]->Sumw2();
527 fMCList[iCut]->Add(fHistoMCEtaPiPlPiMiGammaPt[iCut]);
528
529 fHistoMCEtaDalitzPt[iCut] = new TH1F("MC_Eta_Dalitz_Pt","MC_Eta_Pt",250,0,25);
530 fHistoMCEtaDalitzPt[iCut]->Sumw2();
531 fMCList[iCut]->Add(fHistoMCEtaDalitzPt[iCut]);
532
533 fHistoMCEtaGGPt[iCut] = new TH1F("MC_Eta_GG_Pt","MC_Eta_GG_Pt",250,0,25);
534 fHistoMCEtaGGPt[iCut]->Sumw2();
535 fMCList[iCut]->Add(fHistoMCEtaGGPt[iCut]);
536
d9d6352b 537 fHistoMCEtaPiPlPiMiGammaInAccPt[iCut] = new TH1F("MC_EtaInAcc_Pt","MC_EtaInAcc_Pt",250,0,25);
209b710e 538 fHistoMCEtaPiPlPiMiGammaInAccPt[iCut]->Sumw2();
539 fMCList[iCut]->Add(fHistoMCEtaPiPlPiMiGammaInAccPt[iCut]);
540
541 fTrueList[iCut] = new TList();
344100c4 542 fTrueList[iCut]->SetName(Form("%s_%s_%s_%s True histograms",cutstringEvent.Data(),cutstringGamma.Data(),cutstringPion.Data(),cutstringMeson.Data()));
209b710e 543 fTrueList[iCut]->SetOwner(kTRUE);
544 fCutFolder[iCut]->Add(fTrueList[iCut]);
545
546 fHistoTrueConvGammaPt[iCut] = new TH1F("ESD_TrueConvGamma_Pt","ESD_TrueConvGamma_Pt",250,0,25);
547 fTrueList[iCut]->Add(fHistoTrueConvGammaPt[iCut]);
548 fHistoTrueConvGammaFromEtaPt[iCut] = new TH1F("ESD_TrueConvGammaFromEta_Pt","ESD_TrueConvGammaFromEta_Pt",250,0,25);
549 fTrueList[iCut]->Add(fHistoTrueConvGammaFromEtaPt[iCut]);
550
551 fHistoTruePosPionPt[iCut] = new TH1F("ESD_TruePosPion_Pt","ESD_TruePosPion_Pt",1000,0,25);
552 fTrueList[iCut]->Add(fHistoTruePosPionPt[iCut]);
553 fHistoTrueNegPionPt[iCut] = new TH1F("ESD_TrueNegPion_Pt","ESD_TrueNegPion_Pt",1000,0,25);
554 fTrueList[iCut]->Add(fHistoTrueNegPionPt[iCut]);
555
556 fHistoTrueNegPionFromEtaPt[iCut] = new TH1F("ESD_TrueNegPionFromEta_Pt","ESD_TrueNegPionFromEta_Pt",1000,0,25);
557 fTrueList[iCut]->Add(fHistoTrueNegPionFromEtaPt[iCut]);
558 fHistoTruePosPionFromEtaPt[iCut] = new TH1F("ESD_TruePosPionFromEta_Pt","ESD_TruePosPionFromEta_Pt",1000,0,25);
559 fTrueList[iCut]->Add(fHistoTruePosPionFromEtaPt[iCut]);
560
899d014b 561 fHistoTrueMotherPiPlPiMiGammaInvMassPt[iCut] = new TH2F("ESD_TrueMotherPiPlPiMiGamma_InvMass_Pt","ESD_TrueMotherPiPlPiMiGamma_InvMass_Pt",450,0.3,0.75,250,0,25);
209b710e 562 fHistoTrueMotherPiPlPiMiGammaInvMassPt[iCut]->Sumw2();
563 fTrueList[iCut]->Add(fHistoTrueMotherPiPlPiMiGammaInvMassPt[iCut]);
564
899d014b 565 fHistoTrueMotherGammaGammaInvMassPt[iCut] = new TH2F("ESD_TrueMotherGG_InvMass_Pt","ESD_TrueMotherGG_InvMass_Pt",450,0.3,0.75,250,0,25);
209b710e 566 fHistoTrueMotherGammaGammaInvMassPt[iCut]->Sumw2();
567 fTrueList[iCut]->Add(fHistoTrueMotherGammaGammaInvMassPt[iCut]);
568
899d014b 569 fHistoTrueMotherDalitzInvMassPt[iCut] = new TH2F("ESD_TrueMotherDalitz_InvMass_Pt","ESD_TrueMotherDalitz_InvMass_Pt",450,0.3,0.75,250,0,25);
209b710e 570 fHistoTrueMotherDalitzInvMassPt[iCut]->Sumw2();
571 fTrueList[iCut]->Add(fHistoTrueMotherDalitzInvMassPt[iCut]);
899d014b 572
573 if (fDoMesonQA){
574 fHistoTruePionPionInvMassPt[iCut] = new TH2F("ESD_TruePiPlusPiNeg_InvMassPt","ESD_TruePiPlusPiNeg_InvMassPt",2000,0.,2.,200,0.,20.);
575 fTrueList[iCut]->Add(fHistoTruePionPionInvMassPt[iCut]);
576 fHistoTruePionPionFromEtaInvMassPt[iCut] = new TH2F("ESD_TruePiPlusPiNegFromEta_InvMassPt","ESD_TruePiPlusPiNegFromEta_InvMassPt",2000,0.,2.,200,0.,20.);
577 fTrueList[iCut]->Add(fHistoTruePionPionFromEtaInvMassPt[iCut]);
578 }
209b710e 579 }
580 }
581
582
583
584 InitBack(); // Init Background Handler
585
586 fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask("V0ReaderV1");
587 if(!fV0Reader){printf("Error: No V0 Reader");return;} // GetV0Reader
588
589 if(fV0Reader)
344100c4 590 if((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())
591 if(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms())
592 fOutputContainer->Add(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms());
209b710e 593
594
595
596 fPionSelector=(AliPrimaryPionSelector*)AliAnalysisManager::GetAnalysisManager()->GetTask("PionSelector");
597 if(!fPionSelector){printf("Error: No PionSelector");return;} // GetV0Reader
598
599 if( fPionSelector ){
600 if ( ((AliPrimaryPionCuts*)fPionSelector->GetPrimaryPionCuts())->GetCutHistograms() ){
601 fOutputContainer->Add( ((AliPrimaryPionCuts*)fPionSelector->GetPrimaryPionCuts())->GetCutHistograms() );
602 }
603 }
604
605 for(Int_t iCut = 0; iCut<fnCuts;iCut++){
606 if( fPionCutArray ){
607 if( ((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->GetCutHistograms() ) {
608 fCutFolder[iCut]->Add( ((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->GetCutHistograms() );
609 }
610 }
611 if( fMesonCutArray ) {
612 if( ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms() ) {
613 fCutFolder[iCut]->Add( ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms());
614 }
615 }
616 if( fGammaCutArray ) {
344100c4 617 if( ((AliConversionPhotonCuts*)fGammaCutArray->At(iCut))->GetCutHistograms() ) {
618 fCutFolder[iCut]->Add( ((AliConversionPhotonCuts*)fGammaCutArray->At(iCut))->GetCutHistograms() );
209b710e 619 }
620 }
621 }
622
623 PostData(1, fOutputContainer);
624
625}
626
627//______________________________________________________________________
628void AliAnalysisTaskEtaToPiPlPiMiGamma::UserExec(Option_t *){
629
630 //
631 // Execute analysis for current event
632 //
633
634 fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask("V0ReaderV1");
635 if(!fV0Reader){printf("Error: No V0 Reader");return;} // GetV0Reader
636
344100c4 637 Int_t eventQuality = ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEventQuality();
209b710e 638
639 if(eventQuality == 2 || eventQuality == 3){// Event Not Accepted due to MC event missing or wrong trigger for V0ReaderV1
640 for(Int_t iCut = 0; iCut<fnCuts; iCut++){
641 fHistoNEvents[iCut]->Fill(eventQuality);
642 }
643 return;
644 }
645
646 fPionSelector=(AliPrimaryPionSelector*)AliAnalysisManager::GetAnalysisManager()->GetTask("PionSelector");
647 if(!fPionSelector){printf("Error: No PionSelector");return;} // GetV0Reader
648
649 if(fIsMC) fMCEvent = MCEvent();
650 fESDEvent = (AliESDEvent*)InputEvent();
651 fReaderGammas = fV0Reader->GetReconstructedGammas(); // Gammas from default Cut
652 fSelectorNegPionIndex = fPionSelector->GetReconstructedNegPionIndex(); // Electrons from default Cut
653 fSelectorPosPionIndex = fPionSelector->GetReconstructedPosPionIndex(); // Positrons from default Cut
654
655 fNumberOfESDTracks = fV0Reader->GetNumberOfPrimaryTracks();
656 //AddTaskContainers(); //Add conatiner
657
658 for(Int_t iCut = 0; iCut<fnCuts; iCut++){
659 fiCut = iCut;
7f070437 660 Int_t eventNotAccepted = ((AliConvEventCuts*)fEventCutArray->At(iCut))->IsEventAcceptedByCut(fV0Reader->GetEventCuts(),fInputEvent,fMCEvent,fIsHeavyIon,kFALSE);
209b710e 661
662 if(eventNotAccepted){
663 // cout << "event rejected due to wrong trigger: " <<eventNotAccepted << endl;
664 fHistoNEvents[iCut]->Fill(eventNotAccepted); // Check Centrality, PileUp, SDD and V0AND --> Not Accepted => eventQuality = 1
665 continue;
666 }
667
668 if(eventQuality != 0){// Event Not Accepted
669 // cout << "event rejected due to: " <<eventQuality << endl;
670 fHistoNEvents[iCut]->Fill(eventQuality);
671 continue;
672 }
673
674 fHistoNEvents[iCut]->Fill(eventQuality);
675 fHistoNGoodESDTracks[iCut]->Fill(fNumberOfESDTracks);
676
677 if(fMCEvent){ // Process MC Particle
678 fMCStack = fMCEvent->Stack();
344100c4 679 if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection() != 0){
680 ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetNotRejectedParticles(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection(),
681 ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader(),
682 fMCEvent);
209b710e 683 }
684 ProcessMCParticles();
685 }
686
d9d6352b 687 fIsGammaEtaCand =kFALSE;
209b710e 688// cout << "new event" << endl;
689 ProcessPhotonCandidates(); // Process this cuts gammas
690 ProcessPionCandidates(); // Process this cuts gammas
691
692
693 CalculateMesonCandidates();
694 CalculateBackground();
695 UpdateEventByEventData();
696
697 fGoodGammas->Clear(); // delete this cuts good gammas
698 fGoodVirtualParticles->Clear(); // delete this cuts good gammas
699 }
700
701 fSelectorNegPionIndex.clear();
702 fSelectorPosPionIndex.clear();
703
704 PostData( 1, fOutputContainer );
705}
706
707Bool_t AliAnalysisTaskEtaToPiPlPiMiGamma::Notify(){
708 for(Int_t iCut = 0; iCut<fnCuts;iCut++){
344100c4 709 if( !((AliConvEventCuts*)fEventCutArray->At(iCut))->GetDoEtaShift() ){
209b710e 710 fProfileEtaShift[iCut]->Fill(0.,0.);
711 continue; // No Eta Shift requested, continue
712 }
344100c4 713 if( ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift() == 0.0){ // Eta Shift requested but not set, get shift automatically
714 ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCorrectEtaShiftFromPeriod(fV0Reader->GetPeriodName());
715 ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
716 ((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->SetEtaShift( ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift() );
717 fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
209b710e 718 continue;
719 } else {
720 printf(" Eta t PiPlusPiMinus Gamma Task %s :: Eta Shift Manually Set to %f \n\n",
344100c4 721 (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber()).Data(),((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift());
722 ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
723 ((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->SetEtaShift( ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift() );
724 fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
209b710e 725 }
726 }
727 return kTRUE;
728}
729
730
731void AliAnalysisTaskEtaToPiPlPiMiGamma::Terminate(const Option_t *){
732///Grid
733}
734
735//________________________________________________________________________
736void AliAnalysisTaskEtaToPiPlPiMiGamma::ProcessPhotonCandidates(){
737 Int_t nV0 = 0;
738 TList *GoodGammasStepOne = new TList();
739 TList *GoodGammasStepTwo = new TList();
740 // Loop over Photon Candidates allocated by ReaderV1
741
742 for(Int_t i = 0; i < fReaderGammas->GetEntriesFast(); i++){
743 AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) fReaderGammas->At(i);
744 if(!PhotonCandidate) continue;
745
746 fIsFromMBHeader = kTRUE;
747
344100c4 748 if( fMCEvent && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0 ){
209b710e 749 Int_t isPosFromMBHeader
344100c4 750 = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCStack, fInputEvent);
751 if(isPosFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
209b710e 752 Int_t isNegFromMBHeader
344100c4 753 = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCStack,fInputEvent);
754 if(isNegFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
209b710e 755 if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
756 }
757
344100c4 758 if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelected(PhotonCandidate,fESDEvent)) continue;
209b710e 759
344100c4 760 if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseElecSharingCut() &&
761 !((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseToCloseV0sCut()){ // if no post reader loop is required add to events good gammas
209b710e 762
763 fGoodGammas->Add(PhotonCandidate);
764
765 if(fIsFromMBHeader){
766 fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
767 fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
768 }
769
770 if(fMCEvent){
771 ProcessTruePhotonCandidates(PhotonCandidate);
772 }
344100c4 773 } else if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseElecSharingCut()){ // if Shared Electron cut is enabled, Fill array, add to step one
774 ((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->FillElectonLabelArray(PhotonCandidate,nV0);
209b710e 775 nV0++;
776 GoodGammasStepOne->Add(PhotonCandidate);
344100c4 777 } else if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseElecSharingCut() &&
778 ((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseToCloseV0sCut()){ // shared electron is disabled, step one not needed -> step two
209b710e 779 GoodGammasStepTwo->Add(PhotonCandidate);
780 }
781 }
782
783
344100c4 784 if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseElecSharingCut()){
209b710e 785 for(Int_t i = 0;i<GoodGammasStepOne->GetEntries();i++){
786 AliAODConversionPhoton *PhotonCandidate= (AliAODConversionPhoton*) GoodGammasStepOne->At(i);
787 if(!PhotonCandidate) continue;
788 fIsFromMBHeader = kTRUE;
344100c4 789 if(fMCEvent && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
209b710e 790 Int_t isPosFromMBHeader
344100c4 791 = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCStack,fInputEvent);
209b710e 792 Int_t isNegFromMBHeader
344100c4 793 = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCStack,fInputEvent);
209b710e 794 if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
795 }
344100c4 796 if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->RejectSharedElectronV0s(PhotonCandidate,i,GoodGammasStepOne->GetEntries())) continue;
797 if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseToCloseV0sCut()){ // To Colse v0s cut diabled, step two not needed
209b710e 798 fGoodGammas->Add(PhotonCandidate);
799 if(fIsFromMBHeader){
800 fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
801 fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
802 }
803 if(fMCEvent){
804 ProcessTruePhotonCandidates(PhotonCandidate);
805 }
806 }
807 else GoodGammasStepTwo->Add(PhotonCandidate); // Close v0s cut enabled -> add to list two
808 }
809 }
344100c4 810 if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseToCloseV0sCut()){
209b710e 811 for(Int_t i = 0;i<GoodGammasStepTwo->GetEntries();i++){
812 AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) GoodGammasStepTwo->At(i);
813 if(!PhotonCandidate) continue;
814
344100c4 815 if(fMCEvent && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
209b710e 816 Int_t isPosFromMBHeader
344100c4 817 = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCStack,fInputEvent);
209b710e 818 Int_t isNegFromMBHeader
344100c4 819 = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCStack,fInputEvent);
209b710e 820 if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
821 }
822
344100c4 823 if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->RejectToCloseV0s(PhotonCandidate,GoodGammasStepTwo,i)) continue;
209b710e 824 fGoodGammas->Add(PhotonCandidate); // Add gamma to current cut TList
825
826 if(fIsFromMBHeader){
827 fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt()); // Differences to old V0Reader in p_t due to conversion KF->TLorentzVector
828 fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
829 }
830
831 if(fMCEvent){
832 ProcessTruePhotonCandidates(PhotonCandidate);
833 }
834 }
835 }
836
837 delete GoodGammasStepOne;
838 GoodGammasStepOne = 0x0;
839 delete GoodGammasStepTwo;
840 GoodGammasStepTwo = 0x0;
841}
842
843//________________________________________________________________________
844void AliAnalysisTaskEtaToPiPlPiMiGamma::ProcessTruePhotonCandidates(AliAODConversionPhoton *TruePhotonCandidate)
845{
846 // Process True Photons
847 AliStack *MCStack = fMCEvent->Stack();
848 TParticle *posDaughter = TruePhotonCandidate->GetPositiveMCDaughter(MCStack);
849 TParticle *negDaughter = TruePhotonCandidate->GetNegativeMCDaughter(MCStack);
850
851 if(posDaughter == NULL || negDaughter == NULL) return; // One particle does not exist
852 if(posDaughter->GetMother(0) != negDaughter->GetMother(0)){ // Not Same Mother == Combinatorial Bck
853 return;
854 }
855
856 else if (posDaughter->GetMother(0) == -1){
857 return;
858 }
859
860 if(TMath::Abs(posDaughter->GetPdgCode())!=11 || TMath::Abs(negDaughter->GetPdgCode())!=11) return; //One Particle is not electron
861 if(posDaughter->GetPdgCode()==negDaughter->GetPdgCode()) return; // Same Charge
862 if(posDaughter->GetUniqueID() != 5 || negDaughter->GetUniqueID() !=5) return;// check if the daughters come from a conversion
863
864 TParticle *Photon = TruePhotonCandidate->GetMCParticle(MCStack);
865 if(Photon->GetPdgCode() != 22) return; // Mother is no Photon
866
867 // True Photon
868
869 Int_t labelGamma = TruePhotonCandidate->GetMCParticleLabel(MCStack);
870
871 if( labelGamma < MCStack->GetNprimary() ){
872 if( fIsFromMBHeader ){
873 fHistoTrueConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
874 }
875 }
876
877 if( IsEtaPiPlPiMiGammaDaughter(labelGamma) == kTRUE ) {
878 if( labelGamma < MCStack->GetNprimary() ) {
879 if( fIsFromMBHeader ){
880 fHistoTrueConvGammaFromEtaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
d9d6352b 881
882// TParticle * gammaMC = (TParticle*)MCStack->Particle(labelGamma);
883// Int_t gammaMotherLabel=gammaMC->GetFirstMother();
884// for(Int_t index= ((TParticle*)MCStack->Particle(gammaMotherLabel))->GetFirstDaughter();index<= ((TParticle*)MCStack->Particle(gammaMotherLabel))->GetLastDaughter();index++){
885// TParticle* temp = (TParticle*)fMCStack->Particle( index );
886// switch( temp->GetPdgCode() ) {
887// case 211:
888// cout << "pi- " << index << "\t" << temp->Pt() << "\t" << temp->Eta() << endl;
889// break;
890// case -211:
891// cout << "pi+ " << index << "\t" << temp->Pt() << "\t" << temp->Eta() << endl;
892// break;
893// case ::kGamma:
894// cout << "gamma " << index << "\t" << temp->Pt()<< "\t" << temp->Eta() << endl;
895// break;
896// }
897// }
898 fIsGammaEtaCand = kTRUE;
209b710e 899 }
900 }
901 }
902}
903
904//________________________________________________________________________
905void AliAnalysisTaskEtaToPiPlPiMiGamma::ProcessPionCandidates(){
906
907 Double_t magField = fInputEvent->GetMagneticField();
908 if( magField < 0.0 ){
909 magField = 1.0;
910 } else {
911 magField = -1.0;
912 }
913
914 vector<Int_t> lGoodNegPionIndexPrev(0);
915 vector<Int_t> lGoodPosPionIndexPrev(0);
916
917 for(UInt_t i = 0; i < fSelectorNegPionIndex.size(); i++){
918 AliESDtrack* negPionCandidate = fESDEvent->GetTrack(fSelectorNegPionIndex[i]);
919 if(! ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelected(negPionCandidate) ) continue;
920 lGoodNegPionIndexPrev.push_back( fSelectorNegPionIndex[i] );
921 fHistoNegPionPt[fiCut]->Fill(negPionCandidate->Pt());
922 fHistoNegPionPhi[fiCut]->Fill(negPionCandidate->Phi());
923 if( fMCEvent ) {
924 Int_t labelNegPion = TMath::Abs( negPionCandidate->GetLabel() );
925 if( labelNegPion < fMCStack->GetNtrack() ){
926 TParticle* negPion = fMCStack->Particle(labelNegPion);
927 if( negPion->GetPdgCode() == -211 ){
928 if( labelNegPion < fMCStack->GetNprimary() ){
929 fHistoTrueNegPionPt[fiCut]->Fill(negPionCandidate->Pt()); //primary negPion
930 }
931 if( IsEtaPiPlPiMiGammaDaughter(labelNegPion) == kTRUE ) {
932 if( labelNegPion < fMCStack->GetNprimary() ) {
933 fHistoTrueNegPionFromEtaPt[fiCut]->Fill(negPionCandidate->Pt());
d9d6352b 934// if (fIsGammaEtaCand) cout << "pi- rec" << labelNegPion << "\t" << negPionCandidate->Pt()<< endl;
209b710e 935 }
936 }
937 }
938 }
939 }
940 }
941
942 for(UInt_t i = 0; i < fSelectorPosPionIndex.size(); i++){
943 AliESDtrack* posPionCandidate = fESDEvent->GetTrack( fSelectorPosPionIndex[i] );
944 if(! ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelected(posPionCandidate) ) continue;
945 lGoodPosPionIndexPrev.push_back( fSelectorPosPionIndex[i] );
946 fHistoPosPionPt[fiCut]->Fill( posPionCandidate->Pt() );
947 fHistoPosPionPhi[fiCut]->Fill( posPionCandidate->Phi() );
948
949 if( fMCEvent ) {
950 Int_t labelPosPion = TMath::Abs( posPionCandidate->GetLabel() );
951 if( labelPosPion < fMCStack->GetNtrack() ) {
952 TParticle* posPion = fMCStack->Particle(labelPosPion);
953 if( posPion->GetPdgCode() == 211 ){
954 if( labelPosPion < fMCStack->GetNprimary() ){
955 fHistoTruePosPionPt[fiCut]->Fill(posPionCandidate->Pt());
956 }
957 if( IsEtaPiPlPiMiGammaDaughter(labelPosPion) == kTRUE ) {
958 if( labelPosPion < fMCStack->GetNprimary() ){
959 fHistoTruePosPionFromEtaPt[fiCut]->Fill(posPionCandidate->Pt());
d9d6352b 960// if (fIsGammaEtaCand) cout << "pi+ rec" << labelPosPion << "\t" << posPionCandidate->Pt()<< endl;
209b710e 961 }
962 }
963 }
964 }
965 }
966 }
967
968
969 for(UInt_t i = 0; i < lGoodNegPionIndexPrev.size(); i++){
970
971 AliESDtrack *negPionCandidate = fESDEvent->GetTrack(lGoodNegPionIndexPrev[i]);
972 AliKFParticle negPionCandidateKF( *negPionCandidate->GetConstrainedParam(), 211 );
973
974 for(UInt_t j = 0; j < lGoodPosPionIndexPrev.size(); j++){
975
976 AliESDtrack *posPionCandidate = fESDEvent->GetTrack(lGoodPosPionIndexPrev[j]);
977 AliKFParticle posPionCandidateKF( *posPionCandidate->GetConstrainedParam(), 211 );
978
979 AliKFConversionPhoton* virtualPhoton = NULL;
980 virtualPhoton = new AliKFConversionPhoton(negPionCandidateKF,posPionCandidateKF);
981 AliKFVertex primaryVertexImproved(*fInputEvent->GetPrimaryVertex());
982// primaryVertexImproved+=*virtualPhoton;
983 virtualPhoton->SetProductionVertex(primaryVertexImproved);
984 virtualPhoton->SetTrackLabels( lGoodPosPionIndexPrev[j], lGoodNegPionIndexPrev[i]);
985
986
987 if( fMCEvent ) {
988 Int_t labeln=TMath::Abs(negPionCandidate->GetLabel());
989 Int_t labelp=TMath::Abs(posPionCandidate->GetLabel());
990 TParticle *fNegativeMCParticle = fMCStack->Particle(labeln);
991 TParticle *fPositiveMCParticle = fMCStack->Particle(labelp);
992
993 if( fPositiveMCParticle && fNegativeMCParticle) {
994 virtualPhoton->SetMCLabelPositive(labelp);
995 virtualPhoton->SetMCLabelNegative(labeln);
996 }
997 }
998
d9d6352b 999 AliAODConversionPhoton *vParticle = new AliAODConversionPhoton(virtualPhoton); //To Apply PsiPairCut
1000 if (((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->DoMassCut()){
1001 if (vParticle->GetMass() < ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetMassCut()){
1002 fGoodVirtualParticles->Add( vParticle );
1003 }
1004 } else {
1005 fGoodVirtualParticles->Add( vParticle );
1006 }
209b710e 1007 delete virtualPhoton;
1008 virtualPhoton=NULL;
1009
1010 }
1011 }
1012}
1013
1014//_____________________________________________________________________________
1015void AliAnalysisTaskEtaToPiPlPiMiGamma::ProcessMCParticles(){
1016
1017 // Loop over all primary MC particle
1018
1019 for(Int_t i = 0; i < fMCStack->GetNprimary(); i++) {
1020
1021 TParticle* particle = (TParticle *)fMCStack->Particle(i);
1022 if (!particle) continue;
1023
1024 Int_t isMCFromMBHeader = -1;
344100c4 1025 if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
209b710e 1026 isMCFromMBHeader
344100c4 1027 = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack, fInputEvent);
1028 if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
209b710e 1029 }
1030
344100c4 1031 if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack,fInputEvent)){
209b710e 1032
344100c4 1033 if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCStack,kFALSE)){
209b710e 1034 fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt()); // All MC Gamma
1035 if(particle->GetMother(0) >-1){
1036 if (fMCStack->Particle(particle->GetMother(0))->GetPdgCode() ==221 && fMCStack->Particle(particle->GetMother(0))->GetNDaughters()==3 ) fHistoMCGammaFromEtaPt[fiCut]->Fill(particle->Pt()); // All pos from eta
1037 }
1038 }
1039
344100c4 1040 if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCStack,kTRUE)){
209b710e 1041 fHistoMCConvGammaPt[fiCut]->Fill(particle->Pt());
1042 } // Converted MC Gamma
1043
1044 if(((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelectedMC(i,fMCStack)){
1045 if( particle->GetPdgCode() == 211){
1046 fHistoMCAllPosPionsPt[fiCut]->Fill(particle->Pt()); // All pos pions
1047 if(particle->GetMother(0) >-1){
1048 if (fMCStack->Particle(particle->GetMother(0))->GetPdgCode() ==221) fHistoMCPosPionsFromEtaPt[fiCut]->Fill(particle->Pt()); // All pos from eta
1049 }
1050 }
1051 if( particle->GetPdgCode() == -211){
1052 fHistoMCAllNegPionsPt[fiCut]->Fill(particle->Pt()); // All neg pions
1053 if(particle->GetMother(0) >-1){
1054 if (fMCStack->Particle(particle->GetMother(0))->GetPdgCode() ==221) fHistoMCNegPionsFromEtaPt[fiCut]->Fill(particle->Pt()); // All pos from eta
1055 }
1056 }
1057 }
1058
1059 // \eta -> \gamma \gamma
1060
344100c4 1061 if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedMC( particle,fMCStack,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift() ) ){
209b710e 1062 Float_t weighted= 1;
1063 if( ((AliPrimaryPionCuts*) fPionCutArray->At(fiCut))->DoWeights() ) {
344100c4 1064 if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack, fInputEvent)){
209b710e 1065 if (particle->Pt()>0.005){
344100c4 1066 weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),i, fMCStack,fInputEvent);
209b710e 1067 }
1068 }
1069 }
1070 if(particle->GetPdgCode() == 221)fHistoMCEtaGGPt[fiCut]->Fill( particle->Pt() , weighted); // All MC Eta GG decay
1071 }
1072
1073 // \eta -> e+ e- \gamma
1074 Int_t labelgamma = -1;
1075 Int_t labelelectron = -1;
1076 Int_t labelpositron = -1;
1077
344100c4 1078 if( ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedMCDalitz(particle,fMCStack,labelelectron,labelpositron,labelgamma,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
209b710e 1079 Float_t weighted= 1;
1080 if( ((AliPrimaryPionCuts*) fPionCutArray->At(fiCut))->DoWeights() ) {
344100c4 1081 if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack,fInputEvent)){
209b710e 1082 if (particle->Pt()>0.005){
344100c4 1083 weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),i, fMCStack,fInputEvent);
209b710e 1084 }
1085 }
1086 }
1087 if(particle->GetPdgCode() == 221)fHistoMCEtaDalitzPt[fiCut]->Fill(particle->Pt(), weighted); // All MC Eta
1088 }
1089
1090
1091 // \eta -> pi+ pi- \gamma
1092 Int_t labelGamma3Body = -1;
1093 Int_t labelNegPion = -1;
1094 Int_t labelPosPion = -1;
1095
344100c4 1096 if( ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedMCEtaPiPlPiMiGamma(particle,fMCStack,labelNegPion,labelPosPion,labelGamma3Body,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
209b710e 1097 Float_t weighted= 1;
1098 if( ((AliPrimaryPionCuts*) fPionCutArray->At(fiCut))->DoWeights() ) {
344100c4 1099 if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack,fInputEvent)){
209b710e 1100 if (particle->Pt()>0.005){
344100c4 1101 weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),i, fMCStack,fInputEvent);
209b710e 1102 }
1103 }
1104 }
1105 if(particle->GetPdgCode() == 221)fHistoMCEtaPiPlPiMiGammaPt[fiCut]->Fill(particle->Pt(), weighted); // All MC Eta
1106
1107 TParticle *gamma = fMCStack->Particle(labelGamma3Body);
344100c4 1108 if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelectedMC(gamma,fMCStack,kFALSE) &&
209b710e 1109 ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelectedMC(labelNegPion,fMCStack) &&
1110 ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelectedMC(labelPosPion,fMCStack) ) {
1111 if(particle->GetPdgCode() == 221)fHistoMCEtaPiPlPiMiGammaInAccPt[fiCut]->Fill(particle->Pt(), weighted ); // MC EtaDalitz with gamma and e+e- in acc
1112 }
1113 }
1114 }
1115 }
1116}
1117
1118
1119//________________________________________________________________________
1120void AliAnalysisTaskEtaToPiPlPiMiGamma::CalculateMesonCandidates(){
1121
1122 // Conversion Gammas
1123 if( fGoodGammas->GetEntries() > 0 && fGoodVirtualParticles->GetEntries() > 0 ){
1124
1125 vector<Bool_t> lGoodVirtualParticle(fGoodVirtualParticles->GetEntries(), kFALSE);
1126
1127 for(Int_t GammaIndex=0; GammaIndex<fGoodGammas->GetEntries(); GammaIndex++){
1128
1129 AliAODConversionPhoton *gamma=dynamic_cast<AliAODConversionPhoton*>(fGoodGammas->At(GammaIndex));
1130 if (gamma==NULL) continue;
1131 for(Int_t virtualParticleIndex=0;virtualParticleIndex<fGoodVirtualParticles->GetEntries();virtualParticleIndex++){
1132
899d014b 1133 AliAODConversionPhoton *vParticle=dynamic_cast<AliAODConversionPhoton*>(fGoodVirtualParticles->At(virtualParticleIndex));
1134 if (vParticle==NULL) continue;
209b710e 1135 //Check for same Electron ID
899d014b 1136 if(gamma->GetTrackLabelPositive() == vParticle->GetTrackLabelPositive() ||
1137 gamma->GetTrackLabelNegative() == vParticle->GetTrackLabelNegative() ||
1138 gamma->GetTrackLabelNegative() == vParticle->GetTrackLabelPositive() ||
1139 gamma->GetTrackLabelPositive() == vParticle->GetTrackLabelNegative() ) continue;
209b710e 1140
899d014b 1141 AliAODConversionMother *etacand = new AliAODConversionMother(gamma,vParticle);
209b710e 1142 etacand->SetLabels(GammaIndex,virtualParticleIndex);
d9d6352b 1143
1144// if(fMCEvent){
1145// AliESDtrack *posPionVParticle = fESDEvent->GetTrack( vParticle->GetTrackLabelNegative() );
1146// AliESDtrack *negPionVParticle = fESDEvent->GetTrack( vParticle->GetTrackLabelPositive() );
1147//
1148// Int_t labeln=TMath::Abs(negPionVParticle->GetLabel());
1149// Int_t labelp=TMath::Abs(posPionVParticle->GetLabel());
1150//
1151// cout << labeln << "\t" << labelp << endl;
1152// }
209b710e 1153
344100c4 1154 if( ( ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(etacand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())) ){
209b710e 1155
d9d6352b 1156// cout<< "Meson Accepted "<<endl;
209b710e 1157
1158 Int_t zbin= fBGHandler[fiCut]->GetZBinIndex(fESDEvent->GetPrimaryVertex()->GetZ());
1159 Int_t mbin = 0;
1160 if( ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
1161 mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fNumberOfESDTracks);
1162 } else {
1163 mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fGoodGammas->GetEntries());
1164 }
1165
899d014b 1166 AliESDtrack *posPionVParticle = 0;
1167 AliESDtrack *negPionVParticle = 0;
209b710e 1168
1169 Double_t clsToFPos = -1.0;
1170 Double_t clsToFNeg = -1.0;
1171
1172 Float_t dcaToVertexXYPos = -1.0;
1173 Float_t dcaToVertexZPos = -1.0;
1174 Float_t dcaToVertexXYNeg = -1.0;
1175 Float_t dcaToVertexZNeg = -1.0;
1176
1177
1178 if ( fDoMesonQA ) {
1179
899d014b 1180 fHistoPionPionInvMassPt[fiCut]->Fill( vParticle->GetMass(),vParticle->Pt());
1181
1182 posPionVParticle = fESDEvent->GetTrack( vParticle->GetTrackLabelPositive() );
1183 negPionVParticle = fESDEvent->GetTrack( vParticle->GetTrackLabelNegative() );
1184 clsToFPos = ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetNFindableClustersTPC(posPionVParticle);
1185 clsToFNeg = ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetNFindableClustersTPC(negPionVParticle);
209b710e 1186
1187 Float_t bPos[2];
1188 Float_t bCovPos[3];
899d014b 1189 posPionVParticle->GetImpactParameters(bPos,bCovPos);
209b710e 1190 if (bCovPos[0]<=0 || bCovPos[2]<=0) {
1191 AliDebug(1, "Estimated b resolution lower or equal zero!");
1192 bCovPos[0]=0; bCovPos[2]=0;
1193 }
1194
1195 Float_t bNeg[2];
1196 Float_t bCovNeg[3];
899d014b 1197 posPionVParticle->GetImpactParameters(bNeg,bCovNeg);
209b710e 1198 if (bCovNeg[0]<=0 || bCovNeg[2]<=0) {
1199 AliDebug(1, "Estimated b resolution lower or equal zero!");
1200 bCovNeg[0]=0; bCovNeg[2]=0;
1201 }
1202
1203 dcaToVertexXYPos = bPos[0];
1204 dcaToVertexZPos = bPos[1];
1205 dcaToVertexXYNeg = bNeg[0];
1206 dcaToVertexZNeg = bNeg[1];
1207 }
1208
1209 fHistoMotherInvMassPt[fiCut]->Fill(etacand->M(),etacand->Pt());
1210 Double_t sparesFill[4] = {etacand->M(),etacand->Pt(),(Double_t)zbin,(Double_t)mbin};
1211 fTHnSparseMotherInvMassPtZM[fiCut]->Fill(sparesFill,1);
1212
1213 if ( fDoMesonQA ) {
1214 if( lGoodVirtualParticle[virtualParticleIndex] == kFALSE ) {
1215
899d014b 1216 fHistoNegPionEta[fiCut]->Fill( negPionVParticle->Eta() );
1217 fHistoPosPionEta[fiCut]->Fill( posPionVParticle->Eta() );
209b710e 1218
899d014b 1219 fHistoNegPionClsTPC[fiCut]->Fill(clsToFNeg,negPionVParticle->Pt());
1220 fHistoPosPionClsTPC[fiCut]->Fill(clsToFPos,posPionVParticle->Pt());
209b710e 1221
899d014b 1222 fHistoPionDCAxy[fiCut]->Fill( dcaToVertexXYNeg, negPionVParticle->Pt() );
1223 fHistoPionDCAz[fiCut]->Fill( dcaToVertexZNeg, negPionVParticle->Pt() );
1224 fHistoPionDCAxy[fiCut]->Fill( dcaToVertexXYPos, posPionVParticle->Pt() );
1225 fHistoPionDCAz[fiCut]->Fill( dcaToVertexZPos, posPionVParticle->Pt() );
209b710e 1226
899d014b 1227 fHistoPionTPCdEdxNSigma[fiCut]->Fill( posPionVParticle->P(),((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetPIDResponse()->NumberOfSigmasTPC(posPionVParticle, AliPID::kPion) );
1228 fHistoPionTPCdEdxNSigma[fiCut]->Fill( negPionVParticle->P(),((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetPIDResponse()->NumberOfSigmasTPC(negPionVParticle, AliPID::kPion) );
209b710e 1229
899d014b 1230 fHistoPionTPCdEdx[fiCut]->Fill( posPionVParticle->P(), TMath::Abs(posPionVParticle->GetTPCsignal()));
1231 fHistoPionTPCdEdx[fiCut]->Fill( negPionVParticle->P(), TMath::Abs(negPionVParticle->GetTPCsignal()));
209b710e 1232
1233 lGoodVirtualParticle[virtualParticleIndex] = kTRUE;
1234
1235 }
1236 }
1237
1238
1239 if(fMCEvent){
899d014b 1240 ProcessTrueMesonCandidates(etacand,gamma,vParticle);
209b710e 1241 }
1242 }
1243 delete etacand;
1244 etacand=0x0;
1245 }
1246 }
1247 }
1248}
1249
1250//________________________________________________________________________
1251void AliAnalysisTaskEtaToPiPlPiMiGamma::CalculateBackground(){
1252
1253 Int_t zbin= fBGHandler[fiCut]->GetZBinIndex(fESDEvent->GetPrimaryVertex()->GetZ());
1254 Int_t mbin = 0;
1255
1256
1257 if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
1258 mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fNumberOfESDTracks);
1259 } else {
1260 mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fGoodGammas->GetEntries());
1261 }
1262
1263 Int_t method = 1;
1264 AliGammaConversionAODBGHandler::GammaConversionVertex *bgEventVertex = NULL;
1265 if( ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity() ) {
1266 for(Int_t nEventsInBG=0;nEventsInBG<fBGHandler[fiCut]->GetNBGEvents();nEventsInBG++){
1267 AliGammaConversionAODVector *previousEventV0s = fBGHandler[fiCut]->GetBGGoodV0s(zbin,mbin,nEventsInBG);
1268 if(fMoveParticleAccordingToVertex == kTRUE && method == 1){
1269 bgEventVertex = fBGHandler[fiCut]->GetBGEventVertex(zbin,mbin,nEventsInBG);
1270 }
1271
1272 for(Int_t iCurrent=0;iCurrent<fGoodVirtualParticles->GetEntries();iCurrent++){
1273 AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fGoodVirtualParticles->At(iCurrent));
1274
1275 for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
1276 AliAODConversionPhoton previousGoodV0 = (AliAODConversionPhoton)(*(previousEventV0s->at(iPrevious)));
1277
1278 if(fMoveParticleAccordingToVertex == kTRUE && method == 1 ){
1279 MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
1280 }
1281
1282 AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&previousGoodV0);
1283
1284
344100c4 1285 if( ( ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(backgroundCandidate,kFALSE, ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
209b710e 1286 fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt());
1287 Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
1288 fTHnSparseMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,1);
1289 }
1290 delete backgroundCandidate;
1291 backgroundCandidate = 0x0;
1292 }
1293 }
1294 }
1295 } else {
1296 for(Int_t nEventsInBG=0;nEventsInBG <fBGHandler[fiCut]->GetNBGEvents();nEventsInBG++){
1297 AliGammaConversionAODVector *previousEventV0s = fBGHandler[fiCut]->GetBGGoodV0s(zbin,mbin,nEventsInBG);
1298 if(previousEventV0s){
1299 if(fMoveParticleAccordingToVertex == kTRUE && method == 1){
1300 bgEventVertex = fBGHandler[fiCut]->GetBGEventVertex(zbin,mbin,nEventsInBG);
1301 }
1302 for(Int_t iCurrent=0;iCurrent<fGoodVirtualParticles->GetEntries();iCurrent++){
1303
1304 AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fGoodVirtualParticles->At(iCurrent));
1305
1306 for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
1307
1308 AliAODConversionPhoton previousGoodV0 = (AliAODConversionPhoton)(*(previousEventV0s->at(iPrevious)));
1309
1310 if(fMoveParticleAccordingToVertex == kTRUE && method ==1){
1311 MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
1312 }
1313
1314 AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&previousGoodV0);
1315
344100c4 1316 if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(backgroundCandidate,kFALSE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
209b710e 1317 fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt());
1318 Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
1319 fTHnSparseMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,1);
1320 }
1321 delete backgroundCandidate;
1322 backgroundCandidate = 0x0;
1323 }
1324 }
1325 }
1326 }
1327 }
1328}
1329
1330//______________________________________________________________________
1331void AliAnalysisTaskEtaToPiPlPiMiGamma::ProcessTrueMesonCandidates(AliAODConversionMother *EtaCandidate, AliAODConversionPhoton *TrueGammaCandidate, AliAODConversionPhoton *TrueVirtualParticleCandidate){
1332
1333 // Process True Mesons
1334
1335 AliStack *MCStack = fMCEvent->Stack();
1336
1337 if( TrueGammaCandidate->GetV0Index()<fESDEvent->GetNumberOfV0s() ){
1338
1339 Bool_t isTrueEta = kFALSE;
1340 Int_t gammaMCLabel = TrueGammaCandidate->GetMCParticleLabel(MCStack);
1341 Int_t gammaMotherLabel = -1;
e13e00c9 1342// Bool_t gammaEtaCand = kFALSE;
209b710e 1343
1344 if(gammaMCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
1345 // Daughters Gamma 0
1346 TParticle * negativeMC = (TParticle*)TrueGammaCandidate->GetNegativeMCDaughter(MCStack);
1347 TParticle * positiveMC = (TParticle*)TrueGammaCandidate->GetPositiveMCDaughter(MCStack);
1348 TParticle * gammaMC = (TParticle*)MCStack->Particle(gammaMCLabel);
1349
1350 if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
1351 if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
1352 if(gammaMC->GetPdgCode() == 22){ // ... with Gamma Mother
1353 gammaMotherLabel=gammaMC->GetFirstMother();
e13e00c9 1354// if( ((TParticle*)MCStack->Particle(gammaMotherLabel))->GetNDaughters() == 3 && ((TParticle*)MCStack->Particle(gammaMotherLabel))->GetPdgCode() == 221 ) gammaEtaCand = kTRUE;
209b710e 1355 }
1356 }
1357 }
d9d6352b 1358
1359
209b710e 1360 }
1361
1362 Int_t virtualParticleMCLabel = TrueVirtualParticleCandidate->GetMCParticleLabel(MCStack);
1363 Int_t virtualParticleMotherLabel = -1;
1364
1365 Bool_t isPiPiDecay = kFALSE;
1366 Bool_t isDalitz = kFALSE;
1367 Bool_t isRealGamma = kFALSE;
1368
899d014b 1369 if (fDoMesonQA){
1370 TParticle * negativeMC = (TParticle*)TrueVirtualParticleCandidate->GetNegativeMCDaughter(MCStack);
1371 TParticle * positiveMC = (TParticle*)TrueVirtualParticleCandidate->GetPositiveMCDaughter(MCStack);
d9d6352b 1372// if (gammaEtaCand){
1373// cout << "neg Part: label - " << TrueVirtualParticleCandidate->GetMCLabelNegative() <<" pdg-code - " << negativeMC->GetPdgCode() << endl;
1374// cout << "pos Part: label - " << TrueVirtualParticleCandidate->GetMCLabelPositive() <<" pdg-code - " << positiveMC->GetPdgCode() << endl;
1375// }
899d014b 1376 if(TMath::Abs(negativeMC->GetPdgCode())==211 && TMath::Abs(positiveMC->GetPdgCode())==211){ // Pions ...
1377 fHistoTruePionPionInvMassPt[fiCut]->Fill(TrueVirtualParticleCandidate->GetMass(),TrueVirtualParticleCandidate->Pt());
1378 }
1379 }
1380
209b710e 1381 if(virtualParticleMCLabel != -1){ // if virtualParticleMCLabel==-1 particles don't have same mother
1382 TParticle * negativeMC = (TParticle*)TrueVirtualParticleCandidate->GetNegativeMCDaughter(MCStack);
1383 TParticle * positiveMC = (TParticle*)TrueVirtualParticleCandidate->GetPositiveMCDaughter(MCStack);
209b710e 1384 TParticle * virtualParticleMotherMC = (TParticle*)MCStack->Particle(virtualParticleMCLabel);
1385// cout << "pdg code same mother - " << virtualParticleMotherMC->GetPdgCode() << endl;
1386
1387 if(TMath::Abs(negativeMC->GetPdgCode())==211 && TMath::Abs(positiveMC->GetPdgCode())==211){ // Pions ...
1388 virtualParticleMotherLabel=virtualParticleMCLabel;
1389 isPiPiDecay=kTRUE;
1390 } else if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
1391 if( virtualParticleMotherMC->GetPdgCode() != 22 ){
1392 virtualParticleMotherLabel=virtualParticleMCLabel;
1393 isDalitz = kTRUE;
1394 } else if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
1395 virtualParticleMotherLabel=virtualParticleMotherMC->GetFirstMother();
1396 isRealGamma = kTRUE; //no virtual gamma
1397 }
1398 }
1399 }
1400
1401 if(gammaMotherLabel >= 0 && ( gammaMotherLabel == virtualParticleMotherLabel) ){
1402 if(((TParticle*)MCStack->Particle(virtualParticleMotherLabel))->GetPdgCode() == 221){
1403 isTrueEta=kTRUE;
1404 }
1405 }
1406
1407 if( isTrueEta ){ // True Eta
1408 if ( isPiPiDecay) { //real eta -> Pi+ Pi- Gamma
1409 Float_t weighted= 1;
1410 if( ((AliPrimaryPionCuts*) fPionCutArray->At(fiCut))->DoWeights() ) {
344100c4 1411 if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gammaMotherLabel, fMCStack,fInputEvent)){
209b710e 1412 if (((TParticle*)MCStack->Particle(gammaMotherLabel))->Pt()>0.005){
344100c4 1413 weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),gammaMotherLabel,fMCStack,fInputEvent);
209b710e 1414 }
1415 }
1416 }
899d014b 1417 fHistoTruePionPionFromEtaInvMassPt[fiCut]->Fill(TrueVirtualParticleCandidate->GetMass(),TrueVirtualParticleCandidate->Pt());
209b710e 1418 fHistoTrueMotherPiPlPiMiGammaInvMassPt[fiCut]->Fill(EtaCandidate->M(),EtaCandidate->Pt(),weighted);
1419 } else if ( isRealGamma ){
1420 Float_t weighted= 1;
1421 if( ((AliPrimaryPionCuts*) fPionCutArray->At(fiCut))->DoWeights() ) {
344100c4 1422 if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gammaMotherLabel, fMCStack,fInputEvent)){
209b710e 1423 if (((TParticle*)MCStack->Particle(gammaMotherLabel))->Pt()>0.005){
344100c4 1424 weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),gammaMotherLabel,fMCStack,fInputEvent);
209b710e 1425 }
1426 }
1427 }
1428
1429 fHistoTrueMotherGammaGammaInvMassPt[fiCut]->Fill(EtaCandidate->M(),EtaCandidate->Pt(),weighted);
1430 } else if (isDalitz) {
1431 Float_t weighted= 1;
1432 if( ((AliPrimaryPionCuts*) fPionCutArray->At(fiCut))->DoWeights() ) {
344100c4 1433 if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gammaMotherLabel, fMCStack,fInputEvent)){
209b710e 1434 if (((TParticle*)MCStack->Particle(gammaMotherLabel))->Pt()>0.005){
344100c4 1435 weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),gammaMotherLabel,fMCStack,fInputEvent);
209b710e 1436 }
1437 }
1438 }
1439 fHistoTrueMotherDalitzInvMassPt[fiCut]->Fill(EtaCandidate->M(),EtaCandidate->Pt(),weighted);
1440 }
1441 }
1442 }
1443}
1444
1445
1446//________________________________________________________________________
1447void AliAnalysisTaskEtaToPiPlPiMiGamma::UpdateEventByEventData(){
1448 //see header file for documentation
1449
1450 Int_t method = 1;
1451 if( method == 1 ) {
1452 if(fGoodGammas->GetEntries() >0 ){
1453 if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
1454 fBGHandler[fiCut]->AddEvent(fGoodGammas,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fV0Reader->GetNumberOfPrimaryTracks(),0);
1455 } else{ // means we use #V0s for multiplicity
1456 fBGHandler[fiCut]->AddEvent(fGoodGammas,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fGoodGammas->GetEntries(),0);
1457 }
1458 }
1459 } else if ( method == 2 ){
1460 if(fGoodVirtualParticles->GetEntries() > 0 ){
1461 if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
1462 fBGHandler[fiCut]->AddEvent(fGoodVirtualParticles,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fV0Reader->GetNumberOfPrimaryTracks(),0);
1463 } else{ // means we use #V0s for multiplicity
1464 fBGHandler[fiCut]->AddEvent(fGoodVirtualParticles,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fGoodVirtualParticles->GetEntries(),0);
1465 }
1466 }
1467 }
1468}
1469
1470//________________________________________________________________________
1471void AliAnalysisTaskEtaToPiPlPiMiGamma::MoveParticleAccordingToVertex(AliAODConversionPhoton* particle,const AliGammaConversionAODBGHandler::GammaConversionVertex *vertex){
1472 //see header file for documentation
1473
1474 Double_t dx = vertex->fX - fInputEvent->GetPrimaryVertex()->GetX();
1475 Double_t dy = vertex->fY - fInputEvent->GetPrimaryVertex()->GetY();
1476 Double_t dz = vertex->fZ - fInputEvent->GetPrimaryVertex()->GetZ();
1477
1478 Double_t movedPlace[3] = {particle->GetConversionX() - dx,particle->GetConversionY() - dy,particle->GetConversionZ() - dz};
1479 particle->SetConversionPoint(movedPlace);
1480}
1481
1482//_____________________________________________________________________________________
1483Bool_t AliAnalysisTaskEtaToPiPlPiMiGamma::IsEtaPiPlPiMiGammaDaughter( Int_t label ) const {
1484//
1485// Returns true if the particle comes from eta -> pi+ pi- gamma
1486//
1487 Int_t motherLabel = fMCStack->Particle( label )->GetMother(0);
1488 if( motherLabel < 0 || motherLabel >= fMCStack->GetNtrack() ) return kFALSE;
1489
1490 TParticle* mother = fMCStack->Particle( motherLabel );
1491 if( mother->GetPdgCode() != 221 ) return kFALSE;
1492 if( IsPiPlPiMiGammaDecay( mother ) ) return kTRUE;
1493 return kFALSE;
1494}
1495
1496//_____________________________________________________________________________
1497Bool_t AliAnalysisTaskEtaToPiPlPiMiGamma::IsPiPlPiMiGammaDecay(TParticle *fMCMother) const
1498{
1499
1500 if( fMCMother->GetNDaughters() != 3 ) return kFALSE;
1501 if( fMCMother->GetPdgCode() != 221 ) return kFALSE;
1502
1503
1504 TParticle *posPion = 0x0;
1505 TParticle *negPion = 0x0;
1506 TParticle *gamma = 0x0;
1507
1508 for(Int_t index= fMCMother->GetFirstDaughter();index<= fMCMother->GetLastDaughter();index++){
1509 TParticle* temp = (TParticle*)fMCStack->Particle( index );
1510
1511 switch( temp->GetPdgCode() ) {
1512 case 211:
1513 posPion = temp;
1514 break;
1515 case -211:
1516 negPion = temp;
1517 break;
1518 case ::kGamma:
1519 gamma = temp;
1520 break;
1521 }
1522 }
1523
1524 if( posPion && negPion && gamma) return kTRUE;
1525
1526 return kFALSE;
1527}