Added possibility to not create aod tclones branch
[u/mrichter/AliRoot.git] / PWG4 / GammaConv / AliAnalysisTaskGammaConversion.cxx
CommitLineData
d7d7e825 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: Ana Marin, Kathrin Koch, Kenneth Aamodt *
5 * Version 1.1 *
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
16////////////////////////////////////////////////
17//---------------------------------------------
18// Class used to do analysis on conversion pairs
19//---------------------------------------------
20////////////////////////////////////////////////
21
22// root
23#include <TChain.h>
24
25// analysis
26#include "AliAnalysisTaskGammaConversion.h"
27#include "AliStack.h"
28#include "AliLog.h"
29#include "AliESDtrackCuts.h"
30#include "TNtuple.h"
4a6157dc 31//#include "AliCFManager.h" // for CF
32//#include "AliCFContainer.h" // for CF
9c1cb6f7 33#include "AliESDInputHandler.h"
34#include "AliAnalysisManager.h"
6441e967 35#include "AliAODPWG4Particle.h"
36#include "AliAODPWG4ParticleCorrelation.h"
4a6157dc 37#include "AliGammaConversionAODObject.h"
6441e967 38#include "AliAODConversionParticle.h"
5e55d806 39#include "AliGammaConversionBGHandler.h"
6272370b 40#include "AliESDCaloCluster.h" // for combining PHOS and GammaConv
9c1cb6f7 41#include "AliKFVertex.h"
3c45d101 42#include "AliGenPythiaEventHeader.h"
43#include "AliGenDPMjetEventHeader.h"
44#include "AliGenEventHeader.h"
e60f3265 45#include <AliMCEventHandler.h>
77ac6f3e 46#include "TRandom3.h"
18a1e325 47#include "AliTriggerAnalysis.h"
64f4118c 48#include "AliESDCentrality.h"
77ac6f3e 49
d707e3cf 50class AliESDTrackCuts;
4a6157dc 51class AliCFContainer;
52class AliCFManager;
d7d7e825 53class AliKFVertex;
54class AliAODHandler;
55class AliAODEvent;
56class ALiESDEvent;
57class AliMCEvent;
58class AliMCEventHandler;
59class AliESDInputHandler;
60class AliAnalysisManager;
61class Riostream;
62class TFile;
63class TInterpreter;
64class TSystem;
65class TROOT;
66
67ClassImp(AliAnalysisTaskGammaConversion)
68
69
70AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion():
71AliAnalysisTaskSE(),
72 fV0Reader(NULL),
73 fStack(NULL),
a0b94e5c 74 fMCTruth(NULL), // for CF
4a6157dc 75 fGCMCEvent(NULL), // for CF
d7d7e825 76 fESDEvent(NULL),
77 fOutputContainer(NULL),
a0b94e5c 78 fCFManager(0x0), // for CF
d7d7e825 79 fHistograms(NULL),
b5832f95 80 fTriggerCINT1B(kFALSE),
d7d7e825 81 fDoMCTruth(kFALSE),
82 fDoNeutralMeson(kFALSE),
6272370b 83 fDoOmegaMeson(kFALSE),
d7d7e825 84 fDoJet(kFALSE),
85 fDoChic(kFALSE),
9c1cb6f7 86 fRecalculateV0ForGamma(kFALSE),
6c84d371 87 fKFReconstructedGammasTClone(NULL),
6272370b 88 fKFReconstructedPi0sTClone(NULL),
9c1cb6f7 89 fKFRecalculatedGammasTClone(NULL),
6c84d371 90 fCurrentEventPosElectronTClone(NULL),
91 fCurrentEventNegElectronTClone(NULL),
92 fKFReconstructedGammasCutTClone(NULL),
93 fPreviousEventTLVNegElectronTClone(NULL),
94 fPreviousEventTLVPosElectronTClone(NULL),
d7d7e825 95 fElectronv1(),
96 fElectronv2(),
6272370b 97 fGammav1(),
98 fGammav2(),
9c1cb6f7 99 fElectronRecalculatedv1(),
100 fElectronRecalculatedv2(),
d7d7e825 101 fElectronMass(-1),
102 fGammaMass(-1),
103 fPi0Mass(-1),
104 fEtaMass(-1),
105 fGammaWidth(-1),
106 fPi0Width(-1),
107 fEtaWidth(-1),
108 fMinOpeningAngleGhostCut(0.),
9640a3d1 109 fEsdTrackCuts(NULL),
d7d7e825 110 fCalculateBackground(kFALSE),
111 fWriteNtuple(kFALSE),
112 fGammaNtuple(NULL),
113 fNeutralMesonNtuple(NULL),
114 fTotalNumberOfAddedNtupleEntries(0),
6c84d371 115 fChargedParticles(NULL),
d7d7e825 116 fChargedParticlesId(),
117 fGammaPtHighest(0.),
118 fMinPtForGammaJet(1.),
119 fMinIsoConeSize(0.2),
120 fMinPtIsoCone(0.7),
121 fMinPtGamChargedCorr(0.5),
122 fMinPtJetCone(0.5),
123 fLeadingChargedIndex(-1),
9640a3d1 124 fLowPtMapping(1.),
125 fHighPtMapping(3.),
1e7846f4 126 fDoCF(kFALSE),
04bf4381 127 fAODGamma(NULL),
128 fAODPi0(NULL),
129 fAODOmega(NULL),
037dc2db 130 fAODBranchName("GammaConv"),
6441e967 131 fOutputAODClassName("AliAODConversionParticle"),
63477d82 132 fKFCreateAOD(kTRUE),
d765d400 133 fKFForceAOD(kFALSE),
332f1f44 134 fKFDeltaAODFileName(""),
037dc2db 135 fDoNeutralMesonV0MCCheck(kFALSE),
5ce758b0 136 fUseTrackMultiplicityForBG(kTRUE),
137 fMoveParticleAccordingToVertex(kFALSE),
2e2da371 138 fApplyChi2Cut(kFALSE),
77ac6f3e 139 fNRandomEventsForBG(15),
140 fNDegreesPMBackground(15),
111d75df 141 fDoRotation(kTRUE),
142 fCheckBGProbability(kTRUE),
2f426a53 143 fKFReconstructedGammasV0Index(),
18a1e325 144 fRemovePileUp(kFALSE),
145 fSelectV0AND(kFALSE),
6746e1e1 146 fTriggerAnalysis(NULL),
147 fMultiplicity(0),
148 fUseMultiplicity(0),
64f4118c 149 fUseMultiplicityBin(0),
150 fUseCentrality(0),
151 fUseCentralityBin(0)
d7d7e825 152{
153 // Default constructor
5a34881d 154
155 /* Kenneth: the default constructor should not have any define input/output or the call to SetESDtrackCuts
d7d7e825 156 // Common I/O in slot 0
157 DefineInput (0, TChain::Class());
158 DefineOutput(0, TTree::Class());
159
160 // Your private output
161 DefineOutput(1, TList::Class());
a0b94e5c 162
d7d7e825 163 // Define standard ESD track cuts for Gamma-hadron correlation
164 SetESDtrackCuts();
5a34881d 165 */
d7d7e825 166}
167
168AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion(const char* name):
169 AliAnalysisTaskSE(name),
170 fV0Reader(NULL),
171 fStack(NULL),
a0b94e5c 172 fMCTruth(NULL), // for CF
4a6157dc 173 fGCMCEvent(NULL), // for CF
d7d7e825 174 fESDEvent(NULL),
175 fOutputContainer(0x0),
a0b94e5c 176 fCFManager(0x0), // for CF
d7d7e825 177 fHistograms(NULL),
b5832f95 178 fTriggerCINT1B(kFALSE),
d7d7e825 179 fDoMCTruth(kFALSE),
180 fDoNeutralMeson(kFALSE),
6272370b 181 fDoOmegaMeson(kFALSE),
d7d7e825 182 fDoJet(kFALSE),
183 fDoChic(kFALSE),
9c1cb6f7 184 fRecalculateV0ForGamma(kFALSE),
6c84d371 185 fKFReconstructedGammasTClone(NULL),
6272370b 186 fKFReconstructedPi0sTClone(NULL),
9c1cb6f7 187 fKFRecalculatedGammasTClone(NULL),
6c84d371 188 fCurrentEventPosElectronTClone(NULL),
189 fCurrentEventNegElectronTClone(NULL),
190 fKFReconstructedGammasCutTClone(NULL),
191 fPreviousEventTLVNegElectronTClone(NULL),
192 fPreviousEventTLVPosElectronTClone(NULL),
d7d7e825 193 fElectronv1(),
194 fElectronv2(),
6272370b 195 fGammav1(),
196 fGammav2(),
9c1cb6f7 197 fElectronRecalculatedv1(),
198 fElectronRecalculatedv2(),
d7d7e825 199 fElectronMass(-1),
200 fGammaMass(-1),
201 fPi0Mass(-1),
202 fEtaMass(-1),
203 fGammaWidth(-1),
204 fPi0Width(-1),
205 fEtaWidth(-1),
206 fMinOpeningAngleGhostCut(0.),
9640a3d1 207 fEsdTrackCuts(NULL),
d7d7e825 208 fCalculateBackground(kFALSE),
209 fWriteNtuple(kFALSE),
210 fGammaNtuple(NULL),
211 fNeutralMesonNtuple(NULL),
212 fTotalNumberOfAddedNtupleEntries(0),
6c84d371 213 fChargedParticles(NULL),
d7d7e825 214 fChargedParticlesId(),
215 fGammaPtHighest(0.),
216 fMinPtForGammaJet(1.),
217 fMinIsoConeSize(0.2),
218 fMinPtIsoCone(0.7),
219 fMinPtGamChargedCorr(0.5),
220 fMinPtJetCone(0.5),
221 fLeadingChargedIndex(-1),
9640a3d1 222 fLowPtMapping(1.),
223 fHighPtMapping(3.),
c59360eb 224 fDoCF(kFALSE),
225 fAODGamma(NULL),
226 fAODPi0(NULL),
227 fAODOmega(NULL),
228 fAODBranchName("GammaConv"),
6441e967 229 fOutputAODClassName("AliAODConversionParticle"),
63477d82 230 fKFCreateAOD(kTRUE),
c59360eb 231 fKFForceAOD(kFALSE),
232 fKFDeltaAODFileName(""),
233 fDoNeutralMesonV0MCCheck(kFALSE),
5ce758b0 234 fUseTrackMultiplicityForBG(kTRUE),
235 fMoveParticleAccordingToVertex(kFALSE),
2e2da371 236 fApplyChi2Cut(kFALSE),
77ac6f3e 237 fNRandomEventsForBG(15),
238 fNDegreesPMBackground(15),
111d75df 239 fDoRotation(kTRUE),
240 fCheckBGProbability(kTRUE),
2f426a53 241 fKFReconstructedGammasV0Index(),
18a1e325 242 fRemovePileUp(kFALSE),
243 fSelectV0AND(kFALSE),
6746e1e1 244 fTriggerAnalysis(NULL),
245 fMultiplicity(0),
246 fUseMultiplicity(0),
64f4118c 247 fUseMultiplicityBin(0),
248 fUseCentrality(0),
249 fUseCentralityBin(0)
d7d7e825 250{
251 // Common I/O in slot 0
252 DefineInput (0, TChain::Class());
253 DefineOutput(0, TTree::Class());
254
255 // Your private output
256 DefineOutput(1, TList::Class());
a0b94e5c 257 DefineOutput(2, AliCFContainer::Class()); // for CF
258
259
d7d7e825 260 // Define standard ESD track cuts for Gamma-hadron correlation
261 SetESDtrackCuts();
9c1cb6f7 262
d7d7e825 263}
264
265AliAnalysisTaskGammaConversion::~AliAnalysisTaskGammaConversion()
266{
267 // Remove all pointers
268
269 if(fOutputContainer){
270 fOutputContainer->Clear() ;
271 delete fOutputContainer ;
272 }
273 if(fHistograms){
274 delete fHistograms;
275 }
276 if(fV0Reader){
277 delete fV0Reader;
278 }
a0b94e5c 279
280 // for CF
281 if(fCFManager){
282 delete fCFManager;
283 }
9640a3d1 284
285 if(fEsdTrackCuts){
286 delete fEsdTrackCuts;
287 }
288
04bf4381 289 //Delete AODs
290 if (fAODGamma) {
291 fAODGamma->Clear();
292 delete fAODGamma;
d7d7e825 293 }
04bf4381 294 fAODGamma = NULL;
295
296 if (fAODPi0) {
297 fAODPi0->Clear();
298 delete fAODPi0;
299 }
300 fAODPi0 = NULL;
d7d7e825 301
04bf4381 302 if (fAODOmega) {
303 fAODOmega->Clear();
304 delete fAODOmega;
305 }
306 fAODOmega = NULL;
307
18a1e325 308 if(fTriggerAnalysis) {
309 delete fTriggerAnalysis;
310 }
311
312
04bf4381 313}
d7d7e825 314
12464034 315
d7d7e825 316void AliAnalysisTaskGammaConversion::Init()
317{
318 // Initialization
4a6157dc 319 // AliLog::SetGlobalLogLevel(AliLog::kError);
d7d7e825 320}
321void AliAnalysisTaskGammaConversion::SetESDtrackCuts()
322{
323 // SetESDtrackCuts
9640a3d1 324 if (fEsdTrackCuts!=NULL){
325 delete fEsdTrackCuts;
326 }
d7d7e825 327 fEsdTrackCuts = new AliESDtrackCuts("AliESDtrackCuts");
a0b94e5c 328 //standard cuts from:
329 //http://aliceinfo.cern.ch/alicvs/viewvc/PWG0/dNdEta/CreateCuts.C?revision=1.4&view=markup
ebcfaa7e 330
331 // Cuts used up to 3rd of March
332
333 // fEsdTrackCuts->SetMinNClustersTPC(50);
334// fEsdTrackCuts->SetMaxChi2PerClusterTPC(3.5);
335// fEsdTrackCuts->SetRequireTPCRefit(kTRUE);
336// fEsdTrackCuts->SetRequireITSRefit(kTRUE);
337// fEsdTrackCuts->SetMaxNsigmaToVertex(3);
338// fEsdTrackCuts->SetRequireSigmaToVertex(kTRUE);
339
340 //------- To be tested-----------
d707e3cf 341 // Cuts used up to 26th of Agost
342// Int_t minNClustersTPC = 70;
343// Double_t maxChi2PerClusterTPC = 4.0;
344// Double_t maxDCAtoVertexXY = 2.4; // cm
345// Double_t maxDCAtoVertexZ = 3.2; // cm
346// fEsdTrackCuts->SetRequireSigmaToVertex(kFALSE);
347// fEsdTrackCuts->SetRequireTPCRefit(kTRUE);
348// fEsdTrackCuts->SetRequireITSRefit(kTRUE);
349// // fEsdTrackCuts->SetRequireTPCStandAlone(kTRUE);
350// fEsdTrackCuts->SetAcceptKinkDaughters(kFALSE);
351// fEsdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
352// fEsdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
353// fEsdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
354// fEsdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
355// fEsdTrackCuts->SetDCAToVertex2D(kTRUE);
356// fEsdTrackCuts->SetEtaRange(-0.8, 0.8);
357// fEsdTrackCuts->SetPtRange(0.15);
358
359// fEsdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kFirst);
360
361
362// Using standard function for setting Cuts
363 Bool_t selectPrimaries=kTRUE;
406a77e0 364 fEsdTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(selectPrimaries);
64f4118c 365 fEsdTrackCuts->SetMaxDCAToVertexZ(2);
d707e3cf 366 fEsdTrackCuts->SetEtaRange(-0.8, 0.8);
367 fEsdTrackCuts->SetPtRange(0.15);
ebcfaa7e 368
369 //----- From Jacek 10.03.03 ------------------/
370// minNClustersTPC = 70;
371// maxChi2PerClusterTPC = 4.0;
372// maxDCAtoVertexXY = 2.4; // cm
373// maxDCAtoVertexZ = 3.2; // cm
374
375// esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
376// esdTrackCuts->SetRequireTPCRefit(kFALSE);
377// esdTrackCuts->SetRequireTPCStandAlone(kTRUE);
378// esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
379// esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
380// esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
381// esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
382// esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
383// esdTrackCuts->SetDCAToVertex2D(kTRUE);
384
385
386
d7d7e825 387 // fEsdTrackCuts->SetAcceptKinkDaughters(kFALSE);
037dc2db 388 // fV0Reader->SetESDtrackCuts(fEsdTrackCuts);
d7d7e825 389}
390
c00009fb 391void AliAnalysisTaskGammaConversion::UserExec(Option_t */*option*/)
d7d7e825 392{
393 // Execute analysis for current event
6272370b 394
9c1cb6f7 395 // Load the esdpid from the esdhandler if exists (tender was applied) otherwise set the Bethe Bloch parameters
3c45d101 396 Int_t eventQuality=-1;
9c1cb6f7 397
398 AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
399 AliESDInputHandler *esdHandler=0x0;
400 if ( (esdHandler=dynamic_cast<AliESDInputHandler*>(man->GetInputEventHandler())) && esdHandler->GetESDpid() ){
401 AliV0Reader::SetESDpid(esdHandler->GetESDpid());
402 } else {
403 //load esd pid bethe bloch parameters depending on the existance of the MC handler
404 // yes: MC parameters
405 // no: data parameters
406 if (!AliV0Reader::GetESDpid()){
407 if (fMCEvent ) {
408 AliV0Reader::InitESDpid();
409 } else {
410 AliV0Reader::InitESDpid(1);
411 }
412 }
413 }
414
d765d400 415 //Must set fForceAOD to true for the AOD to get filled. Should only be done when running independent chain / train.
416 if(fKFForceAOD) {
417 if (!AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()) AliFatal("Cannot run ESD filter without an output event handler");
418 AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kTRUE);
419 }
48682642 420
421 if(fV0Reader == NULL){
422 // Write warning here cuts and so on are default if this ever happens
6272370b 423 }
48682642 424
e60f3265 425 if (fMCEvent ) {
426 // To avoid crashes due to unzip errors. Sometimes the trees are not there.
427
428 AliMCEventHandler* mcHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
3c45d101 429 if (!mcHandler){
430 AliError("Could not retrive MC event handler!");
431 return;
432
433 eventQuality=0;
434 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
435 }
436 if (!mcHandler->InitOk() ){
437 eventQuality=0;
438 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
439 return;
440 }
441 if (!mcHandler->TreeK() ){
442 eventQuality=0;
443 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
444 return;
445 }
446 if (!mcHandler->TreeTR() ) {
447 eventQuality=0;
448 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
449 return;
450 }
e60f3265 451 }
452
48682642 453 fV0Reader->SetInputAndMCEvent(InputEvent(), MCEvent());
454
455 fV0Reader->Initialize();
456 fDoMCTruth = fV0Reader->GetDoMCTruth();
457
12464034 458 if(fAODGamma) fAODGamma->Delete();
459 if(fAODPi0) fAODPi0->Delete();
460 if(fAODOmega) fAODOmega->Delete();
a0b94e5c 461
6c84d371 462 if(fKFReconstructedGammasTClone == NULL){
463 fKFReconstructedGammasTClone = new TClonesArray("AliKFParticle",0);
464 }
465 if(fCurrentEventPosElectronTClone == NULL){
466 fCurrentEventPosElectronTClone = new TClonesArray("AliESDtrack",0);
467 }
468 if(fCurrentEventNegElectronTClone == NULL){
469 fCurrentEventNegElectronTClone = new TClonesArray("AliESDtrack",0);
470 }
471 if(fKFReconstructedGammasCutTClone == NULL){
472 fKFReconstructedGammasCutTClone = new TClonesArray("AliKFParticle",0);
473 }
474 if(fPreviousEventTLVNegElectronTClone == NULL){
475 fPreviousEventTLVNegElectronTClone = new TClonesArray("TLorentzVector",0);
476 }
477 if(fPreviousEventTLVPosElectronTClone == NULL){
478 fPreviousEventTLVPosElectronTClone = new TClonesArray("TLorentzVector",0);
479 }
480 if(fChargedParticles == NULL){
481 fChargedParticles = new TClonesArray("AliESDtrack",0);
482 }
6272370b 483
484 if(fKFReconstructedPi0sTClone == NULL){
485 fKFReconstructedPi0sTClone = new TClonesArray("AliKFParticle",0);
486 }
9c1cb6f7 487
18a1e325 488 if(fKFRecalculatedGammasTClone == NULL){
9c1cb6f7 489 fKFRecalculatedGammasTClone = new TClonesArray("AliKFParticle",0);
490 }
491
18a1e325 492 if(fTriggerAnalysis== NULL){
493 fTriggerAnalysis = new AliTriggerAnalysis;
494 }
495
6c84d371 496 //clear TClones
1e7846f4 497 fKFReconstructedGammasTClone->Delete();
498 fCurrentEventPosElectronTClone->Delete();
499 fCurrentEventNegElectronTClone->Delete();
500 fKFReconstructedGammasCutTClone->Delete();
501 fPreviousEventTLVNegElectronTClone->Delete();
502 fPreviousEventTLVPosElectronTClone->Delete();
6272370b 503 fKFReconstructedPi0sTClone->Delete();
9c1cb6f7 504 fKFRecalculatedGammasTClone->Delete();
5e55d806 505
d7d7e825 506 //clear vectors
d7d7e825 507 fElectronv1.clear();
508 fElectronv2.clear();
6272370b 509
510 fGammav1.clear();
511 fGammav2.clear();
512
9c1cb6f7 513 fElectronRecalculatedv1.clear();
514 fElectronRecalculatedv2.clear();
515
d7d7e825 516
1e7846f4 517 fChargedParticles->Delete();
5e55d806 518
d7d7e825 519 fChargedParticlesId.clear();
037dc2db 520
521 fKFReconstructedGammasV0Index.clear();
a0b94e5c 522
d7d7e825 523 //Clear the data in the v0Reader
5e55d806 524 // fV0Reader->UpdateEventByEventData();
b5832f95 525
526 //Take Only events with proper trigger
5e55d806 527 /*
b5832f95 528 if(fTriggerCINT1B){
529 if(!fV0Reader->GetESDEvent()->IsTriggerClassFired("CINT1B-ABCE-NOPF-ALL")) return;
530 }
5e55d806 531 */
10e3319b 532
c8206114 533 if(fV0Reader->CheckForPrimaryVertex() == kFALSE){
534 // cout<< "Event not taken"<< endl;
3c45d101 535 eventQuality=1;
536 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
537 if(fDoMCTruth){
538 CheckMesonProcessTypeEventQuality(eventQuality);
539 }
c8206114 540 return; // aborts if the primary vertex does not have contributors.
541 }
542
543
885114d1 544 if(!fV0Reader->CheckForPrimaryVertexZ() ){
3c45d101 545 eventQuality=2;
546 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
547 if(fDoMCTruth){
548 CheckMesonProcessTypeEventQuality(eventQuality);
549 }
885114d1 550 return;
551 }
2f426a53 552
553 if(fRemovePileUp && fV0Reader->GetESDEvent()->IsPileupFromSPD()) {
0a3d9f49 554 eventQuality=4;
45441b78 555 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
2f426a53 556 return;
557 }
18a1e325 558
18a1e325 559 Bool_t v0A = fTriggerAnalysis->IsOfflineTriggerFired(fV0Reader->GetESDEvent(), AliTriggerAnalysis::kV0A);
560 Bool_t v0C = fTriggerAnalysis->IsOfflineTriggerFired(fV0Reader->GetESDEvent(), AliTriggerAnalysis::kV0C);
561 Bool_t v0AND = v0A && v0C;
562
563 if(fSelectV0AND && !v0AND){
564 eventQuality=5;
45441b78 565 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
18a1e325 566 return;
567 }
6746e1e1 568 fMultiplicity = fEsdTrackCuts->CountAcceptedTracks(fV0Reader->GetESDEvent());
569
570 if( CalculateMultiplicityBin() != fUseMultiplicityBin){
571 eventQuality=6;
572 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
573 return;
574 }
18a1e325 575
64f4118c 576 if(fV0Reader->GetIsHeavyIon()){
577 if(fUseCentrality>0){
578 AliESDCentrality *esdCentrality = fV0Reader->GetESDEvent()->GetCentrality();
579 Int_t centralityC = -1;
580
581 if(fUseCentrality==1){
582 centralityC = esdCentrality->GetCentralityClass10("V0M");
583 if( centralityC != fUseCentralityBin ){
584 eventQuality=7;
585 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
586 return;
587 }
588 }
589
590 if(fUseCentrality==2){
591 centralityC = esdCentrality->GetCentralityClass10("CL1");
592 if( centralityC != fUseCentralityBin ){
593 eventQuality=7;
594 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
595 return;
596 }
597 }
598 }
599 }
3c45d101 600 eventQuality=3;
601 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
885114d1 602
6746e1e1 603
604
605 fHistograms->FillHistogram("ESD_NumberOfGoodESDTracks",fMultiplicity);
606 if (fV0Reader->GetNumberOfContributorsVtx()>=1){
607 fHistograms->FillHistogram("ESD_NumberOfGoodESDTracksVtx",fMultiplicity);
608 }
609
610
611
d7d7e825 612 // Process the MC information
613 if(fDoMCTruth){
614 ProcessMCData();
615 }
a0b94e5c 616
d7d7e825 617 //Process the v0 information with no cuts
618 ProcessV0sNoCut();
cb90a330 619
d7d7e825 620 // Process the v0 information
621 ProcessV0s();
cb90a330 622
5e55d806 623
d7d7e825 624 //Fill Gamma AOD
63477d82 625 if(fKFCreateAOD) {
626 FillAODWithConversionGammas() ;
627 }
628
629
d7d7e825 630 // Process reconstructed gammas
631 if(fDoNeutralMeson == kTRUE){
a0b94e5c 632 ProcessGammasForNeutralMesonAnalysis();
77880bd8 633
48682642 634 }
635
77880bd8 636 if(fDoMCTruth == kTRUE){
637 CheckV0Efficiency();
638 }
d7d7e825 639 //Process reconstructed gammas electrons for Chi_c Analysis
6c84d371 640 if(fDoChic == kTRUE){
d7d7e825 641 ProcessGammaElectronsForChicAnalysis();
642 }
643 // Process reconstructed gammas for gamma Jet/hadron correlations
644 if(fDoJet == kTRUE){
645 ProcessGammasForGammaJetAnalysis();
646 }
a0b94e5c 647
5e55d806 648 //calculate background if flag is set
649 if(fCalculateBackground){
650 CalculateBackground();
651 }
48682642 652
653 if(fDoNeutralMeson == kTRUE){
654// ProcessConvPHOSGammasForNeutralMesonAnalysis();
655 if(fDoOmegaMeson == kTRUE){
656 ProcessGammasForOmegaMesonAnalysis();
657 }
658 }
659
5e55d806 660 //Clear the data in the v0Reader
661 fV0Reader->UpdateEventByEventData();
9c1cb6f7 662 if(fRecalculateV0ForGamma==kTRUE){
663 RecalculateV0ForGamma();
664 }
d7d7e825 665 PostData(1, fOutputContainer);
a0b94e5c 666 PostData(2, fCFManager->GetParticleContainer()); // for CF
d7d7e825 667
668}
669
48682642 670// void AliAnalysisTaskGammaConversion::ConnectInputData(Option_t *option){
671// // see header file for documentation
672// // printf(" ConnectInputData %s\n", GetName());
8a685cf3 673
48682642 674// AliAnalysisTaskSE::ConnectInputData(option);
8a685cf3 675
48682642 676// if(fV0Reader == NULL){
677// // Write warning here cuts and so on are default if this ever happens
678// }
679// fV0Reader->Initialize();
680// fDoMCTruth = fV0Reader->GetDoMCTruth();
681// }
d7d7e825 682
3c45d101 683void AliAnalysisTaskGammaConversion::CheckMesonProcessTypeEventQuality(Int_t evtQ){
77ac6f3e 684 // Check meson process type event quality
3c45d101 685 fStack= MCEvent()->Stack();
686 fGCMCEvent=MCEvent();
687
688 for (Int_t iTracks = 0; iTracks < fStack->GetNprimary(); iTracks++) {
689 TParticle* particle = (TParticle *)fStack->Particle(iTracks);
690 if (!particle) {
691 //print warning here
692 continue;
693 }
694 if(particle->GetPdgCode()!=111){ //Pi0
695 continue;
696 }
697 if(TMath::Abs(particle->Eta())> fV0Reader->GetEtaCut() ) continue;
698 if(evtQ==1){
699 switch(GetProcessType(fGCMCEvent)){
700 case kProcSD:
701 fHistograms->FillHistogram("MC_SD_EvtQ1_Pi0_Pt", particle->Pt());
702 break;
703 case kProcDD:
704 fHistograms->FillHistogram("MC_DD_EvtQ1_Pi0_Pt", particle->Pt());
705 break;
706 case kProcND:
707 fHistograms->FillHistogram("MC_ND_EvtQ1_Pi0_Pt", particle->Pt());
708 break;
709 default:
710 AliError("Unknown Process");
711 }
712 }
713 if(evtQ==2){
714 switch(GetProcessType(fGCMCEvent)){
715 case kProcSD:
716 fHistograms->FillHistogram("MC_SD_EvtQ2_Pi0_Pt", particle->Pt());
717 break;
718 case kProcDD:
719 fHistograms->FillHistogram("MC_DD_EvtQ2_Pi0_Pt", particle->Pt());
720 break;
721 case kProcND:
722 fHistograms->FillHistogram("MC_ND_EvtQ2_Pi0_Pt", particle->Pt());
723 break;
724 default:
725 AliError("Unknown Process");
726 }
727 }
d7d7e825 728
729
3c45d101 730 }
731
732}
733
d7d7e825 734void AliAnalysisTaskGammaConversion::ProcessMCData(){
735 // see header file for documentation
48682642 736 //InputEvent(), MCEvent());
737 /* TestAnaMarin
d7d7e825 738 fStack = fV0Reader->GetMCStack();
a0b94e5c 739 fMCTruth = fV0Reader->GetMCTruth(); // for CF
4a6157dc 740 fGCMCEvent = fV0Reader->GetMCEvent(); // for CF
48682642 741 */
742 fStack= MCEvent()->Stack();
743 fGCMCEvent=MCEvent();
a0b94e5c 744
745 // for CF
1e7846f4 746 Double_t containerInput[3];
747 if(fDoCF){
748 if(!fGCMCEvent) cout << "NO MC INFO FOUND" << endl;
749 fCFManager->SetEventInfo(fGCMCEvent);
750 }
a0b94e5c 751 // end for CF
752
753
d7d7e825 754 if(fV0Reader->CheckForPrimaryVertex() == kFALSE){
755 return; // aborts if the primary vertex does not have contributors.
756 }
2f426a53 757 for (Int_t iTracks = 0; iTracks < fStack->GetNprimary(); iTracks++) {
758 // for (Int_t iTracks = 0; iTracks < fStack->GetNtrack(); iTracks++) {
d7d7e825 759 TParticle* particle = (TParticle *)fStack->Particle(iTracks);
bd6d9fa3 760
111d75df 761
bd6d9fa3 762
d7d7e825 763 if (!particle) {
764 //print warning here
765 continue;
766 }
a0b94e5c 767
d7d7e825 768 ///////////////////////Begin Chic Analysis/////////////////////////////
91b98865 769 if(fDoChic) {
770 if(particle->GetPdgCode() == 443){//Is JPsi
771 if(particle->GetNDaughters()==2){
772 if(TMath::Abs(fStack->Particle(particle->GetFirstDaughter())->GetPdgCode()) == 11 &&
773 TMath::Abs(fStack->Particle(particle->GetLastDaughter())->GetPdgCode()) == 11){
774
775 TParticle* daug0 = fStack->Particle(particle->GetFirstDaughter());
776 TParticle* daug1 = fStack->Particle(particle->GetLastDaughter());
777 if(TMath::Abs(daug0->Eta()) < 0.9 && TMath::Abs(daug1->Eta()) < 0.9)
778 fHistograms->FillTable("Table_Electrons",3);//e+ e- from J/Psi inside acceptance
a0b94e5c 779
91b98865 780 if( TMath::Abs(daug0->Eta()) < 0.9){
781 if(daug0->GetPdgCode() == -11)
782 fHistograms->FillTable("Table_Electrons",1);//e+ from J/Psi inside acceptance
783 else
784 fHistograms->FillTable("Table_Electrons",2);//e- from J/Psi inside acceptance
a0b94e5c 785
91b98865 786 }
787 if(TMath::Abs(daug1->Eta()) < 0.9){
788 if(daug1->GetPdgCode() == -11)
789 fHistograms->FillTable("Table_Electrons",1);//e+ from J/Psi inside acceptance
790 else
791 fHistograms->FillTable("Table_Electrons",2);//e- from J/Psi inside acceptance
792 }
d7d7e825 793 }
794 }
795 }
91b98865 796 // const int CHI_C0 = 10441;
797 // const int CHI_C1 = 20443;
798 // const int CHI_C2 = 445
799 if(particle->GetPdgCode() == 22){//gamma from JPsi
800 if(particle->GetMother(0) > -1){
801 if(fStack->Particle(particle->GetMother(0))->GetPdgCode() == 10441 ||
802 fStack->Particle(particle->GetMother(0))->GetPdgCode() == 20443 ||
803 fStack->Particle(particle->GetMother(0))->GetPdgCode() == 445){
804 if(TMath::Abs(particle->Eta()) < 1.2)
805 fHistograms->FillTable("Table_Electrons",17);// gamma from chic inside accptance
806 }
d7d7e825 807 }
808 }
91b98865 809 if(particle->GetPdgCode() == 10441 || particle->GetPdgCode() == 20443 || particle->GetPdgCode() == 445){
810 if( particle->GetNDaughters() == 2){
811 TParticle* daug0 = fStack->Particle(particle->GetFirstDaughter());
812 TParticle* daug1 = fStack->Particle(particle->GetLastDaughter());
a0b94e5c 813
91b98865 814 if( (daug0->GetPdgCode() == 443 || daug0->GetPdgCode() == 22) && (daug1->GetPdgCode() == 443 || daug1->GetPdgCode() == 22) ){
815 if( daug0->GetPdgCode() == 443){
816 TParticle* daugE0 = fStack->Particle(daug0->GetFirstDaughter());
817 TParticle* daugE1 = fStack->Particle(daug0->GetLastDaughter());
818 if( TMath::Abs(daug1->Eta()) < 1.2 && TMath::Abs(daugE0->Eta()) < 0.9 && TMath::Abs(daugE1->Eta()) < 0.9 )
819 fHistograms->FillTable("Table_Electrons",18);
a0b94e5c 820
91b98865 821 }//if
822 else if (daug1->GetPdgCode() == 443){
823 TParticle* daugE0 = fStack->Particle(daug1->GetFirstDaughter());
824 TParticle* daugE1 = fStack->Particle(daug1->GetLastDaughter());
825 if( TMath::Abs(daug0->Eta()) < 1.2 && TMath::Abs(daugE0->Eta()) < 0.9 && TMath::Abs(daugE1->Eta()) < 0.9 )
826 fHistograms->FillTable("Table_Electrons",18);
827 }//else if
828 }//gamma o Jpsi
829 }//GetNDaughters
830 }
d7d7e825 831 }
a0b94e5c 832
d7d7e825 833 /////////////////////End Chic Analysis////////////////////////////
a0b94e5c 834
835
dc2883e4 836 // if(TMath::Abs(particle->Eta())> fV0Reader->GetEtaCut() ) continue;
a0b94e5c 837
d7d7e825 838 if(particle->R()>fV0Reader->GetMaxRCut()) continue; // cuts on distance from collision point
839
840 Double_t tmpPhi=particle->Phi();
841
842 if(particle->Phi()> TMath::Pi()){
843 tmpPhi = particle->Phi()-(2*TMath::Pi());
844 }
845
846 Double_t rapidity;
847 if(particle->Energy() - particle->Pz() == 0 || particle->Energy() + particle->Pz() == 0){
848 rapidity=0;
849 }
850 else{
851 rapidity = 0.5*(TMath::Log((particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz())));
852 }
853
111d75df 854
855
856 if(iTracks<=fStack->GetNprimary() ){
857 if ( particle->GetPdgCode()== -211 || particle->GetPdgCode()== 211 ||
858 particle->GetPdgCode()== 2212 || particle->GetPdgCode()==-2212 ||
859 particle->GetPdgCode()== 321 || particle->GetPdgCode()==-321 ){
dc2883e4 860 if(TMath::Abs(particle->Eta())> fV0Reader->GetEtaCut() ) continue;
3c45d101 861 fHistograms->FillHistogram("MC_PhysicalPrimaryCharged_Pt", particle->Pt());
111d75df 862 }
bd6d9fa3 863 }
111d75df 864
bd6d9fa3 865
866
d7d7e825 867 //process the gammas
868 if (particle->GetPdgCode() == 22){
dc2883e4 869 if(TMath::Abs(particle->Eta())> fV0Reader->GetEtaCut() ) continue;
a607c218 870
d7d7e825 871 if(particle->GetMother(0) >-1 && fStack->Particle(particle->GetMother(0))->GetPdgCode() == 22){
872 continue; // no photon as mothers!
873 }
a607c218 874
d7d7e825 875 if(particle->GetMother(0) >= fStack->GetNprimary()){
876 continue; // the gamma has a mother, and it is not a primary particle
877 }
f8017b04 878
879 if(particle->GetMother(0) >-1){
880 fHistograms->FillHistogram("MC_DecayAllGamma_Pt", particle->Pt()); // All
881 switch(fStack->Particle(particle->GetMother(0))->GetPdgCode()){
882 case 111: // Pi0
883 fHistograms->FillHistogram("MC_DecayPi0Gamma_Pt", particle->Pt());
884 break;
885 case 113: // Rho0
886 fHistograms->FillHistogram("MC_DecayRho0Gamma_Pt", particle->Pt());
887 break;
888 case 221: // Eta
889 fHistograms->FillHistogram("MC_DecayEtaGamma_Pt", particle->Pt());
890 break;
891 case 223: // Omega
892 fHistograms->FillHistogram("MC_DecayOmegaGamma_Pt", particle->Pt());
893 break;
894 case 310: // K_s0
895 fHistograms->FillHistogram("MC_DecayK0sGamma_Pt", particle->Pt());
896 break;
897 case 331: // Eta'
898 fHistograms->FillHistogram("MC_DecayEtapGamma_Pt", particle->Pt());
899 break;
900 }
901 }
902
d7d7e825 903 fHistograms->FillHistogram("MC_allGamma_Energy", particle->Energy());
904 fHistograms->FillHistogram("MC_allGamma_Pt", particle->Pt());
905 fHistograms->FillHistogram("MC_allGamma_Eta", particle->Eta());
906 fHistograms->FillHistogram("MC_allGamma_Phi", tmpPhi);
907 fHistograms->FillHistogram("MC_allGamma_Rapid", rapidity);
908
a0b94e5c 909 // for CF
1e7846f4 910 if(fDoCF){
911 containerInput[0] = particle->Pt();
912 containerInput[1] = particle->Eta();
913 if(particle->GetMother(0) >=0){
914 containerInput[2] = fStack->Particle(particle->GetMother(0))->GetMass();
915 }
916 else{
917 containerInput[2]=-1;
918 }
a607c218 919
1e7846f4 920 fCFManager->GetParticleContainer()->Fill(containerInput,kStepGenerated); // generated gamma
921 }
d7d7e825 922 if(particle->GetMother(0) < 0){ // direct gamma
923 fHistograms->FillHistogram("MC_allDirectGamma_Energy",particle->Energy());
924 fHistograms->FillHistogram("MC_allDirectGamma_Pt", particle->Pt());
925 fHistograms->FillHistogram("MC_allDirectGamma_Eta", particle->Eta());
926 fHistograms->FillHistogram("MC_allDirectGamma_Phi", tmpPhi);
927 fHistograms->FillHistogram("MC_allDirectGamma_Rapid", rapidity);
928 }
929
d7d7e825 930 // looking for conversion (electron + positron from pairbuilding (= 5) )
931 TParticle* ePos = NULL;
932 TParticle* eNeg = NULL;
933
934 if(particle->GetNDaughters() >= 2){
935 for(Int_t daughterIndex=particle->GetFirstDaughter();daughterIndex<=particle->GetLastDaughter();daughterIndex++){
936 TParticle *tmpDaughter = fStack->Particle(daughterIndex);
937 if(tmpDaughter->GetUniqueID() == 5){
938 if(tmpDaughter->GetPdgCode() == 11){
939 eNeg = tmpDaughter;
940 }
941 else if(tmpDaughter->GetPdgCode() == -11){
942 ePos = tmpDaughter;
943 }
944 }
945 }
946 }
947
948
949 if(ePos == NULL || eNeg == NULL){ // means we do not have two daughters from pair production
950 continue;
951 }
952
953
954 Double_t ePosPhi = ePos->Phi();
955 if(ePos->Phi()> TMath::Pi()) ePosPhi = ePos->Phi()-(2*TMath::Pi());
956
957 Double_t eNegPhi = eNeg->Phi();
958 if(eNeg->Phi()> TMath::Pi()) eNegPhi = eNeg->Phi()-(2*TMath::Pi());
959
960
961 if(ePos->Pt()<fV0Reader->GetPtCut() || eNeg->Pt()<fV0Reader->GetPtCut()){
962 continue; // no reconstruction below the Pt cut
963 }
a0b94e5c 964
d7d7e825 965 if(TMath::Abs(ePos->Eta())> fV0Reader->GetEtaCut() || TMath::Abs(eNeg->Eta())> fV0Reader->GetEtaCut()){
966 continue;
967 }
a0b94e5c 968
d7d7e825 969 if(ePos->R()>fV0Reader->GetMaxRCut()){
970 continue; // cuts on distance from collision point
971 }
a0b94e5c 972
973 if(TMath::Abs(ePos->Vz()) > fV0Reader->GetMaxZCut()){
d7d7e825 974 continue; // outside material
975 }
976
a0b94e5c 977
d7d7e825 978 if((TMath::Abs(ePos->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue() > ePos->R()){
979 continue; // line cut to exclude regions where we do not reconstruct
980 }
981
a0b94e5c 982
983 // for CF
1e7846f4 984 if(fDoCF){
985 fCFManager->GetParticleContainer()->Fill(containerInput,kStepReconstructable); // reconstructable gamma
986 }
d7d7e825 987 fHistograms->FillHistogram("MC_ConvGamma_Energy", particle->Energy());
988 fHistograms->FillHistogram("MC_ConvGamma_Pt", particle->Pt());
989 fHistograms->FillHistogram("MC_ConvGamma_Eta", particle->Eta());
990 fHistograms->FillHistogram("MC_ConvGamma_Phi", tmpPhi);
991 fHistograms->FillHistogram("MC_ConvGamma_Rapid", rapidity);
992 fHistograms->FillHistogram("MC_ConvGamma_Pt_Eta", particle->Pt(),particle->Eta());
993
994 fHistograms->FillHistogram("MC_E_Energy", eNeg->Energy());
995 fHistograms->FillHistogram("MC_E_Pt", eNeg->Pt());
996 fHistograms->FillHistogram("MC_E_Eta", eNeg->Eta());
997 fHistograms->FillHistogram("MC_E_Phi", eNegPhi);
998
999 fHistograms->FillHistogram("MC_P_Energy", ePos->Energy());
1000 fHistograms->FillHistogram("MC_P_Pt", ePos->Pt());
1001 fHistograms->FillHistogram("MC_P_Eta", ePos->Eta());
1002 fHistograms->FillHistogram("MC_P_Phi", ePosPhi);
1003
1004
d7d7e825 1005 // begin Mapping
1006 Int_t rBin = fHistograms->GetRBin(ePos->R());
9640a3d1 1007 Int_t zBin = fHistograms->GetZBin(ePos->Vz());
d7d7e825 1008 Int_t phiBin = fHistograms->GetPhiBin(particle->Phi());
9c1cb6f7 1009 Double_t rFMD=30;
64f4118c 1010 Double_t rITSTPCMin=50;
1011 Double_t rITSTPCMax=80;
9640a3d1 1012
1013 TVector3 vtxPos(ePos->Vx(),ePos->Vy(),ePos->Vz());
1014
d7d7e825 1015 TString nameMCMappingPhiR="";
e158cbc3 1016 nameMCMappingPhiR.Form("MC_Conversion_Mapping_Phi%02d_R%02d",phiBin,rBin);
ebcfaa7e 1017 // fHistograms->FillHistogram(nameMCMappingPhiR, ePos->Vz(), particle->Eta());
d7d7e825 1018
1019 TString nameMCMappingPhi="";
e158cbc3 1020 nameMCMappingPhi.Form("MC_Conversion_Mapping_Phi%02d",phiBin);
9640a3d1 1021 // fHistograms->FillHistogram(nameMCMappingPhi, particle->Eta());
ebcfaa7e 1022 //fHistograms->FillHistogram(nameMCMappingPhi, ePos->Vz(), particle->Eta());
d7d7e825 1023
1024 TString nameMCMappingR="";
e158cbc3 1025 nameMCMappingR.Form("MC_Conversion_Mapping_R%02d",rBin);
9640a3d1 1026 // fHistograms->FillHistogram(nameMCMappingR, particle->Eta());
ebcfaa7e 1027 //fHistograms->FillHistogram(nameMCMappingR,ePos->Vz(), particle->Eta());
d7d7e825 1028
1029 TString nameMCMappingPhiInR="";
e158cbc3 1030 nameMCMappingPhiInR.Form("MC_Conversion_Mapping_Phi_in_R_%02d",rBin);
9640a3d1 1031 // fHistograms->FillHistogram(nameMCMappingPhiInR, tmpPhi);
1032 fHistograms->FillHistogram(nameMCMappingPhiInR, vtxPos.Phi());
1033
1034 TString nameMCMappingZInR="";
1035 nameMCMappingZInR.Form("MC_Conversion_Mapping_Z_in_R_%02d",rBin);
1036 fHistograms->FillHistogram(nameMCMappingZInR,ePos->Vz() );
1037
1038
1039 TString nameMCMappingPhiInZ="";
1040 nameMCMappingPhiInZ.Form("MC_Conversion_Mapping_Phi_in_Z_%02d",zBin);
1041 // fHistograms->FillHistogram(nameMCMappingPhiInR, tmpPhi);
1042 fHistograms->FillHistogram(nameMCMappingPhiInZ, vtxPos.Phi());
1043
9c1cb6f7 1044
1045 if(ePos->R()<rFMD){
1046 TString nameMCMappingFMDPhiInZ="";
1047 nameMCMappingFMDPhiInZ.Form("MC_Conversion_Mapping_FMD_Phi_in_Z_%02d",zBin);
1048 fHistograms->FillHistogram(nameMCMappingFMDPhiInZ, vtxPos.Phi());
1049 }
1050
64f4118c 1051 if(ePos->R()>rITSTPCMin && ePos->R()<rITSTPCMax){
1052 TString nameMCMappingITSTPCPhiInZ="";
1053 nameMCMappingITSTPCPhiInZ.Form("MC_Conversion_Mapping_ITSTPC_Phi_in_Z_%02d",zBin);
1054 fHistograms->FillHistogram(nameMCMappingITSTPCPhiInZ, vtxPos.Phi());
1055 }
1056
9640a3d1 1057 TString nameMCMappingRInZ="";
1058 nameMCMappingRInZ.Form("MC_Conversion_Mapping_R_in_Z_%02d",zBin);
1059 fHistograms->FillHistogram(nameMCMappingRInZ,ePos->R() );
1060
1061 if(particle->Pt() > fLowPtMapping && particle->Pt()< fHighPtMapping){
1062 TString nameMCMappingMidPtPhiInR="";
1063 nameMCMappingMidPtPhiInR.Form("MC_Conversion_Mapping_MidPt_Phi_in_R_%02d",rBin);
1064 fHistograms->FillHistogram(nameMCMappingMidPtPhiInR, vtxPos.Phi());
1065
1066 TString nameMCMappingMidPtZInR="";
1067 nameMCMappingMidPtZInR.Form("MC_Conversion_Mapping_MidPt_Z_in_R_%02d",rBin);
1068 fHistograms->FillHistogram(nameMCMappingMidPtZInR,ePos->Vz() );
1069
1070
1071 TString nameMCMappingMidPtPhiInZ="";
1072 nameMCMappingMidPtPhiInZ.Form("MC_Conversion_Mapping_MidPt_Phi_in_Z_%02d",zBin);
1073 fHistograms->FillHistogram(nameMCMappingMidPtPhiInZ, vtxPos.Phi());
9c1cb6f7 1074
1075
1076 if(ePos->R()<rFMD){
1077 TString nameMCMappingMidPtFMDPhiInZ="";
1078 nameMCMappingMidPtFMDPhiInZ.Form("MC_Conversion_Mapping_MidPt_FMD_Phi_in_Z_%02d",zBin);
1079 fHistograms->FillHistogram(nameMCMappingMidPtFMDPhiInZ, vtxPos.Phi());
1080 }
1081
9640a3d1 1082
1083 TString nameMCMappingMidPtRInZ="";
1084 nameMCMappingMidPtRInZ.Form("MC_Conversion_Mapping_MidPt_R_in_Z_%02d",zBin);
1085 fHistograms->FillHistogram(nameMCMappingMidPtRInZ,ePos->R() );
1086
1087 }
1088
d7d7e825 1089 //end mapping
1090
1091 fHistograms->FillHistogram("MC_Conversion_R",ePos->R());
1092 fHistograms->FillHistogram("MC_Conversion_ZR",ePos->Vz(),ePos->R());
1093 fHistograms->FillHistogram("MC_Conversion_XY",ePos->Vx(),ePos->Vy());
1094 fHistograms->FillHistogram("MC_Conversion_OpeningAngle",GetMCOpeningAngle(ePos, eNeg));
9640a3d1 1095 fHistograms->FillHistogram("MC_ConvGamma_E_AsymmetryP",particle->P(),eNeg->P()/particle->P());
1096 fHistograms->FillHistogram("MC_ConvGamma_P_AsymmetryP",particle->P(),ePos->P()/particle->P());
1097
1098
d7d7e825 1099 if(particle->GetMother(0) < 0){ // no mother = direct gamma, still inside converted
1100 fHistograms->FillHistogram("MC_ConvDirectGamma_Energy",particle->Energy());
1101 fHistograms->FillHistogram("MC_ConvDirectGamma_Pt", particle->Pt());
1102 fHistograms->FillHistogram("MC_ConvDirectGamma_Eta", particle->Eta());
1103 fHistograms->FillHistogram("MC_ConvDirectGamma_Phi", tmpPhi);
1104 fHistograms->FillHistogram("MC_ConvDirectGamma_Rapid", rapidity);
1105
1106 } // end direct gamma
1107 else{ // mother exits
6c84d371 1108 /* if( fStack->Particle(particle->GetMother(0))->GetPdgCode()==10441 ||//chic0
a0b94e5c 1109 fStack->Particle(particle->GetMother(0))->GetPdgCode()==20443 ||//psi2S
1110 fStack->Particle(particle->GetMother(0))->GetPdgCode()==445 //chic2
1111 ){
1112 fMCGammaChic.push_back(particle);
1113 }
6c84d371 1114 */
d7d7e825 1115 } // end if mother exits
1116 } // end if particle is a photon
1117
1118
1119
1120 // process motherparticles (2 gammas as daughters)
1121 // the motherparticle had already to pass the R and the eta cut, but no line cut.
1122 // the line cut is just valid for the conversions!
1123
1124 if(particle->GetNDaughters() == 2){
1125
1126 TParticle* daughter0 = (TParticle*)fStack->Particle(particle->GetFirstDaughter());
1127 TParticle* daughter1 = (TParticle*)fStack->Particle(particle->GetLastDaughter());
1128
1129 if(daughter0->GetPdgCode() != 22 || daughter1->GetPdgCode() != 22) continue; //check for gamma gamma daughters
dc2883e4 1130
1131 if(TMath::Abs(rapidity) > fV0Reader->GetRapidityMesonCut() ) continue;
1132
d7d7e825 1133 // Check the acceptance for both gammas
01b7fdcc 1134 Bool_t gammaEtaCut = kTRUE;
1135 if(TMath::Abs(daughter0->Eta()) > fV0Reader->GetEtaCut() || TMath::Abs(daughter1->Eta()) > fV0Reader->GetEtaCut() ) gammaEtaCut = kFALSE;
1136 Bool_t gammaRCut = kTRUE;
1137 if(daughter0->R() > fV0Reader->GetMaxRCut() || daughter1->R() > fV0Reader->GetMaxRCut() ) gammaRCut = kFALSE;
d7d7e825 1138
1139
1140
1141 // check for conversions now -> have to pass eta, R and line cut!
1142 Bool_t daughter0Electron = kFALSE;
1143 Bool_t daughter0Positron = kFALSE;
1144 Bool_t daughter1Electron = kFALSE;
1145 Bool_t daughter1Positron = kFALSE;
1146
1147 if(daughter0->GetNDaughters() >= 2){ // first gamma
1148 for(Int_t TrackIndex=daughter0->GetFirstDaughter();TrackIndex<=daughter0->GetLastDaughter();TrackIndex++){
1149 TParticle *tmpDaughter = fStack->Particle(TrackIndex);
1150 if(tmpDaughter->GetUniqueID() == 5){
1151 if(tmpDaughter->GetPdgCode() == 11){
1152 if( TMath::Abs(tmpDaughter->Eta()) <= fV0Reader->GetEtaCut() ){
1153 if( ( TMath::Abs(tmpDaughter->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue() < tmpDaughter->R() ){
1154 if(tmpDaughter->R()< fV0Reader->GetMaxRCut()){
1155 daughter0Electron = kTRUE;
1156 }
1157 }
1158
1159 }
1160 }
1161 else if(tmpDaughter->GetPdgCode() == -11){
1162 if( TMath::Abs(tmpDaughter->Eta()) <= fV0Reader->GetEtaCut() ){
1163 if( ( TMath::Abs(tmpDaughter->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue() < tmpDaughter->R() ){
1164 if(tmpDaughter->R()< fV0Reader->GetMaxRCut()){
1165 daughter0Positron = kTRUE;
1166 }
a68437fb 1167 }
1168 }
d7d7e825 1169 }
1170 }
1171 }
1172 }
1173
1174
1175 if(daughter1->GetNDaughters() >= 2){ // second gamma
1176 for(Int_t TrackIndex=daughter1->GetFirstDaughter();TrackIndex<=daughter1->GetLastDaughter();TrackIndex++){
1177 TParticle *tmpDaughter = fStack->Particle(TrackIndex);
1178 if(tmpDaughter->GetUniqueID() == 5){
1179 if(tmpDaughter->GetPdgCode() == 11){
1180 if( TMath::Abs(tmpDaughter->Eta()) <= fV0Reader->GetEtaCut() ){
1181 if( ( TMath::Abs(tmpDaughter->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue() < tmpDaughter->R() ){
1182 if(tmpDaughter->R()< fV0Reader->GetMaxRCut()){
1183 daughter1Electron = kTRUE;
1184 }
1185 }
1186
1187 }
1188 }
1189 else if(tmpDaughter->GetPdgCode() == -11){
1190 if( TMath::Abs(tmpDaughter->Eta()) <= fV0Reader->GetEtaCut() ){
1191 if( ( TMath::Abs(tmpDaughter->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue() < tmpDaughter->R() ){
1192 if(tmpDaughter->R()< fV0Reader->GetMaxRCut()){
1193 daughter1Positron = kTRUE;
1194 }
1195 }
1196
1197 }
1198
1199 }
1200 }
1201 }
1202 }
1203
a0b94e5c 1204
d7d7e825 1205 if(particle->GetPdgCode()==111){ //Pi0
1206 if( iTracks >= fStack->GetNprimary()){
1207 fHistograms->FillHistogram("MC_Pi0_Secondaries_Eta", particle->Eta());
1208 fHistograms->FillHistogram("MC_Pi0_Secondaries_Rapid", rapidity);
1209 fHistograms->FillHistogram("MC_Pi0_Secondaries_Phi", tmpPhi);
1210 fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt", particle->Pt());
1211 fHistograms->FillHistogram("MC_Pi0_Secondaries_Energy", particle->Energy());
1212 fHistograms->FillHistogram("MC_Pi0_Secondaries_R", particle->R());
1213 fHistograms->FillHistogram("MC_Pi0_Secondaries_ZR", particle->Vz(),particle->R());
1214 fHistograms->FillHistogram("MC_Pi0_Secondaries_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));
1215 fHistograms->FillHistogram("MC_Pi0_Secondaries_XY", particle->Vx(),particle->Vy());//only fill from one daughter to avoid multiple filling
1216
01b7fdcc 1217 if(gammaEtaCut && gammaRCut){
d7d7e825 1218 //if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){
1219 fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt_Eta_withinAcceptance", particle->Pt(),particle->Eta());
1220 fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt_Rapid_withinAcceptance", particle->Pt(),rapidity);
1221 if(daughter0Electron && daughter0Positron && daughter1Electron && daughter1Positron){
1222 fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt_Eta_ConvGamma_withinAcceptance", particle->Pt(),particle->Eta());
1223 fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt_Rapid_ConvGamma_withinAcceptance", particle->Pt(),rapidity);
1224 }
1225 }
1226 }
1227 else{
1228 fHistograms->FillHistogram("MC_Pi0_Eta", particle->Eta());
1229 fHistograms->FillHistogram("MC_Pi0_Rapid", rapidity);
1230 fHistograms->FillHistogram("MC_Pi0_Phi", tmpPhi);
1231 fHistograms->FillHistogram("MC_Pi0_Pt", particle->Pt());
dc2883e4 1232 fHistograms->FillHistogram("MC_Pi0_Pt_vs_Rapid", particle->Pt(),rapidity);
d7d7e825 1233 fHistograms->FillHistogram("MC_Pi0_Energy", particle->Energy());
1234 fHistograms->FillHistogram("MC_Pi0_R", particle->R());
1235 fHistograms->FillHistogram("MC_Pi0_ZR", particle->Vz(),particle->R());
1236 fHistograms->FillHistogram("MC_Pi0_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));
1237 fHistograms->FillHistogram("MC_Pi0_XY", particle->Vx(), particle->Vy());//only fill from one daughter to avoid multiple filling
63e16c52 1238 if(TMath::Abs(particle->Eta())<0.9)fHistograms->FillHistogram("MC_Pi0_Pt_Fiducial", particle->Pt());
3c45d101 1239
1240 switch(GetProcessType(fGCMCEvent)){
1241 case kProcSD:
1242 fHistograms->FillHistogram("MC_SD_EvtQ3_Pi0_Pt", particle->Pt());
1243 break;
1244 case kProcDD:
1245 fHistograms->FillHistogram("MC_DD_EvtQ3_Pi0_Pt", particle->Pt());
1246 break;
1247 case kProcND:
1248 fHistograms->FillHistogram("MC_ND_EvtQ3_Pi0_Pt", particle->Pt());
1249 break;
1250 default:
1251 AliError("Unknown Process");
1252 }
63e16c52 1253
01b7fdcc 1254 if(gammaEtaCut && gammaRCut){
d7d7e825 1255 // if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){
1256 fHistograms->FillHistogram("MC_Pi0_Pt_Eta_withinAcceptance", particle->Pt(),particle->Eta());
1257 fHistograms->FillHistogram("MC_Pi0_Pt_Rapid_withinAcceptance", particle->Pt(),rapidity);
63e16c52 1258 if(TMath::Abs(particle->Eta())<0.9)fHistograms->FillHistogram("MC_Pi0_Pt_withinAcceptance_Fiducial", particle->Pt());
1259
d7d7e825 1260 if(daughter0Electron && daughter0Positron && daughter1Electron && daughter1Positron){
1261 fHistograms->FillHistogram("MC_Pi0_Pt_Eta_ConvGamma_withinAcceptance", particle->Pt(),particle->Eta());
1262 fHistograms->FillHistogram("MC_Pi0_Pt_Rapid_ConvGamma_withinAcceptance", particle->Pt(),rapidity);
1263 fHistograms->FillHistogram("MC_Pi0_ZR_ConvGamma_withinAcceptance", particle->Vz(),particle->R());
10e3319b 1264 fHistograms->FillHistogram("MC_Pi0_ConvGamma_OpeningAngle_Pt", particle->Pt(),GetMCOpeningAngle(daughter0,daughter1));
1265 fHistograms->FillHistogram("MC_Pi0_ConvGamma_PtGamma_Pt", particle->Pt(),daughter0->Pt());
1266 fHistograms->FillHistogram("MC_Pi0_ConvGamma_PtGamma_Pt", particle->Pt(),daughter1->Pt());
1267
48682642 1268 Double_t alfa=0.;
77ac6f3e 1269 if((daughter0->Energy()+daughter1->Energy()) > 0.){
48682642 1270 alfa= TMath::Abs((daughter0->Energy()-daughter1->Energy())/(daughter0->Energy()+daughter1->Energy()));
1271 }
1272 fHistograms->FillHistogram("MC_Pi0_alpha",alfa);
1273 if(TMath::Abs(particle->Eta())<0.9)fHistograms->FillHistogram("MC_Pi0_Pt_ConvGamma_withinAcceptance_Fiducial", particle->Pt());
1274
d7d7e825 1275 }
1276 }
1277 }
1278 }
1279
1280 if(particle->GetPdgCode()==221){ //Eta
1281 fHistograms->FillHistogram("MC_Eta_Eta", particle->Eta());
1282 fHistograms->FillHistogram("MC_Eta_Rapid", rapidity);
1283 fHistograms->FillHistogram("MC_Eta_Phi",tmpPhi);
1284 fHistograms->FillHistogram("MC_Eta_Pt", particle->Pt());
dc2883e4 1285 fHistograms->FillHistogram("MC_Eta_Pt_vs_Rapid", particle->Pt(),rapidity);
d7d7e825 1286 fHistograms->FillHistogram("MC_Eta_Energy", particle->Energy());
1287 fHistograms->FillHistogram("MC_Eta_R", particle->R());
1288 fHistograms->FillHistogram("MC_Eta_ZR", particle->Vz(),particle->R());
1289 fHistograms->FillHistogram("MC_Eta_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));
1290 fHistograms->FillHistogram("MC_Eta_XY", particle->Vx(), particle->Vy());//only fill from one daughter to avoid multiple filling
1291
01b7fdcc 1292 if(gammaEtaCut && gammaRCut){
a0b94e5c 1293 // if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){
d7d7e825 1294 fHistograms->FillHistogram("MC_Eta_Pt_Eta_withinAcceptance", particle->Pt(),particle->Eta());
1295 fHistograms->FillHistogram("MC_Eta_Pt_Rapid_withinAcceptance", particle->Pt(),rapidity);
1296 if(daughter0Electron && daughter0Positron && daughter1Electron && daughter1Positron){
1297 fHistograms->FillHistogram("MC_Eta_Pt_Eta_ConvGamma_withinAcceptance", particle->Pt(),particle->Eta());
1298 fHistograms->FillHistogram("MC_Eta_Pt_Rapid_ConvGamma_withinAcceptance", particle->Pt(),rapidity);
1299 fHistograms->FillHistogram("MC_Eta_ZR_ConvGamma_withinAcceptance", particle->Vz(),particle->R());
10e3319b 1300 fHistograms->FillHistogram("MC_Eta_ConvGamma_OpeningAngle_Pt", particle->Pt(),GetMCOpeningAngle(daughter0,daughter1));
1301 fHistograms->FillHistogram("MC_Eta_ConvGamma_PtGamma_Pt", particle->Pt(),daughter0->Pt());
1302 fHistograms->FillHistogram("MC_Eta_ConvGamma_PtGamma_Pt", particle->Pt(),daughter1->Pt());
1303
d7d7e825 1304 }
1305
1306 }
1307
1308 }
1309
1310 // all motherparticles with 2 gammas as daughters
1311 fHistograms->FillHistogram("MC_Mother_R", particle->R());
1312 fHistograms->FillHistogram("MC_Mother_ZR", particle->Vz(),particle->R());
1313 fHistograms->FillHistogram("MC_Mother_XY", particle->Vx(),particle->Vy());
1314 fHistograms->FillHistogram("MC_Mother_Mass", particle->GetCalcMass());
1315 fHistograms->FillHistogram("MC_Mother_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));
1316 fHistograms->FillHistogram("MC_Mother_Energy", particle->Energy());
1317 fHistograms->FillHistogram("MC_Mother_Pt", particle->Pt());
1318 fHistograms->FillHistogram("MC_Mother_Eta", particle->Eta());
1319 fHistograms->FillHistogram("MC_Mother_Rapid", rapidity);
1320 fHistograms->FillHistogram("MC_Mother_Phi",tmpPhi);
1321 fHistograms->FillHistogram("MC_Mother_InvMass_vs_Pt",particle->GetMass(),particle->Pt());
a0b94e5c 1322
01b7fdcc 1323 if(gammaEtaCut && gammaRCut){
a0b94e5c 1324 // if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){
d7d7e825 1325 fHistograms->FillHistogram("MC_Mother_Pt_Eta_withinAcceptance", particle->Pt(),particle->Eta());
1326 fHistograms->FillHistogram("MC_Mother_Pt_Rapid_withinAcceptance", particle->Pt(),rapidity);
1327 fHistograms->FillHistogram("MC_Mother_InvMass_vs_Pt_withinAcceptance",particle->GetMass(),particle->Pt());
1328 if(daughter0Electron && daughter0Positron && daughter1Electron && daughter1Positron){
1329 fHistograms->FillHistogram("MC_Mother_Pt_Eta_ConvGamma_withinAcceptance", particle->Pt(),particle->Eta());
1330 fHistograms->FillHistogram("MC_Mother_Pt_Rapid_ConvGamma_withinAcceptance", particle->Pt(),rapidity);
1331 fHistograms->FillHistogram("MC_Mother_InvMass_vs_Pt_ConvGamma_withinAcceptance",particle->GetMass(),particle->Pt());
a0b94e5c 1332
d7d7e825 1333 }
1334
1335
1336 } // end passed R and eta cut
a0b94e5c 1337
d7d7e825 1338 } // end if(particle->GetNDaughters() == 2)
1339
1340 }// end for (Int_t iTracks = 0; iTracks < fStack->GetNtrack(); iTracks++)
a0b94e5c 1341
d7d7e825 1342} // end ProcessMCData
1343
1344
1345
1346void AliAnalysisTaskGammaConversion::FillNtuple(){
1347 //Fills the ntuple with the different values
a0b94e5c 1348
d7d7e825 1349 if(fGammaNtuple == NULL){
1350 return;
1351 }
1352 Int_t numberOfV0s = fV0Reader->GetNumberOfV0s();
1353 for(Int_t i=0;i<numberOfV0s;i++){
1354 Float_t values[27] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
1355 AliESDv0 * cV0 = fV0Reader->GetV0(i);
1356 Double_t negPID=0;
1357 Double_t posPID=0;
1358 fV0Reader->GetPIDProbability(negPID,posPID);
1359 values[0]=cV0->GetOnFlyStatus();
1360 values[1]=fV0Reader->CheckForPrimaryVertex();
1361 values[2]=negPID;
1362 values[3]=posPID;
1363 values[4]=fV0Reader->GetX();
1364 values[5]=fV0Reader->GetY();
1365 values[6]=fV0Reader->GetZ();
1366 values[7]=fV0Reader->GetXYRadius();
1367 values[8]=fV0Reader->GetMotherCandidateNDF();
1368 values[9]=fV0Reader->GetMotherCandidateChi2();
1369 values[10]=fV0Reader->GetMotherCandidateEnergy();
1370 values[11]=fV0Reader->GetMotherCandidateEta();
1371 values[12]=fV0Reader->GetMotherCandidatePt();
1372 values[13]=fV0Reader->GetMotherCandidateMass();
1373 values[14]=fV0Reader->GetMotherCandidateWidth();
1374 // values[15]=fV0Reader->GetMotherMCParticle()->Pt(); MOVED TO THE END, HAS TO BE CALLED AFTER HasSameMother NB: still has the same entry in the array
1375 values[16]=fV0Reader->GetOpeningAngle();
1376 values[17]=fV0Reader->GetNegativeTrackEnergy();
1377 values[18]=fV0Reader->GetNegativeTrackPt();
1378 values[19]=fV0Reader->GetNegativeTrackEta();
1379 values[20]=fV0Reader->GetNegativeTrackPhi();
1380 values[21]=fV0Reader->GetPositiveTrackEnergy();
1381 values[22]=fV0Reader->GetPositiveTrackPt();
1382 values[23]=fV0Reader->GetPositiveTrackEta();
1383 values[24]=fV0Reader->GetPositiveTrackPhi();
1384 values[25]=fV0Reader->HasSameMCMother();
1385 if(values[25] != 0){
1386 values[26]=fV0Reader->GetMotherMCParticlePDGCode();
1387 values[15]=fV0Reader->GetMotherMCParticle()->Pt();
1388 }
1389 fTotalNumberOfAddedNtupleEntries++;
1390 fGammaNtuple->Fill(values);
1391 }
1392 fV0Reader->ResetV0IndexNumber();
1393
1394}
1395
1396void AliAnalysisTaskGammaConversion::ProcessV0sNoCut(){
1397 // Process all the V0's without applying any cuts to it
a0b94e5c 1398
d7d7e825 1399 Int_t numberOfV0s = fV0Reader->GetNumberOfV0s();
1400 for(Int_t i=0;i<numberOfV0s;i++){
1401 /*AliESDv0 * cV0 = */fV0Reader->GetV0(i);
a0b94e5c 1402
d7d7e825 1403 if(fV0Reader->CheckForPrimaryVertex() == kFALSE){
cb90a330 1404 continue;
d7d7e825 1405 }
9640a3d1 1406
77880bd8 1407 // if( !fV0Reader->GetV0(i)->GetOnFlyStatus()){
1408 if( !fV0Reader->CheckV0FinderStatus(i)){
cb90a330 1409 continue;
9640a3d1 1410 }
1411
cb90a330 1412
1413 if( !((fV0Reader->GetNegativeESDTrack())->GetStatus() & AliESDtrack::kTPCrefit) ||
1414 !((fV0Reader->GetPositiveESDTrack())->GetStatus() & AliESDtrack::kTPCrefit) ){
1415 continue;
9640a3d1 1416 }
cb90a330 1417
ebcfaa7e 1418 if( fV0Reader->GetNegativeESDTrack()->GetSign()== fV0Reader->GetPositiveESDTrack()->GetSign()){
1419 continue;
1420 }
1421
1422 if( fV0Reader->GetNegativeESDTrack()->GetKinkIndex(0) > 0 ||
1423 fV0Reader->GetPositiveESDTrack()->GetKinkIndex(0) > 0) {
1424 continue;
1425 }
9c1cb6f7 1426 if(TMath::Abs(fV0Reader->GetMotherCandidateEta())> fV0Reader->GetEtaCut()){
1427 continue;
1428 }
1429 if(TMath::Abs(fV0Reader->GetPositiveTrackEta())> fV0Reader->GetEtaCut()){
1430 continue;
1431 }
1432 if(TMath::Abs(fV0Reader->GetNegativeTrackEta())> fV0Reader->GetEtaCut()){
1433 continue;
1434 }
1435 if((TMath::Abs(fV0Reader->GetZ())*fV0Reader->GetLineCutZRSlope())-fV0Reader->GetLineCutZValue() > fV0Reader->GetXYRadius() ){ // cuts out regions where we do not reconstruct
1436 continue;
1437 }
d7d7e825 1438 if(fDoMCTruth){
a0b94e5c 1439
d7d7e825 1440 if(fV0Reader->HasSameMCMother() == kFALSE){
1441 continue;
1442 }
a0b94e5c 1443
d7d7e825 1444 TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
1445 TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
a0b94e5c 1446
d7d7e825 1447 if(TMath::Abs(negativeMC->GetPdgCode())!=11 || TMath::Abs(positiveMC->GetPdgCode())!=11){
1448 continue;
1449 }
26923b22 1450 if(negativeMC->GetPdgCode() == positiveMC->GetPdgCode()){
d7d7e825 1451 continue;
1452 }
a68437fb 1453
26923b22 1454 if(negativeMC->GetUniqueID() != 5 || positiveMC->GetUniqueID() !=5){ // id 5 is conversion
a68437fb 1455 continue;
1456 }
a0b94e5c 1457
d7d7e825 1458 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
a0b94e5c 1459
d7d7e825 1460 fHistograms->FillHistogram("ESD_NoCutConvGamma_Pt", fV0Reader->GetMotherCandidatePt());
1461 fHistograms->FillHistogram("ESD_NoCutConvGamma_Energy", fV0Reader->GetMotherCandidateEnergy());
1462 fHistograms->FillHistogram("ESD_NoCutConvGamma_Eta", fV0Reader->GetMotherCandidateEta());
1463 fHistograms->FillHistogram("ESD_NoCutConvGamma_Phi", fV0Reader->GetMotherCandidatePhi());
1464 fHistograms->FillHistogram("ESD_NoCutConvGamma_Mass", fV0Reader->GetMotherCandidateMass());
1465 fHistograms->FillHistogram("ESD_NoCutConvGamma_Width", fV0Reader->GetMotherCandidateWidth());
1466 fHistograms->FillHistogram("ESD_NoCutConvGamma_Chi2", fV0Reader->GetMotherCandidateChi2());
1467 fHistograms->FillHistogram("ESD_NoCutConvGamma_NDF", fV0Reader->GetMotherCandidateNDF());
1468 fHistograms->FillHistogram("ESD_NoCutConvGamma_Rapid", fV0Reader->GetMotherCandidateRapidity());
1469 fHistograms->FillHistogram("ESD_NoCutConvGamma_Pt_Eta", fV0Reader->GetMotherCandidatePt(),fV0Reader->GetMotherCandidateEta());
a0b94e5c 1470
d7d7e825 1471 fHistograms->FillHistogram("ESD_NoCutConvGamma_Pt_Chi2", fV0Reader->GetMotherCandidatePt(), fV0Reader->GetMotherCandidateChi2());
1472 fHistograms->FillHistogram("ESD_NoCutConvGamma_Eta_Chi2", fV0Reader->GetMotherCandidateEta(), fV0Reader->GetMotherCandidateChi2());
1473
1474 fHistograms->FillHistogram("ESD_NoCutConversion_XY", fV0Reader->GetX(),fV0Reader->GetY());
1475 fHistograms->FillHistogram("ESD_NoCutConversion_R", fV0Reader->GetXYRadius());
1476 fHistograms->FillHistogram("ESD_NoCutConversion_ZR", fV0Reader->GetZ(),fV0Reader->GetXYRadius());
1477 fHistograms->FillHistogram("ESD_NoCutConversion_OpeningAngle", fV0Reader->GetOpeningAngle());
9640a3d1 1478 fHistograms->FillHistogram("ESD_NoCutConvGamma_CosPointingAngle", fV0Reader->GetCosPointingAngle());
1479 fHistograms->FillHistogram("ESD_NoCutConvGamma_DcaDaughters", fV0Reader->GetDcaDaughters());
1480 fHistograms->FillHistogram("ESD_NoCutConvGamma_NormDcaDistDaughters", fV0Reader->GetNormDcaDistDaughters());
1481 fHistograms->FillHistogram("ESD_NoCutConvGamma_LikelihoodAP", fV0Reader->GetLikelihoodAP());
1482
1483 fHistograms->FillHistogram("ESD_NoCutConvGamma_E_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetNegativeTrackP()/fV0Reader->GetMotherCandidateP());
1484 fHistograms->FillHistogram("ESD_NoCutConvGamma_P_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetPositiveTrackP()/fV0Reader->GetMotherCandidateP());
1485 fHistograms->FillHistogram("ESD_NoCutConvGamma_E_dEdxP",fV0Reader->GetNegativeTrackP(),fV0Reader->GetNegativeTrackTPCdEdx());
1486 fHistograms->FillHistogram("ESD_NoCutConvGamma_P_dEdxP",fV0Reader->GetPositiveTrackP(),fV0Reader->GetPositiveTrackTPCdEdx());
1487
d7d7e825 1488 //store MCTruth properties
1489 fHistograms->FillHistogram("ESD_NoCutConvGamma_MC_Pt_Eta", fV0Reader->GetMotherMCParticle()->Pt(),fV0Reader->GetMotherMCParticle()->Eta());
1490 fHistograms->FillHistogram("ESD_NoCutConversion_MC_ZR", negativeMC->Vz(),negativeMC->R());
1491 fHistograms->FillHistogram("ESD_NoCutConversion_MC_XY", negativeMC->Vx(),negativeMC->Vy());
d7d7e825 1492 }
1493 }
1494 }
1495 fV0Reader->ResetV0IndexNumber();
1496}
1497
1498void AliAnalysisTaskGammaConversion::ProcessV0s(){
1499 // see header file for documentation
037dc2db 1500
1501
d7d7e825 1502 if(fWriteNtuple == kTRUE){
1503 FillNtuple();
1504 }
1505
1506 Int_t nSurvivingV0s=0;
5ce758b0 1507 fV0Reader->ResetNGoodV0s();
d7d7e825 1508 while(fV0Reader->NextV0()){
1509 nSurvivingV0s++;
1510
e60f3265 1511
1512 TVector3 vtxConv(fV0Reader->GetX(),fV0Reader->GetY(), fV0Reader->GetZ());
1513
d7d7e825 1514 //-------------------------- filling v0 information -------------------------------------
1515 fHistograms->FillHistogram("ESD_Conversion_R", fV0Reader->GetXYRadius());
1516 fHistograms->FillHistogram("ESD_Conversion_ZR", fV0Reader->GetZ(),fV0Reader->GetXYRadius());
1517 fHistograms->FillHistogram("ESD_Conversion_XY", fV0Reader->GetX(),fV0Reader->GetY());
1518 fHistograms->FillHistogram("ESD_Conversion_OpeningAngle", fV0Reader->GetOpeningAngle());
e60f3265 1519
1520 // Specific histograms for beam pipe studies
1521 if( TMath::Abs(fV0Reader->GetZ()) < fV0Reader->GetLineCutZValue() ){
1522 fHistograms->FillHistogram("ESD_Conversion_XY_BeamPipe", fV0Reader->GetX(),fV0Reader->GetY());
1523 fHistograms->FillHistogram("ESD_Conversion_RPhi_BeamPipe", vtxConv.Phi(),fV0Reader->GetXYRadius());
1524 }
1525
1526
d7d7e825 1527 fHistograms->FillHistogram("ESD_E_Energy", fV0Reader->GetNegativeTrackEnergy());
1528 fHistograms->FillHistogram("ESD_E_Pt", fV0Reader->GetNegativeTrackPt());
1529 fHistograms->FillHistogram("ESD_E_Eta", fV0Reader->GetNegativeTrackEta());
1530 fHistograms->FillHistogram("ESD_E_Phi", fV0Reader->GetNegativeTrackPhi());
ebcfaa7e 1531 fHistograms->FillHistogram("ESD_E_nTPCClusters", fV0Reader->GetNegativeTracknTPCClusters());
1532 fHistograms->FillHistogram("ESD_E_nITSClusters", fV0Reader->GetNegativeTracknITSClusters());
5ce758b0 1533 if(fV0Reader->GetNegativeTracknTPCFClusters()!=0 && fV0Reader->GetNegativeTracknTPCClusters()!=0 ){
77ac6f3e 1534 Double_t eClsToF= (Double_t)fV0Reader->GetNegativeTracknTPCClusters()/(Double_t)fV0Reader->GetNegativeTracknTPCFClusters();
1535 fHistograms->FillHistogram("ESD_E_nTPCClustersToFP", fV0Reader->GetNegativeTrackP(),eClsToF );
5ce758b0 1536 fHistograms->FillHistogram("ESD_E_TPCchi2", fV0Reader->GetNegativeTrackTPCchi2()/(Double_t)fV0Reader->GetNegativeTracknTPCClusters());
1537 }
1538
1539
1540
d7d7e825 1541 fHistograms->FillHistogram("ESD_P_Energy", fV0Reader->GetPositiveTrackEnergy());
1542 fHistograms->FillHistogram("ESD_P_Pt", fV0Reader->GetPositiveTrackPt());
1543 fHistograms->FillHistogram("ESD_P_Eta", fV0Reader->GetPositiveTrackEta());
1544 fHistograms->FillHistogram("ESD_P_Phi", fV0Reader->GetPositiveTrackPhi());
ebcfaa7e 1545 fHistograms->FillHistogram("ESD_P_nTPCClusters", fV0Reader->GetPositiveTracknTPCClusters());
1546 fHistograms->FillHistogram("ESD_P_nITSClusters", fV0Reader->GetPositiveTracknITSClusters());
5ce758b0 1547 if(fV0Reader->GetPositiveTracknTPCFClusters()!=0 && (Double_t)fV0Reader->GetPositiveTracknTPCClusters()!=0 ){
77ac6f3e 1548 Double_t pClsToF= (Double_t)fV0Reader->GetPositiveTracknTPCClusters()/(Double_t)fV0Reader->GetPositiveTracknTPCFClusters();
1549 fHistograms->FillHistogram("ESD_P_nTPCClustersToFP",fV0Reader->GetPositiveTrackP(), pClsToF);
5ce758b0 1550 fHistograms->FillHistogram("ESD_P_TPCchi2", fV0Reader->GetPositiveTrackTPCchi2()/(Double_t)fV0Reader->GetPositiveTracknTPCClusters());
1551 }
1552
1553
d7d7e825 1554 fHistograms->FillHistogram("ESD_ConvGamma_Energy", fV0Reader->GetMotherCandidateEnergy());
1555 fHistograms->FillHistogram("ESD_ConvGamma_Pt", fV0Reader->GetMotherCandidatePt());
1556 fHistograms->FillHistogram("ESD_ConvGamma_Eta", fV0Reader->GetMotherCandidateEta());
1557 fHistograms->FillHistogram("ESD_ConvGamma_Phi", fV0Reader->GetMotherCandidatePhi());
1558 fHistograms->FillHistogram("ESD_ConvGamma_Mass", fV0Reader->GetMotherCandidateMass());
1559 fHistograms->FillHistogram("ESD_ConvGamma_Width", fV0Reader->GetMotherCandidateWidth());
1560 fHistograms->FillHistogram("ESD_ConvGamma_Chi2", fV0Reader->GetMotherCandidateChi2());
1561 fHistograms->FillHistogram("ESD_ConvGamma_NDF", fV0Reader->GetMotherCandidateNDF());
1562 fHistograms->FillHistogram("ESD_ConvGamma_Rapid", fV0Reader->GetMotherCandidateRapidity());
1563 fHistograms->FillHistogram("ESD_ConvGamma_Pt_Eta", fV0Reader->GetMotherCandidatePt(),fV0Reader->GetMotherCandidateEta());
1564
1565 fHistograms->FillHistogram("ESD_ConvGamma_Pt_Chi2", fV0Reader->GetMotherCandidatePt(), fV0Reader->GetMotherCandidateChi2());
1566 fHistograms->FillHistogram("ESD_ConvGamma_Eta_Chi2", fV0Reader->GetMotherCandidateEta(), fV0Reader->GetMotherCandidateChi2());
9640a3d1 1567
1568 fHistograms->FillHistogram("ESD_ConvGamma_CosPointingAngle", fV0Reader->GetCosPointingAngle());
1569 fHistograms->FillHistogram("ESD_ConvGamma_DcaDaughters", fV0Reader->GetDcaDaughters());
1570 fHistograms->FillHistogram("ESD_ConvGamma_NormDcaDistDaughters", fV0Reader->GetNormDcaDistDaughters());
1571 fHistograms->FillHistogram("ESD_ConvGamma_LikelihoodAP", fV0Reader->GetLikelihoodAP());
1572
1573 fHistograms->FillHistogram("ESD_ConvGamma_E_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetNegativeTrackP()/fV0Reader->GetMotherCandidateP());
1574 fHistograms->FillHistogram("ESD_ConvGamma_P_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetPositiveTrackP()/fV0Reader->GetMotherCandidateP());
1575 fHistograms->FillHistogram("ESD_ConvGamma_E_dEdxP",fV0Reader->GetNegativeTrackP(),fV0Reader->GetNegativeTrackTPCdEdx());
1576 fHistograms->FillHistogram("ESD_ConvGamma_P_dEdxP",fV0Reader->GetPositiveTrackP(),fV0Reader->GetPositiveTrackTPCdEdx());
1577
9c1cb6f7 1578 Double_t negPID=0;
1579 Double_t posPID=0;
1580 fV0Reader->GetPIDProbability(negPID,posPID);
1581 fHistograms->FillHistogram("ESD_ConvGamma_E_EProbP",fV0Reader->GetNegativeTrackP(),negPID);
1582 fHistograms->FillHistogram("ESD_ConvGamma_P_EProbP",fV0Reader->GetPositiveTrackP(),posPID);
1583
1584 Double_t negPIDmupi=0;
1585 Double_t posPIDmupi=0;
1586 fV0Reader->GetPIDProbabilityMuonPion(negPIDmupi,posPIDmupi);
1587 fHistograms->FillHistogram("ESD_ConvGamma_E_mupiProbP",fV0Reader->GetNegativeTrackP(),negPIDmupi);
1588 fHistograms->FillHistogram("ESD_ConvGamma_P_mupiProbP",fV0Reader->GetPositiveTrackP(),posPIDmupi);
1589
48682642 1590 Double_t armenterosQtAlfa[2];
1591 fV0Reader->GetArmenterosQtAlfa(fV0Reader-> GetNegativeKFParticle(),
1592 fV0Reader-> GetPositiveKFParticle(),
1593 fV0Reader->GetMotherCandidateKFCombination(),
1594 armenterosQtAlfa);
1595
1596 fHistograms->FillHistogram("ESD_ConvGamma_alfa_qt",armenterosQtAlfa[1],armenterosQtAlfa[0]);
1597
037dc2db 1598
d7d7e825 1599 // begin mapping
1600 Int_t rBin = fHistograms->GetRBin(fV0Reader->GetXYRadius());
9640a3d1 1601 Int_t zBin = fHistograms->GetZBin(fV0Reader->GetZ());
d7d7e825 1602 Int_t phiBin = fHistograms->GetPhiBin(fV0Reader->GetNegativeTrackPhi());
9c1cb6f7 1603 Double_t rFMD=30;
64f4118c 1604 Double_t rITSTPCMin=50;
1605 Double_t rITSTPCMax=80;
e60f3265 1606
9640a3d1 1607
ebcfaa7e 1608 // Double_t motherCandidateEta= fV0Reader->GetMotherCandidateEta();
d7d7e825 1609
1610 TString nameESDMappingPhiR="";
e158cbc3 1611 nameESDMappingPhiR.Form("ESD_Conversion_Mapping_Phi%02d_R%02d",phiBin,rBin);
ebcfaa7e 1612 //fHistograms->FillHistogram(nameESDMappingPhiR, fV0Reader->GetZ(), motherCandidateEta);
d7d7e825 1613
1614 TString nameESDMappingPhi="";
e158cbc3 1615 nameESDMappingPhi.Form("ESD_Conversion_Mapping_Phi%02d",phiBin);
ebcfaa7e 1616 //fHistograms->FillHistogram(nameESDMappingPhi, fV0Reader->GetZ(), motherCandidateEta);
d7d7e825 1617
1618 TString nameESDMappingR="";
e158cbc3 1619 nameESDMappingR.Form("ESD_Conversion_Mapping_R%02d",rBin);
ebcfaa7e 1620 //fHistograms->FillHistogram(nameESDMappingR, fV0Reader->GetZ(), motherCandidateEta);
d7d7e825 1621
1622 TString nameESDMappingPhiInR="";
e158cbc3 1623 nameESDMappingPhiInR.Form("ESD_Conversion_Mapping_Phi_in_R_%02d",rBin);
9640a3d1 1624 // fHistograms->FillHistogram(nameESDMappingPhiInR, fV0Reader->GetMotherCandidatePhi());
1625 fHistograms->FillHistogram(nameESDMappingPhiInR, vtxConv.Phi());
1626
1627 TString nameESDMappingZInR="";
1628 nameESDMappingZInR.Form("ESD_Conversion_Mapping_Z_in_R_%02d",rBin);
1629 fHistograms->FillHistogram(nameESDMappingZInR, fV0Reader->GetZ());
1630
1631 TString nameESDMappingPhiInZ="";
1632 nameESDMappingPhiInZ.Form("ESD_Conversion_Mapping_Phi_in_Z_%02d",zBin);
1633 // fHistograms->FillHistogram(nameESDMappingPhiInR, fV0Reader->GetMotherCandidatePhi());
1634 fHistograms->FillHistogram(nameESDMappingPhiInZ, vtxConv.Phi());
1635
9c1cb6f7 1636 if(fV0Reader->GetXYRadius()<rFMD){
1637 TString nameESDMappingFMDPhiInZ="";
1638 nameESDMappingFMDPhiInZ.Form("ESD_Conversion_Mapping_FMD_Phi_in_Z_%02d",zBin);
1639 fHistograms->FillHistogram(nameESDMappingFMDPhiInZ, vtxConv.Phi());
1640 }
1641
64f4118c 1642 if(fV0Reader->GetXYRadius()>rITSTPCMin && fV0Reader->GetXYRadius()<rITSTPCMax){
1643 TString nameESDMappingITSTPCPhiInZ="";
1644 nameESDMappingITSTPCPhiInZ.Form("ESD_Conversion_Mapping_ITSTPC_Phi_in_Z_%02d",zBin);
1645 fHistograms->FillHistogram(nameESDMappingITSTPCPhiInZ, vtxConv.Phi());
1646 }
9c1cb6f7 1647
9640a3d1 1648 TString nameESDMappingRInZ="";
1649 nameESDMappingRInZ.Form("ESD_Conversion_Mapping_R_in_Z_%02d",zBin);
1650 fHistograms->FillHistogram(nameESDMappingRInZ, fV0Reader->GetXYRadius());
1651
1652 if(fV0Reader->GetMotherCandidatePt() > fLowPtMapping && fV0Reader->GetMotherCandidatePt()< fHighPtMapping){
1653 TString nameESDMappingMidPtPhiInR="";
1654 nameESDMappingMidPtPhiInR.Form("ESD_Conversion_Mapping_MidPt_Phi_in_R_%02d",rBin);
1655 fHistograms->FillHistogram(nameESDMappingMidPtPhiInR, vtxConv.Phi());
1656
1657 TString nameESDMappingMidPtZInR="";
1658 nameESDMappingMidPtZInR.Form("ESD_Conversion_Mapping_MidPt_Z_in_R_%02d",rBin);
1659 fHistograms->FillHistogram(nameESDMappingMidPtZInR, fV0Reader->GetZ());
1660
1661 TString nameESDMappingMidPtPhiInZ="";
1662 nameESDMappingMidPtPhiInZ.Form("ESD_Conversion_Mapping_MidPt_Phi_in_Z_%02d",zBin);
1663 fHistograms->FillHistogram(nameESDMappingMidPtPhiInZ, vtxConv.Phi());
9c1cb6f7 1664 if(fV0Reader->GetXYRadius()<rFMD){
1665 TString nameESDMappingMidPtFMDPhiInZ="";
1666 nameESDMappingMidPtFMDPhiInZ.Form("ESD_Conversion_Mapping_MidPt_FMD_Phi_in_Z_%02d",zBin);
1667 fHistograms->FillHistogram(nameESDMappingMidPtFMDPhiInZ, vtxConv.Phi());
1668 }
1669
9640a3d1 1670
1671 TString nameESDMappingMidPtRInZ="";
1672 nameESDMappingMidPtRInZ.Form("ESD_Conversion_Mapping_MidPt_R_in_Z_%02d",zBin);
1673 fHistograms->FillHistogram(nameESDMappingMidPtRInZ, fV0Reader->GetXYRadius());
1674
1675 }
1676
1677
d7d7e825 1678 // end mapping
1679
6c84d371 1680 new((*fKFReconstructedGammasTClone)[fKFReconstructedGammasTClone->GetEntriesFast()]) AliKFParticle(*fV0Reader->GetMotherCandidateKFCombination());
037dc2db 1681 fKFReconstructedGammasV0Index.push_back(fV0Reader->GetCurrentV0IndexNumber()-1);
6c84d371 1682 // fKFReconstructedGammas.push_back(*fV0Reader->GetMotherCandidateKFCombination());
d7d7e825 1683 fElectronv1.push_back(fV0Reader->GetCurrentV0()->GetPindex());
1684 fElectronv2.push_back(fV0Reader->GetCurrentV0()->GetNindex());
a0b94e5c 1685
d7d7e825 1686 //----------------------------------- checking for "real" conversions (MC match) --------------------------------------
1687 if(fDoMCTruth){
64f4118c 1688 TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
1689 TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
d7d7e825 1690
a68437fb 1691 if(fV0Reader->HasSameMCMother() == kFALSE){
64f4118c 1692 fHistograms->FillHistogram("ESD_TrueConvCombinatorial_R", fV0Reader->GetXYRadius());
1693 if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){
1694 fHistograms->FillHistogram("ESD_TrueConvCombinatorialElec_R", fV0Reader->GetXYRadius());
1695 }
a68437fb 1696 continue;
1697 }
64f4118c 1698 // Moved up to check true electron background
1699 // TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
1700 // TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
a68437fb 1701
1702 if(TMath::Abs(negativeMC->GetPdgCode())!=11 || TMath::Abs(positiveMC->GetPdgCode())!=11){
1703 continue;
1704 }
1705
1706 if(negativeMC->GetPdgCode()==positiveMC->GetPdgCode()){
1707 continue;
1708 }
bd6d9fa3 1709 if( (negativeMC->GetUniqueID() == 4 && positiveMC->GetUniqueID() ==4) ||
1710 (negativeMC->GetUniqueID() == 0 && positiveMC->GetUniqueID() ==0) ){// fill r distribution for Dalitz decays
037dc2db 1711 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 111){ //pi0
1712 fHistograms->FillHistogram("ESD_TrueDalitzContamination_R", fV0Reader->GetXYRadius());
64f4118c 1713 fHistograms->FillHistogram("ESD_TrueConvDalitzPi0_R", fV0Reader->GetXYRadius());
037dc2db 1714 }
64f4118c 1715 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 221){ //eta
1716 fHistograms->FillHistogram("ESD_TrueConvDalitzEta_R", fV0Reader->GetXYRadius());
1717 }
1718
037dc2db 1719 }
a68437fb 1720
1721 if(negativeMC->GetUniqueID() != 5 || positiveMC->GetUniqueID() !=5){// check if the daughters come from a conversion
1722 continue;
1723 }
a0b94e5c 1724
d7d7e825 1725 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
a68437fb 1726
26923b22 1727 if(fDoCF){
1728 Double_t containerInput[3];
1729 containerInput[0] = fV0Reader->GetMotherCandidatePt();
1730 containerInput[1] = fV0Reader->GetMotherCandidateEta();
1731 containerInput[2] = fV0Reader->GetMotherCandidateMass();
1732 fCFManager->GetParticleContainer()->Fill(containerInput,kStepTrueGamma); // for CF
1733 }
1734
d7d7e825 1735 fHistograms->FillHistogram("ESD_TrueConvGamma_Pt", fV0Reader->GetMotherCandidatePt());
1736 fHistograms->FillHistogram("ESD_TrueConvGamma_Energy", fV0Reader->GetMotherCandidateEnergy());
1737 fHistograms->FillHistogram("ESD_TrueConvGamma_Eta", fV0Reader->GetMotherCandidateEta());
1738 fHistograms->FillHistogram("ESD_TrueConvGamma_Phi", fV0Reader->GetMotherCandidatePhi());
1739 fHistograms->FillHistogram("ESD_TrueConvGamma_Mass", fV0Reader->GetMotherCandidateMass());
1740 fHistograms->FillHistogram("ESD_TrueConvGamma_Width", fV0Reader->GetMotherCandidateWidth());
1741 fHistograms->FillHistogram("ESD_TrueConvGamma_Chi2", fV0Reader->GetMotherCandidateChi2());
1742 fHistograms->FillHistogram("ESD_TrueConvGamma_NDF", fV0Reader->GetMotherCandidateNDF());
1743 fHistograms->FillHistogram("ESD_TrueConvGamma_Pt_Eta", fV0Reader->GetMotherCandidatePt(),fV0Reader->GetMotherCandidateEta());
1744 fHistograms->FillHistogram("ESD_TrueConvGamma_Rapid", fV0Reader->GetMotherCandidateRapidity());
1745 fHistograms->FillHistogram("ESD_TrueConvGamma_TrackLength", /*fV0Reader->GetNegativeTrackLength()*/fV0Reader->GetNegativeNTPCClusters());
1746 fHistograms->FillHistogram("ESD_TrueConvGamma_TrackLength", /*fV0Reader->GetPositiveTrackLength()*/fV0Reader->GetPositiveNTPCClusters());
1747 fHistograms->FillHistogram("ESD_TrueConvGamma_TrackLengthVSInvMass",/*fV0Reader->GetNegativeTrackLength()*/fV0Reader->GetNegativeNTPCClusters(),fV0Reader->GetMotherCandidateMass());
1748 fHistograms->FillHistogram("ESD_TrueConvGamma_TrackLengthVSInvMass",/*fV0Reader->GetPositiveTrackLength()*/fV0Reader->GetPositiveNTPCClusters(),fV0Reader->GetMotherCandidateMass());
a0b94e5c 1749
d7d7e825 1750 fHistograms->FillHistogram("ESD_TrueConvGamma_Pt_Chi2", fV0Reader->GetMotherCandidatePt(), fV0Reader->GetMotherCandidateChi2());
1751 fHistograms->FillHistogram("ESD_TrueConvGamma_Eta_Chi2", fV0Reader->GetMotherCandidateEta(), fV0Reader->GetMotherCandidateChi2());
a0b94e5c 1752
d7d7e825 1753
1754 fHistograms->FillHistogram("ESD_TrueConversion_XY", fV0Reader->GetX(),fV0Reader->GetY());
1755 fHistograms->FillHistogram("ESD_TrueConversion_R", fV0Reader->GetXYRadius());
1756 fHistograms->FillHistogram("ESD_TrueConversion_ZR", fV0Reader->GetZ(),fV0Reader->GetXYRadius());
1757 fHistograms->FillHistogram("ESD_TrueConversion_OpeningAngle", fV0Reader->GetOpeningAngle());
9640a3d1 1758
1759 fHistograms->FillHistogram("ESD_TrueConvGamma_CosPointingAngle", fV0Reader->GetCosPointingAngle());
1760 fHistograms->FillHistogram("ESD_TrueConvGamma_DcaDaughters", fV0Reader->GetDcaDaughters());
1761 fHistograms->FillHistogram("ESD_TrueConvGamma_NormDcaDistDaughters", fV0Reader->GetNormDcaDistDaughters());
1762 fHistograms->FillHistogram("ESD_TrueConvGamma_LikelihoodAP", fV0Reader->GetLikelihoodAP());
96ade8ef 1763 if (fV0Reader->GetMotherCandidateP() != 0) {
1764 fHistograms->FillHistogram("ESD_TrueConvGamma_E_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetNegativeTrackP()/fV0Reader->GetMotherCandidateP());
1765 fHistograms->FillHistogram("ESD_TrueConvGamma_P_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetPositiveTrackP()/fV0Reader->GetMotherCandidateP());
1766 } else { cout << "Error::fV0Reader->GetNegativeTrackP() == 0 !!!" << endl; }
1767
9640a3d1 1768 fHistograms->FillHistogram("ESD_TrueConvGamma_E_dEdxP",fV0Reader->GetNegativeTrackP(),fV0Reader->GetNegativeTrackTPCdEdx());
1769 fHistograms->FillHistogram("ESD_TrueConvGamma_P_dEdxP",fV0Reader->GetPositiveTrackP(),fV0Reader->GetPositiveTrackTPCdEdx());
70ef88b5 1770 fHistograms->FillHistogram("ESD_TrueConvGamma_alfa_qt",armenterosQtAlfa[1],armenterosQtAlfa[0]);
1771
9640a3d1 1772
a0b94e5c 1773
d7d7e825 1774 //store MCTruth properties
1775 fHistograms->FillHistogram("ESD_TrueConvGamma_MC_Pt_Eta", fV0Reader->GetMotherMCParticle()->Pt(),fV0Reader->GetMotherMCParticle()->Eta());
1776 fHistograms->FillHistogram("ESD_TrueConversion_MC_ZR", negativeMC->Vz(),negativeMC->R());
1777 fHistograms->FillHistogram("ESD_TrueConversion_MC_XY", negativeMC->Vx(),negativeMC->Vy());
48682642 1778
d7d7e825 1779 //resolution
1780 Double_t mcpt = fV0Reader->GetMotherMCParticle()->Pt();
1781 Double_t esdpt = fV0Reader->GetMotherCandidatePt();
9c1cb6f7 1782 Double_t resdPt = 0.;
4a6157dc 1783 if(mcpt > 0){
9c1cb6f7 1784 resdPt = ((esdpt - mcpt)/mcpt)*100.;
d7d7e825 1785 }
4a6157dc 1786 else if(mcpt < 0){
1787 cout<<"Pt of MC particle is negative, this will cause wrong calculation of resPt"<<endl;
1788 }
d7d7e825 1789
ca6d4600 1790 fHistograms->FillHistogram("Resolution_Gamma_dPt_Pt", mcpt, resdPt);
d7d7e825 1791 fHistograms->FillHistogram("Resolution_MC_Pt", mcpt);
1792 fHistograms->FillHistogram("Resolution_ESD_Pt", esdpt);
ca6d4600 1793 fHistograms->FillHistogram("Resolution_Gamma_dPt_Phi", fV0Reader->GetMotherCandidatePhi(), resdPt);
d7d7e825 1794
9c1cb6f7 1795 Double_t resdZ = 0.;
d7d7e825 1796 if(fV0Reader->GetNegativeMCParticle()->Vz() != 0){
9c1cb6f7 1797 resdZ = ((fV0Reader->GetZ() -fV0Reader->GetNegativeMCParticle()->Vz())/fV0Reader->GetNegativeMCParticle()->Vz())*100.;
d7d7e825 1798 }
9c1cb6f7 1799 Double_t resdZAbs = 0.;
037dc2db 1800 resdZAbs = (fV0Reader->GetZ() -fV0Reader->GetNegativeMCParticle()->Vz());
1801
1802 fHistograms->FillHistogram("Resolution_dZAbs_VS_R", fV0Reader->GetNegativeMCParticle()->R(), resdZAbs);
d7d7e825 1803 fHistograms->FillHistogram("Resolution_dZ", fV0Reader->GetNegativeMCParticle()->Vz(), resdZ);
1804 fHistograms->FillHistogram("Resolution_MC_Z", fV0Reader->GetNegativeMCParticle()->Vz());
1805 fHistograms->FillHistogram("Resolution_ESD_Z", fV0Reader->GetZ());
ca6d4600 1806
1807 // new for dPt_Pt-histograms for Electron and Positron
1808 Double_t mcEpt = fV0Reader->GetNegativeMCParticle()->Pt();
9c1cb6f7 1809 Double_t resEdPt = 0.;
ca6d4600 1810 if (mcEpt > 0){
9c1cb6f7 1811 resEdPt = ((fV0Reader->GetNegativeTrackPt()-mcEpt)/mcEpt)*100.;
ca6d4600 1812 }
1813 UInt_t statusN = fV0Reader->GetNegativeESDTrack()->GetStatus();
1814 // AliESDtrack * negTrk = fV0Reader->GetNegativeESDTrack();
1815 UInt_t kTRDoutN = (statusN & AliESDtrack::kTRDout);
1816
77ac6f3e 1817 Int_t nITSclsE= fV0Reader->GetNegativeTracknITSClusters();
ca6d4600 1818 // filling Resolution_Pt_dPt with respect to the Number of ITS clusters for Positrons
77ac6f3e 1819 switch(nITSclsE){
ca6d4600 1820 case 0: // 0 ITS clusters
1821 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS0", mcEpt, resEdPt);
1822 break;
1823 case 1: // 1 ITS cluster
1824 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS1", mcEpt, resEdPt);
1825 break;
1826 case 2: // 2 ITS clusters
1827 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS2", mcEpt, resEdPt);
1828 break;
1829 case 3: // 3 ITS clusters
1830 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS3", mcEpt, resEdPt);
1831 break;
1832 case 4: // 4 ITS clusters
1833 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS4", mcEpt, resEdPt);
1834 break;
1835 case 5: // 5 ITS clusters
1836 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS5", mcEpt, resEdPt);
1837 break;
1838 case 6: // 6 ITS clusters
1839 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS6", mcEpt, resEdPt);
1840 break;
1841 }
1842 //Filling histograms with respect to Electron resolution
1843 fHistograms->FillHistogram("Resolution_E_dPt_Pt", mcEpt, resEdPt);
1844 fHistograms->FillHistogram("Resolution_E_dPt_Phi", fV0Reader->GetNegativeTrackPhi(), resEdPt);
1845 if(kTRDoutN){
1846 fHistograms->FillHistogram("Resolution_E_nTRDtracklets_ESDPt", fV0Reader->GetNegativeTrackPt(), fV0Reader->GetNegativeESDTrack()->GetTRDntracklets());
1847 fHistograms->FillHistogram("Resolution_E_nTRDtracklets_MCPt", mcEpt, fV0Reader->GetNegativeESDTrack()->GetTRDntracklets());
1848 fHistograms->FillHistogram("Resolution_E_nTRDclusters_ESDPt",fV0Reader->GetNegativeTrackPt(), fV0Reader->GetNegativeESDTrack()->GetTRDncls());
1849 fHistograms->FillHistogram("Resolution_E_nTRDclusters_MCPt",mcEpt, fV0Reader->GetNegativeESDTrack()->GetTRDncls());
1850 fHistograms->FillHistogram("Resolution_E_TRDsignal_ESDPt", fV0Reader->GetNegativeTrackPt(), fV0Reader->GetNegativeESDTrack()->GetTRDsignal());
1851 }
1852
1853 Double_t mcPpt = fV0Reader->GetPositiveMCParticle()->Pt();
1854 Double_t resPdPt = 0;
1855 if (mcPpt > 0){
9c1cb6f7 1856 resPdPt = ((fV0Reader->GetPositiveTrackPt()-mcPpt)/mcPpt)*100.;
ca6d4600 1857 }
1858
1859 UInt_t statusP = fV0Reader->GetPositiveESDTrack()->GetStatus();
1860// AliESDtrack * posTr= fV0Reader->GetPositiveESDTrack();
1861 UInt_t kTRDoutP = (statusP & AliESDtrack::kTRDout);
1862
77ac6f3e 1863 Int_t nITSclsP = fV0Reader->GetPositiveTracknITSClusters();
ca6d4600 1864 // filling Resolution_Pt_dPt with respect to the Number of ITS clusters for Positrons
77ac6f3e 1865 switch(nITSclsP){
ca6d4600 1866 case 0: // 0 ITS clusters
1867 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS0", mcPpt, resPdPt);
1868 break;
1869 case 1: // 1 ITS cluster
1870 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS1", mcPpt, resPdPt);
1871 break;
1872 case 2: // 2 ITS clusters
1873 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS2", mcPpt, resPdPt);
1874 break;
1875 case 3: // 3 ITS clusters
1876 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS3", mcPpt, resPdPt);
1877 break;
1878 case 4: // 4 ITS clusters
1879 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS4", mcPpt, resPdPt);
1880 break;
1881 case 5: // 5 ITS clusters
1882 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS5", mcPpt, resPdPt);
1883 break;
1884 case 6: // 6 ITS clusters
1885 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS6", mcPpt, resPdPt);
1886 break;
1887 }
1888 //Filling histograms with respect to Positron resolution
1889 fHistograms->FillHistogram("Resolution_P_dPt_Pt", mcPpt, resPdPt);
1890 fHistograms->FillHistogram("Resolution_P_dPt_Phi", fV0Reader->GetPositiveTrackPhi(), resPdPt);
1891 if(kTRDoutP){
1892 fHistograms->FillHistogram("Resolution_P_nTRDtracklets_ESDPt", fV0Reader->GetPositiveTrackPt(), fV0Reader->GetPositiveESDTrack()->GetTRDntracklets());
1893 fHistograms->FillHistogram("Resolution_P_nTRDtracklets_MCPt", mcPpt, fV0Reader->GetPositiveESDTrack()->GetTRDntracklets());
1894 fHistograms->FillHistogram("Resolution_P_nTRDclusters_ESDPt",fV0Reader->GetPositiveTrackPt(), fV0Reader->GetPositiveESDTrack()->GetTRDncls());
1895 fHistograms->FillHistogram("Resolution_P_nTRDclusters_MCPt",mcPpt, fV0Reader->GetPositiveESDTrack()->GetTRDncls());
1896 fHistograms->FillHistogram("Resolution_P_TRDsignal_ESDPt", fV0Reader->GetPositiveTrackPt(), fV0Reader->GetPositiveESDTrack()->GetTRDsignal());
1897 }
1898
1899
9c1cb6f7 1900 Double_t resdR = 0.;
d7d7e825 1901 if(fV0Reader->GetNegativeMCParticle()->R() != 0){
9c1cb6f7 1902 resdR = ((fV0Reader->GetXYRadius() - fV0Reader->GetNegativeMCParticle()->R())/fV0Reader->GetNegativeMCParticle()->R())*100.;
d7d7e825 1903 }
9c1cb6f7 1904 Double_t resdRAbs = 0.;
037dc2db 1905 resdRAbs = (fV0Reader->GetXYRadius() - fV0Reader->GetNegativeMCParticle()->R());
1906
1907 fHistograms->FillHistogram("Resolution_dRAbs_VS_R", fV0Reader->GetNegativeMCParticle()->R(), resdRAbs);
d7d7e825 1908 fHistograms->FillHistogram("Resolution_dR", fV0Reader->GetNegativeMCParticle()->R(), resdR);
1909 fHistograms->FillHistogram("Resolution_MC_R", fV0Reader->GetNegativeMCParticle()->R());
1910 fHistograms->FillHistogram("Resolution_ESD_R", fV0Reader->GetXYRadius());
ca6d4600 1911 fHistograms->FillHistogram("Resolution_R_dPt", fV0Reader->GetNegativeMCParticle()->R(), resdPt);
1912
9c1cb6f7 1913 Double_t resdPhiAbs=0.;
1914 resdPhiAbs=0.;
037dc2db 1915 resdPhiAbs= (fV0Reader->GetMotherCandidatePhi()-fV0Reader->GetNegativeMCParticle()->Phi());
1916 fHistograms->FillHistogram("Resolution_dPhiAbs_VS_R", fV0Reader->GetNegativeMCParticle()->R(), resdPhiAbs);
1917
d7d7e825 1918 }//if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22)
d7d7e825 1919 }//if(fDoMCTruth)
1920 }//while(fV0Reader->NextV0)
1921 fHistograms->FillHistogram("ESD_NumberOfSurvivingV0s", nSurvivingV0s);
1922 fHistograms->FillHistogram("ESD_NumberOfV0s", fV0Reader->GetNumberOfV0s());
b5832f95 1923 fHistograms->FillHistogram("ESD_NumberOfContributorsVtx", fV0Reader->GetNumberOfContributorsVtx());
cb90a330 1924
1925 fV0Reader->ResetV0IndexNumber();
d7d7e825 1926}
1927
6441e967 1928void AliAnalysisTaskGammaConversion::AddToAODBranch(TClonesArray * branch, AliAODPWG4Particle & particle) {
1929 //See header file for documentation
1930
1931 Int_t i = branch->GetEntriesFast();
1932 if(! (fOutputAODClassName.Contains("Correlation")) ) {
1933 new((*branch)[i]) AliAODPWG4Particle(particle);
1934 } else {
1935 new((*branch)[i]) AliAODPWG4ParticleCorrelation(particle);
1936 }
1937}
1938
1939void AliAnalysisTaskGammaConversion::AddToAODBranch(TClonesArray * branch, AliGammaConversionAODObject & particle) {
1940 //See header file for documentation
1941
1942 Int_t i = branch->GetEntriesFast();
1943 new((*branch)[i]) AliGammaConversionAODObject(particle);
1944}
1945
1946void AliAnalysisTaskGammaConversion::AddToAODBranch(TClonesArray * branch, AliAODConversionParticle & particle) {
1947 //See header file for documentation
1948
1949 Int_t i = branch->GetEntriesFast();
1950 new((*branch)[i]) AliAODConversionParticle(particle);
1951}
1952
1953
d7d7e825 1954void AliAnalysisTaskGammaConversion::FillAODWithConversionGammas(){
1955 // Fill AOD with reconstructed Gamma
a0b94e5c 1956
6c84d371 1957 for(Int_t gammaIndex=0;gammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();gammaIndex++){
332f1f44 1958 AliKFParticle * gammakf = dynamic_cast<AliKFParticle*>(fKFReconstructedGammasTClone->At(gammaIndex));
6441e967 1959
1960 if(fOutputAODClassName.Contains("AliAODPWG4Particle")) {
1961 AliAODPWG4Particle gamma = AliAODPWG4Particle(gammakf->Px(),gammakf->Py(),gammakf->Pz(), gammakf->E());
1962 //gamma.SetLabel(-1);//How to get the MC label of the reconstructed gamma?
1963 gamma.SetTrackLabel( fElectronv1[gammaIndex], fElectronv2[gammaIndex] ); //How to get the MC label of the 2 electrons that form the gamma?
1964 gamma.SetDetector("CTS"); //tag the gamma as reconstructed in the central barrel
1965 gamma.SetPdg(AliPID::kEleCon); //photon id
1966 gamma.SetTag(-1); //Here I usually put a flag saying that montecarlo says it is prompt, decay fragmentation photon, or hadrons or whatever
caf688bd 1967 //PH gamma.SetChi2(gammakf->Chi2());
6441e967 1968
1969 AddToAODBranch(fAODGamma, gamma);
1970
1971 } else if(fOutputAODClassName.Contains("ConversionParticle")) {
1972 TLorentzVector momentum(gammakf->Px(),gammakf->Py(),gammakf->Pz(), gammakf->E());
1973 AliAODConversionParticle gamma = AliAODConversionParticle(momentum);
1974 //gamma.SetLabel(-1);//How to get the MC label of the reconstructed gamma?
1975 gamma.SetTrackLabels( fElectronv1[gammaIndex], fElectronv2[gammaIndex] ); //How to get the MC label of the 2 electrons that form the gamma?
1976 //gamma.SetPdg(AliPID::kEleCon); //photon id
1977 //gamma.SetTag(-1); //Here I usually put a flag saying that montecarlo says it is prompt, decay fragmentation photon, or hadrons or whatever
caf688bd 1978 //PH gamma.SetChi2(gammakf->Chi2());
6441e967 1979 gamma.SetTrackLabels( fElectronv1[gammaIndex], fElectronv2[gammaIndex] );
1980 gamma.SetESDEvent(dynamic_cast<AliESDEvent*>(InputEvent()));
1981 AddToAODBranch(fAODGamma, gamma);
1982
1983
1984
1985 } else {
1986 AliGammaConversionAODObject gamma;
1987 gamma.SetPx(gammakf->GetPx());
1988 gamma.SetPy(gammakf->GetPy());
1989 gamma.SetPz(gammakf->GetPz());
1990 gamma.SetLabel1(fElectronv1[gammaIndex]);
1991 gamma.SetLabel2(fElectronv2[gammaIndex]);
1992 gamma.SetChi2(gammakf->Chi2());
1993 gamma.SetE(gammakf->E());
1994 gamma.SetESDEvent(dynamic_cast<AliESDEvent*>(InputEvent()));
1995 AddToAODBranch(fAODGamma, gamma);
1996 }
a0b94e5c 1997
6441e967 1998 }
d7d7e825 1999}
6272370b 2000void AliAnalysisTaskGammaConversion::ProcessGammasForOmegaMesonAnalysis(){
2001 // omega meson analysis pi0+gamma decay
2002 for(Int_t firstPi0Index=0;firstPi0Index<fKFReconstructedPi0sTClone->GetEntriesFast();firstPi0Index++){
48682642 2003 AliKFParticle * omegaCandidatePi0Daughter = (AliKFParticle *)fKFReconstructedPi0sTClone->At(firstPi0Index);
6272370b 2004 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();firstGammaIndex++){
48682642 2005
6272370b 2006 AliKFParticle * omegaCandidateGammaDaughter = (AliKFParticle *)fKFReconstructedGammasTClone->At(firstGammaIndex);
2007 if(fGammav1[firstPi0Index]==firstGammaIndex || fGammav2[firstPi0Index]==firstGammaIndex){
2008 continue;
2009 }
2010
48682642 2011 AliKFParticle omegaCandidate(*omegaCandidatePi0Daughter,*omegaCandidateGammaDaughter);
6272370b 2012 Double_t massOmegaCandidate = 0.;
2013 Double_t widthOmegaCandidate = 0.;
2014
48682642 2015 omegaCandidate.GetMass(massOmegaCandidate,widthOmegaCandidate);
6272370b 2016
e9aea39f 2017 if ( massOmegaCandidate > 733 && massOmegaCandidate < 833 ) {
6441e967 2018 //AddOmegaToAOD(&omegaCandidate, massOmegaCandidate, firstPi0Index, firstGammaIndex);
c59360eb 2019 }
2020
48682642 2021 fHistograms->FillHistogram("ESD_Omega_InvMass_vs_Pt",massOmegaCandidate ,omegaCandidate.GetPt());
6272370b 2022 fHistograms->FillHistogram("ESD_Omega_InvMass",massOmegaCandidate);
48682642 2023
2024 //delete omegaCandidate;
2025
2026 }// end of omega reconstruction in pi0+gamma channel
2027
2028 if(fDoJet == kTRUE){
2029 AliKFParticle* negPiKF=NULL;
2030 AliKFParticle* posPiKF=NULL;
2031
2032 // look at the pi+pi+pi0 channel
2033 for(Int_t iCh=0;iCh<fChargedParticles->GetEntriesFast();iCh++){
2034 AliESDtrack* posTrack = (AliESDtrack*)(fChargedParticles->At(iCh));
2035 if (posTrack->GetSign()<0) continue;
c0d9051e 2036 if(TMath::Abs(fV0Reader->GetESDpid()->NumberOfSigmasTPC(posTrack,AliPID::kPion))>2.) continue;
48682642 2037 if (posPiKF) delete posPiKF; posPiKF=NULL;
2038 posPiKF = new AliKFParticle( *(posTrack) ,211);
2039
2040 for(Int_t jCh=0;jCh<fChargedParticles->GetEntriesFast();jCh++){
2041 AliESDtrack* negTrack = (AliESDtrack*)(fChargedParticles->At(jCh));
2042 if( negTrack->GetSign()>0) continue;
c0d9051e 2043 if(TMath::Abs(fV0Reader->GetESDpid()->NumberOfSigmasTPC(negTrack,AliPID::kPion))>2.) continue;
48682642 2044 if (negPiKF) delete negPiKF; negPiKF=NULL;
2045 negPiKF = new AliKFParticle( *(negTrack) ,-211);
2046 AliKFParticle omegaCandidatePipPinPi0(*omegaCandidatePi0Daughter,*posPiKF,*negPiKF);
2047 Double_t massOmegaCandidatePipPinPi0 = 0.;
2048 Double_t widthOmegaCandidatePipPinPi0 = 0.;
2049
2050 omegaCandidatePipPinPi0.GetMass(massOmegaCandidatePipPinPi0,widthOmegaCandidatePipPinPi0);
ef2e2748 2051
2052 if ( massOmegaCandidatePipPinPi0 > 733 && massOmegaCandidatePipPinPi0 < 833 ) {
6441e967 2053 // AddOmegaToAOD(&omegaCandidatePipPinPi0, massOmegaCandidatePipPinPi0, -1, -1);
ef2e2748 2054 }
48682642 2055
2056 fHistograms->FillHistogram("ESD_OmegaPipPinPi0_InvMass_vs_Pt",massOmegaCandidatePipPinPi0 ,omegaCandidatePipPinPi0.GetPt());
2057 fHistograms->FillHistogram("ESD_OmegaPipPinPi0_InvMass",massOmegaCandidatePipPinPi0);
2058
2059 // delete omegaCandidatePipPinPi0;
2060 }
2061 }
48682642 2062
45936300 2063 if (posPiKF) delete posPiKF; posPiKF=NULL; if (negPiKF) delete negPiKF; negPiKF=NULL;
48682642 2064
45936300 2065 } // checking ig gammajet because in that case the chargedparticle list is created
6272370b 2066
6272370b 2067 }
48682642 2068
2069 if(fCalculateBackground){
5ce758b0 2070
2071 AliGammaConversionBGHandler * bgHandler = fV0Reader->GetBGHandler();
2072
2073 Int_t zbin= bgHandler->GetZBinIndex(fV0Reader->GetVertexZ());
2074 Int_t mbin = 0;
2075 if(fUseTrackMultiplicityForBG == kTRUE){
2076 mbin = bgHandler->GetMultiplicityBinIndex(fV0Reader->CountESDTracks());
2077 }
2078 else{
2079 mbin = bgHandler->GetMultiplicityBinIndex(fV0Reader->GetNGoodV0s());
2080 }
2081
2082 AliGammaConversionBGHandler::GammaConversionVertex *bgEventVertex = NULL;
2083
48682642 2084 // Background calculation for the omega
2085 for(Int_t nEventsInBG=0;nEventsInBG <fV0Reader->GetNBGEvents();nEventsInBG++){
5ce758b0 2086 AliGammaConversionKFVector * previousEventV0s = bgHandler->GetBGGoodV0s(zbin,mbin,nEventsInBG);
2087
2088 if(fMoveParticleAccordingToVertex == kTRUE){
2089 bgEventVertex = bgHandler->GetBGEventVertex(zbin,mbin,nEventsInBG);
2090 }
48682642 2091 for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
2092 AliKFParticle previousGoodV0 = (AliKFParticle)(*(previousEventV0s->at(iPrevious)));
5ce758b0 2093
2094 if(fMoveParticleAccordingToVertex == kTRUE){
2095 MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
2096 }
2097
48682642 2098 for(Int_t firstPi0Index=0;firstPi0Index<fKFReconstructedPi0sTClone->GetEntriesFast();firstPi0Index++){
2099 AliKFParticle * omegaCandidatePi0Daughter = (AliKFParticle *)fKFReconstructedPi0sTClone->At(firstPi0Index);
2100 AliKFParticle * omegaBckCandidate = new AliKFParticle(*omegaCandidatePi0Daughter,previousGoodV0);
2101 Double_t massOmegaBckCandidate = 0.;
2102 Double_t widthOmegaBckCandidate = 0.;
2103
2104 omegaBckCandidate->GetMass(massOmegaBckCandidate,widthOmegaBckCandidate);
ef2e2748 2105
2106
48682642 2107 fHistograms->FillHistogram("ESD_Omega_Bck_InvMass_vs_Pt",massOmegaBckCandidate ,omegaBckCandidate->GetPt());
2108 fHistograms->FillHistogram("ESD_Omega_Bck_InvMass",massOmegaBckCandidate);
2109
2110 delete omegaBckCandidate;
2111 }
2112 }
2113 }
2114 } // end of checking if background calculation is available
6272370b 2115}
d7d7e825 2116
04bf4381 2117
77ac6f3e 2118void AliAnalysisTaskGammaConversion::AddOmegaToAOD(const AliKFParticle * const omegakf, Double_t mass, Int_t omegaDaughter, Int_t gammaDaughter) {
04bf4381 2119 //See header file for documentation
2120 AliGammaConversionAODObject omega;
77ac6f3e 2121 omega.SetPx(omegakf->GetPx());
2122 omega.SetPy(omegakf->GetPy());
2123 omega.SetPz(omegakf->GetPz());
04bf4381 2124 omega.SetChi2(omegakf->GetChi2());
77ac6f3e 2125 omega.SetE(omegakf->GetE());
04bf4381 2126 omega.SetIMass(mass);
2127 omega.SetLabel1(omegaDaughter);
6441e967 2128 // //dynamic_cast<AliAODPWG4Particle*>(fAODBranch->At(daughter1))->SetTagged(kTRUE);
04bf4381 2129 omega.SetLabel2(gammaDaughter);
6441e967 2130 AddToAODBranch(fAODOmega, omega);
04bf4381 2131}
2132
2133
2134
d7d7e825 2135void AliAnalysisTaskGammaConversion::ProcessGammasForNeutralMesonAnalysis(){
2136 // see header file for documentation
2137
6c84d371 2138 // for(UInt_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammas.size();firstGammaIndex++){
2139 // for(UInt_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fKFReconstructedGammas.size();secondGammaIndex++){
037dc2db 2140
5ce758b0 2141 fESDEvent = fV0Reader->GetESDEvent();
2142
037dc2db 2143 if(fKFReconstructedGammasTClone->GetEntriesFast()>fV0Reader->GetNumberOfV0s()){
2144 cout<<"Warning, number of entries in the tclone is bigger than number of v0s"<<endl;
2145 }
2146
6c84d371 2147 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();firstGammaIndex++){
2148 for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();secondGammaIndex++){
d7d7e825 2149
6c84d371 2150 // AliKFParticle * twoGammaDecayCandidateDaughter0 = &fKFReconstructedGammas[firstGammaIndex];
2151 // AliKFParticle * twoGammaDecayCandidateDaughter1 = &fKFReconstructedGammas[secondGammaIndex];
a0b94e5c 2152
6c84d371 2153 AliKFParticle * twoGammaDecayCandidateDaughter0 = (AliKFParticle *)fKFReconstructedGammasTClone->At(firstGammaIndex);
2154 AliKFParticle * twoGammaDecayCandidateDaughter1 = (AliKFParticle *)fKFReconstructedGammasTClone->At(secondGammaIndex);
a0b94e5c 2155
d7d7e825 2156 if(fElectronv1[firstGammaIndex]==fElectronv1[secondGammaIndex] || fElectronv1[firstGammaIndex]==fElectronv2[secondGammaIndex]){
2157 continue;
2158 }
2159 if(fElectronv2[firstGammaIndex]==fElectronv1[secondGammaIndex] || fElectronv2[firstGammaIndex]==fElectronv2[secondGammaIndex]){
2160 continue;
2161 }
a0b94e5c 2162
d7d7e825 2163 AliKFParticle *twoGammaCandidate = new AliKFParticle(*twoGammaDecayCandidateDaughter0,*twoGammaDecayCandidateDaughter1);
2164
2165 Double_t massTwoGammaCandidate = 0.;
2166 Double_t widthTwoGammaCandidate = 0.;
2167 Double_t chi2TwoGammaCandidate =10000.;
2168 twoGammaCandidate->GetMass(massTwoGammaCandidate,widthTwoGammaCandidate);
d707e3cf 2169 // if(twoGammaCandidate->GetNDF()>0){
2170 // chi2TwoGammaCandidate = twoGammaCandidate->GetChi2()/twoGammaCandidate->GetNDF();
2171 chi2TwoGammaCandidate = twoGammaCandidate->GetChi2();
d7d7e825 2172
70ef88b5 2173 fHistograms->FillHistogram("ESD_Mother_Chi2",chi2TwoGammaCandidate);
2e2da371 2174 if((chi2TwoGammaCandidate>0 && chi2TwoGammaCandidate<fV0Reader->GetChi2CutMeson()) || fApplyChi2Cut == kFALSE){
d7d7e825 2175
2176 TVector3 momentumVectorTwoGammaCandidate(twoGammaCandidate->GetPx(),twoGammaCandidate->GetPy(),twoGammaCandidate->GetPz());
2177 TVector3 spaceVectorTwoGammaCandidate(twoGammaCandidate->GetX(),twoGammaCandidate->GetY(),twoGammaCandidate->GetZ());
2178
2179 Double_t openingAngleTwoGammaCandidate = twoGammaDecayCandidateDaughter0->GetAngle(*twoGammaDecayCandidateDaughter1);
2180 Double_t rapidity;
96ade8ef 2181 if(twoGammaCandidate->GetE() - twoGammaCandidate->GetPz() <= 0 || twoGammaCandidate->GetE() + twoGammaCandidate->GetPz() <= 0){
2182 cout << "Error: |Pz| > E !!!! " << endl;
d7d7e825 2183 rapidity=0;
2184 }
2185 else{
2186 rapidity = 0.5*(TMath::Log((twoGammaCandidate->GetE() +twoGammaCandidate->GetPz()) / (twoGammaCandidate->GetE()-twoGammaCandidate->GetPz())));
2187 }
dc2883e4 2188
2189 if(TMath::Abs(rapidity) > fV0Reader->GetRapidityMesonCut()){
2190 delete twoGammaCandidate;
2191 continue; // rapidity cut
2192 }
2193
2194
48682642 2195 Double_t alfa=0.0;
2196 if( (twoGammaDecayCandidateDaughter0->GetE()+twoGammaDecayCandidateDaughter1->GetE()) != 0){
2197 alfa=TMath::Abs((twoGammaDecayCandidateDaughter0->GetE()-twoGammaDecayCandidateDaughter1->GetE())
2198 /(twoGammaDecayCandidateDaughter0->GetE()+twoGammaDecayCandidateDaughter1->GetE()));
2199 }
d7d7e825 2200
1e7846f4 2201 if(openingAngleTwoGammaCandidate < fMinOpeningAngleGhostCut){
2202 delete twoGammaCandidate;
2203 continue; // minimum opening angle to avoid using ghosttracks
2204 }
2205
67381a40 2206 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
6de3471d 2207 fHistograms->FillHistogram("ESD_Mother_GammaDaughter_OpeningAngle", openingAngleTwoGammaCandidate);
2208 fHistograms->FillHistogram("ESD_Mother_Energy", twoGammaCandidate->GetE());
2209 fHistograms->FillHistogram("ESD_Mother_Pt", momentumVectorTwoGammaCandidate.Pt());
2210 fHistograms->FillHistogram("ESD_Mother_Eta", momentumVectorTwoGammaCandidate.Eta());
2211 fHistograms->FillHistogram("ESD_Mother_Rapid", rapidity);
2212 fHistograms->FillHistogram("ESD_Mother_Phi", spaceVectorTwoGammaCandidate.Phi());
2213 fHistograms->FillHistogram("ESD_Mother_Mass", massTwoGammaCandidate);
2214 fHistograms->FillHistogram("ESD_Mother_alfa", alfa);
9da64c46 2215 if(massTwoGammaCandidate>0.1 && massTwoGammaCandidate<0.15){
2216 fHistograms->FillHistogram("ESD_Mother_alfa_Pi0", alfa);
2217 }
6de3471d 2218 fHistograms->FillHistogram("ESD_Mother_R", spaceVectorTwoGammaCandidate.Pt()); // Pt in Space == R!!!
2219 fHistograms->FillHistogram("ESD_Mother_ZR", twoGammaCandidate->GetZ(), spaceVectorTwoGammaCandidate.Pt());
2220 fHistograms->FillHistogram("ESD_Mother_XY", twoGammaCandidate->GetX(), twoGammaCandidate->GetY());
2221 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2222 fHistograms->FillHistogram("ESD_Mother_InvMass",massTwoGammaCandidate);
9c1cb6f7 2223 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt_alpha",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2224 }
3c45d101 2225 if(alfa<0.1){
2226 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_E_alpha",massTwoGammaCandidate ,twoGammaCandidate->GetE());
2227 }
6de3471d 2228
9640a3d1 2229
9c1cb6f7 2230 if(fCalculateBackground){
5ce758b0 2231 /* Kenneth, just for testing*/
2232 AliGammaConversionBGHandler * bgHandlerTest = fV0Reader->GetBGHandler();
2233
2234 Int_t zbin= bgHandlerTest->GetZBinIndex(fV0Reader->GetVertexZ());
2235 Int_t mbin=0;
2236 Int_t multKAA=0;
2237 if(fUseTrackMultiplicityForBG == kTRUE){
2238 multKAA=fV0Reader->CountESDTracks();
2239 mbin = bgHandlerTest->GetMultiplicityBinIndex(fV0Reader->CountESDTracks());
2240 }
2241 else{// means we use #v0s for multiplicity
2242 multKAA=fV0Reader->GetNGoodV0s();
2243 mbin = bgHandlerTest->GetMultiplicityBinIndex(fV0Reader->GetNGoodV0s());
2244 }
2245 // cout<<"Filling bin number "<<zbin<<" and "<<mbin<<endl;
2246 // cout<<"Corresponding to z = "<<fV0Reader->GetVertexZ()<<" and m = "<<multKAA<<endl;
6de3471d 2247 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
2248 fHistograms->FillHistogram(Form("%d%dESD_Mother_InvMass",zbin,mbin),massTwoGammaCandidate);
2249 fHistograms->FillHistogram(Form("%d%dESD_Mother_InvMass_vs_Pt",zbin,mbin),massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2250 /* end Kenneth, just for testing*/
2251 fHistograms->FillHistogram(Form("%dESD_Mother_InvMass_vs_Pt",mbin),massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2252 }
5ce758b0 2253 }
2254 /* if(fCalculateBackground){
9c1cb6f7 2255 AliGammaConversionBGHandler * bgHandler = fV0Reader->GetBGHandler();
2256 Int_t mbin= bgHandler->GetMultiplicityBinIndex(fV0Reader->CountESDTracks());
2257 fHistograms->FillHistogram(Form("%dESD_Mother_InvMass_vs_Pt",mbin),massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
5ce758b0 2258 }*/
ebcfaa7e 2259 // if(fDoNeutralMesonV0MCCheck){
2260 if(fDoMCTruth){
037dc2db 2261 //Kenneth: Checking the eta of the gamma to check the difference between 0.9 and 1.2
2262 Int_t indexKF1 = fKFReconstructedGammasV0Index.at(firstGammaIndex);
2263 if(indexKF1<fV0Reader->GetNumberOfV0s()){
2264 fV0Reader->GetV0(indexKF1);//updates to the correct v0
2265 Double_t eta1 = fV0Reader->GetMotherCandidateEta();
2266 Bool_t isRealPi0=kFALSE;
10e3319b 2267 Bool_t isRealEta=kFALSE;
037dc2db 2268 Int_t gamma1MotherLabel=-1;
2269 if(fV0Reader->HasSameMCMother() == kTRUE){
2270 //cout<<"This v0 is a real v0!!!!"<<endl;
2271 TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
2272 TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
2273 if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){
2274 if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){
2275 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
2276 gamma1MotherLabel=fV0Reader->GetMotherMCParticle()->GetFirstMother();
2277 }
2278 }
2279 }
2280 }
2281 Int_t indexKF2 = fKFReconstructedGammasV0Index.at(secondGammaIndex);
2282 if(indexKF1 == indexKF2){
2283 cout<<"index of the two KF particles are the same.... should not happen"<<endl;
2284 }
2285 if(indexKF2<fV0Reader->GetNumberOfV0s()){
2286 fV0Reader->GetV0(indexKF2);
2287 Double_t eta2 = fV0Reader->GetMotherCandidateEta();
2288 Int_t gamma2MotherLabel=-1;
2289 if(fV0Reader->HasSameMCMother() == kTRUE){
2290 TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
2291 TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
2292 if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){
2293 if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){
2294 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
2295 gamma2MotherLabel=fV0Reader->GetMotherMCParticle()->GetFirstMother();
2296 }
2297 }
2298 }
2299 }
2300 if(gamma1MotherLabel>=0 && gamma1MotherLabel==gamma2MotherLabel){
2301 if(fV0Reader->CheckIfPi0IsMother(gamma1MotherLabel)){
2302 isRealPi0=kTRUE;
2303 }
10e3319b 2304 if(fV0Reader->CheckIfEtaIsMother(gamma1MotherLabel)){
2305 isRealEta=kTRUE;
2306 }
2307
037dc2db 2308 }
6de3471d 2309 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
2310 if(TMath::Abs(eta1)>0.9 && TMath::Abs(eta2)>0.9){
2311 // fHistograms->FillHistogram("ESD_Mother_InvMass_1212",massTwoGammaCandidate);
2312 // fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt1212",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2313 if(isRealPi0 || isRealEta){
2314 fHistograms->FillHistogram("ESD_TruePi0_InvMass_1212",massTwoGammaCandidate);
2315 fHistograms->FillHistogram("ESD_TruePi0_OpeningAngle_1212",openingAngleTwoGammaCandidate);
2316 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt1212",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2317 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2318 fHistograms->FillHistogram("ESD_TruePi0_InvMass",massTwoGammaCandidate);
d707e3cf 2319 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt_alpha",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2320 }
6de3471d 2321
2322 if(!isRealPi0 && !isRealEta){
2323 if(gamma1MotherLabel>-1 && gamma2MotherLabel>-1){
2324 fHistograms->FillHistogram("ESD_TrueBckGG_InvMass",massTwoGammaCandidate);
2325 }else{
2326 fHistograms->FillHistogram("ESD_TrueBckCont_InvMass",massTwoGammaCandidate);
2327 }
bd6d9fa3 2328 }
bd6d9fa3 2329
6de3471d 2330 }
2331 else if(TMath::Abs(eta1)>0.9 || TMath::Abs(eta2)>0.9){
ebcfaa7e 2332 // fHistograms->FillHistogram("ESD_Mother_InvMass_0912",massTwoGammaCandidate);
2333 // fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt0912",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
6de3471d 2334
2335 if(isRealPi0 || isRealEta){
2336 fHistograms->FillHistogram("ESD_TruePi0_InvMass_0912",massTwoGammaCandidate);
2337 fHistograms->FillHistogram("ESD_TruePi0_OpeningAngle_0912",openingAngleTwoGammaCandidate);
2338 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt0912",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2339 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2340 fHistograms->FillHistogram("ESD_TruePi0_InvMass",massTwoGammaCandidate);
d707e3cf 2341 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt_alpha",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2342 }
6de3471d 2343 if(!isRealPi0 && !isRealEta){
2344 if(gamma1MotherLabel>-1 && gamma2MotherLabel>-1){
2345 fHistograms->FillHistogram("ESD_TrueBckGG_InvMass",massTwoGammaCandidate);
2346 }else{
2347 fHistograms->FillHistogram("ESD_TrueBckCont_InvMass",massTwoGammaCandidate);
2348 }
bd6d9fa3 2349 }
2350 }
6de3471d 2351 else{
ebcfaa7e 2352 // fHistograms->FillHistogram("ESD_Mother_InvMass_0909",massTwoGammaCandidate);
2353 // fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt0909",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
6de3471d 2354 if(isRealPi0 || isRealEta){
2355 fHistograms->FillHistogram("ESD_TruePi0_InvMass_0909",massTwoGammaCandidate);
2356 fHistograms->FillHistogram("ESD_TruePi0_OpeningAngle_0909",openingAngleTwoGammaCandidate);
2357 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt0909",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2358 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2359 fHistograms->FillHistogram("ESD_TruePi0_InvMass",massTwoGammaCandidate);
d707e3cf 2360 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt_alpha",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
6de3471d 2361 if(gamma1MotherLabel > fV0Reader->GetMCStack()->GetNprimary()){
2362 fHistograms->FillHistogram("ESD_TruePi0Sec_InvMass",massTwoGammaCandidate);
2363 }
d707e3cf 2364 }
6de3471d 2365 if(!isRealPi0 && !isRealEta){
2366 if(gamma1MotherLabel>-1 && gamma2MotherLabel>-1){
2367 fHistograms->FillHistogram("ESD_TrueBckGG_InvMass",massTwoGammaCandidate);
2368 }else{
2369 fHistograms->FillHistogram("ESD_TrueBckCont_InvMass",massTwoGammaCandidate);
2370 }
bd6d9fa3 2371 }
037dc2db 2372 }
2373 }
2374 }
2375 }
2376 }
6de3471d 2377 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
2378 if ( TMath::Abs(twoGammaDecayCandidateDaughter0->GetEta())<0.9 && TMath::Abs(twoGammaDecayCandidateDaughter1->GetEta())<0.9 ){
2379 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt_Fiducial",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2380 fHistograms->FillHistogram("ESD_Mother_InvMass_Fiducial",massTwoGammaCandidate);
2381 }
2382
2383 if(TMath::Abs(twoGammaDecayCandidateDaughter0->GetEta())>0.9 && TMath::Abs(twoGammaDecayCandidateDaughter1->GetEta())>0.9){
2384 fHistograms->FillHistogram("ESD_Mother_InvMass_1212",massTwoGammaCandidate);
2385 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt1212",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2386 }
2387 else if(TMath::Abs(twoGammaDecayCandidateDaughter0->GetEta())>0.9 || TMath::Abs(twoGammaDecayCandidateDaughter1->GetEta())>0.9){
2388 fHistograms->FillHistogram("ESD_Mother_InvMass_0912",massTwoGammaCandidate);
2389 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt0912",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2390 }
2391 else{
2392 fHistograms->FillHistogram("ESD_Mother_InvMass_0909",massTwoGammaCandidate);
2393 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt0909",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2394 }
ebcfaa7e 2395
6de3471d 2396 Double_t lowMassPi0=0.1;
2397 Double_t highMassPi0=0.15;
63477d82 2398 if ( fKFCreateAOD && (massTwoGammaCandidate > lowMassPi0) && (massTwoGammaCandidate < highMassPi0) ){
6de3471d 2399 new((*fKFReconstructedPi0sTClone)[fKFReconstructedPi0sTClone->GetEntriesFast()]) AliKFParticle(*twoGammaCandidate);
2400 fGammav1.push_back(firstGammaIndex);
2401 fGammav2.push_back(secondGammaIndex);
22eae5f9 2402 AddPionToAOD(twoGammaCandidate, massTwoGammaCandidate, firstGammaIndex, secondGammaIndex);
6de3471d 2403 }
ebcfaa7e 2404 }
6272370b 2405
2e2da371 2406 }
d707e3cf 2407 //}
6de3471d 2408 delete twoGammaCandidate;
d7d7e825 2409 }
2410 }
2411}
2412
22eae5f9 2413void AliAnalysisTaskGammaConversion::AddPionToAOD(AliKFParticle * pionkf, Double_t mass, Int_t daughter1, Int_t daughter2) {
04bf4381 2414 //See header file for documentation
22eae5f9 2415 if(fOutputAODClassName.Contains("AODObject")) {
2416 AliGammaConversionAODObject pion;
2417 pion.SetPx(pionkf->GetPx());
2418 pion.SetPy(pionkf->GetPy());
2419 pion.SetPz(pionkf->GetPz());
2420 pion.SetChi2(pionkf->GetChi2());
2421 pion.SetE(pionkf->GetE());
2422 pion.SetIMass(mass);
2423 pion.SetLabel1(daughter1);
2424 pion.SetLabel2(daughter2);
2425 AddToAODBranch(fAODPi0, pion);
2426 } else {
2427 TLorentzVector momentum(pionkf->Px(),pionkf->Py(),pionkf->Pz(), pionkf->E());
2428 AliAODConversionParticle pion = AliAODConversionParticle(momentum);
2429 pion.SetTrackLabels( daughter1, daughter2 );
2430 pion.SetChi2(pionkf->GetChi2());
2431 AddToAODBranch(fAODPi0, pion);
2432
2433 }
04bf4381 2434}
2435
2436
48682642 2437/*
77ac6f3e 2438 void AliAnalysisTaskGammaConversion::ProcessConvPHOSGammasForNeutralMesonAnalysis(){
2439
6272370b 2440 // see header file for documentation
2441 // Analyse Pi0 with one photon from Phos and 1 photon from conversions
2442
2443
2444
2445 Double_t vtx[3];
2446 vtx[0] = fV0Reader->GetPrimaryVertex()->GetX();
2447 vtx[1] = fV0Reader->GetPrimaryVertex()->GetY();
2448 vtx[2] = fV0Reader->GetPrimaryVertex()->GetZ();
2449
2450
2451 // Loop over all CaloClusters and consider only the PHOS ones:
2452 AliESDCaloCluster *clu;
2453 TLorentzVector pPHOS;
2454 TLorentzVector gammaPHOS;
2455 TLorentzVector gammaGammaConv;
2456 TLorentzVector pi0GammaConvPHOS;
2457 TLorentzVector gammaGammaConvBck;
2458 TLorentzVector pi0GammaConvPHOSBck;
2459
2460
2461 for (Int_t i=0; i<fV0Reader->GetESDEvent()->GetNumberOfCaloClusters(); i++) {
77ac6f3e 2462 clu = fV0Reader->GetESDEvent()->GetCaloCluster(i);
2463 if ( !clu->IsPHOS() || clu->E()<0.1 ) continue;
2464 clu ->GetMomentum(pPHOS ,vtx);
2465 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();firstGammaIndex++){
2466 AliKFParticle * twoGammaDecayCandidateDaughter0 = (AliKFParticle *)fKFReconstructedGammasTClone->At(firstGammaIndex);
2467 gammaGammaConv.SetXYZM(twoGammaDecayCandidateDaughter0->Px(),twoGammaDecayCandidateDaughter0->Py(),twoGammaDecayCandidateDaughter0->Pz(),0.);
2468 gammaPHOS.SetXYZM(pPHOS.Px(),pPHOS.Py(),pPHOS.Pz(),0.);
2469 pi0GammaConvPHOS=gammaGammaConv+gammaPHOS;
2470 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvPHOS",pi0GammaConvPHOS.M());
2471 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt_GammaConvPHOS",pi0GammaConvPHOS.M(),pi0GammaConvPHOS.Pt());
6272370b 2472
77ac6f3e 2473 TVector3 v3D0(twoGammaDecayCandidateDaughter0->Px(),twoGammaDecayCandidateDaughter0->Py(),twoGammaDecayCandidateDaughter0->Pz());
2474 TVector3 v3D1(gammaPHOS.Px(),gammaPHOS.Py(),gammaPHOS.Pz());
2475 Double_t opanConvPHOS= v3D0.Angle(v3D1);
2476 if ( opanConvPHOS < 0.35){
2477 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvPHOS_OpanLow",pi0GammaConvPHOS.M());
2478 }else{
2479 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvPHOS_OpanHigh",pi0GammaConvPHOS.M());
2480 }
6272370b 2481
77ac6f3e 2482 }
2483
2484 // Now the LorentVector pPHOS is obtained and can be paired with the converted proton
6272370b 2485 }
2486 //==== End of the PHOS cluster selection ============
2487 TLorentzVector pEMCAL;
2488 TLorentzVector gammaEMCAL;
2489 TLorentzVector pi0GammaConvEMCAL;
2490 TLorentzVector pi0GammaConvEMCALBck;
2491
77ac6f3e 2492 for (Int_t i=0; i<fV0Reader->GetESDEvent()->GetNumberOfCaloClusters(); i++) {
2493 clu = fV0Reader->GetESDEvent()->GetCaloCluster(i);
2494 if ( !clu->IsEMCAL() || clu->E()<0.1 ) continue;
2495 if (clu->GetNCells() <= 1) continue;
2496 if ( clu->GetTOF()*1e9 < 550 || clu->GetTOF()*1e9 > 750) continue;
6272370b 2497
77ac6f3e 2498 clu ->GetMomentum(pEMCAL ,vtx);
2499 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();firstGammaIndex++){
2500 AliKFParticle * twoGammaDecayCandidateDaughter0 = (AliKFParticle *)fKFReconstructedGammasTClone->At(firstGammaIndex);
2501 gammaGammaConv.SetXYZM(twoGammaDecayCandidateDaughter0->Px(),
2502 twoGammaDecayCandidateDaughter0->Py(),
2503 twoGammaDecayCandidateDaughter0->Pz(),0.);
2504 gammaEMCAL.SetXYZM(pEMCAL.Px(),pEMCAL.Py(),pEMCAL.Pz(),0.);
2505 pi0GammaConvEMCAL=gammaGammaConv+gammaEMCAL;
2506 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvEMCAL",pi0GammaConvEMCAL.M());
2507 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt_GammaConvEMCAL",pi0GammaConvEMCAL.M(),pi0GammaConvEMCAL.Pt());
2508 TVector3 v3D0(twoGammaDecayCandidateDaughter0->Px(),
2509 twoGammaDecayCandidateDaughter0->Py(),
2510 twoGammaDecayCandidateDaughter0->Pz());
2511 TVector3 v3D1(gammaEMCAL.Px(),gammaEMCAL.Py(),gammaEMCAL.Pz());
6272370b 2512
77ac6f3e 2513
2514 Double_t opanConvEMCAL= v3D0.Angle(v3D1);
2515 if ( opanConvEMCAL < 0.35){
2516 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvEMCAL_OpanLow",pi0GammaConvEMCAL.M());
2517 }else{
2518 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvEMCAL_OpanHigh",pi0GammaConvEMCAL.M());
2519 }
2520
2521 }
2522 if(fCalculateBackground){
2523 for(Int_t nEventsInBG=0;nEventsInBG <fV0Reader->GetNBGEvents();nEventsInBG++){
2524 AliGammaConversionKFVector * previousEventV0s = fV0Reader->GetBGGoodV0s(nEventsInBG);
2525 for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
2526 AliKFParticle previousGoodV0 = (AliKFParticle)(*(previousEventV0s->at(iPrevious)));
2527 gammaGammaConvBck.SetXYZM(previousGoodV0.Px(),
2528 previousGoodV0.Py(),
2529 previousGoodV0.Pz(),0.);
2530 pi0GammaConvEMCALBck=gammaGammaConvBck+gammaEMCAL;
2531 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvEMCAL_Bck",pi0GammaConvEMCALBck.M());
2532 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt_GammaConvEMCAL_Bck",pi0GammaConvEMCALBck.M(),
2533 pi0GammaConvEMCALBck.Pt());
2534 }
2535 }
48682642 2536
77ac6f3e 2537 // Now the LorentVector pEMCAL is obtained and can be paired with the converted proton
2538 } // end of checking if background photons are available
2539 }
6272370b 2540 //==== End of the PHOS cluster selection ============
77ac6f3e 2541
2542 }
48682642 2543*/
6272370b 2544
77ac6f3e 2545void AliAnalysisTaskGammaConversion::MoveParticleAccordingToVertex(AliKFParticle * particle,const AliGammaConversionBGHandler::GammaConversionVertex *vertex){
5ce758b0 2546 //see header file for documentation
2547
77ac6f3e 2548 Double_t dx = vertex->fX - fESDEvent->GetPrimaryVertex()->GetX();
2549 Double_t dy = vertex->fY - fESDEvent->GetPrimaryVertex()->GetY();
2550 Double_t dz = vertex->fZ - fESDEvent->GetPrimaryVertex()->GetZ();
5ce758b0 2551
2552 // cout<<"dx, dy, dz: ["<<dx<<","<<dy<<","<<dz<<"]"<<endl;
77ac6f3e 2553 particle->X() = particle->GetX() - dx;
2554 particle->Y() = particle->GetY() - dy;
2555 particle->Z() = particle->GetZ() - dz;
5ce758b0 2556}
2557
111d75df 2558void AliAnalysisTaskGammaConversion::RotateKFParticle(AliKFParticle * kfParticle,Double_t angle){
77ac6f3e 2559 // Rotate the kf particle
111d75df 2560 Double_t c = cos(angle);
2561 Double_t s = sin(angle);
2562
77ac6f3e 2563 Double_t mA[7][ 7];
111d75df 2564 for( Int_t i=0; i<7; i++ ){
2565 for( Int_t j=0; j<7; j++){
77ac6f3e 2566 mA[i][j] = 0;
111d75df 2567 }
2568 }
2569 for( int i=0; i<7; i++ ){
77ac6f3e 2570 mA[i][i] = 1;
111d75df 2571 }
77ac6f3e 2572 mA[0][0] = c; mA[0][1] = s;
2573 mA[1][0] = -s; mA[1][1] = c;
2574 mA[3][3] = c; mA[3][4] = s;
2575 mA[4][3] = -s; mA[4][4] = c;
111d75df 2576
77ac6f3e 2577 Double_t mAC[7][7];
2578 Double_t mAp[7];
111d75df 2579
2580 for( Int_t i=0; i<7; i++ ){
77ac6f3e 2581 mAp[i] = 0;
111d75df 2582 for( Int_t k=0; k<7; k++){
77ac6f3e 2583 mAp[i]+=mA[i][k] * kfParticle->GetParameter(k);
111d75df 2584 }
2585 }
2586
2587 for( Int_t i=0; i<7; i++){
77ac6f3e 2588 kfParticle->Parameter(i) = mAp[i];
111d75df 2589 }
2590
2591 for( Int_t i=0; i<7; i++ ){
2592 for( Int_t j=0; j<7; j++ ){
77ac6f3e 2593 mAC[i][j] = 0;
111d75df 2594 for( Int_t k=0; k<7; k++ ){
77ac6f3e 2595 mAC[i][j]+= mA[i][k] * kfParticle->GetCovariance(k,j);
111d75df 2596 }
2597 }
2598 }
2599
2600 for( Int_t i=0; i<7; i++ ){
2601 for( Int_t j=0; j<=i; j++ ){
2602 Double_t xx = 0;
2603 for( Int_t k=0; k<7; k++){
77ac6f3e 2604 xx+= mAC[i][k]*mA[j][k];
111d75df 2605 }
2606 kfParticle->Covariance(i,j) = xx;
2607 }
2608 }
2609}
2610
2611
d7d7e825 2612void AliAnalysisTaskGammaConversion::CalculateBackground(){
2613 // see header file for documentation
5e55d806 2614
2615
2616 TClonesArray * currentEventV0s = fV0Reader->GetCurrentEventGoodV0s();
2617
5ce758b0 2618 AliGammaConversionBGHandler * bgHandler = fV0Reader->GetBGHandler();
2619
2620 Int_t zbin= bgHandler->GetZBinIndex(fV0Reader->GetVertexZ());
2621 Int_t mbin = 0;
2622 if(fUseTrackMultiplicityForBG == kTRUE){
2623 mbin = bgHandler->GetMultiplicityBinIndex(fV0Reader->CountESDTracks());
2624 }
2625 else{
2626 mbin = bgHandler->GetMultiplicityBinIndex(fV0Reader->GetNGoodV0s());
2627 }
2628
111d75df 2629 if(fDoRotation == kTRUE){
3c45d101 2630 TRandom3 *random = new TRandom3();
111d75df 2631 for(Int_t iCurrent=0;iCurrent<currentEventV0s->GetEntriesFast();iCurrent++){
2632 AliKFParticle currentEventGoodV0 = *(AliKFParticle *)(currentEventV0s->At(iCurrent));
2633 for(Int_t iCurrent2=iCurrent+1;iCurrent2<currentEventV0s->GetEntriesFast();iCurrent2++){
77ac6f3e 2634 for(Int_t nRandom=0;nRandom<fNRandomEventsForBG;nRandom++){
111d75df 2635
2636 AliKFParticle currentEventGoodV02 = *(AliKFParticle *)(currentEventV0s->At(iCurrent2));
3bfbe89a 2637
2638 if(fCheckBGProbability == kTRUE){
2639 Double_t massBGprob =0.;
2640 Double_t widthBGprob = 0.;
2641 AliKFParticle *backgroundCandidateProb = new AliKFParticle(currentEventGoodV0,currentEventGoodV02);
2642 backgroundCandidateProb->GetMass(massBGprob,widthBGprob);
2643 if(massBGprob>0.1 && massBGprob<0.14){
2644 if(random->Rndm()>bgHandler->GetBGProb(zbin,mbin)){
2645 delete backgroundCandidateProb;
2646 continue;
2647 }
2648 }
2649 delete backgroundCandidateProb;
2650 }
111d75df 2651
77ac6f3e 2652 Double_t nRadiansPM = fNDegreesPMBackground*TMath::Pi()/180;
111d75df 2653
2654 Double_t rotationValue = random->Rndm()*2*nRadiansPM + TMath::Pi()-nRadiansPM;
5ce758b0 2655
111d75df 2656 RotateKFParticle(&currentEventGoodV02,rotationValue);
5ce758b0 2657
111d75df 2658 AliKFParticle *backgroundCandidate = new AliKFParticle(currentEventGoodV0,currentEventGoodV02);
5e55d806 2659
5ce758b0 2660 Double_t massBG =0.;
2661 Double_t widthBG = 0.;
2662 Double_t chi2BG =10000.;
2663 backgroundCandidate->GetMass(massBG,widthBG);
111d75df 2664
111d75df 2665 // if(backgroundCandidate->GetNDF()>0){
2666 chi2BG = backgroundCandidate->GetChi2();
2667 if((chi2BG>0 && chi2BG<fV0Reader->GetChi2CutMeson()) || fApplyChi2Cut == kFALSE){
2668
2669 TVector3 momentumVectorbackgroundCandidate(backgroundCandidate->GetPx(),backgroundCandidate->GetPy(),backgroundCandidate->GetPz());
2670 TVector3 spaceVectorbackgroundCandidate(backgroundCandidate->GetX(),backgroundCandidate->GetY(),backgroundCandidate->GetZ());
2671
2672 Double_t openingAngleBG = currentEventGoodV0.GetAngle(currentEventGoodV02);
2673
2674 Double_t rapidity;
2675 if(backgroundCandidate->GetE() - backgroundCandidate->GetPz() == 0 || backgroundCandidate->GetE() + backgroundCandidate->GetPz() == 0) rapidity=0;
2676 else rapidity = 0.5*(TMath::Log((backgroundCandidate->GetE() +backgroundCandidate->GetPz()) / (backgroundCandidate->GetE()-backgroundCandidate->GetPz())));
2677
dc2883e4 2678 if(TMath::Abs(rapidity) > fV0Reader->GetRapidityMesonCut() ){
2679 delete backgroundCandidate;
2680 continue; // rapidity cut
2681 }
2682
111d75df 2683
2684 Double_t alfa=0.0;
2685 if( (currentEventGoodV0.GetE()+currentEventGoodV02.GetE()) != 0){
2686 alfa=TMath::Abs((currentEventGoodV0.GetE()-currentEventGoodV02.GetE())
2687 /(currentEventGoodV0.GetE()+currentEventGoodV02.GetE()));
2688 }
2689
2690
2691 if(openingAngleBG < fMinOpeningAngleGhostCut ){
2692 delete backgroundCandidate;
2693 continue; // minimum opening angle to avoid using ghosttracks
2694 }
2695
2696 // original
111d75df 2697 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
6de3471d 2698 fHistograms->FillHistogram("ESD_Background_GammaDaughter_OpeningAngle", openingAngleBG);
2699 fHistograms->FillHistogram("ESD_Background_Energy", backgroundCandidate->GetE());
2700 fHistograms->FillHistogram("ESD_Background_Pt", momentumVectorbackgroundCandidate.Pt());
2701 fHistograms->FillHistogram("ESD_Background_Eta", momentumVectorbackgroundCandidate.Eta());
2702 fHistograms->FillHistogram("ESD_Background_Rapidity", rapidity);
2703 fHistograms->FillHistogram("ESD_Background_Phi", spaceVectorbackgroundCandidate.Phi());
2704 fHistograms->FillHistogram("ESD_Background_Mass", massBG);
2705 fHistograms->FillHistogram("ESD_Background_R", spaceVectorbackgroundCandidate.Pt()); // Pt in Space == R!!!!
2706 fHistograms->FillHistogram("ESD_Background_ZR", backgroundCandidate->GetZ(), spaceVectorbackgroundCandidate.Pt());
2707 fHistograms->FillHistogram("ESD_Background_XY", backgroundCandidate->GetX(), backgroundCandidate->GetY());
2708 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt",massBG,momentumVectorbackgroundCandidate.Pt());
2709 fHistograms->FillHistogram("ESD_Background_InvMass",massBG);
111d75df 2710 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt_alpha",massBG,momentumVectorbackgroundCandidate.Pt());
6de3471d 2711
2712
2713 if ( TMath::Abs(currentEventGoodV0.GetEta())<0.9 && TMath::Abs(currentEventGoodV02.GetEta())<0.9 ){
2714 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt_Fiducial",massBG,momentumVectorbackgroundCandidate.Pt());
2715 fHistograms->FillHistogram("ESD_Background_InvMass_Fiducial",massBG);
2716 }
2717
2718 fHistograms->FillHistogram(Form("%d%dESD_Background_GammaDaughter_OpeningAngle",zbin,mbin), openingAngleBG);
2719 fHistograms->FillHistogram(Form("%d%dESD_Background_Energy",zbin,mbin), backgroundCandidate->GetE());
2720 fHistograms->FillHistogram(Form("%d%dESD_Background_Pt",zbin,mbin), momentumVectorbackgroundCandidate.Pt());
2721 fHistograms->FillHistogram(Form("%d%dESD_Background_Eta",zbin,mbin), momentumVectorbackgroundCandidate.Eta());
2722 fHistograms->FillHistogram(Form("%d%dESD_Background_Rapidity",zbin,mbin), rapidity);
2723 fHistograms->FillHistogram(Form("%d%dESD_Background_Phi",zbin,mbin), spaceVectorbackgroundCandidate.Phi());
2724 fHistograms->FillHistogram(Form("%d%dESD_Background_Mass",zbin,mbin), massBG);
2725 fHistograms->FillHistogram(Form("%d%dESD_Background_R",zbin,mbin), spaceVectorbackgroundCandidate.Pt()); // Pt in Space == R!!!!
2726 fHistograms->FillHistogram(Form("%d%dESD_Background_ZR",zbin,mbin), backgroundCandidate->GetZ(), spaceVectorbackgroundCandidate.Pt());
2727 fHistograms->FillHistogram(Form("%d%dESD_Background_XY",zbin,mbin), backgroundCandidate->GetX(), backgroundCandidate->GetY());
2728 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_vs_Pt",zbin,mbin),massBG,momentumVectorbackgroundCandidate.Pt());
2729 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass",zbin,mbin),massBG);
2730
2731 if ( TMath::Abs(currentEventGoodV0.GetEta())<0.9 && TMath::Abs(currentEventGoodV02.GetEta())<0.9 ){
2732 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_vs_Pt_Fiducial",zbin,mbin),massBG,momentumVectorbackgroundCandidate.Pt());
2733 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_Fiducial",zbin,mbin),massBG);
2734 }
111d75df 2735 }
3c45d101 2736 if(alfa<0.1){
2737 fHistograms->FillHistogram("ESD_Background_InvMass_vs_E_alpha",massBG ,backgroundCandidate->GetE());
2738 }
2739
2e2da371 2740 }
111d75df 2741 //}
5ce758b0 2742 delete backgroundCandidate;
2743 }
2744 }
2745 }
111d75df 2746 delete random;
5ce758b0 2747 }
111d75df 2748 else{ // means no rotation
2749 AliGammaConversionBGHandler::GammaConversionVertex *bgEventVertex = NULL;
2750
2751 if(fUseTrackMultiplicityForBG){
2752 // cout<<"Using charged track multiplicity for background calculation"<<endl;
2753 for(Int_t nEventsInBG=0;nEventsInBG <fV0Reader->GetNBGEvents();nEventsInBG++){
5ce758b0 2754
111d75df 2755 AliGammaConversionKFVector * previousEventV0s = bgHandler->GetBGGoodV0s(zbin,mbin,nEventsInBG);//fV0Reader->GetBGGoodV0s(nEventsInBG);
2756
5ce758b0 2757 if(fMoveParticleAccordingToVertex == kTRUE){
2758 bgEventVertex = bgHandler->GetBGEventVertex(zbin,mbin,nEventsInBG);
2759 }
2760
2761 for(Int_t iCurrent=0;iCurrent<currentEventV0s->GetEntriesFast();iCurrent++){
2762 AliKFParticle currentEventGoodV0 = *(AliKFParticle *)(currentEventV0s->At(iCurrent));
2763 for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
2764 AliKFParticle previousGoodV0 = (AliKFParticle)(*(previousEventV0s->at(iPrevious)));
111d75df 2765 AliKFParticle previousGoodV0test = (AliKFParticle)(*(previousEventV0s->at(iPrevious)));
5ce758b0 2766
111d75df 2767 //cout<<"Primary Vertex event: ["<<fESDEvent->GetPrimaryVertex()->GetX()<<","<<fESDEvent->GetPrimaryVertex()->GetY()<<","<<fESDEvent->GetPrimaryVertex()->GetZ()<<"]"<<endl;
2768 //cout<<"BG prim Vertex event: ["<<bgEventVertex->fX<<","<<bgEventVertex->fY<<","<<bgEventVertex->fZ<<"]"<<endl;
2769
2770 //cout<<"XYZ of particle before transport: ["<<previousGoodV0.X()<<","<<previousGoodV0.Y()<<","<<previousGoodV0.Z()<<"]"<<endl;
5ce758b0 2771 if(fMoveParticleAccordingToVertex == kTRUE){
2772 MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
2773 }
111d75df 2774 //cout<<"XYZ of particle after transport: ["<<previousGoodV0.X()<<","<<previousGoodV0.Y()<<","<<previousGoodV0.Z()<<"]"<<endl;
5ce758b0 2775
2776 AliKFParticle *backgroundCandidate = new AliKFParticle(currentEventGoodV0,previousGoodV0);
111d75df 2777
5ce758b0 2778 Double_t massBG =0.;
2779 Double_t widthBG = 0.;
2780 Double_t chi2BG =10000.;
2781 backgroundCandidate->GetMass(massBG,widthBG);
111d75df 2782 // if(backgroundCandidate->GetNDF()>0){
2783 // chi2BG = backgroundCandidate->GetChi2()/backgroundCandidate->GetNDF();
2784 chi2BG = backgroundCandidate->GetChi2();
2785 if((chi2BG>0 && chi2BG<fV0Reader->GetChi2CutMeson()) || fApplyChi2Cut == kFALSE){
2786
2787 TVector3 momentumVectorbackgroundCandidate(backgroundCandidate->GetPx(),backgroundCandidate->GetPy(),backgroundCandidate->GetPz());
2788 TVector3 spaceVectorbackgroundCandidate(backgroundCandidate->GetX(),backgroundCandidate->GetY(),backgroundCandidate->GetZ());
2789
2790 Double_t openingAngleBG = currentEventGoodV0.GetAngle(previousGoodV0);
2791
2792 Double_t rapidity;
2793
2794 if(backgroundCandidate->GetE() - backgroundCandidate->GetPz() <= 0 || backgroundCandidate->GetE() + backgroundCandidate->GetPz() <= 0){
2795 cout << "Error: |Pz| > E !!!! " << endl;
2796 rapidity=0;
2797 } else {
2798 rapidity = 0.5*(TMath::Log((backgroundCandidate->GetE() +backgroundCandidate->GetPz()) / (backgroundCandidate->GetE()-backgroundCandidate->GetPz())));
2799 }
dc2883e4 2800 if(TMath::Abs(rapidity) > fV0Reader->GetRapidityMesonCut() ){
2801 delete backgroundCandidate;
2802 continue; // rapidity cut
2803 }
2804
2805
111d75df 2806 Double_t alfa=0.0;
2807 if( (currentEventGoodV0.GetE()+previousGoodV0.GetE()) != 0){
2808 alfa=TMath::Abs((currentEventGoodV0.GetE()-previousGoodV0.GetE())
2809 /(currentEventGoodV0.GetE()+previousGoodV0.GetE()));
2810 }
2811
2812
2813 if(openingAngleBG < fMinOpeningAngleGhostCut ){
2814 delete backgroundCandidate;
2815 continue; // minimum opening angle to avoid using ghosttracks
2816 }
2817
2818 // original
111d75df 2819 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
6de3471d 2820 fHistograms->FillHistogram("ESD_Background_GammaDaughter_OpeningAngle", openingAngleBG);
2821 fHistograms->FillHistogram("ESD_Background_Energy", backgroundCandidate->GetE());
2822 fHistograms->FillHistogram("ESD_Background_Pt", momentumVectorbackgroundCandidate.Pt());
2823 fHistograms->FillHistogram("ESD_Background_Eta", momentumVectorbackgroundCandidate.Eta());
2824 fHistograms->FillHistogram("ESD_Background_Rapidity", rapidity);
2825 fHistograms->FillHistogram("ESD_Background_Phi", spaceVectorbackgroundCandidate.Phi());
2826 fHistograms->FillHistogram("ESD_Background_Mass", massBG);
2827 fHistograms->FillHistogram("ESD_Background_R", spaceVectorbackgroundCandidate.Pt()); // Pt in Space == R!!!!
2828 fHistograms->FillHistogram("ESD_Background_ZR", backgroundCandidate->GetZ(), spaceVectorbackgroundCandidate.Pt());
2829 fHistograms->FillHistogram("ESD_Background_XY", backgroundCandidate->GetX(), backgroundCandidate->GetY());
2830 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt",massBG,momentumVectorbackgroundCandidate.Pt());
2831 fHistograms->FillHistogram("ESD_Background_InvMass",massBG);
111d75df 2832 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt_alpha",massBG,momentumVectorbackgroundCandidate.Pt());
6de3471d 2833
2834
2835 if ( TMath::Abs(currentEventGoodV0.GetEta())<0.9 && TMath::Abs(previousGoodV0.GetEta())<0.9 ){
2836 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt_Fiducial",massBG,momentumVectorbackgroundCandidate.Pt());
2837 fHistograms->FillHistogram("ESD_Background_InvMass_Fiducial",massBG);
2838 }
2839
2840 // test
2841 fHistograms->FillHistogram(Form("%d%dESD_Background_GammaDaughter_OpeningAngle",zbin,mbin), openingAngleBG);
2842 fHistograms->FillHistogram(Form("%d%dESD_Background_Energy",zbin,mbin), backgroundCandidate->GetE());
2843 fHistograms->FillHistogram(Form("%d%dESD_Background_Pt",zbin,mbin), momentumVectorbackgroundCandidate.Pt());
2844 fHistograms->FillHistogram(Form("%d%dESD_Background_Eta",zbin,mbin), momentumVectorbackgroundCandidate.Eta());
2845 fHistograms->FillHistogram(Form("%d%dESD_Background_Rapidity",zbin,mbin), rapidity);
2846 fHistograms->FillHistogram(Form("%d%dESD_Background_Phi",zbin,mbin), spaceVectorbackgroundCandidate.Phi());
2847 fHistograms->FillHistogram(Form("%d%dESD_Background_Mass",zbin,mbin), massBG);
2848 fHistograms->FillHistogram(Form("%d%dESD_Background_R",zbin,mbin), spaceVectorbackgroundCandidate.Pt()); // Pt in Space == R!!!!
2849 fHistograms->FillHistogram(Form("%d%dESD_Background_ZR",zbin,mbin), backgroundCandidate->GetZ(), spaceVectorbackgroundCandidate.Pt());
2850 fHistograms->FillHistogram(Form("%d%dESD_Background_XY",zbin,mbin), backgroundCandidate->GetX(), backgroundCandidate->GetY());
2851 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_vs_Pt",zbin,mbin),massBG,momentumVectorbackgroundCandidate.Pt());
2852 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass",zbin,mbin),massBG);
2853
2854 if ( TMath::Abs(currentEventGoodV0.GetEta())<0.9 && TMath::Abs(previousGoodV0.GetEta())<0.9 ){
2855 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_vs_Pt_Fiducial",zbin,mbin),massBG,momentumVectorbackgroundCandidate.Pt());
2856 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_Fiducial",zbin,mbin),massBG);
2857 }
2858 // }
111d75df 2859 }
3c45d101 2860 if(alfa<0.1){