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 "AliAODPWG4Particle.h"
36 #include "AliAODPWG4ParticleCorrelation.h"
37 #include "AliGammaConversionAODObject.h"
38 #include "AliAODConversionParticle.h"
39 #include "AliGammaConversionBGHandler.h"
40 #include "AliESDCaloCluster.h" // for combining PHOS and GammaConv
41 #include "AliKFVertex.h"
42 #include "AliGenPythiaEventHeader.h"
43 #include "AliGenDPMjetEventHeader.h"
44 #include "AliGenEventHeader.h"
45 #include <AliMCEventHandler.h>
47 #include "AliTriggerAnalysis.h"
48 #include "AliCentrality.h"
50 class AliESDTrackCuts;
58 class AliMCEventHandler;
59 class AliESDInputHandler;
60 class AliAnalysisManager;
67 ClassImp(AliAnalysisTaskGammaConversion)
70 AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion():
74 fMCTruth(NULL), // for CF
75 fGCMCEvent(NULL), // for CF
77 fOutputContainer(NULL),
78 fCFManager(0x0), // for CF
80 fTriggerCINT1B(kFALSE),
82 fDoNeutralMeson(kFALSE),
83 fDoOmegaMeson(kFALSE),
86 fRecalculateV0ForGamma(kFALSE),
87 fKFReconstructedGammasTClone(NULL),
88 fKFReconstructedPi0sTClone(NULL),
89 fKFRecalculatedGammasTClone(NULL),
90 fCurrentEventPosElectronTClone(NULL),
91 fCurrentEventNegElectronTClone(NULL),
92 fKFReconstructedGammasCutTClone(NULL),
93 fPreviousEventTLVNegElectronTClone(NULL),
94 fPreviousEventTLVPosElectronTClone(NULL),
99 fElectronRecalculatedv1(),
100 fElectronRecalculatedv2(),
108 fMinOpeningAngleGhostCut(0.),
110 fCalculateBackground(kFALSE),
111 fWriteNtuple(kFALSE),
113 fNeutralMesonNtuple(NULL),
114 fTotalNumberOfAddedNtupleEntries(0),
115 fChargedParticles(NULL),
116 fChargedParticlesId(),
118 fMinPtForGammaJet(1.),
119 fMinIsoConeSize(0.2),
121 fMinPtGamChargedCorr(0.5),
123 fLeadingChargedIndex(-1),
130 fAODBranchName("GammaConv"),
133 fKFDeltaAODFileName(""),
134 fDoNeutralMesonV0MCCheck(kFALSE),
135 fUseTrackMultiplicityForBG(kTRUE),
136 fMoveParticleAccordingToVertex(kFALSE),
137 fApplyChi2Cut(kFALSE),
138 fNRandomEventsForBG(15),
139 fNDegreesPMBackground(15),
141 fCheckBGProbability(kTRUE),
142 fKFReconstructedGammasV0Index(),
143 fRemovePileUp(kFALSE),
144 fSelectV0AND(kFALSE),
145 fTriggerAnalysis(NULL),
148 fUseMultiplicityBin(0),
152 // Default constructor
154 /* Kenneth: the default constructor should not have any define input/output or the call to SetESDtrackCuts
155 // Common I/O in slot 0
156 DefineInput (0, TChain::Class());
157 DefineOutput(0, TTree::Class());
159 // Your private output
160 DefineOutput(1, TList::Class());
162 // Define standard ESD track cuts for Gamma-hadron correlation
167 AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion(const char* name):
168 AliAnalysisTaskSE(name),
171 fMCTruth(NULL), // for CF
172 fGCMCEvent(NULL), // for CF
174 fOutputContainer(0x0),
175 fCFManager(0x0), // for CF
177 fTriggerCINT1B(kFALSE),
179 fDoNeutralMeson(kFALSE),
180 fDoOmegaMeson(kFALSE),
183 fRecalculateV0ForGamma(kFALSE),
184 fKFReconstructedGammasTClone(NULL),
185 fKFReconstructedPi0sTClone(NULL),
186 fKFRecalculatedGammasTClone(NULL),
187 fCurrentEventPosElectronTClone(NULL),
188 fCurrentEventNegElectronTClone(NULL),
189 fKFReconstructedGammasCutTClone(NULL),
190 fPreviousEventTLVNegElectronTClone(NULL),
191 fPreviousEventTLVPosElectronTClone(NULL),
196 fElectronRecalculatedv1(),
197 fElectronRecalculatedv2(),
205 fMinOpeningAngleGhostCut(0.),
207 fCalculateBackground(kFALSE),
208 fWriteNtuple(kFALSE),
210 fNeutralMesonNtuple(NULL),
211 fTotalNumberOfAddedNtupleEntries(0),
212 fChargedParticles(NULL),
213 fChargedParticlesId(),
215 fMinPtForGammaJet(1.),
216 fMinIsoConeSize(0.2),
218 fMinPtGamChargedCorr(0.5),
220 fLeadingChargedIndex(-1),
227 fAODBranchName("GammaConv"),
230 fKFDeltaAODFileName(""),
231 fDoNeutralMesonV0MCCheck(kFALSE),
232 fUseTrackMultiplicityForBG(kTRUE),
233 fMoveParticleAccordingToVertex(kFALSE),
234 fApplyChi2Cut(kFALSE),
235 fNRandomEventsForBG(15),
236 fNDegreesPMBackground(15),
238 fCheckBGProbability(kTRUE),
239 fKFReconstructedGammasV0Index(),
240 fRemovePileUp(kFALSE),
241 fSelectV0AND(kFALSE),
242 fTriggerAnalysis(NULL),
245 fUseMultiplicityBin(0),
249 // Common I/O in slot 0, don't define when inheriting from AnalysisTaskSE
250 // DefineInput (0, TChain::Class());
251 // DefineOutput(0, TTree::Class());
253 // Your private output
254 DefineOutput(1, TList::Class());
255 DefineOutput(2, AliCFContainer::Class()); // for CF
258 // Define standard ESD track cuts for Gamma-hadron correlation
263 AliAnalysisTaskGammaConversion::~AliAnalysisTaskGammaConversion()
265 // Remove all pointers
267 if(fOutputContainer){
268 fOutputContainer->Clear() ;
269 delete fOutputContainer ;
284 delete fEsdTrackCuts;
306 if(fTriggerAnalysis) {
307 delete fTriggerAnalysis;
314 void AliAnalysisTaskGammaConversion::Init()
317 // AliLog::SetGlobalLogLevel(AliLog::kError);
319 void AliAnalysisTaskGammaConversion::SetESDtrackCuts()
322 if (fEsdTrackCuts!=NULL){
323 delete fEsdTrackCuts;
325 fEsdTrackCuts = new AliESDtrackCuts("AliESDtrackCuts");
326 //standard cuts from:
327 //http://aliceinfo.cern.ch/alicvs/viewvc/PWG0/dNdEta/CreateCuts.C?revision=1.4&view=markup
329 // Cuts used up to 3rd of March
331 // fEsdTrackCuts->SetMinNClustersTPC(50);
332 // fEsdTrackCuts->SetMaxChi2PerClusterTPC(3.5);
333 // fEsdTrackCuts->SetRequireTPCRefit(kTRUE);
334 // fEsdTrackCuts->SetRequireITSRefit(kTRUE);
335 // fEsdTrackCuts->SetMaxNsigmaToVertex(3);
336 // fEsdTrackCuts->SetRequireSigmaToVertex(kTRUE);
338 //------- To be tested-----------
339 // Cuts used up to 26th of Agost
340 // Int_t minNClustersTPC = 70;
341 // Double_t maxChi2PerClusterTPC = 4.0;
342 // Double_t maxDCAtoVertexXY = 2.4; // cm
343 // Double_t maxDCAtoVertexZ = 3.2; // cm
344 // fEsdTrackCuts->SetRequireSigmaToVertex(kFALSE);
345 // fEsdTrackCuts->SetRequireTPCRefit(kTRUE);
346 // fEsdTrackCuts->SetRequireITSRefit(kTRUE);
347 // // fEsdTrackCuts->SetRequireTPCStandAlone(kTRUE);
348 // fEsdTrackCuts->SetAcceptKinkDaughters(kFALSE);
349 // fEsdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
350 // fEsdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
351 // fEsdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
352 // fEsdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
353 // fEsdTrackCuts->SetDCAToVertex2D(kTRUE);
354 // fEsdTrackCuts->SetEtaRange(-0.8, 0.8);
355 // fEsdTrackCuts->SetPtRange(0.15);
357 // fEsdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kFirst);
360 // Using standard function for setting Cuts
361 Bool_t selectPrimaries=kTRUE;
362 fEsdTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(selectPrimaries);
363 fEsdTrackCuts->SetMaxDCAToVertexZ(2);
364 fEsdTrackCuts->SetEtaRange(-0.8, 0.8);
365 fEsdTrackCuts->SetPtRange(0.15);
367 //----- From Jacek 10.03.03 ------------------/
368 // minNClustersTPC = 70;
369 // maxChi2PerClusterTPC = 4.0;
370 // maxDCAtoVertexXY = 2.4; // cm
371 // maxDCAtoVertexZ = 3.2; // cm
373 // esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
374 // esdTrackCuts->SetRequireTPCRefit(kFALSE);
375 // esdTrackCuts->SetRequireTPCStandAlone(kTRUE);
376 // esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
377 // esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
378 // esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
379 // esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
380 // esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
381 // esdTrackCuts->SetDCAToVertex2D(kTRUE);
385 // fEsdTrackCuts->SetAcceptKinkDaughters(kFALSE);
386 // fV0Reader->SetESDtrackCuts(fEsdTrackCuts);
389 void AliAnalysisTaskGammaConversion::UserExec(Option_t */*option*/)
391 // Execute analysis for current event
393 // Load the esdpid from the esdhandler if exists (tender was applied) otherwise set the Bethe Bloch parameters
394 Int_t eventQuality=-1;
396 AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
397 AliESDInputHandler *esdHandler=0x0;
398 if ( (esdHandler=dynamic_cast<AliESDInputHandler*>(man->GetInputEventHandler())) && esdHandler->GetESDpid() ){
399 AliV0Reader::SetESDpid(esdHandler->GetESDpid());
401 //load esd pid bethe bloch parameters depending on the existance of the MC handler
402 // yes: MC parameters
403 // no: data parameters
404 if (!AliV0Reader::GetESDpid()){
406 AliV0Reader::InitESDpid();
408 AliV0Reader::InitESDpid(1);
413 //Must set fForceAOD to true for the AOD to get filled. Should only be done when running independent chain / train.
415 if (!AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()) AliFatal("Cannot run ESD filter without an output event handler");
416 AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kTRUE);
419 // if(fV0Reader == NULL){ // coverty does not permit this test
420 // Write warning here cuts and so on are default if this ever happens
424 // To avoid crashes due to unzip errors. Sometimes the trees are not there.
426 AliMCEventHandler* mcHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
428 AliError("Could not retrive MC event handler!");
432 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
434 if (!mcHandler->InitOk() ){
436 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
439 if (!mcHandler->TreeK() ){
441 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
444 if (!mcHandler->TreeTR() ) {
446 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
451 fV0Reader->SetInputAndMCEvent(InputEvent(), MCEvent());
453 fV0Reader->Initialize();
454 fDoMCTruth = fV0Reader->GetDoMCTruth();
456 if(fAODGamma) fAODGamma->Delete();
457 if(fAODPi0) fAODPi0->Delete();
458 if(fAODOmega) fAODOmega->Delete();
460 if(fKFReconstructedGammasTClone == NULL){
461 fKFReconstructedGammasTClone = new TClonesArray("AliKFParticle",0);
463 if(fCurrentEventPosElectronTClone == NULL){
464 fCurrentEventPosElectronTClone = new TClonesArray("AliESDtrack",0);
466 if(fCurrentEventNegElectronTClone == NULL){
467 fCurrentEventNegElectronTClone = new TClonesArray("AliESDtrack",0);
469 if(fKFReconstructedGammasCutTClone == NULL){
470 fKFReconstructedGammasCutTClone = new TClonesArray("AliKFParticle",0);
472 if(fPreviousEventTLVNegElectronTClone == NULL){
473 fPreviousEventTLVNegElectronTClone = new TClonesArray("TLorentzVector",0);
475 if(fPreviousEventTLVPosElectronTClone == NULL){
476 fPreviousEventTLVPosElectronTClone = new TClonesArray("TLorentzVector",0);
478 if(fChargedParticles == NULL){
479 fChargedParticles = new TClonesArray("AliESDtrack",0);
482 if(fKFReconstructedPi0sTClone == NULL){
483 fKFReconstructedPi0sTClone = new TClonesArray("AliKFParticle",0);
486 if(fKFRecalculatedGammasTClone == NULL){
487 fKFRecalculatedGammasTClone = new TClonesArray("AliKFParticle",0);
490 if(fTriggerAnalysis== NULL){
491 fTriggerAnalysis = new AliTriggerAnalysis;
495 fKFReconstructedGammasTClone->Delete();
496 fCurrentEventPosElectronTClone->Delete();
497 fCurrentEventNegElectronTClone->Delete();
498 fKFReconstructedGammasCutTClone->Delete();
499 fPreviousEventTLVNegElectronTClone->Delete();
500 fPreviousEventTLVPosElectronTClone->Delete();
501 fKFReconstructedPi0sTClone->Delete();
502 fKFRecalculatedGammasTClone->Delete();
511 fElectronRecalculatedv1.clear();
512 fElectronRecalculatedv2.clear();
515 fChargedParticles->Delete();
517 fChargedParticlesId.clear();
519 fKFReconstructedGammasV0Index.clear();
521 //Clear the data in the v0Reader
522 // fV0Reader->UpdateEventByEventData();
524 //Take Only events with proper trigger
527 if(!fV0Reader->GetESDEvent()->IsTriggerClassFired("CINT1B-ABCE-NOPF-ALL")) return;
530 Bool_t v0A = fTriggerAnalysis->IsOfflineTriggerFired(fV0Reader->GetESDEvent(), AliTriggerAnalysis::kV0A);
531 Bool_t v0C = fTriggerAnalysis->IsOfflineTriggerFired(fV0Reader->GetESDEvent(), AliTriggerAnalysis::kV0C);
532 Bool_t v0AND = v0A && v0C;
534 if(fSelectV0AND && !v0AND){
536 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
538 CheckMesonProcessTypeEventQuality(eventQuality);
544 if(fV0Reader->CheckForPrimaryVertex() == kFALSE){
545 // cout<< "Event not taken"<< endl;
547 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
549 CheckMesonProcessTypeEventQuality(eventQuality);
551 return; // aborts if the primary vertex does not have contributors.
556 if(!fV0Reader->CheckForPrimaryVertexZ() ){
558 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
560 CheckMesonProcessTypeEventQuality(eventQuality);
565 if(fV0Reader->GetESDEvent()->GetPrimaryVertexTracks()->GetNContributors()>0) {
566 fHistograms->FillHistogram("ESD_GlobalPrimaryVtxZ",fV0Reader->GetESDEvent()->GetPrimaryVertex()->GetZ());
568 if(fV0Reader->GetESDEvent()->GetPrimaryVertexSPD()->GetNContributors()>0) {
569 fHistograms->FillHistogram("ESD_SPDPrimaryVtxZ",fV0Reader->GetESDEvent()->GetPrimaryVertex()->GetZ());
573 if(fRemovePileUp && fV0Reader->GetESDEvent()->IsPileupFromSPD()) {
575 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
579 fMultiplicity = fEsdTrackCuts->CountAcceptedTracks(fV0Reader->GetESDEvent());
581 if( CalculateMultiplicityBin() != fUseMultiplicityBin){
583 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
587 if(fV0Reader->GetIsHeavyIon()){
588 if(fUseCentrality>0){
589 AliCentrality *esdCentrality = fV0Reader->GetESDEvent()->GetCentrality();
590 Int_t centralityC = -1;
592 if(fUseCentrality==1){
593 centralityC = esdCentrality->GetCentralityClass10("V0M");
594 if( centralityC != fUseCentralityBin ){
596 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
601 if(fUseCentrality==2){
602 centralityC = esdCentrality->GetCentralityClass10("CL1");
603 if( centralityC != fUseCentralityBin ){
605 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
610 ////////////////////////////////////// RRnew start /////////////////////////////////////////////////////
611 if(fUseCentrality==3){
612 centralityC = esdCentrality->GetCentralityClass10("V0M");
613 if( (fUseCentralityBin == 0) && (centralityC!=0) ){ // 0-10%
615 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
618 if( (fUseCentralityBin == 1) && (centralityC!=1) ){ // 10-20%
620 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
623 if( (fUseCentralityBin == 2) && (centralityC!=2) && (centralityC!=3) ){ // 20-40%
625 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
628 if( (fUseCentralityBin == 4) && (centralityC!=4) && (centralityC!=5) ){ // 40-60%
630 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
633 if( (fUseCentralityBin == 6) && (centralityC!=6) && (centralityC!=7) && (centralityC!=8) ){ // 60-90%
635 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
640 if(fUseCentrality==4){
641 centralityC = esdCentrality->GetCentralityClass10("CL1");
642 if( (fUseCentralityBin == 0) && (centralityC!=0) ){ // 0-10%
644 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
647 if( (fUseCentralityBin == 1) && (centralityC!=1) ){ // 10-20%
649 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
652 if( (fUseCentralityBin == 2) && (centralityC!=2) && (centralityC!=3) ){ // 20-40%
654 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
657 if( (fUseCentralityBin == 4) && (centralityC!=4) && (centralityC!=5) ){ // 40-60%
659 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
662 if( (fUseCentralityBin == 6) && (centralityC!=6) && (centralityC!=7) && (centralityC!=8) ){ // 60-90%
664 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
668 ////////////////////////////////////// RRnew end ///////////////////////////////////////////////////////
673 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
677 fHistograms->FillHistogram("ESD_NumberOfGoodESDTracks",fMultiplicity);
678 if (fV0Reader->GetNumberOfContributorsVtx()>=1){
679 fHistograms->FillHistogram("ESD_NumberOfGoodESDTracksVtx",fMultiplicity);
684 // Process the MC information
689 //Process the v0 information with no cuts
692 // Process the v0 information
698 FillAODWithConversionGammas() ;
702 // Process reconstructed gammas
703 if(fDoNeutralMeson == kTRUE){
704 ProcessGammasForNeutralMesonAnalysis();
708 if(fDoMCTruth == kTRUE){
711 //Process reconstructed gammas electrons for Chi_c Analysis
712 if(fDoChic == kTRUE){
713 ProcessGammaElectronsForChicAnalysis();
715 // Process reconstructed gammas for gamma Jet/hadron correlations
717 ProcessGammasForGammaJetAnalysis();
720 //calculate background if flag is set
721 if(fCalculateBackground){
722 CalculateBackground();
725 if(fDoNeutralMeson == kTRUE){
726 // ProcessConvPHOSGammasForNeutralMesonAnalysis();
727 if(fDoOmegaMeson == kTRUE){
728 ProcessGammasForOmegaMesonAnalysis();
732 //Clear the data in the v0Reader
733 fV0Reader->UpdateEventByEventData();
734 if(fRecalculateV0ForGamma==kTRUE){
735 RecalculateV0ForGamma();
737 PostData(1, fOutputContainer);
738 PostData(2, fCFManager->GetParticleContainer()); // for CF
742 // void AliAnalysisTaskGammaConversion::ConnectInputData(Option_t *option){
743 // // see header file for documentation
744 // // printf(" ConnectInputData %s\n", GetName());
746 // AliAnalysisTaskSE::ConnectInputData(option);
748 // if(fV0Reader == NULL){
749 // // Write warning here cuts and so on are default if this ever happens
751 // fV0Reader->Initialize();
752 // fDoMCTruth = fV0Reader->GetDoMCTruth();
755 void AliAnalysisTaskGammaConversion::CheckMesonProcessTypeEventQuality(Int_t evtQ){
756 // Check meson process type event quality
757 fStack= MCEvent()->Stack();
758 fGCMCEvent=MCEvent();
760 for (Int_t iTracks = 0; iTracks < fStack->GetNprimary(); iTracks++) {
761 TParticle* particle = (TParticle *)fStack->Particle(iTracks);
766 if(particle->GetPdgCode()!=111){ //Pi0
771 if(particle->Energy() - particle->Pz() == 0 || particle->Energy() + particle->Pz() == 0){
775 rapidity = 0.5*(TMath::Log((particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz())));
778 if(TMath::Abs(rapidity) > fV0Reader->GetRapidityMesonCut() ) continue;
779 if(fV0Reader->GetIsHeavyIon()) continue;
782 switch(GetProcessType(fGCMCEvent)){
784 fHistograms->FillHistogram("MC_SD_EvtQ1_Pi0_Pt", particle->Pt());
787 fHistograms->FillHistogram("MC_DD_EvtQ1_Pi0_Pt", particle->Pt());
790 fHistograms->FillHistogram("MC_ND_EvtQ1_Pi0_Pt", particle->Pt());
793 AliError("Unknown Process");
797 switch(GetProcessType(fGCMCEvent)){
799 fHistograms->FillHistogram("MC_SD_EvtQ2_Pi0_Pt", particle->Pt());
802 fHistograms->FillHistogram("MC_DD_EvtQ2_Pi0_Pt", particle->Pt());
805 fHistograms->FillHistogram("MC_ND_EvtQ2_Pi0_Pt", particle->Pt());
808 AliError("Unknown Process");
813 switch(GetProcessType(fGCMCEvent)){
815 fHistograms->FillHistogram("MC_SD_EvtQ4_Pi0_Pt", particle->Pt());
818 fHistograms->FillHistogram("MC_DD_EvtQ4_Pi0_Pt", particle->Pt());
821 fHistograms->FillHistogram("MC_ND_EvtQ4_Pi0_Pt", particle->Pt());
824 AliError("Unknown Process");
829 switch(GetProcessType(fGCMCEvent)){
831 fHistograms->FillHistogram("MC_SD_EvtQ5_Pi0_Pt", particle->Pt());
834 fHistograms->FillHistogram("MC_DD_EvtQ5_Pi0_Pt", particle->Pt());
837 fHistograms->FillHistogram("MC_ND_EvtQ5_Pi0_Pt", particle->Pt());
840 AliError("Unknown Process");
848 void AliAnalysisTaskGammaConversion::ProcessMCData(){
849 // see header file for documentation
850 //InputEvent(), MCEvent());
852 fStack = fV0Reader->GetMCStack();
853 fMCTruth = fV0Reader->GetMCTruth(); // for CF
854 fGCMCEvent = fV0Reader->GetMCEvent(); // for CF
856 fStack= MCEvent()->Stack();
857 fGCMCEvent=MCEvent();
860 Double_t containerInput[3];
862 if(!fGCMCEvent) cout << "NO MC INFO FOUND" << endl;
863 fCFManager->SetEventInfo(fGCMCEvent);
868 if(fV0Reader->CheckForPrimaryVertex() == kFALSE){
869 return; // aborts if the primary vertex does not have contributors.
871 for (Int_t iTracks = 0; iTracks < fStack->GetNprimary(); iTracks++) {
872 // for (Int_t iTracks = 0; iTracks < fStack->GetNtrack(); iTracks++) {
873 TParticle* particle = (TParticle *)fStack->Particle(iTracks);
882 ///////////////////////Begin Chic Analysis/////////////////////////////
884 if(particle->GetPdgCode() == 443){//Is JPsi
885 if(particle->GetNDaughters()==2){
886 if(TMath::Abs(fStack->Particle(particle->GetFirstDaughter())->GetPdgCode()) == 11 &&
887 TMath::Abs(fStack->Particle(particle->GetLastDaughter())->GetPdgCode()) == 11){
889 TParticle* daug0 = fStack->Particle(particle->GetFirstDaughter());
890 TParticle* daug1 = fStack->Particle(particle->GetLastDaughter());
891 if(TMath::Abs(daug0->Eta()) < 0.9 && TMath::Abs(daug1->Eta()) < 0.9)
892 fHistograms->FillTable("Table_Electrons",3);//e+ e- from J/Psi inside acceptance
894 if( TMath::Abs(daug0->Eta()) < 0.9){
895 if(daug0->GetPdgCode() == -11)
896 fHistograms->FillTable("Table_Electrons",1);//e+ from J/Psi inside acceptance
898 fHistograms->FillTable("Table_Electrons",2);//e- from J/Psi inside acceptance
901 if(TMath::Abs(daug1->Eta()) < 0.9){
902 if(daug1->GetPdgCode() == -11)
903 fHistograms->FillTable("Table_Electrons",1);//e+ from J/Psi inside acceptance
905 fHistograms->FillTable("Table_Electrons",2);//e- from J/Psi inside acceptance
910 // const int CHI_C0 = 10441;
911 // const int CHI_C1 = 20443;
912 // const int CHI_C2 = 445
913 if(particle->GetPdgCode() == 22){//gamma from JPsi
914 if(particle->GetMother(0) > -1){
915 if(fStack->Particle(particle->GetMother(0))->GetPdgCode() == 10441 ||
916 fStack->Particle(particle->GetMother(0))->GetPdgCode() == 20443 ||
917 fStack->Particle(particle->GetMother(0))->GetPdgCode() == 445){
918 if(TMath::Abs(particle->Eta()) < 1.2)
919 fHistograms->FillTable("Table_Electrons",17);// gamma from chic inside accptance
923 if(particle->GetPdgCode() == 10441 || particle->GetPdgCode() == 20443 || particle->GetPdgCode() == 445){
924 if( particle->GetNDaughters() == 2){
925 TParticle* daug0 = fStack->Particle(particle->GetFirstDaughter());
926 TParticle* daug1 = fStack->Particle(particle->GetLastDaughter());
928 if( (daug0->GetPdgCode() == 443 || daug0->GetPdgCode() == 22) && (daug1->GetPdgCode() == 443 || daug1->GetPdgCode() == 22) ){
929 if( daug0->GetPdgCode() == 443){
930 TParticle* daugE0 = fStack->Particle(daug0->GetFirstDaughter());
931 TParticle* daugE1 = fStack->Particle(daug0->GetLastDaughter());
932 if( TMath::Abs(daug1->Eta()) < 1.2 && TMath::Abs(daugE0->Eta()) < 0.9 && TMath::Abs(daugE1->Eta()) < 0.9 )
933 fHistograms->FillTable("Table_Electrons",18);
936 else if (daug1->GetPdgCode() == 443){
937 TParticle* daugE0 = fStack->Particle(daug1->GetFirstDaughter());
938 TParticle* daugE1 = fStack->Particle(daug1->GetLastDaughter());
939 if( TMath::Abs(daug0->Eta()) < 1.2 && TMath::Abs(daugE0->Eta()) < 0.9 && TMath::Abs(daugE1->Eta()) < 0.9 )
940 fHistograms->FillTable("Table_Electrons",18);
947 /////////////////////End Chic Analysis////////////////////////////
950 // if(TMath::Abs(particle->Eta())> fV0Reader->GetEtaCut() ) continue;
952 if(particle->R()>fV0Reader->GetMaxRCut()) continue; // cuts on distance from collision point
954 Double_t tmpPhi=particle->Phi();
956 if(particle->Phi()> TMath::Pi()){
957 tmpPhi = particle->Phi()-(2*TMath::Pi());
961 if(particle->Energy() - particle->Pz() == 0 || particle->Energy() + particle->Pz() == 0){
965 rapidity = 0.5*(TMath::Log((particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz())));
970 if(iTracks<=fStack->GetNprimary() ){
971 if ( particle->GetPdgCode()== -211 || particle->GetPdgCode()== 211 ||
972 particle->GetPdgCode()== 2212 || particle->GetPdgCode()==-2212 ||
973 particle->GetPdgCode()== 321 || particle->GetPdgCode()==-321 ){
974 if(TMath::Abs(particle->Eta())> fV0Reader->GetEtaCut() ) continue;
975 fHistograms->FillHistogram("MC_PhysicalPrimaryCharged_Pt", particle->Pt());
982 if (particle->GetPdgCode() == 22){
983 if(TMath::Abs(particle->Eta())> fV0Reader->GetEtaCut() ) continue;
985 if(particle->GetMother(0) >-1 && fStack->Particle(particle->GetMother(0))->GetPdgCode() == 22){
986 continue; // no photon as mothers!
989 if(particle->GetMother(0) >= fStack->GetNprimary()){
990 continue; // the gamma has a mother, and it is not a primary particle
993 if(particle->GetMother(0) >-1){
994 fHistograms->FillHistogram("MC_DecayAllGamma_Pt", particle->Pt()); // All
995 switch(fStack->Particle(particle->GetMother(0))->GetPdgCode()){
997 fHistograms->FillHistogram("MC_DecayPi0Gamma_Pt", particle->Pt());
1000 fHistograms->FillHistogram("MC_DecayRho0Gamma_Pt", particle->Pt());
1003 fHistograms->FillHistogram("MC_DecayEtaGamma_Pt", particle->Pt());
1006 fHistograms->FillHistogram("MC_DecayOmegaGamma_Pt", particle->Pt());
1009 fHistograms->FillHistogram("MC_DecayK0sGamma_Pt", particle->Pt());
1012 fHistograms->FillHistogram("MC_DecayEtapGamma_Pt", particle->Pt());
1015 fHistograms->FillHistogram("MC_DecayPhiGamma_Pt", particle->Pt());
1020 fHistograms->FillHistogram("MC_allGamma_Energy", particle->Energy());
1021 fHistograms->FillHistogram("MC_allGamma_Pt", particle->Pt());
1022 fHistograms->FillHistogram("MC_allGamma_Eta", particle->Eta());
1023 fHistograms->FillHistogram("MC_allGamma_Phi", tmpPhi);
1024 fHistograms->FillHistogram("MC_allGamma_Rapid", rapidity);
1028 containerInput[0] = particle->Pt();
1029 containerInput[1] = particle->Eta();
1030 if(particle->GetMother(0) >=0){
1031 containerInput[2] = fStack->Particle(particle->GetMother(0))->GetMass();
1034 containerInput[2]=-1;
1037 fCFManager->GetParticleContainer()->Fill(containerInput,kStepGenerated); // generated gamma
1039 if(particle->GetMother(0) < 0 || //Phojet p+p -> Direct Photons have no mother
1040 ((particle->GetMother(0) > -1) &&
1041 ((TMath::Abs(fStack->Particle(particle->GetMother(0))->GetPdgCode()) < 10)||
1042 (TMath::Abs(fStack->Particle(particle->GetMother(0))->GetPdgCode()) ==21) )) //Pythia p+p -> Direct Photons have quarksor gluons as mother
1044 fHistograms->FillHistogram("MC_allDirectGamma_Energy",particle->Energy());
1045 fHistograms->FillHistogram("MC_allDirectGamma_Pt", particle->Pt());
1046 fHistograms->FillHistogram("MC_allDirectGamma_Eta", particle->Eta());
1047 fHistograms->FillHistogram("MC_allDirectGamma_Phi", tmpPhi);
1048 fHistograms->FillHistogram("MC_allDirectGamma_Rapid", rapidity);
1051 // looking for conversion (electron + positron from pairbuilding (= 5) )
1052 TParticle* ePos = NULL;
1053 TParticle* eNeg = NULL;
1055 if(particle->GetNDaughters() >= 2){
1056 for(Int_t daughterIndex=particle->GetFirstDaughter();daughterIndex<=particle->GetLastDaughter();daughterIndex++){
1057 TParticle *tmpDaughter = fStack->Particle(daughterIndex);
1058 if(tmpDaughter->GetUniqueID() == 5){
1059 if(tmpDaughter->GetPdgCode() == 11){
1062 else if(tmpDaughter->GetPdgCode() == -11){
1070 if(ePos == NULL || eNeg == NULL){ // means we do not have two daughters from pair production
1075 Double_t ePosPhi = ePos->Phi();
1076 if(ePos->Phi()> TMath::Pi()) ePosPhi = ePos->Phi()-(2*TMath::Pi());
1078 Double_t eNegPhi = eNeg->Phi();
1079 if(eNeg->Phi()> TMath::Pi()) eNegPhi = eNeg->Phi()-(2*TMath::Pi());
1082 if(ePos->Pt()<fV0Reader->GetPtCut() || eNeg->Pt()<fV0Reader->GetPtCut()){
1083 continue; // no reconstruction below the Pt cut
1086 if(TMath::Abs(ePos->Eta())> fV0Reader->GetEtaCut() || TMath::Abs(eNeg->Eta())> fV0Reader->GetEtaCut()){
1090 if(ePos->R()>fV0Reader->GetMaxRCut()){
1091 continue; // cuts on distance from collision point
1094 if(TMath::Abs(ePos->Vz()) > fV0Reader->GetMaxZCut()){
1095 continue; // outside material
1099 if((TMath::Abs(ePos->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue() > ePos->R()){
1100 continue; // line cut to exclude regions where we do not reconstruct
1106 fCFManager->GetParticleContainer()->Fill(containerInput,kStepReconstructable); // reconstructable gamma
1108 fHistograms->FillHistogram("MC_ConvGamma_Energy", particle->Energy());
1109 fHistograms->FillHistogram("MC_ConvGamma_Pt", particle->Pt());
1110 fHistograms->FillHistogram("MC_ConvGamma_Eta", particle->Eta());
1111 fHistograms->FillHistogram("MC_ConvGamma_Phi", tmpPhi);
1112 fHistograms->FillHistogram("MC_ConvGamma_Rapid", rapidity);
1113 fHistograms->FillHistogram("MC_ConvGamma_Pt_Eta", particle->Pt(),particle->Eta());
1115 fHistograms->FillHistogram("MC_E_Energy", eNeg->Energy());
1116 fHistograms->FillHistogram("MC_E_Pt", eNeg->Pt());
1117 fHistograms->FillHistogram("MC_E_Eta", eNeg->Eta());
1118 fHistograms->FillHistogram("MC_E_Phi", eNegPhi);
1120 fHistograms->FillHistogram("MC_P_Energy", ePos->Energy());
1121 fHistograms->FillHistogram("MC_P_Pt", ePos->Pt());
1122 fHistograms->FillHistogram("MC_P_Eta", ePos->Eta());
1123 fHistograms->FillHistogram("MC_P_Phi", ePosPhi);
1127 Int_t rBin = fHistograms->GetRBin(ePos->R());
1128 Int_t zBin = fHistograms->GetZBin(ePos->Vz());
1129 Int_t phiBin = fHistograms->GetPhiBin(particle->Phi());
1131 Double_t rITSTPCMin=50;
1132 Double_t rITSTPCMax=80;
1134 TVector3 vtxPos(ePos->Vx(),ePos->Vy(),ePos->Vz());
1136 TString nameMCMappingPhiR="";
1137 nameMCMappingPhiR.Form("MC_Conversion_Mapping_Phi%02d_R%02d",phiBin,rBin);
1138 // fHistograms->FillHistogram(nameMCMappingPhiR, ePos->Vz(), particle->Eta());
1140 TString nameMCMappingPhi="";
1141 nameMCMappingPhi.Form("MC_Conversion_Mapping_Phi%02d",phiBin);
1142 // fHistograms->FillHistogram(nameMCMappingPhi, particle->Eta());
1143 //fHistograms->FillHistogram(nameMCMappingPhi, ePos->Vz(), particle->Eta());
1145 TString nameMCMappingR="";
1146 nameMCMappingR.Form("MC_Conversion_Mapping_R%02d",rBin);
1147 // fHistograms->FillHistogram(nameMCMappingR, particle->Eta());
1148 //fHistograms->FillHistogram(nameMCMappingR,ePos->Vz(), particle->Eta());
1150 TString nameMCMappingPhiInR="";
1151 nameMCMappingPhiInR.Form("MC_Conversion_Mapping_Phi_in_R_%02d",rBin);
1152 // fHistograms->FillHistogram(nameMCMappingPhiInR, tmpPhi);
1153 fHistograms->FillHistogram(nameMCMappingPhiInR, vtxPos.Phi());
1155 TString nameMCMappingZInR="";
1156 nameMCMappingZInR.Form("MC_Conversion_Mapping_Z_in_R_%02d",rBin);
1157 fHistograms->FillHistogram(nameMCMappingZInR,ePos->Vz() );
1160 TString nameMCMappingPhiInZ="";
1161 nameMCMappingPhiInZ.Form("MC_Conversion_Mapping_Phi_in_Z_%02d",zBin);
1162 // fHistograms->FillHistogram(nameMCMappingPhiInR, tmpPhi);
1163 fHistograms->FillHistogram(nameMCMappingPhiInZ, vtxPos.Phi());
1167 TString nameMCMappingFMDPhiInZ="";
1168 nameMCMappingFMDPhiInZ.Form("MC_Conversion_Mapping_FMD_Phi_in_Z_%02d",zBin);
1169 fHistograms->FillHistogram(nameMCMappingFMDPhiInZ, vtxPos.Phi());
1172 if(ePos->R()>rITSTPCMin && ePos->R()<rITSTPCMax){
1173 TString nameMCMappingITSTPCPhiInZ="";
1174 nameMCMappingITSTPCPhiInZ.Form("MC_Conversion_Mapping_ITSTPC_Phi_in_Z_%02d",zBin);
1175 fHistograms->FillHistogram(nameMCMappingITSTPCPhiInZ, vtxPos.Phi());
1178 TString nameMCMappingRInZ="";
1179 nameMCMappingRInZ.Form("MC_Conversion_Mapping_R_in_Z_%02d",zBin);
1180 fHistograms->FillHistogram(nameMCMappingRInZ,ePos->R() );
1182 if(particle->Pt() > fLowPtMapping && particle->Pt()< fHighPtMapping){
1183 TString nameMCMappingMidPtPhiInR="";
1184 nameMCMappingMidPtPhiInR.Form("MC_Conversion_Mapping_MidPt_Phi_in_R_%02d",rBin);
1185 fHistograms->FillHistogram(nameMCMappingMidPtPhiInR, vtxPos.Phi());
1187 TString nameMCMappingMidPtZInR="";
1188 nameMCMappingMidPtZInR.Form("MC_Conversion_Mapping_MidPt_Z_in_R_%02d",rBin);
1189 fHistograms->FillHistogram(nameMCMappingMidPtZInR,ePos->Vz() );
1192 TString nameMCMappingMidPtPhiInZ="";
1193 nameMCMappingMidPtPhiInZ.Form("MC_Conversion_Mapping_MidPt_Phi_in_Z_%02d",zBin);
1194 fHistograms->FillHistogram(nameMCMappingMidPtPhiInZ, vtxPos.Phi());
1198 TString nameMCMappingMidPtFMDPhiInZ="";
1199 nameMCMappingMidPtFMDPhiInZ.Form("MC_Conversion_Mapping_MidPt_FMD_Phi_in_Z_%02d",zBin);
1200 fHistograms->FillHistogram(nameMCMappingMidPtFMDPhiInZ, vtxPos.Phi());
1204 TString nameMCMappingMidPtRInZ="";
1205 nameMCMappingMidPtRInZ.Form("MC_Conversion_Mapping_MidPt_R_in_Z_%02d",zBin);
1206 fHistograms->FillHistogram(nameMCMappingMidPtRInZ,ePos->R() );
1212 fHistograms->FillHistogram("MC_Conversion_R",ePos->R());
1213 fHistograms->FillHistogram("MC_Conversion_ZR",ePos->Vz(),ePos->R());
1214 fHistograms->FillHistogram("MC_Conversion_XY",ePos->Vx(),ePos->Vy());
1215 fHistograms->FillHistogram("MC_Conversion_OpeningAngle",GetMCOpeningAngle(ePos, eNeg));
1216 fHistograms->FillHistogram("MC_ConvGamma_E_AsymmetryP",particle->P(),eNeg->P()/particle->P());
1217 fHistograms->FillHistogram("MC_ConvGamma_P_AsymmetryP",particle->P(),ePos->P()/particle->P());
1220 if(particle->GetMother(0) < 0){ // no mother = direct gamma, still inside converted
1221 fHistograms->FillHistogram("MC_ConvDirectGamma_Energy",particle->Energy());
1222 fHistograms->FillHistogram("MC_ConvDirectGamma_Pt", particle->Pt());
1223 fHistograms->FillHistogram("MC_ConvDirectGamma_Eta", particle->Eta());
1224 fHistograms->FillHistogram("MC_ConvDirectGamma_Phi", tmpPhi);
1225 fHistograms->FillHistogram("MC_ConvDirectGamma_Rapid", rapidity);
1227 } // end direct gamma
1228 else{ // mother exits
1229 /* if( fStack->Particle(particle->GetMother(0))->GetPdgCode()==10441 ||//chic0
1230 fStack->Particle(particle->GetMother(0))->GetPdgCode()==20443 ||//psi2S
1231 fStack->Particle(particle->GetMother(0))->GetPdgCode()==445 //chic2
1233 fMCGammaChic.push_back(particle);
1236 } // end if mother exits
1237 } // end if particle is a photon
1241 // process motherparticles (2 gammas as daughters)
1242 // the motherparticle had already to pass the R and the eta cut, but no line cut.
1243 // the line cut is just valid for the conversions!
1245 // RR primary Pi0 debug ////////////////////////////////////////////////////////////////////////////////////////////
1246 if (particle->GetPdgCode()==111){
1247 if( TMath::Abs(rapidity) < fV0Reader->GetRapidityMesonCut() ){
1248 fHistograms->FillHistogram("MC_Pi0_Pt_vs_Rapid_allDaughters", particle->Pt(),rapidity);
1251 // end RR primary Pi0 debug ////////////////////////////////////////////////////////////////////////////////////////
1253 if(particle->GetNDaughters() == 2){
1255 TParticle* daughter0 = (TParticle*)fStack->Particle(particle->GetFirstDaughter());
1256 TParticle* daughter1 = (TParticle*)fStack->Particle(particle->GetLastDaughter());
1258 if(daughter0->GetPdgCode() != 22 || daughter1->GetPdgCode() != 22) continue; //check for gamma gamma daughters
1260 if(TMath::Abs(rapidity) > fV0Reader->GetRapidityMesonCut() ) continue;
1262 // Check the acceptance for both gammas
1263 Bool_t gammaEtaCut = kTRUE;
1264 if(TMath::Abs(daughter0->Eta()) > fV0Reader->GetEtaCut() || TMath::Abs(daughter1->Eta()) > fV0Reader->GetEtaCut() ) gammaEtaCut = kFALSE;
1265 Bool_t gammaRCut = kTRUE;
1266 if(daughter0->R() > fV0Reader->GetMaxRCut() || daughter1->R() > fV0Reader->GetMaxRCut() ) gammaRCut = kFALSE;
1270 // check for conversions now -> have to pass eta, R and line cut!
1271 Bool_t daughter0Electron = kFALSE;
1272 Bool_t daughter0Positron = kFALSE;
1273 Bool_t daughter1Electron = kFALSE;
1274 Bool_t daughter1Positron = kFALSE;
1276 if(daughter0->GetNDaughters() >= 2){ // first gamma
1277 for(Int_t TrackIndex=daughter0->GetFirstDaughter();TrackIndex<=daughter0->GetLastDaughter();TrackIndex++){
1278 TParticle *tmpDaughter = fStack->Particle(TrackIndex);
1279 if(tmpDaughter->GetUniqueID() == 5){
1280 if(tmpDaughter->GetPdgCode() == 11){
1281 if( TMath::Abs(tmpDaughter->Eta()) <= fV0Reader->GetEtaCut() ){
1282 if( ( TMath::Abs(tmpDaughter->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue() < tmpDaughter->R() ){
1283 if(tmpDaughter->R()< fV0Reader->GetMaxRCut()){
1284 daughter0Electron = kTRUE;
1290 else if(tmpDaughter->GetPdgCode() == -11){
1291 if( TMath::Abs(tmpDaughter->Eta()) <= fV0Reader->GetEtaCut() ){
1292 if( ( TMath::Abs(tmpDaughter->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue() < tmpDaughter->R() ){
1293 if(tmpDaughter->R()< fV0Reader->GetMaxRCut()){
1294 daughter0Positron = kTRUE;
1304 if(daughter1->GetNDaughters() >= 2){ // second gamma
1305 for(Int_t TrackIndex=daughter1->GetFirstDaughter();TrackIndex<=daughter1->GetLastDaughter();TrackIndex++){
1306 TParticle *tmpDaughter = fStack->Particle(TrackIndex);
1307 if(tmpDaughter->GetUniqueID() == 5){
1308 if(tmpDaughter->GetPdgCode() == 11){
1309 if( TMath::Abs(tmpDaughter->Eta()) <= fV0Reader->GetEtaCut() ){
1310 if( ( TMath::Abs(tmpDaughter->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue() < tmpDaughter->R() ){
1311 if(tmpDaughter->R()< fV0Reader->GetMaxRCut()){
1312 daughter1Electron = kTRUE;
1318 else if(tmpDaughter->GetPdgCode() == -11){
1319 if( TMath::Abs(tmpDaughter->Eta()) <= fV0Reader->GetEtaCut() ){
1320 if( ( TMath::Abs(tmpDaughter->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue() < tmpDaughter->R() ){
1321 if(tmpDaughter->R()< fV0Reader->GetMaxRCut()){
1322 daughter1Positron = kTRUE;
1334 if(particle->GetPdgCode()==111){ //Pi0
1335 if( iTracks >= fStack->GetNprimary()){
1336 fHistograms->FillHistogram("MC_Pi0_Secondaries_Eta", particle->Eta());
1337 fHistograms->FillHistogram("MC_Pi0_Secondaries_Rapid", rapidity);
1338 fHistograms->FillHistogram("MC_Pi0_Secondaries_Phi", tmpPhi);
1339 fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt", particle->Pt());
1340 fHistograms->FillHistogram("MC_Pi0_Secondaries_Energy", particle->Energy());
1341 fHistograms->FillHistogram("MC_Pi0_Secondaries_R", particle->R());
1342 fHistograms->FillHistogram("MC_Pi0_Secondaries_ZR", particle->Vz(),particle->R());
1343 fHistograms->FillHistogram("MC_Pi0_Secondaries_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));
1344 fHistograms->FillHistogram("MC_Pi0_Secondaries_XY", particle->Vx(),particle->Vy());//only fill from one daughter to avoid multiple filling
1346 if(gammaEtaCut && gammaRCut){
1347 //if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){
1348 fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt_Eta_withinAcceptance", particle->Pt(),particle->Eta());
1349 fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt_Rapid_withinAcceptance", particle->Pt(),rapidity);
1350 if(daughter0Electron && daughter0Positron && daughter1Electron && daughter1Positron){
1351 fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt_Eta_ConvGamma_withinAcceptance", particle->Pt(),particle->Eta());
1352 fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt_Rapid_ConvGamma_withinAcceptance", particle->Pt(),rapidity);
1357 fHistograms->FillHistogram("MC_Pi0_Eta", particle->Eta());
1358 fHistograms->FillHistogram("MC_Pi0_Rapid", rapidity);
1359 fHistograms->FillHistogram("MC_Pi0_Phi", tmpPhi);
1360 fHistograms->FillHistogram("MC_Pi0_Pt", particle->Pt());
1361 fHistograms->FillHistogram("MC_Pi0_Pt_vs_Rapid", particle->Pt(),rapidity);
1362 fHistograms->FillHistogram("MC_Pi0_Energy", particle->Energy());
1363 fHistograms->FillHistogram("MC_Pi0_R", particle->R());
1364 fHistograms->FillHistogram("MC_Pi0_ZR", particle->Vz(),particle->R());
1365 fHistograms->FillHistogram("MC_Pi0_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));
1366 fHistograms->FillHistogram("MC_Pi0_XY", particle->Vx(), particle->Vy());//only fill from one daughter to avoid multiple filling
1367 if(TMath::Abs(particle->Eta())<0.9)fHistograms->FillHistogram("MC_Pi0_Pt_Fiducial", particle->Pt());
1369 if(!fV0Reader->GetIsHeavyIon()) {
1371 switch(GetProcessType(fGCMCEvent)){
1373 fHistograms->FillHistogram("MC_SD_EvtQ3_Pi0_Pt", particle->Pt());
1376 fHistograms->FillHistogram("MC_DD_EvtQ3_Pi0_Pt", particle->Pt());
1379 fHistograms->FillHistogram("MC_ND_EvtQ3_Pi0_Pt", particle->Pt());
1382 AliError("Unknown Process");
1385 if(gammaEtaCut && gammaRCut){
1386 // if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){
1387 fHistograms->FillHistogram("MC_Pi0_Pt_Eta_withinAcceptance", particle->Pt(),particle->Eta());
1388 fHistograms->FillHistogram("MC_Pi0_Pt_Rapid_withinAcceptance", particle->Pt(),rapidity);
1389 if(TMath::Abs(particle->Eta())<0.9)fHistograms->FillHistogram("MC_Pi0_Pt_withinAcceptance_Fiducial", particle->Pt());
1391 if(daughter0Electron && daughter0Positron && daughter1Electron && daughter1Positron){
1392 fHistograms->FillHistogram("MC_Pi0_Pt_Eta_ConvGamma_withinAcceptance", particle->Pt(),particle->Eta());
1393 fHistograms->FillHistogram("MC_Pi0_Pt_Rapid_ConvGamma_withinAcceptance", particle->Pt(),rapidity);
1394 fHistograms->FillHistogram("MC_Pi0_ZR_ConvGamma_withinAcceptance", particle->Vz(),particle->R());
1395 fHistograms->FillHistogram("MC_Pi0_ConvGamma_OpeningAngle_Pt", particle->Pt(),GetMCOpeningAngle(daughter0,daughter1));
1396 fHistograms->FillHistogram("MC_Pi0_ConvGamma_PtGamma_Pt", particle->Pt(),daughter0->Pt());
1397 fHistograms->FillHistogram("MC_Pi0_ConvGamma_PtGamma_Pt", particle->Pt(),daughter1->Pt());
1400 if((daughter0->Energy()+daughter1->Energy()) > 0.){
1401 alfa= TMath::Abs((daughter0->Energy()-daughter1->Energy())/(daughter0->Energy()+daughter1->Energy()));
1403 fHistograms->FillHistogram("MC_Pi0_alpha",alfa);
1404 if(TMath::Abs(particle->Eta())<0.9)fHistograms->FillHistogram("MC_Pi0_Pt_ConvGamma_withinAcceptance_Fiducial", particle->Pt());
1411 if(particle->GetPdgCode()==221){ //Eta
1412 fHistograms->FillHistogram("MC_Eta_Eta", particle->Eta());
1413 fHistograms->FillHistogram("MC_Eta_Rapid", rapidity);
1414 fHistograms->FillHistogram("MC_Eta_Phi",tmpPhi);
1415 fHistograms->FillHistogram("MC_Eta_Pt", particle->Pt());
1416 fHistograms->FillHistogram("MC_Eta_Pt_vs_Rapid", particle->Pt(),rapidity);
1417 fHistograms->FillHistogram("MC_Eta_Energy", particle->Energy());
1418 fHistograms->FillHistogram("MC_Eta_R", particle->R());
1419 fHistograms->FillHistogram("MC_Eta_ZR", particle->Vz(),particle->R());
1420 fHistograms->FillHistogram("MC_Eta_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));
1421 fHistograms->FillHistogram("MC_Eta_XY", particle->Vx(), particle->Vy());//only fill from one daughter to avoid multiple filling
1423 if(gammaEtaCut && gammaRCut){
1424 // if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){
1425 fHistograms->FillHistogram("MC_Eta_Pt_Eta_withinAcceptance", particle->Pt(),particle->Eta());
1426 fHistograms->FillHistogram("MC_Eta_Pt_Rapid_withinAcceptance", particle->Pt(),rapidity);
1427 if(daughter0Electron && daughter0Positron && daughter1Electron && daughter1Positron){
1428 fHistograms->FillHistogram("MC_Eta_Pt_Eta_ConvGamma_withinAcceptance", particle->Pt(),particle->Eta());
1429 fHistograms->FillHistogram("MC_Eta_Pt_Rapid_ConvGamma_withinAcceptance", particle->Pt(),rapidity);
1430 fHistograms->FillHistogram("MC_Eta_ZR_ConvGamma_withinAcceptance", particle->Vz(),particle->R());
1431 fHistograms->FillHistogram("MC_Eta_ConvGamma_OpeningAngle_Pt", particle->Pt(),GetMCOpeningAngle(daughter0,daughter1));
1432 fHistograms->FillHistogram("MC_Eta_ConvGamma_PtGamma_Pt", particle->Pt(),daughter0->Pt());
1433 fHistograms->FillHistogram("MC_Eta_ConvGamma_PtGamma_Pt", particle->Pt(),daughter1->Pt());
1436 if((daughter0->Energy()+daughter1->Energy()) > 0.){
1437 alfa= TMath::Abs((daughter0->Energy()-daughter1->Energy())/(daughter0->Energy()+daughter1->Energy()));
1439 fHistograms->FillHistogram("MC_Eta_alpha",alfa);
1447 // all motherparticles with 2 gammas as daughters
1448 fHistograms->FillHistogram("MC_Mother_R", particle->R());
1449 fHistograms->FillHistogram("MC_Mother_ZR", particle->Vz(),particle->R());
1450 fHistograms->FillHistogram("MC_Mother_XY", particle->Vx(),particle->Vy());
1451 fHistograms->FillHistogram("MC_Mother_Mass", particle->GetCalcMass());
1452 fHistograms->FillHistogram("MC_Mother_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));
1453 fHistograms->FillHistogram("MC_Mother_Energy", particle->Energy());
1454 fHistograms->FillHistogram("MC_Mother_Pt", particle->Pt());
1455 fHistograms->FillHistogram("MC_Mother_Eta", particle->Eta());
1456 fHistograms->FillHistogram("MC_Mother_Rapid", rapidity);
1457 fHistograms->FillHistogram("MC_Mother_Phi",tmpPhi);
1458 fHistograms->FillHistogram("MC_Mother_InvMass_vs_Pt",particle->GetMass(),particle->Pt());
1460 if(gammaEtaCut && gammaRCut){
1461 // if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){
1462 fHistograms->FillHistogram("MC_Mother_Pt_Eta_withinAcceptance", particle->Pt(),particle->Eta());
1463 fHistograms->FillHistogram("MC_Mother_Pt_Rapid_withinAcceptance", particle->Pt(),rapidity);
1464 fHistograms->FillHistogram("MC_Mother_InvMass_vs_Pt_withinAcceptance",particle->GetMass(),particle->Pt());
1465 if(daughter0Electron && daughter0Positron && daughter1Electron && daughter1Positron){
1466 fHistograms->FillHistogram("MC_Mother_Pt_Eta_ConvGamma_withinAcceptance", particle->Pt(),particle->Eta());
1467 fHistograms->FillHistogram("MC_Mother_Pt_Rapid_ConvGamma_withinAcceptance", particle->Pt(),rapidity);
1468 fHistograms->FillHistogram("MC_Mother_InvMass_vs_Pt_ConvGamma_withinAcceptance",particle->GetMass(),particle->Pt());
1473 } // end passed R and eta cut
1475 } // end if(particle->GetNDaughters() == 2)
1477 }// end for (Int_t iTracks = 0; iTracks < fStack->GetNtrack(); iTracks++)
1479 } // end ProcessMCData
1483 void AliAnalysisTaskGammaConversion::FillNtuple(){
1484 //Fills the ntuple with the different values
1486 if(fGammaNtuple == NULL){
1489 Int_t numberOfV0s = fV0Reader->GetNumberOfV0s();
1490 for(Int_t i=0;i<numberOfV0s;i++){
1491 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};
1492 AliESDv0 * cV0 = fV0Reader->GetV0(i);
1495 fV0Reader->GetPIDProbability(negPID,posPID);
1496 values[0]=cV0->GetOnFlyStatus();
1497 values[1]=fV0Reader->CheckForPrimaryVertex();
1500 values[4]=fV0Reader->GetX();
1501 values[5]=fV0Reader->GetY();
1502 values[6]=fV0Reader->GetZ();
1503 values[7]=fV0Reader->GetXYRadius();
1504 values[8]=fV0Reader->GetMotherCandidateNDF();
1505 values[9]=fV0Reader->GetMotherCandidateChi2();
1506 values[10]=fV0Reader->GetMotherCandidateEnergy();
1507 values[11]=fV0Reader->GetMotherCandidateEta();
1508 values[12]=fV0Reader->GetMotherCandidatePt();
1509 values[13]=fV0Reader->GetMotherCandidateMass();
1510 values[14]=fV0Reader->GetMotherCandidateWidth();
1511 // values[15]=fV0Reader->GetMotherMCParticle()->Pt(); MOVED TO THE END, HAS TO BE CALLED AFTER HasSameMother NB: still has the same entry in the array
1512 values[16]=fV0Reader->GetOpeningAngle();
1513 values[17]=fV0Reader->GetNegativeTrackEnergy();
1514 values[18]=fV0Reader->GetNegativeTrackPt();
1515 values[19]=fV0Reader->GetNegativeTrackEta();
1516 values[20]=fV0Reader->GetNegativeTrackPhi();
1517 values[21]=fV0Reader->GetPositiveTrackEnergy();
1518 values[22]=fV0Reader->GetPositiveTrackPt();
1519 values[23]=fV0Reader->GetPositiveTrackEta();
1520 values[24]=fV0Reader->GetPositiveTrackPhi();
1521 values[25]=fV0Reader->HasSameMCMother();
1522 if(values[25] != 0){
1523 values[26]=fV0Reader->GetMotherMCParticlePDGCode();
1524 values[15]=fV0Reader->GetMotherMCParticle()->Pt();
1526 fTotalNumberOfAddedNtupleEntries++;
1527 fGammaNtuple->Fill(values);
1529 fV0Reader->ResetV0IndexNumber();
1533 void AliAnalysisTaskGammaConversion::ProcessV0sNoCut(){
1534 // Process all the V0's without applying any cuts to it
1536 Int_t numberOfV0s = fV0Reader->GetNumberOfV0s();
1537 for(Int_t i=0;i<numberOfV0s;i++){
1538 /*AliESDv0 * cV0 = */fV0Reader->GetV0(i);
1540 if(fV0Reader->CheckForPrimaryVertex() == kFALSE){
1544 // if( !fV0Reader->GetV0(i)->GetOnFlyStatus()){
1545 if( !fV0Reader->CheckV0FinderStatus(i)){
1550 if( !((fV0Reader->GetNegativeESDTrack())->GetStatus() & AliESDtrack::kTPCrefit) ||
1551 !((fV0Reader->GetPositiveESDTrack())->GetStatus() & AliESDtrack::kTPCrefit) ){
1555 if( fV0Reader->GetNegativeESDTrack()->GetSign()== fV0Reader->GetPositiveESDTrack()->GetSign()){
1559 if( fV0Reader->GetNegativeESDTrack()->GetKinkIndex(0) > 0 ||
1560 fV0Reader->GetPositiveESDTrack()->GetKinkIndex(0) > 0) {
1563 if(TMath::Abs(fV0Reader->GetMotherCandidateEta())> fV0Reader->GetEtaCut()){
1566 if(TMath::Abs(fV0Reader->GetPositiveTrackEta())> fV0Reader->GetEtaCut()){
1569 if(TMath::Abs(fV0Reader->GetNegativeTrackEta())> fV0Reader->GetEtaCut()){
1572 if((TMath::Abs(fV0Reader->GetZ())*fV0Reader->GetLineCutZRSlope())-fV0Reader->GetLineCutZValue() > fV0Reader->GetXYRadius() ){ // cuts out regions where we do not reconstruct
1576 fHistograms->FillHistogram("ESD_NoCutAllV0_Pt", fV0Reader->GetMotherCandidatePt());
1578 // RRnewTOF start ///////////////////////////////////////////////
1579 UInt_t statusPos = fV0Reader->GetPositiveESDTrack()->GetStatus();
1580 UInt_t statusNeg = fV0Reader->GetNegativeESDTrack()->GetStatus();
1582 Double_t t0pos = fV0Reader->GetESDpid()->GetTOFResponse().GetStartTime(fV0Reader->GetPositiveTrackP());
1583 Double_t t0neg = fV0Reader->GetESDpid()->GetTOFResponse().GetStartTime(fV0Reader->GetNegativeTrackP());
1585 Double_t timesPos[5];
1586 fV0Reader->GetPositiveESDTrack()->GetIntegratedTimes(timesPos);
1587 Double_t timesNeg[5];
1588 fV0Reader->GetNegativeESDTrack()->GetIntegratedTimes(timesNeg);
1590 Double_t TOFsignalPos = fV0Reader->GetPositiveTrackTOFsignal();
1591 Double_t TOFsignalNeg = fV0Reader->GetNegativeTrackTOFsignal();
1593 Double_t dTpos = TOFsignalPos - t0pos - timesPos[0];
1594 Double_t dTneg = TOFsignalNeg - t0neg - timesNeg[0];
1596 if(statusPos & AliESDtrack::kTOFpid) fHistograms->FillHistogram("ESD_NoCutConvGamma_EandP_P_dT", fV0Reader->GetPositiveTrackP(), dTpos);
1597 if(statusNeg & AliESDtrack::kTOFpid) fHistograms->FillHistogram("ESD_NoCutConvGamma_EandP_P_dT", fV0Reader->GetNegativeTrackP(), dTneg);
1598 // RRnewTOF end /////////////////////////////////////////////////
1602 if(fV0Reader->HasSameMCMother() == kFALSE){
1606 TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
1607 TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
1609 if(TMath::Abs(negativeMC->GetPdgCode())!=11 || TMath::Abs(positiveMC->GetPdgCode())!=11){
1612 if(negativeMC->GetPdgCode() == positiveMC->GetPdgCode()){
1616 if(negativeMC->GetUniqueID() != 5 || positiveMC->GetUniqueID() !=5){ // id 5 is conversion
1620 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
1622 fHistograms->FillHistogram("ESD_NoCutConvGamma_Pt", fV0Reader->GetMotherCandidatePt());
1623 fHistograms->FillHistogram("ESD_NoCutConvGamma_Energy", fV0Reader->GetMotherCandidateEnergy());
1624 fHistograms->FillHistogram("ESD_NoCutConvGamma_Eta", fV0Reader->GetMotherCandidateEta());
1625 fHistograms->FillHistogram("ESD_NoCutConvGamma_Phi", fV0Reader->GetMotherCandidatePhi());
1626 fHistograms->FillHistogram("ESD_NoCutConvGamma_Mass", fV0Reader->GetMotherCandidateMass());
1627 fHistograms->FillHistogram("ESD_NoCutConvGamma_Width", fV0Reader->GetMotherCandidateWidth());
1628 fHistograms->FillHistogram("ESD_NoCutConvGamma_Chi2", fV0Reader->GetMotherCandidateChi2());
1629 fHistograms->FillHistogram("ESD_NoCutConvGamma_NDF", fV0Reader->GetMotherCandidateNDF());
1630 fHistograms->FillHistogram("ESD_NoCutConvGamma_Rapid", fV0Reader->GetMotherCandidateRapidity());
1631 fHistograms->FillHistogram("ESD_NoCutConvGamma_Pt_Eta", fV0Reader->GetMotherCandidatePt(),fV0Reader->GetMotherCandidateEta());
1633 fHistograms->FillHistogram("ESD_NoCutConvGamma_Pt_Chi2", fV0Reader->GetMotherCandidatePt(), fV0Reader->GetMotherCandidateChi2());
1634 fHistograms->FillHistogram("ESD_NoCutConvGamma_Eta_Chi2", fV0Reader->GetMotherCandidateEta(), fV0Reader->GetMotherCandidateChi2());
1636 fHistograms->FillHistogram("ESD_NoCutConversion_XY", fV0Reader->GetX(),fV0Reader->GetY());
1637 fHistograms->FillHistogram("ESD_NoCutConversion_R", fV0Reader->GetXYRadius());
1638 fHistograms->FillHistogram("ESD_NoCutConversion_ZR", fV0Reader->GetZ(),fV0Reader->GetXYRadius());
1639 fHistograms->FillHistogram("ESD_NoCutConversion_OpeningAngle", fV0Reader->GetOpeningAngle());
1640 fHistograms->FillHistogram("ESD_NoCutConvGamma_CosPointingAngle", fV0Reader->GetCosPointingAngle());
1641 fHistograms->FillHistogram("ESD_NoCutConvGamma_DcaDaughters", fV0Reader->GetDcaDaughters());
1642 fHistograms->FillHistogram("ESD_NoCutConvGamma_NormDcaDistDaughters", fV0Reader->GetNormDcaDistDaughters());
1643 fHistograms->FillHistogram("ESD_NoCutConvGamma_LikelihoodAP", fV0Reader->GetLikelihoodAP());
1645 fHistograms->FillHistogram("ESD_NoCutConvGamma_E_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetNegativeTrackP()/fV0Reader->GetMotherCandidateP());
1646 fHistograms->FillHistogram("ESD_NoCutConvGamma_P_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetPositiveTrackP()/fV0Reader->GetMotherCandidateP());
1647 fHistograms->FillHistogram("ESD_NoCutConvGamma_E_dEdxP",fV0Reader->GetNegativeTrackP(),fV0Reader->GetNegativeTrackTPCdEdx());
1648 fHistograms->FillHistogram("ESD_NoCutConvGamma_P_dEdxP",fV0Reader->GetPositiveTrackP(),fV0Reader->GetPositiveTrackTPCdEdx());
1650 //store MCTruth properties
1651 fHistograms->FillHistogram("ESD_NoCutConvGamma_MC_Pt_Eta", fV0Reader->GetMotherMCParticle()->Pt(),fV0Reader->GetMotherMCParticle()->Eta());
1652 fHistograms->FillHistogram("ESD_NoCutConversion_MC_ZR", negativeMC->Vz(),negativeMC->R());
1653 fHistograms->FillHistogram("ESD_NoCutConversion_MC_XY", negativeMC->Vx(),negativeMC->Vy());
1657 fV0Reader->ResetV0IndexNumber();
1660 void AliAnalysisTaskGammaConversion::ProcessV0s(){
1661 // see header file for documentation
1664 if(fWriteNtuple == kTRUE){
1668 Int_t nSurvivingV0s=0;
1669 fV0Reader->ResetNGoodV0s();
1670 while(fV0Reader->NextV0()){
1674 TVector3 vtxConv(fV0Reader->GetX(),fV0Reader->GetY(), fV0Reader->GetZ());
1676 //-------------------------- filling v0 information -------------------------------------
1677 fHistograms->FillHistogram("ESD_Conversion_R", fV0Reader->GetXYRadius());
1678 fHistograms->FillHistogram("ESD_Conversion_ZR", fV0Reader->GetZ(),fV0Reader->GetXYRadius());
1679 fHistograms->FillHistogram("ESD_Conversion_XY", fV0Reader->GetX(),fV0Reader->GetY());
1680 fHistograms->FillHistogram("ESD_Conversion_OpeningAngle", fV0Reader->GetOpeningAngle());
1682 // Specific histograms for beam pipe studies
1683 if( TMath::Abs(fV0Reader->GetZ()) < fV0Reader->GetLineCutZValue() ){
1684 fHistograms->FillHistogram("ESD_Conversion_XY_BeamPipe", fV0Reader->GetX(),fV0Reader->GetY());
1685 fHistograms->FillHistogram("ESD_Conversion_RPhi_BeamPipe", vtxConv.Phi(),fV0Reader->GetXYRadius());
1689 fHistograms->FillHistogram("ESD_E_Energy", fV0Reader->GetNegativeTrackEnergy());
1690 fHistograms->FillHistogram("ESD_E_Pt", fV0Reader->GetNegativeTrackPt());
1691 fHistograms->FillHistogram("ESD_E_Eta", fV0Reader->GetNegativeTrackEta());
1692 fHistograms->FillHistogram("ESD_E_Phi", fV0Reader->GetNegativeTrackPhi());
1693 fHistograms->FillHistogram("ESD_E_nTPCClusters", fV0Reader->GetNegativeTracknTPCClusters());
1694 fHistograms->FillHistogram("ESD_E_nITSClusters", fV0Reader->GetNegativeTracknITSClusters());
1695 Double_t eClsToF= 0;
1696 if(!fV0Reader->GetUseCorrectedTPCClsInfo()){
1697 if(fV0Reader->GetNegativeTracknTPCFClusters()!=0 ){
1698 eClsToF=(Double_t)fV0Reader->GetNegativeTracknTPCClusters()/(Double_t)fV0Reader->GetNegativeTracknTPCFClusters();
1701 eClsToF= fV0Reader->GetNegativeESDTrack()->GetTPCClusterInfo(2,0,fV0Reader->GetFirstTPCRow(fV0Reader->GetXYRadius()));
1703 fHistograms->FillHistogram("ESD_E_nTPCClustersToFP", fV0Reader->GetNegativeTrackP(),eClsToF );
1704 fHistograms->FillHistogram("ESD_E_nTPCClustersToFR", fV0Reader->GetXYRadius(),eClsToF );
1706 if(fV0Reader->GetNegativeTracknTPCClusters()!=0 ){
1707 fHistograms->FillHistogram("ESD_E_TPCchi2", fV0Reader->GetNegativeTrackTPCchi2()/(Double_t)fV0Reader->GetNegativeTracknTPCClusters());
1712 fHistograms->FillHistogram("ESD_P_Energy", fV0Reader->GetPositiveTrackEnergy());
1713 fHistograms->FillHistogram("ESD_P_Pt", fV0Reader->GetPositiveTrackPt());
1714 fHistograms->FillHistogram("ESD_P_Eta", fV0Reader->GetPositiveTrackEta());
1715 fHistograms->FillHistogram("ESD_P_Phi", fV0Reader->GetPositiveTrackPhi());
1716 fHistograms->FillHistogram("ESD_P_nTPCClusters", fV0Reader->GetPositiveTracknTPCClusters());
1717 fHistograms->FillHistogram("ESD_P_nITSClusters", fV0Reader->GetPositiveTracknITSClusters());
1718 Double_t pClsToF= 0;
1719 if(!fV0Reader->GetUseCorrectedTPCClsInfo()){
1720 if(fV0Reader->GetPositiveTracknTPCFClusters()!=0){
1721 pClsToF = (Double_t)fV0Reader->GetPositiveTracknTPCClusters()/(Double_t)fV0Reader->GetPositiveTracknTPCFClusters();
1724 pClsToF= fV0Reader->GetPositiveESDTrack()->GetTPCClusterInfo(2,0,fV0Reader->GetFirstTPCRow(fV0Reader->GetXYRadius()));
1727 fHistograms->FillHistogram("ESD_P_nTPCClustersToFP",fV0Reader->GetPositiveTrackP(), pClsToF);
1728 fHistograms->FillHistogram("ESD_P_nTPCClustersToFR",fV0Reader->GetXYRadius(), pClsToF);
1730 if(fV0Reader->GetPositiveTracknTPCClusters()!=0){
1731 fHistograms->FillHistogram("ESD_P_TPCchi2", fV0Reader->GetPositiveTrackTPCchi2()/(Double_t)fV0Reader->GetPositiveTracknTPCClusters());
1736 fHistograms->FillHistogram("ESD_ConvGamma_Energy", fV0Reader->GetMotherCandidateEnergy());
1737 fHistograms->FillHistogram("ESD_ConvGamma_Pt", fV0Reader->GetMotherCandidatePt());
1738 fHistograms->FillHistogram("ESD_ConvGamma_Eta", fV0Reader->GetMotherCandidateEta());
1739 fHistograms->FillHistogram("ESD_ConvGamma_Phi", fV0Reader->GetMotherCandidatePhi());
1740 fHistograms->FillHistogram("ESD_ConvGamma_Mass", fV0Reader->GetMotherCandidateMass());
1741 fHistograms->FillHistogram("ESD_ConvGamma_Width", fV0Reader->GetMotherCandidateWidth());
1742 fHistograms->FillHistogram("ESD_ConvGamma_Chi2", fV0Reader->GetMotherCandidateChi2());
1743 fHistograms->FillHistogram("ESD_ConvGamma_NDF", fV0Reader->GetMotherCandidateNDF());
1744 fHistograms->FillHistogram("ESD_ConvGamma_Rapid", fV0Reader->GetMotherCandidateRapidity());
1745 fHistograms->FillHistogram("ESD_ConvGamma_Pt_Eta", fV0Reader->GetMotherCandidatePt(),fV0Reader->GetMotherCandidateEta());
1747 fHistograms->FillHistogram("ESD_ConvGamma_Pt_Chi2", fV0Reader->GetMotherCandidatePt(), fV0Reader->GetMotherCandidateChi2());
1748 fHistograms->FillHistogram("ESD_ConvGamma_Eta_Chi2", fV0Reader->GetMotherCandidateEta(), fV0Reader->GetMotherCandidateChi2());
1750 fHistograms->FillHistogram("ESD_ConvGamma_CosPointingAngle", fV0Reader->GetCosPointingAngle());
1751 fHistograms->FillHistogram("ESD_ConvGamma_DcaDaughters", fV0Reader->GetDcaDaughters());
1752 fHistograms->FillHistogram("ESD_ConvGamma_NormDcaDistDaughters", fV0Reader->GetNormDcaDistDaughters());
1753 fHistograms->FillHistogram("ESD_ConvGamma_LikelihoodAP", fV0Reader->GetLikelihoodAP());
1755 fHistograms->FillHistogram("ESD_ConvGamma_E_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetNegativeTrackP()/fV0Reader->GetMotherCandidateP());
1756 fHistograms->FillHistogram("ESD_ConvGamma_P_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetPositiveTrackP()/fV0Reader->GetMotherCandidateP());
1757 fHistograms->FillHistogram("ESD_ConvGamma_E_dEdxP",fV0Reader->GetNegativeTrackP(),fV0Reader->GetNegativeTrackTPCdEdx());
1758 fHistograms->FillHistogram("ESD_ConvGamma_P_dEdxP",fV0Reader->GetPositiveTrackP(),fV0Reader->GetPositiveTrackTPCdEdx());
1760 UInt_t statusPos = fV0Reader->GetPositiveESDTrack()->GetStatus(); //moved up here from below RRnewTOF
1761 UInt_t statusNeg = fV0Reader->GetNegativeESDTrack()->GetStatus();
1762 // RRnewTOF start ///////////////////////////////////////////////
1763 Double_t t0pos = fV0Reader->GetESDpid()->GetTOFResponse().GetStartTime(fV0Reader->GetPositiveTrackP());
1764 Double_t t0neg = fV0Reader->GetESDpid()->GetTOFResponse().GetStartTime(fV0Reader->GetNegativeTrackP());
1766 Double_t timesPos[5];
1767 fV0Reader->GetPositiveESDTrack()->GetIntegratedTimes(timesPos);
1768 Double_t timesNeg[5];
1769 fV0Reader->GetNegativeESDTrack()->GetIntegratedTimes(timesNeg);
1771 Double_t TOFsignalPos = fV0Reader->GetPositiveTrackTOFsignal();
1772 Double_t TOFsignalNeg = fV0Reader->GetNegativeTrackTOFsignal();
1774 Double_t dTpos = TOFsignalPos - t0pos - timesPos[0];
1775 Double_t dTneg = TOFsignalNeg - t0neg - timesNeg[0];
1777 if(statusPos & AliESDtrack::kTOFpid) fHistograms->FillHistogram("ESD_ConvGamma_EandP_P_dT", fV0Reader->GetPositiveTrackP(), dTpos);
1778 if(statusNeg & AliESDtrack::kTOFpid) fHistograms->FillHistogram("ESD_ConvGamma_EandP_P_dT", fV0Reader->GetNegativeTrackP(), dTneg);
1779 // RRnewTOF end /////////////////////////////////////////////////
1783 fV0Reader->GetPIDProbability(negPID,posPID);
1784 fHistograms->FillHistogram("ESD_ConvGamma_E_EProbP",fV0Reader->GetNegativeTrackP(),negPID);
1785 fHistograms->FillHistogram("ESD_ConvGamma_P_EProbP",fV0Reader->GetPositiveTrackP(),posPID);
1787 Double_t negPIDmupi=0;
1788 Double_t posPIDmupi=0;
1789 fV0Reader->GetPIDProbabilityMuonPion(negPIDmupi,posPIDmupi);
1790 fHistograms->FillHistogram("ESD_ConvGamma_E_mupiProbP",fV0Reader->GetNegativeTrackP(),negPIDmupi);
1791 fHistograms->FillHistogram("ESD_ConvGamma_P_mupiProbP",fV0Reader->GetPositiveTrackP(),posPIDmupi);
1793 Double_t armenterosQtAlfa[2];
1794 fV0Reader->GetArmenterosQtAlfa(fV0Reader-> GetNegativeKFParticle(),
1795 fV0Reader-> GetPositiveKFParticle(),
1796 fV0Reader->GetMotherCandidateKFCombination(),
1799 fHistograms->FillHistogram("ESD_ConvGamma_alfa_qt",armenterosQtAlfa[1],armenterosQtAlfa[0]);
1803 Int_t rBin = fHistograms->GetRBin(fV0Reader->GetXYRadius());
1804 Int_t zBin = fHistograms->GetZBin(fV0Reader->GetZ());
1805 Int_t phiBin = fHistograms->GetPhiBin(fV0Reader->GetNegativeTrackPhi());
1807 Double_t rITSTPCMin=50;
1808 Double_t rITSTPCMax=80;
1811 // Double_t motherCandidateEta= fV0Reader->GetMotherCandidateEta();
1813 TString nameESDMappingPhiR="";
1814 nameESDMappingPhiR.Form("ESD_Conversion_Mapping_Phi%02d_R%02d",phiBin,rBin);
1815 //fHistograms->FillHistogram(nameESDMappingPhiR, fV0Reader->GetZ(), motherCandidateEta);
1817 TString nameESDMappingPhi="";
1818 nameESDMappingPhi.Form("ESD_Conversion_Mapping_Phi%02d",phiBin);
1819 //fHistograms->FillHistogram(nameESDMappingPhi, fV0Reader->GetZ(), motherCandidateEta);
1821 TString nameESDMappingR="";
1822 nameESDMappingR.Form("ESD_Conversion_Mapping_R%02d",rBin);
1823 //fHistograms->FillHistogram(nameESDMappingR, fV0Reader->GetZ(), motherCandidateEta);
1825 TString nameESDMappingPhiInR="";
1826 nameESDMappingPhiInR.Form("ESD_Conversion_Mapping_Phi_in_R_%02d",rBin);
1827 // fHistograms->FillHistogram(nameESDMappingPhiInR, fV0Reader->GetMotherCandidatePhi());
1828 fHistograms->FillHistogram(nameESDMappingPhiInR, vtxConv.Phi());
1830 TString nameESDMappingZInR="";
1831 nameESDMappingZInR.Form("ESD_Conversion_Mapping_Z_in_R_%02d",rBin);
1832 fHistograms->FillHistogram(nameESDMappingZInR, fV0Reader->GetZ());
1834 TString nameESDMappingPhiInZ="";
1835 nameESDMappingPhiInZ.Form("ESD_Conversion_Mapping_Phi_in_Z_%02d",zBin);
1836 // fHistograms->FillHistogram(nameESDMappingPhiInR, fV0Reader->GetMotherCandidatePhi());
1837 fHistograms->FillHistogram(nameESDMappingPhiInZ, vtxConv.Phi());
1839 if(fV0Reader->GetXYRadius()<rFMD){
1840 TString nameESDMappingFMDPhiInZ="";
1841 nameESDMappingFMDPhiInZ.Form("ESD_Conversion_Mapping_FMD_Phi_in_Z_%02d",zBin);
1842 fHistograms->FillHistogram(nameESDMappingFMDPhiInZ, vtxConv.Phi());
1845 if(fV0Reader->GetXYRadius()>rITSTPCMin && fV0Reader->GetXYRadius()<rITSTPCMax){
1846 TString nameESDMappingITSTPCPhiInZ="";
1847 nameESDMappingITSTPCPhiInZ.Form("ESD_Conversion_Mapping_ITSTPC_Phi_in_Z_%02d",zBin);
1848 fHistograms->FillHistogram(nameESDMappingITSTPCPhiInZ, vtxConv.Phi());
1851 TString nameESDMappingRInZ="";
1852 nameESDMappingRInZ.Form("ESD_Conversion_Mapping_R_in_Z_%02d",zBin);
1853 fHistograms->FillHistogram(nameESDMappingRInZ, fV0Reader->GetXYRadius());
1855 if(fV0Reader->GetMotherCandidatePt() > fLowPtMapping && fV0Reader->GetMotherCandidatePt()< fHighPtMapping){
1856 TString nameESDMappingMidPtPhiInR="";
1857 nameESDMappingMidPtPhiInR.Form("ESD_Conversion_Mapping_MidPt_Phi_in_R_%02d",rBin);
1858 fHistograms->FillHistogram(nameESDMappingMidPtPhiInR, vtxConv.Phi());
1860 TString nameESDMappingMidPtZInR="";
1861 nameESDMappingMidPtZInR.Form("ESD_Conversion_Mapping_MidPt_Z_in_R_%02d",rBin);
1862 fHistograms->FillHistogram(nameESDMappingMidPtZInR, fV0Reader->GetZ());
1864 TString nameESDMappingMidPtPhiInZ="";
1865 nameESDMappingMidPtPhiInZ.Form("ESD_Conversion_Mapping_MidPt_Phi_in_Z_%02d",zBin);
1866 fHistograms->FillHistogram(nameESDMappingMidPtPhiInZ, vtxConv.Phi());
1867 if(fV0Reader->GetXYRadius()<rFMD){
1868 TString nameESDMappingMidPtFMDPhiInZ="";
1869 nameESDMappingMidPtFMDPhiInZ.Form("ESD_Conversion_Mapping_MidPt_FMD_Phi_in_Z_%02d",zBin);
1870 fHistograms->FillHistogram(nameESDMappingMidPtFMDPhiInZ, vtxConv.Phi());
1874 TString nameESDMappingMidPtRInZ="";
1875 nameESDMappingMidPtRInZ.Form("ESD_Conversion_Mapping_MidPt_R_in_Z_%02d",zBin);
1876 fHistograms->FillHistogram(nameESDMappingMidPtRInZ, fV0Reader->GetXYRadius());
1883 new((*fKFReconstructedGammasTClone)[fKFReconstructedGammasTClone->GetEntriesFast()]) AliKFParticle(*fV0Reader->GetMotherCandidateKFCombination());
1884 fKFReconstructedGammasV0Index.push_back(fV0Reader->GetCurrentV0IndexNumber()-1);
1885 // fKFReconstructedGammas.push_back(*fV0Reader->GetMotherCandidateKFCombination());
1886 fElectronv1.push_back(fV0Reader->GetCurrentV0()->GetPindex());
1887 fElectronv2.push_back(fV0Reader->GetCurrentV0()->GetNindex());
1889 //----------------------------------- checking for "real" conversions (MC match) --------------------------------------
1891 TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
1892 TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
1894 if(fV0Reader->HasSameMCMother() == kFALSE){
1895 fHistograms->FillHistogram("ESD_TrueConvCombinatorial_R", fV0Reader->GetXYRadius());
1896 fHistograms->FillHistogram("ESD_TrueConvCombinatorial_Pt", fV0Reader->GetMotherCandidatePt());
1897 fHistograms->FillHistogram("ESD_TrueConvCombinatorialDaughter_Pt", negativeMC->Pt(),positiveMC->Pt());
1898 if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){
1899 fHistograms->FillHistogram("ESD_TrueConvCombinatorialElec_R", fV0Reader->GetXYRadius());
1900 fHistograms->FillHistogram("ESD_TrueConvCombinatorialElec_Pt", fV0Reader->GetMotherCandidatePt());
1902 if(TMath::Abs(negativeMC->GetPdgCode())==211 && TMath::Abs(positiveMC->GetPdgCode())==211){
1903 fHistograms->FillHistogram("ESD_TrueConvCombinatorialPi_R", fV0Reader->GetXYRadius());
1904 fHistograms->FillHistogram("ESD_TrueConvCombinatorialPi_Pt", fV0Reader->GetMotherCandidatePt());
1905 fHistograms->FillHistogram("ESD_TrueConvCombinatorialPiDaughter_Pt", negativeMC->Pt(),positiveMC->Pt());
1907 if((TMath::Abs(negativeMC->GetPdgCode())==211 && TMath::Abs(positiveMC->GetPdgCode())==2211) ||
1908 (TMath::Abs(negativeMC->GetPdgCode())==2212 && TMath::Abs(positiveMC->GetPdgCode())==211)){
1909 fHistograms->FillHistogram("ESD_TrueConvCombinatorialPiP_R", fV0Reader->GetXYRadius());
1910 fHistograms->FillHistogram("ESD_TrueConvCombinatorialPiP_Pt", fV0Reader->GetMotherCandidatePt());
1911 fHistograms->FillHistogram("ESD_TrueConvCombinatorialPiPDaughter_Pt", negativeMC->Pt(),positiveMC->Pt());
1913 if((TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==211) ||
1914 (TMath::Abs(negativeMC->GetPdgCode())==211 && TMath::Abs(positiveMC->GetPdgCode())==11)){
1915 fHistograms->FillHistogram("ESD_TrueConvCombinatorialElecPi_R", fV0Reader->GetXYRadius());
1916 fHistograms->FillHistogram("ESD_TrueConvCombinatorialElecPi_Pt", fV0Reader->GetMotherCandidatePt());
1918 if( (statusPos & AliESDtrack::kTOFpid) && ( TMath::Abs(positiveMC->GetPdgCode()) != 11 ) )
1919 fHistograms->FillHistogram("ESD_TrueConvCombinatorial_DaughtersNotElec_P_dT", fV0Reader->GetPositiveTrackP(), dTpos);//RRnewTOF
1920 if( (statusNeg & AliESDtrack::kTOFpid) && ( TMath::Abs(negativeMC->GetPdgCode()) != 11 ) )
1921 fHistograms->FillHistogram("ESD_TrueConvCombinatorial_DaughtersNotElec_P_dT", fV0Reader->GetNegativeTrackP(), dTneg);//RRnewTOF
1924 // Moved up to check true electron background
1925 // TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
1926 // TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
1928 if(TMath::Abs(negativeMC->GetPdgCode())!=11 || TMath::Abs(positiveMC->GetPdgCode())!=11){
1929 fHistograms->FillHistogram("ESD_TrueConvHadronicBck_R", fV0Reader->GetXYRadius());
1930 fHistograms->FillHistogram("ESD_TrueConvHadronicBck_Pt", fV0Reader->GetMotherCandidatePt());
1931 fHistograms->FillHistogram("ESD_TrueConvHadronicBckDaughter_Pt", negativeMC->Pt(),positiveMC->Pt());
1932 if(statusPos & AliESDtrack::kTOFpid)
1933 fHistograms->FillHistogram("ESD_TrueConvHadronicBck_Daughters_P_dT", fV0Reader->GetPositiveTrackP(), dTpos);//RRnewTOF
1934 if(statusNeg & AliESDtrack::kTOFpid)
1935 fHistograms->FillHistogram("ESD_TrueConvHadronicBck_Daughters_P_dT", fV0Reader->GetNegativeTrackP(), dTneg);//RRnewTOF
1936 if((TMath::Abs(negativeMC->GetPdgCode())==211 && TMath::Abs(positiveMC->GetPdgCode())==2211) ||
1937 (TMath::Abs(negativeMC->GetPdgCode())==2212 && TMath::Abs(positiveMC->GetPdgCode())==211)){
1938 fHistograms->FillHistogram("ESD_TrueConvLambda_R", fV0Reader->GetXYRadius());
1939 fHistograms->FillHistogram("ESD_TrueConvLambda_Pt", fV0Reader->GetMotherCandidatePt());
1941 if(TMath::Abs(negativeMC->GetPdgCode())==211 && TMath::Abs(positiveMC->GetPdgCode())==211){
1942 fHistograms->FillHistogram("ESD_TrueConvMeson_R", fV0Reader->GetXYRadius());
1943 fHistograms->FillHistogram("ESD_TrueConvMeson_Pt", fV0Reader->GetMotherCandidatePt());
1949 if(negativeMC->GetPdgCode()==positiveMC->GetPdgCode()){
1953 //UInt_t statusPos = fV0Reader->GetPositiveESDTrack()->GetStatus(); moved higher
1954 //UInt_t statusNeg = fV0Reader->GetNegativeESDTrack()->GetStatus();
1955 UChar_t itsPixelPos = fV0Reader->GetPositiveESDTrack()->GetITSClusterMap();
1956 UChar_t itsPixelNeg = fV0Reader->GetNegativeESDTrack()->GetITSClusterMap();
1958 // Using the UniqueID Phojet does not get the Dalitz right
1959 // if( (negativeMC->GetUniqueID() == 4 && positiveMC->GetUniqueID() ==4) ||
1960 // (negativeMC->GetUniqueID() == 0 && positiveMC->GetUniqueID() ==0) ){// fill r distribution for Dalitz decays
1961 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 111){ //pi0
1962 fHistograms->FillHistogram("ESD_TrueDalitzContamination_R", fV0Reader->GetXYRadius());
1963 fHistograms->FillHistogram("ESD_TrueConvDalitzPi0_R", fV0Reader->GetXYRadius());
1964 //--------Histos for HFE
1966 if(statusPos & AliESDtrack::kTOFpid){
1967 fHistograms->FillHistogram("ESD_TrueConvDalitzPi0_SinglePos_R", fV0Reader->GetXYRadius());
1968 if( TESTBIT(itsPixelPos, 0) ){
1969 fHistograms->FillHistogram("ESD_TrueConvDalitzPi0_SinglePos_kFirst_R", fV0Reader->GetXYRadius());
1972 if(statusNeg & AliESDtrack::kTOFpid){
1973 fHistograms->FillHistogram("ESD_TrueConvDalitzPi0_SingleNeg_R", fV0Reader->GetXYRadius());
1974 if( TESTBIT(itsPixelNeg, 0) ){
1975 fHistograms->FillHistogram("ESD_TrueConvDalitzPi0_SingleNeg_kFirst_R", fV0Reader->GetXYRadius());
1978 //--------------------------------------------------------
1981 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 221){ //eta
1982 fHistograms->FillHistogram("ESD_TrueConvDalitzEta_R", fV0Reader->GetXYRadius());
1987 if(negativeMC->GetUniqueID() != 5 || positiveMC->GetUniqueID() !=5){// check if the daughters come from a conversion
1991 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
1994 Double_t containerInput[3];
1995 containerInput[0] = fV0Reader->GetMotherCandidatePt();
1996 containerInput[1] = fV0Reader->GetMotherCandidateEta();
1997 containerInput[2] = fV0Reader->GetMotherCandidateMass();
1998 fCFManager->GetParticleContainer()->Fill(containerInput,kStepTrueGamma); // for CF
2001 // RRnewTOF start ///////////////////////////////////////////////
2002 if(statusPos & AliESDtrack::kTOFpid) fHistograms->FillHistogram("ESD_TrueConvGamma_EandP_P_dT", fV0Reader->GetPositiveTrackP(), dTpos);
2003 if(statusNeg & AliESDtrack::kTOFpid) fHistograms->FillHistogram("ESD_TrueConvGamma_EandP_P_dT", fV0Reader->GetNegativeTrackP(), dTneg);
2004 // RRnewTOF end /////////////////////////////////////////////////
2006 fHistograms->FillHistogram("ESD_TrueConvGamma_Pt", fV0Reader->GetMotherCandidatePt());
2007 fHistograms->FillHistogram("ESD_TrueConvGamma_Energy", fV0Reader->GetMotherCandidateEnergy());
2008 fHistograms->FillHistogram("ESD_TrueConvGamma_Eta", fV0Reader->GetMotherCandidateEta());
2009 fHistograms->FillHistogram("ESD_TrueConvGamma_Phi", fV0Reader->GetMotherCandidatePhi());
2010 fHistograms->FillHistogram("ESD_TrueConvGamma_Mass", fV0Reader->GetMotherCandidateMass());
2011 fHistograms->FillHistogram("ESD_TrueConvGamma_Width", fV0Reader->GetMotherCandidateWidth());
2012 fHistograms->FillHistogram("ESD_TrueConvGamma_Chi2", fV0Reader->GetMotherCandidateChi2());
2013 fHistograms->FillHistogram("ESD_TrueConvGamma_NDF", fV0Reader->GetMotherCandidateNDF());
2014 fHistograms->FillHistogram("ESD_TrueConvGamma_Pt_Eta", fV0Reader->GetMotherCandidatePt(),fV0Reader->GetMotherCandidateEta());
2015 fHistograms->FillHistogram("ESD_TrueConvGamma_Rapid", fV0Reader->GetMotherCandidateRapidity());
2016 fHistograms->FillHistogram("ESD_TrueConvGamma_TrackLength", /*fV0Reader->GetNegativeTrackLength()*/fV0Reader->GetNegativeNTPCClusters());
2017 fHistograms->FillHistogram("ESD_TrueConvGamma_TrackLength", /*fV0Reader->GetPositiveTrackLength()*/fV0Reader->GetPositiveNTPCClusters());
2018 fHistograms->FillHistogram("ESD_TrueConvGamma_TrackLengthVSInvMass",/*fV0Reader->GetNegativeTrackLength()*/fV0Reader->GetNegativeNTPCClusters(),fV0Reader->GetMotherCandidateMass());
2019 fHistograms->FillHistogram("ESD_TrueConvGamma_TrackLengthVSInvMass",/*fV0Reader->GetPositiveTrackLength()*/fV0Reader->GetPositiveNTPCClusters(),fV0Reader->GetMotherCandidateMass());
2021 fHistograms->FillHistogram("ESD_TrueConvGamma_Pt_Chi2", fV0Reader->GetMotherCandidatePt(), fV0Reader->GetMotherCandidateChi2());
2022 fHistograms->FillHistogram("ESD_TrueConvGamma_Eta_Chi2", fV0Reader->GetMotherCandidateEta(), fV0Reader->GetMotherCandidateChi2());
2024 fHistograms->FillHistogram("ESD_TrueConversion_E_nTPCClustersToFR", fV0Reader->GetXYRadius(),eClsToF );
2025 fHistograms->FillHistogram("ESD_TrueConversion_P_nTPCClustersToFR",fV0Reader->GetXYRadius(), pClsToF);
2027 fHistograms->FillHistogram("ESD_TrueConversion_XY", fV0Reader->GetX(),fV0Reader->GetY());
2028 fHistograms->FillHistogram("ESD_TrueConversion_R", fV0Reader->GetXYRadius());
2029 fHistograms->FillHistogram("ESD_TrueConversion_ZR", fV0Reader->GetZ(),fV0Reader->GetXYRadius());
2030 fHistograms->FillHistogram("ESD_TrueConversion_OpeningAngle", fV0Reader->GetOpeningAngle());
2032 //----Histos for HFE--------------------------------------
2034 if(statusPos & AliESDtrack::kTOFpid){
2035 fHistograms->FillHistogram("ESD_TrueConversion_SinglePos_R", positiveMC->R(),fV0Reader->GetPositiveMCParticle()->Pt());
2036 if( TESTBIT(itsPixelPos, 0) ){
2037 fHistograms->FillHistogram("ESD_TrueConversion_SinglePos_kFirst_R", positiveMC->R(),fV0Reader->GetPositiveMCParticle()->Pt());
2040 if(statusNeg & AliESDtrack::kTOFpid){
2041 fHistograms->FillHistogram("ESD_TrueConversion_SingleNeg_R", negativeMC->R(),fV0Reader->GetNegativeMCParticle()->Pt());
2042 if( TESTBIT(itsPixelNeg, 0) ){
2043 fHistograms->FillHistogram("ESD_TrueConversion_SingleNeg_kFirst_R", negativeMC->R(),fV0Reader->GetNegativeMCParticle()->Pt());
2046 //--------------------------------------------------------
2048 fHistograms->FillHistogram("ESD_TrueConvGamma_CosPointingAngle", fV0Reader->GetCosPointingAngle());
2049 fHistograms->FillHistogram("ESD_TrueConvGamma_DcaDaughters", fV0Reader->GetDcaDaughters());
2050 fHistograms->FillHistogram("ESD_TrueConvGamma_NormDcaDistDaughters", fV0Reader->GetNormDcaDistDaughters());
2051 fHistograms->FillHistogram("ESD_TrueConvGamma_LikelihoodAP", fV0Reader->GetLikelihoodAP());
2052 if (fV0Reader->GetMotherCandidateP() != 0) {
2053 fHistograms->FillHistogram("ESD_TrueConvGamma_E_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetNegativeTrackP()/fV0Reader->GetMotherCandidateP());
2054 fHistograms->FillHistogram("ESD_TrueConvGamma_P_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetPositiveTrackP()/fV0Reader->GetMotherCandidateP());
2055 } else { cout << "Error::fV0Reader->GetNegativeTrackP() == 0 !!!" << endl; }
2057 fHistograms->FillHistogram("ESD_TrueConvGamma_E_dEdxP",fV0Reader->GetNegativeTrackP(),fV0Reader->GetNegativeTrackTPCdEdx());
2058 fHistograms->FillHistogram("ESD_TrueConvGamma_P_dEdxP",fV0Reader->GetPositiveTrackP(),fV0Reader->GetPositiveTrackTPCdEdx());
2059 fHistograms->FillHistogram("ESD_TrueConvGamma_alfa_qt",armenterosQtAlfa[1],armenterosQtAlfa[0]);
2063 //store MCTruth properties
2064 fHistograms->FillHistogram("ESD_TrueConvGamma_MC_Pt_Eta", fV0Reader->GetMotherMCParticle()->Pt(),fV0Reader->GetMotherMCParticle()->Eta());
2065 fHistograms->FillHistogram("ESD_TrueConversion_MC_ZR", negativeMC->Vz(),negativeMC->R());
2066 fHistograms->FillHistogram("ESD_TrueConversion_MC_XY", negativeMC->Vx(),negativeMC->Vy());
2069 Double_t mcpt = fV0Reader->GetMotherMCParticle()->Pt();
2070 Double_t esdpt = fV0Reader->GetMotherCandidatePt();
2071 Double_t resdPt = 0.;
2073 resdPt = ((esdpt - mcpt)/mcpt)*100.;
2076 cout<<"Pt of MC particle is negative, this will cause wrong calculation of resPt"<<endl;
2079 fHistograms->FillHistogram("Resolution_Gamma_dPt_Pt", mcpt, resdPt);
2080 fHistograms->FillHistogram("Resolution_MC_Pt", mcpt);
2081 fHistograms->FillHistogram("Resolution_ESD_Pt", esdpt);
2082 fHistograms->FillHistogram("Resolution_Gamma_dPt_Phi", fV0Reader->GetMotherCandidatePhi(), resdPt);
2084 Double_t resdZ = 0.;
2085 if(fV0Reader->GetNegativeMCParticle()->Vz() != 0){
2086 resdZ = ((fV0Reader->GetZ() -fV0Reader->GetNegativeMCParticle()->Vz())/fV0Reader->GetNegativeMCParticle()->Vz())*100.;
2088 Double_t resdZAbs = 0.;
2089 resdZAbs = (fV0Reader->GetZ() -fV0Reader->GetNegativeMCParticle()->Vz());
2091 fHistograms->FillHistogram("Resolution_dZAbs_VS_R", fV0Reader->GetNegativeMCParticle()->R(), resdZAbs);
2092 fHistograms->FillHistogram("Resolution_dZ", fV0Reader->GetNegativeMCParticle()->Vz(), resdZ);
2093 fHistograms->FillHistogram("Resolution_MC_Z", fV0Reader->GetNegativeMCParticle()->Vz());
2094 fHistograms->FillHistogram("Resolution_ESD_Z", fV0Reader->GetZ());
2096 // new for dPt_Pt-histograms for Electron and Positron
2097 Double_t mcEpt = fV0Reader->GetNegativeMCParticle()->Pt();
2098 Double_t resEdPt = 0.;
2100 resEdPt = ((fV0Reader->GetNegativeTrackPt()-mcEpt)/mcEpt)*100.;
2102 UInt_t statusN = fV0Reader->GetNegativeESDTrack()->GetStatus();
2103 // AliESDtrack * negTrk = fV0Reader->GetNegativeESDTrack();
2104 UInt_t kTRDoutN = (statusN & AliESDtrack::kTRDout);
2106 Int_t nITSclsE= fV0Reader->GetNegativeTracknITSClusters();
2107 // filling Resolution_Pt_dPt with respect to the Number of ITS clusters for Positrons
2109 case 0: // 0 ITS clusters
2110 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS0", mcEpt, resEdPt);
2112 case 1: // 1 ITS cluster
2113 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS1", mcEpt, resEdPt);
2115 case 2: // 2 ITS clusters
2116 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS2", mcEpt, resEdPt);
2118 case 3: // 3 ITS clusters
2119 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS3", mcEpt, resEdPt);
2121 case 4: // 4 ITS clusters
2122 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS4", mcEpt, resEdPt);
2124 case 5: // 5 ITS clusters
2125 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS5", mcEpt, resEdPt);
2127 case 6: // 6 ITS clusters
2128 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS6", mcEpt, resEdPt);
2131 //Filling histograms with respect to Electron resolution
2132 fHistograms->FillHistogram("Resolution_E_dPt_Pt", mcEpt, resEdPt);
2133 fHistograms->FillHistogram("Resolution_E_dPt_Phi", fV0Reader->GetNegativeTrackPhi(), resEdPt);
2135 fHistograms->FillHistogram("Resolution_E_nTRDtracklets_ESDPt", fV0Reader->GetNegativeTrackPt(), fV0Reader->GetNegativeESDTrack()->GetTRDntracklets());
2136 fHistograms->FillHistogram("Resolution_E_nTRDtracklets_MCPt", mcEpt, fV0Reader->GetNegativeESDTrack()->GetTRDntracklets());
2137 fHistograms->FillHistogram("Resolution_E_nTRDclusters_ESDPt",fV0Reader->GetNegativeTrackPt(), fV0Reader->GetNegativeESDTrack()->GetTRDncls());
2138 fHistograms->FillHistogram("Resolution_E_nTRDclusters_MCPt",mcEpt, fV0Reader->GetNegativeESDTrack()->GetTRDncls());
2139 fHistograms->FillHistogram("Resolution_E_TRDsignal_ESDPt", fV0Reader->GetNegativeTrackPt(), fV0Reader->GetNegativeESDTrack()->GetTRDsignal());
2142 Double_t mcPpt = fV0Reader->GetPositiveMCParticle()->Pt();
2143 Double_t resPdPt = 0;
2145 resPdPt = ((fV0Reader->GetPositiveTrackPt()-mcPpt)/mcPpt)*100.;
2148 UInt_t statusP = fV0Reader->GetPositiveESDTrack()->GetStatus();
2149 // AliESDtrack * posTr= fV0Reader->GetPositiveESDTrack();
2150 UInt_t kTRDoutP = (statusP & AliESDtrack::kTRDout);
2152 Int_t nITSclsP = fV0Reader->GetPositiveTracknITSClusters();
2153 // filling Resolution_Pt_dPt with respect to the Number of ITS clusters for Positrons
2155 case 0: // 0 ITS clusters
2156 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS0", mcPpt, resPdPt);
2158 case 1: // 1 ITS cluster
2159 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS1", mcPpt, resPdPt);
2161 case 2: // 2 ITS clusters
2162 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS2", mcPpt, resPdPt);
2164 case 3: // 3 ITS clusters
2165 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS3", mcPpt, resPdPt);
2167 case 4: // 4 ITS clusters
2168 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS4", mcPpt, resPdPt);
2170 case 5: // 5 ITS clusters
2171 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS5", mcPpt, resPdPt);
2173 case 6: // 6 ITS clusters
2174 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS6", mcPpt, resPdPt);
2177 //Filling histograms with respect to Positron resolution
2178 fHistograms->FillHistogram("Resolution_P_dPt_Pt", mcPpt, resPdPt);
2179 fHistograms->FillHistogram("Resolution_P_dPt_Phi", fV0Reader->GetPositiveTrackPhi(), resPdPt);
2181 fHistograms->FillHistogram("Resolution_P_nTRDtracklets_ESDPt", fV0Reader->GetPositiveTrackPt(), fV0Reader->GetPositiveESDTrack()->GetTRDntracklets());
2182 fHistograms->FillHistogram("Resolution_P_nTRDtracklets_MCPt", mcPpt, fV0Reader->GetPositiveESDTrack()->GetTRDntracklets());
2183 fHistograms->FillHistogram("Resolution_P_nTRDclusters_ESDPt",fV0Reader->GetPositiveTrackPt(), fV0Reader->GetPositiveESDTrack()->GetTRDncls());
2184 fHistograms->FillHistogram("Resolution_P_nTRDclusters_MCPt",mcPpt, fV0Reader->GetPositiveESDTrack()->GetTRDncls());
2185 fHistograms->FillHistogram("Resolution_P_TRDsignal_ESDPt", fV0Reader->GetPositiveTrackPt(), fV0Reader->GetPositiveESDTrack()->GetTRDsignal());
2189 Double_t resdR = 0.;
2190 if(fV0Reader->GetNegativeMCParticle()->R() != 0){
2191 resdR = ((fV0Reader->GetXYRadius() - fV0Reader->GetNegativeMCParticle()->R())/fV0Reader->GetNegativeMCParticle()->R())*100.;
2193 Double_t resdRAbs = 0.;
2194 resdRAbs = (fV0Reader->GetXYRadius() - fV0Reader->GetNegativeMCParticle()->R());
2196 fHistograms->FillHistogram("Resolution_dRAbs_VS_R", fV0Reader->GetNegativeMCParticle()->R(), resdRAbs);
2197 fHistograms->FillHistogram("Resolution_dR", fV0Reader->GetNegativeMCParticle()->R(), resdR);
2198 fHistograms->FillHistogram("Resolution_MC_R", fV0Reader->GetNegativeMCParticle()->R());
2199 fHistograms->FillHistogram("Resolution_ESD_R", fV0Reader->GetXYRadius());
2200 fHistograms->FillHistogram("Resolution_R_dPt", fV0Reader->GetNegativeMCParticle()->R(), resdPt);
2202 Double_t resdPhiAbs=0.;
2204 resdPhiAbs= (fV0Reader->GetMotherCandidatePhi()-fV0Reader->GetNegativeMCParticle()->Phi());
2205 fHistograms->FillHistogram("Resolution_dPhiAbs_VS_R", fV0Reader->GetNegativeMCParticle()->R(), resdPhiAbs);
2207 }//if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22)
2209 }//while(fV0Reader->NextV0)
2210 fHistograms->FillHistogram("ESD_NumberOfSurvivingV0s", nSurvivingV0s);
2211 fHistograms->FillHistogram("ESD_NumberOfV0s", fV0Reader->GetNumberOfV0s());
2212 fHistograms->FillHistogram("ESD_NumberOfContributorsVtx", fV0Reader->GetNumberOfContributorsVtx());
2214 fV0Reader->ResetV0IndexNumber();
2219 ///_____________________________________________________________________________________
2220 void AliAnalysisTaskGammaConversion::ProcessGammasForOmegaMesonAnalysis(){
2221 // omega meson analysis pi0+gamma decay
2222 for(Int_t firstPi0Index=0;firstPi0Index<fKFReconstructedPi0sTClone->GetEntriesFast();firstPi0Index++){
2223 AliKFParticle * omegaCandidatePi0Daughter = (AliKFParticle *)fKFReconstructedPi0sTClone->At(firstPi0Index);
2224 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();firstGammaIndex++){
2226 AliKFParticle * omegaCandidateGammaDaughter = (AliKFParticle *)fKFReconstructedGammasTClone->At(firstGammaIndex);
2227 if(fGammav1[firstPi0Index]==firstGammaIndex || fGammav2[firstPi0Index]==firstGammaIndex){
2231 AliKFParticle omegaCandidate(*omegaCandidatePi0Daughter,*omegaCandidateGammaDaughter);
2232 Double_t massOmegaCandidate = 0.;
2233 Double_t widthOmegaCandidate = 0.;
2235 omegaCandidate.GetMass(massOmegaCandidate,widthOmegaCandidate);
2237 if ( massOmegaCandidate > 733 && massOmegaCandidate < 833 ) {
2238 //AddOmegaToAOD(&omegaCandidate, massOmegaCandidate, firstPi0Index, firstGammaIndex);
2241 fHistograms->FillHistogram("ESD_Omega_InvMass_vs_Pt",massOmegaCandidate ,omegaCandidate.GetPt());
2242 fHistograms->FillHistogram("ESD_Omega_InvMass",massOmegaCandidate);
2244 //delete omegaCandidate;
2246 }// end of omega reconstruction in pi0+gamma channel
2248 if(fDoJet == kTRUE){
2249 AliKFParticle* negPiKF=NULL;
2250 AliKFParticle* posPiKF=NULL;
2252 // look at the pi+pi+pi0 channel
2253 for(Int_t iCh=0;iCh<fChargedParticles->GetEntriesFast();iCh++){
2254 AliESDtrack* posTrack = (AliESDtrack*)(fChargedParticles->At(iCh));
2255 if (posTrack->GetSign()<0) continue;
2256 if(TMath::Abs(fV0Reader->GetESDpid()->NumberOfSigmasTPC(posTrack,AliPID::kPion))>2.) continue;
2257 if (posPiKF) delete posPiKF; posPiKF=NULL;
2258 posPiKF = new AliKFParticle( *(posTrack) ,211);
2260 for(Int_t jCh=0;jCh<fChargedParticles->GetEntriesFast();jCh++){
2261 AliESDtrack* negTrack = (AliESDtrack*)(fChargedParticles->At(jCh));
2262 if( negTrack->GetSign()>0) continue;
2263 if(TMath::Abs(fV0Reader->GetESDpid()->NumberOfSigmasTPC(negTrack,AliPID::kPion))>2.) continue;
2264 if (negPiKF) delete negPiKF; negPiKF=NULL;
2265 negPiKF = new AliKFParticle( *(negTrack) ,-211);
2266 AliKFParticle omegaCandidatePipPinPi0(*omegaCandidatePi0Daughter,*posPiKF,*negPiKF);
2267 Double_t massOmegaCandidatePipPinPi0 = 0.;
2268 Double_t widthOmegaCandidatePipPinPi0 = 0.;
2270 omegaCandidatePipPinPi0.GetMass(massOmegaCandidatePipPinPi0,widthOmegaCandidatePipPinPi0);
2272 if ( massOmegaCandidatePipPinPi0 > 733 && massOmegaCandidatePipPinPi0 < 833 ) {
2273 // AddOmegaToAOD(&omegaCandidatePipPinPi0, massOmegaCandidatePipPinPi0, -1, -1);
2276 fHistograms->FillHistogram("ESD_OmegaPipPinPi0_InvMass_vs_Pt",massOmegaCandidatePipPinPi0 ,omegaCandidatePipPinPi0.GetPt());
2277 fHistograms->FillHistogram("ESD_OmegaPipPinPi0_InvMass",massOmegaCandidatePipPinPi0);
2279 // delete omegaCandidatePipPinPi0;
2283 if (posPiKF) delete posPiKF; posPiKF=NULL; if (negPiKF) delete negPiKF; negPiKF=NULL;
2285 } // checking ig gammajet because in that case the chargedparticle list is created
2289 if(fCalculateBackground){
2291 AliGammaConversionBGHandler * bgHandler = fV0Reader->GetBGHandler();
2293 Int_t zbin= bgHandler->GetZBinIndex(fV0Reader->GetVertexZ());
2295 if(fUseTrackMultiplicityForBG == kTRUE){
2296 mbin = bgHandler->GetMultiplicityBinIndex(fV0Reader->CountESDTracks());
2299 mbin = bgHandler->GetMultiplicityBinIndex(fV0Reader->GetNGoodV0s());
2302 AliGammaConversionBGHandler::GammaConversionVertex *bgEventVertex = NULL;
2304 // Background calculation for the omega
2305 for(Int_t nEventsInBG=0;nEventsInBG <fV0Reader->GetNBGEvents();nEventsInBG++){
2306 AliGammaConversionKFVector * previousEventV0s = bgHandler->GetBGGoodV0s(zbin,mbin,nEventsInBG);
2308 if(fMoveParticleAccordingToVertex == kTRUE){
2309 bgEventVertex = bgHandler->GetBGEventVertex(zbin,mbin,nEventsInBG);
2311 for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
2312 AliKFParticle previousGoodV0 = (AliKFParticle)(*(previousEventV0s->at(iPrevious)));
2314 if(fMoveParticleAccordingToVertex == kTRUE){
2315 MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
2318 for(Int_t firstPi0Index=0;firstPi0Index<fKFReconstructedPi0sTClone->GetEntriesFast();firstPi0Index++){
2319 AliKFParticle * omegaCandidatePi0Daughter = (AliKFParticle *)fKFReconstructedPi0sTClone->At(firstPi0Index);
2320 AliKFParticle * omegaBckCandidate = new AliKFParticle(*omegaCandidatePi0Daughter,previousGoodV0);
2321 Double_t massOmegaBckCandidate = 0.;
2322 Double_t widthOmegaBckCandidate = 0.;
2324 omegaBckCandidate->GetMass(massOmegaBckCandidate,widthOmegaBckCandidate);
2327 fHistograms->FillHistogram("ESD_Omega_Bck_InvMass_vs_Pt",massOmegaBckCandidate ,omegaBckCandidate->GetPt());
2328 fHistograms->FillHistogram("ESD_Omega_Bck_InvMass",massOmegaBckCandidate);
2330 delete omegaBckCandidate;
2334 } // end of checking if background calculation is available
2341 void AliAnalysisTaskGammaConversion::ProcessGammasForNeutralMesonAnalysis(){
2342 // see header file for documentation
2344 // for(UInt_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammas.size();firstGammaIndex++){
2345 // for(UInt_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fKFReconstructedGammas.size();secondGammaIndex++){
2347 fESDEvent = fV0Reader->GetESDEvent();
2349 if(fKFReconstructedGammasTClone->GetEntriesFast()>fV0Reader->GetNumberOfV0s()){
2350 cout<<"Warning, number of entries in the tclone is bigger than number of v0s"<<endl;
2353 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();firstGammaIndex++){
2354 for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();secondGammaIndex++){
2356 // AliKFParticle * twoGammaDecayCandidateDaughter0 = &fKFReconstructedGammas[firstGammaIndex];
2357 // AliKFParticle * twoGammaDecayCandidateDaughter1 = &fKFReconstructedGammas[secondGammaIndex];
2359 AliKFParticle * twoGammaDecayCandidateDaughter0 = (AliKFParticle *)fKFReconstructedGammasTClone->At(firstGammaIndex);
2360 AliKFParticle * twoGammaDecayCandidateDaughter1 = (AliKFParticle *)fKFReconstructedGammasTClone->At(secondGammaIndex);
2362 if(fElectronv1[firstGammaIndex]==fElectronv1[secondGammaIndex] || fElectronv1[firstGammaIndex]==fElectronv2[secondGammaIndex]){
2365 if(fElectronv2[firstGammaIndex]==fElectronv1[secondGammaIndex] || fElectronv2[firstGammaIndex]==fElectronv2[secondGammaIndex]){
2369 AliKFParticle *twoGammaCandidate = new AliKFParticle(*twoGammaDecayCandidateDaughter0,*twoGammaDecayCandidateDaughter1);
2371 Double_t massTwoGammaCandidate = 0.;
2372 Double_t widthTwoGammaCandidate = 0.;
2373 Double_t chi2TwoGammaCandidate =10000.;
2374 twoGammaCandidate->GetMass(massTwoGammaCandidate,widthTwoGammaCandidate);
2375 // if(twoGammaCandidate->GetNDF()>0){
2376 // chi2TwoGammaCandidate = twoGammaCandidate->GetChi2()/twoGammaCandidate->GetNDF();
2377 chi2TwoGammaCandidate = twoGammaCandidate->GetChi2();
2379 fHistograms->FillHistogram("ESD_Mother_Chi2",chi2TwoGammaCandidate);
2380 if((chi2TwoGammaCandidate>0 && chi2TwoGammaCandidate<fV0Reader->GetChi2CutMeson()) || fApplyChi2Cut == kFALSE){
2382 TVector3 momentumVectorTwoGammaCandidate(twoGammaCandidate->GetPx(),twoGammaCandidate->GetPy(),twoGammaCandidate->GetPz());
2383 TVector3 spaceVectorTwoGammaCandidate(twoGammaCandidate->GetX(),twoGammaCandidate->GetY(),twoGammaCandidate->GetZ());
2385 Double_t openingAngleTwoGammaCandidate = twoGammaDecayCandidateDaughter0->GetAngle(*twoGammaDecayCandidateDaughter1);
2387 if(twoGammaCandidate->GetE() - twoGammaCandidate->GetPz() <= 0 || twoGammaCandidate->GetE() + twoGammaCandidate->GetPz() <= 0){
2388 cout << "Error: |Pz| > E !!!! " << endl;
2392 rapidity = 0.5*(TMath::Log((twoGammaCandidate->GetE() +twoGammaCandidate->GetPz()) / (twoGammaCandidate->GetE()-twoGammaCandidate->GetPz())));
2395 if(TMath::Abs(rapidity) > fV0Reader->GetRapidityMesonCut()){
2396 delete twoGammaCandidate;
2397 continue; // rapidity cut
2402 if( (twoGammaDecayCandidateDaughter0->GetE()+twoGammaDecayCandidateDaughter1->GetE()) != 0){
2403 alfa=TMath::Abs((twoGammaDecayCandidateDaughter0->GetE()-twoGammaDecayCandidateDaughter1->GetE())
2404 /(twoGammaDecayCandidateDaughter0->GetE()+twoGammaDecayCandidateDaughter1->GetE()));
2407 if(openingAngleTwoGammaCandidate < fMinOpeningAngleGhostCut){
2408 delete twoGammaCandidate;
2409 continue; // minimum opening angle to avoid using ghosttracks
2412 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
2413 fHistograms->FillHistogram("ESD_Mother_GammaDaughter_OpeningAngle", openingAngleTwoGammaCandidate);
2414 fHistograms->FillHistogram("ESD_Mother_Energy", twoGammaCandidate->GetE());
2415 fHistograms->FillHistogram("ESD_Mother_Pt", momentumVectorTwoGammaCandidate.Pt());
2416 fHistograms->FillHistogram("ESD_Mother_Eta", momentumVectorTwoGammaCandidate.Eta());
2417 fHistograms->FillHistogram("ESD_Mother_Rapid", rapidity);
2418 fHistograms->FillHistogram("ESD_Mother_Phi", spaceVectorTwoGammaCandidate.Phi());
2419 fHistograms->FillHistogram("ESD_Mother_Mass", massTwoGammaCandidate);
2420 fHistograms->FillHistogram("ESD_Mother_alfa", alfa);
2421 if(massTwoGammaCandidate>0.1 && massTwoGammaCandidate<0.15){
2422 fHistograms->FillHistogram("ESD_Mother_alfa_Pi0", alfa);
2424 if(massTwoGammaCandidate>0.5 && massTwoGammaCandidate<0.57){
2425 fHistograms->FillHistogram("ESD_Mother_alfa_Eta", alfa);
2428 fHistograms->FillHistogram("ESD_Mother_R", spaceVectorTwoGammaCandidate.Pt()); // Pt in Space == R!!!
2429 fHistograms->FillHistogram("ESD_Mother_ZR", twoGammaCandidate->GetZ(), spaceVectorTwoGammaCandidate.Pt());
2430 fHistograms->FillHistogram("ESD_Mother_XY", twoGammaCandidate->GetX(), twoGammaCandidate->GetY());
2431 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2432 fHistograms->FillHistogram("ESD_Mother_InvMass",massTwoGammaCandidate);
2433 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt_alpha",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2436 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_E_alpha",massTwoGammaCandidate ,twoGammaCandidate->GetE());
2440 if(fCalculateBackground){
2441 /* Kenneth, just for testing*/
2442 AliGammaConversionBGHandler * bgHandlerTest = fV0Reader->GetBGHandler();
2444 Int_t zbin= bgHandlerTest->GetZBinIndex(fV0Reader->GetVertexZ());
2447 if(fUseTrackMultiplicityForBG == kTRUE){
2448 multKAA=fV0Reader->CountESDTracks();
2449 mbin = bgHandlerTest->GetMultiplicityBinIndex(fV0Reader->CountESDTracks());
2451 else{// means we use #v0s for multiplicity
2452 multKAA=fV0Reader->GetNGoodV0s();
2453 mbin = bgHandlerTest->GetMultiplicityBinIndex(fV0Reader->GetNGoodV0s());
2455 // cout<<"Filling bin number "<<zbin<<" and "<<mbin<<endl;
2456 // cout<<"Corresponding to z = "<<fV0Reader->GetVertexZ()<<" and m = "<<multKAA<<endl;
2457 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
2458 fHistograms->FillHistogram(Form("%d%dESD_Mother_InvMass",zbin,mbin),massTwoGammaCandidate);
2459 fHistograms->FillHistogram(Form("%d%dESD_Mother_InvMass_vs_Pt",zbin,mbin),massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2460 /* end Kenneth, just for testing*/
2461 fHistograms->FillHistogram(Form("%dESD_Mother_InvMass_vs_Pt",mbin),massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2464 /* if(fCalculateBackground){
2465 AliGammaConversionBGHandler * bgHandler = fV0Reader->GetBGHandler();
2466 Int_t mbin= bgHandler->GetMultiplicityBinIndex(fV0Reader->CountESDTracks());
2467 fHistograms->FillHistogram(Form("%dESD_Mother_InvMass_vs_Pt",mbin),massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2469 // if(fDoNeutralMesonV0MCCheck){
2471 //Kenneth: Checking the eta of the gamma to check the difference between 0.9 and 1.2
2472 Int_t indexKF1 = fKFReconstructedGammasV0Index.at(firstGammaIndex);
2473 if(indexKF1<fV0Reader->GetNumberOfV0s()){
2474 fV0Reader->GetV0(indexKF1);//updates to the correct v0
2475 Double_t eta1 = fV0Reader->GetMotherCandidateEta();
2476 Bool_t isRealPi0=kFALSE;
2477 Bool_t isRealEta=kFALSE;
2478 Int_t gamma1MotherLabel=-1;
2479 if(fV0Reader->HasSameMCMother() == kTRUE){
2480 //cout<<"This v0 is a real v0!!!!"<<endl;
2481 TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
2482 TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
2483 if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){
2484 if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){
2485 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
2486 gamma1MotherLabel=fV0Reader->GetMotherMCParticle()->GetFirstMother();
2489 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() ==111){
2490 gamma1MotherLabel=-111;
2492 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() ==221){
2493 gamma1MotherLabel=-221;
2497 Int_t indexKF2 = fKFReconstructedGammasV0Index.at(secondGammaIndex);
2498 if(indexKF1 == indexKF2){
2499 cout<<"index of the two KF particles are the same.... should not happen"<<endl;
2501 if(indexKF2<fV0Reader->GetNumberOfV0s()){
2502 fV0Reader->GetV0(indexKF2);
2503 Double_t eta2 = fV0Reader->GetMotherCandidateEta();
2504 Int_t gamma2MotherLabel=-1;
2505 if(fV0Reader->HasSameMCMother() == kTRUE){
2506 TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
2507 TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
2508 if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){
2509 if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){
2510 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
2511 gamma2MotherLabel=fV0Reader->GetMotherMCParticle()->GetFirstMother();
2514 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() ==111){
2515 gamma2MotherLabel=-111;
2517 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() ==221){
2518 gamma2MotherLabel=-221;
2523 if(gamma1MotherLabel>=0 && gamma1MotherLabel==gamma2MotherLabel){
2524 if(fV0Reader->CheckIfPi0IsMother(gamma1MotherLabel)){
2527 if(fV0Reader->CheckIfEtaIsMother(gamma1MotherLabel)){
2532 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
2533 if(TMath::Abs(eta1)>0.9 && TMath::Abs(eta2)>0.9){
2534 // fHistograms->FillHistogram("ESD_Mother_InvMass_1212",massTwoGammaCandidate);
2535 // fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt1212",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2536 if(isRealPi0 || isRealEta){
2537 fHistograms->FillHistogram("ESD_TruePi0_InvMass_1212",massTwoGammaCandidate);
2538 fHistograms->FillHistogram("ESD_TruePi0_OpeningAngle_1212",openingAngleTwoGammaCandidate);
2539 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt1212",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2540 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2541 fHistograms->FillHistogram("ESD_TruePi0_InvMass",massTwoGammaCandidate);
2542 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt_alpha",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2545 if(!isRealPi0 && !isRealEta){
2546 if(gamma1MotherLabel>-1 && gamma2MotherLabel>-1){
2547 fHistograms->FillHistogram("ESD_TrueBckGG_InvMass_vs_Pt",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2549 fHistograms->FillHistogram("ESD_TrueBckCont_InvMass_vs_Pt",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2551 if(gamma1MotherLabel==-111 || gamma2MotherLabel==-111 || gamma1MotherLabel==-221 || gamma2MotherLabel==-221){
2552 fHistograms->FillHistogram("ESD_TruePi0DalitzCont_InvMass_vs_Pt",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2557 else if(TMath::Abs(eta1)>0.9 || TMath::Abs(eta2)>0.9){
2558 // fHistograms->FillHistogram("ESD_Mother_InvMass_0912",massTwoGammaCandidate);
2559 // fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt0912",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2561 if(isRealPi0 || isRealEta){
2562 fHistograms->FillHistogram("ESD_TruePi0_InvMass_0912",massTwoGammaCandidate);
2563 fHistograms->FillHistogram("ESD_TruePi0_OpeningAngle_0912",openingAngleTwoGammaCandidate);
2564 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt0912",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2565 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2566 fHistograms->FillHistogram("ESD_TruePi0_InvMass",massTwoGammaCandidate);
2567 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt_alpha",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2569 if(!isRealPi0 && !isRealEta){
2570 if(gamma1MotherLabel>-1 && gamma2MotherLabel>-1){
2571 fHistograms->FillHistogram("ESD_TrueBckGG_InvMass_vs_Pt",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2573 fHistograms->FillHistogram("ESD_TrueBckCont_InvMass_vs_Pt",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2575 if(gamma1MotherLabel==-111 || gamma2MotherLabel==-111 || gamma1MotherLabel==-221 || gamma2MotherLabel==-221){
2576 fHistograms->FillHistogram("ESD_TruePi0DalitzCont_InvMass_vs_Pt",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2581 // fHistograms->FillHistogram("ESD_Mother_InvMass_0909",massTwoGammaCandidate);
2582 // fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt0909",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2583 if(isRealPi0 || isRealEta){
2584 fHistograms->FillHistogram("ESD_TruePi0_InvMass_0909",massTwoGammaCandidate);
2585 fHistograms->FillHistogram("ESD_TruePi0_OpeningAngle_0909",openingAngleTwoGammaCandidate);
2586 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt0909",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2587 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2588 fHistograms->FillHistogram("ESD_TruePi0_InvMass",massTwoGammaCandidate);
2589 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt_alpha",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2590 if(gamma1MotherLabel > fV0Reader->GetMCStack()->GetNprimary()){
2591 fHistograms->FillHistogram("ESD_TruePi0Sec_InvMass_vs_Pt",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2594 if(!isRealPi0 && !isRealEta){
2595 if(gamma1MotherLabel>-1 && gamma2MotherLabel>-1){
2596 fHistograms->FillHistogram("ESD_TrueBckGG_InvMass_vs_Pt",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2598 fHistograms->FillHistogram("ESD_TrueBckCont_InvMass_vs_Pt",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2600 if(gamma1MotherLabel==-111 || gamma2MotherLabel==-111 || gamma1MotherLabel==-221 || gamma2MotherLabel==-221 ){
2601 fHistograms->FillHistogram("ESD_TruePi0DalitzCont_InvMass_vs_Pt",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2609 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
2610 if ( TMath::Abs(twoGammaDecayCandidateDaughter0->GetEta())<0.9 && TMath::Abs(twoGammaDecayCandidateDaughter1->GetEta())<0.9 ){
2611 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt_Fiducial",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2612 fHistograms->FillHistogram("ESD_Mother_InvMass_Fiducial",massTwoGammaCandidate);
2615 if(TMath::Abs(twoGammaDecayCandidateDaughter0->GetEta())>0.9 && TMath::Abs(twoGammaDecayCandidateDaughter1->GetEta())>0.9){
2616 fHistograms->FillHistogram("ESD_Mother_InvMass_1212",massTwoGammaCandidate);
2617 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt1212",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2619 else if(TMath::Abs(twoGammaDecayCandidateDaughter0->GetEta())>0.9 || TMath::Abs(twoGammaDecayCandidateDaughter1->GetEta())>0.9){
2620 fHistograms->FillHistogram("ESD_Mother_InvMass_0912",massTwoGammaCandidate);
2621 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt0912",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2624 fHistograms->FillHistogram("ESD_Mother_InvMass_0909",massTwoGammaCandidate);
2625 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt0909",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2628 Double_t lowMassPi0=0.1;
2629 Double_t highMassPi0=0.15;
2630 if ( ( massTwoGammaCandidate > lowMassPi0) && (massTwoGammaCandidate < highMassPi0) ){
2631 new((*fKFReconstructedPi0sTClone)[fKFReconstructedPi0sTClone->GetEntriesFast()]) AliKFParticle(*twoGammaCandidate);
2632 fGammav1.push_back(firstGammaIndex);
2633 fGammav2.push_back(secondGammaIndex);
2636 if( fKFCreateAOD ) {
2639 Double_t lowMassEta=0.5;
2640 Double_t highMassEta=0.6;
2642 if ( ( massTwoGammaCandidate > lowMassPi0) && (massTwoGammaCandidate < highMassPi0) ){
2643 AddPionToAOD(twoGammaCandidate, massTwoGammaCandidate, firstGammaIndex, secondGammaIndex);
2644 } else if ( ( massTwoGammaCandidate > lowMassEta) && (massTwoGammaCandidate < highMassEta) ){
2645 AddPionToAOD(twoGammaCandidate, massTwoGammaCandidate, firstGammaIndex, secondGammaIndex);
2651 delete twoGammaCandidate;
2656 ///__________________________________________________________________________________
2657 void AliAnalysisTaskGammaConversion::AddToAODBranch(TClonesArray * branch, AliKFParticle * kfParticle, Double_t mass, Int_t daughter1, Int_t daughter2) {
2659 new((*branch)[branch->GetEntriesFast()]) AliAODConversionParticle(kfParticle, daughter1, daughter2);
2660 AliAODConversionParticle * aodParticle = dynamic_cast<AliAODConversionParticle*>(branch->Last());
2662 aodParticle->SetChi2(kfParticle->Chi2());
2663 aodParticle->SetIMass(mass);
2667 ///__________________________________________________________________________________
2668 void AliAnalysisTaskGammaConversion::AddPionToAOD(AliKFParticle * kfParticle, Double_t mass, Int_t daughter1, Int_t daughter2) {
2669 AddToAODBranch(fAODPi0, kfParticle, mass, daughter1, daughter2);
2670 TagDaughter(daughter1);
2671 TagDaughter(daughter2);
2676 ///__________________________________________________________________________________
2677 void AliAnalysisTaskGammaConversion::TagDaughter(Int_t gammaIndex) {
2678 AliAODConversionParticle * daughter = dynamic_cast<AliAODConversionParticle*>(fAODGamma->At(gammaIndex));
2680 daughter->SetTag(kTRUE);
2682 AliError("Daughter not in gamma tree!!");
2686 ///___________________________________________________________________________________
2687 void AliAnalysisTaskGammaConversion::FillAODWithConversionGammas(){
2688 // Fill AOD with reconstructed Gamma
2690 for(Int_t gammaIndex=0;gammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();gammaIndex++){
2691 AliKFParticle * gammakf = dynamic_cast<AliKFParticle*>(fKFReconstructedGammasTClone->At(gammaIndex));
2692 AddToAODBranch(fAODGamma, gammakf, gammakf->GetMass(), fElectronv1[gammaIndex], fElectronv2[gammaIndex]);
2698 void AliAnalysisTaskGammaConversion::ProcessConvPHOSGammasForNeutralMesonAnalysis(){
2700 // see header file for documentation
2701 // Analyse Pi0 with one photon from Phos and 1 photon from conversions
2706 vtx[0] = fV0Reader->GetPrimaryVertex()->GetX();
2707 vtx[1] = fV0Reader->GetPrimaryVertex()->GetY();
2708 vtx[2] = fV0Reader->GetPrimaryVertex()->GetZ();
2711 // Loop over all CaloClusters and consider only the PHOS ones:
2712 AliESDCaloCluster *clu;
2713 TLorentzVector pPHOS;
2714 TLorentzVector gammaPHOS;
2715 TLorentzVector gammaGammaConv;
2716 TLorentzVector pi0GammaConvPHOS;
2717 TLorentzVector gammaGammaConvBck;
2718 TLorentzVector pi0GammaConvPHOSBck;
2721 for (Int_t i=0; i<fV0Reader->GetESDEvent()->GetNumberOfCaloClusters(); i++) {
2722 clu = fV0Reader->GetESDEvent()->GetCaloCluster(i);
2723 if ( !clu->IsPHOS() || clu->E()<0.1 ) continue;
2724 clu ->GetMomentum(pPHOS ,vtx);
2725 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();firstGammaIndex++){
2726 AliKFParticle * twoGammaDecayCandidateDaughter0 = (AliKFParticle *)fKFReconstructedGammasTClone->At(firstGammaIndex);
2727 gammaGammaConv.SetXYZM(twoGammaDecayCandidateDaughter0->Px(),twoGammaDecayCandidateDaughter0->Py(),twoGammaDecayCandidateDaughter0->Pz(),0.);
2728 gammaPHOS.SetXYZM(pPHOS.Px(),pPHOS.Py(),pPHOS.Pz(),0.);
2729 pi0GammaConvPHOS=gammaGammaConv+gammaPHOS;
2730 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvPHOS",pi0GammaConvPHOS.M());
2731 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt_GammaConvPHOS",pi0GammaConvPHOS.M(),pi0GammaConvPHOS.Pt());
2733 TVector3 v3D0(twoGammaDecayCandidateDaughter0->Px(),twoGammaDecayCandidateDaughter0->Py(),twoGammaDecayCandidateDaughter0->Pz());
2734 TVector3 v3D1(gammaPHOS.Px(),gammaPHOS.Py(),gammaPHOS.Pz());
2735 Double_t opanConvPHOS= v3D0.Angle(v3D1);
2736 if ( opanConvPHOS < 0.35){
2737 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvPHOS_OpanLow",pi0GammaConvPHOS.M());
2739 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvPHOS_OpanHigh",pi0GammaConvPHOS.M());
2744 // Now the LorentVector pPHOS is obtained and can be paired with the converted proton
2746 //==== End of the PHOS cluster selection ============
2747 TLorentzVector pEMCAL;
2748 TLorentzVector gammaEMCAL;
2749 TLorentzVector pi0GammaConvEMCAL;
2750 TLorentzVector pi0GammaConvEMCALBck;
2752 for (Int_t i=0; i<fV0Reader->GetESDEvent()->GetNumberOfCaloClusters(); i++) {
2753 clu = fV0Reader->GetESDEvent()->GetCaloCluster(i);
2754 if ( !clu->IsEMCAL() || clu->E()<0.1 ) continue;
2755 if (clu->GetNCells() <= 1) continue;
2756 if ( clu->GetTOF()*1e9 < 550 || clu->GetTOF()*1e9 > 750) continue;
2758 clu ->GetMomentum(pEMCAL ,vtx);
2759 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();firstGammaIndex++){
2760 AliKFParticle * twoGammaDecayCandidateDaughter0 = (AliKFParticle *)fKFReconstructedGammasTClone->At(firstGammaIndex);
2761 gammaGammaConv.SetXYZM(twoGammaDecayCandidateDaughter0->Px(),
2762 twoGammaDecayCandidateDaughter0->Py(),
2763 twoGammaDecayCandidateDaughter0->Pz(),0.);
2764 gammaEMCAL.SetXYZM(pEMCAL.Px(),pEMCAL.Py(),pEMCAL.Pz(),0.);
2765 pi0GammaConvEMCAL=gammaGammaConv+gammaEMCAL;
2766 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvEMCAL",pi0GammaConvEMCAL.M());
2767 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt_GammaConvEMCAL",pi0GammaConvEMCAL.M(),pi0GammaConvEMCAL.Pt());
2768 TVector3 v3D0(twoGammaDecayCandidateDaughter0->Px(),
2769 twoGammaDecayCandidateDaughter0->Py(),
2770 twoGammaDecayCandidateDaughter0->Pz());
2771 TVector3 v3D1(gammaEMCAL.Px(),gammaEMCAL.Py(),gammaEMCAL.Pz());
2774 Double_t opanConvEMCAL= v3D0.Angle(v3D1);
2775 if ( opanConvEMCAL < 0.35){
2776 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvEMCAL_OpanLow",pi0GammaConvEMCAL.M());
2778 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvEMCAL_OpanHigh",pi0GammaConvEMCAL.M());
2782 if(fCalculateBackground){
2783 for(Int_t nEventsInBG=0;nEventsInBG <fV0Reader->GetNBGEvents();nEventsInBG++){
2784 AliGammaConversionKFVector * previousEventV0s = fV0Reader->GetBGGoodV0s(nEventsInBG);
2785 for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
2786 AliKFParticle previousGoodV0 = (AliKFParticle)(*(previousEventV0s->at(iPrevious)));
2787 gammaGammaConvBck.SetXYZM(previousGoodV0.Px(),
2788 previousGoodV0.Py(),
2789 previousGoodV0.Pz(),0.);
2790 pi0GammaConvEMCALBck=gammaGammaConvBck+gammaEMCAL;
2791 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvEMCAL_Bck",pi0GammaConvEMCALBck.M());
2792 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt_GammaConvEMCAL_Bck",pi0GammaConvEMCALBck.M(),
2793 pi0GammaConvEMCALBck.Pt());
2797 // Now the LorentVector pEMCAL is obtained and can be paired with the converted proton
2798 } // end of checking if background photons are available
2800 //==== End of the PHOS cluster selection ============
2805 void AliAnalysisTaskGammaConversion::MoveParticleAccordingToVertex(AliKFParticle * particle,const AliGammaConversionBGHandler::GammaConversionVertex *vertex){
2806 //see header file for documentation
2808 Double_t dx = vertex->fX - fESDEvent->GetPrimaryVertex()->GetX();
2809 Double_t dy = vertex->fY - fESDEvent->GetPrimaryVertex()->GetY();
2810 Double_t dz = vertex->fZ - fESDEvent->GetPrimaryVertex()->GetZ();
2812 // cout<<"dx, dy, dz: ["<<dx<<","<<dy<<","<<dz<<"]"<<endl;
2813 particle->X() = particle->GetX() - dx;
2814 particle->Y() = particle->GetY() - dy;
2815 particle->Z() = particle->GetZ() - dz;
2818 void AliAnalysisTaskGammaConversion::RotateKFParticle(AliKFParticle * kfParticle,Double_t angle){
2819 // Before rotate needs to be moved to position 0,0,0, ; move back after rotation
2820 Double_t dx = fESDEvent->GetPrimaryVertex()->GetX()-0.;
2821 Double_t dy = fESDEvent->GetPrimaryVertex()->GetY()-0.;
2822 Double_t dz = fESDEvent->GetPrimaryVertex()->GetZ()-0.;
2824 kfParticle->X() = kfParticle->GetX() - dx;
2825 kfParticle->Y() = kfParticle->GetY() - dy;
2826 kfParticle->Z() = kfParticle->GetZ() - dz;
2829 // Rotate the kf particle
2830 Double_t c = cos(angle);
2831 Double_t s = sin(angle);
2834 for( Int_t i=0; i<8; i++ ){
2835 for( Int_t j=0; j<8; j++){
2839 for( int i=0; i<8; i++ ){
2842 mA[0][0] = c; mA[0][1] = s;
2843 mA[1][0] = -s; mA[1][1] = c;
2844 mA[3][3] = c; mA[3][4] = s;
2845 mA[4][3] = -s; mA[4][4] = c;
2850 for( Int_t i=0; i<8; i++ ){
2852 for( Int_t k=0; k<8; k++){
2853 mAp[i]+=mA[i][k] * kfParticle->GetParameter(k);
2857 for( Int_t i=0; i<8; i++){
2858 kfParticle->Parameter(i) = mAp[i];
2861 for( Int_t i=0; i<8; i++ ){
2862 for( Int_t j=0; j<8; j++ ){
2864 for( Int_t k=0; k<8; k++ ){
2865 mAC[i][j]+= mA[i][k] * kfParticle->GetCovariance(k,j);
2870 for( Int_t i=0; i<8; i++ ){
2871 for( Int_t j=0; j<=i; j++ ){
2873 for( Int_t k=0; k<8; k++){
2874 xx+= mAC[i][k]*mA[j][k];
2876 kfParticle->Covariance(i,j) = xx;
2880 Double_t dx1 = 0.-fESDEvent->GetPrimaryVertex()->GetX();
2881 Double_t dy1 = 0.-fESDEvent->GetPrimaryVertex()->GetY();
2882 Double_t dz1 = 0.-fESDEvent->GetPrimaryVertex()->GetZ();
2884 kfParticle->X() = kfParticle->GetX() - dx1;
2885 kfParticle->Y() = kfParticle->GetY() - dy1;
2886 kfParticle->Z() = kfParticle->GetZ() - dz1;
2891 void AliAnalysisTaskGammaConversion::CalculateBackground(){
2892 // see header file for documentation
2895 TClonesArray * currentEventV0s = fV0Reader->GetCurrentEventGoodV0s();
2897 AliGammaConversionBGHandler * bgHandler = fV0Reader->GetBGHandler();
2899 Int_t zbin= bgHandler->GetZBinIndex(fV0Reader->GetVertexZ());
2901 if(fUseTrackMultiplicityForBG == kTRUE){
2902 mbin = bgHandler->GetMultiplicityBinIndex(fV0Reader->CountESDTracks());
2905 mbin = bgHandler->GetMultiplicityBinIndex(fV0Reader->GetNGoodV0s());
2908 if(fDoRotation == kTRUE){
2909 TRandom3 *random = new TRandom3(0);
2911 for(Int_t iCurrent=0;iCurrent<currentEventV0s->GetEntriesFast();iCurrent++){
2912 AliKFParticle currentEventGoodV0 = *(AliKFParticle *)(currentEventV0s->At(iCurrent));
2913 for(Int_t iCurrent2=iCurrent+1;iCurrent2<currentEventV0s->GetEntriesFast();iCurrent2++){
2914 for(Int_t nRandom=0;nRandom<fNRandomEventsForBG;nRandom++){
2916 AliKFParticle currentEventGoodV02 = *(AliKFParticle *)(currentEventV0s->At(iCurrent2));
2918 if(fCheckBGProbability == kTRUE){
2919 Double_t massBGprob =0.;
2920 Double_t widthBGprob = 0.;
2921 AliKFParticle *backgroundCandidateProb = new AliKFParticle(currentEventGoodV0,currentEventGoodV02);
2922 backgroundCandidateProb->GetMass(massBGprob,widthBGprob);
2923 if(massBGprob>0.1 && massBGprob<0.14){
2924 if(random->Rndm()>bgHandler->GetBGProb(zbin,mbin)){
2925 delete backgroundCandidateProb;
2929 delete backgroundCandidateProb;
2932 Double_t nRadiansPM = fNDegreesPMBackground*TMath::Pi()/180;
2934 Double_t rotationValue = random->Rndm()*2*nRadiansPM + TMath::Pi()-nRadiansPM;
2936 RotateKFParticle(¤tEventGoodV02,rotationValue);
2938 AliKFParticle *backgroundCandidate = new AliKFParticle(currentEventGoodV0,currentEventGoodV02);
2940 Double_t massBG =0.;
2941 Double_t widthBG = 0.;
2942 Double_t chi2BG =10000.;
2943 backgroundCandidate->GetMass(massBG,widthBG);
2944 // if(backgroundCandidate->GetNDF()>0){
2945 chi2BG = backgroundCandidate->GetChi2();
2946 if((chi2BG>0 && chi2BG<fV0Reader->GetChi2CutMeson()) || fApplyChi2Cut == kFALSE){
2948 TVector3 momentumVectorbackgroundCandidate(backgroundCandidate->GetPx(),backgroundCandidate->GetPy(),backgroundCandidate->GetPz());
2949 TVector3 spaceVectorbackgroundCandidate(backgroundCandidate->GetX(),backgroundCandidate->GetY(),backgroundCandidate->GetZ());
2951 Double_t openingAngleBG = currentEventGoodV0.GetAngle(currentEventGoodV02);
2954 if(backgroundCandidate->GetE() - backgroundCandidate->GetPz() == 0 || backgroundCandidate->GetE() + backgroundCandidate->GetPz() == 0) rapidity=0;
2955 else rapidity = 0.5*(TMath::Log((backgroundCandidate->GetE() +backgroundCandidate->GetPz()) / (backgroundCandidate->GetE()-backgroundCandidate->GetPz())));
2957 if(TMath::Abs(rapidity) > fV0Reader->GetRapidityMesonCut() ){
2958 delete backgroundCandidate;
2959 continue; // rapidity cut
2964 if( (currentEventGoodV0.GetE()+currentEventGoodV02.GetE()) != 0){
2965 alfa=TMath::Abs((currentEventGoodV0.GetE()-currentEventGoodV02.GetE())
2966 /(currentEventGoodV0.GetE()+currentEventGoodV02.GetE()));
2970 if(openingAngleBG < fMinOpeningAngleGhostCut ){
2971 delete backgroundCandidate;
2972 continue; // minimum opening angle to avoid using ghosttracks
2976 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
2977 fHistograms->FillHistogram("ESD_Background_GammaDaughter_OpeningAngle", openingAngleBG);
2978 fHistograms->FillHistogram("ESD_Background_Energy", backgroundCandidate->GetE());
2979 fHistograms->FillHistogram("ESD_Background_Pt", momentumVectorbackgroundCandidate.Pt());
2980 fHistograms->FillHistogram("ESD_Background_Eta", momentumVectorbackgroundCandidate.Eta());
2981 fHistograms->FillHistogram("ESD_Background_Rapidity", rapidity);
2982 fHistograms->FillHistogram("ESD_Background_Phi", spaceVectorbackgroundCandidate.Phi());
2983 fHistograms->FillHistogram("ESD_Background_Mass", massBG);
2984 fHistograms->FillHistogram("ESD_Background_R", spaceVectorbackgroundCandidate.Pt()); // Pt in Space == R!!!!
2985 fHistograms->FillHistogram("ESD_Background_ZR", backgroundCandidate->GetZ(), spaceVectorbackgroundCandidate.Pt());
2986 fHistograms->FillHistogram("ESD_Background_XY", backgroundCandidate->GetX(), backgroundCandidate->GetY());
2987 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt",massBG,momentumVectorbackgroundCandidate.Pt());
2988 fHistograms->FillHistogram("ESD_Background_InvMass",massBG);
2989 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt_alpha",massBG,momentumVectorbackgroundCandidate.Pt());
2991 if(massBG>0.1 && massBG<0.15){
2992 fHistograms->FillHistogram("ESD_Background_alfa_Pi0", alfa);
2994 if(massBG>0.5 && massBG<0.57){
2995 fHistograms->FillHistogram("ESD_Background_alfa_Eta", alfa);
2998 if ( TMath::Abs(currentEventGoodV0.GetEta())<0.9 && TMath::Abs(currentEventGoodV02.GetEta())<0.9 ){
2999 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt_Fiducial",massBG,momentumVectorbackgroundCandidate.Pt());
3000 fHistograms->FillHistogram("ESD_Background_InvMass_Fiducial",massBG);
3003 fHistograms->FillHistogram(Form("%d%dESD_Background_GammaDaughter_OpeningAngle",zbin,mbin), openingAngleBG);
3004 fHistograms->FillHistogram(Form("%d%dESD_Background_Energy",zbin,mbin), backgroundCandidate->GetE());
3005 fHistograms->FillHistogram(Form("%d%dESD_Background_Pt",zbin,mbin), momentumVectorbackgroundCandidate.Pt());
3006 fHistograms->FillHistogram(Form("%d%dESD_Background_Eta",zbin,mbin), momentumVectorbackgroundCandidate.Eta());
3007 fHistograms->FillHistogram(Form("%d%dESD_Background_Rapidity",zbin,mbin), rapidity);
3008 fHistograms->FillHistogram(Form("%d%dESD_Background_Phi",zbin,mbin), spaceVectorbackgroundCandidate.Phi());
3009 fHistograms->FillHistogram(Form("%d%dESD_Background_Mass",zbin,mbin), massBG);
3010 fHistograms->FillHistogram(Form("%d%dESD_Background_R",zbin,mbin), spaceVectorbackgroundCandidate.Pt()); // Pt in Space == R!!!!
3011 fHistograms->FillHistogram(Form("%d%dESD_Background_ZR",zbin,mbin), backgroundCandidate->GetZ(), spaceVectorbackgroundCandidate.Pt());
3012 fHistograms->FillHistogram(Form("%d%dESD_Background_XY",zbin,mbin), backgroundCandidate->GetX(), backgroundCandidate->GetY());
3013 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_vs_Pt",zbin,mbin),massBG,momentumVectorbackgroundCandidate.Pt());
3014 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass",zbin,mbin),massBG);
3016 if ( TMath::Abs(currentEventGoodV0.GetEta())<0.9 && TMath::Abs(currentEventGoodV02.GetEta())<0.9 ){
3017 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_vs_Pt_Fiducial",zbin,mbin),massBG,momentumVectorbackgroundCandidate.Pt());
3018 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_Fiducial",zbin,mbin),massBG);
3022 fHistograms->FillHistogram("ESD_Background_InvMass_vs_E_alpha",massBG ,backgroundCandidate->GetE());
3027 delete backgroundCandidate;
3033 else{ // means no rotation
3034 AliGammaConversionBGHandler::GammaConversionVertex *bgEventVertex = NULL;
3036 if(fUseTrackMultiplicityForBG){
3037 // cout<<"Using charged track multiplicity for background calculation"<<endl;
3038 for(Int_t nEventsInBG=0;nEventsInBG <fV0Reader->GetNBGEvents();nEventsInBG++){
3040 AliGammaConversionKFVector * previousEventV0s = bgHandler->GetBGGoodV0s(zbin,mbin,nEventsInBG);//fV0Reader->GetBGGoodV0s(nEventsInBG);
3042 if(fMoveParticleAccordingToVertex == kTRUE){
3043 bgEventVertex = bgHandler->GetBGEventVertex(zbin,mbin,nEventsInBG);
3046 for(Int_t iCurrent=0;iCurrent<currentEventV0s->GetEntriesFast();iCurrent++){
3047 AliKFParticle currentEventGoodV0 = *(AliKFParticle *)(currentEventV0s->At(iCurrent));
3048 for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
3049 AliKFParticle previousGoodV0 = (AliKFParticle)(*(previousEventV0s->at(iPrevious)));
3050 AliKFParticle previousGoodV0test = (AliKFParticle)(*(previousEventV0s->at(iPrevious)));
3052 //cout<<"Primary Vertex event: ["<<fESDEvent->GetPrimaryVertex()->GetX()<<","<<fESDEvent->GetPrimaryVertex()->GetY()<<","<<fESDEvent->GetPrimaryVertex()->GetZ()<<"]"<<endl;
3053 //cout<<"BG prim Vertex event: ["<<bgEventVertex->fX<<","<<bgEventVertex->fY<<","<<bgEventVertex->fZ<<"]"<<endl;
3055 //cout<<"XYZ of particle before transport: ["<<previousGoodV0.X()<<","<<previousGoodV0.Y()<<","<<previousGoodV0.Z()<<"]"<<endl;
3056 if(fMoveParticleAccordingToVertex == kTRUE){
3057 MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
3059 //cout<<"XYZ of particle after transport: ["<<previousGoodV0.X()<<","<<previousGoodV0.Y()<<","<<previousGoodV0.Z()<<"]"<<endl;
3061 AliKFParticle *backgroundCandidate = new AliKFParticle(currentEventGoodV0,previousGoodV0);
3063 Double_t massBG =0.;
3064 Double_t widthBG = 0.;
3065 Double_t chi2BG =10000.;
3066 backgroundCandidate->GetMass(massBG,widthBG);
3068 // if(backgroundCandidate->GetNDF()>0){
3069 // chi2BG = backgroundCandidate->GetChi2()/backgroundCandidate->GetNDF();
3070 chi2BG = backgroundCandidate->GetChi2();
3071 if((chi2BG>0 && chi2BG<fV0Reader->GetChi2CutMeson()) || fApplyChi2Cut == kFALSE){
3073 TVector3 momentumVectorbackgroundCandidate(backgroundCandidate->GetPx(),backgroundCandidate->GetPy(),backgroundCandidate->GetPz());
3074 TVector3 spaceVectorbackgroundCandidate(backgroundCandidate->GetX(),backgroundCandidate->GetY(),backgroundCandidate->GetZ());
3076 Double_t openingAngleBG = currentEventGoodV0.GetAngle(previousGoodV0);
3080 if(backgroundCandidate->GetE() - backgroundCandidate->GetPz() <= 0 || backgroundCandidate->GetE() + backgroundCandidate->GetPz() <= 0){
3081 cout << "Error: |Pz| > E !!!! " << endl;
3084 rapidity = 0.5*(TMath::Log((backgroundCandidate->GetE() +backgroundCandidate->GetPz()) / (backgroundCandidate->GetE()-backgroundCandidate->GetPz())));
3086 if(TMath::Abs(rapidity) > fV0Reader->GetRapidityMesonCut() ){
3087 delete backgroundCandidate;
3088 continue; // rapidity cut
3093 if( (currentEventGoodV0.GetE()+previousGoodV0.GetE()) != 0){
3094 alfa=TMath::Abs((currentEventGoodV0.GetE()-previousGoodV0.GetE())
3095 /(currentEventGoodV0.GetE()+previousGoodV0.GetE()));
3099 if(openingAngleBG < fMinOpeningAngleGhostCut ){
3100 delete backgroundCandidate;
3101 continue; // minimum opening angle to avoid using ghosttracks
3105 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
3106 fHistograms->FillHistogram("ESD_Background_GammaDaughter_OpeningAngle", openingAngleBG);
3107 fHistograms->FillHistogram("ESD_Background_Energy", backgroundCandidate->GetE());
3108 fHistograms->FillHistogram("ESD_Background_Pt", momentumVectorbackgroundCandidate.Pt());
3109 fHistograms->FillHistogram("ESD_Background_Eta", momentumVectorbackgroundCandidate.Eta());
3110 fHistograms->FillHistogram("ESD_Background_Rapidity", rapidity);
3111 fHistograms->FillHistogram("ESD_Background_Phi", spaceVectorbackgroundCandidate.Phi());
3112 fHistograms->FillHistogram("ESD_Background_Mass", massBG);
3113 fHistograms->FillHistogram("ESD_Background_R", spaceVectorbackgroundCandidate.Pt()); // Pt in Space == R!!!!
3114 fHistograms->FillHistogram("ESD_Background_ZR", backgroundCandidate->GetZ(), spaceVectorbackgroundCandidate.Pt());
3115 fHistograms->FillHistogram("ESD_Background_XY", backgroundCandidate->GetX(), backgroundCandidate->GetY());
3116 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt",massBG,momentumVectorbackgroundCandidate.Pt());
3117 fHistograms->FillHistogram("ESD_Background_InvMass",massBG);
3118 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt_alpha",massBG,momentumVectorbackgroundCandidate.Pt());
3120 if(massBG>0.1 && massBG<0.15){
3121 fHistograms->FillHistogram("ESD_Background_alfa_Pi0", alfa);
3123 if(massBG>0.5 && massBG<0.57){
3124 fHistograms->FillHistogram("ESD_Background_alfa_Eta", alfa);
3127 if ( TMath::Abs(currentEventGoodV0.GetEta())<0.9 && TMath::Abs(previousGoodV0.GetEta())<0.9 ){
3128 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt_Fiducial",massBG,momentumVectorbackgroundCandidate.Pt());
3129 fHistograms->FillHistogram("ESD_Background_InvMass_Fiducial",massBG);
3133 fHistograms->FillHistogram(Form("%d%dESD_Background_GammaDaughter_OpeningAngle",zbin,mbin), openingAngleBG);
3134 fHistograms->FillHistogram(Form("%d%dESD_Background_Energy",zbin,mbin), backgroundCandidate->GetE());
3135 fHistograms->FillHistogram(Form("%d%dESD_Background_Pt",zbin,mbin), momentumVectorbackgroundCandidate.Pt());
3136 fHistograms->FillHistogram(Form("%d%dESD_Background_Eta",zbin,mbin), momentumVectorbackgroundCandidate.Eta());
3137 fHistograms->FillHistogram(Form("%d%dESD_Background_Rapidity",zbin,mbin), rapidity);
3138 fHistograms->FillHistogram(Form("%d%dESD_Background_Phi",zbin,mbin), spaceVectorbackgroundCandidate.Phi());
3139 fHistograms->FillHistogram(Form("%d%dESD_Background_Mass",zbin,mbin), massBG);
3140 fHistograms->FillHistogram(Form("%d%dESD_Background_R",zbin,mbin), spaceVectorbackgroundCandidate.Pt()); // Pt in Space == R!!!!
3141 fHistograms->FillHistogram(Form("%d%dESD_Background_ZR",zbin,mbin), backgroundCandidate->GetZ(), spaceVectorbackgroundCandidate.Pt());
3142 fHistograms->FillHistogram(Form("%d%dESD_Background_XY",zbin,mbin), backgroundCandidate->GetX(), backgroundCandidate->GetY());
3143 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_vs_Pt",zbin,mbin),massBG,momentumVectorbackgroundCandidate.Pt());
3144 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass",zbin,mbin),massBG);
3146 if ( TMath::Abs(currentEventGoodV0.GetEta())<0.9 && TMath::Abs(previousGoodV0.GetEta())<0.9 ){
3147 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_vs_Pt_Fiducial",zbin,mbin),massBG,momentumVectorbackgroundCandidate.Pt());
3148 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_Fiducial",zbin,mbin),massBG);
3153 fHistograms->FillHistogram("ESD_Background_InvMass_vs_E_alpha",massBG ,backgroundCandidate->GetE());
3157 delete backgroundCandidate;
3162 else{ // means using #V0s for multiplicity
3164 // cout<<"Using the v0 multiplicity to calculate background"<<endl;
3166 fHistograms->FillHistogram("ESD_Background_z_m",zbin,mbin);
3167 fHistograms->FillHistogram("ESD_Mother_multpilicityVSv0s",fV0Reader->CountESDTracks(),fV0Reader->GetNumberOfV0s());
3169 for(Int_t nEventsInBG=0;nEventsInBG <fV0Reader->GetNBGEvents();nEventsInBG++){
3170 AliGammaConversionKFVector * previousEventV0s = bgHandler->GetBGGoodV0s(zbin,mbin,nEventsInBG);// fV0Reader->GetBGGoodV0s(nEventsInBG);
3171 if(previousEventV0s){
3173 if(fMoveParticleAccordingToVertex == kTRUE){
3174 bgEventVertex = bgHandler->GetBGEventVertex(zbin,mbin,nEventsInBG);
3177 for(Int_t iCurrent=0;iCurrent<currentEventV0s->GetEntriesFast();iCurrent++){
3178 AliKFParticle currentEventGoodV0 = *(AliKFParticle *)(currentEventV0s->At(iCurrent));
3179 for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
3180 AliKFParticle previousGoodV0 = (AliKFParticle)(*(previousEventV0s->at(iPrevious)));
3182 if(fMoveParticleAccordingToVertex == kTRUE){
3183 MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
3186 AliKFParticle *backgroundCandidate = new AliKFParticle(currentEventGoodV0,previousGoodV0);
3187 Double_t massBG =0.;
3188 Double_t widthBG = 0.;
3189 Double_t chi2BG =10000.;
3190 backgroundCandidate->GetMass(massBG,widthBG);
3192 /* if(backgroundCandidate->GetNDF()>0){
3193 chi2BG = backgroundCandidate->GetChi2()/backgroundCandidate->GetNDF();
3194 {//remember to remove
3195 TVector3 momentumVectorbackgroundCandidate(backgroundCandidate->GetPx(),backgroundCandidate->GetPy(),backgroundCandidate->GetPz());
3196 TVector3 spaceVectorbackgroundCandidate(backgroundCandidate->GetX(),backgroundCandidate->GetY(),backgroundCandidate->GetZ());
3198 Double_t openingAngleBG = currentEventGoodV0.GetAngle(previousGoodV0);
3199 fHistograms->FillHistogram("ESD_Background_GammaDaughter_OpeningAngle_nochi2", openingAngleBG);
3202 chi2BG = backgroundCandidate->GetChi2();
3203 if((chi2BG>0 && chi2BG<fV0Reader->GetChi2CutMeson()) || fApplyChi2Cut == kFALSE){
3204 TVector3 momentumVectorbackgroundCandidate(backgroundCandidate->GetPx(),backgroundCandidate->GetPy(),backgroundCandidate->GetPz());
3205 TVector3 spaceVectorbackgroundCandidate(backgroundCandidate->GetX(),backgroundCandidate->GetY(),backgroundCandidate->GetZ());
3207 Double_t openingAngleBG = currentEventGoodV0.GetAngle(previousGoodV0);
3210 if(backgroundCandidate->GetE() - backgroundCandidate->GetPz() == 0 || backgroundCandidate->GetE() + backgroundCandidate->GetPz() == 0) rapidity=0;
3211 else rapidity = 0.5*(TMath::Log((backgroundCandidate->GetE() +backgroundCandidate->GetPz()) / (backgroundCandidate->GetE()-backgroundCandidate->GetPz())));
3213 if(TMath::Abs(rapidity) > fV0Reader->GetRapidityMesonCut() ){
3214 delete backgroundCandidate;
3215 continue; // rapidity cut
3220 if( (currentEventGoodV0.GetE()+previousGoodV0.GetE()) != 0){
3221 alfa=TMath::Abs((currentEventGoodV0.GetE()-previousGoodV0.GetE())
3222 /(currentEventGoodV0.GetE()+previousGoodV0.GetE()));
3226 if(openingAngleBG < fMinOpeningAngleGhostCut ){
3227 delete backgroundCandidate;
3228 continue; // minimum opening angle to avoid using ghosttracks
3231 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
3232 fHistograms->FillHistogram("ESD_Background_GammaDaughter_OpeningAngle", openingAngleBG);
3233 fHistograms->FillHistogram("ESD_Background_Energy", backgroundCandidate->GetE());
3234 fHistograms->FillHistogram("ESD_Background_Pt", momentumVectorbackgroundCandidate.Pt());
3235 fHistograms->FillHistogram("ESD_Background_Eta", momentumVectorbackgroundCandidate.Eta());
3236 fHistograms->FillHistogram("ESD_Background_Rapidity", rapidity);
3237 fHistograms->FillHistogram("ESD_Background_Phi", spaceVectorbackgroundCandidate.Phi());
3238 fHistograms->FillHistogram("ESD_Background_Mass", massBG);
3239 fHistograms->FillHistogram("ESD_Background_R", spaceVectorbackgroundCandidate.Pt()); // Pt in Space == R!!!!
3240 fHistograms->FillHistogram("ESD_Background_ZR", backgroundCandidate->GetZ(), spaceVectorbackgroundCandidate.Pt());
3241 fHistograms->FillHistogram("ESD_Background_XY", backgroundCandidate->GetX(), backgroundCandidate->GetY());
3242 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt",massBG,momentumVectorbackgroundCandidate.Pt());
3243 fHistograms->FillHistogram("ESD_Background_InvMass",massBG);
3246 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt_alpha",massBG,momentumVectorbackgroundCandidate.Pt());
3248 if(massBG>0.1 && massBG<0.15){
3249 fHistograms->FillHistogram("ESD_Background_alfa_Pi0", alfa);
3251 if(massBG>0.5 && massBG<0.57){
3252 fHistograms->FillHistogram("ESD_Background_alfa_Eta", alfa);
3255 if ( TMath::Abs(currentEventGoodV0.GetEta())<0.9 && TMath::Abs(previousGoodV0.GetEta())<0.9 ){
3256 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt_Fiducial",massBG,momentumVectorbackgroundCandidate.Pt());
3257 fHistograms->FillHistogram("ESD_Background_InvMass_Fiducial",massBG);
3260 if(massBG>0.5 && massBG<0.6){
3261 fHistograms->FillHistogram("ESD_Background_alfa_pt0506",momentumVectorbackgroundCandidate.Pt(),alfa);
3263 if(massBG>0.3 && massBG<0.4){
3264 fHistograms->FillHistogram("ESD_Background_alfa_pt0304",momentumVectorbackgroundCandidate.Pt(),alfa);
3268 fHistograms->FillHistogram(Form("%d%dESD_Background_GammaDaughter_OpeningAngle",zbin,mbin), openingAngleBG);
3269 fHistograms->FillHistogram(Form("%d%dESD_Background_Energy",zbin,mbin), backgroundCandidate->GetE());
3270 fHistograms->FillHistogram(Form("%d%dESD_Background_Pt",zbin,mbin), momentumVectorbackgroundCandidate.Pt());
3271 fHistograms->FillHistogram(Form("%d%dESD_Background_Eta",zbin,mbin), momentumVectorbackgroundCandidate.Eta());
3272 fHistograms->FillHistogram(Form("%d%dESD_Background_Rapidity",zbin,mbin), rapidity);
3273 fHistograms->FillHistogram(Form("%d%dESD_Background_Phi",zbin,mbin), spaceVectorbackgroundCandidate.Phi());
3274 fHistograms->FillHistogram(Form("%d%dESD_Background_Mass",zbin,mbin), massBG);
3275 fHistograms->FillHistogram(Form("%d%dESD_Background_R",zbin,mbin), spaceVectorbackgroundCandidate.Pt()); // Pt in Space == R!!!!
3276 fHistograms->FillHistogram(Form("%d%dESD_Background_ZR",zbin,mbin), backgroundCandidate->GetZ(), spaceVectorbackgroundCandidate.Pt());
3277 fHistograms->FillHistogram(Form("%d%dESD_Background_XY",zbin,mbin), backgroundCandidate->GetX(), backgroundCandidate->GetY());
3278 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_vs_Pt",zbin,mbin),massBG,momentumVectorbackgroundCandidate.Pt());
3279 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass",zbin,mbin),massBG);
3281 if ( TMath::Abs(currentEventGoodV0.GetEta())<0.9 && TMath::Abs(previousGoodV0.GetEta())<0.9 ){
3282 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_vs_Pt_Fiducial",zbin,mbin),massBG,momentumVectorbackgroundCandidate.Pt());
3283 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_Fiducial",zbin,mbin),massBG);
3288 fHistograms->FillHistogram("ESD_Background_InvMass_vs_E_alpha",massBG ,backgroundCandidate->GetE());
3292 delete backgroundCandidate;
3297 } // end else (means use #v0s as multiplicity)
3298 } // end no rotation
3302 void AliAnalysisTaskGammaConversion::ProcessGammasForGammaJetAnalysis(){
3303 //ProcessGammasForGammaJetAnalysis
3305 Double_t distIsoMin;
3307 CreateListOfChargedParticles();
3310 // for(UInt_t gammaIndex=0;gammaIndex<fKFReconstructedGammas.size();gammaIndex++){
3311 for(Int_t gammaIndex=0;gammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();gammaIndex++){
3312 AliKFParticle * currentGamma = (AliKFParticle*)fKFReconstructedGammasTClone->At(gammaIndex);
3313 TVector3 momentumVectorCurrentGamma(currentGamma->GetPx(),currentGamma->GetPy(),currentGamma->GetPz());
3315 if( momentumVectorCurrentGamma.Pt()> fMinPtForGammaJet){
3316 distIsoMin=GetMinimumDistanceToCharge(gammaIndex);
3318 if (distIsoMin > fMinIsoConeSize && fLeadingChargedIndex>=0){
3319 CalculateJetCone(gammaIndex);
3325 //____________________________________________________________________
3326 Bool_t AliAnalysisTaskGammaConversion::IsGoodImpPar(const AliESDtrack *const track)
3329 // check whether particle has good DCAr(Pt) impact
3330 // parameter. Only for TPC+ITS tracks (7*sigma cut)
3331 // Origin: Andrea Dainese
3334 Float_t d0z0[2],covd0z0[3];
3335 track->GetImpactParameters(d0z0,covd0z0);
3336 Float_t sigma= 0.0050+0.0060/TMath::Power(track->Pt(),0.9);
3337 Float_t d0max = 7.*sigma;
3338 if(TMath::Abs(d0z0[0]) < d0max) return kTRUE;
3344 void AliAnalysisTaskGammaConversion::CreateListOfChargedParticles(){
3345 // CreateListOfChargedParticles
3347 fESDEvent = fV0Reader->GetESDEvent();
3348 Int_t numberOfESDTracks=0;
3349 for(Int_t iTracks = 0; iTracks < fESDEvent->GetNumberOfTracks(); iTracks++){
3350 AliESDtrack* curTrack = fESDEvent->GetTrack(iTracks);
3355 // Not needed if Standard function used.
3356 // if(!IsGoodImpPar(curTrack)){
3360 if(fEsdTrackCuts->AcceptTrack(curTrack) ){
3361 new((*fChargedParticles)[fChargedParticles->GetEntriesFast()]) AliESDtrack(*curTrack);
3362 // fChargedParticles.push_back(curTrack);
3363 fChargedParticlesId.push_back(iTracks);
3364 numberOfESDTracks++;
3367 // Moved to UserExec using CountAcceptedTracks function. runjet is not needed by default
3368 // fHistograms->FillHistogram("ESD_NumberOfGoodESDTracks",numberOfESDTracks);
3369 // cout<<"esdtracks::"<< numberOfESDTracks<<endl;
3370 // if (fV0Reader->GetNumberOfContributorsVtx()>=1){
3371 // fHistograms->FillHistogram("ESD_NumberOfGoodESDTracksVtx",numberOfESDTracks);
3374 void AliAnalysisTaskGammaConversion::RecalculateV0ForGamma(){
3375 //recalculates v0 for gamma
3377 Double_t massE=0.00051099892;
3378 TLorentzVector curElecPos;
3379 TLorentzVector curElecNeg;
3380 TLorentzVector curGamma;
3382 TLorentzVector curGammaAt;
3383 TLorentzVector curElecPosAt;
3384 TLorentzVector curElecNegAt;
3385 AliKFVertex primVtxGamma(*(fESDEvent->GetPrimaryVertex()));
3386 AliKFVertex primVtxImprovedGamma = primVtxGamma;
3388 const AliESDVertex *vtxT3D=fESDEvent->GetPrimaryVertex();
3390 Double_t xPrimaryVertex=vtxT3D->GetXv();
3391 Double_t yPrimaryVertex=vtxT3D->GetYv();
3392 Double_t zPrimaryVertex=vtxT3D->GetZv();
3393 // Float_t primvertex[3]={xPrimaryVertex,yPrimaryVertex,zPrimaryVertex};
3395 Float_t nsigmaTPCtrackPos;
3396 Float_t nsigmaTPCtrackNeg;
3397 Float_t nsigmaTPCtrackPosToPion;
3398 Float_t nsigmaTPCtrackNegToPion;
3399 AliKFParticle* negKF=NULL;
3400 AliKFParticle* posKF=NULL;
3402 for(Int_t iTracks = 0; iTracks < fESDEvent->GetNumberOfTracks(); iTracks++){
3403 AliESDtrack* posTrack = fESDEvent->GetTrack(iTracks);
3407 if (posKF) delete posKF; posKF=NULL;
3408 if(posTrack->GetSign()<0) continue;
3409 if(!(posTrack->GetStatus() & AliESDtrack::kTPCrefit))continue;
3410 if(posTrack->GetKinkIndex(0)>0 ) continue;
3411 if(posTrack->GetNcls(1)<50)continue;
3413 // posTrack->GetConstrainedPxPyPz(momPos);
3414 posTrack->GetPxPyPz(momPos);
3415 AliESDtrack *ptrk=fESDEvent->GetTrack(iTracks);
3416 curElecPos.SetXYZM(momPos[0],momPos[1],momPos[2],massE);
3417 if(TMath::Abs(curElecPos.Eta())<0.9) continue;
3418 posKF = new AliKFParticle( *(posTrack),-11);
3420 nsigmaTPCtrackPos = fV0Reader->GetESDpid()->NumberOfSigmasTPC(posTrack,AliPID::kElectron);
3421 nsigmaTPCtrackPosToPion = fV0Reader->GetESDpid()->NumberOfSigmasTPC(posTrack,AliPID::kPion);
3423 if ( nsigmaTPCtrackPos>5.|| nsigmaTPCtrackPos<-2.){
3427 if(pow((momPos[0]*momPos[0]+momPos[1]*momPos[1]+momPos[2]*momPos[2]),0.5)>0.5 && nsigmaTPCtrackPosToPion<1){
3433 for(Int_t jTracks = 0; jTracks < fESDEvent->GetNumberOfTracks(); jTracks++){
3434 AliESDtrack* negTrack = fESDEvent->GetTrack(jTracks);
3438 if (negKF) delete negKF; negKF=NULL;
3439 if(negTrack->GetSign()>0) continue;
3440 if(!(negTrack->GetStatus() & AliESDtrack::kTPCrefit))continue;
3441 if(negTrack->GetKinkIndex(0)>0 ) continue;
3442 if(negTrack->GetNcls(1)<50)continue;
3444 // negTrack->GetConstrainedPxPyPz(momNeg);
3445 negTrack->GetPxPyPz(momNeg);
3447 nsigmaTPCtrackNeg = fV0Reader->GetESDpid()->NumberOfSigmasTPC(negTrack,AliPID::kElectron);
3448 nsigmaTPCtrackNegToPion = fV0Reader->GetESDpid()->NumberOfSigmasTPC(negTrack,AliPID::kPion);
3449 if ( nsigmaTPCtrackNeg>5. || nsigmaTPCtrackNeg<-2.){
3452 if(pow((momNeg[0]*momNeg[0]+momNeg[1]*momNeg[1]+momNeg[2]*momNeg[2]),0.5)>0.5 && nsigmaTPCtrackNegToPion<1){
3455 AliESDtrack *ntrk=fESDEvent->GetTrack(jTracks);
3456 curElecNeg.SetXYZM(momNeg[0],momNeg[1],momNeg[2],massE);
3457 if(TMath::Abs(curElecNeg.Eta())<0.9) continue;
3458 negKF = new AliKFParticle( *(negTrack) ,11);
3460 Double_t b=fESDEvent->GetMagneticField();
3461 Double_t xn, xp, dca=ntrk->GetDCA(ptrk,b,xn,xp);
3462 AliExternalTrackParam nt(*ntrk), pt(*ptrk);
3463 nt.PropagateTo(xn,b); pt.PropagateTo(xp,b);
3466 //--- Like in ITSV0Finder
3467 AliExternalTrackParam ntAt0(*ntrk), ptAt0(*ptrk);
3468 Double_t xxP,yyP,alphaP;
3471 // if (!ptAt0.GetGlobalXYZat(ptAt0->GetX(),xxP,yyP,zzP)) continue;
3472 if (!ptAt0.GetXYZAt(ptAt0.GetX(),b,rP)) continue;
3475 alphaP = TMath::ATan2(yyP,xxP);
3478 ptAt0.Propagate(alphaP,0,b);
3479 Float_t ptfacP = (1.+100.*TMath::Abs(ptAt0.GetC(b)));
3481 // Double_t distP = ptAt0.GetY();
3482 Double_t normP = ptfacP*TMath::Sqrt(ptAt0.GetSigmaY2());
3483 Double_t normdist0P = TMath::Abs(ptAt0.GetY()/normP);
3484 Double_t normdist1P = TMath::Abs((ptAt0.GetZ()-zPrimaryVertex)/(ptfacP*TMath::Sqrt(ptAt0.GetSigmaZ2())));
3485 Double_t normdistP = TMath::Sqrt(normdist0P*normdist0P+normdist1P*normdist1P);
3488 Double_t xxN,yyN,alphaN;
3490 // if (!ntAt0.GetGlobalXYZat(ntAt0->GetX(),xxN,yyN,zzN)) continue;
3491 if (!ntAt0.GetXYZAt(ntAt0.GetX(),b,rN)) continue;
3495 alphaN = TMath::ATan2(yyN,xxN);
3497 ntAt0.Propagate(alphaN,0,b);
3499 Float_t ptfacN = (1.+100.*TMath::Abs(ntAt0.GetC(b)));
3500 // Double_t distN = ntAt0.GetY();
3501 Double_t normN = ptfacN*TMath::Sqrt(ntAt0.GetSigmaY2());
3502 Double_t normdist0N = TMath::Abs(ntAt0.GetY()/normN);
3503 Double_t normdist1N = TMath::Abs((ntAt0.GetZ()-zPrimaryVertex)/(ptfacN*TMath::Sqrt(ntAt0.GetSigmaZ2())));
3504 Double_t normdistN = TMath::Sqrt(normdist0N*normdist0N+normdist1N*normdist1N);
3506 //-----------------------------
3508 Double_t momNegAt[3];
3509 nt.GetPxPyPz(momNegAt);
3510 curElecNegAt.SetXYZM(momNegAt[0],momNegAt[1],momNegAt[2],massE);
3512 Double_t momPosAt[3];
3513 pt.GetPxPyPz(momPosAt);
3514 curElecPosAt.SetXYZM(momPosAt[0],momPosAt[1],momPosAt[2],massE);
3519 // Double_t dneg= negTrack->GetD(xPrimaryVertex,yPrimaryVertex,b);
3520 // Double_t dpos= posTrack->GetD(xPrimaryVertex,yPrimaryVertex,b);
3521 AliESDv0 vertex(nt,jTracks,pt,iTracks);
3524 Float_t cpa=vertex.GetV0CosineOfPointingAngle(xPrimaryVertex,yPrimaryVertex,zPrimaryVertex);
3528 // cout<< "v0Rr::"<< v0Rr<<endl;
3529 // if (pvertex.GetRr()<0.5){
3532 // cout<<"vertex.GetChi2V0()"<<vertex.GetChi2V0()<<endl;
3533 if(cpa<0.9)continue;
3534 // if (vertex.GetChi2V0() > 30) continue;
3535 // cout<<"xp+xn::"<<xp<<" "<<xn<<endl;
3536 if ((xn+xp) < 0.4) continue;
3537 if (TMath::Abs(ntrk->GetD(xPrimaryVertex,yPrimaryVertex,b))<0.05)
3538 if (TMath::Abs(ptrk->GetD(xPrimaryVertex,yPrimaryVertex,b))<0.05) continue;
3540 //cout<<"pass"<<endl;
3542 AliKFParticle v0GammaC;
3545 v0GammaC.SetMassConstraint(0,0.001);
3546 primVtxImprovedGamma+=v0GammaC;
3547 v0GammaC.SetProductionVertex(primVtxImprovedGamma);
3550 curGamma=curElecNeg+curElecPos;
3551 curGammaAt=curElecNegAt+curElecPosAt;
3553 // invariant mass versus pt of K0short
3555 Double_t chi2V0GammaC=100000.;
3556 if( v0GammaC.GetNDF() != 0) {
3557 chi2V0GammaC = v0GammaC.GetChi2()/v0GammaC.GetNDF();
3559 cout<< "ERROR::v0K0C.GetNDF()" << endl;
3562 if(chi2V0GammaC<200 &&chi2V0GammaC>0 ){
3563 if(fHistograms != NULL){
3564 fHistograms->FillHistogram("ESD_RecalculateV0_InvMass",v0GammaC.GetMass());
3565 fHistograms->FillHistogram("ESD_RecalculateV0_Pt",v0GammaC.GetPt());
3566 fHistograms->FillHistogram("ESD_RecalculateV0_E_dEdxP",curElecNegAt.P(),negTrack->GetTPCsignal());
3567 fHistograms->FillHistogram("ESD_RecalculateV0_P_dEdxP",curElecPosAt.P(),posTrack->GetTPCsignal());
3568 fHistograms->FillHistogram("ESD_RecalculateV0_cpa",cpa);
3569 fHistograms->FillHistogram("ESD_RecalculateV0_dca",dca);
3570 fHistograms->FillHistogram("ESD_RecalculateV0_normdistP",normdistP);
3571 fHistograms->FillHistogram("ESD_RecalculateV0_normdistN",normdistN);
3573 new((*fKFRecalculatedGammasTClone)[fKFRecalculatedGammasTClone->GetEntriesFast()]) AliKFParticle(v0GammaC);
3574 fElectronRecalculatedv1.push_back(iTracks);
3575 fElectronRecalculatedv2.push_back(jTracks);
3581 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFRecalculatedGammasTClone->GetEntriesFast();firstGammaIndex++){
3582 for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fKFRecalculatedGammasTClone->GetEntriesFast();secondGammaIndex++){
3583 AliKFParticle * twoGammaDecayCandidateDaughter0 = (AliKFParticle *)fKFRecalculatedGammasTClone->At(firstGammaIndex);
3584 AliKFParticle * twoGammaDecayCandidateDaughter1 = (AliKFParticle *)fKFRecalculatedGammasTClone->At(secondGammaIndex);
3586 if(fElectronRecalculatedv1[firstGammaIndex]==fElectronRecalculatedv1[secondGammaIndex]){
3589 if( fElectronRecalculatedv2[firstGammaIndex]==fElectronRecalculatedv2[secondGammaIndex]){
3593 AliKFParticle twoGammaCandidate(*twoGammaDecayCandidateDaughter0,*twoGammaDecayCandidateDaughter1);
3594 if(fHistograms != NULL){
3595 fHistograms->FillHistogram("ESD_RecalculateGG_InvMass",twoGammaCandidate.GetMass());
3596 fHistograms->FillHistogram("ESD_RecalculateGG_InvMass_vs_Pt",twoGammaCandidate.GetMass(),twoGammaCandidate.GetPt());
3601 void AliAnalysisTaskGammaConversion::CalculateJetCone(Int_t gammaIndex){
3605 Double_t coneSize=0.3;
3608 // AliKFParticle * currentGamma = &fKFReconstructedGammas[gammaIndex];
3609 AliKFParticle * currentGamma = (AliKFParticle*)fKFReconstructedGammasTClone->At(gammaIndex);
3611 TVector3 momentumVectorCurrentGamma(currentGamma->GetPx(),currentGamma->GetPy(),currentGamma->GetPz());
3613 AliESDtrack* leadingCharged = (AliESDtrack*)(fChargedParticles->At(fLeadingChargedIndex));
3615 Double_t momLeadingCharged[3];
3616 leadingCharged->GetConstrainedPxPyPz(momLeadingCharged);
3618 TVector3 momentumVectorLeadingCharged(momLeadingCharged[0],momLeadingCharged[1],momLeadingCharged[2]);
3620 Double_t phi1=momentumVectorLeadingCharged.Phi();
3621 Double_t eta1=momentumVectorLeadingCharged.Eta();
3622 Double_t phi3=momentumVectorCurrentGamma.Phi();
3624 for(Int_t iCh=0;iCh<fChargedParticles->GetEntriesFast();iCh++){
3625 AliESDtrack* curTrack = (AliESDtrack*)(fChargedParticles->At(iCh));
3626 Int_t chId = fChargedParticlesId[iCh];
3627 if(fLeadingChargedIndex==chId || fLeadingChargedIndex==chId) continue;
3629 curTrack->GetConstrainedPxPyPz(mom);
3630 TVector3 momentumVectorChargedParticle(mom[0],mom[1],mom[2]);
3631 Double_t phi2=momentumVectorChargedParticle.Phi();
3632 Double_t eta2=momentumVectorChargedParticle.Eta();
3636 if( TMath::Abs(phi2 - phi1) <= ( TMath::TwoPi()-coneSize) ){
3637 cone = TMath::Sqrt( TMath::Power((eta2-eta1),2)+ TMath::Power((phi2-phi1),2) );
3639 if( (phi2 - phi1)> TMath::TwoPi()-coneSize ){
3640 cone = TMath::Sqrt( TMath::Power((eta2-eta1),2)+ TMath::Power((phi2-TMath::TwoPi()-phi1),2) );
3642 if( (phi2 - phi1)< -(TMath::TwoPi()-coneSize) ){
3643 cone = TMath::Sqrt( TMath::Power((eta2-eta1),2)+ TMath::Power((phi2+TMath::TwoPi()-phi1),2) );
3647 if(cone <coneSize&& momentumVectorChargedParticle.Pt()>fMinPtJetCone ){
3648 ptJet+= momentumVectorChargedParticle.Pt();
3649 Double_t ffzHdrGam = momentumVectorChargedParticle.Pt()/momentumVectorCurrentGamma.Pt();
3650 Double_t imbalanceHdrGam=-momentumVectorChargedParticle.Dot(momentumVectorCurrentGamma)/momentumVectorCurrentGamma.Mag2();
3651 fHistograms->FillHistogram("ESD_FFzHdrGam",ffzHdrGam);
3652 fHistograms->FillHistogram("ESD_ImbalanceHdrGam",imbalanceHdrGam);
3656 Double_t dphiHdrGam=phi3-phi2;
3657 if ( dphiHdrGam < (-TMath::PiOver2())){
3658 dphiHdrGam+=(TMath::TwoPi());
3661 if ( dphiHdrGam > (3.*TMath::PiOver2()) ){
3662 dphiHdrGam-=(TMath::TwoPi());
3665 if (momentumVectorChargedParticle.Pt()>fMinPtGamChargedCorr){
3666 fHistograms->FillHistogram("ESD_dphiHdrGamIsolated",dphiHdrGam);
3673 Double_t AliAnalysisTaskGammaConversion::GetMinimumDistanceToCharge(Int_t indexHighestPtGamma){
3674 // GetMinimumDistanceToCharge
3676 Double_t fIsoMin=100.;
3677 Double_t ptLeadingCharged=-1.;
3679 fLeadingChargedIndex=-1;
3681 AliKFParticle * gammaHighestPt = (AliKFParticle*)fKFReconstructedGammasTClone->At(indexHighestPtGamma);
3682 TVector3 momentumVectorgammaHighestPt(gammaHighestPt->GetPx(),gammaHighestPt->GetPy(),gammaHighestPt->GetPz());
3684 Double_t phi1=momentumVectorgammaHighestPt.Phi();
3685 Double_t eta1=momentumVectorgammaHighestPt.Eta();
3687 for(Int_t iCh=0;iCh<fChargedParticles->GetEntriesFast();iCh++){
3688 AliESDtrack* curTrack = (AliESDtrack*)(fChargedParticles->At(iCh));
3689 Int_t chId = fChargedParticlesId[iCh];
3690 if(fElectronv1[indexHighestPtGamma]==chId || fElectronv2[indexHighestPtGamma]==chId) continue;
3692 curTrack->GetConstrainedPxPyPz(mom);
3693 TVector3 momentumVectorChargedParticle(mom[0],mom[1],mom[2]);
3694 Double_t phi2=momentumVectorChargedParticle.Phi();
3695 Double_t eta2=momentumVectorChargedParticle.Eta();
3696 Double_t iso=pow( (pow( (eta1-eta2),2)+ pow((phi1-phi2),2)),0.5 );
3698 if(momentumVectorChargedParticle.Pt()>fMinPtIsoCone ){
3704 Double_t dphiHdrGam=phi1-phi2;
3705 if ( dphiHdrGam < (-TMath::PiOver2())){
3706 dphiHdrGam+=(TMath::TwoPi());
3709 if ( dphiHdrGam > (3.*TMath::PiOver2()) ){
3710 dphiHdrGam-=(TMath::TwoPi());
3712 if (momentumVectorChargedParticle.Pt()>fMinPtGamChargedCorr){
3713 fHistograms->FillHistogram("ESD_dphiHdrGam",dphiHdrGam);
3716 if (dphiHdrGam>0.9*TMath::Pi() && dphiHdrGam<1.1*TMath::Pi()){
3717 if (momentumVectorChargedParticle.Pt()> ptLeadingCharged && momentumVectorChargedParticle.Pt()>0.1*momentumVectorgammaHighestPt.Pt()){
3718 ptLeadingCharged=momentumVectorChargedParticle.Pt();
3719 fLeadingChargedIndex=iCh;
3724 fHistograms->FillHistogram("ESD_MinimumIsoDistance",fIsoMin);
3729 Int_t AliAnalysisTaskGammaConversion::GetIndexHighestPtGamma(){
3730 //GetIndexHighestPtGamma
3732 Int_t indexHighestPtGamma=-1;
3734 fGammaPtHighest = -100.;
3736 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();firstGammaIndex++){
3737 AliKFParticle * gammaHighestPtCandidate = (AliKFParticle*)fKFReconstructedGammasTClone->At(firstGammaIndex);
3738 TVector3 momentumVectorgammaHighestPtCandidate(gammaHighestPtCandidate->GetPx(),gammaHighestPtCandidate->GetPy(),gammaHighestPtCandidate->GetPz());
3739 if (momentumVectorgammaHighestPtCandidate.Pt() > fGammaPtHighest){
3740 fGammaPtHighest=momentumVectorgammaHighestPtCandidate.Pt();
3741 //gammaHighestPt = gammaHighestPtCandidate;
3742 indexHighestPtGamma=firstGammaIndex;
3746 return indexHighestPtGamma;
3751 void AliAnalysisTaskGammaConversion::Terminate(Option_t */*option*/)
3753 // Terminate analysis
3755 AliDebug(1,"Do nothing in Terminate");
3758 void AliAnalysisTaskGammaConversion::UserCreateOutputObjects()
3764 if(!fAODGamma) fAODGamma = new TClonesArray("AliAODConversionParticle", 0);
3765 else fAODGamma->Delete();
3766 fAODGamma->SetName(Form("%s_gamma", fAODBranchName.Data()));
3768 if(!fAODPi0) fAODPi0 = new TClonesArray("AliAODConversionParticle", 0);
3769 else fAODPi0->Delete();
3770 fAODPi0->SetName(Form("%s_Pi0", fAODBranchName.Data()));
3772 if(!fAODOmega) fAODOmega = new TClonesArray("AliAODConversionParticle", 0);
3773 else fAODOmega->Delete();
3774 fAODOmega->SetName(Form("%s_Omega", fAODBranchName.Data()));
3776 //If delta AOD file name set, add in separate file. Else add in standard aod file.
3777 if(GetDeltaAODFileName().Length() > 0) {
3778 AddAODBranch("TClonesArray", &fAODGamma, GetDeltaAODFileName().Data());
3779 AddAODBranch("TClonesArray", &fAODPi0, GetDeltaAODFileName().Data());
3780 AddAODBranch("TClonesArray", &fAODOmega, GetDeltaAODFileName().Data());
3781 AliAnalysisManager::GetAnalysisManager()->RegisterExtraFile(GetDeltaAODFileName().Data());
3783 AddAODBranch("TClonesArray", &fAODGamma);
3784 AddAODBranch("TClonesArray", &fAODPi0);
3785 AddAODBranch("TClonesArray", &fAODOmega);
3789 // Create the output container
3790 if(fOutputContainer != NULL){
3791 delete fOutputContainer;
3792 fOutputContainer = NULL;
3794 if(fOutputContainer == NULL){
3795 fOutputContainer = new TList();
3796 fOutputContainer->SetOwner(kTRUE);
3799 //Adding the histograms to the output container
3800 fHistograms->GetOutputContainer(fOutputContainer);
3804 if(fGammaNtuple == NULL){
3805 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);
3807 if(fNeutralMesonNtuple == NULL){
3808 fNeutralMesonNtuple = new TNtuple("NeutralMesonNtuple","NeutralMesonNtuple","test");
3810 TList * ntupleTList = new TList();
3811 ntupleTList->SetOwner(kTRUE);
3812 ntupleTList->SetName("Ntuple");
3813 ntupleTList->Add((TNtuple*)fGammaNtuple);
3814 fOutputContainer->Add(ntupleTList);
3817 fOutputContainer->SetName(GetName());
3819 PostData(1, fOutputContainer);
3820 PostData(2, fCFManager->GetParticleContainer()); // for CF
3824 Double_t AliAnalysisTaskGammaConversion::GetMCOpeningAngle(const TParticle* const daughter0, const TParticle* const daughter1) const{
3826 TVector3 v3D0(daughter0->Px(),daughter0->Py(),daughter0->Pz());
3827 TVector3 v3D1(daughter1->Px(),daughter1->Py(),daughter1->Pz());
3828 return v3D0.Angle(v3D1);
3831 void AliAnalysisTaskGammaConversion::CheckV0Efficiency(){
3832 // see header file for documentation
3834 vector<Int_t> indexOfGammaParticle;
3836 fStack = fV0Reader->GetMCStack();
3838 if(fV0Reader->CheckForPrimaryVertex() == kFALSE){
3839 return; // aborts if the primary vertex does not have contributors.
3842 for (Int_t iTracks = 0; iTracks < fStack->GetNprimary(); iTracks++) {
3843 TParticle* particle = (TParticle *)fStack->Particle(iTracks);
3844 if(particle->GetPdgCode()==22){ //Gamma
3845 if(particle->GetNDaughters() >= 2){
3846 TParticle* electron=NULL;
3847 TParticle* positron=NULL;
3848 for(Int_t daughterIndex=particle->GetFirstDaughter();daughterIndex<=particle->GetLastDaughter();daughterIndex++){
3849 TParticle *tmpDaughter = fStack->Particle(daughterIndex);
3850 if(tmpDaughter->GetUniqueID() == 5){
3851 if(tmpDaughter->GetPdgCode() == 11){
3852 electron = tmpDaughter;
3854 else if(tmpDaughter->GetPdgCode() == -11){
3855 positron = tmpDaughter;
3859 if(electron!=NULL && positron!=0){
3860 if(electron->R()<160){
3861 indexOfGammaParticle.push_back(iTracks);
3868 Int_t nFoundGammas=0;
3869 Int_t nNotFoundGammas=0;
3871 Int_t numberOfV0s = fV0Reader->GetNumberOfV0s();
3872 for(Int_t i=0;i<numberOfV0s;i++){
3873 fV0Reader->GetV0(i);
3875 if(fV0Reader->HasSameMCMother() == kFALSE){
3879 TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
3880 TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
3882 if(TMath::Abs(negativeMC->GetPdgCode())!=11 || TMath::Abs(positiveMC->GetPdgCode())!=11){
3885 if(negativeMC->GetPdgCode()==positiveMC->GetPdgCode()){
3889 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
3890 //TParticle * v0Gamma = fV0Reader->GetMotherMCParticle();
3891 for(UInt_t mcIndex=0;mcIndex<indexOfGammaParticle.size();mcIndex++){
3892 if(negativeMC->GetFirstMother()==indexOfGammaParticle[mcIndex]){
3904 void AliAnalysisTaskGammaConversion::ProcessGammaElectronsForChicAnalysis(){
3905 // see header file for documantation
3907 fESDEvent = fV0Reader->GetESDEvent();
3910 TClonesArray * vESDeNegTemp = new TClonesArray("AliESDtrack",0);
3911 TClonesArray * vESDePosTemp = new TClonesArray("AliESDtrack",0);
3912 TClonesArray * vESDxNegTemp = new TClonesArray("AliESDtrack",0);
3913 TClonesArray * vESDxPosTemp = new TClonesArray("AliESDtrack",0);
3914 TClonesArray * vESDeNegNoJPsi = new TClonesArray("AliESDtrack",0);
3915 TClonesArray * vESDePosNoJPsi = new TClonesArray("AliESDtrack",0);
3918 vector <AliESDtrack*> vESDeNegTemp(0);
3919 vector <AliESDtrack*> vESDePosTemp(0);
3920 vector <AliESDtrack*> vESDxNegTemp(0);
3921 vector <AliESDtrack*> vESDxPosTemp(0);
3922 vector <AliESDtrack*> vESDeNegNoJPsi(0);
3923 vector <AliESDtrack*> vESDePosNoJPsi(0);
3927 fHistograms->FillTable("Table_Electrons",0);//Count number of Events
3929 for(Int_t iTracks = 0; iTracks < fESDEvent->GetNumberOfTracks(); iTracks++){
3930 AliESDtrack* curTrack = fESDEvent->GetTrack(iTracks);
3933 //print warning here
3937 double p[3];if(!curTrack->GetConstrainedPxPyPz(p))continue;
3938 double r[3];curTrack->GetConstrainedXYZ(r);
3942 fHistograms->FillTable("Table_Electrons",4);//Count number of ESD tracks
3944 Bool_t flagKink = kTRUE;
3945 Bool_t flagTPCrefit = kTRUE;
3946 Bool_t flagTRDrefit = kTRUE;
3947 Bool_t flagITSrefit = kTRUE;
3948 Bool_t flagTRDout = kTRUE;
3949 Bool_t flagVertex = kTRUE;
3952 //Cuts ---------------------------------------------------------------
3954 if(curTrack->GetKinkIndex(0) > 0){
3955 fHistograms->FillHistogram("Table_Electrons",5);//Count kink
3959 ULong_t trkStatus = curTrack->GetStatus();
3961 ULong_t tpcRefit = (trkStatus & AliESDtrack::kTPCrefit);
3964 fHistograms->FillHistogram("Table_Electrons",9);//Count not TPCrefit
3965 flagTPCrefit = kFALSE;
3968 ULong_t itsRefit = (trkStatus & AliESDtrack::kITSrefit);
3970 fHistograms->FillHistogram("Table_Electrons",10);//Count not ITSrefit
3971 flagITSrefit = kFALSE;
3974 ULong_t trdRefit = (trkStatus & AliESDtrack::kTRDrefit);
3977 fHistograms->FillHistogram("Table_Electrons",8); //Count not TRDrefit
3978 flagTRDrefit = kFALSE;
3981 ULong_t trdOut = (trkStatus & AliESDtrack::kTRDout);
3984 fHistograms->FillHistogram("Table_Electrons",7); //Count not TRDout
3985 flagTRDout = kFALSE;
3988 double nsigmaToVxt = GetSigmaToVertex(curTrack);
3990 if(nsigmaToVxt > 3){
3991 fHistograms->FillHistogram("Table_Electrons",6); //Count Tracks with number of sigmas > 3
3992 flagVertex = kFALSE;
3995 if(! (flagKink && flagTPCrefit && flagITSrefit && flagTRDrefit && flagTRDout && flagVertex ) ) continue;
3996 fHistograms->FillHistogram("Table_Electrons",11);//Count Tracks passed Cuts
4000 GetPID(curTrack, pid, weight);
4003 fHistograms->FillHistogram("Table_Electrons",12); //Count Tracks with pid != 0
4007 fHistograms->FillHistogram("Table_Electrons",13); //Count Tracks with pid != 0
4015 TLorentzVector curElec;
4016 curElec.SetXYZM(p[0],p[1],p[2],fElectronMass);
4020 Int_t labelMC = TMath::Abs(curTrack->GetLabel());
4021 TParticle* curParticle = fStack->Particle(labelMC);
4022 if(curTrack->GetSign() > 0){
4024 fHistograms->FillHistogram("MC_ElectronPosNegPt",curParticle->Pt());
4025 fHistograms->FillHistogram("MC_ElectronPosNegEta",curParticle->Eta());
4028 fHistograms->FillHistogram("MC_ElectronPosNegPt",curParticle->Pt());
4029 fHistograms->FillHistogram("MC_ElectronPosNegEta",curParticle->Eta());
4035 if(curTrack->GetSign() > 0){
4037 // vESDxPosTemp.push_back(curTrack);
4038 new((*vESDxPosTemp)[vESDxPosTemp->GetEntriesFast()]) AliESDtrack(*curTrack);
4042 fHistograms->FillHistogram("ESD_ElectronPosNegPt",curElec.Pt());
4043 fHistograms->FillHistogram("ESD_ElectronPosPt",curElec.Pt());
4044 // fHistograms->FillHistogram("MC_ElectronPosNegPt",curParticle->Pt());
4045 fHistograms->FillHistogram("ESD_ElectronPosNegEta",curElec.Eta());
4046 // fHistograms->FillHistogram("MC_ElectronPosNegEta",curParticle->Eta());
4047 // vESDePosTemp.push_back(curTrack);
4048 new((*vESDePosTemp)[vESDePosTemp->GetEntriesFast()]) AliESDtrack(*curTrack);
4055 new((*vESDxNegTemp)[vESDxNegTemp->GetEntriesFast()]) AliESDtrack(*curTrack);
4059 fHistograms->FillHistogram("ESD_ElectronPosNegPt",curElec.Pt());
4060 fHistograms->FillHistogram("ESD_ElectronNegPt",curElec.Pt());
4061 fHistograms->FillHistogram("ESD_ElectronPosNegEta",curElec.Eta());
4062 new((*vESDeNegTemp)[vESDeNegTemp->GetEntriesFast()]) AliESDtrack(*curTrack);
4071 Bool_t ePosJPsi = kFALSE;
4072 Bool_t eNegJPsi = kFALSE;
4073 Bool_t ePosPi0 = kFALSE;
4074 Bool_t eNegPi0 = kFALSE;
4076 UInt_t iePosJPsi=0,ieNegJPsi=0,iePosPi0=0,ieNegPi0=0;
4078 for(Int_t iNeg=0; iNeg < vESDeNegTemp->GetEntriesFast(); iNeg++){
4079 if(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDeNegTemp->At(iNeg)))->GetLabel()))->GetPdgCode() == 11)
4080 if(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDeNegTemp->At(iNeg)))->GetLabel()))->GetMother(0) > -1){
4081 Int_t labelMother = fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDeNegTemp->At(iNeg)))->GetLabel()))->GetMother(0);
4082 TParticle* partMother = fStack ->Particle(labelMother);
4083 if (partMother->GetPdgCode() == 111){
4087 if(partMother->GetPdgCode() == 443){ //Mother JPsi
4088 fHistograms->FillTable("Table_Electrons",14);
4093 // vESDeNegNoJPsi.push_back(vESDeNegTemp[iNeg]);
4094 new((*vESDeNegNoJPsi)[vESDeNegNoJPsi->GetEntriesFast()]) AliESDtrack(*(AliESDtrack*)(vESDeNegTemp->At(iNeg)));
4095 // cout<<"ESD No Positivo JPsi "<<endl;
4101 for(Int_t iPos=0; iPos < vESDePosTemp->GetEntriesFast(); iPos++){
4102 if(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDePosTemp->At(iPos)))->GetLabel()))->GetPdgCode() == -11)
4103 if(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDePosTemp->At(iPos)))->GetLabel()))->GetMother(0) > -1){
4104 Int_t labelMother = fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDePosTemp->At(iPos)))->GetLabel()))->GetMother(0);
4105 TParticle* partMother = fStack ->Particle(labelMother);
4106 if (partMother->GetPdgCode() == 111){
4110 if(partMother->GetPdgCode() == 443){ //Mother JPsi
4111 fHistograms->FillTable("Table_Electrons",15);
4116 // vESDePosNoJPsi.push_back(vESDePosTemp[iPos]);
4117 new((*vESDePosNoJPsi)[vESDePosNoJPsi->GetEntriesFast()]) AliESDtrack(*(AliESDtrack*)(vESDePosTemp->At(iPos)));
4118 // cout<<"ESD No Negativo JPsi "<<endl;
4124 if( eNegJPsi && ePosJPsi ){
4125 TVector3 tempeNegV,tempePosV;
4126 tempeNegV.SetXYZ(((AliESDtrack*)(vESDeNegTemp->At(ieNegJPsi)))->Px(),((AliESDtrack*)(vESDeNegTemp->At(ieNegJPsi)))->Py(),((AliESDtrack*)(vESDeNegTemp->At(ieNegJPsi)))->Pz());
4127 tempePosV.SetXYZ(((AliESDtrack*)(vESDePosTemp->At(iePosJPsi)))->Px(),((AliESDtrack*)(vESDePosTemp->At(iePosJPsi)))->Py(),((AliESDtrack*)(vESDePosTemp->At(iePosJPsi)))->Pz());
4128 fHistograms->FillTable("Table_Electrons",16);
4129 fHistograms->FillHistogram("ESD_ElectronPosNegJPsiAngle",tempeNegV.Angle(tempePosV));
4130 fHistograms->FillHistogram("MC_ElectronPosNegJPsiAngle",GetMCOpeningAngle(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDeNegTemp->At(ieNegJPsi)))->GetLabel())),
4131 fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDePosTemp->At(iePosJPsi)))->GetLabel()))));
4134 if( eNegPi0 && ePosPi0 ){
4135 TVector3 tempeNegV,tempePosV;
4136 tempeNegV.SetXYZ(((AliESDtrack*)(vESDeNegTemp->At(ieNegPi0)))->Px(),((AliESDtrack*)(vESDeNegTemp->At(ieNegPi0)))->Py(),((AliESDtrack*)(vESDeNegTemp->At(ieNegPi0)))->Pz());
4137 tempePosV.SetXYZ(((AliESDtrack*)(vESDePosTemp->At(iePosPi0)))->Px(),((AliESDtrack*)(vESDePosTemp->At(iePosPi0)))->Py(),((AliESDtrack*)(vESDePosTemp->At(iePosPi0)))->Pz());
4138 fHistograms->FillHistogram("ESD_ElectronPosNegPi0Angle",tempeNegV.Angle(tempePosV));
4139 fHistograms->FillHistogram("MC_ElectronPosNegPi0Angle",GetMCOpeningAngle(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDeNegTemp->At(ieNegPi0)))->GetLabel())),
4140 fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDePosTemp->At(iePosPi0)))->GetLabel()))));
4144 FillAngle("ESD_eNegePosAngleBeforeCut",GetTLorentzVector(vESDeNegTemp),GetTLorentzVector(vESDePosTemp));
4146 CleanWithAngleCuts(*vESDeNegTemp,*vESDePosTemp,*fKFReconstructedGammasTClone);
4148 // vector <TLorentzVector> vCurrentTLVeNeg = GetTLorentzVector(fCurrentEventNegElectron);
4149 // vector <TLorentzVector> vCurrentTLVePos = GetTLorentzVector(fCurrentEventPosElectron);
4151 TClonesArray vCurrentTLVeNeg = GetTLorentzVector(fCurrentEventNegElectronTClone);
4152 TClonesArray vCurrentTLVePos = GetTLorentzVector(fCurrentEventPosElectronTClone);
4155 FillAngle("ESD_eNegePosAngleAfterCut",vCurrentTLVeNeg,vCurrentTLVePos);
4160 //FillAngle("ESD_eNegePosAngleAfterCut",CurrentTLVeNeg,CurrentTLVePos);
4163 FillElectronInvMass("ESD_InvMass_ePluseMinus",vCurrentTLVeNeg,vCurrentTLVePos);
4164 FillElectronInvMass("ESD_InvMass_xPlusxMinus",GetTLorentzVector(vESDxNegTemp),GetTLorentzVector(vESDxPosTemp));
4168 FillGammaElectronInvMass("ESD_InvMass_GammaePluseMinusChiC","ESD_InvMass_GammaePluseMinusChiCDiff",*fKFReconstructedGammasCutTClone,vCurrentTLVeNeg,vCurrentTLVePos);
4170 FillGammaElectronInvMass("ESD_InvMass_GammaePluseMinusPi0","ESD_InvMass_GammaePluseMinusPi0Diff",
4171 *fKFReconstructedGammasCutTClone,vCurrentTLVeNeg,vCurrentTLVePos);
4176 ElectronBackground("ESD_ENegBackground",vCurrentTLVeNeg);
4177 ElectronBackground("ESD_EPosBackground",vCurrentTLVePos);
4178 ElectronBackground("ESD_EPosENegBackground",vCurrentTLVeNeg);
4179 ElectronBackground("ESD_EPosENegBackground",vCurrentTLVePos);
4181 // Like Sign e+e- no JPsi
4182 ElectronBackground("ESD_EPosENegNoJPsiBG",GetTLorentzVector(vESDeNegNoJPsi));
4183 ElectronBackground("ESD_EPosENegNoJPsiBG",GetTLorentzVector(vESDePosNoJPsi));
4187 if( fCurrentEventPosElectronTClone->GetEntriesFast() > 0 && fCurrentEventNegElectronTClone->GetEntriesFast() > 0 && fKFReconstructedGammasCutTClone->GetEntriesFast() > 0 ){
4188 FillGammaElectronInvMass("ESD_EPosENegGammaBackgroundMX","ESD_EPosENegGammaBackgroundMXDiff",
4189 *fKFReconstructedGammasCutTClone,*fPreviousEventTLVNegElectronTClone,*fPreviousEventTLVPosElectronTClone);
4190 *fPreviousEventTLVNegElectronTClone = vCurrentTLVeNeg;
4191 *fPreviousEventTLVPosElectronTClone = vCurrentTLVePos;
4198 vtx[0]=0;vtx[1]=0;vtx[2]=0;
4199 for(UInt_t i=0;i<fKFReconstructedGammasChic.size();i++){
4201 // if(fMCGammaChicTempCut[i]->GetMother(0) < 0) continue;
4205 Int_t tempLabel = fStack->Particle(fMCGammaChicTempCut[i]->GetMother(0))->GetPdgCode();
4206 // cout<<" Label Pedro Gonzalez " <<tempLabel <<endl;
4208 // cout<<" Label Distance"<<fKFReconstructedGammasChic[i].GetDistanceFromVertex(vtx)<<endl;
4210 if( tempLabel == 10441 || tempLabel == 20443 || tempLabel == 445 )
4212 fHistograms->FillHistogram("ESD_PhotonsMomentum",fKFReconstructedGammasChic[i].GetMomentum());
4221 vESDeNegTemp->Delete();
4222 vESDePosTemp->Delete();
4223 vESDxNegTemp->Delete();
4224 vESDxPosTemp->Delete();
4225 vESDeNegNoJPsi->Delete();
4226 vESDePosNoJPsi->Delete();
4228 delete vESDeNegTemp;
4229 delete vESDePosTemp;
4230 delete vESDxNegTemp;
4231 delete vESDxPosTemp;
4232 delete vESDeNegNoJPsi;
4233 delete vESDePosNoJPsi;
4237 void AliAnalysisTaskGammaConversion::FillAngle(TString histoName,vector <TLorentzVector> tlVeNeg, vector <TLorentzVector> tlVePos){
4238 //see header file for documentation
4239 for( UInt_t iNeg=0; iNeg < tlVeNeg.size(); iNeg++){
4240 for (UInt_t iPos=0; iPos < tlVePos.size(); iPos++){
4241 fHistograms->FillHistogram(histoName.Data(),tlVeNeg[iNeg].Vect().Angle(tlVePos[iPos].Vect()));
4246 void AliAnalysisTaskGammaConversion::FillAngle(TString histoName,TClonesArray const tlVeNeg, TClonesArray const tlVePos){
4247 //see header file for documentation
4248 for( Int_t iNeg=0; iNeg < tlVeNeg.GetEntriesFast(); iNeg++){
4249 for (Int_t iPos=0; iPos < tlVePos.GetEntriesFast(); iPos++){
4250 fHistograms->FillHistogram(histoName.Data(),((TLorentzVector*)(tlVeNeg.At(iNeg)))->Vect().Angle(((TLorentzVector*)(tlVePos.At(iPos)))->Vect()));
4254 void AliAnalysisTaskGammaConversion::FillElectronInvMass(TString histoName, TClonesArray const eNeg, TClonesArray const ePos){
4255 //see header file for documentation
4256 for( Int_t n=0; n < eNeg.GetEntriesFast(); n++){
4257 TLorentzVector en = (*(TLorentzVector*)(eNeg.At(n)));
4258 for (Int_t p=0; p < ePos.GetEntriesFast(); p++){
4259 TLorentzVector ep = (*(TLorentzVector*)(ePos.At(p)));
4260 TLorentzVector np = ep + en;
4261 fHistograms->FillHistogram(histoName.Data(),np.M());
4266 void AliAnalysisTaskGammaConversion::FillGammaElectronInvMass(TString histoMass,TString histoDiff,TClonesArray const fKFGammas,
4267 TClonesArray const tlVeNeg,TClonesArray const tlVePos)
4269 //see header file for documentation
4271 for( Int_t iNeg=0; iNeg < tlVeNeg.GetEntriesFast(); iNeg++ ){
4273 for (Int_t iPos=0; iPos < tlVePos.GetEntriesFast(); iPos++){
4275 TLorentzVector xy = *((TLorentzVector *)(tlVePos.At(iPos))) + *((TLorentzVector *)(tlVeNeg.At(iNeg)));
4277 for (Int_t iGam=0; iGam < fKFGammas.GetEntriesFast(); iGam++){
4279 // AliKFParticle * gammaCandidate = &fKFGammas[iGam];
4280 AliKFParticle * gammaCandidate = (AliKFParticle *)(fKFGammas.At(iGam));
4283 g.SetXYZM(gammaCandidate->GetPx(),gammaCandidate->GetPy(),gammaCandidate->GetPz(),fGammaMass);
4284 TLorentzVector xyg = xy + g;
4285 fHistograms->FillHistogram(histoMass.Data(),xyg.M());
4286 fHistograms->FillHistogram(histoDiff.Data(),(xyg.M()-xy.M()));
4292 void AliAnalysisTaskGammaConversion::ElectronBackground(TString hBg, TClonesArray e)
4294 // see header file for documentation
4295 for(Int_t i=0; i < e.GetEntriesFast(); i++)
4297 for (Int_t j=i+1; j < e.GetEntriesFast(); j++)
4299 TLorentzVector ee = (*(TLorentzVector*)(e.At(i))) + (*(TLorentzVector*)(e.At(j)));
4301 fHistograms->FillHistogram(hBg.Data(),ee.M());
4307 void AliAnalysisTaskGammaConversion::CleanWithAngleCuts(TClonesArray const negativeElectrons,
4308 TClonesArray const positiveElectrons,
4309 TClonesArray const gammas){
4310 // see header file for documentation
4312 UInt_t sizeN = negativeElectrons.GetEntriesFast();
4313 UInt_t sizeP = positiveElectrons.GetEntriesFast();
4314 UInt_t sizeG = gammas.GetEntriesFast();
4318 vector <Bool_t> xNegBand(sizeN);
4319 vector <Bool_t> xPosBand(sizeP);
4320 vector <Bool_t> gammaBand(sizeG);
4323 for(UInt_t iNeg=0; iNeg < sizeN; iNeg++) xNegBand[iNeg]=kTRUE;
4324 for(UInt_t iPos=0; iPos < sizeP; iPos++) xPosBand[iPos]=kTRUE;
4325 for(UInt_t iGam=0; iGam < sizeG; iGam++) gammaBand[iGam]=kTRUE;
4328 for(UInt_t iPos=0; iPos < sizeP; iPos++){
4331 ((AliESDtrack*)(positiveElectrons.At(iPos)))->GetConstrainedPxPyPz(aP);
4333 TVector3 ePosV(aP[0],aP[1],aP[2]);
4335 for(UInt_t iNeg=0; iNeg < sizeN; iNeg++){
4338 ((AliESDtrack*)(negativeElectrons.At(iNeg)))->GetConstrainedPxPyPz(aN);
4339 TVector3 eNegV(aN[0],aN[1],aN[2]);
4341 if(ePosV.Angle(eNegV) < 0.05){ //e+e- from gamma
4342 xPosBand[iPos]=kFALSE;
4343 xNegBand[iNeg]=kFALSE;
4346 for(UInt_t iGam=0; iGam < sizeG; iGam++){
4347 AliKFParticle* gammaCandidate = (AliKFParticle*)gammas.At(iGam);
4348 TVector3 gammaCandidateVector(gammaCandidate->Px(),gammaCandidate->Py(),gammaCandidate->Pz());
4349 if(ePosV.Angle(gammaCandidateVector) < 0.05 || eNegV.Angle(gammaCandidateVector) < 0.05)
4350 gammaBand[iGam]=kFALSE;
4358 for(UInt_t iPos=0; iPos < sizeP; iPos++){
4360 new((*fCurrentEventPosElectronTClone)[fCurrentEventPosElectronTClone->GetEntriesFast()]) AliESDtrack((*(AliESDtrack*)(positiveElectrons.At(iPos))));
4361 // fCurrentEventPosElectron.push_back(positiveElectrons[iPos]);
4364 for(UInt_t iNeg=0;iNeg < sizeN; iNeg++){
4366 new((*fCurrentEventNegElectronTClone)[fCurrentEventNegElectronTClone->GetEntriesFast()]) AliESDtrack((*(AliESDtrack*)(negativeElectrons.At(iNeg))));
4367 // fCurrentEventNegElectron.push_back(negativeElectrons[iNeg]);
4370 for(UInt_t iGam=0; iGam < sizeG; iGam++){
4371 if(gammaBand[iGam]){
4372 new((*fKFReconstructedGammasCutTClone)[fKFReconstructedGammasCutTClone->GetEntriesFast()]) AliKFParticle((*(AliKFParticle*)(gammas.At(iGam))));
4373 //fKFReconstructedGammasCut.push_back(*(AliKFParticle*)gammas->At(iGam));
4379 void AliAnalysisTaskGammaConversion::GetPID(const AliESDtrack *track, Stat_t &pid, Stat_t &weight)
4381 // see header file for documentation
4386 double wpartbayes[5];
4388 //get probability of the diffenrent particle types
4389 track->GetESDpid(wpart);
4391 // Tentative particle type "concentrations"
4392 double c[5]={0.01, 0.01, 0.85, 0.10, 0.05};
4396 for (int i = 0; i < 5; i++)
4398 rcc+=(c[i] * wpart[i]);
4403 for (int i=0; i<5; i++) {
4404 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)
4405 wpartbayes[i] = c[i] * wpart[i] / rcc;
4413 //find most probable particle in ESD pid
4414 //0:Electron - 1:Muon - 2:Pion - 3:Kaon - 4:Proton
4415 for (int i = 0; i < 5; i++)
4417 if (wpartbayes[i] > max)
4420 max = wpartbayes[i];
4427 double AliAnalysisTaskGammaConversion::GetSigmaToVertex(const AliESDtrack* t)
4429 // Calculates the number of sigma to the vertex.
4434 t->GetImpactParameters(b,bCov);
4435 if (bCov[0]<=0 || bCov[2]<=0) {
4436 AliDebug(1, "Estimated b resolution lower or equal zero!");
4437 bCov[0]=0; bCov[2]=0;
4439 bRes[0] = TMath::Sqrt(bCov[0]);
4440 bRes[1] = TMath::Sqrt(bCov[2]);
4442 // -----------------------------------
4443 // How to get to a n-sigma cut?
4445 // The accumulated statistics from 0 to d is
4447 // -> Erf(d/Sqrt(2)) for a 1-dim gauss (d = n_sigma)
4448 // -> 1 - Exp(-d**2) for a 2-dim gauss (d*d = dx*dx + dy*dy != n_sigma)
4450 // It means that for a 2-dim gauss: n_sigma(d) = Sqrt(2)*ErfInv(1 - Exp((-x**2)/2)
4451 // Can this be expressed in a different way?
4453 if (bRes[0] == 0 || bRes[1] ==0)
4456 double d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
4458 // stupid rounding problem screws up everything:
4459 // if d is too big, TMath::Exp(...) gets 0, and TMath::ErfInverse(1) that should be infinite, gets 0 :(
4460 if (TMath::Exp(-d * d / 2) < 1e-10)
4464 d = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);
4468 //vector <TLorentzVector> AliAnalysisTaskGammaConversion::GetTLorentzVector(vector <AliESDtrack*> esdTrack){
4469 TClonesArray AliAnalysisTaskGammaConversion::GetTLorentzVector(TClonesArray *const esdTrack){
4470 //Return TLoresntz vector of track?
4471 // vector <TLorentzVector> tlVtrack(0);
4472 TClonesArray array("TLorentzVector",0);
4474 for(Int_t itrack=0; itrack < esdTrack->GetEntriesFast(); itrack++){
4476 //esdTrack[itrack]->GetConstrainedPxPyPz(p);
4477 ((AliESDtrack*)(esdTrack->At(itrack)))->GetConstrainedPxPyPz(p);
4478 TLorentzVector currentTrack;
4479 currentTrack.SetXYZM(p[0],p[1],p[2],fElectronMass);
4480 new((array)[array.GetEntriesFast()]) TLorentzVector(currentTrack);
4481 // tlVtrack.push_back(currentTrack);
4488 Int_t AliAnalysisTaskGammaConversion::GetProcessType(const AliMCEvent * mcEvt) {
4490 // Determine if the event was generated with pythia or phojet and return the process type
4492 // Check if mcEvt is fine
4493 if (!mcEvt) { // coverty does not allow this, the check is done elsewhere
4494 AliFatal("NULL mc event");
4498 // Determine if it was a pythia or phojet header, and return the correct process type
4499 AliGenPythiaEventHeader * headPy = 0;
4500 AliGenDPMjetEventHeader * headPho = 0;
4501 AliGenEventHeader * htmp = mcEvt->GenEventHeader();
4503 AliFatal("Cannot Get MC Header!!");
4506 if( TString(htmp->IsA()->GetName()) == "AliGenPythiaEventHeader") {
4507 headPy = (AliGenPythiaEventHeader*) htmp;
4508 } else if (TString(htmp->IsA()->GetName()) == "AliGenDPMjetEventHeader") {
4509 headPho = (AliGenDPMjetEventHeader*) htmp;
4511 AliError("Unknown header");
4514 // Determine process type
4516 if(headPy->ProcessType() == 92 || headPy->ProcessType() == 93) {
4517 // single difractive
4519 } else if (headPy->ProcessType() == 94) {
4520 // double diffractive
4523 else if(headPy->ProcessType() != 92 && headPy->ProcessType() != 93 && headPy->ProcessType() != 94) {
4527 } else if (headPho) {
4528 if(headPho->ProcessType() == 5 || headPho->ProcessType() == 6 ) {
4529 // single difractive
4531 } else if (headPho->ProcessType() == 7) {
4532 // double diffractive
4534 } else if(headPho->ProcessType() != 5 && headPho->ProcessType() != 6 && headPho->ProcessType() != 7 ) {
4541 // no process type found?
4542 AliError(Form("Unknown header: %s", htmp->IsA()->GetName()));
4543 return kProcUnknown;
4547 Int_t AliAnalysisTaskGammaConversion::CalculateMultiplicityBin(){
4548 // Get Centrality bin
4550 Int_t multiplicity = 0;
4552 if ( fUseMultiplicity == 1 ) {
4554 if (fMultiplicity>= 0 && fMultiplicity<= 5) multiplicity=1;
4555 if (fMultiplicity>= 6 && fMultiplicity<= 9) multiplicity=2;
4556 if (fMultiplicity>=10 && fMultiplicity<=14) multiplicity=3;
4557 if (fMultiplicity>=15 && fMultiplicity<=22) multiplicity=4;
4558 if (fMultiplicity>=23 ) multiplicity=5;
4561 return multiplicity;