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