1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: Ana Marin, Kathrin Koch, Kenneth Aamodt *
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 **************************************************************************/
16 ////////////////////////////////////////////////
17 //---------------------------------------------
18 // Class used to do analysis on conversion pairs
19 //---------------------------------------------
20 ////////////////////////////////////////////////
26 #include "AliAnalysisTaskGammaConversion.h"
29 #include "AliESDtrackCuts.h"
31 //#include "AliCFManager.h" // for CF
32 //#include "AliCFContainer.h" // for CF
33 #include "AliESDInputHandler.h"
34 #include "AliAnalysisManager.h"
35 #include "AliGammaConversionAODObject.h"
36 #include "AliGammaConversionBGHandler.h"
37 #include "AliESDCaloCluster.h" // for combining PHOS and GammaConv
38 #include "AliKFVertex.h"
39 #include "AliGenPythiaEventHeader.h"
40 #include "AliGenDPMjetEventHeader.h"
41 #include "AliGenEventHeader.h"
42 #include <AliMCEventHandler.h>
44 #include "AliTriggerAnalysis.h"
46 class AliESDTrackCuts;
54 class AliMCEventHandler;
55 class AliESDInputHandler;
56 class AliAnalysisManager;
63 ClassImp(AliAnalysisTaskGammaConversion)
66 AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion():
70 fMCTruth(NULL), // for CF
71 fGCMCEvent(NULL), // for CF
73 fOutputContainer(NULL),
74 fCFManager(0x0), // for CF
76 fTriggerCINT1B(kFALSE),
78 fDoNeutralMeson(kFALSE),
79 fDoOmegaMeson(kFALSE),
82 fRecalculateV0ForGamma(kFALSE),
83 fKFReconstructedGammasTClone(NULL),
84 fKFReconstructedPi0sTClone(NULL),
85 fKFRecalculatedGammasTClone(NULL),
86 fCurrentEventPosElectronTClone(NULL),
87 fCurrentEventNegElectronTClone(NULL),
88 fKFReconstructedGammasCutTClone(NULL),
89 fPreviousEventTLVNegElectronTClone(NULL),
90 fPreviousEventTLVPosElectronTClone(NULL),
95 fElectronRecalculatedv1(),
96 fElectronRecalculatedv2(),
104 fMinOpeningAngleGhostCut(0.),
106 fCalculateBackground(kFALSE),
107 fWriteNtuple(kFALSE),
109 fNeutralMesonNtuple(NULL),
110 fTotalNumberOfAddedNtupleEntries(0),
111 fChargedParticles(NULL),
112 fChargedParticlesId(),
114 fMinPtForGammaJet(1.),
115 fMinIsoConeSize(0.2),
117 fMinPtGamChargedCorr(0.5),
119 fLeadingChargedIndex(-1),
126 fAODBranchName("GammaConv"),
128 fKFDeltaAODFileName(""),
129 fDoNeutralMesonV0MCCheck(kFALSE),
130 fUseTrackMultiplicityForBG(kTRUE),
131 fMoveParticleAccordingToVertex(kFALSE),
132 fApplyChi2Cut(kFALSE),
133 fNRandomEventsForBG(15),
134 fNDegreesPMBackground(15),
136 fCheckBGProbability(kTRUE),
137 fKFReconstructedGammasV0Index(),
138 fRemovePileUp(kFALSE),
139 fSelectV0AND(kFALSE),
140 fTriggerAnalysis(NULL),
143 fUseMultiplicityBin(0)
145 // Default constructor
147 /* Kenneth: the default constructor should not have any define input/output or the call to SetESDtrackCuts
148 // Common I/O in slot 0
149 DefineInput (0, TChain::Class());
150 DefineOutput(0, TTree::Class());
152 // Your private output
153 DefineOutput(1, TList::Class());
155 // Define standard ESD track cuts for Gamma-hadron correlation
160 AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion(const char* name):
161 AliAnalysisTaskSE(name),
164 fMCTruth(NULL), // for CF
165 fGCMCEvent(NULL), // for CF
167 fOutputContainer(0x0),
168 fCFManager(0x0), // for CF
170 fTriggerCINT1B(kFALSE),
172 fDoNeutralMeson(kFALSE),
173 fDoOmegaMeson(kFALSE),
176 fRecalculateV0ForGamma(kFALSE),
177 fKFReconstructedGammasTClone(NULL),
178 fKFReconstructedPi0sTClone(NULL),
179 fKFRecalculatedGammasTClone(NULL),
180 fCurrentEventPosElectronTClone(NULL),
181 fCurrentEventNegElectronTClone(NULL),
182 fKFReconstructedGammasCutTClone(NULL),
183 fPreviousEventTLVNegElectronTClone(NULL),
184 fPreviousEventTLVPosElectronTClone(NULL),
189 fElectronRecalculatedv1(),
190 fElectronRecalculatedv2(),
198 fMinOpeningAngleGhostCut(0.),
200 fCalculateBackground(kFALSE),
201 fWriteNtuple(kFALSE),
203 fNeutralMesonNtuple(NULL),
204 fTotalNumberOfAddedNtupleEntries(0),
205 fChargedParticles(NULL),
206 fChargedParticlesId(),
208 fMinPtForGammaJet(1.),
209 fMinIsoConeSize(0.2),
211 fMinPtGamChargedCorr(0.5),
213 fLeadingChargedIndex(-1),
220 fAODBranchName("GammaConv"),
222 fKFDeltaAODFileName(""),
223 fDoNeutralMesonV0MCCheck(kFALSE),
224 fUseTrackMultiplicityForBG(kTRUE),
225 fMoveParticleAccordingToVertex(kFALSE),
226 fApplyChi2Cut(kFALSE),
227 fNRandomEventsForBG(15),
228 fNDegreesPMBackground(15),
230 fCheckBGProbability(kTRUE),
231 fKFReconstructedGammasV0Index(),
232 fRemovePileUp(kFALSE),
233 fSelectV0AND(kFALSE),
234 fTriggerAnalysis(NULL),
237 fUseMultiplicityBin(0)
239 // Common I/O in slot 0
240 DefineInput (0, TChain::Class());
241 DefineOutput(0, TTree::Class());
243 // Your private output
244 DefineOutput(1, TList::Class());
245 DefineOutput(2, AliCFContainer::Class()); // for CF
248 // Define standard ESD track cuts for Gamma-hadron correlation
253 AliAnalysisTaskGammaConversion::~AliAnalysisTaskGammaConversion()
255 // Remove all pointers
257 if(fOutputContainer){
258 fOutputContainer->Clear() ;
259 delete fOutputContainer ;
274 delete fEsdTrackCuts;
296 if(fTriggerAnalysis) {
297 delete fTriggerAnalysis;
304 void AliAnalysisTaskGammaConversion::Init()
307 // AliLog::SetGlobalLogLevel(AliLog::kError);
309 void AliAnalysisTaskGammaConversion::SetESDtrackCuts()
312 if (fEsdTrackCuts!=NULL){
313 delete fEsdTrackCuts;
315 fEsdTrackCuts = new AliESDtrackCuts("AliESDtrackCuts");
316 //standard cuts from:
317 //http://aliceinfo.cern.ch/alicvs/viewvc/PWG0/dNdEta/CreateCuts.C?revision=1.4&view=markup
319 // Cuts used up to 3rd of March
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);
328 //------- To be tested-----------
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);
347 // fEsdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kFirst);
350 // Using standard function for setting Cuts
351 Bool_t selectPrimaries=kTRUE;
352 fEsdTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(selectPrimaries);
353 fEsdTrackCuts->SetEtaRange(-0.8, 0.8);
354 fEsdTrackCuts->SetPtRange(0.15);
356 //----- From Jacek 10.03.03 ------------------/
357 // minNClustersTPC = 70;
358 // maxChi2PerClusterTPC = 4.0;
359 // maxDCAtoVertexXY = 2.4; // cm
360 // maxDCAtoVertexZ = 3.2; // cm
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);
374 // fEsdTrackCuts->SetAcceptKinkDaughters(kFALSE);
375 // fV0Reader->SetESDtrackCuts(fEsdTrackCuts);
378 void AliAnalysisTaskGammaConversion::UserExec(Option_t */*option*/)
380 // Execute analysis for current event
382 // Load the esdpid from the esdhandler if exists (tender was applied) otherwise set the Bethe Bloch parameters
383 Int_t eventQuality=-1;
385 AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
386 AliESDInputHandler *esdHandler=0x0;
387 if ( (esdHandler=dynamic_cast<AliESDInputHandler*>(man->GetInputEventHandler())) && esdHandler->GetESDpid() ){
388 AliV0Reader::SetESDpid(esdHandler->GetESDpid());
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()){
395 AliV0Reader::InitESDpid();
397 AliV0Reader::InitESDpid(1);
402 //Must set fForceAOD to true for the AOD to get filled. Should only be done when running independent chain / train.
404 if (!AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()) AliFatal("Cannot run ESD filter without an output event handler");
405 AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kTRUE);
408 if(fV0Reader == NULL){
409 // Write warning here cuts and so on are default if this ever happens
413 // To avoid crashes due to unzip errors. Sometimes the trees are not there.
415 AliMCEventHandler* mcHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
417 AliError("Could not retrive MC event handler!");
421 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
423 if (!mcHandler->InitOk() ){
425 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
428 if (!mcHandler->TreeK() ){
430 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
433 if (!mcHandler->TreeTR() ) {
435 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
440 fV0Reader->SetInputAndMCEvent(InputEvent(), MCEvent());
442 fV0Reader->Initialize();
443 fDoMCTruth = fV0Reader->GetDoMCTruth();
445 if(fAODGamma) fAODGamma->Delete();
446 if(fAODPi0) fAODPi0->Delete();
447 if(fAODOmega) fAODOmega->Delete();
449 if(fKFReconstructedGammasTClone == NULL){
450 fKFReconstructedGammasTClone = new TClonesArray("AliKFParticle",0);
452 if(fCurrentEventPosElectronTClone == NULL){
453 fCurrentEventPosElectronTClone = new TClonesArray("AliESDtrack",0);
455 if(fCurrentEventNegElectronTClone == NULL){
456 fCurrentEventNegElectronTClone = new TClonesArray("AliESDtrack",0);
458 if(fKFReconstructedGammasCutTClone == NULL){
459 fKFReconstructedGammasCutTClone = new TClonesArray("AliKFParticle",0);
461 if(fPreviousEventTLVNegElectronTClone == NULL){
462 fPreviousEventTLVNegElectronTClone = new TClonesArray("TLorentzVector",0);
464 if(fPreviousEventTLVPosElectronTClone == NULL){
465 fPreviousEventTLVPosElectronTClone = new TClonesArray("TLorentzVector",0);
467 if(fChargedParticles == NULL){
468 fChargedParticles = new TClonesArray("AliESDtrack",0);
471 if(fKFReconstructedPi0sTClone == NULL){
472 fKFReconstructedPi0sTClone = new TClonesArray("AliKFParticle",0);
475 if(fKFRecalculatedGammasTClone == NULL){
476 fKFRecalculatedGammasTClone = new TClonesArray("AliKFParticle",0);
479 if(fTriggerAnalysis== NULL){
480 fTriggerAnalysis = new AliTriggerAnalysis;
484 fKFReconstructedGammasTClone->Delete();
485 fCurrentEventPosElectronTClone->Delete();
486 fCurrentEventNegElectronTClone->Delete();
487 fKFReconstructedGammasCutTClone->Delete();
488 fPreviousEventTLVNegElectronTClone->Delete();
489 fPreviousEventTLVPosElectronTClone->Delete();
490 fKFReconstructedPi0sTClone->Delete();
491 fKFRecalculatedGammasTClone->Delete();
500 fElectronRecalculatedv1.clear();
501 fElectronRecalculatedv2.clear();
504 fChargedParticles->Delete();
506 fChargedParticlesId.clear();
508 fKFReconstructedGammasV0Index.clear();
510 //Clear the data in the v0Reader
511 // fV0Reader->UpdateEventByEventData();
513 //Take Only events with proper trigger
516 if(!fV0Reader->GetESDEvent()->IsTriggerClassFired("CINT1B-ABCE-NOPF-ALL")) return;
520 if(fV0Reader->CheckForPrimaryVertex() == kFALSE){
521 // cout<< "Event not taken"<< endl;
523 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
525 CheckMesonProcessTypeEventQuality(eventQuality);
527 return; // aborts if the primary vertex does not have contributors.
531 if(!fV0Reader->CheckForPrimaryVertexZ() ){
533 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
535 CheckMesonProcessTypeEventQuality(eventQuality);
540 if(fRemovePileUp && fV0Reader->GetESDEvent()->IsPileupFromSPD()) {
542 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
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;
550 if(fSelectV0AND && !v0AND){
552 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
555 fMultiplicity = fEsdTrackCuts->CountAcceptedTracks(fV0Reader->GetESDEvent());
557 if( CalculateMultiplicityBin() != fUseMultiplicityBin){
559 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
564 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
568 fHistograms->FillHistogram("ESD_NumberOfGoodESDTracks",fMultiplicity);
569 if (fV0Reader->GetNumberOfContributorsVtx()>=1){
570 fHistograms->FillHistogram("ESD_NumberOfGoodESDTracksVtx",fMultiplicity);
575 // Process the MC information
580 //Process the v0 information with no cuts
583 // Process the v0 information
588 FillAODWithConversionGammas() ;
590 // Process reconstructed gammas
591 if(fDoNeutralMeson == kTRUE){
592 ProcessGammasForNeutralMesonAnalysis();
596 if(fDoMCTruth == kTRUE){
599 //Process reconstructed gammas electrons for Chi_c Analysis
600 if(fDoChic == kTRUE){
601 ProcessGammaElectronsForChicAnalysis();
603 // Process reconstructed gammas for gamma Jet/hadron correlations
605 ProcessGammasForGammaJetAnalysis();
608 //calculate background if flag is set
609 if(fCalculateBackground){
610 CalculateBackground();
613 if(fDoNeutralMeson == kTRUE){
614 // ProcessConvPHOSGammasForNeutralMesonAnalysis();
615 if(fDoOmegaMeson == kTRUE){
616 ProcessGammasForOmegaMesonAnalysis();
620 //Clear the data in the v0Reader
621 fV0Reader->UpdateEventByEventData();
622 if(fRecalculateV0ForGamma==kTRUE){
623 RecalculateV0ForGamma();
625 PostData(1, fOutputContainer);
626 PostData(2, fCFManager->GetParticleContainer()); // for CF
630 // void AliAnalysisTaskGammaConversion::ConnectInputData(Option_t *option){
631 // // see header file for documentation
632 // // printf(" ConnectInputData %s\n", GetName());
634 // AliAnalysisTaskSE::ConnectInputData(option);
636 // if(fV0Reader == NULL){
637 // // Write warning here cuts and so on are default if this ever happens
639 // fV0Reader->Initialize();
640 // fDoMCTruth = fV0Reader->GetDoMCTruth();
643 void AliAnalysisTaskGammaConversion::CheckMesonProcessTypeEventQuality(Int_t evtQ){
644 // Check meson process type event quality
645 fStack= MCEvent()->Stack();
646 fGCMCEvent=MCEvent();
648 for (Int_t iTracks = 0; iTracks < fStack->GetNprimary(); iTracks++) {
649 TParticle* particle = (TParticle *)fStack->Particle(iTracks);
654 if(particle->GetPdgCode()!=111){ //Pi0
657 if(TMath::Abs(particle->Eta())> fV0Reader->GetEtaCut() ) continue;
659 switch(GetProcessType(fGCMCEvent)){
661 fHistograms->FillHistogram("MC_SD_EvtQ1_Pi0_Pt", particle->Pt());
664 fHistograms->FillHistogram("MC_DD_EvtQ1_Pi0_Pt", particle->Pt());
667 fHistograms->FillHistogram("MC_ND_EvtQ1_Pi0_Pt", particle->Pt());
670 AliError("Unknown Process");
674 switch(GetProcessType(fGCMCEvent)){
676 fHistograms->FillHistogram("MC_SD_EvtQ2_Pi0_Pt", particle->Pt());
679 fHistograms->FillHistogram("MC_DD_EvtQ2_Pi0_Pt", particle->Pt());
682 fHistograms->FillHistogram("MC_ND_EvtQ2_Pi0_Pt", particle->Pt());
685 AliError("Unknown Process");
694 void AliAnalysisTaskGammaConversion::ProcessMCData(){
695 // see header file for documentation
696 //InputEvent(), MCEvent());
698 fStack = fV0Reader->GetMCStack();
699 fMCTruth = fV0Reader->GetMCTruth(); // for CF
700 fGCMCEvent = fV0Reader->GetMCEvent(); // for CF
702 fStack= MCEvent()->Stack();
703 fGCMCEvent=MCEvent();
706 Double_t containerInput[3];
708 if(!fGCMCEvent) cout << "NO MC INFO FOUND" << endl;
709 fCFManager->SetEventInfo(fGCMCEvent);
714 if(fV0Reader->CheckForPrimaryVertex() == kFALSE){
715 return; // aborts if the primary vertex does not have contributors.
717 for (Int_t iTracks = 0; iTracks < fStack->GetNprimary(); iTracks++) {
718 // for (Int_t iTracks = 0; iTracks < fStack->GetNtrack(); iTracks++) {
719 TParticle* particle = (TParticle *)fStack->Particle(iTracks);
728 ///////////////////////Begin Chic Analysis/////////////////////////////
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){
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
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
744 fHistograms->FillTable("Table_Electrons",2);//e- from J/Psi inside acceptance
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
751 fHistograms->FillTable("Table_Electrons",2);//e- from J/Psi inside acceptance
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
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());
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);
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);
793 /////////////////////End Chic Analysis////////////////////////////
796 // if(TMath::Abs(particle->Eta())> fV0Reader->GetEtaCut() ) continue;
798 if(particle->R()>fV0Reader->GetMaxRCut()) continue; // cuts on distance from collision point
800 Double_t tmpPhi=particle->Phi();
802 if(particle->Phi()> TMath::Pi()){
803 tmpPhi = particle->Phi()-(2*TMath::Pi());
807 if(particle->Energy() - particle->Pz() == 0 || particle->Energy() + particle->Pz() == 0){
811 rapidity = 0.5*(TMath::Log((particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz())));
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 ){
820 if(TMath::Abs(particle->Eta())> fV0Reader->GetEtaCut() ) continue;
821 fHistograms->FillHistogram("MC_PhysicalPrimaryCharged_Pt", particle->Pt());
828 if (particle->GetPdgCode() == 22){
829 if(TMath::Abs(particle->Eta())> fV0Reader->GetEtaCut() ) continue;
831 if(particle->GetMother(0) >-1 && fStack->Particle(particle->GetMother(0))->GetPdgCode() == 22){
832 continue; // no photon as mothers!
835 if(particle->GetMother(0) >= fStack->GetNprimary()){
836 continue; // the gamma has a mother, and it is not a primary particle
839 if(particle->GetMother(0) >-1){
840 fHistograms->FillHistogram("MC_DecayAllGamma_Pt", particle->Pt()); // All
841 switch(fStack->Particle(particle->GetMother(0))->GetPdgCode()){
843 fHistograms->FillHistogram("MC_DecayPi0Gamma_Pt", particle->Pt());
846 fHistograms->FillHistogram("MC_DecayRho0Gamma_Pt", particle->Pt());
849 fHistograms->FillHistogram("MC_DecayEtaGamma_Pt", particle->Pt());
852 fHistograms->FillHistogram("MC_DecayOmegaGamma_Pt", particle->Pt());
855 fHistograms->FillHistogram("MC_DecayK0sGamma_Pt", particle->Pt());
858 fHistograms->FillHistogram("MC_DecayEtapGamma_Pt", particle->Pt());
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);
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();
877 containerInput[2]=-1;
880 fCFManager->GetParticleContainer()->Fill(containerInput,kStepGenerated); // generated gamma
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);
890 // looking for conversion (electron + positron from pairbuilding (= 5) )
891 TParticle* ePos = NULL;
892 TParticle* eNeg = NULL;
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){
901 else if(tmpDaughter->GetPdgCode() == -11){
909 if(ePos == NULL || eNeg == NULL){ // means we do not have two daughters from pair production
914 Double_t ePosPhi = ePos->Phi();
915 if(ePos->Phi()> TMath::Pi()) ePosPhi = ePos->Phi()-(2*TMath::Pi());
917 Double_t eNegPhi = eNeg->Phi();
918 if(eNeg->Phi()> TMath::Pi()) eNegPhi = eNeg->Phi()-(2*TMath::Pi());
921 if(ePos->Pt()<fV0Reader->GetPtCut() || eNeg->Pt()<fV0Reader->GetPtCut()){
922 continue; // no reconstruction below the Pt cut
925 if(TMath::Abs(ePos->Eta())> fV0Reader->GetEtaCut() || TMath::Abs(eNeg->Eta())> fV0Reader->GetEtaCut()){
929 if(ePos->R()>fV0Reader->GetMaxRCut()){
930 continue; // cuts on distance from collision point
933 if(TMath::Abs(ePos->Vz()) > fV0Reader->GetMaxZCut()){
934 continue; // outside material
938 if((TMath::Abs(ePos->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue() > ePos->R()){
939 continue; // line cut to exclude regions where we do not reconstruct
945 fCFManager->GetParticleContainer()->Fill(containerInput,kStepReconstructable); // reconstructable gamma
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());
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);
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);
966 Int_t rBin = fHistograms->GetRBin(ePos->R());
967 Int_t zBin = fHistograms->GetZBin(ePos->Vz());
968 Int_t phiBin = fHistograms->GetPhiBin(particle->Phi());
971 TVector3 vtxPos(ePos->Vx(),ePos->Vy(),ePos->Vz());
973 TString nameMCMappingPhiR="";
974 nameMCMappingPhiR.Form("MC_Conversion_Mapping_Phi%02d_R%02d",phiBin,rBin);
975 // fHistograms->FillHistogram(nameMCMappingPhiR, ePos->Vz(), particle->Eta());
977 TString nameMCMappingPhi="";
978 nameMCMappingPhi.Form("MC_Conversion_Mapping_Phi%02d",phiBin);
979 // fHistograms->FillHistogram(nameMCMappingPhi, particle->Eta());
980 //fHistograms->FillHistogram(nameMCMappingPhi, ePos->Vz(), particle->Eta());
982 TString nameMCMappingR="";
983 nameMCMappingR.Form("MC_Conversion_Mapping_R%02d",rBin);
984 // fHistograms->FillHistogram(nameMCMappingR, particle->Eta());
985 //fHistograms->FillHistogram(nameMCMappingR,ePos->Vz(), particle->Eta());
987 TString nameMCMappingPhiInR="";
988 nameMCMappingPhiInR.Form("MC_Conversion_Mapping_Phi_in_R_%02d",rBin);
989 // fHistograms->FillHistogram(nameMCMappingPhiInR, tmpPhi);
990 fHistograms->FillHistogram(nameMCMappingPhiInR, vtxPos.Phi());
992 TString nameMCMappingZInR="";
993 nameMCMappingZInR.Form("MC_Conversion_Mapping_Z_in_R_%02d",rBin);
994 fHistograms->FillHistogram(nameMCMappingZInR,ePos->Vz() );
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());
1004 TString nameMCMappingFMDPhiInZ="";
1005 nameMCMappingFMDPhiInZ.Form("MC_Conversion_Mapping_FMD_Phi_in_Z_%02d",zBin);
1006 fHistograms->FillHistogram(nameMCMappingFMDPhiInZ, vtxPos.Phi());
1009 TString nameMCMappingRInZ="";
1010 nameMCMappingRInZ.Form("MC_Conversion_Mapping_R_in_Z_%02d",zBin);
1011 fHistograms->FillHistogram(nameMCMappingRInZ,ePos->R() );
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());
1018 TString nameMCMappingMidPtZInR="";
1019 nameMCMappingMidPtZInR.Form("MC_Conversion_Mapping_MidPt_Z_in_R_%02d",rBin);
1020 fHistograms->FillHistogram(nameMCMappingMidPtZInR,ePos->Vz() );
1023 TString nameMCMappingMidPtPhiInZ="";
1024 nameMCMappingMidPtPhiInZ.Form("MC_Conversion_Mapping_MidPt_Phi_in_Z_%02d",zBin);
1025 fHistograms->FillHistogram(nameMCMappingMidPtPhiInZ, vtxPos.Phi());
1029 TString nameMCMappingMidPtFMDPhiInZ="";
1030 nameMCMappingMidPtFMDPhiInZ.Form("MC_Conversion_Mapping_MidPt_FMD_Phi_in_Z_%02d",zBin);
1031 fHistograms->FillHistogram(nameMCMappingMidPtFMDPhiInZ, vtxPos.Phi());
1035 TString nameMCMappingMidPtRInZ="";
1036 nameMCMappingMidPtRInZ.Form("MC_Conversion_Mapping_MidPt_R_in_Z_%02d",zBin);
1037 fHistograms->FillHistogram(nameMCMappingMidPtRInZ,ePos->R() );
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));
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());
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);
1058 } // end direct gamma
1059 else{ // mother exits
1060 /* if( fStack->Particle(particle->GetMother(0))->GetPdgCode()==10441 ||//chic0
1061 fStack->Particle(particle->GetMother(0))->GetPdgCode()==20443 ||//psi2S
1062 fStack->Particle(particle->GetMother(0))->GetPdgCode()==445 //chic2
1064 fMCGammaChic.push_back(particle);
1067 } // end if mother exits
1068 } // end if particle is a photon
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!
1076 if(particle->GetNDaughters() == 2){
1078 TParticle* daughter0 = (TParticle*)fStack->Particle(particle->GetFirstDaughter());
1079 TParticle* daughter1 = (TParticle*)fStack->Particle(particle->GetLastDaughter());
1081 if(daughter0->GetPdgCode() != 22 || daughter1->GetPdgCode() != 22) continue; //check for gamma gamma daughters
1083 if(TMath::Abs(rapidity) > fV0Reader->GetRapidityMesonCut() ) continue;
1085 // Check the acceptance for both gammas
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;
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;
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;
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;
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;
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;
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
1169 if(gammaEtaCut && gammaRCut){
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);
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());
1184 fHistograms->FillHistogram("MC_Pi0_Pt_vs_Rapid", particle->Pt(),rapidity);
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
1190 if(TMath::Abs(particle->Eta())<0.9)fHistograms->FillHistogram("MC_Pi0_Pt_Fiducial", particle->Pt());
1192 switch(GetProcessType(fGCMCEvent)){
1194 fHistograms->FillHistogram("MC_SD_EvtQ3_Pi0_Pt", particle->Pt());
1197 fHistograms->FillHistogram("MC_DD_EvtQ3_Pi0_Pt", particle->Pt());
1200 fHistograms->FillHistogram("MC_ND_EvtQ3_Pi0_Pt", particle->Pt());
1203 AliError("Unknown Process");
1206 if(gammaEtaCut && gammaRCut){
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);
1210 if(TMath::Abs(particle->Eta())<0.9)fHistograms->FillHistogram("MC_Pi0_Pt_withinAcceptance_Fiducial", particle->Pt());
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());
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());
1221 if((daughter0->Energy()+daughter1->Energy()) > 0.){
1222 alfa= TMath::Abs((daughter0->Energy()-daughter1->Energy())/(daughter0->Energy()+daughter1->Energy()));
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());
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());
1237 fHistograms->FillHistogram("MC_Eta_Pt_vs_Rapid", particle->Pt(),rapidity);
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
1244 if(gammaEtaCut && gammaRCut){
1245 // if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){
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());
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());
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());
1275 if(gammaEtaCut && gammaRCut){
1276 // if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){
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());
1288 } // end passed R and eta cut
1290 } // end if(particle->GetNDaughters() == 2)
1292 }// end for (Int_t iTracks = 0; iTracks < fStack->GetNtrack(); iTracks++)
1294 } // end ProcessMCData
1298 void AliAnalysisTaskGammaConversion::FillNtuple(){
1299 //Fills the ntuple with the different values
1301 if(fGammaNtuple == NULL){
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);
1310 fV0Reader->GetPIDProbability(negPID,posPID);
1311 values[0]=cV0->GetOnFlyStatus();
1312 values[1]=fV0Reader->CheckForPrimaryVertex();
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();
1341 fTotalNumberOfAddedNtupleEntries++;
1342 fGammaNtuple->Fill(values);
1344 fV0Reader->ResetV0IndexNumber();
1348 void AliAnalysisTaskGammaConversion::ProcessV0sNoCut(){
1349 // Process all the V0's without applying any cuts to it
1351 Int_t numberOfV0s = fV0Reader->GetNumberOfV0s();
1352 for(Int_t i=0;i<numberOfV0s;i++){
1353 /*AliESDv0 * cV0 = */fV0Reader->GetV0(i);
1355 if(fV0Reader->CheckForPrimaryVertex() == kFALSE){
1359 // if( !fV0Reader->GetV0(i)->GetOnFlyStatus()){
1360 if( !fV0Reader->CheckV0FinderStatus(i)){
1365 if( !((fV0Reader->GetNegativeESDTrack())->GetStatus() & AliESDtrack::kTPCrefit) ||
1366 !((fV0Reader->GetPositiveESDTrack())->GetStatus() & AliESDtrack::kTPCrefit) ){
1370 if( fV0Reader->GetNegativeESDTrack()->GetSign()== fV0Reader->GetPositiveESDTrack()->GetSign()){
1374 if( fV0Reader->GetNegativeESDTrack()->GetKinkIndex(0) > 0 ||
1375 fV0Reader->GetPositiveESDTrack()->GetKinkIndex(0) > 0) {
1378 if(TMath::Abs(fV0Reader->GetMotherCandidateEta())> fV0Reader->GetEtaCut()){
1381 if(TMath::Abs(fV0Reader->GetPositiveTrackEta())> fV0Reader->GetEtaCut()){
1384 if(TMath::Abs(fV0Reader->GetNegativeTrackEta())> fV0Reader->GetEtaCut()){
1387 if((TMath::Abs(fV0Reader->GetZ())*fV0Reader->GetLineCutZRSlope())-fV0Reader->GetLineCutZValue() > fV0Reader->GetXYRadius() ){ // cuts out regions where we do not reconstruct
1392 if(fV0Reader->HasSameMCMother() == kFALSE){
1396 TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
1397 TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
1399 if(TMath::Abs(negativeMC->GetPdgCode())!=11 || TMath::Abs(positiveMC->GetPdgCode())!=11){
1402 if(negativeMC->GetPdgCode() == positiveMC->GetPdgCode()){
1406 if(negativeMC->GetUniqueID() != 5 || positiveMC->GetUniqueID() !=5){ // id 5 is conversion
1410 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
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());
1423 fHistograms->FillHistogram("ESD_NoCutConvGamma_Pt_Chi2", fV0Reader->GetMotherCandidatePt(), fV0Reader->GetMotherCandidateChi2());
1424 fHistograms->FillHistogram("ESD_NoCutConvGamma_Eta_Chi2", fV0Reader->GetMotherCandidateEta(), fV0Reader->GetMotherCandidateChi2());
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());
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());
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());
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());
1447 fV0Reader->ResetV0IndexNumber();
1450 void AliAnalysisTaskGammaConversion::ProcessV0s(){
1451 // see header file for documentation
1454 if(fWriteNtuple == kTRUE){
1458 Int_t nSurvivingV0s=0;
1459 fV0Reader->ResetNGoodV0s();
1460 while(fV0Reader->NextV0()){
1464 TVector3 vtxConv(fV0Reader->GetX(),fV0Reader->GetY(), fV0Reader->GetZ());
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());
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());
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());
1483 fHistograms->FillHistogram("ESD_E_nTPCClusters", fV0Reader->GetNegativeTracknTPCClusters());
1484 fHistograms->FillHistogram("ESD_E_nITSClusters", fV0Reader->GetNegativeTracknITSClusters());
1485 if(fV0Reader->GetNegativeTracknTPCFClusters()!=0 && fV0Reader->GetNegativeTracknTPCClusters()!=0 ){
1486 Double_t eClsToF= (Double_t)fV0Reader->GetNegativeTracknTPCClusters()/(Double_t)fV0Reader->GetNegativeTracknTPCFClusters();
1487 fHistograms->FillHistogram("ESD_E_nTPCClustersToFP", fV0Reader->GetNegativeTrackP(),eClsToF );
1488 fHistograms->FillHistogram("ESD_E_TPCchi2", fV0Reader->GetNegativeTrackTPCchi2()/(Double_t)fV0Reader->GetNegativeTracknTPCClusters());
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());
1497 fHistograms->FillHistogram("ESD_P_nTPCClusters", fV0Reader->GetPositiveTracknTPCClusters());
1498 fHistograms->FillHistogram("ESD_P_nITSClusters", fV0Reader->GetPositiveTracknITSClusters());
1499 if(fV0Reader->GetPositiveTracknTPCFClusters()!=0 && (Double_t)fV0Reader->GetPositiveTracknTPCClusters()!=0 ){
1500 Double_t pClsToF= (Double_t)fV0Reader->GetPositiveTracknTPCClusters()/(Double_t)fV0Reader->GetPositiveTracknTPCFClusters();
1501 fHistograms->FillHistogram("ESD_P_nTPCClustersToFP",fV0Reader->GetPositiveTrackP(), pClsToF);
1502 fHistograms->FillHistogram("ESD_P_TPCchi2", fV0Reader->GetPositiveTrackTPCchi2()/(Double_t)fV0Reader->GetPositiveTracknTPCClusters());
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());
1517 fHistograms->FillHistogram("ESD_ConvGamma_Pt_Chi2", fV0Reader->GetMotherCandidatePt(), fV0Reader->GetMotherCandidateChi2());
1518 fHistograms->FillHistogram("ESD_ConvGamma_Eta_Chi2", fV0Reader->GetMotherCandidateEta(), fV0Reader->GetMotherCandidateChi2());
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());
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());
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);
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);
1542 Double_t armenterosQtAlfa[2];
1543 fV0Reader->GetArmenterosQtAlfa(fV0Reader-> GetNegativeKFParticle(),
1544 fV0Reader-> GetPositiveKFParticle(),
1545 fV0Reader->GetMotherCandidateKFCombination(),
1548 fHistograms->FillHistogram("ESD_ConvGamma_alfa_qt",armenterosQtAlfa[1],armenterosQtAlfa[0]);
1552 Int_t rBin = fHistograms->GetRBin(fV0Reader->GetXYRadius());
1553 Int_t zBin = fHistograms->GetZBin(fV0Reader->GetZ());
1554 Int_t phiBin = fHistograms->GetPhiBin(fV0Reader->GetNegativeTrackPhi());
1559 // Double_t motherCandidateEta= fV0Reader->GetMotherCandidateEta();
1561 TString nameESDMappingPhiR="";
1562 nameESDMappingPhiR.Form("ESD_Conversion_Mapping_Phi%02d_R%02d",phiBin,rBin);
1563 //fHistograms->FillHistogram(nameESDMappingPhiR, fV0Reader->GetZ(), motherCandidateEta);
1565 TString nameESDMappingPhi="";
1566 nameESDMappingPhi.Form("ESD_Conversion_Mapping_Phi%02d",phiBin);
1567 //fHistograms->FillHistogram(nameESDMappingPhi, fV0Reader->GetZ(), motherCandidateEta);
1569 TString nameESDMappingR="";
1570 nameESDMappingR.Form("ESD_Conversion_Mapping_R%02d",rBin);
1571 //fHistograms->FillHistogram(nameESDMappingR, fV0Reader->GetZ(), motherCandidateEta);
1573 TString nameESDMappingPhiInR="";
1574 nameESDMappingPhiInR.Form("ESD_Conversion_Mapping_Phi_in_R_%02d",rBin);
1575 // fHistograms->FillHistogram(nameESDMappingPhiInR, fV0Reader->GetMotherCandidatePhi());
1576 fHistograms->FillHistogram(nameESDMappingPhiInR, vtxConv.Phi());
1578 TString nameESDMappingZInR="";
1579 nameESDMappingZInR.Form("ESD_Conversion_Mapping_Z_in_R_%02d",rBin);
1580 fHistograms->FillHistogram(nameESDMappingZInR, fV0Reader->GetZ());
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());
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());
1594 TString nameESDMappingRInZ="";
1595 nameESDMappingRInZ.Form("ESD_Conversion_Mapping_R_in_Z_%02d",zBin);
1596 fHistograms->FillHistogram(nameESDMappingRInZ, fV0Reader->GetXYRadius());
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());
1603 TString nameESDMappingMidPtZInR="";
1604 nameESDMappingMidPtZInR.Form("ESD_Conversion_Mapping_MidPt_Z_in_R_%02d",rBin);
1605 fHistograms->FillHistogram(nameESDMappingMidPtZInR, fV0Reader->GetZ());
1607 TString nameESDMappingMidPtPhiInZ="";
1608 nameESDMappingMidPtPhiInZ.Form("ESD_Conversion_Mapping_MidPt_Phi_in_Z_%02d",zBin);
1609 fHistograms->FillHistogram(nameESDMappingMidPtPhiInZ, vtxConv.Phi());
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());
1617 TString nameESDMappingMidPtRInZ="";
1618 nameESDMappingMidPtRInZ.Form("ESD_Conversion_Mapping_MidPt_R_in_Z_%02d",zBin);
1619 fHistograms->FillHistogram(nameESDMappingMidPtRInZ, fV0Reader->GetXYRadius());
1626 new((*fKFReconstructedGammasTClone)[fKFReconstructedGammasTClone->GetEntriesFast()]) AliKFParticle(*fV0Reader->GetMotherCandidateKFCombination());
1627 fKFReconstructedGammasV0Index.push_back(fV0Reader->GetCurrentV0IndexNumber()-1);
1628 // fKFReconstructedGammas.push_back(*fV0Reader->GetMotherCandidateKFCombination());
1629 fElectronv1.push_back(fV0Reader->GetCurrentV0()->GetPindex());
1630 fElectronv2.push_back(fV0Reader->GetCurrentV0()->GetNindex());
1632 //----------------------------------- checking for "real" conversions (MC match) --------------------------------------
1635 if(fV0Reader->HasSameMCMother() == kFALSE){
1638 TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
1639 TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
1641 if(TMath::Abs(negativeMC->GetPdgCode())!=11 || TMath::Abs(positiveMC->GetPdgCode())!=11){
1645 if(negativeMC->GetPdgCode()==positiveMC->GetPdgCode()){
1648 if( (negativeMC->GetUniqueID() == 4 && positiveMC->GetUniqueID() ==4) ||
1649 (negativeMC->GetUniqueID() == 0 && positiveMC->GetUniqueID() ==0) ){// fill r distribution for Dalitz decays
1650 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 111){ //pi0
1651 fHistograms->FillHistogram("ESD_TrueDalitzContamination_R", fV0Reader->GetXYRadius());
1655 if(negativeMC->GetUniqueID() != 5 || positiveMC->GetUniqueID() !=5){// check if the daughters come from a conversion
1659 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
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
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());
1684 fHistograms->FillHistogram("ESD_TrueConvGamma_Pt_Chi2", fV0Reader->GetMotherCandidatePt(), fV0Reader->GetMotherCandidateChi2());
1685 fHistograms->FillHistogram("ESD_TrueConvGamma_Eta_Chi2", fV0Reader->GetMotherCandidateEta(), fV0Reader->GetMotherCandidateChi2());
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());
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());
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; }
1702 fHistograms->FillHistogram("ESD_TrueConvGamma_E_dEdxP",fV0Reader->GetNegativeTrackP(),fV0Reader->GetNegativeTrackTPCdEdx());
1703 fHistograms->FillHistogram("ESD_TrueConvGamma_P_dEdxP",fV0Reader->GetPositiveTrackP(),fV0Reader->GetPositiveTrackTPCdEdx());
1704 fHistograms->FillHistogram("ESD_TrueConvGamma_alfa_qt",armenterosQtAlfa[1],armenterosQtAlfa[0]);
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());
1714 Double_t mcpt = fV0Reader->GetMotherMCParticle()->Pt();
1715 Double_t esdpt = fV0Reader->GetMotherCandidatePt();
1716 Double_t resdPt = 0.;
1718 resdPt = ((esdpt - mcpt)/mcpt)*100.;
1721 cout<<"Pt of MC particle is negative, this will cause wrong calculation of resPt"<<endl;
1724 fHistograms->FillHistogram("Resolution_Gamma_dPt_Pt", mcpt, resdPt);
1725 fHistograms->FillHistogram("Resolution_MC_Pt", mcpt);
1726 fHistograms->FillHistogram("Resolution_ESD_Pt", esdpt);
1727 fHistograms->FillHistogram("Resolution_Gamma_dPt_Phi", fV0Reader->GetMotherCandidatePhi(), resdPt);
1729 Double_t resdZ = 0.;
1730 if(fV0Reader->GetNegativeMCParticle()->Vz() != 0){
1731 resdZ = ((fV0Reader->GetZ() -fV0Reader->GetNegativeMCParticle()->Vz())/fV0Reader->GetNegativeMCParticle()->Vz())*100.;
1733 Double_t resdZAbs = 0.;
1734 resdZAbs = (fV0Reader->GetZ() -fV0Reader->GetNegativeMCParticle()->Vz());
1736 fHistograms->FillHistogram("Resolution_dZAbs_VS_R", fV0Reader->GetNegativeMCParticle()->R(), resdZAbs);
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());
1741 // new for dPt_Pt-histograms for Electron and Positron
1742 Double_t mcEpt = fV0Reader->GetNegativeMCParticle()->Pt();
1743 Double_t resEdPt = 0.;
1745 resEdPt = ((fV0Reader->GetNegativeTrackPt()-mcEpt)/mcEpt)*100.;
1747 UInt_t statusN = fV0Reader->GetNegativeESDTrack()->GetStatus();
1748 // AliESDtrack * negTrk = fV0Reader->GetNegativeESDTrack();
1749 UInt_t kTRDoutN = (statusN & AliESDtrack::kTRDout);
1751 Int_t nITSclsE= fV0Reader->GetNegativeTracknITSClusters();
1752 // filling Resolution_Pt_dPt with respect to the Number of ITS clusters for Positrons
1754 case 0: // 0 ITS clusters
1755 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS0", mcEpt, resEdPt);
1757 case 1: // 1 ITS cluster
1758 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS1", mcEpt, resEdPt);
1760 case 2: // 2 ITS clusters
1761 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS2", mcEpt, resEdPt);
1763 case 3: // 3 ITS clusters
1764 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS3", mcEpt, resEdPt);
1766 case 4: // 4 ITS clusters
1767 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS4", mcEpt, resEdPt);
1769 case 5: // 5 ITS clusters
1770 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS5", mcEpt, resEdPt);
1772 case 6: // 6 ITS clusters
1773 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS6", mcEpt, resEdPt);
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);
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());
1787 Double_t mcPpt = fV0Reader->GetPositiveMCParticle()->Pt();
1788 Double_t resPdPt = 0;
1790 resPdPt = ((fV0Reader->GetPositiveTrackPt()-mcPpt)/mcPpt)*100.;
1793 UInt_t statusP = fV0Reader->GetPositiveESDTrack()->GetStatus();
1794 // AliESDtrack * posTr= fV0Reader->GetPositiveESDTrack();
1795 UInt_t kTRDoutP = (statusP & AliESDtrack::kTRDout);
1797 Int_t nITSclsP = fV0Reader->GetPositiveTracknITSClusters();
1798 // filling Resolution_Pt_dPt with respect to the Number of ITS clusters for Positrons
1800 case 0: // 0 ITS clusters
1801 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS0", mcPpt, resPdPt);
1803 case 1: // 1 ITS cluster
1804 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS1", mcPpt, resPdPt);
1806 case 2: // 2 ITS clusters
1807 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS2", mcPpt, resPdPt);
1809 case 3: // 3 ITS clusters
1810 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS3", mcPpt, resPdPt);
1812 case 4: // 4 ITS clusters
1813 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS4", mcPpt, resPdPt);
1815 case 5: // 5 ITS clusters
1816 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS5", mcPpt, resPdPt);
1818 case 6: // 6 ITS clusters
1819 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS6", mcPpt, resPdPt);
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);
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());
1834 Double_t resdR = 0.;
1835 if(fV0Reader->GetNegativeMCParticle()->R() != 0){
1836 resdR = ((fV0Reader->GetXYRadius() - fV0Reader->GetNegativeMCParticle()->R())/fV0Reader->GetNegativeMCParticle()->R())*100.;
1838 Double_t resdRAbs = 0.;
1839 resdRAbs = (fV0Reader->GetXYRadius() - fV0Reader->GetNegativeMCParticle()->R());
1841 fHistograms->FillHistogram("Resolution_dRAbs_VS_R", fV0Reader->GetNegativeMCParticle()->R(), resdRAbs);
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());
1845 fHistograms->FillHistogram("Resolution_R_dPt", fV0Reader->GetNegativeMCParticle()->R(), resdPt);
1847 Double_t resdPhiAbs=0.;
1849 resdPhiAbs= (fV0Reader->GetMotherCandidatePhi()-fV0Reader->GetNegativeMCParticle()->Phi());
1850 fHistograms->FillHistogram("Resolution_dPhiAbs_VS_R", fV0Reader->GetNegativeMCParticle()->R(), resdPhiAbs);
1852 }//if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22)
1854 }//while(fV0Reader->NextV0)
1855 fHistograms->FillHistogram("ESD_NumberOfSurvivingV0s", nSurvivingV0s);
1856 fHistograms->FillHistogram("ESD_NumberOfV0s", fV0Reader->GetNumberOfV0s());
1857 fHistograms->FillHistogram("ESD_NumberOfContributorsVtx", fV0Reader->GetNumberOfContributorsVtx());
1859 fV0Reader->ResetV0IndexNumber();
1862 void AliAnalysisTaskGammaConversion::FillAODWithConversionGammas(){
1863 // Fill AOD with reconstructed Gamma
1865 for(Int_t gammaIndex=0;gammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();gammaIndex++){
1866 // for(UInt_t gammaIndex=0;gammaIndex<fKFReconstructedGammas.size();gammaIndex++){
1867 //Create AOD particle object from AliKFParticle
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
1872 AliKFParticle * gammakf = dynamic_cast<AliKFParticle*>(fKFReconstructedGammasTClone->At(gammaIndex));
1873 AliAODPWG4Particle gamma = AliAODPWG4Particle(gammakf->Px(),gammakf->Py(),gammakf->Pz(), gammakf->E());
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?
1876 gamma.SetDetector("CTS"); //tag the gamma as reconstructed in the central barrel
1877 gamma.SetPdg(AliPID::kEleCon); //photon id
1878 gamma.SetTag(-1); //Here I usually put a flag saying that montecarlo says it is prompt, decay fragmentation photon, or hadrons or whatever
1879 gamma.SetChi2(gammakf->Chi2());
1880 Int_t i = fAODBranch->GetEntriesFast();
1881 new((*fAODBranch)[i]) AliAODPWG4Particle(gamma);
1884 AliKFParticle * gammakf = (AliKFParticle *)fKFReconstructedGammasTClone->At(gammaIndex);
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]);
1891 aodObject.SetChi2(gammakf->Chi2());
1892 aodObject.SetE(gammakf->E());
1893 Int_t i = fAODGamma->GetEntriesFast();
1894 new((*fAODGamma)[i]) AliGammaConversionAODObject(aodObject);
1899 void AliAnalysisTaskGammaConversion::ProcessGammasForOmegaMesonAnalysis(){
1900 // omega meson analysis pi0+gamma decay
1901 for(Int_t firstPi0Index=0;firstPi0Index<fKFReconstructedPi0sTClone->GetEntriesFast();firstPi0Index++){
1902 AliKFParticle * omegaCandidatePi0Daughter = (AliKFParticle *)fKFReconstructedPi0sTClone->At(firstPi0Index);
1903 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();firstGammaIndex++){
1905 AliKFParticle * omegaCandidateGammaDaughter = (AliKFParticle *)fKFReconstructedGammasTClone->At(firstGammaIndex);
1906 if(fGammav1[firstPi0Index]==firstGammaIndex || fGammav2[firstPi0Index]==firstGammaIndex){
1910 AliKFParticle omegaCandidate(*omegaCandidatePi0Daughter,*omegaCandidateGammaDaughter);
1911 Double_t massOmegaCandidate = 0.;
1912 Double_t widthOmegaCandidate = 0.;
1914 omegaCandidate.GetMass(massOmegaCandidate,widthOmegaCandidate);
1916 if ( massOmegaCandidate > 733 && massOmegaCandidate < 833 ) {
1917 AddOmegaToAOD(&omegaCandidate, massOmegaCandidate, firstPi0Index, firstGammaIndex);
1920 fHistograms->FillHistogram("ESD_Omega_InvMass_vs_Pt",massOmegaCandidate ,omegaCandidate.GetPt());
1921 fHistograms->FillHistogram("ESD_Omega_InvMass",massOmegaCandidate);
1923 //delete omegaCandidate;
1925 }// end of omega reconstruction in pi0+gamma channel
1927 if(fDoJet == kTRUE){
1928 AliKFParticle* negPiKF=NULL;
1929 AliKFParticle* posPiKF=NULL;
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;
1935 if(TMath::Abs(fV0Reader->GetESDpid()->NumberOfSigmasTPC(posTrack,AliPID::kPion))>2.) continue;
1936 if (posPiKF) delete posPiKF; posPiKF=NULL;
1937 posPiKF = new AliKFParticle( *(posTrack) ,211);
1939 for(Int_t jCh=0;jCh<fChargedParticles->GetEntriesFast();jCh++){
1940 AliESDtrack* negTrack = (AliESDtrack*)(fChargedParticles->At(jCh));
1941 if( negTrack->GetSign()>0) continue;
1942 if(TMath::Abs(fV0Reader->GetESDpid()->NumberOfSigmasTPC(negTrack,AliPID::kPion))>2.) continue;
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.;
1949 omegaCandidatePipPinPi0.GetMass(massOmegaCandidatePipPinPi0,widthOmegaCandidatePipPinPi0);
1951 if ( massOmegaCandidatePipPinPi0 > 733 && massOmegaCandidatePipPinPi0 < 833 ) {
1952 AddOmegaToAOD(&omegaCandidatePipPinPi0, massOmegaCandidatePipPinPi0, -1, -1);
1955 fHistograms->FillHistogram("ESD_OmegaPipPinPi0_InvMass_vs_Pt",massOmegaCandidatePipPinPi0 ,omegaCandidatePipPinPi0.GetPt());
1956 fHistograms->FillHistogram("ESD_OmegaPipPinPi0_InvMass",massOmegaCandidatePipPinPi0);
1958 // delete omegaCandidatePipPinPi0;
1961 } // checking ig gammajet because in that case the chargedparticle list is created
1967 if(fCalculateBackground){
1969 AliGammaConversionBGHandler * bgHandler = fV0Reader->GetBGHandler();
1971 Int_t zbin= bgHandler->GetZBinIndex(fV0Reader->GetVertexZ());
1973 if(fUseTrackMultiplicityForBG == kTRUE){
1974 mbin = bgHandler->GetMultiplicityBinIndex(fV0Reader->CountESDTracks());
1977 mbin = bgHandler->GetMultiplicityBinIndex(fV0Reader->GetNGoodV0s());
1980 AliGammaConversionBGHandler::GammaConversionVertex *bgEventVertex = NULL;
1982 // Background calculation for the omega
1983 for(Int_t nEventsInBG=0;nEventsInBG <fV0Reader->GetNBGEvents();nEventsInBG++){
1984 AliGammaConversionKFVector * previousEventV0s = bgHandler->GetBGGoodV0s(zbin,mbin,nEventsInBG);
1986 if(fMoveParticleAccordingToVertex == kTRUE){
1987 bgEventVertex = bgHandler->GetBGEventVertex(zbin,mbin,nEventsInBG);
1989 for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
1990 AliKFParticle previousGoodV0 = (AliKFParticle)(*(previousEventV0s->at(iPrevious)));
1992 if(fMoveParticleAccordingToVertex == kTRUE){
1993 MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
1996 for(Int_t firstPi0Index=0;firstPi0Index<fKFReconstructedPi0sTClone->GetEntriesFast();firstPi0Index++){
1997 AliKFParticle * omegaCandidatePi0Daughter = (AliKFParticle *)fKFReconstructedPi0sTClone->At(firstPi0Index);
1998 AliKFParticle * omegaBckCandidate = new AliKFParticle(*omegaCandidatePi0Daughter,previousGoodV0);
1999 Double_t massOmegaBckCandidate = 0.;
2000 Double_t widthOmegaBckCandidate = 0.;
2002 omegaBckCandidate->GetMass(massOmegaBckCandidate,widthOmegaBckCandidate);
2005 fHistograms->FillHistogram("ESD_Omega_Bck_InvMass_vs_Pt",massOmegaBckCandidate ,omegaBckCandidate->GetPt());
2006 fHistograms->FillHistogram("ESD_Omega_Bck_InvMass",massOmegaBckCandidate);
2008 delete omegaBckCandidate;
2012 } // end of checking if background calculation is available
2016 void AliAnalysisTaskGammaConversion::AddOmegaToAOD(const AliKFParticle * const omegakf, Double_t mass, Int_t omegaDaughter, Int_t gammaDaughter) {
2017 //See header file for documentation
2018 AliGammaConversionAODObject omega;
2019 omega.SetPx(omegakf->GetPx());
2020 omega.SetPy(omegakf->GetPy());
2021 omega.SetPz(omegakf->GetPz());
2022 omega.SetChi2(omegakf->GetChi2());
2023 omega.SetE(omegakf->GetE());
2024 omega.SetIMass(mass);
2025 omega.SetLabel1(omegaDaughter);
2026 //dynamic_cast<AliGammaConversionAODObject*>(fAODBranch->At(daughter1))->SetTagged(kTRUE);
2027 omega.SetLabel2(gammaDaughter);
2028 new((*fAODOmega)[fAODOmega->GetEntriesFast()]) AliGammaConversionAODObject(omega);
2033 void AliAnalysisTaskGammaConversion::ProcessGammasForNeutralMesonAnalysis(){
2034 // see header file for documentation
2036 // for(UInt_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammas.size();firstGammaIndex++){
2037 // for(UInt_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fKFReconstructedGammas.size();secondGammaIndex++){
2039 fESDEvent = fV0Reader->GetESDEvent();
2041 if(fKFReconstructedGammasTClone->GetEntriesFast()>fV0Reader->GetNumberOfV0s()){
2042 cout<<"Warning, number of entries in the tclone is bigger than number of v0s"<<endl;
2045 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();firstGammaIndex++){
2046 for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();secondGammaIndex++){
2048 // AliKFParticle * twoGammaDecayCandidateDaughter0 = &fKFReconstructedGammas[firstGammaIndex];
2049 // AliKFParticle * twoGammaDecayCandidateDaughter1 = &fKFReconstructedGammas[secondGammaIndex];
2051 AliKFParticle * twoGammaDecayCandidateDaughter0 = (AliKFParticle *)fKFReconstructedGammasTClone->At(firstGammaIndex);
2052 AliKFParticle * twoGammaDecayCandidateDaughter1 = (AliKFParticle *)fKFReconstructedGammasTClone->At(secondGammaIndex);
2054 if(fElectronv1[firstGammaIndex]==fElectronv1[secondGammaIndex] || fElectronv1[firstGammaIndex]==fElectronv2[secondGammaIndex]){
2057 if(fElectronv2[firstGammaIndex]==fElectronv1[secondGammaIndex] || fElectronv2[firstGammaIndex]==fElectronv2[secondGammaIndex]){
2061 AliKFParticle *twoGammaCandidate = new AliKFParticle(*twoGammaDecayCandidateDaughter0,*twoGammaDecayCandidateDaughter1);
2063 Double_t massTwoGammaCandidate = 0.;
2064 Double_t widthTwoGammaCandidate = 0.;
2065 Double_t chi2TwoGammaCandidate =10000.;
2066 twoGammaCandidate->GetMass(massTwoGammaCandidate,widthTwoGammaCandidate);
2067 // if(twoGammaCandidate->GetNDF()>0){
2068 // chi2TwoGammaCandidate = twoGammaCandidate->GetChi2()/twoGammaCandidate->GetNDF();
2069 chi2TwoGammaCandidate = twoGammaCandidate->GetChi2();
2071 fHistograms->FillHistogram("ESD_Mother_Chi2",chi2TwoGammaCandidate);
2072 if((chi2TwoGammaCandidate>0 && chi2TwoGammaCandidate<fV0Reader->GetChi2CutMeson()) || fApplyChi2Cut == kFALSE){
2074 TVector3 momentumVectorTwoGammaCandidate(twoGammaCandidate->GetPx(),twoGammaCandidate->GetPy(),twoGammaCandidate->GetPz());
2075 TVector3 spaceVectorTwoGammaCandidate(twoGammaCandidate->GetX(),twoGammaCandidate->GetY(),twoGammaCandidate->GetZ());
2077 Double_t openingAngleTwoGammaCandidate = twoGammaDecayCandidateDaughter0->GetAngle(*twoGammaDecayCandidateDaughter1);
2079 if(twoGammaCandidate->GetE() - twoGammaCandidate->GetPz() <= 0 || twoGammaCandidate->GetE() + twoGammaCandidate->GetPz() <= 0){
2080 cout << "Error: |Pz| > E !!!! " << endl;
2084 rapidity = 0.5*(TMath::Log((twoGammaCandidate->GetE() +twoGammaCandidate->GetPz()) / (twoGammaCandidate->GetE()-twoGammaCandidate->GetPz())));
2087 if(TMath::Abs(rapidity) > fV0Reader->GetRapidityMesonCut()){
2088 delete twoGammaCandidate;
2089 continue; // rapidity cut
2094 if( (twoGammaDecayCandidateDaughter0->GetE()+twoGammaDecayCandidateDaughter1->GetE()) != 0){
2095 alfa=TMath::Abs((twoGammaDecayCandidateDaughter0->GetE()-twoGammaDecayCandidateDaughter1->GetE())
2096 /(twoGammaDecayCandidateDaughter0->GetE()+twoGammaDecayCandidateDaughter1->GetE()));
2099 if(openingAngleTwoGammaCandidate < fMinOpeningAngleGhostCut){
2100 delete twoGammaCandidate;
2101 continue; // minimum opening angle to avoid using ghosttracks
2104 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
2105 fHistograms->FillHistogram("ESD_Mother_GammaDaughter_OpeningAngle", openingAngleTwoGammaCandidate);
2106 fHistograms->FillHistogram("ESD_Mother_Energy", twoGammaCandidate->GetE());
2107 fHistograms->FillHistogram("ESD_Mother_Pt", momentumVectorTwoGammaCandidate.Pt());
2108 fHistograms->FillHistogram("ESD_Mother_Eta", momentumVectorTwoGammaCandidate.Eta());
2109 fHistograms->FillHistogram("ESD_Mother_Rapid", rapidity);
2110 fHistograms->FillHistogram("ESD_Mother_Phi", spaceVectorTwoGammaCandidate.Phi());
2111 fHistograms->FillHistogram("ESD_Mother_Mass", massTwoGammaCandidate);
2112 fHistograms->FillHistogram("ESD_Mother_alfa", alfa);
2113 if(massTwoGammaCandidate>0.1 && massTwoGammaCandidate<0.15){
2114 fHistograms->FillHistogram("ESD_Mother_alfa_Pi0", alfa);
2116 fHistograms->FillHistogram("ESD_Mother_R", spaceVectorTwoGammaCandidate.Pt()); // Pt in Space == R!!!
2117 fHistograms->FillHistogram("ESD_Mother_ZR", twoGammaCandidate->GetZ(), spaceVectorTwoGammaCandidate.Pt());
2118 fHistograms->FillHistogram("ESD_Mother_XY", twoGammaCandidate->GetX(), twoGammaCandidate->GetY());
2119 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2120 fHistograms->FillHistogram("ESD_Mother_InvMass",massTwoGammaCandidate);
2121 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt_alpha",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2124 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_E_alpha",massTwoGammaCandidate ,twoGammaCandidate->GetE());
2128 if(fCalculateBackground){
2129 /* Kenneth, just for testing*/
2130 AliGammaConversionBGHandler * bgHandlerTest = fV0Reader->GetBGHandler();
2132 Int_t zbin= bgHandlerTest->GetZBinIndex(fV0Reader->GetVertexZ());
2135 if(fUseTrackMultiplicityForBG == kTRUE){
2136 multKAA=fV0Reader->CountESDTracks();
2137 mbin = bgHandlerTest->GetMultiplicityBinIndex(fV0Reader->CountESDTracks());
2139 else{// means we use #v0s for multiplicity
2140 multKAA=fV0Reader->GetNGoodV0s();
2141 mbin = bgHandlerTest->GetMultiplicityBinIndex(fV0Reader->GetNGoodV0s());
2143 // cout<<"Filling bin number "<<zbin<<" and "<<mbin<<endl;
2144 // cout<<"Corresponding to z = "<<fV0Reader->GetVertexZ()<<" and m = "<<multKAA<<endl;
2145 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
2146 fHistograms->FillHistogram(Form("%d%dESD_Mother_InvMass",zbin,mbin),massTwoGammaCandidate);
2147 fHistograms->FillHistogram(Form("%d%dESD_Mother_InvMass_vs_Pt",zbin,mbin),massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2148 /* end Kenneth, just for testing*/
2149 fHistograms->FillHistogram(Form("%dESD_Mother_InvMass_vs_Pt",mbin),massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2152 /* if(fCalculateBackground){
2153 AliGammaConversionBGHandler * bgHandler = fV0Reader->GetBGHandler();
2154 Int_t mbin= bgHandler->GetMultiplicityBinIndex(fV0Reader->CountESDTracks());
2155 fHistograms->FillHistogram(Form("%dESD_Mother_InvMass_vs_Pt",mbin),massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2157 // if(fDoNeutralMesonV0MCCheck){
2159 //Kenneth: Checking the eta of the gamma to check the difference between 0.9 and 1.2
2160 Int_t indexKF1 = fKFReconstructedGammasV0Index.at(firstGammaIndex);
2161 if(indexKF1<fV0Reader->GetNumberOfV0s()){
2162 fV0Reader->GetV0(indexKF1);//updates to the correct v0
2163 Double_t eta1 = fV0Reader->GetMotherCandidateEta();
2164 Bool_t isRealPi0=kFALSE;
2165 Bool_t isRealEta=kFALSE;
2166 Int_t gamma1MotherLabel=-1;
2167 if(fV0Reader->HasSameMCMother() == kTRUE){
2168 //cout<<"This v0 is a real v0!!!!"<<endl;
2169 TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
2170 TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
2171 if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){
2172 if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){
2173 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
2174 gamma1MotherLabel=fV0Reader->GetMotherMCParticle()->GetFirstMother();
2179 Int_t indexKF2 = fKFReconstructedGammasV0Index.at(secondGammaIndex);
2180 if(indexKF1 == indexKF2){
2181 cout<<"index of the two KF particles are the same.... should not happen"<<endl;
2183 if(indexKF2<fV0Reader->GetNumberOfV0s()){
2184 fV0Reader->GetV0(indexKF2);
2185 Double_t eta2 = fV0Reader->GetMotherCandidateEta();
2186 Int_t gamma2MotherLabel=-1;
2187 if(fV0Reader->HasSameMCMother() == kTRUE){
2188 TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
2189 TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
2190 if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){
2191 if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){
2192 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
2193 gamma2MotherLabel=fV0Reader->GetMotherMCParticle()->GetFirstMother();
2198 if(gamma1MotherLabel>=0 && gamma1MotherLabel==gamma2MotherLabel){
2199 if(fV0Reader->CheckIfPi0IsMother(gamma1MotherLabel)){
2202 if(fV0Reader->CheckIfEtaIsMother(gamma1MotherLabel)){
2207 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
2208 if(TMath::Abs(eta1)>0.9 && TMath::Abs(eta2)>0.9){
2209 // fHistograms->FillHistogram("ESD_Mother_InvMass_1212",massTwoGammaCandidate);
2210 // fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt1212",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2211 if(isRealPi0 || isRealEta){
2212 fHistograms->FillHistogram("ESD_TruePi0_InvMass_1212",massTwoGammaCandidate);
2213 fHistograms->FillHistogram("ESD_TruePi0_OpeningAngle_1212",openingAngleTwoGammaCandidate);
2214 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt1212",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2215 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2216 fHistograms->FillHistogram("ESD_TruePi0_InvMass",massTwoGammaCandidate);
2217 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt_alpha",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2220 if(!isRealPi0 && !isRealEta){
2221 if(gamma1MotherLabel>-1 && gamma2MotherLabel>-1){
2222 fHistograms->FillHistogram("ESD_TrueBckGG_InvMass",massTwoGammaCandidate);
2224 fHistograms->FillHistogram("ESD_TrueBckCont_InvMass",massTwoGammaCandidate);
2229 else if(TMath::Abs(eta1)>0.9 || TMath::Abs(eta2)>0.9){
2230 // fHistograms->FillHistogram("ESD_Mother_InvMass_0912",massTwoGammaCandidate);
2231 // fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt0912",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2233 if(isRealPi0 || isRealEta){
2234 fHistograms->FillHistogram("ESD_TruePi0_InvMass_0912",massTwoGammaCandidate);
2235 fHistograms->FillHistogram("ESD_TruePi0_OpeningAngle_0912",openingAngleTwoGammaCandidate);
2236 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt0912",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2237 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2238 fHistograms->FillHistogram("ESD_TruePi0_InvMass",massTwoGammaCandidate);
2239 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt_alpha",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2241 if(!isRealPi0 && !isRealEta){
2242 if(gamma1MotherLabel>-1 && gamma2MotherLabel>-1){
2243 fHistograms->FillHistogram("ESD_TrueBckGG_InvMass",massTwoGammaCandidate);
2245 fHistograms->FillHistogram("ESD_TrueBckCont_InvMass",massTwoGammaCandidate);
2250 // fHistograms->FillHistogram("ESD_Mother_InvMass_0909",massTwoGammaCandidate);
2251 // fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt0909",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2252 if(isRealPi0 || isRealEta){
2253 fHistograms->FillHistogram("ESD_TruePi0_InvMass_0909",massTwoGammaCandidate);
2254 fHistograms->FillHistogram("ESD_TruePi0_OpeningAngle_0909",openingAngleTwoGammaCandidate);
2255 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt0909",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2256 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2257 fHistograms->FillHistogram("ESD_TruePi0_InvMass",massTwoGammaCandidate);
2258 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt_alpha",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2259 if(gamma1MotherLabel > fV0Reader->GetMCStack()->GetNprimary()){
2260 fHistograms->FillHistogram("ESD_TruePi0Sec_InvMass",massTwoGammaCandidate);
2263 if(!isRealPi0 && !isRealEta){
2264 if(gamma1MotherLabel>-1 && gamma2MotherLabel>-1){
2265 fHistograms->FillHistogram("ESD_TrueBckGG_InvMass",massTwoGammaCandidate);
2267 fHistograms->FillHistogram("ESD_TrueBckCont_InvMass",massTwoGammaCandidate);
2275 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
2276 if ( TMath::Abs(twoGammaDecayCandidateDaughter0->GetEta())<0.9 && TMath::Abs(twoGammaDecayCandidateDaughter1->GetEta())<0.9 ){
2277 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt_Fiducial",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2278 fHistograms->FillHistogram("ESD_Mother_InvMass_Fiducial",massTwoGammaCandidate);
2281 if(TMath::Abs(twoGammaDecayCandidateDaughter0->GetEta())>0.9 && TMath::Abs(twoGammaDecayCandidateDaughter1->GetEta())>0.9){
2282 fHistograms->FillHistogram("ESD_Mother_InvMass_1212",massTwoGammaCandidate);
2283 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt1212",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2285 else if(TMath::Abs(twoGammaDecayCandidateDaughter0->GetEta())>0.9 || TMath::Abs(twoGammaDecayCandidateDaughter1->GetEta())>0.9){
2286 fHistograms->FillHistogram("ESD_Mother_InvMass_0912",massTwoGammaCandidate);
2287 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt0912",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2290 fHistograms->FillHistogram("ESD_Mother_InvMass_0909",massTwoGammaCandidate);
2291 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt0909",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2294 Double_t lowMassPi0=0.1;
2295 Double_t highMassPi0=0.15;
2296 if (massTwoGammaCandidate > lowMassPi0 && massTwoGammaCandidate < highMassPi0 ){
2297 new((*fKFReconstructedPi0sTClone)[fKFReconstructedPi0sTClone->GetEntriesFast()]) AliKFParticle(*twoGammaCandidate);
2298 fGammav1.push_back(firstGammaIndex);
2299 fGammav2.push_back(secondGammaIndex);
2300 AddPionToAOD(twoGammaCandidate, massTwoGammaCandidate, firstGammaIndex, secondGammaIndex);
2306 delete twoGammaCandidate;
2311 void AliAnalysisTaskGammaConversion::AddPionToAOD(const AliKFParticle * const pionkf, Double_t mass, Int_t daughter1, Int_t daughter2) {
2312 //See header file for documentation
2313 AliGammaConversionAODObject pion;
2314 pion.SetPx(pionkf->GetPx());
2315 pion.SetPy(pionkf->GetPy());
2316 pion.SetPz(pionkf->GetPz());
2317 pion.SetChi2(pionkf->GetChi2());
2318 pion.SetE(pionkf->GetE());
2319 pion.SetIMass(mass);
2320 pion.SetLabel1(daughter1);
2321 //dynamic_cast<AliGammaConversionAODObject*>(fAODBranch->At(daughter1))->SetTagged(kTRUE);
2322 pion.SetLabel2(daughter2);
2323 new((*fAODPi0)[fAODPi0->GetEntriesFast()]) AliGammaConversionAODObject(pion);
2329 void AliAnalysisTaskGammaConversion::ProcessConvPHOSGammasForNeutralMesonAnalysis(){
2331 // see header file for documentation
2332 // Analyse Pi0 with one photon from Phos and 1 photon from conversions
2337 vtx[0] = fV0Reader->GetPrimaryVertex()->GetX();
2338 vtx[1] = fV0Reader->GetPrimaryVertex()->GetY();
2339 vtx[2] = fV0Reader->GetPrimaryVertex()->GetZ();
2342 // Loop over all CaloClusters and consider only the PHOS ones:
2343 AliESDCaloCluster *clu;
2344 TLorentzVector pPHOS;
2345 TLorentzVector gammaPHOS;
2346 TLorentzVector gammaGammaConv;
2347 TLorentzVector pi0GammaConvPHOS;
2348 TLorentzVector gammaGammaConvBck;
2349 TLorentzVector pi0GammaConvPHOSBck;
2352 for (Int_t i=0; i<fV0Reader->GetESDEvent()->GetNumberOfCaloClusters(); i++) {
2353 clu = fV0Reader->GetESDEvent()->GetCaloCluster(i);
2354 if ( !clu->IsPHOS() || clu->E()<0.1 ) continue;
2355 clu ->GetMomentum(pPHOS ,vtx);
2356 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();firstGammaIndex++){
2357 AliKFParticle * twoGammaDecayCandidateDaughter0 = (AliKFParticle *)fKFReconstructedGammasTClone->At(firstGammaIndex);
2358 gammaGammaConv.SetXYZM(twoGammaDecayCandidateDaughter0->Px(),twoGammaDecayCandidateDaughter0->Py(),twoGammaDecayCandidateDaughter0->Pz(),0.);
2359 gammaPHOS.SetXYZM(pPHOS.Px(),pPHOS.Py(),pPHOS.Pz(),0.);
2360 pi0GammaConvPHOS=gammaGammaConv+gammaPHOS;
2361 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvPHOS",pi0GammaConvPHOS.M());
2362 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt_GammaConvPHOS",pi0GammaConvPHOS.M(),pi0GammaConvPHOS.Pt());
2364 TVector3 v3D0(twoGammaDecayCandidateDaughter0->Px(),twoGammaDecayCandidateDaughter0->Py(),twoGammaDecayCandidateDaughter0->Pz());
2365 TVector3 v3D1(gammaPHOS.Px(),gammaPHOS.Py(),gammaPHOS.Pz());
2366 Double_t opanConvPHOS= v3D0.Angle(v3D1);
2367 if ( opanConvPHOS < 0.35){
2368 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvPHOS_OpanLow",pi0GammaConvPHOS.M());
2370 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvPHOS_OpanHigh",pi0GammaConvPHOS.M());
2375 // Now the LorentVector pPHOS is obtained and can be paired with the converted proton
2377 //==== End of the PHOS cluster selection ============
2378 TLorentzVector pEMCAL;
2379 TLorentzVector gammaEMCAL;
2380 TLorentzVector pi0GammaConvEMCAL;
2381 TLorentzVector pi0GammaConvEMCALBck;
2383 for (Int_t i=0; i<fV0Reader->GetESDEvent()->GetNumberOfCaloClusters(); i++) {
2384 clu = fV0Reader->GetESDEvent()->GetCaloCluster(i);
2385 if ( !clu->IsEMCAL() || clu->E()<0.1 ) continue;
2386 if (clu->GetNCells() <= 1) continue;
2387 if ( clu->GetTOF()*1e9 < 550 || clu->GetTOF()*1e9 > 750) continue;
2389 clu ->GetMomentum(pEMCAL ,vtx);
2390 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();firstGammaIndex++){
2391 AliKFParticle * twoGammaDecayCandidateDaughter0 = (AliKFParticle *)fKFReconstructedGammasTClone->At(firstGammaIndex);
2392 gammaGammaConv.SetXYZM(twoGammaDecayCandidateDaughter0->Px(),
2393 twoGammaDecayCandidateDaughter0->Py(),
2394 twoGammaDecayCandidateDaughter0->Pz(),0.);
2395 gammaEMCAL.SetXYZM(pEMCAL.Px(),pEMCAL.Py(),pEMCAL.Pz(),0.);
2396 pi0GammaConvEMCAL=gammaGammaConv+gammaEMCAL;
2397 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvEMCAL",pi0GammaConvEMCAL.M());
2398 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt_GammaConvEMCAL",pi0GammaConvEMCAL.M(),pi0GammaConvEMCAL.Pt());
2399 TVector3 v3D0(twoGammaDecayCandidateDaughter0->Px(),
2400 twoGammaDecayCandidateDaughter0->Py(),
2401 twoGammaDecayCandidateDaughter0->Pz());
2402 TVector3 v3D1(gammaEMCAL.Px(),gammaEMCAL.Py(),gammaEMCAL.Pz());
2405 Double_t opanConvEMCAL= v3D0.Angle(v3D1);
2406 if ( opanConvEMCAL < 0.35){
2407 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvEMCAL_OpanLow",pi0GammaConvEMCAL.M());
2409 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvEMCAL_OpanHigh",pi0GammaConvEMCAL.M());
2413 if(fCalculateBackground){
2414 for(Int_t nEventsInBG=0;nEventsInBG <fV0Reader->GetNBGEvents();nEventsInBG++){
2415 AliGammaConversionKFVector * previousEventV0s = fV0Reader->GetBGGoodV0s(nEventsInBG);
2416 for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
2417 AliKFParticle previousGoodV0 = (AliKFParticle)(*(previousEventV0s->at(iPrevious)));
2418 gammaGammaConvBck.SetXYZM(previousGoodV0.Px(),
2419 previousGoodV0.Py(),
2420 previousGoodV0.Pz(),0.);
2421 pi0GammaConvEMCALBck=gammaGammaConvBck+gammaEMCAL;
2422 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvEMCAL_Bck",pi0GammaConvEMCALBck.M());
2423 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt_GammaConvEMCAL_Bck",pi0GammaConvEMCALBck.M(),
2424 pi0GammaConvEMCALBck.Pt());
2428 // Now the LorentVector pEMCAL is obtained and can be paired with the converted proton
2429 } // end of checking if background photons are available
2431 //==== End of the PHOS cluster selection ============
2436 void AliAnalysisTaskGammaConversion::MoveParticleAccordingToVertex(AliKFParticle * particle,const AliGammaConversionBGHandler::GammaConversionVertex *vertex){
2437 //see header file for documentation
2439 Double_t dx = vertex->fX - fESDEvent->GetPrimaryVertex()->GetX();
2440 Double_t dy = vertex->fY - fESDEvent->GetPrimaryVertex()->GetY();
2441 Double_t dz = vertex->fZ - fESDEvent->GetPrimaryVertex()->GetZ();
2443 // cout<<"dx, dy, dz: ["<<dx<<","<<dy<<","<<dz<<"]"<<endl;
2444 particle->X() = particle->GetX() - dx;
2445 particle->Y() = particle->GetY() - dy;
2446 particle->Z() = particle->GetZ() - dz;
2449 void AliAnalysisTaskGammaConversion::RotateKFParticle(AliKFParticle * kfParticle,Double_t angle){
2450 // Rotate the kf particle
2451 Double_t c = cos(angle);
2452 Double_t s = sin(angle);
2455 for( Int_t i=0; i<7; i++ ){
2456 for( Int_t j=0; j<7; j++){
2460 for( int i=0; i<7; i++ ){
2463 mA[0][0] = c; mA[0][1] = s;
2464 mA[1][0] = -s; mA[1][1] = c;
2465 mA[3][3] = c; mA[3][4] = s;
2466 mA[4][3] = -s; mA[4][4] = c;
2471 for( Int_t i=0; i<7; i++ ){
2473 for( Int_t k=0; k<7; k++){
2474 mAp[i]+=mA[i][k] * kfParticle->GetParameter(k);
2478 for( Int_t i=0; i<7; i++){
2479 kfParticle->Parameter(i) = mAp[i];
2482 for( Int_t i=0; i<7; i++ ){
2483 for( Int_t j=0; j<7; j++ ){
2485 for( Int_t k=0; k<7; k++ ){
2486 mAC[i][j]+= mA[i][k] * kfParticle->GetCovariance(k,j);
2491 for( Int_t i=0; i<7; i++ ){
2492 for( Int_t j=0; j<=i; j++ ){
2494 for( Int_t k=0; k<7; k++){
2495 xx+= mAC[i][k]*mA[j][k];
2497 kfParticle->Covariance(i,j) = xx;
2503 void AliAnalysisTaskGammaConversion::CalculateBackground(){
2504 // see header file for documentation
2507 TClonesArray * currentEventV0s = fV0Reader->GetCurrentEventGoodV0s();
2509 AliGammaConversionBGHandler * bgHandler = fV0Reader->GetBGHandler();
2511 Int_t zbin= bgHandler->GetZBinIndex(fV0Reader->GetVertexZ());
2513 if(fUseTrackMultiplicityForBG == kTRUE){
2514 mbin = bgHandler->GetMultiplicityBinIndex(fV0Reader->CountESDTracks());
2517 mbin = bgHandler->GetMultiplicityBinIndex(fV0Reader->GetNGoodV0s());
2520 if(fDoRotation == kTRUE){
2521 TRandom3 *random = new TRandom3();
2522 for(Int_t iCurrent=0;iCurrent<currentEventV0s->GetEntriesFast();iCurrent++){
2523 AliKFParticle currentEventGoodV0 = *(AliKFParticle *)(currentEventV0s->At(iCurrent));
2524 for(Int_t iCurrent2=iCurrent+1;iCurrent2<currentEventV0s->GetEntriesFast();iCurrent2++){
2525 for(Int_t nRandom=0;nRandom<fNRandomEventsForBG;nRandom++){
2527 AliKFParticle currentEventGoodV02 = *(AliKFParticle *)(currentEventV0s->At(iCurrent2));
2529 if(fCheckBGProbability == kTRUE){
2530 Double_t massBGprob =0.;
2531 Double_t widthBGprob = 0.;
2532 AliKFParticle *backgroundCandidateProb = new AliKFParticle(currentEventGoodV0,currentEventGoodV02);
2533 backgroundCandidateProb->GetMass(massBGprob,widthBGprob);
2534 if(massBGprob>0.1 && massBGprob<0.14){
2535 if(random->Rndm()>bgHandler->GetBGProb(zbin,mbin)){
2536 delete backgroundCandidateProb;
2540 delete backgroundCandidateProb;
2543 Double_t nRadiansPM = fNDegreesPMBackground*TMath::Pi()/180;
2545 Double_t rotationValue = random->Rndm()*2*nRadiansPM + TMath::Pi()-nRadiansPM;
2547 RotateKFParticle(¤tEventGoodV02,rotationValue);
2549 AliKFParticle *backgroundCandidate = new AliKFParticle(currentEventGoodV0,currentEventGoodV02);
2551 Double_t massBG =0.;
2552 Double_t widthBG = 0.;
2553 Double_t chi2BG =10000.;
2554 backgroundCandidate->GetMass(massBG,widthBG);
2556 // if(backgroundCandidate->GetNDF()>0){
2557 chi2BG = backgroundCandidate->GetChi2();
2558 if((chi2BG>0 && chi2BG<fV0Reader->GetChi2CutMeson()) || fApplyChi2Cut == kFALSE){
2560 TVector3 momentumVectorbackgroundCandidate(backgroundCandidate->GetPx(),backgroundCandidate->GetPy(),backgroundCandidate->GetPz());
2561 TVector3 spaceVectorbackgroundCandidate(backgroundCandidate->GetX(),backgroundCandidate->GetY(),backgroundCandidate->GetZ());
2563 Double_t openingAngleBG = currentEventGoodV0.GetAngle(currentEventGoodV02);
2566 if(backgroundCandidate->GetE() - backgroundCandidate->GetPz() == 0 || backgroundCandidate->GetE() + backgroundCandidate->GetPz() == 0) rapidity=0;
2567 else rapidity = 0.5*(TMath::Log((backgroundCandidate->GetE() +backgroundCandidate->GetPz()) / (backgroundCandidate->GetE()-backgroundCandidate->GetPz())));
2569 if(TMath::Abs(rapidity) > fV0Reader->GetRapidityMesonCut() ){
2570 delete backgroundCandidate;
2571 continue; // rapidity cut
2576 if( (currentEventGoodV0.GetE()+currentEventGoodV02.GetE()) != 0){
2577 alfa=TMath::Abs((currentEventGoodV0.GetE()-currentEventGoodV02.GetE())
2578 /(currentEventGoodV0.GetE()+currentEventGoodV02.GetE()));
2582 if(openingAngleBG < fMinOpeningAngleGhostCut ){
2583 delete backgroundCandidate;
2584 continue; // minimum opening angle to avoid using ghosttracks
2588 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
2589 fHistograms->FillHistogram("ESD_Background_GammaDaughter_OpeningAngle", openingAngleBG);
2590 fHistograms->FillHistogram("ESD_Background_Energy", backgroundCandidate->GetE());
2591 fHistograms->FillHistogram("ESD_Background_Pt", momentumVectorbackgroundCandidate.Pt());
2592 fHistograms->FillHistogram("ESD_Background_Eta", momentumVectorbackgroundCandidate.Eta());
2593 fHistograms->FillHistogram("ESD_Background_Rapidity", rapidity);
2594 fHistograms->FillHistogram("ESD_Background_Phi", spaceVectorbackgroundCandidate.Phi());
2595 fHistograms->FillHistogram("ESD_Background_Mass", massBG);
2596 fHistograms->FillHistogram("ESD_Background_R", spaceVectorbackgroundCandidate.Pt()); // Pt in Space == R!!!!
2597 fHistograms->FillHistogram("ESD_Background_ZR", backgroundCandidate->GetZ(), spaceVectorbackgroundCandidate.Pt());
2598 fHistograms->FillHistogram("ESD_Background_XY", backgroundCandidate->GetX(), backgroundCandidate->GetY());
2599 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt",massBG,momentumVectorbackgroundCandidate.Pt());
2600 fHistograms->FillHistogram("ESD_Background_InvMass",massBG);
2601 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt_alpha",massBG,momentumVectorbackgroundCandidate.Pt());
2604 if ( TMath::Abs(currentEventGoodV0.GetEta())<0.9 && TMath::Abs(currentEventGoodV02.GetEta())<0.9 ){
2605 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt_Fiducial",massBG,momentumVectorbackgroundCandidate.Pt());
2606 fHistograms->FillHistogram("ESD_Background_InvMass_Fiducial",massBG);
2609 fHistograms->FillHistogram(Form("%d%dESD_Background_GammaDaughter_OpeningAngle",zbin,mbin), openingAngleBG);
2610 fHistograms->FillHistogram(Form("%d%dESD_Background_Energy",zbin,mbin), backgroundCandidate->GetE());
2611 fHistograms->FillHistogram(Form("%d%dESD_Background_Pt",zbin,mbin), momentumVectorbackgroundCandidate.Pt());
2612 fHistograms->FillHistogram(Form("%d%dESD_Background_Eta",zbin,mbin), momentumVectorbackgroundCandidate.Eta());
2613 fHistograms->FillHistogram(Form("%d%dESD_Background_Rapidity",zbin,mbin), rapidity);
2614 fHistograms->FillHistogram(Form("%d%dESD_Background_Phi",zbin,mbin), spaceVectorbackgroundCandidate.Phi());
2615 fHistograms->FillHistogram(Form("%d%dESD_Background_Mass",zbin,mbin), massBG);
2616 fHistograms->FillHistogram(Form("%d%dESD_Background_R",zbin,mbin), spaceVectorbackgroundCandidate.Pt()); // Pt in Space == R!!!!
2617 fHistograms->FillHistogram(Form("%d%dESD_Background_ZR",zbin,mbin), backgroundCandidate->GetZ(), spaceVectorbackgroundCandidate.Pt());
2618 fHistograms->FillHistogram(Form("%d%dESD_Background_XY",zbin,mbin), backgroundCandidate->GetX(), backgroundCandidate->GetY());
2619 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_vs_Pt",zbin,mbin),massBG,momentumVectorbackgroundCandidate.Pt());
2620 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass",zbin,mbin),massBG);
2622 if ( TMath::Abs(currentEventGoodV0.GetEta())<0.9 && TMath::Abs(currentEventGoodV02.GetEta())<0.9 ){
2623 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_vs_Pt_Fiducial",zbin,mbin),massBG,momentumVectorbackgroundCandidate.Pt());
2624 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_Fiducial",zbin,mbin),massBG);
2628 fHistograms->FillHistogram("ESD_Background_InvMass_vs_E_alpha",massBG ,backgroundCandidate->GetE());
2633 delete backgroundCandidate;
2639 else{ // means no rotation
2640 AliGammaConversionBGHandler::GammaConversionVertex *bgEventVertex = NULL;
2642 if(fUseTrackMultiplicityForBG){
2643 // cout<<"Using charged track multiplicity for background calculation"<<endl;
2644 for(Int_t nEventsInBG=0;nEventsInBG <fV0Reader->GetNBGEvents();nEventsInBG++){
2646 AliGammaConversionKFVector * previousEventV0s = bgHandler->GetBGGoodV0s(zbin,mbin,nEventsInBG);//fV0Reader->GetBGGoodV0s(nEventsInBG);
2648 if(fMoveParticleAccordingToVertex == kTRUE){
2649 bgEventVertex = bgHandler->GetBGEventVertex(zbin,mbin,nEventsInBG);
2652 for(Int_t iCurrent=0;iCurrent<currentEventV0s->GetEntriesFast();iCurrent++){
2653 AliKFParticle currentEventGoodV0 = *(AliKFParticle *)(currentEventV0s->At(iCurrent));
2654 for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
2655 AliKFParticle previousGoodV0 = (AliKFParticle)(*(previousEventV0s->at(iPrevious)));
2656 AliKFParticle previousGoodV0test = (AliKFParticle)(*(previousEventV0s->at(iPrevious)));
2658 //cout<<"Primary Vertex event: ["<<fESDEvent->GetPrimaryVertex()->GetX()<<","<<fESDEvent->GetPrimaryVertex()->GetY()<<","<<fESDEvent->GetPrimaryVertex()->GetZ()<<"]"<<endl;
2659 //cout<<"BG prim Vertex event: ["<<bgEventVertex->fX<<","<<bgEventVertex->fY<<","<<bgEventVertex->fZ<<"]"<<endl;
2661 //cout<<"XYZ of particle before transport: ["<<previousGoodV0.X()<<","<<previousGoodV0.Y()<<","<<previousGoodV0.Z()<<"]"<<endl;
2662 if(fMoveParticleAccordingToVertex == kTRUE){
2663 MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
2665 //cout<<"XYZ of particle after transport: ["<<previousGoodV0.X()<<","<<previousGoodV0.Y()<<","<<previousGoodV0.Z()<<"]"<<endl;
2667 AliKFParticle *backgroundCandidate = new AliKFParticle(currentEventGoodV0,previousGoodV0);
2669 Double_t massBG =0.;
2670 Double_t widthBG = 0.;
2671 Double_t chi2BG =10000.;
2672 backgroundCandidate->GetMass(massBG,widthBG);
2673 // if(backgroundCandidate->GetNDF()>0){
2674 // chi2BG = backgroundCandidate->GetChi2()/backgroundCandidate->GetNDF();
2675 chi2BG = backgroundCandidate->GetChi2();
2676 if((chi2BG>0 && chi2BG<fV0Reader->GetChi2CutMeson()) || fApplyChi2Cut == kFALSE){
2678 TVector3 momentumVectorbackgroundCandidate(backgroundCandidate->GetPx(),backgroundCandidate->GetPy(),backgroundCandidate->GetPz());
2679 TVector3 spaceVectorbackgroundCandidate(backgroundCandidate->GetX(),backgroundCandidate->GetY(),backgroundCandidate->GetZ());
2681 Double_t openingAngleBG = currentEventGoodV0.GetAngle(previousGoodV0);
2685 if(backgroundCandidate->GetE() - backgroundCandidate->GetPz() <= 0 || backgroundCandidate->GetE() + backgroundCandidate->GetPz() <= 0){
2686 cout << "Error: |Pz| > E !!!! " << endl;
2689 rapidity = 0.5*(TMath::Log((backgroundCandidate->GetE() +backgroundCandidate->GetPz()) / (backgroundCandidate->GetE()-backgroundCandidate->GetPz())));
2691 if(TMath::Abs(rapidity) > fV0Reader->GetRapidityMesonCut() ){
2692 delete backgroundCandidate;
2693 continue; // rapidity cut
2698 if( (currentEventGoodV0.GetE()+previousGoodV0.GetE()) != 0){
2699 alfa=TMath::Abs((currentEventGoodV0.GetE()-previousGoodV0.GetE())
2700 /(currentEventGoodV0.GetE()+previousGoodV0.GetE()));
2704 if(openingAngleBG < fMinOpeningAngleGhostCut ){
2705 delete backgroundCandidate;
2706 continue; // minimum opening angle to avoid using ghosttracks
2710 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
2711 fHistograms->FillHistogram("ESD_Background_GammaDaughter_OpeningAngle", openingAngleBG);
2712 fHistograms->FillHistogram("ESD_Background_Energy", backgroundCandidate->GetE());
2713 fHistograms->FillHistogram("ESD_Background_Pt", momentumVectorbackgroundCandidate.Pt());
2714 fHistograms->FillHistogram("ESD_Background_Eta", momentumVectorbackgroundCandidate.Eta());
2715 fHistograms->FillHistogram("ESD_Background_Rapidity", rapidity);
2716 fHistograms->FillHistogram("ESD_Background_Phi", spaceVectorbackgroundCandidate.Phi());
2717 fHistograms->FillHistogram("ESD_Background_Mass", massBG);
2718 fHistograms->FillHistogram("ESD_Background_R", spaceVectorbackgroundCandidate.Pt()); // Pt in Space == R!!!!
2719 fHistograms->FillHistogram("ESD_Background_ZR", backgroundCandidate->GetZ(), spaceVectorbackgroundCandidate.Pt());
2720 fHistograms->FillHistogram("ESD_Background_XY", backgroundCandidate->GetX(), backgroundCandidate->GetY());
2721 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt",massBG,momentumVectorbackgroundCandidate.Pt());
2722 fHistograms->FillHistogram("ESD_Background_InvMass",massBG);
2723 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt_alpha",massBG,momentumVectorbackgroundCandidate.Pt());
2726 if ( TMath::Abs(currentEventGoodV0.GetEta())<0.9 && TMath::Abs(previousGoodV0.GetEta())<0.9 ){
2727 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt_Fiducial",massBG,momentumVectorbackgroundCandidate.Pt());
2728 fHistograms->FillHistogram("ESD_Background_InvMass_Fiducial",massBG);
2732 fHistograms->FillHistogram(Form("%d%dESD_Background_GammaDaughter_OpeningAngle",zbin,mbin), openingAngleBG);
2733 fHistograms->FillHistogram(Form("%d%dESD_Background_Energy",zbin,mbin), backgroundCandidate->GetE());
2734 fHistograms->FillHistogram(Form("%d%dESD_Background_Pt",zbin,mbin), momentumVectorbackgroundCandidate.Pt());
2735 fHistograms->FillHistogram(Form("%d%dESD_Background_Eta",zbin,mbin), momentumVectorbackgroundCandidate.Eta());
2736 fHistograms->FillHistogram(Form("%d%dESD_Background_Rapidity",zbin,mbin), rapidity);
2737 fHistograms->FillHistogram(Form("%d%dESD_Background_Phi",zbin,mbin), spaceVectorbackgroundCandidate.Phi());
2738 fHistograms->FillHistogram(Form("%d%dESD_Background_Mass",zbin,mbin), massBG);
2739 fHistograms->FillHistogram(Form("%d%dESD_Background_R",zbin,mbin), spaceVectorbackgroundCandidate.Pt()); // Pt in Space == R!!!!
2740 fHistograms->FillHistogram(Form("%d%dESD_Background_ZR",zbin,mbin), backgroundCandidate->GetZ(), spaceVectorbackgroundCandidate.Pt());
2741 fHistograms->FillHistogram(Form("%d%dESD_Background_XY",zbin,mbin), backgroundCandidate->GetX(), backgroundCandidate->GetY());
2742 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_vs_Pt",zbin,mbin),massBG,momentumVectorbackgroundCandidate.Pt());
2743 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass",zbin,mbin),massBG);
2745 if ( TMath::Abs(currentEventGoodV0.GetEta())<0.9 && TMath::Abs(previousGoodV0.GetEta())<0.9 ){
2746 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_vs_Pt_Fiducial",zbin,mbin),massBG,momentumVectorbackgroundCandidate.Pt());
2747 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_Fiducial",zbin,mbin),massBG);
2752 fHistograms->FillHistogram("ESD_Background_InvMass_vs_E_alpha",massBG ,backgroundCandidate->GetE());
2756 delete backgroundCandidate;
2761 else{ // means using #V0s for multiplicity
2763 // cout<<"Using the v0 multiplicity to calculate background"<<endl;
2765 fHistograms->FillHistogram("ESD_Background_z_m",zbin,mbin);
2766 fHistograms->FillHistogram("ESD_Mother_multpilicityVSv0s",fV0Reader->CountESDTracks(),fV0Reader->GetNumberOfV0s());
2768 for(Int_t nEventsInBG=0;nEventsInBG <fV0Reader->GetNBGEvents();nEventsInBG++){
2769 AliGammaConversionKFVector * previousEventV0s = bgHandler->GetBGGoodV0s(zbin,mbin,nEventsInBG);// fV0Reader->GetBGGoodV0s(nEventsInBG);
2770 if(previousEventV0s){
2772 if(fMoveParticleAccordingToVertex == kTRUE){
2773 bgEventVertex = bgHandler->GetBGEventVertex(zbin,mbin,nEventsInBG);
2776 for(Int_t iCurrent=0;iCurrent<currentEventV0s->GetEntriesFast();iCurrent++){
2777 AliKFParticle currentEventGoodV0 = *(AliKFParticle *)(currentEventV0s->At(iCurrent));
2778 for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
2779 AliKFParticle previousGoodV0 = (AliKFParticle)(*(previousEventV0s->at(iPrevious)));
2781 if(fMoveParticleAccordingToVertex == kTRUE){
2782 MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
2785 AliKFParticle *backgroundCandidate = new AliKFParticle(currentEventGoodV0,previousGoodV0);
2786 Double_t massBG =0.;
2787 Double_t widthBG = 0.;
2788 Double_t chi2BG =10000.;
2789 backgroundCandidate->GetMass(massBG,widthBG);
2790 /* if(backgroundCandidate->GetNDF()>0){
2791 chi2BG = backgroundCandidate->GetChi2()/backgroundCandidate->GetNDF();
2792 {//remember to remove
2793 TVector3 momentumVectorbackgroundCandidate(backgroundCandidate->GetPx(),backgroundCandidate->GetPy(),backgroundCandidate->GetPz());
2794 TVector3 spaceVectorbackgroundCandidate(backgroundCandidate->GetX(),backgroundCandidate->GetY(),backgroundCandidate->GetZ());
2796 Double_t openingAngleBG = currentEventGoodV0.GetAngle(previousGoodV0);
2797 fHistograms->FillHistogram("ESD_Background_GammaDaughter_OpeningAngle_nochi2", openingAngleBG);
2800 chi2BG = backgroundCandidate->GetChi2();
2801 if((chi2BG>0 && chi2BG<fV0Reader->GetChi2CutMeson()) || fApplyChi2Cut == kFALSE){
2802 TVector3 momentumVectorbackgroundCandidate(backgroundCandidate->GetPx(),backgroundCandidate->GetPy(),backgroundCandidate->GetPz());
2803 TVector3 spaceVectorbackgroundCandidate(backgroundCandidate->GetX(),backgroundCandidate->GetY(),backgroundCandidate->GetZ());
2805 Double_t openingAngleBG = currentEventGoodV0.GetAngle(previousGoodV0);
2808 if(backgroundCandidate->GetE() - backgroundCandidate->GetPz() == 0 || backgroundCandidate->GetE() + backgroundCandidate->GetPz() == 0) rapidity=0;
2809 else rapidity = 0.5*(TMath::Log((backgroundCandidate->GetE() +backgroundCandidate->GetPz()) / (backgroundCandidate->GetE()-backgroundCandidate->GetPz())));
2811 if(TMath::Abs(rapidity) > fV0Reader->GetRapidityMesonCut() ){
2812 delete backgroundCandidate;
2813 continue; // rapidity cut
2818 if( (currentEventGoodV0.GetE()+previousGoodV0.GetE()) != 0){
2819 alfa=TMath::Abs((currentEventGoodV0.GetE()-previousGoodV0.GetE())
2820 /(currentEventGoodV0.GetE()+previousGoodV0.GetE()));
2824 if(openingAngleBG < fMinOpeningAngleGhostCut ){
2825 delete backgroundCandidate;
2826 continue; // minimum opening angle to avoid using ghosttracks
2829 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
2830 fHistograms->FillHistogram("ESD_Background_GammaDaughter_OpeningAngle", openingAngleBG);
2831 fHistograms->FillHistogram("ESD_Background_Energy", backgroundCandidate->GetE());
2832 fHistograms->FillHistogram("ESD_Background_Pt", momentumVectorbackgroundCandidate.Pt());
2833 fHistograms->FillHistogram("ESD_Background_Eta", momentumVectorbackgroundCandidate.Eta());
2834 fHistograms->FillHistogram("ESD_Background_Rapidity", rapidity);
2835 fHistograms->FillHistogram("ESD_Background_Phi", spaceVectorbackgroundCandidate.Phi());
2836 fHistograms->FillHistogram("ESD_Background_Mass", massBG);
2837 fHistograms->FillHistogram("ESD_Background_R", spaceVectorbackgroundCandidate.Pt()); // Pt in Space == R!!!!
2838 fHistograms->FillHistogram("ESD_Background_ZR", backgroundCandidate->GetZ(), spaceVectorbackgroundCandidate.Pt());
2839 fHistograms->FillHistogram("ESD_Background_XY", backgroundCandidate->GetX(), backgroundCandidate->GetY());
2840 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt",massBG,momentumVectorbackgroundCandidate.Pt());
2841 fHistograms->FillHistogram("ESD_Background_InvMass",massBG);
2844 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt_alpha",massBG,momentumVectorbackgroundCandidate.Pt());
2847 if ( TMath::Abs(currentEventGoodV0.GetEta())<0.9 && TMath::Abs(previousGoodV0.GetEta())<0.9 ){
2848 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt_Fiducial",massBG,momentumVectorbackgroundCandidate.Pt());
2849 fHistograms->FillHistogram("ESD_Background_InvMass_Fiducial",massBG);
2852 if(massBG>0.5 && massBG<0.6){
2853 fHistograms->FillHistogram("ESD_Background_alfa_pt0506",momentumVectorbackgroundCandidate.Pt(),alfa);
2855 if(massBG>0.3 && massBG<0.4){
2856 fHistograms->FillHistogram("ESD_Background_alfa_pt0304",momentumVectorbackgroundCandidate.Pt(),alfa);
2860 fHistograms->FillHistogram(Form("%d%dESD_Background_GammaDaughter_OpeningAngle",zbin,mbin), openingAngleBG);
2861 fHistograms->FillHistogram(Form("%d%dESD_Background_Energy",zbin,mbin), backgroundCandidate->GetE());
2862 fHistograms->FillHistogram(Form("%d%dESD_Background_Pt",zbin,mbin), momentumVectorbackgroundCandidate.Pt());
2863 fHistograms->FillHistogram(Form("%d%dESD_Background_Eta",zbin,mbin), momentumVectorbackgroundCandidate.Eta());
2864 fHistograms->FillHistogram(Form("%d%dESD_Background_Rapidity",zbin,mbin), rapidity);
2865 fHistograms->FillHistogram(Form("%d%dESD_Background_Phi",zbin,mbin), spaceVectorbackgroundCandidate.Phi());
2866 fHistograms->FillHistogram(Form("%d%dESD_Background_Mass",zbin,mbin), massBG);
2867 fHistograms->FillHistogram(Form("%d%dESD_Background_R",zbin,mbin), spaceVectorbackgroundCandidate.Pt()); // Pt in Space == R!!!!
2868 fHistograms->FillHistogram(Form("%d%dESD_Background_ZR",zbin,mbin), backgroundCandidate->GetZ(), spaceVectorbackgroundCandidate.Pt());
2869 fHistograms->FillHistogram(Form("%d%dESD_Background_XY",zbin,mbin), backgroundCandidate->GetX(), backgroundCandidate->GetY());
2870 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_vs_Pt",zbin,mbin),massBG,momentumVectorbackgroundCandidate.Pt());
2871 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass",zbin,mbin),massBG);
2873 if ( TMath::Abs(currentEventGoodV0.GetEta())<0.9 && TMath::Abs(previousGoodV0.GetEta())<0.9 ){
2874 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_vs_Pt_Fiducial",zbin,mbin),massBG,momentumVectorbackgroundCandidate.Pt());
2875 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_Fiducial",zbin,mbin),massBG);
2880 fHistograms->FillHistogram("ESD_Background_InvMass_vs_E_alpha",massBG ,backgroundCandidate->GetE());
2884 delete backgroundCandidate;
2889 } // end else (means use #v0s as multiplicity)
2890 } // end no rotation
2894 void AliAnalysisTaskGammaConversion::ProcessGammasForGammaJetAnalysis(){
2895 //ProcessGammasForGammaJetAnalysis
2897 Double_t distIsoMin;
2899 CreateListOfChargedParticles();
2902 // for(UInt_t gammaIndex=0;gammaIndex<fKFReconstructedGammas.size();gammaIndex++){
2903 for(Int_t gammaIndex=0;gammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();gammaIndex++){
2904 AliKFParticle * currentGamma = (AliKFParticle*)fKFReconstructedGammasTClone->At(gammaIndex);
2905 TVector3 momentumVectorCurrentGamma(currentGamma->GetPx(),currentGamma->GetPy(),currentGamma->GetPz());
2907 if( momentumVectorCurrentGamma.Pt()> fMinPtForGammaJet){
2908 distIsoMin=GetMinimumDistanceToCharge(gammaIndex);
2910 if (distIsoMin > fMinIsoConeSize && fLeadingChargedIndex>=0){
2911 CalculateJetCone(gammaIndex);
2917 //____________________________________________________________________
2918 Bool_t AliAnalysisTaskGammaConversion::IsGoodImpPar(const AliESDtrack *const track)
2921 // check whether particle has good DCAr(Pt) impact
2922 // parameter. Only for TPC+ITS tracks (7*sigma cut)
2923 // Origin: Andrea Dainese
2926 Float_t d0z0[2],covd0z0[3];
2927 track->GetImpactParameters(d0z0,covd0z0);
2928 Float_t sigma= 0.0050+0.0060/TMath::Power(track->Pt(),0.9);
2929 Float_t d0max = 7.*sigma;
2930 if(TMath::Abs(d0z0[0]) < d0max) return kTRUE;
2936 void AliAnalysisTaskGammaConversion::CreateListOfChargedParticles(){
2937 // CreateListOfChargedParticles
2939 fESDEvent = fV0Reader->GetESDEvent();
2940 Int_t numberOfESDTracks=0;
2941 for(Int_t iTracks = 0; iTracks < fESDEvent->GetNumberOfTracks(); iTracks++){
2942 AliESDtrack* curTrack = fESDEvent->GetTrack(iTracks);
2947 // Not needed if Standard function used.
2948 // if(!IsGoodImpPar(curTrack)){
2952 if(fEsdTrackCuts->AcceptTrack(curTrack) ){
2953 new((*fChargedParticles)[fChargedParticles->GetEntriesFast()]) AliESDtrack(*curTrack);
2954 // fChargedParticles.push_back(curTrack);
2955 fChargedParticlesId.push_back(iTracks);
2956 numberOfESDTracks++;
2959 // Moved to UserExec using CountAcceptedTracks function. runjet is not needed by default
2960 // fHistograms->FillHistogram("ESD_NumberOfGoodESDTracks",numberOfESDTracks);
2961 // cout<<"esdtracks::"<< numberOfESDTracks<<endl;
2962 // if (fV0Reader->GetNumberOfContributorsVtx()>=1){
2963 // fHistograms->FillHistogram("ESD_NumberOfGoodESDTracksVtx",numberOfESDTracks);
2966 void AliAnalysisTaskGammaConversion::RecalculateV0ForGamma(){
2967 //recalculates v0 for gamma
2969 Double_t massE=0.00051099892;
2970 TLorentzVector curElecPos;
2971 TLorentzVector curElecNeg;
2972 TLorentzVector curGamma;
2974 TLorentzVector curGammaAt;
2975 TLorentzVector curElecPosAt;
2976 TLorentzVector curElecNegAt;
2977 AliKFVertex primVtxGamma(*(fESDEvent->GetPrimaryVertex()));
2978 AliKFVertex primVtxImprovedGamma = primVtxGamma;
2980 const AliESDVertex *vtxT3D=fESDEvent->GetPrimaryVertex();
2982 Double_t xPrimaryVertex=vtxT3D->GetXv();
2983 Double_t yPrimaryVertex=vtxT3D->GetYv();
2984 Double_t zPrimaryVertex=vtxT3D->GetZv();
2985 // Float_t primvertex[3]={xPrimaryVertex,yPrimaryVertex,zPrimaryVertex};
2987 Float_t nsigmaTPCtrackPos;
2988 Float_t nsigmaTPCtrackNeg;
2989 Float_t nsigmaTPCtrackPosToPion;
2990 Float_t nsigmaTPCtrackNegToPion;
2991 AliKFParticle* negKF=NULL;
2992 AliKFParticle* posKF=NULL;
2994 for(Int_t iTracks = 0; iTracks < fESDEvent->GetNumberOfTracks(); iTracks++){
2995 AliESDtrack* posTrack = fESDEvent->GetTrack(iTracks);
2999 if (posKF) delete posKF; posKF=NULL;
3000 if(posTrack->GetSign()<0) continue;
3001 if(!(posTrack->GetStatus() & AliESDtrack::kTPCrefit))continue;
3002 if(posTrack->GetKinkIndex(0)>0 ) continue;
3003 if(posTrack->GetNcls(1)<50)continue;
3005 // posTrack->GetConstrainedPxPyPz(momPos);
3006 posTrack->GetPxPyPz(momPos);
3007 AliESDtrack *ptrk=fESDEvent->GetTrack(iTracks);
3008 curElecPos.SetXYZM(momPos[0],momPos[1],momPos[2],massE);
3009 if(TMath::Abs(curElecPos.Eta())<0.9) continue;
3010 posKF = new AliKFParticle( *(posTrack),-11);
3012 nsigmaTPCtrackPos = fV0Reader->GetESDpid()->NumberOfSigmasTPC(posTrack,AliPID::kElectron);
3013 nsigmaTPCtrackPosToPion = fV0Reader->GetESDpid()->NumberOfSigmasTPC(posTrack,AliPID::kPion);
3015 if ( nsigmaTPCtrackPos>5.|| nsigmaTPCtrackPos<-2.){
3019 if(pow((momPos[0]*momPos[0]+momPos[1]*momPos[1]+momPos[2]*momPos[2]),0.5)>0.5 && nsigmaTPCtrackPosToPion<1){
3025 for(Int_t jTracks = 0; jTracks < fESDEvent->GetNumberOfTracks(); jTracks++){
3026 AliESDtrack* negTrack = fESDEvent->GetTrack(jTracks);
3030 if (negKF) delete negKF; negKF=NULL;
3031 if(negTrack->GetSign()>0) continue;
3032 if(!(negTrack->GetStatus() & AliESDtrack::kTPCrefit))continue;
3033 if(negTrack->GetKinkIndex(0)>0 ) continue;
3034 if(negTrack->GetNcls(1)<50)continue;
3036 // negTrack->GetConstrainedPxPyPz(momNeg);
3037 negTrack->GetPxPyPz(momNeg);
3039 nsigmaTPCtrackNeg = fV0Reader->GetESDpid()->NumberOfSigmasTPC(negTrack,AliPID::kElectron);
3040 nsigmaTPCtrackNegToPion = fV0Reader->GetESDpid()->NumberOfSigmasTPC(negTrack,AliPID::kPion);
3041 if ( nsigmaTPCtrackNeg>5. || nsigmaTPCtrackNeg<-2.){
3044 if(pow((momNeg[0]*momNeg[0]+momNeg[1]*momNeg[1]+momNeg[2]*momNeg[2]),0.5)>0.5 && nsigmaTPCtrackNegToPion<1){
3047 AliESDtrack *ntrk=fESDEvent->GetTrack(jTracks);
3048 curElecNeg.SetXYZM(momNeg[0],momNeg[1],momNeg[2],massE);
3049 if(TMath::Abs(curElecNeg.Eta())<0.9) continue;
3050 negKF = new AliKFParticle( *(negTrack) ,11);
3052 Double_t b=fESDEvent->GetMagneticField();
3053 Double_t xn, xp, dca=ntrk->GetDCA(ptrk,b,xn,xp);
3054 AliExternalTrackParam nt(*ntrk), pt(*ptrk);
3055 nt.PropagateTo(xn,b); pt.PropagateTo(xp,b);
3058 //--- Like in ITSV0Finder
3059 AliExternalTrackParam ntAt0(*ntrk), ptAt0(*ptrk);
3060 Double_t xxP,yyP,alphaP;
3063 // if (!ptAt0.GetGlobalXYZat(ptAt0->GetX(),xxP,yyP,zzP)) continue;
3064 if (!ptAt0.GetXYZAt(ptAt0.GetX(),b,rP)) continue;
3067 alphaP = TMath::ATan2(yyP,xxP);
3070 ptAt0.Propagate(alphaP,0,b);
3071 Float_t ptfacP = (1.+100.*TMath::Abs(ptAt0.GetC(b)));
3073 // Double_t distP = ptAt0.GetY();
3074 Double_t normP = ptfacP*TMath::Sqrt(ptAt0.GetSigmaY2());
3075 Double_t normdist0P = TMath::Abs(ptAt0.GetY()/normP);
3076 Double_t normdist1P = TMath::Abs((ptAt0.GetZ()-zPrimaryVertex)/(ptfacP*TMath::Sqrt(ptAt0.GetSigmaZ2())));
3077 Double_t normdistP = TMath::Sqrt(normdist0P*normdist0P+normdist1P*normdist1P);
3080 Double_t xxN,yyN,alphaN;
3082 // if (!ntAt0.GetGlobalXYZat(ntAt0->GetX(),xxN,yyN,zzN)) continue;
3083 if (!ntAt0.GetXYZAt(ntAt0.GetX(),b,rN)) continue;
3087 alphaN = TMath::ATan2(yyN,xxN);
3089 ntAt0.Propagate(alphaN,0,b);
3091 Float_t ptfacN = (1.+100.*TMath::Abs(ntAt0.GetC(b)));
3092 // Double_t distN = ntAt0.GetY();
3093 Double_t normN = ptfacN*TMath::Sqrt(ntAt0.GetSigmaY2());
3094 Double_t normdist0N = TMath::Abs(ntAt0.GetY()/normN);
3095 Double_t normdist1N = TMath::Abs((ntAt0.GetZ()-zPrimaryVertex)/(ptfacN*TMath::Sqrt(ntAt0.GetSigmaZ2())));
3096 Double_t normdistN = TMath::Sqrt(normdist0N*normdist0N+normdist1N*normdist1N);
3098 //-----------------------------
3100 Double_t momNegAt[3];
3101 nt.GetPxPyPz(momNegAt);
3102 curElecNegAt.SetXYZM(momNegAt[0],momNegAt[1],momNegAt[2],massE);
3104 Double_t momPosAt[3];
3105 pt.GetPxPyPz(momPosAt);
3106 curElecPosAt.SetXYZM(momPosAt[0],momPosAt[1],momPosAt[2],massE);
3111 // Double_t dneg= negTrack->GetD(xPrimaryVertex,yPrimaryVertex,b);
3112 // Double_t dpos= posTrack->GetD(xPrimaryVertex,yPrimaryVertex,b);
3113 AliESDv0 vertex(nt,jTracks,pt,iTracks);
3116 Float_t cpa=vertex.GetV0CosineOfPointingAngle(xPrimaryVertex,yPrimaryVertex,zPrimaryVertex);
3120 // cout<< "v0Rr::"<< v0Rr<<endl;
3121 // if (pvertex.GetRr()<0.5){
3124 // cout<<"vertex.GetChi2V0()"<<vertex.GetChi2V0()<<endl;
3125 if(cpa<0.9)continue;
3126 // if (vertex.GetChi2V0() > 30) continue;
3127 // cout<<"xp+xn::"<<xp<<" "<<xn<<endl;
3128 if ((xn+xp) < 0.4) continue;
3129 if (TMath::Abs(ntrk->GetD(xPrimaryVertex,yPrimaryVertex,b))<0.05)
3130 if (TMath::Abs(ptrk->GetD(xPrimaryVertex,yPrimaryVertex,b))<0.05) continue;
3132 //cout<<"pass"<<endl;
3134 AliKFParticle v0GammaC;
3137 v0GammaC.SetMassConstraint(0,0.001);
3138 primVtxImprovedGamma+=v0GammaC;
3139 v0GammaC.SetProductionVertex(primVtxImprovedGamma);
3142 curGamma=curElecNeg+curElecPos;
3143 curGammaAt=curElecNegAt+curElecPosAt;
3145 // invariant mass versus pt of K0short
3147 Double_t chi2V0GammaC=100000.;
3148 if( v0GammaC.GetNDF() != 0) {
3149 chi2V0GammaC = v0GammaC.GetChi2()/v0GammaC.GetNDF();
3151 cout<< "ERROR::v0K0C.GetNDF()" << endl;
3154 if(chi2V0GammaC<200 &&chi2V0GammaC>0 ){
3155 if(fHistograms != NULL){
3156 fHistograms->FillHistogram("ESD_RecalculateV0_InvMass",v0GammaC.GetMass());
3157 fHistograms->FillHistogram("ESD_RecalculateV0_Pt",v0GammaC.GetPt());
3158 fHistograms->FillHistogram("ESD_RecalculateV0_E_dEdxP",curElecNegAt.P(),negTrack->GetTPCsignal());
3159 fHistograms->FillHistogram("ESD_RecalculateV0_P_dEdxP",curElecPosAt.P(),posTrack->GetTPCsignal());
3160 fHistograms->FillHistogram("ESD_RecalculateV0_cpa",cpa);
3161 fHistograms->FillHistogram("ESD_RecalculateV0_dca",dca);
3162 fHistograms->FillHistogram("ESD_RecalculateV0_normdistP",normdistP);
3163 fHistograms->FillHistogram("ESD_RecalculateV0_normdistN",normdistN);
3165 new((*fKFRecalculatedGammasTClone)[fKFRecalculatedGammasTClone->GetEntriesFast()]) AliKFParticle(v0GammaC);
3166 fElectronRecalculatedv1.push_back(iTracks);
3167 fElectronRecalculatedv2.push_back(jTracks);
3173 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFRecalculatedGammasTClone->GetEntriesFast();firstGammaIndex++){
3174 for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fKFRecalculatedGammasTClone->GetEntriesFast();secondGammaIndex++){
3175 AliKFParticle * twoGammaDecayCandidateDaughter0 = (AliKFParticle *)fKFRecalculatedGammasTClone->At(firstGammaIndex);
3176 AliKFParticle * twoGammaDecayCandidateDaughter1 = (AliKFParticle *)fKFRecalculatedGammasTClone->At(secondGammaIndex);
3178 if(fElectronRecalculatedv1[firstGammaIndex]==fElectronRecalculatedv1[secondGammaIndex]){
3181 if( fElectronRecalculatedv2[firstGammaIndex]==fElectronRecalculatedv2[secondGammaIndex]){
3185 AliKFParticle twoGammaCandidate(*twoGammaDecayCandidateDaughter0,*twoGammaDecayCandidateDaughter1);
3186 fHistograms->FillHistogram("ESD_RecalculateGG_InvMass",twoGammaCandidate.GetMass());
3187 fHistograms->FillHistogram("ESD_RecalculateGG_InvMass_vs_Pt",twoGammaCandidate.GetMass(),twoGammaCandidate.GetPt());
3191 void AliAnalysisTaskGammaConversion::CalculateJetCone(Int_t gammaIndex){
3195 Double_t coneSize=0.3;
3198 // AliKFParticle * currentGamma = &fKFReconstructedGammas[gammaIndex];
3199 AliKFParticle * currentGamma = (AliKFParticle*)fKFReconstructedGammasTClone->At(gammaIndex);
3201 TVector3 momentumVectorCurrentGamma(currentGamma->GetPx(),currentGamma->GetPy(),currentGamma->GetPz());
3203 AliESDtrack* leadingCharged = (AliESDtrack*)(fChargedParticles->At(fLeadingChargedIndex));
3205 Double_t momLeadingCharged[3];
3206 leadingCharged->GetConstrainedPxPyPz(momLeadingCharged);
3208 TVector3 momentumVectorLeadingCharged(momLeadingCharged[0],momLeadingCharged[1],momLeadingCharged[2]);
3210 Double_t phi1=momentumVectorLeadingCharged.Phi();
3211 Double_t eta1=momentumVectorLeadingCharged.Eta();
3212 Double_t phi3=momentumVectorCurrentGamma.Phi();
3214 for(Int_t iCh=0;iCh<fChargedParticles->GetEntriesFast();iCh++){
3215 AliESDtrack* curTrack = (AliESDtrack*)(fChargedParticles->At(iCh));
3216 Int_t chId = fChargedParticlesId[iCh];
3217 if(fLeadingChargedIndex==chId || fLeadingChargedIndex==chId) continue;
3219 curTrack->GetConstrainedPxPyPz(mom);
3220 TVector3 momentumVectorChargedParticle(mom[0],mom[1],mom[2]);
3221 Double_t phi2=momentumVectorChargedParticle.Phi();
3222 Double_t eta2=momentumVectorChargedParticle.Eta();
3226 if( TMath::Abs(phi2 - phi1) <= ( TMath::TwoPi()-coneSize) ){
3227 cone = TMath::Sqrt( TMath::Power((eta2-eta1),2)+ TMath::Power((phi2-phi1),2) );
3229 if( (phi2 - phi1)> TMath::TwoPi()-coneSize ){
3230 cone = TMath::Sqrt( TMath::Power((eta2-eta1),2)+ TMath::Power((phi2-TMath::TwoPi()-phi1),2) );
3232 if( (phi2 - phi1)< -(TMath::TwoPi()-coneSize) ){
3233 cone = TMath::Sqrt( TMath::Power((eta2-eta1),2)+ TMath::Power((phi2+TMath::TwoPi()-phi1),2) );
3237 if(cone <coneSize&& momentumVectorChargedParticle.Pt()>fMinPtJetCone ){
3238 ptJet+= momentumVectorChargedParticle.Pt();
3239 Double_t ffzHdrGam = momentumVectorChargedParticle.Pt()/momentumVectorCurrentGamma.Pt();
3240 Double_t imbalanceHdrGam=-momentumVectorChargedParticle.Dot(momentumVectorCurrentGamma)/momentumVectorCurrentGamma.Mag2();
3241 fHistograms->FillHistogram("ESD_FFzHdrGam",ffzHdrGam);
3242 fHistograms->FillHistogram("ESD_ImbalanceHdrGam",imbalanceHdrGam);
3246 Double_t dphiHdrGam=phi3-phi2;
3247 if ( dphiHdrGam < (-TMath::PiOver2())){
3248 dphiHdrGam+=(TMath::TwoPi());
3251 if ( dphiHdrGam > (3.*TMath::PiOver2()) ){
3252 dphiHdrGam-=(TMath::TwoPi());
3255 if (momentumVectorChargedParticle.Pt()>fMinPtGamChargedCorr){
3256 fHistograms->FillHistogram("ESD_dphiHdrGamIsolated",dphiHdrGam);
3263 Double_t AliAnalysisTaskGammaConversion::GetMinimumDistanceToCharge(Int_t indexHighestPtGamma){
3264 // GetMinimumDistanceToCharge
3266 Double_t fIsoMin=100.;
3267 Double_t ptLeadingCharged=-1.;
3269 fLeadingChargedIndex=-1;
3271 AliKFParticle * gammaHighestPt = (AliKFParticle*)fKFReconstructedGammasTClone->At(indexHighestPtGamma);
3272 TVector3 momentumVectorgammaHighestPt(gammaHighestPt->GetPx(),gammaHighestPt->GetPy(),gammaHighestPt->GetPz());
3274 Double_t phi1=momentumVectorgammaHighestPt.Phi();
3275 Double_t eta1=momentumVectorgammaHighestPt.Eta();
3277 for(Int_t iCh=0;iCh<fChargedParticles->GetEntriesFast();iCh++){
3278 AliESDtrack* curTrack = (AliESDtrack*)(fChargedParticles->At(iCh));
3279 Int_t chId = fChargedParticlesId[iCh];
3280 if(fElectronv1[indexHighestPtGamma]==chId || fElectronv2[indexHighestPtGamma]==chId) continue;
3282 curTrack->GetConstrainedPxPyPz(mom);
3283 TVector3 momentumVectorChargedParticle(mom[0],mom[1],mom[2]);
3284 Double_t phi2=momentumVectorChargedParticle.Phi();
3285 Double_t eta2=momentumVectorChargedParticle.Eta();
3286 Double_t iso=pow( (pow( (eta1-eta2),2)+ pow((phi1-phi2),2)),0.5 );
3288 if(momentumVectorChargedParticle.Pt()>fMinPtIsoCone ){
3294 Double_t dphiHdrGam=phi1-phi2;
3295 if ( dphiHdrGam < (-TMath::PiOver2())){
3296 dphiHdrGam+=(TMath::TwoPi());
3299 if ( dphiHdrGam > (3.*TMath::PiOver2()) ){
3300 dphiHdrGam-=(TMath::TwoPi());
3302 if (momentumVectorChargedParticle.Pt()>fMinPtGamChargedCorr){
3303 fHistograms->FillHistogram("ESD_dphiHdrGam",dphiHdrGam);
3306 if (dphiHdrGam>0.9*TMath::Pi() && dphiHdrGam<1.1*TMath::Pi()){
3307 if (momentumVectorChargedParticle.Pt()> ptLeadingCharged && momentumVectorChargedParticle.Pt()>0.1*momentumVectorgammaHighestPt.Pt()){
3308 ptLeadingCharged=momentumVectorChargedParticle.Pt();
3309 fLeadingChargedIndex=iCh;
3314 fHistograms->FillHistogram("ESD_MinimumIsoDistance",fIsoMin);
3319 Int_t AliAnalysisTaskGammaConversion::GetIndexHighestPtGamma(){
3320 //GetIndexHighestPtGamma
3322 Int_t indexHighestPtGamma=-1;
3324 fGammaPtHighest = -100.;
3326 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();firstGammaIndex++){
3327 AliKFParticle * gammaHighestPtCandidate = (AliKFParticle*)fKFReconstructedGammasTClone->At(firstGammaIndex);
3328 TVector3 momentumVectorgammaHighestPtCandidate(gammaHighestPtCandidate->GetPx(),gammaHighestPtCandidate->GetPy(),gammaHighestPtCandidate->GetPz());
3329 if (momentumVectorgammaHighestPtCandidate.Pt() > fGammaPtHighest){
3330 fGammaPtHighest=momentumVectorgammaHighestPtCandidate.Pt();
3331 //gammaHighestPt = gammaHighestPtCandidate;
3332 indexHighestPtGamma=firstGammaIndex;
3336 return indexHighestPtGamma;
3341 void AliAnalysisTaskGammaConversion::Terminate(Option_t */*option*/)
3343 // Terminate analysis
3345 AliDebug(1,"Do nothing in Terminate");
3348 void AliAnalysisTaskGammaConversion::UserCreateOutputObjects()
3351 if(!fAODGamma) fAODGamma = new TClonesArray("AliGammaConversionAODObject", 0);
3352 else fAODGamma->Delete();
3353 fAODGamma->SetName(Form("%s_gamma", fAODBranchName.Data()));
3355 if(!fAODPi0) fAODPi0 = new TClonesArray("AliGammaConversionAODObject", 0);
3356 else fAODPi0->Delete();
3357 fAODPi0->SetName(Form("%s_Pi0", fAODBranchName.Data()));
3359 if(!fAODOmega) fAODOmega = new TClonesArray("AliGammaConversionAODObject", 0);
3360 else fAODOmega->Delete();
3361 fAODOmega->SetName(Form("%s_Omega", fAODBranchName.Data()));
3363 //If delta AOD file name set, add in separate file. Else add in standard aod file.
3364 if(fKFDeltaAODFileName.Length() > 0) {
3365 AddAODBranch("TClonesArray", &fAODGamma, fKFDeltaAODFileName.Data());
3366 AddAODBranch("TClonesArray", &fAODPi0, fKFDeltaAODFileName.Data());
3367 AddAODBranch("TClonesArray", &fAODOmega, fKFDeltaAODFileName.Data());
3368 AliAnalysisManager::GetAnalysisManager()->RegisterExtraFile(fKFDeltaAODFileName.Data());
3370 AddAODBranch("TClonesArray", &fAODGamma);
3371 AddAODBranch("TClonesArray", &fAODPi0);
3372 AddAODBranch("TClonesArray", &fAODOmega);
3375 // Create the output container
3376 if(fOutputContainer != NULL){
3377 delete fOutputContainer;
3378 fOutputContainer = NULL;
3380 if(fOutputContainer == NULL){
3381 fOutputContainer = new TList();
3382 fOutputContainer->SetOwner(kTRUE);
3385 //Adding the histograms to the output container
3386 fHistograms->GetOutputContainer(fOutputContainer);
3390 if(fGammaNtuple == NULL){
3391 fGammaNtuple = new TNtuple("V0ntuple","V0ntuple","OnTheFly:HasVertex:NegPIDProb:PosPIDProb:X:Y:Z:R:MotherCandidateNDF:MotherCandidateChi2:MotherCandidateEnergy:MotherCandidateEta:MotherCandidatePt:MotherCandidateMass:MotherCandidateWidth:MCMotherCandidatePT:EPOpeningAngle:ElectronEnergy:ElectronPt:ElectronEta:ElectronPhi:PositronEnergy:PositronPt:PositronEta:PositronPhi:HasSameMCMother:MotherMCParticlePIDCode",50000);
3393 if(fNeutralMesonNtuple == NULL){
3394 fNeutralMesonNtuple = new TNtuple("NeutralMesonNtuple","NeutralMesonNtuple","test");
3396 TList * ntupleTList = new TList();
3397 ntupleTList->SetOwner(kTRUE);
3398 ntupleTList->SetName("Ntuple");
3399 ntupleTList->Add((TNtuple*)fGammaNtuple);
3400 fOutputContainer->Add(ntupleTList);
3403 fOutputContainer->SetName(GetName());
3406 Double_t AliAnalysisTaskGammaConversion::GetMCOpeningAngle(const TParticle* const daughter0, const TParticle* const daughter1) const{
3408 TVector3 v3D0(daughter0->Px(),daughter0->Py(),daughter0->Pz());
3409 TVector3 v3D1(daughter1->Px(),daughter1->Py(),daughter1->Pz());
3410 return v3D0.Angle(v3D1);
3413 void AliAnalysisTaskGammaConversion::CheckV0Efficiency(){
3414 // see header file for documentation
3416 vector<Int_t> indexOfGammaParticle;
3418 fStack = fV0Reader->GetMCStack();
3420 if(fV0Reader->CheckForPrimaryVertex() == kFALSE){
3421 return; // aborts if the primary vertex does not have contributors.
3424 for (Int_t iTracks = 0; iTracks < fStack->GetNprimary(); iTracks++) {
3425 TParticle* particle = (TParticle *)fStack->Particle(iTracks);
3426 if(particle->GetPdgCode()==22){ //Gamma
3427 if(particle->GetNDaughters() >= 2){
3428 TParticle* electron=NULL;
3429 TParticle* positron=NULL;
3430 for(Int_t daughterIndex=particle->GetFirstDaughter();daughterIndex<=particle->GetLastDaughter();daughterIndex++){
3431 TParticle *tmpDaughter = fStack->Particle(daughterIndex);
3432 if(tmpDaughter->GetUniqueID() == 5){
3433 if(tmpDaughter->GetPdgCode() == 11){
3434 electron = tmpDaughter;
3436 else if(tmpDaughter->GetPdgCode() == -11){
3437 positron = tmpDaughter;
3441 if(electron!=NULL && positron!=0){
3442 if(electron->R()<160){
3443 indexOfGammaParticle.push_back(iTracks);
3450 Int_t nFoundGammas=0;
3451 Int_t nNotFoundGammas=0;
3453 Int_t numberOfV0s = fV0Reader->GetNumberOfV0s();
3454 for(Int_t i=0;i<numberOfV0s;i++){
3455 fV0Reader->GetV0(i);
3457 if(fV0Reader->HasSameMCMother() == kFALSE){
3461 TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
3462 TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
3464 if(TMath::Abs(negativeMC->GetPdgCode())!=11 || TMath::Abs(positiveMC->GetPdgCode())!=11){
3467 if(negativeMC->GetPdgCode()==positiveMC->GetPdgCode()){
3471 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
3472 //TParticle * v0Gamma = fV0Reader->GetMotherMCParticle();
3473 for(UInt_t mcIndex=0;mcIndex<indexOfGammaParticle.size();mcIndex++){
3474 if(negativeMC->GetFirstMother()==indexOfGammaParticle[mcIndex]){
3486 void AliAnalysisTaskGammaConversion::ProcessGammaElectronsForChicAnalysis(){
3487 // see header file for documantation
3489 fESDEvent = fV0Reader->GetESDEvent();
3492 TClonesArray * vESDeNegTemp = new TClonesArray("AliESDtrack",0);
3493 TClonesArray * vESDePosTemp = new TClonesArray("AliESDtrack",0);
3494 TClonesArray * vESDxNegTemp = new TClonesArray("AliESDtrack",0);
3495 TClonesArray * vESDxPosTemp = new TClonesArray("AliESDtrack",0);
3496 TClonesArray * vESDeNegNoJPsi = new TClonesArray("AliESDtrack",0);
3497 TClonesArray * vESDePosNoJPsi = new TClonesArray("AliESDtrack",0);
3500 vector <AliESDtrack*> vESDeNegTemp(0);
3501 vector <AliESDtrack*> vESDePosTemp(0);
3502 vector <AliESDtrack*> vESDxNegTemp(0);
3503 vector <AliESDtrack*> vESDxPosTemp(0);
3504 vector <AliESDtrack*> vESDeNegNoJPsi(0);
3505 vector <AliESDtrack*> vESDePosNoJPsi(0);
3509 fHistograms->FillTable("Table_Electrons",0);//Count number of Events
3511 for(Int_t iTracks = 0; iTracks < fESDEvent->GetNumberOfTracks(); iTracks++){
3512 AliESDtrack* curTrack = fESDEvent->GetTrack(iTracks);
3515 //print warning here
3519 double p[3];if(!curTrack->GetConstrainedPxPyPz(p))continue;
3520 double r[3];curTrack->GetConstrainedXYZ(r);
3524 fHistograms->FillTable("Table_Electrons",4);//Count number of ESD tracks
3526 Bool_t flagKink = kTRUE;
3527 Bool_t flagTPCrefit = kTRUE;
3528 Bool_t flagTRDrefit = kTRUE;
3529 Bool_t flagITSrefit = kTRUE;
3530 Bool_t flagTRDout = kTRUE;
3531 Bool_t flagVertex = kTRUE;
3534 //Cuts ---------------------------------------------------------------
3536 if(curTrack->GetKinkIndex(0) > 0){
3537 fHistograms->FillHistogram("Table_Electrons",5);//Count kink
3541 ULong_t trkStatus = curTrack->GetStatus();
3543 ULong_t tpcRefit = (trkStatus & AliESDtrack::kTPCrefit);
3546 fHistograms->FillHistogram("Table_Electrons",9);//Count not TPCrefit
3547 flagTPCrefit = kFALSE;
3550 ULong_t itsRefit = (trkStatus & AliESDtrack::kITSrefit);
3552 fHistograms->FillHistogram("Table_Electrons",10);//Count not ITSrefit
3553 flagITSrefit = kFALSE;
3556 ULong_t trdRefit = (trkStatus & AliESDtrack::kTRDrefit);
3559 fHistograms->FillHistogram("Table_Electrons",8); //Count not TRDrefit
3560 flagTRDrefit = kFALSE;
3563 ULong_t trdOut = (trkStatus & AliESDtrack::kTRDout);
3566 fHistograms->FillHistogram("Table_Electrons",7); //Count not TRDout
3567 flagTRDout = kFALSE;
3570 double nsigmaToVxt = GetSigmaToVertex(curTrack);
3572 if(nsigmaToVxt > 3){
3573 fHistograms->FillHistogram("Table_Electrons",6); //Count Tracks with number of sigmas > 3
3574 flagVertex = kFALSE;
3577 if(! (flagKink && flagTPCrefit && flagITSrefit && flagTRDrefit && flagTRDout && flagVertex ) ) continue;
3578 fHistograms->FillHistogram("Table_Electrons",11);//Count Tracks passed Cuts
3582 GetPID(curTrack, pid, weight);
3585 fHistograms->FillHistogram("Table_Electrons",12); //Count Tracks with pid != 0
3589 fHistograms->FillHistogram("Table_Electrons",13); //Count Tracks with pid != 0
3597 TLorentzVector curElec;
3598 curElec.SetXYZM(p[0],p[1],p[2],fElectronMass);
3602 Int_t labelMC = TMath::Abs(curTrack->GetLabel());
3603 TParticle* curParticle = fStack->Particle(labelMC);
3604 if(curTrack->GetSign() > 0){
3606 fHistograms->FillHistogram("MC_ElectronPosNegPt",curParticle->Pt());
3607 fHistograms->FillHistogram("MC_ElectronPosNegEta",curParticle->Eta());
3610 fHistograms->FillHistogram("MC_ElectronPosNegPt",curParticle->Pt());
3611 fHistograms->FillHistogram("MC_ElectronPosNegEta",curParticle->Eta());
3617 if(curTrack->GetSign() > 0){
3619 // vESDxPosTemp.push_back(curTrack);
3620 new((*vESDxPosTemp)[vESDxPosTemp->GetEntriesFast()]) AliESDtrack(*curTrack);
3624 fHistograms->FillHistogram("ESD_ElectronPosNegPt",curElec.Pt());
3625 fHistograms->FillHistogram("ESD_ElectronPosPt",curElec.Pt());
3626 // fHistograms->FillHistogram("MC_ElectronPosNegPt",curParticle->Pt());
3627 fHistograms->FillHistogram("ESD_ElectronPosNegEta",curElec.Eta());
3628 // fHistograms->FillHistogram("MC_ElectronPosNegEta",curParticle->Eta());
3629 // vESDePosTemp.push_back(curTrack);
3630 new((*vESDePosTemp)[vESDePosTemp->GetEntriesFast()]) AliESDtrack(*curTrack);
3637 new((*vESDxNegTemp)[vESDxNegTemp->GetEntriesFast()]) AliESDtrack(*curTrack);
3641 fHistograms->FillHistogram("ESD_ElectronPosNegPt",curElec.Pt());
3642 fHistograms->FillHistogram("ESD_ElectronNegPt",curElec.Pt());
3643 fHistograms->FillHistogram("ESD_ElectronPosNegEta",curElec.Eta());
3644 new((*vESDeNegTemp)[vESDeNegTemp->GetEntriesFast()]) AliESDtrack(*curTrack);
3653 Bool_t ePosJPsi = kFALSE;
3654 Bool_t eNegJPsi = kFALSE;
3655 Bool_t ePosPi0 = kFALSE;
3656 Bool_t eNegPi0 = kFALSE;
3658 UInt_t iePosJPsi=0,ieNegJPsi=0,iePosPi0=0,ieNegPi0=0;
3660 for(Int_t iNeg=0; iNeg < vESDeNegTemp->GetEntriesFast(); iNeg++){
3661 if(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDeNegTemp->At(iNeg)))->GetLabel()))->GetPdgCode() == 11)
3662 if(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDeNegTemp->At(iNeg)))->GetLabel()))->GetMother(0) > -1){
3663 Int_t labelMother = fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDeNegTemp->At(iNeg)))->GetLabel()))->GetMother(0);
3664 TParticle* partMother = fStack ->Particle(labelMother);
3665 if (partMother->GetPdgCode() == 111){
3669 if(partMother->GetPdgCode() == 443){ //Mother JPsi
3670 fHistograms->FillTable("Table_Electrons",14);
3675 // vESDeNegNoJPsi.push_back(vESDeNegTemp[iNeg]);
3676 new((*vESDeNegNoJPsi)[vESDeNegNoJPsi->GetEntriesFast()]) AliESDtrack(*(AliESDtrack*)(vESDeNegTemp->At(iNeg)));
3677 // cout<<"ESD No Positivo JPsi "<<endl;
3683 for(Int_t iPos=0; iPos < vESDePosTemp->GetEntriesFast(); iPos++){
3684 if(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDePosTemp->At(iPos)))->GetLabel()))->GetPdgCode() == -11)
3685 if(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDePosTemp->At(iPos)))->GetLabel()))->GetMother(0) > -1){
3686 Int_t labelMother = fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDePosTemp->At(iPos)))->GetLabel()))->GetMother(0);
3687 TParticle* partMother = fStack ->Particle(labelMother);
3688 if (partMother->GetPdgCode() == 111){
3692 if(partMother->GetPdgCode() == 443){ //Mother JPsi
3693 fHistograms->FillTable("Table_Electrons",15);
3698 // vESDePosNoJPsi.push_back(vESDePosTemp[iPos]);
3699 new((*vESDePosNoJPsi)[vESDePosNoJPsi->GetEntriesFast()]) AliESDtrack(*(AliESDtrack*)(vESDePosTemp->At(iPos)));
3700 // cout<<"ESD No Negativo JPsi "<<endl;
3706 if( eNegJPsi && ePosJPsi ){
3707 TVector3 tempeNegV,tempePosV;
3708 tempeNegV.SetXYZ(((AliESDtrack*)(vESDeNegTemp->At(ieNegJPsi)))->Px(),((AliESDtrack*)(vESDeNegTemp->At(ieNegJPsi)))->Py(),((AliESDtrack*)(vESDeNegTemp->At(ieNegJPsi)))->Pz());
3709 tempePosV.SetXYZ(((AliESDtrack*)(vESDePosTemp->At(iePosJPsi)))->Px(),((AliESDtrack*)(vESDePosTemp->At(iePosJPsi)))->Py(),((AliESDtrack*)(vESDePosTemp->At(iePosJPsi)))->Pz());
3710 fHistograms->FillTable("Table_Electrons",16);
3711 fHistograms->FillHistogram("ESD_ElectronPosNegJPsiAngle",tempeNegV.Angle(tempePosV));
3712 fHistograms->FillHistogram("MC_ElectronPosNegJPsiAngle",GetMCOpeningAngle(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDeNegTemp->At(ieNegJPsi)))->GetLabel())),
3713 fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDePosTemp->At(iePosJPsi)))->GetLabel()))));
3716 if( eNegPi0 && ePosPi0 ){
3717 TVector3 tempeNegV,tempePosV;
3718 tempeNegV.SetXYZ(((AliESDtrack*)(vESDeNegTemp->At(ieNegPi0)))->Px(),((AliESDtrack*)(vESDeNegTemp->At(ieNegPi0)))->Py(),((AliESDtrack*)(vESDeNegTemp->At(ieNegPi0)))->Pz());
3719 tempePosV.SetXYZ(((AliESDtrack*)(vESDePosTemp->At(iePosPi0)))->Px(),((AliESDtrack*)(vESDePosTemp->At(iePosPi0)))->Py(),((AliESDtrack*)(vESDePosTemp->At(iePosPi0)))->Pz());
3720 fHistograms->FillHistogram("ESD_ElectronPosNegPi0Angle",tempeNegV.Angle(tempePosV));
3721 fHistograms->FillHistogram("MC_ElectronPosNegPi0Angle",GetMCOpeningAngle(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDeNegTemp->At(ieNegPi0)))->GetLabel())),
3722 fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDePosTemp->At(iePosPi0)))->GetLabel()))));
3726 FillAngle("ESD_eNegePosAngleBeforeCut",GetTLorentzVector(vESDeNegTemp),GetTLorentzVector(vESDePosTemp));
3728 CleanWithAngleCuts(*vESDeNegTemp,*vESDePosTemp,*fKFReconstructedGammasTClone);
3730 // vector <TLorentzVector> vCurrentTLVeNeg = GetTLorentzVector(fCurrentEventNegElectron);
3731 // vector <TLorentzVector> vCurrentTLVePos = GetTLorentzVector(fCurrentEventPosElectron);
3733 TClonesArray vCurrentTLVeNeg = GetTLorentzVector(fCurrentEventNegElectronTClone);
3734 TClonesArray vCurrentTLVePos = GetTLorentzVector(fCurrentEventPosElectronTClone);
3737 FillAngle("ESD_eNegePosAngleAfterCut",vCurrentTLVeNeg,vCurrentTLVePos);
3742 //FillAngle("ESD_eNegePosAngleAfterCut",CurrentTLVeNeg,CurrentTLVePos);
3745 FillElectronInvMass("ESD_InvMass_ePluseMinus",vCurrentTLVeNeg,vCurrentTLVePos);
3746 FillElectronInvMass("ESD_InvMass_xPlusxMinus",GetTLorentzVector(vESDxNegTemp),GetTLorentzVector(vESDxPosTemp));
3750 FillGammaElectronInvMass("ESD_InvMass_GammaePluseMinusChiC","ESD_InvMass_GammaePluseMinusChiCDiff",*fKFReconstructedGammasCutTClone,vCurrentTLVeNeg,vCurrentTLVePos);
3752 FillGammaElectronInvMass("ESD_InvMass_GammaePluseMinusPi0","ESD_InvMass_GammaePluseMinusPi0Diff",
3753 *fKFReconstructedGammasCutTClone,vCurrentTLVeNeg,vCurrentTLVePos);
3758 ElectronBackground("ESD_ENegBackground",vCurrentTLVeNeg);
3759 ElectronBackground("ESD_EPosBackground",vCurrentTLVePos);
3760 ElectronBackground("ESD_EPosENegBackground",vCurrentTLVeNeg);
3761 ElectronBackground("ESD_EPosENegBackground",vCurrentTLVePos);
3763 // Like Sign e+e- no JPsi
3764 ElectronBackground("ESD_EPosENegNoJPsiBG",GetTLorentzVector(vESDeNegNoJPsi));
3765 ElectronBackground("ESD_EPosENegNoJPsiBG",GetTLorentzVector(vESDePosNoJPsi));
3769 if( fCurrentEventPosElectronTClone->GetEntriesFast() > 0 && fCurrentEventNegElectronTClone->GetEntriesFast() > 0 && fKFReconstructedGammasCutTClone->GetEntriesFast() > 0 ){
3770 FillGammaElectronInvMass("ESD_EPosENegGammaBackgroundMX","ESD_EPosENegGammaBackgroundMXDiff",
3771 *fKFReconstructedGammasCutTClone,*fPreviousEventTLVNegElectronTClone,*fPreviousEventTLVPosElectronTClone);
3772 *fPreviousEventTLVNegElectronTClone = vCurrentTLVeNeg;
3773 *fPreviousEventTLVPosElectronTClone = vCurrentTLVePos;
3780 vtx[0]=0;vtx[1]=0;vtx[2]=0;
3781 for(UInt_t i=0;i<fKFReconstructedGammasChic.size();i++){
3783 // if(fMCGammaChicTempCut[i]->GetMother(0) < 0) continue;
3787 Int_t tempLabel = fStack->Particle(fMCGammaChicTempCut[i]->GetMother(0))->GetPdgCode();
3788 // cout<<" Label Pedro Gonzalez " <<tempLabel <<endl;
3790 // cout<<" Label Distance"<<fKFReconstructedGammasChic[i].GetDistanceFromVertex(vtx)<<endl;
3792 if( tempLabel == 10441 || tempLabel == 20443 || tempLabel == 445 )
3794 fHistograms->FillHistogram("ESD_PhotonsMomentum",fKFReconstructedGammasChic[i].GetMomentum());
3803 vESDeNegTemp->Delete();
3804 vESDePosTemp->Delete();
3805 vESDxNegTemp->Delete();
3806 vESDxPosTemp->Delete();
3807 vESDeNegNoJPsi->Delete();
3808 vESDePosNoJPsi->Delete();
3810 delete vESDeNegTemp;
3811 delete vESDePosTemp;
3812 delete vESDxNegTemp;
3813 delete vESDxPosTemp;
3814 delete vESDeNegNoJPsi;
3815 delete vESDePosNoJPsi;
3819 void AliAnalysisTaskGammaConversion::FillAngle(TString histoName,vector <TLorentzVector> tlVeNeg, vector <TLorentzVector> tlVePos){
3820 //see header file for documentation
3821 for( UInt_t iNeg=0; iNeg < tlVeNeg.size(); iNeg++){
3822 for (UInt_t iPos=0; iPos < tlVePos.size(); iPos++){
3823 fHistograms->FillHistogram(histoName.Data(),tlVeNeg[iNeg].Vect().Angle(tlVePos[iPos].Vect()));
3828 void AliAnalysisTaskGammaConversion::FillAngle(TString histoName,TClonesArray const tlVeNeg, TClonesArray const tlVePos){
3829 //see header file for documentation
3830 for( Int_t iNeg=0; iNeg < tlVeNeg.GetEntriesFast(); iNeg++){
3831 for (Int_t iPos=0; iPos < tlVePos.GetEntriesFast(); iPos++){
3832 fHistograms->FillHistogram(histoName.Data(),((TLorentzVector*)(tlVeNeg.At(iNeg)))->Vect().Angle(((TLorentzVector*)(tlVePos.At(iPos)))->Vect()));
3836 void AliAnalysisTaskGammaConversion::FillElectronInvMass(TString histoName, TClonesArray const eNeg, TClonesArray const ePos){
3837 //see header file for documentation
3838 for( Int_t n=0; n < eNeg.GetEntriesFast(); n++){
3839 TLorentzVector en = (*(TLorentzVector*)(eNeg.At(n)));
3840 for (Int_t p=0; p < ePos.GetEntriesFast(); p++){
3841 TLorentzVector ep = (*(TLorentzVector*)(ePos.At(p)));
3842 TLorentzVector np = ep + en;
3843 fHistograms->FillHistogram(histoName.Data(),np.M());
3848 void AliAnalysisTaskGammaConversion::FillGammaElectronInvMass(TString histoMass,TString histoDiff,TClonesArray const fKFGammas,
3849 TClonesArray const tlVeNeg,TClonesArray const tlVePos)
3851 //see header file for documentation
3853 for( Int_t iNeg=0; iNeg < tlVeNeg.GetEntriesFast(); iNeg++ ){
3855 for (Int_t iPos=0; iPos < tlVePos.GetEntriesFast(); iPos++){
3857 TLorentzVector xy = *((TLorentzVector *)(tlVePos.At(iPos))) + *((TLorentzVector *)(tlVeNeg.At(iNeg)));
3859 for (Int_t iGam=0; iGam < fKFGammas.GetEntriesFast(); iGam++){
3861 // AliKFParticle * gammaCandidate = &fKFGammas[iGam];
3862 AliKFParticle * gammaCandidate = (AliKFParticle *)(fKFGammas.At(iGam));
3865 g.SetXYZM(gammaCandidate->GetPx(),gammaCandidate->GetPy(),gammaCandidate->GetPz(),fGammaMass);
3866 TLorentzVector xyg = xy + g;
3867 fHistograms->FillHistogram(histoMass.Data(),xyg.M());
3868 fHistograms->FillHistogram(histoDiff.Data(),(xyg.M()-xy.M()));
3874 void AliAnalysisTaskGammaConversion::ElectronBackground(TString hBg, TClonesArray e)
3876 // see header file for documentation
3877 for(Int_t i=0; i < e.GetEntriesFast(); i++)
3879 for (Int_t j=i+1; j < e.GetEntriesFast(); j++)
3881 TLorentzVector ee = (*(TLorentzVector*)(e.At(i))) + (*(TLorentzVector*)(e.At(j)));
3883 fHistograms->FillHistogram(hBg.Data(),ee.M());
3889 void AliAnalysisTaskGammaConversion::CleanWithAngleCuts(TClonesArray const negativeElectrons,
3890 TClonesArray const positiveElectrons,
3891 TClonesArray const gammas){
3892 // see header file for documentation
3894 UInt_t sizeN = negativeElectrons.GetEntriesFast();
3895 UInt_t sizeP = positiveElectrons.GetEntriesFast();
3896 UInt_t sizeG = gammas.GetEntriesFast();
3900 vector <Bool_t> xNegBand(sizeN);
3901 vector <Bool_t> xPosBand(sizeP);
3902 vector <Bool_t> gammaBand(sizeG);
3905 for(UInt_t iNeg=0; iNeg < sizeN; iNeg++) xNegBand[iNeg]=kTRUE;
3906 for(UInt_t iPos=0; iPos < sizeP; iPos++) xPosBand[iPos]=kTRUE;
3907 for(UInt_t iGam=0; iGam < sizeG; iGam++) gammaBand[iGam]=kTRUE;
3910 for(UInt_t iPos=0; iPos < sizeP; iPos++){
3913 ((AliESDtrack*)(positiveElectrons.At(iPos)))->GetConstrainedPxPyPz(aP);
3915 TVector3 ePosV(aP[0],aP[1],aP[2]);
3917 for(UInt_t iNeg=0; iNeg < sizeN; iNeg++){
3920 ((AliESDtrack*)(negativeElectrons.At(iNeg)))->GetConstrainedPxPyPz(aN);
3921 TVector3 eNegV(aN[0],aN[1],aN[2]);
3923 if(ePosV.Angle(eNegV) < 0.05){ //e+e- from gamma
3924 xPosBand[iPos]=kFALSE;
3925 xNegBand[iNeg]=kFALSE;
3928 for(UInt_t iGam=0; iGam < sizeG; iGam++){
3929 AliKFParticle* gammaCandidate = (AliKFParticle*)gammas.At(iGam);
3930 TVector3 gammaCandidateVector(gammaCandidate->Px(),gammaCandidate->Py(),gammaCandidate->Pz());
3931 if(ePosV.Angle(gammaCandidateVector) < 0.05 || eNegV.Angle(gammaCandidateVector) < 0.05)
3932 gammaBand[iGam]=kFALSE;
3940 for(UInt_t iPos=0; iPos < sizeP; iPos++){
3942 new((*fCurrentEventPosElectronTClone)[fCurrentEventPosElectronTClone->GetEntriesFast()]) AliESDtrack((*(AliESDtrack*)(positiveElectrons.At(iPos))));
3943 // fCurrentEventPosElectron.push_back(positiveElectrons[iPos]);
3946 for(UInt_t iNeg=0;iNeg < sizeN; iNeg++){
3948 new((*fCurrentEventNegElectronTClone)[fCurrentEventNegElectronTClone->GetEntriesFast()]) AliESDtrack((*(AliESDtrack*)(negativeElectrons.At(iNeg))));
3949 // fCurrentEventNegElectron.push_back(negativeElectrons[iNeg]);
3952 for(UInt_t iGam=0; iGam < sizeG; iGam++){
3953 if(gammaBand[iGam]){
3954 new((*fKFReconstructedGammasCutTClone)[fKFReconstructedGammasCutTClone->GetEntriesFast()]) AliKFParticle((*(AliKFParticle*)(gammas.At(iGam))));
3955 //fKFReconstructedGammasCut.push_back(*(AliKFParticle*)gammas->At(iGam));
3961 void AliAnalysisTaskGammaConversion::GetPID(const AliESDtrack *track, Stat_t &pid, Stat_t &weight)
3963 // see header file for documentation
3968 double wpartbayes[5];
3970 //get probability of the diffenrent particle types
3971 track->GetESDpid(wpart);
3973 // Tentative particle type "concentrations"
3974 double c[5]={0.01, 0.01, 0.85, 0.10, 0.05};
3978 for (int i = 0; i < 5; i++)
3980 rcc+=(c[i] * wpart[i]);
3985 for (int i=0; i<5; i++) {
3986 if( rcc>0 || rcc<0){//Kenneth: not sure if the rcc<0 should be there, this is from fixing a coding violation where we are not allowed to say: rcc!=0 (RC19)
3987 wpartbayes[i] = c[i] * wpart[i] / rcc;
3995 //find most probable particle in ESD pid
3996 //0:Electron - 1:Muon - 2:Pion - 3:Kaon - 4:Proton
3997 for (int i = 0; i < 5; i++)
3999 if (wpartbayes[i] > max)
4002 max = wpartbayes[i];
4009 double AliAnalysisTaskGammaConversion::GetSigmaToVertex(const AliESDtrack* t)
4011 // Calculates the number of sigma to the vertex.
4016 t->GetImpactParameters(b,bCov);
4017 if (bCov[0]<=0 || bCov[2]<=0) {
4018 AliDebug(1, "Estimated b resolution lower or equal zero!");
4019 bCov[0]=0; bCov[2]=0;
4021 bRes[0] = TMath::Sqrt(bCov[0]);
4022 bRes[1] = TMath::Sqrt(bCov[2]);
4024 // -----------------------------------
4025 // How to get to a n-sigma cut?
4027 // The accumulated statistics from 0 to d is
4029 // -> Erf(d/Sqrt(2)) for a 1-dim gauss (d = n_sigma)
4030 // -> 1 - Exp(-d**2) for a 2-dim gauss (d*d = dx*dx + dy*dy != n_sigma)
4032 // It means that for a 2-dim gauss: n_sigma(d) = Sqrt(2)*ErfInv(1 - Exp((-x**2)/2)
4033 // Can this be expressed in a different way?
4035 if (bRes[0] == 0 || bRes[1] ==0)
4038 double d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
4040 // stupid rounding problem screws up everything:
4041 // if d is too big, TMath::Exp(...) gets 0, and TMath::ErfInverse(1) that should be infinite, gets 0 :(
4042 if (TMath::Exp(-d * d / 2) < 1e-10)
4046 d = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);
4050 //vector <TLorentzVector> AliAnalysisTaskGammaConversion::GetTLorentzVector(vector <AliESDtrack*> esdTrack){
4051 TClonesArray AliAnalysisTaskGammaConversion::GetTLorentzVector(TClonesArray *const esdTrack){
4052 //Return TLoresntz vector of track?
4053 // vector <TLorentzVector> tlVtrack(0);
4054 TClonesArray array("TLorentzVector",0);
4056 for(Int_t itrack=0; itrack < esdTrack->GetEntriesFast(); itrack++){
4058 //esdTrack[itrack]->GetConstrainedPxPyPz(p);
4059 ((AliESDtrack*)(esdTrack->At(itrack)))->GetConstrainedPxPyPz(p);
4060 TLorentzVector currentTrack;
4061 currentTrack.SetXYZM(p[0],p[1],p[2],fElectronMass);
4062 new((array)[array.GetEntriesFast()]) TLorentzVector(currentTrack);
4063 // tlVtrack.push_back(currentTrack);
4070 Int_t AliAnalysisTaskGammaConversion::GetProcessType(const AliMCEvent * mcEvt) {
4072 // Determine if the event was generated with pythia or phojet and return the process type
4074 // Check if mcEvt is fine
4076 AliFatal("NULL mc event");
4079 // Determine if it was a pythia or phojet header, and return the correct process type
4080 AliGenPythiaEventHeader * headPy = 0;
4081 AliGenDPMjetEventHeader * headPho = 0;
4082 AliGenEventHeader * htmp = mcEvt->GenEventHeader();
4084 AliFatal("Cannot Get MC Header!!");
4086 if( TString(htmp->IsA()->GetName()) == "AliGenPythiaEventHeader") {
4087 headPy = (AliGenPythiaEventHeader*) htmp;
4088 } else if (TString(htmp->IsA()->GetName()) == "AliGenDPMjetEventHeader") {
4089 headPho = (AliGenDPMjetEventHeader*) htmp;
4091 AliError("Unknown header");
4094 // Determine process type
4096 if(headPy->ProcessType() == 92 || headPy->ProcessType() == 93) {
4097 // single difractive
4099 } else if (headPy->ProcessType() == 94) {
4100 // double diffractive
4103 else if(headPy->ProcessType() != 92 && headPy->ProcessType() != 93 && headPy->ProcessType() != 94) {
4107 } else if (headPho) {
4108 if(headPho->ProcessType() == 5 || headPho->ProcessType() == 6 ) {
4109 // single difractive
4111 } else if (headPho->ProcessType() == 7) {
4112 // double diffractive
4114 } else if(headPho->ProcessType() != 5 && headPho->ProcessType() != 6 && headPho->ProcessType() != 7 ) {
4121 // no process type found?
4122 AliError(Form("Unknown header: %s", htmp->IsA()->GetName()));
4123 return kProcUnknown;
4127 Int_t AliAnalysisTaskGammaConversion::CalculateMultiplicityBin(){
4128 // Get Centrality bin
4130 Int_t multiplicity = 0;
4132 if ( fUseMultiplicity == 1 ) {
4134 if (fMultiplicity>= 0 && fMultiplicity<= 5) multiplicity=1;
4135 if (fMultiplicity>= 6 && fMultiplicity<= 9) multiplicity=2;
4136 if (fMultiplicity>=10 && fMultiplicity<=14) multiplicity=3;
4137 if (fMultiplicity>=15 && fMultiplicity<=22) multiplicity=4;
4138 if (fMultiplicity>=23 ) multiplicity=5;
4141 return multiplicity;