1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: Ana Marin, Kathrin Koch, Kenneth Aamodt *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 ////////////////////////////////////////////////
17 //---------------------------------------------
18 // Class used to do analysis on conversion pairs
19 //---------------------------------------------
20 ////////////////////////////////////////////////
26 #include "AliAnalysisTaskGammaConversion.h"
29 #include "AliESDtrackCuts.h"
31 //#include "AliCFManager.h" // for CF
32 //#include "AliCFContainer.h" // for CF
33 #include "AliESDInputHandler.h"
34 #include "AliAnalysisManager.h"
35 #include "AliGammaConversionAODObject.h"
36 #include "AliGammaConversionBGHandler.h"
37 #include "AliESDCaloCluster.h" // for combining PHOS and GammaConv
38 #include "AliKFVertex.h"
39 #include <AliMCEventHandler.h>
40 class AliESDTrackCuts;
48 class AliMCEventHandler;
49 class AliESDInputHandler;
50 class AliAnalysisManager;
57 ClassImp(AliAnalysisTaskGammaConversion)
60 AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion():
64 fMCTruth(NULL), // for CF
65 fGCMCEvent(NULL), // for CF
67 fOutputContainer(NULL),
68 fCFManager(0x0), // for CF
70 fTriggerCINT1B(kFALSE),
72 fDoNeutralMeson(kFALSE),
73 fDoOmegaMeson(kFALSE),
76 fRecalculateV0ForGamma(kFALSE),
77 fKFReconstructedGammasTClone(NULL),
78 fKFReconstructedPi0sTClone(NULL),
79 fKFRecalculatedGammasTClone(NULL),
80 fCurrentEventPosElectronTClone(NULL),
81 fCurrentEventNegElectronTClone(NULL),
82 fKFReconstructedGammasCutTClone(NULL),
83 fPreviousEventTLVNegElectronTClone(NULL),
84 fPreviousEventTLVPosElectronTClone(NULL),
89 fElectronRecalculatedv1(),
90 fElectronRecalculatedv2(),
98 fMinOpeningAngleGhostCut(0.),
100 fCalculateBackground(kFALSE),
101 fWriteNtuple(kFALSE),
103 fNeutralMesonNtuple(NULL),
104 fTotalNumberOfAddedNtupleEntries(0),
105 fChargedParticles(NULL),
106 fChargedParticlesId(),
108 fMinPtForGammaJet(1.),
109 fMinIsoConeSize(0.2),
111 fMinPtGamChargedCorr(0.5),
113 fLeadingChargedIndex(-1),
120 fAODBranchName("GammaConv"),
122 fKFDeltaAODFileName(""),
123 fDoNeutralMesonV0MCCheck(kFALSE),
124 fKFReconstructedGammasV0Index()
126 // Default constructor
128 /* Kenneth: the default constructor should not have any define input/output or the call to SetESDtrackCuts
129 // Common I/O in slot 0
130 DefineInput (0, TChain::Class());
131 DefineOutput(0, TTree::Class());
133 // Your private output
134 DefineOutput(1, TList::Class());
136 // Define standard ESD track cuts for Gamma-hadron correlation
141 AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion(const char* name):
142 AliAnalysisTaskSE(name),
145 fMCTruth(NULL), // for CF
146 fGCMCEvent(NULL), // for CF
148 fOutputContainer(0x0),
149 fCFManager(0x0), // for CF
151 fTriggerCINT1B(kFALSE),
153 fDoNeutralMeson(kFALSE),
154 fDoOmegaMeson(kFALSE),
157 fRecalculateV0ForGamma(kFALSE),
158 fKFReconstructedGammasTClone(NULL),
159 fKFReconstructedPi0sTClone(NULL),
160 fKFRecalculatedGammasTClone(NULL),
161 fCurrentEventPosElectronTClone(NULL),
162 fCurrentEventNegElectronTClone(NULL),
163 fKFReconstructedGammasCutTClone(NULL),
164 fPreviousEventTLVNegElectronTClone(NULL),
165 fPreviousEventTLVPosElectronTClone(NULL),
170 fElectronRecalculatedv1(),
171 fElectronRecalculatedv2(),
179 fMinOpeningAngleGhostCut(0.),
181 fCalculateBackground(kFALSE),
182 fWriteNtuple(kFALSE),
184 fNeutralMesonNtuple(NULL),
185 fTotalNumberOfAddedNtupleEntries(0),
186 fChargedParticles(NULL),
187 fChargedParticlesId(),
189 fMinPtForGammaJet(1.),
190 fMinIsoConeSize(0.2),
192 fMinPtGamChargedCorr(0.5),
194 fLeadingChargedIndex(-1),
201 fAODBranchName("GammaConv"),
203 fKFDeltaAODFileName(""),
204 fDoNeutralMesonV0MCCheck(kFALSE),
205 fKFReconstructedGammasV0Index()
207 // Common I/O in slot 0
208 DefineInput (0, TChain::Class());
209 DefineOutput(0, TTree::Class());
211 // Your private output
212 DefineOutput(1, TList::Class());
213 DefineOutput(2, AliCFContainer::Class()); // for CF
216 // Define standard ESD track cuts for Gamma-hadron correlation
221 AliAnalysisTaskGammaConversion::~AliAnalysisTaskGammaConversion()
223 // Remove all pointers
225 if(fOutputContainer){
226 fOutputContainer->Clear() ;
227 delete fOutputContainer ;
242 delete fEsdTrackCuts;
268 void AliAnalysisTaskGammaConversion::Init()
271 // AliLog::SetGlobalLogLevel(AliLog::kError);
273 void AliAnalysisTaskGammaConversion::SetESDtrackCuts()
276 if (fEsdTrackCuts!=NULL){
277 delete fEsdTrackCuts;
279 fEsdTrackCuts = new AliESDtrackCuts("AliESDtrackCuts");
280 //standard cuts from:
281 //http://aliceinfo.cern.ch/alicvs/viewvc/PWG0/dNdEta/CreateCuts.C?revision=1.4&view=markup
283 // Cuts used up to 3rd of March
285 // fEsdTrackCuts->SetMinNClustersTPC(50);
286 // fEsdTrackCuts->SetMaxChi2PerClusterTPC(3.5);
287 // fEsdTrackCuts->SetRequireTPCRefit(kTRUE);
288 // fEsdTrackCuts->SetRequireITSRefit(kTRUE);
289 // fEsdTrackCuts->SetMaxNsigmaToVertex(3);
290 // fEsdTrackCuts->SetRequireSigmaToVertex(kTRUE);
292 //------- To be tested-----------
293 // Cuts used up to 26th of Agost
294 // Int_t minNClustersTPC = 70;
295 // Double_t maxChi2PerClusterTPC = 4.0;
296 // Double_t maxDCAtoVertexXY = 2.4; // cm
297 // Double_t maxDCAtoVertexZ = 3.2; // cm
298 // fEsdTrackCuts->SetRequireSigmaToVertex(kFALSE);
299 // fEsdTrackCuts->SetRequireTPCRefit(kTRUE);
300 // fEsdTrackCuts->SetRequireITSRefit(kTRUE);
301 // // fEsdTrackCuts->SetRequireTPCStandAlone(kTRUE);
302 // fEsdTrackCuts->SetAcceptKinkDaughters(kFALSE);
303 // fEsdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
304 // fEsdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
305 // fEsdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
306 // fEsdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
307 // fEsdTrackCuts->SetDCAToVertex2D(kTRUE);
308 // fEsdTrackCuts->SetEtaRange(-0.8, 0.8);
309 // fEsdTrackCuts->SetPtRange(0.15);
311 // fEsdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kFirst);
314 // Using standard function for setting Cuts
315 Bool_t selectPrimaries=kTRUE;
316 fEsdTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2009(selectPrimaries);
317 fEsdTrackCuts->SetEtaRange(-0.8, 0.8);
318 fEsdTrackCuts->SetPtRange(0.15);
320 //----- From Jacek 10.03.03 ------------------/
321 // minNClustersTPC = 70;
322 // maxChi2PerClusterTPC = 4.0;
323 // maxDCAtoVertexXY = 2.4; // cm
324 // maxDCAtoVertexZ = 3.2; // cm
326 // esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
327 // esdTrackCuts->SetRequireTPCRefit(kFALSE);
328 // esdTrackCuts->SetRequireTPCStandAlone(kTRUE);
329 // esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
330 // esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
331 // esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
332 // esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
333 // esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
334 // esdTrackCuts->SetDCAToVertex2D(kTRUE);
338 // fEsdTrackCuts->SetAcceptKinkDaughters(kFALSE);
339 // fV0Reader->SetESDtrackCuts(fEsdTrackCuts);
342 void AliAnalysisTaskGammaConversion::UserExec(Option_t */*option*/)
344 // Execute analysis for current event
346 // Load the esdpid from the esdhandler if exists (tender was applied) otherwise set the Bethe Bloch parameters
348 AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
349 AliESDInputHandler *esdHandler=0x0;
350 if ( (esdHandler=dynamic_cast<AliESDInputHandler*>(man->GetInputEventHandler())) && esdHandler->GetESDpid() ){
351 AliV0Reader::SetESDpid(esdHandler->GetESDpid());
353 //load esd pid bethe bloch parameters depending on the existance of the MC handler
354 // yes: MC parameters
355 // no: data parameters
356 if (!AliV0Reader::GetESDpid()){
358 AliV0Reader::InitESDpid();
360 AliV0Reader::InitESDpid(1);
365 //Must set fForceAOD to true for the AOD to get filled. Should only be done when running independent chain / train.
367 if (!AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()) AliFatal("Cannot run ESD filter without an output event handler");
368 AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kTRUE);
371 if(fV0Reader == NULL){
372 // Write warning here cuts and so on are default if this ever happens
376 // To avoid crashes due to unzip errors. Sometimes the trees are not there.
378 AliMCEventHandler* mcHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
379 if (!mcHandler){ AliError("Could not retrive MC event handler!"); return; }
380 if (!mcHandler->InitOk() ) return;
381 if (!mcHandler->TreeK() ) return;
382 if (!mcHandler->TreeTR() ) return;
385 fV0Reader->SetInputAndMCEvent(InputEvent(), MCEvent());
387 fV0Reader->Initialize();
388 fDoMCTruth = fV0Reader->GetDoMCTruth();
392 //ConnectInputData("");
394 //Each event needs an empty branch
395 // fAODBranch->Clear();
396 if(fAODGamma) fAODGamma->Delete();
397 if(fAODPi0) fAODPi0->Delete();
398 if(fAODOmega) fAODOmega->Delete();
400 if(fKFReconstructedGammasTClone == NULL){
401 fKFReconstructedGammasTClone = new TClonesArray("AliKFParticle",0);
403 if(fCurrentEventPosElectronTClone == NULL){
404 fCurrentEventPosElectronTClone = new TClonesArray("AliESDtrack",0);
406 if(fCurrentEventNegElectronTClone == NULL){
407 fCurrentEventNegElectronTClone = new TClonesArray("AliESDtrack",0);
409 if(fKFReconstructedGammasCutTClone == NULL){
410 fKFReconstructedGammasCutTClone = new TClonesArray("AliKFParticle",0);
412 if(fPreviousEventTLVNegElectronTClone == NULL){
413 fPreviousEventTLVNegElectronTClone = new TClonesArray("TLorentzVector",0);
415 if(fPreviousEventTLVPosElectronTClone == NULL){
416 fPreviousEventTLVPosElectronTClone = new TClonesArray("TLorentzVector",0);
418 if(fChargedParticles == NULL){
419 fChargedParticles = new TClonesArray("AliESDtrack",0);
422 if(fKFReconstructedPi0sTClone == NULL){
423 fKFReconstructedPi0sTClone = new TClonesArray("AliKFParticle",0);
426 if(fKFRecalculatedGammasTClone == NULL){
427 fKFRecalculatedGammasTClone = new TClonesArray("AliKFParticle",0);
432 fKFReconstructedGammasTClone->Delete();
433 fCurrentEventPosElectronTClone->Delete();
434 fCurrentEventNegElectronTClone->Delete();
435 fKFReconstructedGammasCutTClone->Delete();
436 fPreviousEventTLVNegElectronTClone->Delete();
437 fPreviousEventTLVPosElectronTClone->Delete();
438 fKFReconstructedPi0sTClone->Delete();
439 fKFRecalculatedGammasTClone->Delete();
448 fElectronRecalculatedv1.clear();
449 fElectronRecalculatedv2.clear();
452 fChargedParticles->Delete();
454 fChargedParticlesId.clear();
456 fKFReconstructedGammasV0Index.clear();
458 //Clear the data in the v0Reader
459 // fV0Reader->UpdateEventByEventData();
461 //Take Only events with proper trigger
464 if(!fV0Reader->GetESDEvent()->IsTriggerClassFired("CINT1B-ABCE-NOPF-ALL")) return;
468 if(fV0Reader->CheckForPrimaryVertex() == kFALSE){
469 // cout<< "Event not taken"<< endl;
470 return; // aborts if the primary vertex does not have contributors.
474 if(!fV0Reader->CheckForPrimaryVertexZ() ){
480 // Process the MC information
485 //Process the v0 information with no cuts
488 // Process the v0 information
493 FillAODWithConversionGammas() ;
495 // Process reconstructed gammas
496 if(fDoNeutralMeson == kTRUE){
497 ProcessGammasForNeutralMesonAnalysis();
501 if(fDoMCTruth == kTRUE){
504 //Process reconstructed gammas electrons for Chi_c Analysis
505 if(fDoChic == kTRUE){
506 ProcessGammaElectronsForChicAnalysis();
508 // Process reconstructed gammas for gamma Jet/hadron correlations
510 ProcessGammasForGammaJetAnalysis();
513 //calculate background if flag is set
514 if(fCalculateBackground){
515 CalculateBackground();
518 if(fDoNeutralMeson == kTRUE){
519 // ProcessConvPHOSGammasForNeutralMesonAnalysis();
520 if(fDoOmegaMeson == kTRUE){
521 ProcessGammasForOmegaMesonAnalysis();
525 //Clear the data in the v0Reader
526 fV0Reader->UpdateEventByEventData();
527 if(fRecalculateV0ForGamma==kTRUE){
528 RecalculateV0ForGamma();
530 PostData(1, fOutputContainer);
531 PostData(2, fCFManager->GetParticleContainer()); // for CF
535 // void AliAnalysisTaskGammaConversion::ConnectInputData(Option_t *option){
536 // // see header file for documentation
537 // // printf(" ConnectInputData %s\n", GetName());
539 // AliAnalysisTaskSE::ConnectInputData(option);
541 // if(fV0Reader == NULL){
542 // // Write warning here cuts and so on are default if this ever happens
544 // fV0Reader->Initialize();
545 // fDoMCTruth = fV0Reader->GetDoMCTruth();
550 void AliAnalysisTaskGammaConversion::ProcessMCData(){
551 // see header file for documentation
552 //InputEvent(), MCEvent());
554 fStack = fV0Reader->GetMCStack();
555 fMCTruth = fV0Reader->GetMCTruth(); // for CF
556 fGCMCEvent = fV0Reader->GetMCEvent(); // for CF
558 fStack= MCEvent()->Stack();
559 fGCMCEvent=MCEvent();
562 Double_t containerInput[3];
564 if(!fGCMCEvent) cout << "NO MC INFO FOUND" << endl;
565 fCFManager->SetEventInfo(fGCMCEvent);
570 if(fV0Reader->CheckForPrimaryVertex() == kFALSE){
571 return; // aborts if the primary vertex does not have contributors.
574 for (Int_t iTracks = 0; iTracks < fStack->GetNtrack(); iTracks++) {
575 TParticle* particle = (TParticle *)fStack->Particle(iTracks);
582 ///////////////////////Begin Chic Analysis/////////////////////////////
584 if(particle->GetPdgCode() == 443){//Is JPsi
585 if(particle->GetNDaughters()==2){
586 if(TMath::Abs(fStack->Particle(particle->GetFirstDaughter())->GetPdgCode()) == 11 &&
587 TMath::Abs(fStack->Particle(particle->GetLastDaughter())->GetPdgCode()) == 11){
589 TParticle* daug0 = fStack->Particle(particle->GetFirstDaughter());
590 TParticle* daug1 = fStack->Particle(particle->GetLastDaughter());
591 if(TMath::Abs(daug0->Eta()) < 0.9 && TMath::Abs(daug1->Eta()) < 0.9)
592 fHistograms->FillTable("Table_Electrons",3);//e+ e- from J/Psi inside acceptance
594 if( TMath::Abs(daug0->Eta()) < 0.9){
595 if(daug0->GetPdgCode() == -11)
596 fHistograms->FillTable("Table_Electrons",1);//e+ from J/Psi inside acceptance
598 fHistograms->FillTable("Table_Electrons",2);//e- from J/Psi inside acceptance
601 if(TMath::Abs(daug1->Eta()) < 0.9){
602 if(daug1->GetPdgCode() == -11)
603 fHistograms->FillTable("Table_Electrons",1);//e+ from J/Psi inside acceptance
605 fHistograms->FillTable("Table_Electrons",2);//e- from J/Psi inside acceptance
610 // const int CHI_C0 = 10441;
611 // const int CHI_C1 = 20443;
612 // const int CHI_C2 = 445
613 if(particle->GetPdgCode() == 22){//gamma from JPsi
614 if(particle->GetMother(0) > -1){
615 if(fStack->Particle(particle->GetMother(0))->GetPdgCode() == 10441 ||
616 fStack->Particle(particle->GetMother(0))->GetPdgCode() == 20443 ||
617 fStack->Particle(particle->GetMother(0))->GetPdgCode() == 445){
618 if(TMath::Abs(particle->Eta()) < 1.2)
619 fHistograms->FillTable("Table_Electrons",17);// gamma from chic inside accptance
623 if(particle->GetPdgCode() == 10441 || particle->GetPdgCode() == 20443 || particle->GetPdgCode() == 445){
624 if( particle->GetNDaughters() == 2){
625 TParticle* daug0 = fStack->Particle(particle->GetFirstDaughter());
626 TParticle* daug1 = fStack->Particle(particle->GetLastDaughter());
628 if( (daug0->GetPdgCode() == 443 || daug0->GetPdgCode() == 22) && (daug1->GetPdgCode() == 443 || daug1->GetPdgCode() == 22) ){
629 if( daug0->GetPdgCode() == 443){
630 TParticle* daugE0 = fStack->Particle(daug0->GetFirstDaughter());
631 TParticle* daugE1 = fStack->Particle(daug0->GetLastDaughter());
632 if( TMath::Abs(daug1->Eta()) < 1.2 && TMath::Abs(daugE0->Eta()) < 0.9 && TMath::Abs(daugE1->Eta()) < 0.9 )
633 fHistograms->FillTable("Table_Electrons",18);
636 else if (daug1->GetPdgCode() == 443){
637 TParticle* daugE0 = fStack->Particle(daug1->GetFirstDaughter());
638 TParticle* daugE1 = fStack->Particle(daug1->GetLastDaughter());
639 if( TMath::Abs(daug0->Eta()) < 1.2 && TMath::Abs(daugE0->Eta()) < 0.9 && TMath::Abs(daugE1->Eta()) < 0.9 )
640 fHistograms->FillTable("Table_Electrons",18);
647 /////////////////////End Chic Analysis////////////////////////////
650 if(TMath::Abs(particle->Eta())> fV0Reader->GetEtaCut() ) continue;
652 if(particle->R()>fV0Reader->GetMaxRCut()) continue; // cuts on distance from collision point
654 Double_t tmpPhi=particle->Phi();
656 if(particle->Phi()> TMath::Pi()){
657 tmpPhi = particle->Phi()-(2*TMath::Pi());
661 if(particle->Energy() - particle->Pz() == 0 || particle->Energy() + particle->Pz() == 0){
665 rapidity = 0.5*(TMath::Log((particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz())));
669 if (particle->GetPdgCode() == 22){
672 if(particle->GetMother(0) >-1 && fStack->Particle(particle->GetMother(0))->GetPdgCode() == 22){
673 continue; // no photon as mothers!
676 if(particle->GetMother(0) >= fStack->GetNprimary()){
677 continue; // the gamma has a mother, and it is not a primary particle
680 fHistograms->FillHistogram("MC_allGamma_Energy", particle->Energy());
681 fHistograms->FillHistogram("MC_allGamma_Pt", particle->Pt());
682 fHistograms->FillHistogram("MC_allGamma_Eta", particle->Eta());
683 fHistograms->FillHistogram("MC_allGamma_Phi", tmpPhi);
684 fHistograms->FillHistogram("MC_allGamma_Rapid", rapidity);
688 containerInput[0] = particle->Pt();
689 containerInput[1] = particle->Eta();
690 if(particle->GetMother(0) >=0){
691 containerInput[2] = fStack->Particle(particle->GetMother(0))->GetMass();
694 containerInput[2]=-1;
697 fCFManager->GetParticleContainer()->Fill(containerInput,kStepGenerated); // generated gamma
699 if(particle->GetMother(0) < 0){ // direct gamma
700 fHistograms->FillHistogram("MC_allDirectGamma_Energy",particle->Energy());
701 fHistograms->FillHistogram("MC_allDirectGamma_Pt", particle->Pt());
702 fHistograms->FillHistogram("MC_allDirectGamma_Eta", particle->Eta());
703 fHistograms->FillHistogram("MC_allDirectGamma_Phi", tmpPhi);
704 fHistograms->FillHistogram("MC_allDirectGamma_Rapid", rapidity);
707 // looking for conversion (electron + positron from pairbuilding (= 5) )
708 TParticle* ePos = NULL;
709 TParticle* eNeg = NULL;
711 if(particle->GetNDaughters() >= 2){
712 for(Int_t daughterIndex=particle->GetFirstDaughter();daughterIndex<=particle->GetLastDaughter();daughterIndex++){
713 TParticle *tmpDaughter = fStack->Particle(daughterIndex);
714 if(tmpDaughter->GetUniqueID() == 5){
715 if(tmpDaughter->GetPdgCode() == 11){
718 else if(tmpDaughter->GetPdgCode() == -11){
726 if(ePos == NULL || eNeg == NULL){ // means we do not have two daughters from pair production
731 Double_t ePosPhi = ePos->Phi();
732 if(ePos->Phi()> TMath::Pi()) ePosPhi = ePos->Phi()-(2*TMath::Pi());
734 Double_t eNegPhi = eNeg->Phi();
735 if(eNeg->Phi()> TMath::Pi()) eNegPhi = eNeg->Phi()-(2*TMath::Pi());
738 if(ePos->Pt()<fV0Reader->GetPtCut() || eNeg->Pt()<fV0Reader->GetPtCut()){
739 continue; // no reconstruction below the Pt cut
742 if(TMath::Abs(ePos->Eta())> fV0Reader->GetEtaCut() || TMath::Abs(eNeg->Eta())> fV0Reader->GetEtaCut()){
746 if(ePos->R()>fV0Reader->GetMaxRCut()){
747 continue; // cuts on distance from collision point
750 if(TMath::Abs(ePos->Vz()) > fV0Reader->GetMaxZCut()){
751 continue; // outside material
755 if((TMath::Abs(ePos->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue() > ePos->R()){
756 continue; // line cut to exclude regions where we do not reconstruct
762 fCFManager->GetParticleContainer()->Fill(containerInput,kStepReconstructable); // reconstructable gamma
764 fHistograms->FillHistogram("MC_ConvGamma_Energy", particle->Energy());
765 fHistograms->FillHistogram("MC_ConvGamma_Pt", particle->Pt());
766 fHistograms->FillHistogram("MC_ConvGamma_Eta", particle->Eta());
767 fHistograms->FillHistogram("MC_ConvGamma_Phi", tmpPhi);
768 fHistograms->FillHistogram("MC_ConvGamma_Rapid", rapidity);
769 fHistograms->FillHistogram("MC_ConvGamma_Pt_Eta", particle->Pt(),particle->Eta());
771 fHistograms->FillHistogram("MC_E_Energy", eNeg->Energy());
772 fHistograms->FillHistogram("MC_E_Pt", eNeg->Pt());
773 fHistograms->FillHistogram("MC_E_Eta", eNeg->Eta());
774 fHistograms->FillHistogram("MC_E_Phi", eNegPhi);
776 fHistograms->FillHistogram("MC_P_Energy", ePos->Energy());
777 fHistograms->FillHistogram("MC_P_Pt", ePos->Pt());
778 fHistograms->FillHistogram("MC_P_Eta", ePos->Eta());
779 fHistograms->FillHistogram("MC_P_Phi", ePosPhi);
783 Int_t rBin = fHistograms->GetRBin(ePos->R());
784 Int_t zBin = fHistograms->GetZBin(ePos->Vz());
785 Int_t phiBin = fHistograms->GetPhiBin(particle->Phi());
788 TVector3 vtxPos(ePos->Vx(),ePos->Vy(),ePos->Vz());
790 TString nameMCMappingPhiR="";
791 nameMCMappingPhiR.Form("MC_Conversion_Mapping_Phi%02d_R%02d",phiBin,rBin);
792 // fHistograms->FillHistogram(nameMCMappingPhiR, ePos->Vz(), particle->Eta());
794 TString nameMCMappingPhi="";
795 nameMCMappingPhi.Form("MC_Conversion_Mapping_Phi%02d",phiBin);
796 // fHistograms->FillHistogram(nameMCMappingPhi, particle->Eta());
797 //fHistograms->FillHistogram(nameMCMappingPhi, ePos->Vz(), particle->Eta());
799 TString nameMCMappingR="";
800 nameMCMappingR.Form("MC_Conversion_Mapping_R%02d",rBin);
801 // fHistograms->FillHistogram(nameMCMappingR, particle->Eta());
802 //fHistograms->FillHistogram(nameMCMappingR,ePos->Vz(), particle->Eta());
804 TString nameMCMappingPhiInR="";
805 nameMCMappingPhiInR.Form("MC_Conversion_Mapping_Phi_in_R_%02d",rBin);
806 // fHistograms->FillHistogram(nameMCMappingPhiInR, tmpPhi);
807 fHistograms->FillHistogram(nameMCMappingPhiInR, vtxPos.Phi());
809 TString nameMCMappingZInR="";
810 nameMCMappingZInR.Form("MC_Conversion_Mapping_Z_in_R_%02d",rBin);
811 fHistograms->FillHistogram(nameMCMappingZInR,ePos->Vz() );
814 TString nameMCMappingPhiInZ="";
815 nameMCMappingPhiInZ.Form("MC_Conversion_Mapping_Phi_in_Z_%02d",zBin);
816 // fHistograms->FillHistogram(nameMCMappingPhiInR, tmpPhi);
817 fHistograms->FillHistogram(nameMCMappingPhiInZ, vtxPos.Phi());
821 TString nameMCMappingFMDPhiInZ="";
822 nameMCMappingFMDPhiInZ.Form("MC_Conversion_Mapping_FMD_Phi_in_Z_%02d",zBin);
823 fHistograms->FillHistogram(nameMCMappingFMDPhiInZ, vtxPos.Phi());
826 TString nameMCMappingRInZ="";
827 nameMCMappingRInZ.Form("MC_Conversion_Mapping_R_in_Z_%02d",zBin);
828 fHistograms->FillHistogram(nameMCMappingRInZ,ePos->R() );
830 if(particle->Pt() > fLowPtMapping && particle->Pt()< fHighPtMapping){
831 TString nameMCMappingMidPtPhiInR="";
832 nameMCMappingMidPtPhiInR.Form("MC_Conversion_Mapping_MidPt_Phi_in_R_%02d",rBin);
833 fHistograms->FillHistogram(nameMCMappingMidPtPhiInR, vtxPos.Phi());
835 TString nameMCMappingMidPtZInR="";
836 nameMCMappingMidPtZInR.Form("MC_Conversion_Mapping_MidPt_Z_in_R_%02d",rBin);
837 fHistograms->FillHistogram(nameMCMappingMidPtZInR,ePos->Vz() );
840 TString nameMCMappingMidPtPhiInZ="";
841 nameMCMappingMidPtPhiInZ.Form("MC_Conversion_Mapping_MidPt_Phi_in_Z_%02d",zBin);
842 fHistograms->FillHistogram(nameMCMappingMidPtPhiInZ, vtxPos.Phi());
846 TString nameMCMappingMidPtFMDPhiInZ="";
847 nameMCMappingMidPtFMDPhiInZ.Form("MC_Conversion_Mapping_MidPt_FMD_Phi_in_Z_%02d",zBin);
848 fHistograms->FillHistogram(nameMCMappingMidPtFMDPhiInZ, vtxPos.Phi());
852 TString nameMCMappingMidPtRInZ="";
853 nameMCMappingMidPtRInZ.Form("MC_Conversion_Mapping_MidPt_R_in_Z_%02d",zBin);
854 fHistograms->FillHistogram(nameMCMappingMidPtRInZ,ePos->R() );
860 fHistograms->FillHistogram("MC_Conversion_R",ePos->R());
861 fHistograms->FillHistogram("MC_Conversion_ZR",ePos->Vz(),ePos->R());
862 fHistograms->FillHistogram("MC_Conversion_XY",ePos->Vx(),ePos->Vy());
863 fHistograms->FillHistogram("MC_Conversion_OpeningAngle",GetMCOpeningAngle(ePos, eNeg));
864 fHistograms->FillHistogram("MC_ConvGamma_E_AsymmetryP",particle->P(),eNeg->P()/particle->P());
865 fHistograms->FillHistogram("MC_ConvGamma_P_AsymmetryP",particle->P(),ePos->P()/particle->P());
868 if(particle->GetMother(0) < 0){ // no mother = direct gamma, still inside converted
869 fHistograms->FillHistogram("MC_ConvDirectGamma_Energy",particle->Energy());
870 fHistograms->FillHistogram("MC_ConvDirectGamma_Pt", particle->Pt());
871 fHistograms->FillHistogram("MC_ConvDirectGamma_Eta", particle->Eta());
872 fHistograms->FillHistogram("MC_ConvDirectGamma_Phi", tmpPhi);
873 fHistograms->FillHistogram("MC_ConvDirectGamma_Rapid", rapidity);
875 } // end direct gamma
876 else{ // mother exits
877 /* if( fStack->Particle(particle->GetMother(0))->GetPdgCode()==10441 ||//chic0
878 fStack->Particle(particle->GetMother(0))->GetPdgCode()==20443 ||//psi2S
879 fStack->Particle(particle->GetMother(0))->GetPdgCode()==445 //chic2
881 fMCGammaChic.push_back(particle);
884 } // end if mother exits
885 } // end if particle is a photon
889 // process motherparticles (2 gammas as daughters)
890 // the motherparticle had already to pass the R and the eta cut, but no line cut.
891 // the line cut is just valid for the conversions!
893 if(particle->GetNDaughters() == 2){
895 TParticle* daughter0 = (TParticle*)fStack->Particle(particle->GetFirstDaughter());
896 TParticle* daughter1 = (TParticle*)fStack->Particle(particle->GetLastDaughter());
898 if(daughter0->GetPdgCode() != 22 || daughter1->GetPdgCode() != 22) continue; //check for gamma gamma daughters
900 // Check the acceptance for both gammas
901 Bool_t gammaEtaCut = kTRUE;
902 if(TMath::Abs(daughter0->Eta()) > fV0Reader->GetEtaCut() || TMath::Abs(daughter1->Eta()) > fV0Reader->GetEtaCut() ) gammaEtaCut = kFALSE;
903 Bool_t gammaRCut = kTRUE;
904 if(daughter0->R() > fV0Reader->GetMaxRCut() || daughter1->R() > fV0Reader->GetMaxRCut() ) gammaRCut = kFALSE;
908 // check for conversions now -> have to pass eta, R and line cut!
909 Bool_t daughter0Electron = kFALSE;
910 Bool_t daughter0Positron = kFALSE;
911 Bool_t daughter1Electron = kFALSE;
912 Bool_t daughter1Positron = kFALSE;
914 if(daughter0->GetNDaughters() >= 2){ // first gamma
915 for(Int_t TrackIndex=daughter0->GetFirstDaughter();TrackIndex<=daughter0->GetLastDaughter();TrackIndex++){
916 TParticle *tmpDaughter = fStack->Particle(TrackIndex);
917 if(tmpDaughter->GetUniqueID() == 5){
918 if(tmpDaughter->GetPdgCode() == 11){
919 if( TMath::Abs(tmpDaughter->Eta()) <= fV0Reader->GetEtaCut() ){
920 if( ( TMath::Abs(tmpDaughter->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue() < tmpDaughter->R() ){
921 if(tmpDaughter->R()< fV0Reader->GetMaxRCut()){
922 daughter0Electron = kTRUE;
928 else if(tmpDaughter->GetPdgCode() == -11){
929 if( TMath::Abs(tmpDaughter->Eta()) <= fV0Reader->GetEtaCut() ){
930 if( ( TMath::Abs(tmpDaughter->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue() < tmpDaughter->R() ){
931 if(tmpDaughter->R()< fV0Reader->GetMaxRCut()){
932 daughter0Positron = kTRUE;
942 if(daughter1->GetNDaughters() >= 2){ // second gamma
943 for(Int_t TrackIndex=daughter1->GetFirstDaughter();TrackIndex<=daughter1->GetLastDaughter();TrackIndex++){
944 TParticle *tmpDaughter = fStack->Particle(TrackIndex);
945 if(tmpDaughter->GetUniqueID() == 5){
946 if(tmpDaughter->GetPdgCode() == 11){
947 if( TMath::Abs(tmpDaughter->Eta()) <= fV0Reader->GetEtaCut() ){
948 if( ( TMath::Abs(tmpDaughter->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue() < tmpDaughter->R() ){
949 if(tmpDaughter->R()< fV0Reader->GetMaxRCut()){
950 daughter1Electron = kTRUE;
956 else if(tmpDaughter->GetPdgCode() == -11){
957 if( TMath::Abs(tmpDaughter->Eta()) <= fV0Reader->GetEtaCut() ){
958 if( ( TMath::Abs(tmpDaughter->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue() < tmpDaughter->R() ){
959 if(tmpDaughter->R()< fV0Reader->GetMaxRCut()){
960 daughter1Positron = kTRUE;
972 if(particle->GetPdgCode()==111){ //Pi0
973 if( iTracks >= fStack->GetNprimary()){
974 fHistograms->FillHistogram("MC_Pi0_Secondaries_Eta", particle->Eta());
975 fHistograms->FillHistogram("MC_Pi0_Secondaries_Rapid", rapidity);
976 fHistograms->FillHistogram("MC_Pi0_Secondaries_Phi", tmpPhi);
977 fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt", particle->Pt());
978 fHistograms->FillHistogram("MC_Pi0_Secondaries_Energy", particle->Energy());
979 fHistograms->FillHistogram("MC_Pi0_Secondaries_R", particle->R());
980 fHistograms->FillHistogram("MC_Pi0_Secondaries_ZR", particle->Vz(),particle->R());
981 fHistograms->FillHistogram("MC_Pi0_Secondaries_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));
982 fHistograms->FillHistogram("MC_Pi0_Secondaries_XY", particle->Vx(),particle->Vy());//only fill from one daughter to avoid multiple filling
984 if(gammaEtaCut && gammaRCut){
985 //if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){
986 fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt_Eta_withinAcceptance", particle->Pt(),particle->Eta());
987 fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt_Rapid_withinAcceptance", particle->Pt(),rapidity);
988 if(daughter0Electron && daughter0Positron && daughter1Electron && daughter1Positron){
989 fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt_Eta_ConvGamma_withinAcceptance", particle->Pt(),particle->Eta());
990 fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt_Rapid_ConvGamma_withinAcceptance", particle->Pt(),rapidity);
995 fHistograms->FillHistogram("MC_Pi0_Eta", particle->Eta());
996 fHistograms->FillHistogram("MC_Pi0_Rapid", rapidity);
997 fHistograms->FillHistogram("MC_Pi0_Phi", tmpPhi);
998 fHistograms->FillHistogram("MC_Pi0_Pt", particle->Pt());
999 fHistograms->FillHistogram("MC_Pi0_Energy", particle->Energy());
1000 fHistograms->FillHistogram("MC_Pi0_R", particle->R());
1001 fHistograms->FillHistogram("MC_Pi0_ZR", particle->Vz(),particle->R());
1002 fHistograms->FillHistogram("MC_Pi0_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));
1003 fHistograms->FillHistogram("MC_Pi0_XY", particle->Vx(), particle->Vy());//only fill from one daughter to avoid multiple filling
1004 if(TMath::Abs(particle->Eta())<0.9)fHistograms->FillHistogram("MC_Pi0_Pt_Fiducial", particle->Pt());
1006 if(gammaEtaCut && gammaRCut){
1007 // if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){
1008 fHistograms->FillHistogram("MC_Pi0_Pt_Eta_withinAcceptance", particle->Pt(),particle->Eta());
1009 fHistograms->FillHistogram("MC_Pi0_Pt_Rapid_withinAcceptance", particle->Pt(),rapidity);
1010 if(TMath::Abs(particle->Eta())<0.9)fHistograms->FillHistogram("MC_Pi0_Pt_withinAcceptance_Fiducial", particle->Pt());
1012 if(daughter0Electron && daughter0Positron && daughter1Electron && daughter1Positron){
1013 fHistograms->FillHistogram("MC_Pi0_Pt_Eta_ConvGamma_withinAcceptance", particle->Pt(),particle->Eta());
1014 fHistograms->FillHistogram("MC_Pi0_Pt_Rapid_ConvGamma_withinAcceptance", particle->Pt(),rapidity);
1015 fHistograms->FillHistogram("MC_Pi0_ZR_ConvGamma_withinAcceptance", particle->Vz(),particle->R());
1016 fHistograms->FillHistogram("MC_Pi0_ConvGamma_OpeningAngle_Pt", particle->Pt(),GetMCOpeningAngle(daughter0,daughter1));
1017 fHistograms->FillHistogram("MC_Pi0_ConvGamma_PtGamma_Pt", particle->Pt(),daughter0->Pt());
1018 fHistograms->FillHistogram("MC_Pi0_ConvGamma_PtGamma_Pt", particle->Pt(),daughter1->Pt());
1021 if((daughter0->Energy()+daughter1->Energy())!= 0.){
1022 alfa= TMath::Abs((daughter0->Energy()-daughter1->Energy())/(daughter0->Energy()+daughter1->Energy()));
1024 fHistograms->FillHistogram("MC_Pi0_alpha",alfa);
1025 if(TMath::Abs(particle->Eta())<0.9)fHistograms->FillHistogram("MC_Pi0_Pt_ConvGamma_withinAcceptance_Fiducial", particle->Pt());
1032 if(particle->GetPdgCode()==221){ //Eta
1033 fHistograms->FillHistogram("MC_Eta_Eta", particle->Eta());
1034 fHistograms->FillHistogram("MC_Eta_Rapid", rapidity);
1035 fHistograms->FillHistogram("MC_Eta_Phi",tmpPhi);
1036 fHistograms->FillHistogram("MC_Eta_Pt", particle->Pt());
1037 fHistograms->FillHistogram("MC_Eta_Energy", particle->Energy());
1038 fHistograms->FillHistogram("MC_Eta_R", particle->R());
1039 fHistograms->FillHistogram("MC_Eta_ZR", particle->Vz(),particle->R());
1040 fHistograms->FillHistogram("MC_Eta_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));
1041 fHistograms->FillHistogram("MC_Eta_XY", particle->Vx(), particle->Vy());//only fill from one daughter to avoid multiple filling
1043 if(gammaEtaCut && gammaRCut){
1044 // if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){
1045 fHistograms->FillHistogram("MC_Eta_Pt_Eta_withinAcceptance", particle->Pt(),particle->Eta());
1046 fHistograms->FillHistogram("MC_Eta_Pt_Rapid_withinAcceptance", particle->Pt(),rapidity);
1047 if(daughter0Electron && daughter0Positron && daughter1Electron && daughter1Positron){
1048 fHistograms->FillHistogram("MC_Eta_Pt_Eta_ConvGamma_withinAcceptance", particle->Pt(),particle->Eta());
1049 fHistograms->FillHistogram("MC_Eta_Pt_Rapid_ConvGamma_withinAcceptance", particle->Pt(),rapidity);
1050 fHistograms->FillHistogram("MC_Eta_ZR_ConvGamma_withinAcceptance", particle->Vz(),particle->R());
1051 fHistograms->FillHistogram("MC_Eta_ConvGamma_OpeningAngle_Pt", particle->Pt(),GetMCOpeningAngle(daughter0,daughter1));
1052 fHistograms->FillHistogram("MC_Eta_ConvGamma_PtGamma_Pt", particle->Pt(),daughter0->Pt());
1053 fHistograms->FillHistogram("MC_Eta_ConvGamma_PtGamma_Pt", particle->Pt(),daughter1->Pt());
1061 // all motherparticles with 2 gammas as daughters
1062 fHistograms->FillHistogram("MC_Mother_R", particle->R());
1063 fHistograms->FillHistogram("MC_Mother_ZR", particle->Vz(),particle->R());
1064 fHistograms->FillHistogram("MC_Mother_XY", particle->Vx(),particle->Vy());
1065 fHistograms->FillHistogram("MC_Mother_Mass", particle->GetCalcMass());
1066 fHistograms->FillHistogram("MC_Mother_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));
1067 fHistograms->FillHistogram("MC_Mother_Energy", particle->Energy());
1068 fHistograms->FillHistogram("MC_Mother_Pt", particle->Pt());
1069 fHistograms->FillHistogram("MC_Mother_Eta", particle->Eta());
1070 fHistograms->FillHistogram("MC_Mother_Rapid", rapidity);
1071 fHistograms->FillHistogram("MC_Mother_Phi",tmpPhi);
1072 fHistograms->FillHistogram("MC_Mother_InvMass_vs_Pt",particle->GetMass(),particle->Pt());
1074 if(gammaEtaCut && gammaRCut){
1075 // if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){
1076 fHistograms->FillHistogram("MC_Mother_Pt_Eta_withinAcceptance", particle->Pt(),particle->Eta());
1077 fHistograms->FillHistogram("MC_Mother_Pt_Rapid_withinAcceptance", particle->Pt(),rapidity);
1078 fHistograms->FillHistogram("MC_Mother_InvMass_vs_Pt_withinAcceptance",particle->GetMass(),particle->Pt());
1079 if(daughter0Electron && daughter0Positron && daughter1Electron && daughter1Positron){
1080 fHistograms->FillHistogram("MC_Mother_Pt_Eta_ConvGamma_withinAcceptance", particle->Pt(),particle->Eta());
1081 fHistograms->FillHistogram("MC_Mother_Pt_Rapid_ConvGamma_withinAcceptance", particle->Pt(),rapidity);
1082 fHistograms->FillHistogram("MC_Mother_InvMass_vs_Pt_ConvGamma_withinAcceptance",particle->GetMass(),particle->Pt());
1087 } // end passed R and eta cut
1089 } // end if(particle->GetNDaughters() == 2)
1091 }// end for (Int_t iTracks = 0; iTracks < fStack->GetNtrack(); iTracks++)
1093 } // end ProcessMCData
1097 void AliAnalysisTaskGammaConversion::FillNtuple(){
1098 //Fills the ntuple with the different values
1100 if(fGammaNtuple == NULL){
1103 Int_t numberOfV0s = fV0Reader->GetNumberOfV0s();
1104 for(Int_t i=0;i<numberOfV0s;i++){
1105 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};
1106 AliESDv0 * cV0 = fV0Reader->GetV0(i);
1109 fV0Reader->GetPIDProbability(negPID,posPID);
1110 values[0]=cV0->GetOnFlyStatus();
1111 values[1]=fV0Reader->CheckForPrimaryVertex();
1114 values[4]=fV0Reader->GetX();
1115 values[5]=fV0Reader->GetY();
1116 values[6]=fV0Reader->GetZ();
1117 values[7]=fV0Reader->GetXYRadius();
1118 values[8]=fV0Reader->GetMotherCandidateNDF();
1119 values[9]=fV0Reader->GetMotherCandidateChi2();
1120 values[10]=fV0Reader->GetMotherCandidateEnergy();
1121 values[11]=fV0Reader->GetMotherCandidateEta();
1122 values[12]=fV0Reader->GetMotherCandidatePt();
1123 values[13]=fV0Reader->GetMotherCandidateMass();
1124 values[14]=fV0Reader->GetMotherCandidateWidth();
1125 // values[15]=fV0Reader->GetMotherMCParticle()->Pt(); MOVED TO THE END, HAS TO BE CALLED AFTER HasSameMother NB: still has the same entry in the array
1126 values[16]=fV0Reader->GetOpeningAngle();
1127 values[17]=fV0Reader->GetNegativeTrackEnergy();
1128 values[18]=fV0Reader->GetNegativeTrackPt();
1129 values[19]=fV0Reader->GetNegativeTrackEta();
1130 values[20]=fV0Reader->GetNegativeTrackPhi();
1131 values[21]=fV0Reader->GetPositiveTrackEnergy();
1132 values[22]=fV0Reader->GetPositiveTrackPt();
1133 values[23]=fV0Reader->GetPositiveTrackEta();
1134 values[24]=fV0Reader->GetPositiveTrackPhi();
1135 values[25]=fV0Reader->HasSameMCMother();
1136 if(values[25] != 0){
1137 values[26]=fV0Reader->GetMotherMCParticlePDGCode();
1138 values[15]=fV0Reader->GetMotherMCParticle()->Pt();
1140 fTotalNumberOfAddedNtupleEntries++;
1141 fGammaNtuple->Fill(values);
1143 fV0Reader->ResetV0IndexNumber();
1147 void AliAnalysisTaskGammaConversion::ProcessV0sNoCut(){
1148 // Process all the V0's without applying any cuts to it
1150 Int_t numberOfV0s = fV0Reader->GetNumberOfV0s();
1151 for(Int_t i=0;i<numberOfV0s;i++){
1152 /*AliESDv0 * cV0 = */fV0Reader->GetV0(i);
1154 if(fV0Reader->CheckForPrimaryVertex() == kFALSE){
1158 // if( !fV0Reader->GetV0(i)->GetOnFlyStatus()){
1159 if( !fV0Reader->CheckV0FinderStatus(i)){
1164 if( !((fV0Reader->GetNegativeESDTrack())->GetStatus() & AliESDtrack::kTPCrefit) ||
1165 !((fV0Reader->GetPositiveESDTrack())->GetStatus() & AliESDtrack::kTPCrefit) ){
1169 if( fV0Reader->GetNegativeESDTrack()->GetSign()== fV0Reader->GetPositiveESDTrack()->GetSign()){
1173 if( fV0Reader->GetNegativeESDTrack()->GetKinkIndex(0) > 0 ||
1174 fV0Reader->GetPositiveESDTrack()->GetKinkIndex(0) > 0) {
1177 if(TMath::Abs(fV0Reader->GetMotherCandidateEta())> fV0Reader->GetEtaCut()){
1180 if(TMath::Abs(fV0Reader->GetPositiveTrackEta())> fV0Reader->GetEtaCut()){
1183 if(TMath::Abs(fV0Reader->GetNegativeTrackEta())> fV0Reader->GetEtaCut()){
1186 if((TMath::Abs(fV0Reader->GetZ())*fV0Reader->GetLineCutZRSlope())-fV0Reader->GetLineCutZValue() > fV0Reader->GetXYRadius() ){ // cuts out regions where we do not reconstruct
1191 if(fV0Reader->HasSameMCMother() == kFALSE){
1195 TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
1196 TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
1198 if(TMath::Abs(negativeMC->GetPdgCode())!=11 || TMath::Abs(positiveMC->GetPdgCode())!=11){
1201 if(negativeMC->GetPdgCode() == positiveMC->GetPdgCode()){
1205 if(negativeMC->GetUniqueID() != 5 || positiveMC->GetUniqueID() !=5){ // id 5 is conversion
1209 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
1211 fHistograms->FillHistogram("ESD_NoCutConvGamma_Pt", fV0Reader->GetMotherCandidatePt());
1212 fHistograms->FillHistogram("ESD_NoCutConvGamma_Energy", fV0Reader->GetMotherCandidateEnergy());
1213 fHistograms->FillHistogram("ESD_NoCutConvGamma_Eta", fV0Reader->GetMotherCandidateEta());
1214 fHistograms->FillHistogram("ESD_NoCutConvGamma_Phi", fV0Reader->GetMotherCandidatePhi());
1215 fHistograms->FillHistogram("ESD_NoCutConvGamma_Mass", fV0Reader->GetMotherCandidateMass());
1216 fHistograms->FillHistogram("ESD_NoCutConvGamma_Width", fV0Reader->GetMotherCandidateWidth());
1217 fHistograms->FillHistogram("ESD_NoCutConvGamma_Chi2", fV0Reader->GetMotherCandidateChi2());
1218 fHistograms->FillHistogram("ESD_NoCutConvGamma_NDF", fV0Reader->GetMotherCandidateNDF());
1219 fHistograms->FillHistogram("ESD_NoCutConvGamma_Rapid", fV0Reader->GetMotherCandidateRapidity());
1220 fHistograms->FillHistogram("ESD_NoCutConvGamma_Pt_Eta", fV0Reader->GetMotherCandidatePt(),fV0Reader->GetMotherCandidateEta());
1222 fHistograms->FillHistogram("ESD_NoCutConvGamma_Pt_Chi2", fV0Reader->GetMotherCandidatePt(), fV0Reader->GetMotherCandidateChi2());
1223 fHistograms->FillHistogram("ESD_NoCutConvGamma_Eta_Chi2", fV0Reader->GetMotherCandidateEta(), fV0Reader->GetMotherCandidateChi2());
1225 fHistograms->FillHistogram("ESD_NoCutConversion_XY", fV0Reader->GetX(),fV0Reader->GetY());
1226 fHistograms->FillHistogram("ESD_NoCutConversion_R", fV0Reader->GetXYRadius());
1227 fHistograms->FillHistogram("ESD_NoCutConversion_ZR", fV0Reader->GetZ(),fV0Reader->GetXYRadius());
1228 fHistograms->FillHistogram("ESD_NoCutConversion_OpeningAngle", fV0Reader->GetOpeningAngle());
1229 fHistograms->FillHistogram("ESD_NoCutConvGamma_CosPointingAngle", fV0Reader->GetCosPointingAngle());
1230 fHistograms->FillHistogram("ESD_NoCutConvGamma_DcaDaughters", fV0Reader->GetDcaDaughters());
1231 fHistograms->FillHistogram("ESD_NoCutConvGamma_NormDcaDistDaughters", fV0Reader->GetNormDcaDistDaughters());
1232 fHistograms->FillHistogram("ESD_NoCutConvGamma_LikelihoodAP", fV0Reader->GetLikelihoodAP());
1234 fHistograms->FillHistogram("ESD_NoCutConvGamma_E_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetNegativeTrackP()/fV0Reader->GetMotherCandidateP());
1235 fHistograms->FillHistogram("ESD_NoCutConvGamma_P_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetPositiveTrackP()/fV0Reader->GetMotherCandidateP());
1236 fHistograms->FillHistogram("ESD_NoCutConvGamma_E_dEdxP",fV0Reader->GetNegativeTrackP(),fV0Reader->GetNegativeTrackTPCdEdx());
1237 fHistograms->FillHistogram("ESD_NoCutConvGamma_P_dEdxP",fV0Reader->GetPositiveTrackP(),fV0Reader->GetPositiveTrackTPCdEdx());
1239 //store MCTruth properties
1240 fHistograms->FillHistogram("ESD_NoCutConvGamma_MC_Pt_Eta", fV0Reader->GetMotherMCParticle()->Pt(),fV0Reader->GetMotherMCParticle()->Eta());
1241 fHistograms->FillHistogram("ESD_NoCutConversion_MC_ZR", negativeMC->Vz(),negativeMC->R());
1242 fHistograms->FillHistogram("ESD_NoCutConversion_MC_XY", negativeMC->Vx(),negativeMC->Vy());
1246 fV0Reader->ResetV0IndexNumber();
1249 void AliAnalysisTaskGammaConversion::ProcessV0s(){
1250 // see header file for documentation
1253 if(fWriteNtuple == kTRUE){
1257 Int_t nSurvivingV0s=0;
1258 while(fV0Reader->NextV0()){
1262 TVector3 vtxConv(fV0Reader->GetX(),fV0Reader->GetY(), fV0Reader->GetZ());
1264 //-------------------------- filling v0 information -------------------------------------
1265 fHistograms->FillHistogram("ESD_Conversion_R", fV0Reader->GetXYRadius());
1266 fHistograms->FillHistogram("ESD_Conversion_ZR", fV0Reader->GetZ(),fV0Reader->GetXYRadius());
1267 fHistograms->FillHistogram("ESD_Conversion_XY", fV0Reader->GetX(),fV0Reader->GetY());
1268 fHistograms->FillHistogram("ESD_Conversion_OpeningAngle", fV0Reader->GetOpeningAngle());
1270 // Specific histograms for beam pipe studies
1271 if( TMath::Abs(fV0Reader->GetZ()) < fV0Reader->GetLineCutZValue() ){
1272 fHistograms->FillHistogram("ESD_Conversion_XY_BeamPipe", fV0Reader->GetX(),fV0Reader->GetY());
1273 fHistograms->FillHistogram("ESD_Conversion_RPhi_BeamPipe", vtxConv.Phi(),fV0Reader->GetXYRadius());
1277 fHistograms->FillHistogram("ESD_E_Energy", fV0Reader->GetNegativeTrackEnergy());
1278 fHistograms->FillHistogram("ESD_E_Pt", fV0Reader->GetNegativeTrackPt());
1279 fHistograms->FillHistogram("ESD_E_Eta", fV0Reader->GetNegativeTrackEta());
1280 fHistograms->FillHistogram("ESD_E_Phi", fV0Reader->GetNegativeTrackPhi());
1281 fHistograms->FillHistogram("ESD_E_nTPCClusters", fV0Reader->GetNegativeTracknTPCClusters());
1282 fHistograms->FillHistogram("ESD_E_nITSClusters", fV0Reader->GetNegativeTracknITSClusters());
1284 fHistograms->FillHistogram("ESD_P_Energy", fV0Reader->GetPositiveTrackEnergy());
1285 fHistograms->FillHistogram("ESD_P_Pt", fV0Reader->GetPositiveTrackPt());
1286 fHistograms->FillHistogram("ESD_P_Eta", fV0Reader->GetPositiveTrackEta());
1287 fHistograms->FillHistogram("ESD_P_Phi", fV0Reader->GetPositiveTrackPhi());
1288 fHistograms->FillHistogram("ESD_P_nTPCClusters", fV0Reader->GetPositiveTracknTPCClusters());
1289 fHistograms->FillHistogram("ESD_P_nITSClusters", fV0Reader->GetPositiveTracknITSClusters());
1291 fHistograms->FillHistogram("ESD_ConvGamma_Energy", fV0Reader->GetMotherCandidateEnergy());
1292 fHistograms->FillHistogram("ESD_ConvGamma_Pt", fV0Reader->GetMotherCandidatePt());
1293 fHistograms->FillHistogram("ESD_ConvGamma_Eta", fV0Reader->GetMotherCandidateEta());
1294 fHistograms->FillHistogram("ESD_ConvGamma_Phi", fV0Reader->GetMotherCandidatePhi());
1295 fHistograms->FillHistogram("ESD_ConvGamma_Mass", fV0Reader->GetMotherCandidateMass());
1296 fHistograms->FillHistogram("ESD_ConvGamma_Width", fV0Reader->GetMotherCandidateWidth());
1297 fHistograms->FillHistogram("ESD_ConvGamma_Chi2", fV0Reader->GetMotherCandidateChi2());
1298 fHistograms->FillHistogram("ESD_ConvGamma_NDF", fV0Reader->GetMotherCandidateNDF());
1299 fHistograms->FillHistogram("ESD_ConvGamma_Rapid", fV0Reader->GetMotherCandidateRapidity());
1300 fHistograms->FillHistogram("ESD_ConvGamma_Pt_Eta", fV0Reader->GetMotherCandidatePt(),fV0Reader->GetMotherCandidateEta());
1302 fHistograms->FillHistogram("ESD_ConvGamma_Pt_Chi2", fV0Reader->GetMotherCandidatePt(), fV0Reader->GetMotherCandidateChi2());
1303 fHistograms->FillHistogram("ESD_ConvGamma_Eta_Chi2", fV0Reader->GetMotherCandidateEta(), fV0Reader->GetMotherCandidateChi2());
1305 fHistograms->FillHistogram("ESD_ConvGamma_CosPointingAngle", fV0Reader->GetCosPointingAngle());
1306 fHistograms->FillHistogram("ESD_ConvGamma_DcaDaughters", fV0Reader->GetDcaDaughters());
1307 fHistograms->FillHistogram("ESD_ConvGamma_NormDcaDistDaughters", fV0Reader->GetNormDcaDistDaughters());
1308 fHistograms->FillHistogram("ESD_ConvGamma_LikelihoodAP", fV0Reader->GetLikelihoodAP());
1310 fHistograms->FillHistogram("ESD_ConvGamma_E_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetNegativeTrackP()/fV0Reader->GetMotherCandidateP());
1311 fHistograms->FillHistogram("ESD_ConvGamma_P_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetPositiveTrackP()/fV0Reader->GetMotherCandidateP());
1312 fHistograms->FillHistogram("ESD_ConvGamma_E_dEdxP",fV0Reader->GetNegativeTrackP(),fV0Reader->GetNegativeTrackTPCdEdx());
1313 fHistograms->FillHistogram("ESD_ConvGamma_P_dEdxP",fV0Reader->GetPositiveTrackP(),fV0Reader->GetPositiveTrackTPCdEdx());
1317 fV0Reader->GetPIDProbability(negPID,posPID);
1318 fHistograms->FillHistogram("ESD_ConvGamma_E_EProbP",fV0Reader->GetNegativeTrackP(),negPID);
1319 fHistograms->FillHistogram("ESD_ConvGamma_P_EProbP",fV0Reader->GetPositiveTrackP(),posPID);
1321 Double_t negPIDmupi=0;
1322 Double_t posPIDmupi=0;
1323 fV0Reader->GetPIDProbabilityMuonPion(negPIDmupi,posPIDmupi);
1324 fHistograms->FillHistogram("ESD_ConvGamma_E_mupiProbP",fV0Reader->GetNegativeTrackP(),negPIDmupi);
1325 fHistograms->FillHistogram("ESD_ConvGamma_P_mupiProbP",fV0Reader->GetPositiveTrackP(),posPIDmupi);
1327 Double_t armenterosQtAlfa[2];
1328 fV0Reader->GetArmenterosQtAlfa(fV0Reader-> GetNegativeKFParticle(),
1329 fV0Reader-> GetPositiveKFParticle(),
1330 fV0Reader->GetMotherCandidateKFCombination(),
1333 fHistograms->FillHistogram("ESD_ConvGamma_alfa_qt",armenterosQtAlfa[1],armenterosQtAlfa[0]);
1337 Int_t rBin = fHistograms->GetRBin(fV0Reader->GetXYRadius());
1338 Int_t zBin = fHistograms->GetZBin(fV0Reader->GetZ());
1339 Int_t phiBin = fHistograms->GetPhiBin(fV0Reader->GetNegativeTrackPhi());
1344 // Double_t motherCandidateEta= fV0Reader->GetMotherCandidateEta();
1346 TString nameESDMappingPhiR="";
1347 nameESDMappingPhiR.Form("ESD_Conversion_Mapping_Phi%02d_R%02d",phiBin,rBin);
1348 //fHistograms->FillHistogram(nameESDMappingPhiR, fV0Reader->GetZ(), motherCandidateEta);
1350 TString nameESDMappingPhi="";
1351 nameESDMappingPhi.Form("ESD_Conversion_Mapping_Phi%02d",phiBin);
1352 //fHistograms->FillHistogram(nameESDMappingPhi, fV0Reader->GetZ(), motherCandidateEta);
1354 TString nameESDMappingR="";
1355 nameESDMappingR.Form("ESD_Conversion_Mapping_R%02d",rBin);
1356 //fHistograms->FillHistogram(nameESDMappingR, fV0Reader->GetZ(), motherCandidateEta);
1358 TString nameESDMappingPhiInR="";
1359 nameESDMappingPhiInR.Form("ESD_Conversion_Mapping_Phi_in_R_%02d",rBin);
1360 // fHistograms->FillHistogram(nameESDMappingPhiInR, fV0Reader->GetMotherCandidatePhi());
1361 fHistograms->FillHistogram(nameESDMappingPhiInR, vtxConv.Phi());
1363 TString nameESDMappingZInR="";
1364 nameESDMappingZInR.Form("ESD_Conversion_Mapping_Z_in_R_%02d",rBin);
1365 fHistograms->FillHistogram(nameESDMappingZInR, fV0Reader->GetZ());
1367 TString nameESDMappingPhiInZ="";
1368 nameESDMappingPhiInZ.Form("ESD_Conversion_Mapping_Phi_in_Z_%02d",zBin);
1369 // fHistograms->FillHistogram(nameESDMappingPhiInR, fV0Reader->GetMotherCandidatePhi());
1370 fHistograms->FillHistogram(nameESDMappingPhiInZ, vtxConv.Phi());
1372 if(fV0Reader->GetXYRadius()<rFMD){
1373 TString nameESDMappingFMDPhiInZ="";
1374 nameESDMappingFMDPhiInZ.Form("ESD_Conversion_Mapping_FMD_Phi_in_Z_%02d",zBin);
1375 fHistograms->FillHistogram(nameESDMappingFMDPhiInZ, vtxConv.Phi());
1379 TString nameESDMappingRInZ="";
1380 nameESDMappingRInZ.Form("ESD_Conversion_Mapping_R_in_Z_%02d",zBin);
1381 fHistograms->FillHistogram(nameESDMappingRInZ, fV0Reader->GetXYRadius());
1383 if(fV0Reader->GetMotherCandidatePt() > fLowPtMapping && fV0Reader->GetMotherCandidatePt()< fHighPtMapping){
1384 TString nameESDMappingMidPtPhiInR="";
1385 nameESDMappingMidPtPhiInR.Form("ESD_Conversion_Mapping_MidPt_Phi_in_R_%02d",rBin);
1386 fHistograms->FillHistogram(nameESDMappingMidPtPhiInR, vtxConv.Phi());
1388 TString nameESDMappingMidPtZInR="";
1389 nameESDMappingMidPtZInR.Form("ESD_Conversion_Mapping_MidPt_Z_in_R_%02d",rBin);
1390 fHistograms->FillHistogram(nameESDMappingMidPtZInR, fV0Reader->GetZ());
1392 TString nameESDMappingMidPtPhiInZ="";
1393 nameESDMappingMidPtPhiInZ.Form("ESD_Conversion_Mapping_MidPt_Phi_in_Z_%02d",zBin);
1394 fHistograms->FillHistogram(nameESDMappingMidPtPhiInZ, vtxConv.Phi());
1395 if(fV0Reader->GetXYRadius()<rFMD){
1396 TString nameESDMappingMidPtFMDPhiInZ="";
1397 nameESDMappingMidPtFMDPhiInZ.Form("ESD_Conversion_Mapping_MidPt_FMD_Phi_in_Z_%02d",zBin);
1398 fHistograms->FillHistogram(nameESDMappingMidPtFMDPhiInZ, vtxConv.Phi());
1402 TString nameESDMappingMidPtRInZ="";
1403 nameESDMappingMidPtRInZ.Form("ESD_Conversion_Mapping_MidPt_R_in_Z_%02d",zBin);
1404 fHistograms->FillHistogram(nameESDMappingMidPtRInZ, fV0Reader->GetXYRadius());
1411 new((*fKFReconstructedGammasTClone)[fKFReconstructedGammasTClone->GetEntriesFast()]) AliKFParticle(*fV0Reader->GetMotherCandidateKFCombination());
1412 fKFReconstructedGammasV0Index.push_back(fV0Reader->GetCurrentV0IndexNumber()-1);
1413 // fKFReconstructedGammas.push_back(*fV0Reader->GetMotherCandidateKFCombination());
1414 fElectronv1.push_back(fV0Reader->GetCurrentV0()->GetPindex());
1415 fElectronv2.push_back(fV0Reader->GetCurrentV0()->GetNindex());
1417 //----------------------------------- checking for "real" conversions (MC match) --------------------------------------
1420 if(fV0Reader->HasSameMCMother() == kFALSE){
1423 TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
1424 TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
1426 if(TMath::Abs(negativeMC->GetPdgCode())!=11 || TMath::Abs(positiveMC->GetPdgCode())!=11){
1430 if(negativeMC->GetPdgCode()==positiveMC->GetPdgCode()){
1433 if(negativeMC->GetUniqueID() == 4 && positiveMC->GetUniqueID() ==4){// fill r distribution for Dalitz decays
1434 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 111){ //pi0
1435 fHistograms->FillHistogram("ESD_TrueDalitzContamination_R", fV0Reader->GetXYRadius());
1439 if(negativeMC->GetUniqueID() != 5 || positiveMC->GetUniqueID() !=5){// check if the daughters come from a conversion
1443 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
1446 Double_t containerInput[3];
1447 containerInput[0] = fV0Reader->GetMotherCandidatePt();
1448 containerInput[1] = fV0Reader->GetMotherCandidateEta();
1449 containerInput[2] = fV0Reader->GetMotherCandidateMass();
1450 fCFManager->GetParticleContainer()->Fill(containerInput,kStepTrueGamma); // for CF
1453 fHistograms->FillHistogram("ESD_TrueConvGamma_Pt", fV0Reader->GetMotherCandidatePt());
1454 fHistograms->FillHistogram("ESD_TrueConvGamma_Energy", fV0Reader->GetMotherCandidateEnergy());
1455 fHistograms->FillHistogram("ESD_TrueConvGamma_Eta", fV0Reader->GetMotherCandidateEta());
1456 fHistograms->FillHistogram("ESD_TrueConvGamma_Phi", fV0Reader->GetMotherCandidatePhi());
1457 fHistograms->FillHistogram("ESD_TrueConvGamma_Mass", fV0Reader->GetMotherCandidateMass());
1458 fHistograms->FillHistogram("ESD_TrueConvGamma_Width", fV0Reader->GetMotherCandidateWidth());
1459 fHistograms->FillHistogram("ESD_TrueConvGamma_Chi2", fV0Reader->GetMotherCandidateChi2());
1460 fHistograms->FillHistogram("ESD_TrueConvGamma_NDF", fV0Reader->GetMotherCandidateNDF());
1461 fHistograms->FillHistogram("ESD_TrueConvGamma_Pt_Eta", fV0Reader->GetMotherCandidatePt(),fV0Reader->GetMotherCandidateEta());
1462 fHistograms->FillHistogram("ESD_TrueConvGamma_Rapid", fV0Reader->GetMotherCandidateRapidity());
1463 fHistograms->FillHistogram("ESD_TrueConvGamma_TrackLength", /*fV0Reader->GetNegativeTrackLength()*/fV0Reader->GetNegativeNTPCClusters());
1464 fHistograms->FillHistogram("ESD_TrueConvGamma_TrackLength", /*fV0Reader->GetPositiveTrackLength()*/fV0Reader->GetPositiveNTPCClusters());
1465 fHistograms->FillHistogram("ESD_TrueConvGamma_TrackLengthVSInvMass",/*fV0Reader->GetNegativeTrackLength()*/fV0Reader->GetNegativeNTPCClusters(),fV0Reader->GetMotherCandidateMass());
1466 fHistograms->FillHistogram("ESD_TrueConvGamma_TrackLengthVSInvMass",/*fV0Reader->GetPositiveTrackLength()*/fV0Reader->GetPositiveNTPCClusters(),fV0Reader->GetMotherCandidateMass());
1468 fHistograms->FillHistogram("ESD_TrueConvGamma_Pt_Chi2", fV0Reader->GetMotherCandidatePt(), fV0Reader->GetMotherCandidateChi2());
1469 fHistograms->FillHistogram("ESD_TrueConvGamma_Eta_Chi2", fV0Reader->GetMotherCandidateEta(), fV0Reader->GetMotherCandidateChi2());
1472 fHistograms->FillHistogram("ESD_TrueConversion_XY", fV0Reader->GetX(),fV0Reader->GetY());
1473 fHistograms->FillHistogram("ESD_TrueConversion_R", fV0Reader->GetXYRadius());
1474 fHistograms->FillHistogram("ESD_TrueConversion_ZR", fV0Reader->GetZ(),fV0Reader->GetXYRadius());
1475 fHistograms->FillHistogram("ESD_TrueConversion_OpeningAngle", fV0Reader->GetOpeningAngle());
1477 fHistograms->FillHistogram("ESD_TrueConvGamma_CosPointingAngle", fV0Reader->GetCosPointingAngle());
1478 fHistograms->FillHistogram("ESD_TrueConvGamma_DcaDaughters", fV0Reader->GetDcaDaughters());
1479 fHistograms->FillHistogram("ESD_TrueConvGamma_NormDcaDistDaughters", fV0Reader->GetNormDcaDistDaughters());
1480 fHistograms->FillHistogram("ESD_TrueConvGamma_LikelihoodAP", fV0Reader->GetLikelihoodAP());
1481 if (fV0Reader->GetMotherCandidateP() != 0) {
1482 fHistograms->FillHistogram("ESD_TrueConvGamma_E_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetNegativeTrackP()/fV0Reader->GetMotherCandidateP());
1483 fHistograms->FillHistogram("ESD_TrueConvGamma_P_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetPositiveTrackP()/fV0Reader->GetMotherCandidateP());
1484 } else { cout << "Error::fV0Reader->GetNegativeTrackP() == 0 !!!" << endl; }
1486 fHistograms->FillHistogram("ESD_TrueConvGamma_E_dEdxP",fV0Reader->GetNegativeTrackP(),fV0Reader->GetNegativeTrackTPCdEdx());
1487 fHistograms->FillHistogram("ESD_TrueConvGamma_P_dEdxP",fV0Reader->GetPositiveTrackP(),fV0Reader->GetPositiveTrackTPCdEdx());
1488 fHistograms->FillHistogram("ESD_TrueConvGamma_alfa_qt",armenterosQtAlfa[1],armenterosQtAlfa[0]);
1492 //store MCTruth properties
1493 fHistograms->FillHistogram("ESD_TrueConvGamma_MC_Pt_Eta", fV0Reader->GetMotherMCParticle()->Pt(),fV0Reader->GetMotherMCParticle()->Eta());
1494 fHistograms->FillHistogram("ESD_TrueConversion_MC_ZR", negativeMC->Vz(),negativeMC->R());
1495 fHistograms->FillHistogram("ESD_TrueConversion_MC_XY", negativeMC->Vx(),negativeMC->Vy());
1498 Double_t mcpt = fV0Reader->GetMotherMCParticle()->Pt();
1499 Double_t esdpt = fV0Reader->GetMotherCandidatePt();
1500 Double_t resdPt = 0.;
1502 resdPt = ((esdpt - mcpt)/mcpt)*100.;
1505 cout<<"Pt of MC particle is negative, this will cause wrong calculation of resPt"<<endl;
1508 fHistograms->FillHistogram("Resolution_Gamma_dPt_Pt", mcpt, resdPt);
1509 fHistograms->FillHistogram("Resolution_MC_Pt", mcpt);
1510 fHistograms->FillHistogram("Resolution_ESD_Pt", esdpt);
1511 fHistograms->FillHistogram("Resolution_Gamma_dPt_Phi", fV0Reader->GetMotherCandidatePhi(), resdPt);
1513 Double_t resdZ = 0.;
1514 if(fV0Reader->GetNegativeMCParticle()->Vz() != 0){
1515 resdZ = ((fV0Reader->GetZ() -fV0Reader->GetNegativeMCParticle()->Vz())/fV0Reader->GetNegativeMCParticle()->Vz())*100.;
1517 Double_t resdZAbs = 0.;
1518 resdZAbs = (fV0Reader->GetZ() -fV0Reader->GetNegativeMCParticle()->Vz());
1520 fHistograms->FillHistogram("Resolution_dZAbs_VS_R", fV0Reader->GetNegativeMCParticle()->R(), resdZAbs);
1521 fHistograms->FillHistogram("Resolution_dZ", fV0Reader->GetNegativeMCParticle()->Vz(), resdZ);
1522 fHistograms->FillHistogram("Resolution_MC_Z", fV0Reader->GetNegativeMCParticle()->Vz());
1523 fHistograms->FillHistogram("Resolution_ESD_Z", fV0Reader->GetZ());
1525 // new for dPt_Pt-histograms for Electron and Positron
1526 Double_t mcEpt = fV0Reader->GetNegativeMCParticle()->Pt();
1527 Double_t resEdPt = 0.;
1529 resEdPt = ((fV0Reader->GetNegativeTrackPt()-mcEpt)/mcEpt)*100.;
1531 UInt_t statusN = fV0Reader->GetNegativeESDTrack()->GetStatus();
1532 // AliESDtrack * negTrk = fV0Reader->GetNegativeESDTrack();
1533 UInt_t kTRDoutN = (statusN & AliESDtrack::kTRDout);
1535 Int_t ITSclsE= fV0Reader->GetNegativeTracknITSClusters();
1536 // filling Resolution_Pt_dPt with respect to the Number of ITS clusters for Positrons
1538 case 0: // 0 ITS clusters
1539 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS0", mcEpt, resEdPt);
1541 case 1: // 1 ITS cluster
1542 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS1", mcEpt, resEdPt);
1544 case 2: // 2 ITS clusters
1545 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS2", mcEpt, resEdPt);
1547 case 3: // 3 ITS clusters
1548 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS3", mcEpt, resEdPt);
1550 case 4: // 4 ITS clusters
1551 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS4", mcEpt, resEdPt);
1553 case 5: // 5 ITS clusters
1554 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS5", mcEpt, resEdPt);
1556 case 6: // 6 ITS clusters
1557 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS6", mcEpt, resEdPt);
1560 //Filling histograms with respect to Electron resolution
1561 fHistograms->FillHistogram("Resolution_E_dPt_Pt", mcEpt, resEdPt);
1562 fHistograms->FillHistogram("Resolution_E_dPt_Phi", fV0Reader->GetNegativeTrackPhi(), resEdPt);
1564 fHistograms->FillHistogram("Resolution_E_nTRDtracklets_ESDPt", fV0Reader->GetNegativeTrackPt(), fV0Reader->GetNegativeESDTrack()->GetTRDntracklets());
1565 fHistograms->FillHistogram("Resolution_E_nTRDtracklets_MCPt", mcEpt, fV0Reader->GetNegativeESDTrack()->GetTRDntracklets());
1566 fHistograms->FillHistogram("Resolution_E_nTRDclusters_ESDPt",fV0Reader->GetNegativeTrackPt(), fV0Reader->GetNegativeESDTrack()->GetTRDncls());
1567 fHistograms->FillHistogram("Resolution_E_nTRDclusters_MCPt",mcEpt, fV0Reader->GetNegativeESDTrack()->GetTRDncls());
1568 fHistograms->FillHistogram("Resolution_E_TRDsignal_ESDPt", fV0Reader->GetNegativeTrackPt(), fV0Reader->GetNegativeESDTrack()->GetTRDsignal());
1571 Double_t mcPpt = fV0Reader->GetPositiveMCParticle()->Pt();
1572 Double_t resPdPt = 0;
1574 resPdPt = ((fV0Reader->GetPositiveTrackPt()-mcPpt)/mcPpt)*100.;
1577 UInt_t statusP = fV0Reader->GetPositiveESDTrack()->GetStatus();
1578 // AliESDtrack * posTr= fV0Reader->GetPositiveESDTrack();
1579 UInt_t kTRDoutP = (statusP & AliESDtrack::kTRDout);
1581 Int_t ITSclsP = fV0Reader->GetPositiveTracknITSClusters();
1582 // filling Resolution_Pt_dPt with respect to the Number of ITS clusters for Positrons
1584 case 0: // 0 ITS clusters
1585 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS0", mcPpt, resPdPt);
1587 case 1: // 1 ITS cluster
1588 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS1", mcPpt, resPdPt);
1590 case 2: // 2 ITS clusters
1591 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS2", mcPpt, resPdPt);
1593 case 3: // 3 ITS clusters
1594 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS3", mcPpt, resPdPt);
1596 case 4: // 4 ITS clusters
1597 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS4", mcPpt, resPdPt);
1599 case 5: // 5 ITS clusters
1600 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS5", mcPpt, resPdPt);
1602 case 6: // 6 ITS clusters
1603 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS6", mcPpt, resPdPt);
1606 //Filling histograms with respect to Positron resolution
1607 fHistograms->FillHistogram("Resolution_P_dPt_Pt", mcPpt, resPdPt);
1608 fHistograms->FillHistogram("Resolution_P_dPt_Phi", fV0Reader->GetPositiveTrackPhi(), resPdPt);
1610 fHistograms->FillHistogram("Resolution_P_nTRDtracklets_ESDPt", fV0Reader->GetPositiveTrackPt(), fV0Reader->GetPositiveESDTrack()->GetTRDntracklets());
1611 fHistograms->FillHistogram("Resolution_P_nTRDtracklets_MCPt", mcPpt, fV0Reader->GetPositiveESDTrack()->GetTRDntracklets());
1612 fHistograms->FillHistogram("Resolution_P_nTRDclusters_ESDPt",fV0Reader->GetPositiveTrackPt(), fV0Reader->GetPositiveESDTrack()->GetTRDncls());
1613 fHistograms->FillHistogram("Resolution_P_nTRDclusters_MCPt",mcPpt, fV0Reader->GetPositiveESDTrack()->GetTRDncls());
1614 fHistograms->FillHistogram("Resolution_P_TRDsignal_ESDPt", fV0Reader->GetPositiveTrackPt(), fV0Reader->GetPositiveESDTrack()->GetTRDsignal());
1618 Double_t resdR = 0.;
1619 if(fV0Reader->GetNegativeMCParticle()->R() != 0){
1620 resdR = ((fV0Reader->GetXYRadius() - fV0Reader->GetNegativeMCParticle()->R())/fV0Reader->GetNegativeMCParticle()->R())*100.;
1622 Double_t resdRAbs = 0.;
1623 resdRAbs = (fV0Reader->GetXYRadius() - fV0Reader->GetNegativeMCParticle()->R());
1625 fHistograms->FillHistogram("Resolution_dRAbs_VS_R", fV0Reader->GetNegativeMCParticle()->R(), resdRAbs);
1626 fHistograms->FillHistogram("Resolution_dR", fV0Reader->GetNegativeMCParticle()->R(), resdR);
1627 fHistograms->FillHistogram("Resolution_MC_R", fV0Reader->GetNegativeMCParticle()->R());
1628 fHistograms->FillHistogram("Resolution_ESD_R", fV0Reader->GetXYRadius());
1629 fHistograms->FillHistogram("Resolution_R_dPt", fV0Reader->GetNegativeMCParticle()->R(), resdPt);
1631 Double_t resdPhiAbs=0.;
1633 resdPhiAbs= (fV0Reader->GetMotherCandidatePhi()-fV0Reader->GetNegativeMCParticle()->Phi());
1634 fHistograms->FillHistogram("Resolution_dPhiAbs_VS_R", fV0Reader->GetNegativeMCParticle()->R(), resdPhiAbs);
1636 }//if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22)
1638 }//while(fV0Reader->NextV0)
1639 fHistograms->FillHistogram("ESD_NumberOfSurvivingV0s", nSurvivingV0s);
1640 fHistograms->FillHistogram("ESD_NumberOfV0s", fV0Reader->GetNumberOfV0s());
1641 fHistograms->FillHistogram("ESD_NumberOfContributorsVtx", fV0Reader->GetNumberOfContributorsVtx());
1643 fV0Reader->ResetV0IndexNumber();
1646 void AliAnalysisTaskGammaConversion::FillAODWithConversionGammas(){
1647 // Fill AOD with reconstructed Gamma
1649 for(Int_t gammaIndex=0;gammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();gammaIndex++){
1650 // for(UInt_t gammaIndex=0;gammaIndex<fKFReconstructedGammas.size();gammaIndex++){
1651 //Create AOD particle object from AliKFParticle
1652 //You could add directly AliKFParticle objects to the AOD, avoiding dependences with PartCorr
1653 //but this means that I have to work a little bit more in my side.
1654 //AODPWG4Particle objects are simpler and lighter, I think
1656 AliKFParticle * gammakf = dynamic_cast<AliKFParticle*>(fKFReconstructedGammasTClone->At(gammaIndex));
1657 AliAODPWG4Particle gamma = AliAODPWG4Particle(gammakf->Px(),gammakf->Py(),gammakf->Pz(), gammakf->E());
1658 //gamma.SetLabel(-1);//How to get the MC label of the reconstructed gamma?
1659 gamma.SetTrackLabel( fElectronv1[gammaIndex], fElectronv2[gammaIndex] ); //How to get the MC label of the 2 electrons that form the gamma?
1660 gamma.SetDetector("CTS"); //tag the gamma as reconstructed in the central barrel
1661 gamma.SetPdg(AliPID::kEleCon); //photon id
1662 gamma.SetTag(-1); //Here I usually put a flag saying that montecarlo says it is prompt, decay fragmentation photon, or hadrons or whatever
1663 gamma.SetChi2(gammakf->Chi2());
1664 Int_t i = fAODBranch->GetEntriesFast();
1665 new((*fAODBranch)[i]) AliAODPWG4Particle(gamma);
1668 AliKFParticle * gammakf = (AliKFParticle *)fKFReconstructedGammasTClone->At(gammaIndex);
1669 AliGammaConversionAODObject aodObject;
1670 aodObject.SetPx(gammakf->GetPx());
1671 aodObject.SetPy(gammakf->GetPy());
1672 aodObject.SetPz(gammakf->GetPz());
1673 aodObject.SetLabel1(fElectronv1[gammaIndex]);
1674 aodObject.SetLabel2(fElectronv2[gammaIndex]);
1675 aodObject.SetChi2(gammakf->Chi2());
1676 aodObject.SetE(gammakf->E());
1677 Int_t i = fAODGamma->GetEntriesFast();
1678 new((*fAODGamma)[i]) AliGammaConversionAODObject(aodObject);
1683 void AliAnalysisTaskGammaConversion::ProcessGammasForOmegaMesonAnalysis(){
1684 // omega meson analysis pi0+gamma decay
1685 for(Int_t firstPi0Index=0;firstPi0Index<fKFReconstructedPi0sTClone->GetEntriesFast();firstPi0Index++){
1686 AliKFParticle * omegaCandidatePi0Daughter = (AliKFParticle *)fKFReconstructedPi0sTClone->At(firstPi0Index);
1687 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();firstGammaIndex++){
1689 AliKFParticle * omegaCandidateGammaDaughter = (AliKFParticle *)fKFReconstructedGammasTClone->At(firstGammaIndex);
1690 if(fGammav1[firstPi0Index]==firstGammaIndex || fGammav2[firstPi0Index]==firstGammaIndex){
1694 AliKFParticle omegaCandidate(*omegaCandidatePi0Daughter,*omegaCandidateGammaDaughter);
1695 Double_t massOmegaCandidate = 0.;
1696 Double_t widthOmegaCandidate = 0.;
1698 omegaCandidate.GetMass(massOmegaCandidate,widthOmegaCandidate);
1700 if ( massOmegaCandidate > 733 && massOmegaCandidate < 833 ) {
1701 AddOmegaToAOD(&omegaCandidate, massOmegaCandidate, firstPi0Index, firstGammaIndex);
1704 fHistograms->FillHistogram("ESD_Omega_InvMass_vs_Pt",massOmegaCandidate ,omegaCandidate.GetPt());
1705 fHistograms->FillHistogram("ESD_Omega_InvMass",massOmegaCandidate);
1707 //delete omegaCandidate;
1709 }// end of omega reconstruction in pi0+gamma channel
1711 if(fDoJet == kTRUE){
1712 AliKFParticle* negPiKF=NULL;
1713 AliKFParticle* posPiKF=NULL;
1715 // look at the pi+pi+pi0 channel
1716 for(Int_t iCh=0;iCh<fChargedParticles->GetEntriesFast();iCh++){
1717 AliESDtrack* posTrack = (AliESDtrack*)(fChargedParticles->At(iCh));
1718 if (posTrack->GetSign()<0) continue;
1719 if(TMath::Abs(fV0Reader->GetESDpid()->NumberOfSigmasTPC(posTrack,AliPID::kPion))>2.) continue;
1720 if (posPiKF) delete posPiKF; posPiKF=NULL;
1721 posPiKF = new AliKFParticle( *(posTrack) ,211);
1723 for(Int_t jCh=0;jCh<fChargedParticles->GetEntriesFast();jCh++){
1724 AliESDtrack* negTrack = (AliESDtrack*)(fChargedParticles->At(jCh));
1725 if( negTrack->GetSign()>0) continue;
1726 if(TMath::Abs(fV0Reader->GetESDpid()->NumberOfSigmasTPC(negTrack,AliPID::kPion))>2.) continue;
1727 if (negPiKF) delete negPiKF; negPiKF=NULL;
1728 negPiKF = new AliKFParticle( *(negTrack) ,-211);
1729 AliKFParticle omegaCandidatePipPinPi0(*omegaCandidatePi0Daughter,*posPiKF,*negPiKF);
1730 Double_t massOmegaCandidatePipPinPi0 = 0.;
1731 Double_t widthOmegaCandidatePipPinPi0 = 0.;
1733 omegaCandidatePipPinPi0.GetMass(massOmegaCandidatePipPinPi0,widthOmegaCandidatePipPinPi0);
1735 fHistograms->FillHistogram("ESD_OmegaPipPinPi0_InvMass_vs_Pt",massOmegaCandidatePipPinPi0 ,omegaCandidatePipPinPi0.GetPt());
1736 fHistograms->FillHistogram("ESD_OmegaPipPinPi0_InvMass",massOmegaCandidatePipPinPi0);
1738 // delete omegaCandidatePipPinPi0;
1741 } // checking ig gammajet because in that case the chargedparticle list is created
1747 if(fCalculateBackground){
1748 // Background calculation for the omega
1749 for(Int_t nEventsInBG=0;nEventsInBG <fV0Reader->GetNBGEvents();nEventsInBG++){
1750 AliGammaConversionKFVector * previousEventV0s = fV0Reader->GetBGGoodV0s(nEventsInBG);
1751 for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
1752 AliKFParticle previousGoodV0 = (AliKFParticle)(*(previousEventV0s->at(iPrevious)));
1753 for(Int_t firstPi0Index=0;firstPi0Index<fKFReconstructedPi0sTClone->GetEntriesFast();firstPi0Index++){
1754 AliKFParticle * omegaCandidatePi0Daughter = (AliKFParticle *)fKFReconstructedPi0sTClone->At(firstPi0Index);
1755 AliKFParticle * omegaBckCandidate = new AliKFParticle(*omegaCandidatePi0Daughter,previousGoodV0);
1756 Double_t massOmegaBckCandidate = 0.;
1757 Double_t widthOmegaBckCandidate = 0.;
1759 omegaBckCandidate->GetMass(massOmegaBckCandidate,widthOmegaBckCandidate);
1760 fHistograms->FillHistogram("ESD_Omega_Bck_InvMass_vs_Pt",massOmegaBckCandidate ,omegaBckCandidate->GetPt());
1761 fHistograms->FillHistogram("ESD_Omega_Bck_InvMass",massOmegaBckCandidate);
1763 delete omegaBckCandidate;
1767 } // end of checking if background calculation is available
1771 void AliAnalysisTaskGammaConversion::AddOmegaToAOD(AliKFParticle * omegakf, Double_t mass, Int_t omegaDaughter, Int_t gammaDaughter) {
1772 //See header file for documentation
1773 AliGammaConversionAODObject omega;
1774 omega.SetPx(omegakf->Px());
1775 omega.SetPy(omegakf->Py());
1776 omega.SetPz(omegakf->Pz());
1777 omega.SetChi2(omegakf->GetChi2());
1778 omega.SetE(omegakf->E());
1779 omega.SetIMass(mass);
1780 omega.SetLabel1(omegaDaughter);
1781 //dynamic_cast<AliGammaConversionAODObject*>(fAODBranch->At(daughter1))->SetTagged(kTRUE);
1782 omega.SetLabel2(gammaDaughter);
1783 new((*fAODOmega)[fAODOmega->GetEntriesFast()]) AliGammaConversionAODObject(omega);
1788 void AliAnalysisTaskGammaConversion::ProcessGammasForNeutralMesonAnalysis(){
1789 // see header file for documentation
1791 // for(UInt_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammas.size();firstGammaIndex++){
1792 // for(UInt_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fKFReconstructedGammas.size();secondGammaIndex++){
1794 if(fKFReconstructedGammasTClone->GetEntriesFast()>fV0Reader->GetNumberOfV0s()){
1795 cout<<"Warning, number of entries in the tclone is bigger than number of v0s"<<endl;
1798 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();firstGammaIndex++){
1799 for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();secondGammaIndex++){
1801 // AliKFParticle * twoGammaDecayCandidateDaughter0 = &fKFReconstructedGammas[firstGammaIndex];
1802 // AliKFParticle * twoGammaDecayCandidateDaughter1 = &fKFReconstructedGammas[secondGammaIndex];
1804 AliKFParticle * twoGammaDecayCandidateDaughter0 = (AliKFParticle *)fKFReconstructedGammasTClone->At(firstGammaIndex);
1805 AliKFParticle * twoGammaDecayCandidateDaughter1 = (AliKFParticle *)fKFReconstructedGammasTClone->At(secondGammaIndex);
1807 if(fElectronv1[firstGammaIndex]==fElectronv1[secondGammaIndex] || fElectronv1[firstGammaIndex]==fElectronv2[secondGammaIndex]){
1810 if(fElectronv2[firstGammaIndex]==fElectronv1[secondGammaIndex] || fElectronv2[firstGammaIndex]==fElectronv2[secondGammaIndex]){
1814 AliKFParticle *twoGammaCandidate = new AliKFParticle(*twoGammaDecayCandidateDaughter0,*twoGammaDecayCandidateDaughter1);
1816 Double_t massTwoGammaCandidate = 0.;
1817 Double_t widthTwoGammaCandidate = 0.;
1818 Double_t chi2TwoGammaCandidate =10000.;
1819 twoGammaCandidate->GetMass(massTwoGammaCandidate,widthTwoGammaCandidate);
1820 // if(twoGammaCandidate->GetNDF()>0){
1821 // chi2TwoGammaCandidate = twoGammaCandidate->GetChi2()/twoGammaCandidate->GetNDF();
1822 chi2TwoGammaCandidate = twoGammaCandidate->GetChi2();
1824 fHistograms->FillHistogram("ESD_Mother_Chi2",chi2TwoGammaCandidate);
1825 //if(chi2TwoGammaCandidate>0 && chi2TwoGammaCandidate<fV0Reader->GetChi2CutMeson()){
1827 TVector3 momentumVectorTwoGammaCandidate(twoGammaCandidate->GetPx(),twoGammaCandidate->GetPy(),twoGammaCandidate->GetPz());
1828 TVector3 spaceVectorTwoGammaCandidate(twoGammaCandidate->GetX(),twoGammaCandidate->GetY(),twoGammaCandidate->GetZ());
1830 Double_t openingAngleTwoGammaCandidate = twoGammaDecayCandidateDaughter0->GetAngle(*twoGammaDecayCandidateDaughter1);
1832 if(twoGammaCandidate->GetE() - twoGammaCandidate->GetPz() <= 0 || twoGammaCandidate->GetE() + twoGammaCandidate->GetPz() <= 0){
1833 cout << "Error: |Pz| > E !!!! " << endl;
1837 rapidity = 0.5*(TMath::Log((twoGammaCandidate->GetE() +twoGammaCandidate->GetPz()) / (twoGammaCandidate->GetE()-twoGammaCandidate->GetPz())));
1840 if( (twoGammaDecayCandidateDaughter0->GetE()+twoGammaDecayCandidateDaughter1->GetE()) != 0){
1841 alfa=TMath::Abs((twoGammaDecayCandidateDaughter0->GetE()-twoGammaDecayCandidateDaughter1->GetE())
1842 /(twoGammaDecayCandidateDaughter0->GetE()+twoGammaDecayCandidateDaughter1->GetE()));
1845 if(openingAngleTwoGammaCandidate < fMinOpeningAngleGhostCut){
1846 delete twoGammaCandidate;
1847 continue; // minimum opening angle to avoid using ghosttracks
1850 fHistograms->FillHistogram("ESD_Mother_GammaDaughter_OpeningAngle", openingAngleTwoGammaCandidate);
1851 fHistograms->FillHistogram("ESD_Mother_Energy", twoGammaCandidate->GetE());
1852 fHistograms->FillHistogram("ESD_Mother_Pt", momentumVectorTwoGammaCandidate.Pt());
1853 fHistograms->FillHistogram("ESD_Mother_Eta", momentumVectorTwoGammaCandidate.Eta());
1854 fHistograms->FillHistogram("ESD_Mother_Rapid", rapidity);
1855 fHistograms->FillHistogram("ESD_Mother_Phi", spaceVectorTwoGammaCandidate.Phi());
1856 fHistograms->FillHistogram("ESD_Mother_Mass", massTwoGammaCandidate);
1857 fHistograms->FillHistogram("ESD_Mother_alfa", alfa);
1858 fHistograms->FillHistogram("ESD_Mother_R", spaceVectorTwoGammaCandidate.Pt()); // Pt in Space == R!!!
1859 fHistograms->FillHistogram("ESD_Mother_ZR", twoGammaCandidate->GetZ(), spaceVectorTwoGammaCandidate.Pt());
1860 fHistograms->FillHistogram("ESD_Mother_XY", twoGammaCandidate->GetX(), twoGammaCandidate->GetY());
1861 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
1862 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
1863 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt_alpha",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
1865 fHistograms->FillHistogram("ESD_Mother_InvMass",massTwoGammaCandidate);
1867 /* Kenneth, just for testing*/
1868 AliGammaConversionBGHandler * bgHandlerTest = fV0Reader->GetBGHandler();
1870 Int_t zbin= bgHandlerTest->GetZBinIndex(fV0Reader->GetVertexZ());
1871 Int_t mbintest= bgHandlerTest->GetMultiplicityBinIndex(fV0Reader->CountESDTracks());
1873 fHistograms->FillHistogram(Form("%d%dESD_Mother_InvMass",zbin,mbintest),massTwoGammaCandidate);
1875 /* end Kenneth, just for testing*/
1877 if(fCalculateBackground){
1878 AliGammaConversionBGHandler * bgHandler = fV0Reader->GetBGHandler();
1879 Int_t mbin= bgHandler->GetMultiplicityBinIndex(fV0Reader->CountESDTracks());
1880 fHistograms->FillHistogram(Form("%dESD_Mother_InvMass_vs_Pt",mbin),massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
1882 // if(fDoNeutralMesonV0MCCheck){
1884 //Kenneth: Checking the eta of the gamma to check the difference between 0.9 and 1.2
1885 Int_t indexKF1 = fKFReconstructedGammasV0Index.at(firstGammaIndex);
1886 if(indexKF1<fV0Reader->GetNumberOfV0s()){
1887 fV0Reader->GetV0(indexKF1);//updates to the correct v0
1888 Double_t eta1 = fV0Reader->GetMotherCandidateEta();
1889 Bool_t isRealPi0=kFALSE;
1890 Bool_t isRealEta=kFALSE;
1891 Int_t gamma1MotherLabel=-1;
1892 if(fV0Reader->HasSameMCMother() == kTRUE){
1893 //cout<<"This v0 is a real v0!!!!"<<endl;
1894 TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
1895 TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
1896 if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){
1897 if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){
1898 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
1899 gamma1MotherLabel=fV0Reader->GetMotherMCParticle()->GetFirstMother();
1904 Int_t indexKF2 = fKFReconstructedGammasV0Index.at(secondGammaIndex);
1905 if(indexKF1 == indexKF2){
1906 cout<<"index of the two KF particles are the same.... should not happen"<<endl;
1908 if(indexKF2<fV0Reader->GetNumberOfV0s()){
1909 fV0Reader->GetV0(indexKF2);
1910 Double_t eta2 = fV0Reader->GetMotherCandidateEta();
1911 Int_t gamma2MotherLabel=-1;
1912 if(fV0Reader->HasSameMCMother() == kTRUE){
1913 TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
1914 TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
1915 if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){
1916 if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){
1917 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
1918 gamma2MotherLabel=fV0Reader->GetMotherMCParticle()->GetFirstMother();
1923 if(gamma1MotherLabel>=0 && gamma1MotherLabel==gamma2MotherLabel){
1924 if(fV0Reader->CheckIfPi0IsMother(gamma1MotherLabel)){
1927 if(fV0Reader->CheckIfEtaIsMother(gamma1MotherLabel)){
1933 if(TMath::Abs(eta1)>0.9 && TMath::Abs(eta2)>0.9){
1934 // fHistograms->FillHistogram("ESD_Mother_InvMass_1212",massTwoGammaCandidate);
1935 // fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt1212",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
1936 if(isRealPi0 || isRealEta){
1937 fHistograms->FillHistogram("ESD_TruePi0_InvMass_1212",massTwoGammaCandidate);
1938 fHistograms->FillHistogram("ESD_TruePi0_OpeningAngle_1212",openingAngleTwoGammaCandidate);
1939 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt1212",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
1940 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
1941 fHistograms->FillHistogram("ESD_TruePi0_InvMass",massTwoGammaCandidate);
1942 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
1943 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt_alpha",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
1947 else if(TMath::Abs(eta1)>0.9 || TMath::Abs(eta2)>0.9){
1948 // fHistograms->FillHistogram("ESD_Mother_InvMass_0912",massTwoGammaCandidate);
1949 // fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt0912",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
1950 if(isRealPi0 || isRealEta){
1951 fHistograms->FillHistogram("ESD_TruePi0_InvMass_0912",massTwoGammaCandidate);
1952 fHistograms->FillHistogram("ESD_TruePi0_OpeningAngle_0912",openingAngleTwoGammaCandidate);
1953 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt0912",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
1954 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
1955 fHistograms->FillHistogram("ESD_TruePi0_InvMass",massTwoGammaCandidate);
1956 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
1957 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt_alpha",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
1962 // fHistograms->FillHistogram("ESD_Mother_InvMass_0909",massTwoGammaCandidate);
1963 // fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt0909",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
1964 if(isRealPi0 || isRealEta){
1965 fHistograms->FillHistogram("ESD_TruePi0_InvMass_0909",massTwoGammaCandidate);
1966 fHistograms->FillHistogram("ESD_TruePi0_OpeningAngle_0909",openingAngleTwoGammaCandidate);
1967 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt0909",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
1968 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
1969 fHistograms->FillHistogram("ESD_TruePi0_InvMass",massTwoGammaCandidate);
1970 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
1971 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt_alpha",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
1978 if ( TMath::Abs(twoGammaDecayCandidateDaughter0->GetEta())<0.9 && TMath::Abs(twoGammaDecayCandidateDaughter1->GetEta())<0.9 ){
1979 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt_Fiducial",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
1980 fHistograms->FillHistogram("ESD_Mother_InvMass_Fiducial",massTwoGammaCandidate);
1983 if(TMath::Abs(twoGammaDecayCandidateDaughter0->GetEta())>0.9 && TMath::Abs(twoGammaDecayCandidateDaughter1->GetEta())>0.9){
1984 fHistograms->FillHistogram("ESD_Mother_InvMass_1212",massTwoGammaCandidate);
1985 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt1212",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
1987 else if(TMath::Abs(twoGammaDecayCandidateDaughter0->GetEta())>0.9 || TMath::Abs(twoGammaDecayCandidateDaughter1->GetEta())>0.9){
1988 fHistograms->FillHistogram("ESD_Mother_InvMass_0912",massTwoGammaCandidate);
1989 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt0912",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
1992 fHistograms->FillHistogram("ESD_Mother_InvMass_0909",massTwoGammaCandidate);
1993 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt0909",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
1995 Double_t lowMassPi0=0.1;
1996 Double_t highMassPi0=0.15;
1997 if (massTwoGammaCandidate > lowMassPi0 && massTwoGammaCandidate < highMassPi0 ){
1998 new((*fKFReconstructedPi0sTClone)[fKFReconstructedPi0sTClone->GetEntriesFast()]) AliKFParticle(*twoGammaCandidate);
1999 fGammav1.push_back(firstGammaIndex);
2000 fGammav2.push_back(secondGammaIndex);
2001 AddPionToAOD(twoGammaCandidate, massTwoGammaCandidate, firstGammaIndex, secondGammaIndex);
2006 delete twoGammaCandidate;
2011 void AliAnalysisTaskGammaConversion::AddPionToAOD(AliKFParticle * pionkf, Double_t mass, Int_t daughter1, Int_t daughter2) {
2012 //See header file for documentation
2013 AliGammaConversionAODObject pion;
2014 pion.SetPx(pionkf->Px());
2015 pion.SetPy(pionkf->Py());
2016 pion.SetPz(pionkf->Pz());
2017 pion.SetChi2(pionkf->GetChi2());
2018 pion.SetE(pionkf->E());
2019 pion.SetIMass(mass);
2020 pion.SetLabel1(daughter1);
2021 //dynamic_cast<AliGammaConversionAODObject*>(fAODBranch->At(daughter1))->SetTagged(kTRUE);
2022 pion.SetLabel2(daughter2);
2023 new((*fAODPi0)[fAODPi0->GetEntriesFast()]) AliGammaConversionAODObject(pion);
2029 void AliAnalysisTaskGammaConversion::ProcessConvPHOSGammasForNeutralMesonAnalysis(){
2031 // see header file for documentation
2032 // Analyse Pi0 with one photon from Phos and 1 photon from conversions
2037 vtx[0] = fV0Reader->GetPrimaryVertex()->GetX();
2038 vtx[1] = fV0Reader->GetPrimaryVertex()->GetY();
2039 vtx[2] = fV0Reader->GetPrimaryVertex()->GetZ();
2042 // Loop over all CaloClusters and consider only the PHOS ones:
2043 AliESDCaloCluster *clu;
2044 TLorentzVector pPHOS;
2045 TLorentzVector gammaPHOS;
2046 TLorentzVector gammaGammaConv;
2047 TLorentzVector pi0GammaConvPHOS;
2048 TLorentzVector gammaGammaConvBck;
2049 TLorentzVector pi0GammaConvPHOSBck;
2052 for (Int_t i=0; i<fV0Reader->GetESDEvent()->GetNumberOfCaloClusters(); i++) {
2053 clu = fV0Reader->GetESDEvent()->GetCaloCluster(i);
2054 if ( !clu->IsPHOS() || clu->E()<0.1 ) continue;
2055 clu ->GetMomentum(pPHOS ,vtx);
2056 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();firstGammaIndex++){
2057 AliKFParticle * twoGammaDecayCandidateDaughter0 = (AliKFParticle *)fKFReconstructedGammasTClone->At(firstGammaIndex);
2058 gammaGammaConv.SetXYZM(twoGammaDecayCandidateDaughter0->Px(),twoGammaDecayCandidateDaughter0->Py(),twoGammaDecayCandidateDaughter0->Pz(),0.);
2059 gammaPHOS.SetXYZM(pPHOS.Px(),pPHOS.Py(),pPHOS.Pz(),0.);
2060 pi0GammaConvPHOS=gammaGammaConv+gammaPHOS;
2061 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvPHOS",pi0GammaConvPHOS.M());
2062 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt_GammaConvPHOS",pi0GammaConvPHOS.M(),pi0GammaConvPHOS.Pt());
2064 TVector3 v3D0(twoGammaDecayCandidateDaughter0->Px(),twoGammaDecayCandidateDaughter0->Py(),twoGammaDecayCandidateDaughter0->Pz());
2065 TVector3 v3D1(gammaPHOS.Px(),gammaPHOS.Py(),gammaPHOS.Pz());
2066 Double_t opanConvPHOS= v3D0.Angle(v3D1);
2067 if ( opanConvPHOS < 0.35){
2068 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvPHOS_OpanLow",pi0GammaConvPHOS.M());
2070 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvPHOS_OpanHigh",pi0GammaConvPHOS.M());
2075 // Now the LorentVector pPHOS is obtained and can be paired with the converted proton
2077 //==== End of the PHOS cluster selection ============
2078 TLorentzVector pEMCAL;
2079 TLorentzVector gammaEMCAL;
2080 TLorentzVector pi0GammaConvEMCAL;
2081 TLorentzVector pi0GammaConvEMCALBck;
2083 for (Int_t i=0; i<fV0Reader->GetESDEvent()->GetNumberOfCaloClusters(); i++) {
2084 clu = fV0Reader->GetESDEvent()->GetCaloCluster(i);
2085 if ( !clu->IsEMCAL() || clu->E()<0.1 ) continue;
2086 if (clu->GetNCells() <= 1) continue;
2087 if ( clu->GetTOF()*1e9 < 550 || clu->GetTOF()*1e9 > 750) continue;
2089 clu ->GetMomentum(pEMCAL ,vtx);
2090 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();firstGammaIndex++){
2091 AliKFParticle * twoGammaDecayCandidateDaughter0 = (AliKFParticle *)fKFReconstructedGammasTClone->At(firstGammaIndex);
2092 gammaGammaConv.SetXYZM(twoGammaDecayCandidateDaughter0->Px(),
2093 twoGammaDecayCandidateDaughter0->Py(),
2094 twoGammaDecayCandidateDaughter0->Pz(),0.);
2095 gammaEMCAL.SetXYZM(pEMCAL.Px(),pEMCAL.Py(),pEMCAL.Pz(),0.);
2096 pi0GammaConvEMCAL=gammaGammaConv+gammaEMCAL;
2097 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvEMCAL",pi0GammaConvEMCAL.M());
2098 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt_GammaConvEMCAL",pi0GammaConvEMCAL.M(),pi0GammaConvEMCAL.Pt());
2099 TVector3 v3D0(twoGammaDecayCandidateDaughter0->Px(),
2100 twoGammaDecayCandidateDaughter0->Py(),
2101 twoGammaDecayCandidateDaughter0->Pz());
2102 TVector3 v3D1(gammaEMCAL.Px(),gammaEMCAL.Py(),gammaEMCAL.Pz());
2105 Double_t opanConvEMCAL= v3D0.Angle(v3D1);
2106 if ( opanConvEMCAL < 0.35){
2107 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvEMCAL_OpanLow",pi0GammaConvEMCAL.M());
2109 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvEMCAL_OpanHigh",pi0GammaConvEMCAL.M());
2113 if(fCalculateBackground){
2114 for(Int_t nEventsInBG=0;nEventsInBG <fV0Reader->GetNBGEvents();nEventsInBG++){
2115 AliGammaConversionKFVector * previousEventV0s = fV0Reader->GetBGGoodV0s(nEventsInBG);
2116 for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
2117 AliKFParticle previousGoodV0 = (AliKFParticle)(*(previousEventV0s->at(iPrevious)));
2118 gammaGammaConvBck.SetXYZM(previousGoodV0.Px(),
2119 previousGoodV0.Py(),
2120 previousGoodV0.Pz(),0.);
2121 pi0GammaConvEMCALBck=gammaGammaConvBck+gammaEMCAL;
2122 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvEMCAL_Bck",pi0GammaConvEMCALBck.M());
2123 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt_GammaConvEMCAL_Bck",pi0GammaConvEMCALBck.M(),
2124 pi0GammaConvEMCALBck.Pt());
2128 // Now the LorentVector pEMCAL is obtained and can be paired with the converted proton
2129 } // end of checking if background photons are available
2131 //==== End of the PHOS cluster selection ============
2135 void AliAnalysisTaskGammaConversion::CalculateBackground(){
2136 // see header file for documentation
2139 TClonesArray * currentEventV0s = fV0Reader->GetCurrentEventGoodV0s();
2141 for(Int_t nEventsInBG=0;nEventsInBG <fV0Reader->GetNBGEvents();nEventsInBG++){
2142 AliGammaConversionKFVector * previousEventV0s = fV0Reader->GetBGGoodV0s(nEventsInBG);
2143 for(Int_t iCurrent=0;iCurrent<currentEventV0s->GetEntriesFast();iCurrent++){
2144 AliKFParticle currentEventGoodV0 = *(AliKFParticle *)(currentEventV0s->At(iCurrent));
2145 for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
2146 AliKFParticle previousGoodV0 = (AliKFParticle)(*(previousEventV0s->at(iPrevious)));
2148 AliKFParticle *backgroundCandidate = new AliKFParticle(currentEventGoodV0,previousGoodV0);
2150 Double_t massBG =0.;
2151 Double_t widthBG = 0.;
2152 Double_t chi2BG =10000.;
2153 backgroundCandidate->GetMass(massBG,widthBG);
2154 // if(backgroundCandidate->GetNDF()>0){
2155 // chi2BG = backgroundCandidate->GetChi2()/backgroundCandidate->GetNDF();
2156 chi2BG = backgroundCandidate->GetChi2();
2157 // if(chi2BG>0 && chi2BG<fV0Reader->GetChi2CutMeson()){
2159 TVector3 momentumVectorbackgroundCandidate(backgroundCandidate->GetPx(),backgroundCandidate->GetPy(),backgroundCandidate->GetPz());
2160 TVector3 spaceVectorbackgroundCandidate(backgroundCandidate->GetX(),backgroundCandidate->GetY(),backgroundCandidate->GetZ());
2162 Double_t openingAngleBG = currentEventGoodV0.GetAngle(previousGoodV0);
2166 if(backgroundCandidate->GetE() - backgroundCandidate->GetPz() <= 0 || backgroundCandidate->GetE() + backgroundCandidate->GetPz() <= 0){
2167 cout << "Error: |Pz| > E !!!! " << endl;
2170 rapidity = 0.5*(TMath::Log((backgroundCandidate->GetE() +backgroundCandidate->GetPz()) / (backgroundCandidate->GetE()-backgroundCandidate->GetPz())));
2174 if( (currentEventGoodV0.GetE()+previousGoodV0.GetE()) != 0){
2175 alfa=TMath::Abs((currentEventGoodV0.GetE()-previousGoodV0.GetE())
2176 /(currentEventGoodV0.GetE()+previousGoodV0.GetE()));
2180 if(openingAngleBG < fMinOpeningAngleGhostCut ){
2181 delete backgroundCandidate;
2182 continue; // minimum opening angle to avoid using ghosttracks
2186 fHistograms->FillHistogram("ESD_Background_GammaDaughter_OpeningAngle", openingAngleBG);
2187 fHistograms->FillHistogram("ESD_Background_Energy", backgroundCandidate->GetE());
2188 fHistograms->FillHistogram("ESD_Background_Pt", momentumVectorbackgroundCandidate.Pt());
2189 fHistograms->FillHistogram("ESD_Background_Eta", momentumVectorbackgroundCandidate.Eta());
2190 fHistograms->FillHistogram("ESD_Background_Rapidity", rapidity);
2191 fHistograms->FillHistogram("ESD_Background_Phi", spaceVectorbackgroundCandidate.Phi());
2192 fHistograms->FillHistogram("ESD_Background_Mass", massBG);
2193 fHistograms->FillHistogram("ESD_Background_R", spaceVectorbackgroundCandidate.Pt()); // Pt in Space == R!!!!
2194 fHistograms->FillHistogram("ESD_Background_ZR", backgroundCandidate->GetZ(), spaceVectorbackgroundCandidate.Pt());
2195 fHistograms->FillHistogram("ESD_Background_XY", backgroundCandidate->GetX(), backgroundCandidate->GetY());
2196 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt",massBG,momentumVectorbackgroundCandidate.Pt());
2197 fHistograms->FillHistogram("ESD_Background_InvMass",massBG);
2199 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
2200 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt_alpha",massBG,momentumVectorbackgroundCandidate.Pt());
2202 if ( TMath::Abs(currentEventGoodV0.GetEta())<0.9 && TMath::Abs(previousGoodV0.GetEta())<0.9 ){
2203 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt_Fiducial",massBG,momentumVectorbackgroundCandidate.Pt());
2204 fHistograms->FillHistogram("ESD_Background_InvMass_Fiducial",massBG);
2209 AliGammaConversionBGHandler * bgHandler = fV0Reader->GetBGHandler();
2211 Int_t zbin= bgHandler->GetZBinIndex(fV0Reader->GetVertexZ());
2212 Int_t mbin= bgHandler->GetMultiplicityBinIndex(fV0Reader->CountESDTracks());
2214 fHistograms->FillHistogram(Form("%d%dESD_Background_GammaDaughter_OpeningAngle",zbin,mbin), openingAngleBG);
2215 fHistograms->FillHistogram(Form("%d%dESD_Background_Energy",zbin,mbin), backgroundCandidate->GetE());
2216 fHistograms->FillHistogram(Form("%d%dESD_Background_Pt",zbin,mbin), momentumVectorbackgroundCandidate.Pt());
2217 fHistograms->FillHistogram(Form("%d%dESD_Background_Eta",zbin,mbin), momentumVectorbackgroundCandidate.Eta());
2218 fHistograms->FillHistogram(Form("%d%dESD_Background_Rapidity",zbin,mbin), rapidity);
2219 fHistograms->FillHistogram(Form("%d%dESD_Background_Phi",zbin,mbin), spaceVectorbackgroundCandidate.Phi());
2220 fHistograms->FillHistogram(Form("%d%dESD_Background_Mass",zbin,mbin), massBG);
2221 fHistograms->FillHistogram(Form("%d%dESD_Background_R",zbin,mbin), spaceVectorbackgroundCandidate.Pt()); // Pt in Space == R!!!!
2222 fHistograms->FillHistogram(Form("%d%dESD_Background_ZR",zbin,mbin), backgroundCandidate->GetZ(), spaceVectorbackgroundCandidate.Pt());
2223 fHistograms->FillHistogram(Form("%d%dESD_Background_XY",zbin,mbin), backgroundCandidate->GetX(), backgroundCandidate->GetY());
2224 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_vs_Pt",zbin,mbin),massBG,momentumVectorbackgroundCandidate.Pt());
2225 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass",zbin,mbin),massBG);
2227 if ( TMath::Abs(currentEventGoodV0.GetEta())<0.9 && TMath::Abs(previousGoodV0.GetEta())<0.9 ){
2228 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_vs_Pt_Fiducial",zbin,mbin),massBG,momentumVectorbackgroundCandidate.Pt());
2229 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_Fiducial",zbin,mbin),massBG);
2233 delete backgroundCandidate;
2240 void AliAnalysisTaskGammaConversion::ProcessGammasForGammaJetAnalysis(){
2241 //ProcessGammasForGammaJetAnalysis
2243 Double_t distIsoMin;
2245 CreateListOfChargedParticles();
2248 // for(UInt_t gammaIndex=0;gammaIndex<fKFReconstructedGammas.size();gammaIndex++){
2249 for(Int_t gammaIndex=0;gammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();gammaIndex++){
2250 AliKFParticle * currentGamma = (AliKFParticle*)fKFReconstructedGammasTClone->At(gammaIndex);
2251 TVector3 momentumVectorCurrentGamma(currentGamma->GetPx(),currentGamma->GetPy(),currentGamma->GetPz());
2253 if( momentumVectorCurrentGamma.Pt()> fMinPtForGammaJet){
2254 distIsoMin=GetMinimumDistanceToCharge(gammaIndex);
2256 if (distIsoMin > fMinIsoConeSize && fLeadingChargedIndex>=0){
2257 CalculateJetCone(gammaIndex);
2263 //____________________________________________________________________
2264 Bool_t AliAnalysisTaskGammaConversion::IsGoodImpPar(AliESDtrack *const track)
2267 // check whether particle has good DCAr(Pt) impact
2268 // parameter. Only for TPC+ITS tracks (7*sigma cut)
2269 // Origin: Andrea Dainese
2272 Float_t d0z0[2],covd0z0[3];
2273 track->GetImpactParameters(d0z0,covd0z0);
2274 Float_t sigma= 0.0050+0.0060/TMath::Power(track->Pt(),0.9);
2275 Float_t d0max = 7.*sigma;
2276 if(TMath::Abs(d0z0[0]) < d0max) return kTRUE;
2282 void AliAnalysisTaskGammaConversion::CreateListOfChargedParticles(){
2283 // CreateListOfChargedParticles
2285 fESDEvent = fV0Reader->GetESDEvent();
2286 Int_t numberOfESDTracks=0;
2287 for(Int_t iTracks = 0; iTracks < fESDEvent->GetNumberOfTracks(); iTracks++){
2288 AliESDtrack* curTrack = fESDEvent->GetTrack(iTracks);
2293 // Not needed if Standard function used.
2294 // if(!IsGoodImpPar(curTrack)){
2298 if(fEsdTrackCuts->AcceptTrack(curTrack) ){
2299 new((*fChargedParticles)[fChargedParticles->GetEntriesFast()]) AliESDtrack(*curTrack);
2300 // fChargedParticles.push_back(curTrack);
2301 fChargedParticlesId.push_back(iTracks);
2302 numberOfESDTracks++;
2305 fHistograms->FillHistogram("ESD_NumberOfGoodESDTracks",numberOfESDTracks);
2307 if (fV0Reader->GetNumberOfContributorsVtx()>=1){
2308 fHistograms->FillHistogram("ESD_NumberOfGoodESDTracksVtx",numberOfESDTracks);
2311 void AliAnalysisTaskGammaConversion::RecalculateV0ForGamma(){
2313 Double_t massE=0.00051099892;
2314 TLorentzVector curElecPos;
2315 TLorentzVector curElecNeg;
2316 TLorentzVector curGamma;
2318 TLorentzVector curGammaAt;
2319 TLorentzVector curElecPosAt;
2320 TLorentzVector curElecNegAt;
2321 AliKFVertex primVtxGamma(*(fESDEvent->GetPrimaryVertex()));
2322 AliKFVertex primVtxImprovedGamma = primVtxGamma;
2324 const AliESDVertex *vtxT3D=fESDEvent->GetPrimaryVertex();
2326 Double_t xPrimaryVertex=vtxT3D->GetXv();
2327 Double_t yPrimaryVertex=vtxT3D->GetYv();
2328 Double_t zPrimaryVertex=vtxT3D->GetZv();
2329 // Float_t primvertex[3]={xPrimaryVertex,yPrimaryVertex,zPrimaryVertex};
2331 Float_t nsigmaTPCtrackPos;
2332 Float_t nsigmaTPCtrackNeg;
2333 Float_t nsigmaTPCtrackPosToPion;
2334 Float_t nsigmaTPCtrackNegToPion;
2335 AliKFParticle* negKF=NULL;
2336 AliKFParticle* posKF=NULL;
2338 for(Int_t iTracks = 0; iTracks < fESDEvent->GetNumberOfTracks(); iTracks++){
2339 AliESDtrack* posTrack = fESDEvent->GetTrack(iTracks);
2343 if (posKF) delete posKF; posKF=NULL;
2344 if(posTrack->GetSign()<0) continue;
2345 if(!(posTrack->GetStatus() & AliESDtrack::kTPCrefit))continue;
2346 if(posTrack->GetKinkIndex(0)>0 ) continue;
2347 if(posTrack->GetNcls(1)<50)continue;
2349 // posTrack->GetConstrainedPxPyPz(momPos);
2350 posTrack->GetPxPyPz(momPos);
2351 AliESDtrack *ptrk=fESDEvent->GetTrack(iTracks);
2352 curElecPos.SetXYZM(momPos[0],momPos[1],momPos[2],massE);
2353 if(TMath::Abs(curElecPos.Eta())<0.9) continue;
2354 posKF = new AliKFParticle( *(posTrack),-11);
2356 nsigmaTPCtrackPos = fV0Reader->GetESDpid()->NumberOfSigmasTPC(posTrack,AliPID::kElectron);
2357 nsigmaTPCtrackPosToPion = fV0Reader->GetESDpid()->NumberOfSigmasTPC(posTrack,AliPID::kPion);
2359 if ( nsigmaTPCtrackPos>5.|| nsigmaTPCtrackPos<-2.){
2363 if(pow((momPos[0]*momPos[0]+momPos[1]*momPos[1]+momPos[2]*momPos[2]),0.5)>0.5 && nsigmaTPCtrackPosToPion<1){
2369 for(Int_t jTracks = 0; jTracks < fESDEvent->GetNumberOfTracks(); jTracks++){
2370 AliESDtrack* negTrack = fESDEvent->GetTrack(jTracks);
2374 if (negKF) delete negKF; negKF=NULL;
2375 if(negTrack->GetSign()>0) continue;
2376 if(!(negTrack->GetStatus() & AliESDtrack::kTPCrefit))continue;
2377 if(negTrack->GetKinkIndex(0)>0 ) continue;
2378 if(negTrack->GetNcls(1)<50)continue;
2380 // negTrack->GetConstrainedPxPyPz(momNeg);
2381 negTrack->GetPxPyPz(momNeg);
2383 nsigmaTPCtrackNeg = fV0Reader->GetESDpid()->NumberOfSigmasTPC(negTrack,AliPID::kElectron);
2384 nsigmaTPCtrackNegToPion = fV0Reader->GetESDpid()->NumberOfSigmasTPC(negTrack,AliPID::kPion);
2385 if ( nsigmaTPCtrackNeg>5. || nsigmaTPCtrackNeg<-2.){
2388 if(pow((momNeg[0]*momNeg[0]+momNeg[1]*momNeg[1]+momNeg[2]*momNeg[2]),0.5)>0.5 && nsigmaTPCtrackNegToPion<1){
2391 AliESDtrack *ntrk=fESDEvent->GetTrack(jTracks);
2392 curElecNeg.SetXYZM(momNeg[0],momNeg[1],momNeg[2],massE);
2393 if(TMath::Abs(curElecNeg.Eta())<0.9) continue;
2394 negKF = new AliKFParticle( *(negTrack) ,11);
2396 Double_t b=fESDEvent->GetMagneticField();
2397 Double_t xn, xp, dca=ntrk->GetDCA(ptrk,b,xn,xp);
2398 AliExternalTrackParam nt(*ntrk), pt(*ptrk);
2399 nt.PropagateTo(xn,b); pt.PropagateTo(xp,b);
2402 //--- Like in ITSV0Finder
2403 AliExternalTrackParam ntAt0(*ntrk), ptAt0(*ptrk);
2404 Double_t xxP,yyP,alphaP;
2407 // if (!ptAt0.GetGlobalXYZat(ptAt0->GetX(),xxP,yyP,zzP)) continue;
2408 if (!ptAt0.GetXYZAt(ptAt0.GetX(),b,rP)) continue;
2411 alphaP = TMath::ATan2(yyP,xxP);
2414 ptAt0.Propagate(alphaP,0,b);
2415 Float_t ptfacP = (1.+100.*TMath::Abs(ptAt0.GetC(b)));
2417 // Double_t distP = ptAt0.GetY();
2418 Double_t normP = ptfacP*TMath::Sqrt(ptAt0.GetSigmaY2());
2419 Double_t normdist0P = TMath::Abs(ptAt0.GetY()/normP);
2420 Double_t normdist1P = TMath::Abs((ptAt0.GetZ()-zPrimaryVertex)/(ptfacP*TMath::Sqrt(ptAt0.GetSigmaZ2())));
2421 Double_t normdistP = TMath::Sqrt(normdist0P*normdist0P+normdist1P*normdist1P);
2424 Double_t xxN,yyN,alphaN;
2426 // if (!ntAt0.GetGlobalXYZat(ntAt0->GetX(),xxN,yyN,zzN)) continue;
2427 if (!ntAt0.GetXYZAt(ntAt0.GetX(),b,rN)) continue;
2431 alphaN = TMath::ATan2(yyN,xxN);
2433 ntAt0.Propagate(alphaN,0,b);
2435 Float_t ptfacN = (1.+100.*TMath::Abs(ntAt0.GetC(b)));
2436 // Double_t distN = ntAt0.GetY();
2437 Double_t normN = ptfacN*TMath::Sqrt(ntAt0.GetSigmaY2());
2438 Double_t normdist0N = TMath::Abs(ntAt0.GetY()/normN);
2439 Double_t normdist1N = TMath::Abs((ntAt0.GetZ()-zPrimaryVertex)/(ptfacN*TMath::Sqrt(ntAt0.GetSigmaZ2())));
2440 Double_t normdistN = TMath::Sqrt(normdist0N*normdist0N+normdist1N*normdist1N);
2442 //-----------------------------
2444 Double_t momNegAt[3];
2445 nt.GetPxPyPz(momNegAt);
2446 curElecNegAt.SetXYZM(momNegAt[0],momNegAt[1],momNegAt[2],massE);
2448 Double_t momPosAt[3];
2449 pt.GetPxPyPz(momPosAt);
2450 curElecPosAt.SetXYZM(momPosAt[0],momPosAt[1],momPosAt[2],massE);
2455 // Double_t dneg= negTrack->GetD(xPrimaryVertex,yPrimaryVertex,b);
2456 // Double_t dpos= posTrack->GetD(xPrimaryVertex,yPrimaryVertex,b);
2457 AliESDv0 vertex(nt,jTracks,pt,iTracks);
2460 Float_t cpa=vertex.GetV0CosineOfPointingAngle(xPrimaryVertex,yPrimaryVertex,zPrimaryVertex);
2464 // cout<< "v0Rr::"<< v0Rr<<endl;
2465 // if (pvertex.GetRr()<0.5){
2468 // cout<<"vertex.GetChi2V0()"<<vertex.GetChi2V0()<<endl;
2469 if(cpa<0.9)continue;
2470 // if (vertex.GetChi2V0() > 30) continue;
2471 // cout<<"xp+xn::"<<xp<<" "<<xn<<endl;
2472 if ((xn+xp) < 0.4) continue;
2473 if (TMath::Abs(ntrk->GetD(xPrimaryVertex,yPrimaryVertex,b))<0.05)
2474 if (TMath::Abs(ptrk->GetD(xPrimaryVertex,yPrimaryVertex,b))<0.05) continue;
2476 //cout<<"pass"<<endl;
2478 AliKFParticle v0GammaC;
2481 v0GammaC.SetMassConstraint(0,0.001);
2482 primVtxImprovedGamma+=v0GammaC;
2483 v0GammaC.SetProductionVertex(primVtxImprovedGamma);
2486 curGamma=curElecNeg+curElecPos;
2487 curGammaAt=curElecNegAt+curElecPosAt;
2489 // invariant mass versus pt of K0short
2491 Double_t chi2V0GammaC=100000.;
2492 if( v0GammaC.GetNDF() != 0) {
2493 chi2V0GammaC = v0GammaC.GetChi2()/v0GammaC.GetNDF();
2495 cout<< "ERROR::v0K0C.GetNDF()" << endl;
2498 if(chi2V0GammaC<200 &&chi2V0GammaC>0 ){
2499 if(fHistograms != NULL){
2500 fHistograms->FillHistogram("ESD_RecalculateV0_InvMass",v0GammaC.GetMass());
2501 fHistograms->FillHistogram("ESD_RecalculateV0_Pt",v0GammaC.GetPt());
2502 fHistograms->FillHistogram("ESD_RecalculateV0_E_dEdxP",curElecNegAt.P(),negTrack->GetTPCsignal());
2503 fHistograms->FillHistogram("ESD_RecalculateV0_P_dEdxP",curElecPosAt.P(),posTrack->GetTPCsignal());
2504 fHistograms->FillHistogram("ESD_RecalculateV0_cpa",cpa);
2505 fHistograms->FillHistogram("ESD_RecalculateV0_dca",dca);
2506 fHistograms->FillHistogram("ESD_RecalculateV0_normdistP",normdistP);
2507 fHistograms->FillHistogram("ESD_RecalculateV0_normdistN",normdistN);
2509 new((*fKFRecalculatedGammasTClone)[fKFRecalculatedGammasTClone->GetEntriesFast()]) AliKFParticle(v0GammaC);
2510 fElectronRecalculatedv1.push_back(iTracks);
2511 fElectronRecalculatedv2.push_back(jTracks);
2517 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFRecalculatedGammasTClone->GetEntriesFast();firstGammaIndex++){
2518 for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fKFRecalculatedGammasTClone->GetEntriesFast();secondGammaIndex++){
2519 AliKFParticle * twoGammaDecayCandidateDaughter0 = (AliKFParticle *)fKFRecalculatedGammasTClone->At(firstGammaIndex);
2520 AliKFParticle * twoGammaDecayCandidateDaughter1 = (AliKFParticle *)fKFRecalculatedGammasTClone->At(secondGammaIndex);
2522 if(fElectronRecalculatedv1[firstGammaIndex]==fElectronRecalculatedv1[secondGammaIndex]){
2525 if( fElectronRecalculatedv2[firstGammaIndex]==fElectronRecalculatedv2[secondGammaIndex]){
2529 AliKFParticle twoGammaCandidate(*twoGammaDecayCandidateDaughter0,*twoGammaDecayCandidateDaughter1);
2530 fHistograms->FillHistogram("ESD_RecalculateGG_InvMass",twoGammaCandidate.GetMass());
2531 fHistograms->FillHistogram("ESD_RecalculateGG_InvMass_vs_Pt",twoGammaCandidate.GetMass(),twoGammaCandidate.GetPt());
2535 void AliAnalysisTaskGammaConversion::CalculateJetCone(Int_t gammaIndex){
2539 Double_t coneSize=0.3;
2542 // AliKFParticle * currentGamma = &fKFReconstructedGammas[gammaIndex];
2543 AliKFParticle * currentGamma = (AliKFParticle*)fKFReconstructedGammasTClone->At(gammaIndex);
2545 TVector3 momentumVectorCurrentGamma(currentGamma->GetPx(),currentGamma->GetPy(),currentGamma->GetPz());
2547 AliESDtrack* leadingCharged = (AliESDtrack*)(fChargedParticles->At(fLeadingChargedIndex));
2549 Double_t momLeadingCharged[3];
2550 leadingCharged->GetConstrainedPxPyPz(momLeadingCharged);
2552 TVector3 momentumVectorLeadingCharged(momLeadingCharged[0],momLeadingCharged[1],momLeadingCharged[2]);
2554 Double_t phi1=momentumVectorLeadingCharged.Phi();
2555 Double_t eta1=momentumVectorLeadingCharged.Eta();
2556 Double_t phi3=momentumVectorCurrentGamma.Phi();
2558 for(Int_t iCh=0;iCh<fChargedParticles->GetEntriesFast();iCh++){
2559 AliESDtrack* curTrack = (AliESDtrack*)(fChargedParticles->At(iCh));
2560 Int_t chId = fChargedParticlesId[iCh];
2561 if(fLeadingChargedIndex==chId || fLeadingChargedIndex==chId) continue;
2563 curTrack->GetConstrainedPxPyPz(mom);
2564 TVector3 momentumVectorChargedParticle(mom[0],mom[1],mom[2]);
2565 Double_t phi2=momentumVectorChargedParticle.Phi();
2566 Double_t eta2=momentumVectorChargedParticle.Eta();
2570 if( TMath::Abs(phi2 - phi1) <= ( TMath::TwoPi()-coneSize) ){
2571 cone = TMath::Sqrt( TMath::Power((eta2-eta1),2)+ TMath::Power((phi2-phi1),2) );
2573 if( (phi2 - phi1)> TMath::TwoPi()-coneSize ){
2574 cone = TMath::Sqrt( TMath::Power((eta2-eta1),2)+ TMath::Power((phi2-TMath::TwoPi()-phi1),2) );
2576 if( (phi2 - phi1)< -(TMath::TwoPi()-coneSize) ){
2577 cone = TMath::Sqrt( TMath::Power((eta2-eta1),2)+ TMath::Power((phi2+TMath::TwoPi()-phi1),2) );
2581 if(cone <coneSize&& momentumVectorChargedParticle.Pt()>fMinPtJetCone ){
2582 ptJet+= momentumVectorChargedParticle.Pt();
2583 Double_t ffzHdrGam = momentumVectorChargedParticle.Pt()/momentumVectorCurrentGamma.Pt();
2584 Double_t imbalanceHdrGam=-momentumVectorChargedParticle.Dot(momentumVectorCurrentGamma)/momentumVectorCurrentGamma.Mag2();
2585 fHistograms->FillHistogram("ESD_FFzHdrGam",ffzHdrGam);
2586 fHistograms->FillHistogram("ESD_ImbalanceHdrGam",imbalanceHdrGam);
2590 Double_t dphiHdrGam=phi3-phi2;
2591 if ( dphiHdrGam < (-TMath::PiOver2())){
2592 dphiHdrGam+=(TMath::TwoPi());
2595 if ( dphiHdrGam > (3.*TMath::PiOver2()) ){
2596 dphiHdrGam-=(TMath::TwoPi());
2599 if (momentumVectorChargedParticle.Pt()>fMinPtGamChargedCorr){
2600 fHistograms->FillHistogram("ESD_dphiHdrGamIsolated",dphiHdrGam);
2607 Double_t AliAnalysisTaskGammaConversion::GetMinimumDistanceToCharge(Int_t indexHighestPtGamma){
2608 // GetMinimumDistanceToCharge
2610 Double_t fIsoMin=100.;
2611 Double_t ptLeadingCharged=-1.;
2613 fLeadingChargedIndex=-1;
2615 AliKFParticle * gammaHighestPt = (AliKFParticle*)fKFReconstructedGammasTClone->At(indexHighestPtGamma);
2616 TVector3 momentumVectorgammaHighestPt(gammaHighestPt->GetPx(),gammaHighestPt->GetPy(),gammaHighestPt->GetPz());
2618 Double_t phi1=momentumVectorgammaHighestPt.Phi();
2619 Double_t eta1=momentumVectorgammaHighestPt.Eta();
2621 for(Int_t iCh=0;iCh<fChargedParticles->GetEntriesFast();iCh++){
2622 AliESDtrack* curTrack = (AliESDtrack*)(fChargedParticles->At(iCh));
2623 Int_t chId = fChargedParticlesId[iCh];
2624 if(fElectronv1[indexHighestPtGamma]==chId || fElectronv2[indexHighestPtGamma]==chId) continue;
2626 curTrack->GetConstrainedPxPyPz(mom);
2627 TVector3 momentumVectorChargedParticle(mom[0],mom[1],mom[2]);
2628 Double_t phi2=momentumVectorChargedParticle.Phi();
2629 Double_t eta2=momentumVectorChargedParticle.Eta();
2630 Double_t iso=pow( (pow( (eta1-eta2),2)+ pow((phi1-phi2),2)),0.5 );
2632 if(momentumVectorChargedParticle.Pt()>fMinPtIsoCone ){
2638 Double_t dphiHdrGam=phi1-phi2;
2639 if ( dphiHdrGam < (-TMath::PiOver2())){
2640 dphiHdrGam+=(TMath::TwoPi());
2643 if ( dphiHdrGam > (3.*TMath::PiOver2()) ){
2644 dphiHdrGam-=(TMath::TwoPi());
2646 if (momentumVectorChargedParticle.Pt()>fMinPtGamChargedCorr){
2647 fHistograms->FillHistogram("ESD_dphiHdrGam",dphiHdrGam);
2650 if (dphiHdrGam>0.9*TMath::Pi() && dphiHdrGam<1.1*TMath::Pi()){
2651 if (momentumVectorChargedParticle.Pt()> ptLeadingCharged && momentumVectorChargedParticle.Pt()>0.1*momentumVectorgammaHighestPt.Pt()){
2652 ptLeadingCharged=momentumVectorChargedParticle.Pt();
2653 fLeadingChargedIndex=iCh;
2658 fHistograms->FillHistogram("ESD_MinimumIsoDistance",fIsoMin);
2663 Int_t AliAnalysisTaskGammaConversion::GetIndexHighestPtGamma(){
2664 //GetIndexHighestPtGamma
2666 Int_t indexHighestPtGamma=-1;
2668 fGammaPtHighest = -100.;
2670 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();firstGammaIndex++){
2671 AliKFParticle * gammaHighestPtCandidate = (AliKFParticle*)fKFReconstructedGammasTClone->At(firstGammaIndex);
2672 TVector3 momentumVectorgammaHighestPtCandidate(gammaHighestPtCandidate->GetPx(),gammaHighestPtCandidate->GetPy(),gammaHighestPtCandidate->GetPz());
2673 if (momentumVectorgammaHighestPtCandidate.Pt() > fGammaPtHighest){
2674 fGammaPtHighest=momentumVectorgammaHighestPtCandidate.Pt();
2675 //gammaHighestPt = gammaHighestPtCandidate;
2676 indexHighestPtGamma=firstGammaIndex;
2680 return indexHighestPtGamma;
2685 void AliAnalysisTaskGammaConversion::Terminate(Option_t */*option*/)
2687 // Terminate analysis
2689 AliDebug(1,"Do nothing in Terminate");
2692 void AliAnalysisTaskGammaConversion::UserCreateOutputObjects()
2695 if(!fAODGamma) fAODGamma = new TClonesArray("AliGammaConversionAODObject", 0);
2696 else fAODGamma->Delete();
2697 fAODGamma->SetName(Form("%s_gamma", fAODBranchName.Data()));
2699 if(!fAODPi0) fAODPi0 = new TClonesArray("AliGammaConversionAODObject", 0);
2700 else fAODPi0->Delete();
2701 fAODPi0->SetName(Form("%s_Pi0", fAODBranchName.Data()));
2703 if(!fAODOmega) fAODOmega = new TClonesArray("AliGammaConversionAODObject", 0);
2704 else fAODOmega->Delete();
2705 fAODOmega->SetName(Form("%s_Omega", fAODBranchName.Data()));
2707 //If delta AOD file name set, add in separate file. Else add in standard aod file.
2708 if(fKFDeltaAODFileName.Length() > 0) {
2709 AddAODBranch("TClonesArray", &fAODGamma, fKFDeltaAODFileName.Data());
2710 AddAODBranch("TClonesArray", &fAODPi0, fKFDeltaAODFileName.Data());
2711 AddAODBranch("TClonesArray", &fAODOmega, fKFDeltaAODFileName.Data());
2712 AliAnalysisManager::GetAnalysisManager()->RegisterExtraFile(fKFDeltaAODFileName.Data());
2714 AddAODBranch("TClonesArray", &fAODGamma);
2715 AddAODBranch("TClonesArray", &fAODPi0);
2716 AddAODBranch("TClonesArray", &fAODOmega);
2719 // Create the output container
2720 if(fOutputContainer != NULL){
2721 delete fOutputContainer;
2722 fOutputContainer = NULL;
2724 if(fOutputContainer == NULL){
2725 fOutputContainer = new TList();
2726 fOutputContainer->SetOwner(kTRUE);
2729 //Adding the histograms to the output container
2730 fHistograms->GetOutputContainer(fOutputContainer);
2734 if(fGammaNtuple == NULL){
2735 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);
2737 if(fNeutralMesonNtuple == NULL){
2738 fNeutralMesonNtuple = new TNtuple("NeutralMesonNtuple","NeutralMesonNtuple","test");
2740 TList * ntupleTList = new TList();
2741 ntupleTList->SetOwner(kTRUE);
2742 ntupleTList->SetName("Ntuple");
2743 ntupleTList->Add((TNtuple*)fGammaNtuple);
2744 fOutputContainer->Add(ntupleTList);
2747 fOutputContainer->SetName(GetName());
2750 Double_t AliAnalysisTaskGammaConversion::GetMCOpeningAngle(TParticle* const daughter0, TParticle* const daughter1) const{
2752 TVector3 v3D0(daughter0->Px(),daughter0->Py(),daughter0->Pz());
2753 TVector3 v3D1(daughter1->Px(),daughter1->Py(),daughter1->Pz());
2754 return v3D0.Angle(v3D1);
2757 void AliAnalysisTaskGammaConversion::CheckV0Efficiency(){
2758 // see header file for documentation
2760 vector<Int_t> indexOfGammaParticle;
2762 fStack = fV0Reader->GetMCStack();
2764 if(fV0Reader->CheckForPrimaryVertex() == kFALSE){
2765 return; // aborts if the primary vertex does not have contributors.
2768 for (Int_t iTracks = 0; iTracks < fStack->GetNprimary(); iTracks++) {
2769 TParticle* particle = (TParticle *)fStack->Particle(iTracks);
2770 if(particle->GetPdgCode()==22){ //Gamma
2771 if(particle->GetNDaughters() >= 2){
2772 TParticle* electron=NULL;
2773 TParticle* positron=NULL;
2774 for(Int_t daughterIndex=particle->GetFirstDaughter();daughterIndex<=particle->GetLastDaughter();daughterIndex++){
2775 TParticle *tmpDaughter = fStack->Particle(daughterIndex);
2776 if(tmpDaughter->GetUniqueID() == 5){
2777 if(tmpDaughter->GetPdgCode() == 11){
2778 electron = tmpDaughter;
2780 else if(tmpDaughter->GetPdgCode() == -11){
2781 positron = tmpDaughter;
2785 if(electron!=NULL && positron!=0){
2786 if(electron->R()<160){
2787 indexOfGammaParticle.push_back(iTracks);
2794 Int_t nFoundGammas=0;
2795 Int_t nNotFoundGammas=0;
2797 Int_t numberOfV0s = fV0Reader->GetNumberOfV0s();
2798 for(Int_t i=0;i<numberOfV0s;i++){
2799 fV0Reader->GetV0(i);
2801 if(fV0Reader->HasSameMCMother() == kFALSE){
2805 TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
2806 TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
2808 if(TMath::Abs(negativeMC->GetPdgCode())!=11 || TMath::Abs(positiveMC->GetPdgCode())!=11){
2811 if(negativeMC->GetPdgCode()==positiveMC->GetPdgCode()){
2815 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
2816 //TParticle * v0Gamma = fV0Reader->GetMotherMCParticle();
2817 for(UInt_t mcIndex=0;mcIndex<indexOfGammaParticle.size();mcIndex++){
2818 if(negativeMC->GetFirstMother()==indexOfGammaParticle[mcIndex]){
2830 void AliAnalysisTaskGammaConversion::ProcessGammaElectronsForChicAnalysis(){
2831 // see header file for documantation
2833 fESDEvent = fV0Reader->GetESDEvent();
2836 TClonesArray * vESDeNegTemp = new TClonesArray("AliESDtrack",0);
2837 TClonesArray * vESDePosTemp = new TClonesArray("AliESDtrack",0);
2838 TClonesArray * vESDxNegTemp = new TClonesArray("AliESDtrack",0);
2839 TClonesArray * vESDxPosTemp = new TClonesArray("AliESDtrack",0);
2840 TClonesArray * vESDeNegNoJPsi = new TClonesArray("AliESDtrack",0);
2841 TClonesArray * vESDePosNoJPsi = new TClonesArray("AliESDtrack",0);
2844 vector <AliESDtrack*> vESDeNegTemp(0);
2845 vector <AliESDtrack*> vESDePosTemp(0);
2846 vector <AliESDtrack*> vESDxNegTemp(0);
2847 vector <AliESDtrack*> vESDxPosTemp(0);
2848 vector <AliESDtrack*> vESDeNegNoJPsi(0);
2849 vector <AliESDtrack*> vESDePosNoJPsi(0);
2853 fHistograms->FillTable("Table_Electrons",0);//Count number of Events
2855 for(Int_t iTracks = 0; iTracks < fESDEvent->GetNumberOfTracks(); iTracks++){
2856 AliESDtrack* curTrack = fESDEvent->GetTrack(iTracks);
2859 //print warning here
2863 double p[3];if(!curTrack->GetConstrainedPxPyPz(p))continue;
2864 double r[3];curTrack->GetConstrainedXYZ(r);
2868 fHistograms->FillTable("Table_Electrons",4);//Count number of ESD tracks
2870 Bool_t flagKink = kTRUE;
2871 Bool_t flagTPCrefit = kTRUE;
2872 Bool_t flagTRDrefit = kTRUE;
2873 Bool_t flagITSrefit = kTRUE;
2874 Bool_t flagTRDout = kTRUE;
2875 Bool_t flagVertex = kTRUE;
2878 //Cuts ---------------------------------------------------------------
2880 if(curTrack->GetKinkIndex(0) > 0){
2881 fHistograms->FillHistogram("Table_Electrons",5);//Count kink
2885 ULong_t trkStatus = curTrack->GetStatus();
2887 ULong_t tpcRefit = (trkStatus & AliESDtrack::kTPCrefit);
2890 fHistograms->FillHistogram("Table_Electrons",9);//Count not TPCrefit
2891 flagTPCrefit = kFALSE;
2894 ULong_t itsRefit = (trkStatus & AliESDtrack::kITSrefit);
2896 fHistograms->FillHistogram("Table_Electrons",10);//Count not ITSrefit
2897 flagITSrefit = kFALSE;
2900 ULong_t trdRefit = (trkStatus & AliESDtrack::kTRDrefit);
2903 fHistograms->FillHistogram("Table_Electrons",8); //Count not TRDrefit
2904 flagTRDrefit = kFALSE;
2907 ULong_t trdOut = (trkStatus & AliESDtrack::kTRDout);
2910 fHistograms->FillHistogram("Table_Electrons",7); //Count not TRDout
2911 flagTRDout = kFALSE;
2914 double nsigmaToVxt = GetSigmaToVertex(curTrack);
2916 if(nsigmaToVxt > 3){
2917 fHistograms->FillHistogram("Table_Electrons",6); //Count Tracks with number of sigmas > 3
2918 flagVertex = kFALSE;
2921 if(! (flagKink && flagTPCrefit && flagITSrefit && flagTRDrefit && flagTRDout && flagVertex ) ) continue;
2922 fHistograms->FillHistogram("Table_Electrons",11);//Count Tracks passed Cuts
2926 GetPID(curTrack, pid, weight);
2929 fHistograms->FillHistogram("Table_Electrons",12); //Count Tracks with pid != 0
2933 fHistograms->FillHistogram("Table_Electrons",13); //Count Tracks with pid != 0
2941 TLorentzVector curElec;
2942 curElec.SetXYZM(p[0],p[1],p[2],fElectronMass);
2946 Int_t labelMC = TMath::Abs(curTrack->GetLabel());
2947 TParticle* curParticle = fStack->Particle(labelMC);
2948 if(curTrack->GetSign() > 0){
2950 fHistograms->FillHistogram("MC_ElectronPosNegPt",curParticle->Pt());
2951 fHistograms->FillHistogram("MC_ElectronPosNegEta",curParticle->Eta());
2954 fHistograms->FillHistogram("MC_ElectronPosNegPt",curParticle->Pt());
2955 fHistograms->FillHistogram("MC_ElectronPosNegEta",curParticle->Eta());
2961 if(curTrack->GetSign() > 0){
2963 // vESDxPosTemp.push_back(curTrack);
2964 new((*vESDxPosTemp)[vESDxPosTemp->GetEntriesFast()]) AliESDtrack(*curTrack);
2968 fHistograms->FillHistogram("ESD_ElectronPosNegPt",curElec.Pt());
2969 fHistograms->FillHistogram("ESD_ElectronPosPt",curElec.Pt());
2970 // fHistograms->FillHistogram("MC_ElectronPosNegPt",curParticle->Pt());
2971 fHistograms->FillHistogram("ESD_ElectronPosNegEta",curElec.Eta());
2972 // fHistograms->FillHistogram("MC_ElectronPosNegEta",curParticle->Eta());
2973 // vESDePosTemp.push_back(curTrack);
2974 new((*vESDePosTemp)[vESDePosTemp->GetEntriesFast()]) AliESDtrack(*curTrack);
2981 new((*vESDxNegTemp)[vESDxNegTemp->GetEntriesFast()]) AliESDtrack(*curTrack);
2985 fHistograms->FillHistogram("ESD_ElectronPosNegPt",curElec.Pt());
2986 fHistograms->FillHistogram("ESD_ElectronNegPt",curElec.Pt());
2987 fHistograms->FillHistogram("ESD_ElectronPosNegEta",curElec.Eta());
2988 new((*vESDeNegTemp)[vESDeNegTemp->GetEntriesFast()]) AliESDtrack(*curTrack);
2997 Bool_t ePosJPsi = kFALSE;
2998 Bool_t eNegJPsi = kFALSE;
2999 Bool_t ePosPi0 = kFALSE;
3000 Bool_t eNegPi0 = kFALSE;
3002 UInt_t iePosJPsi=0,ieNegJPsi=0,iePosPi0=0,ieNegPi0=0;
3004 for(Int_t iNeg=0; iNeg < vESDeNegTemp->GetEntriesFast(); iNeg++){
3005 if(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDeNegTemp->At(iNeg)))->GetLabel()))->GetPdgCode() == 11)
3006 if(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDeNegTemp->At(iNeg)))->GetLabel()))->GetMother(0) > -1){
3007 Int_t labelMother = fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDeNegTemp->At(iNeg)))->GetLabel()))->GetMother(0);
3008 TParticle* partMother = fStack ->Particle(labelMother);
3009 if (partMother->GetPdgCode() == 111){
3013 if(partMother->GetPdgCode() == 443){ //Mother JPsi
3014 fHistograms->FillTable("Table_Electrons",14);
3019 // vESDeNegNoJPsi.push_back(vESDeNegTemp[iNeg]);
3020 new((*vESDeNegNoJPsi)[vESDeNegNoJPsi->GetEntriesFast()]) AliESDtrack(*(AliESDtrack*)(vESDeNegTemp->At(iNeg)));
3021 // cout<<"ESD No Positivo JPsi "<<endl;
3027 for(Int_t iPos=0; iPos < vESDePosTemp->GetEntriesFast(); iPos++){
3028 if(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDePosTemp->At(iPos)))->GetLabel()))->GetPdgCode() == -11)
3029 if(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDePosTemp->At(iPos)))->GetLabel()))->GetMother(0) > -1){
3030 Int_t labelMother = fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDePosTemp->At(iPos)))->GetLabel()))->GetMother(0);
3031 TParticle* partMother = fStack ->Particle(labelMother);
3032 if (partMother->GetPdgCode() == 111){
3036 if(partMother->GetPdgCode() == 443){ //Mother JPsi
3037 fHistograms->FillTable("Table_Electrons",15);
3042 // vESDePosNoJPsi.push_back(vESDePosTemp[iPos]);
3043 new((*vESDePosNoJPsi)[vESDePosNoJPsi->GetEntriesFast()]) AliESDtrack(*(AliESDtrack*)(vESDePosTemp->At(iPos)));
3044 // cout<<"ESD No Negativo JPsi "<<endl;
3050 if( eNegJPsi && ePosJPsi ){
3051 TVector3 tempeNegV,tempePosV;
3052 tempeNegV.SetXYZ(((AliESDtrack*)(vESDeNegTemp->At(ieNegJPsi)))->Px(),((AliESDtrack*)(vESDeNegTemp->At(ieNegJPsi)))->Py(),((AliESDtrack*)(vESDeNegTemp->At(ieNegJPsi)))->Pz());
3053 tempePosV.SetXYZ(((AliESDtrack*)(vESDePosTemp->At(iePosJPsi)))->Px(),((AliESDtrack*)(vESDePosTemp->At(iePosJPsi)))->Py(),((AliESDtrack*)(vESDePosTemp->At(iePosJPsi)))->Pz());
3054 fHistograms->FillTable("Table_Electrons",16);
3055 fHistograms->FillHistogram("ESD_ElectronPosNegJPsiAngle",tempeNegV.Angle(tempePosV));
3056 fHistograms->FillHistogram("MC_ElectronPosNegJPsiAngle",GetMCOpeningAngle(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDeNegTemp->At(ieNegJPsi)))->GetLabel())),
3057 fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDePosTemp->At(iePosJPsi)))->GetLabel()))));
3060 if( eNegPi0 && ePosPi0 ){
3061 TVector3 tempeNegV,tempePosV;
3062 tempeNegV.SetXYZ(((AliESDtrack*)(vESDeNegTemp->At(ieNegPi0)))->Px(),((AliESDtrack*)(vESDeNegTemp->At(ieNegPi0)))->Py(),((AliESDtrack*)(vESDeNegTemp->At(ieNegPi0)))->Pz());
3063 tempePosV.SetXYZ(((AliESDtrack*)(vESDePosTemp->At(iePosPi0)))->Px(),((AliESDtrack*)(vESDePosTemp->At(iePosPi0)))->Py(),((AliESDtrack*)(vESDePosTemp->At(iePosPi0)))->Pz());
3064 fHistograms->FillHistogram("ESD_ElectronPosNegPi0Angle",tempeNegV.Angle(tempePosV));
3065 fHistograms->FillHistogram("MC_ElectronPosNegPi0Angle",GetMCOpeningAngle(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDeNegTemp->At(ieNegPi0)))->GetLabel())),
3066 fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDePosTemp->At(iePosPi0)))->GetLabel()))));
3070 FillAngle("ESD_eNegePosAngleBeforeCut",GetTLorentzVector(vESDeNegTemp),GetTLorentzVector(vESDePosTemp));
3072 CleanWithAngleCuts(*vESDeNegTemp,*vESDePosTemp,*fKFReconstructedGammasTClone);
3074 // vector <TLorentzVector> vCurrentTLVeNeg = GetTLorentzVector(fCurrentEventNegElectron);
3075 // vector <TLorentzVector> vCurrentTLVePos = GetTLorentzVector(fCurrentEventPosElectron);
3077 TClonesArray vCurrentTLVeNeg = GetTLorentzVector(fCurrentEventNegElectronTClone);
3078 TClonesArray vCurrentTLVePos = GetTLorentzVector(fCurrentEventPosElectronTClone);
3081 FillAngle("ESD_eNegePosAngleAfterCut",vCurrentTLVeNeg,vCurrentTLVePos);
3086 //FillAngle("ESD_eNegePosAngleAfterCut",CurrentTLVeNeg,CurrentTLVePos);
3089 FillElectronInvMass("ESD_InvMass_ePluseMinus",vCurrentTLVeNeg,vCurrentTLVePos);
3090 FillElectronInvMass("ESD_InvMass_xPlusxMinus",GetTLorentzVector(vESDxNegTemp),GetTLorentzVector(vESDxPosTemp));
3094 FillGammaElectronInvMass("ESD_InvMass_GammaePluseMinusChiC","ESD_InvMass_GammaePluseMinusChiCDiff",*fKFReconstructedGammasCutTClone,vCurrentTLVeNeg,vCurrentTLVePos);
3096 FillGammaElectronInvMass("ESD_InvMass_GammaePluseMinusPi0","ESD_InvMass_GammaePluseMinusPi0Diff",
3097 *fKFReconstructedGammasCutTClone,vCurrentTLVeNeg,vCurrentTLVePos);
3102 ElectronBackground("ESD_ENegBackground",vCurrentTLVeNeg);
3103 ElectronBackground("ESD_EPosBackground",vCurrentTLVePos);
3104 ElectronBackground("ESD_EPosENegBackground",vCurrentTLVeNeg);
3105 ElectronBackground("ESD_EPosENegBackground",vCurrentTLVePos);
3107 // Like Sign e+e- no JPsi
3108 ElectronBackground("ESD_EPosENegNoJPsiBG",GetTLorentzVector(vESDeNegNoJPsi));
3109 ElectronBackground("ESD_EPosENegNoJPsiBG",GetTLorentzVector(vESDePosNoJPsi));
3113 if( fCurrentEventPosElectronTClone->GetEntriesFast() > 0 && fCurrentEventNegElectronTClone->GetEntriesFast() > 0 && fKFReconstructedGammasCutTClone->GetEntriesFast() > 0 ){
3114 FillGammaElectronInvMass("ESD_EPosENegGammaBackgroundMX","ESD_EPosENegGammaBackgroundMXDiff",
3115 *fKFReconstructedGammasCutTClone,*fPreviousEventTLVNegElectronTClone,*fPreviousEventTLVPosElectronTClone);
3116 *fPreviousEventTLVNegElectronTClone = vCurrentTLVeNeg;
3117 *fPreviousEventTLVPosElectronTClone = vCurrentTLVePos;
3124 vtx[0]=0;vtx[1]=0;vtx[2]=0;
3125 for(UInt_t i=0;i<fKFReconstructedGammasChic.size();i++){
3127 // if(fMCGammaChicTempCut[i]->GetMother(0) < 0) continue;
3131 Int_t tempLabel = fStack->Particle(fMCGammaChicTempCut[i]->GetMother(0))->GetPdgCode();
3132 // cout<<" Label Pedro Gonzalez " <<tempLabel <<endl;
3134 // cout<<" Label Distance"<<fKFReconstructedGammasChic[i].GetDistanceFromVertex(vtx)<<endl;
3136 if( tempLabel == 10441 || tempLabel == 20443 || tempLabel == 445 )
3138 fHistograms->FillHistogram("ESD_PhotonsMomentum",fKFReconstructedGammasChic[i].GetMomentum());
3147 vESDeNegTemp->Delete();
3148 vESDePosTemp->Delete();
3149 vESDxNegTemp->Delete();
3150 vESDxPosTemp->Delete();
3151 vESDeNegNoJPsi->Delete();
3152 vESDePosNoJPsi->Delete();
3154 delete vESDeNegTemp;
3155 delete vESDePosTemp;
3156 delete vESDxNegTemp;
3157 delete vESDxPosTemp;
3158 delete vESDeNegNoJPsi;
3159 delete vESDePosNoJPsi;
3163 void AliAnalysisTaskGammaConversion::FillAngle(TString histoName,vector <TLorentzVector> tlVeNeg, vector <TLorentzVector> tlVePos){
3164 //see header file for documentation
3165 for( UInt_t iNeg=0; iNeg < tlVeNeg.size(); iNeg++){
3166 for (UInt_t iPos=0; iPos < tlVePos.size(); iPos++){
3167 fHistograms->FillHistogram(histoName.Data(),tlVeNeg[iNeg].Vect().Angle(tlVePos[iPos].Vect()));
3172 void AliAnalysisTaskGammaConversion::FillAngle(TString histoName,TClonesArray const tlVeNeg, TClonesArray const tlVePos){
3173 //see header file for documentation
3174 for( Int_t iNeg=0; iNeg < tlVeNeg.GetEntriesFast(); iNeg++){
3175 for (Int_t iPos=0; iPos < tlVePos.GetEntriesFast(); iPos++){
3176 fHistograms->FillHistogram(histoName.Data(),((TLorentzVector*)(tlVeNeg.At(iNeg)))->Vect().Angle(((TLorentzVector*)(tlVePos.At(iPos)))->Vect()));
3180 void AliAnalysisTaskGammaConversion::FillElectronInvMass(TString histoName, TClonesArray const eNeg, TClonesArray const ePos){
3181 //see header file for documentation
3182 for( Int_t n=0; n < eNeg.GetEntriesFast(); n++){
3183 TLorentzVector en = (*(TLorentzVector*)(eNeg.At(n)));
3184 for (Int_t p=0; p < ePos.GetEntriesFast(); p++){
3185 TLorentzVector ep = (*(TLorentzVector*)(ePos.At(p)));
3186 TLorentzVector np = ep + en;
3187 fHistograms->FillHistogram(histoName.Data(),np.M());
3192 void AliAnalysisTaskGammaConversion::FillGammaElectronInvMass(TString histoMass,TString histoDiff,TClonesArray const fKFGammas,
3193 TClonesArray const tlVeNeg,TClonesArray const tlVePos)
3195 //see header file for documentation
3197 for( Int_t iNeg=0; iNeg < tlVeNeg.GetEntriesFast(); iNeg++ ){
3199 for (Int_t iPos=0; iPos < tlVePos.GetEntriesFast(); iPos++){
3201 TLorentzVector xy = *((TLorentzVector *)(tlVePos.At(iPos))) + *((TLorentzVector *)(tlVeNeg.At(iNeg)));
3203 for (Int_t iGam=0; iGam < fKFGammas.GetEntriesFast(); iGam++){
3205 // AliKFParticle * gammaCandidate = &fKFGammas[iGam];
3206 AliKFParticle * gammaCandidate = (AliKFParticle *)(fKFGammas.At(iGam));
3209 g.SetXYZM(gammaCandidate->GetPx(),gammaCandidate->GetPy(),gammaCandidate->GetPz(),fGammaMass);
3210 TLorentzVector xyg = xy + g;
3211 fHistograms->FillHistogram(histoMass.Data(),xyg.M());
3212 fHistograms->FillHistogram(histoDiff.Data(),(xyg.M()-xy.M()));
3218 void AliAnalysisTaskGammaConversion::ElectronBackground(TString hBg, TClonesArray e)
3220 // see header file for documentation
3221 for(Int_t i=0; i < e.GetEntriesFast(); i++)
3223 for (Int_t j=i+1; j < e.GetEntriesFast(); j++)
3225 TLorentzVector ee = (*(TLorentzVector*)(e.At(i))) + (*(TLorentzVector*)(e.At(j)));
3227 fHistograms->FillHistogram(hBg.Data(),ee.M());
3233 void AliAnalysisTaskGammaConversion::CleanWithAngleCuts(TClonesArray const negativeElectrons,
3234 TClonesArray const positiveElectrons,
3235 TClonesArray const gammas){
3236 // see header file for documentation
3238 UInt_t sizeN = negativeElectrons.GetEntriesFast();
3239 UInt_t sizeP = positiveElectrons.GetEntriesFast();
3240 UInt_t sizeG = gammas.GetEntriesFast();
3244 vector <Bool_t> xNegBand(sizeN);
3245 vector <Bool_t> xPosBand(sizeP);
3246 vector <Bool_t> gammaBand(sizeG);
3249 for(UInt_t iNeg=0; iNeg < sizeN; iNeg++) xNegBand[iNeg]=kTRUE;
3250 for(UInt_t iPos=0; iPos < sizeP; iPos++) xPosBand[iPos]=kTRUE;
3251 for(UInt_t iGam=0; iGam < sizeG; iGam++) gammaBand[iGam]=kTRUE;
3254 for(UInt_t iPos=0; iPos < sizeP; iPos++){
3257 ((AliESDtrack*)(positiveElectrons.At(iPos)))->GetConstrainedPxPyPz(aP);
3259 TVector3 ePosV(aP[0],aP[1],aP[2]);
3261 for(UInt_t iNeg=0; iNeg < sizeN; iNeg++){
3264 ((AliESDtrack*)(negativeElectrons.At(iNeg)))->GetConstrainedPxPyPz(aN);
3265 TVector3 eNegV(aN[0],aN[1],aN[2]);
3267 if(ePosV.Angle(eNegV) < 0.05){ //e+e- from gamma
3268 xPosBand[iPos]=kFALSE;
3269 xNegBand[iNeg]=kFALSE;
3272 for(UInt_t iGam=0; iGam < sizeG; iGam++){
3273 AliKFParticle* gammaCandidate = (AliKFParticle*)gammas.At(iGam);
3274 TVector3 gammaCandidateVector(gammaCandidate->Px(),gammaCandidate->Py(),gammaCandidate->Pz());
3275 if(ePosV.Angle(gammaCandidateVector) < 0.05 || eNegV.Angle(gammaCandidateVector) < 0.05)
3276 gammaBand[iGam]=kFALSE;
3284 for(UInt_t iPos=0; iPos < sizeP; iPos++){
3286 new((*fCurrentEventPosElectronTClone)[fCurrentEventPosElectronTClone->GetEntriesFast()]) AliESDtrack((*(AliESDtrack*)(positiveElectrons.At(iPos))));
3287 // fCurrentEventPosElectron.push_back(positiveElectrons[iPos]);
3290 for(UInt_t iNeg=0;iNeg < sizeN; iNeg++){
3292 new((*fCurrentEventNegElectronTClone)[fCurrentEventNegElectronTClone->GetEntriesFast()]) AliESDtrack((*(AliESDtrack*)(negativeElectrons.At(iNeg))));
3293 // fCurrentEventNegElectron.push_back(negativeElectrons[iNeg]);
3296 for(UInt_t iGam=0; iGam < sizeG; iGam++){
3297 if(gammaBand[iGam]){
3298 new((*fKFReconstructedGammasCutTClone)[fKFReconstructedGammasCutTClone->GetEntriesFast()]) AliKFParticle((*(AliKFParticle*)(gammas.At(iGam))));
3299 //fKFReconstructedGammasCut.push_back(*(AliKFParticle*)gammas->At(iGam));
3305 void AliAnalysisTaskGammaConversion::GetPID(AliESDtrack *track, Stat_t &pid, Stat_t &weight)
3307 // see header file for documentation
3312 double wpartbayes[5];
3314 //get probability of the diffenrent particle types
3315 track->GetESDpid(wpart);
3317 // Tentative particle type "concentrations"
3318 double c[5]={0.01, 0.01, 0.85, 0.10, 0.05};
3322 for (int i = 0; i < 5; i++)
3324 rcc+=(c[i] * wpart[i]);
3329 for (int i=0; i<5; i++) {
3330 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)
3331 wpartbayes[i] = c[i] * wpart[i] / rcc;
3339 //find most probable particle in ESD pid
3340 //0:Electron - 1:Muon - 2:Pion - 3:Kaon - 4:Proton
3341 for (int i = 0; i < 5; i++)
3343 if (wpartbayes[i] > max)
3346 max = wpartbayes[i];
3353 double AliAnalysisTaskGammaConversion::GetSigmaToVertex(AliESDtrack* t)
3355 // Calculates the number of sigma to the vertex.
3360 t->GetImpactParameters(b,bCov);
3361 if (bCov[0]<=0 || bCov[2]<=0) {
3362 AliDebug(1, "Estimated b resolution lower or equal zero!");
3363 bCov[0]=0; bCov[2]=0;
3365 bRes[0] = TMath::Sqrt(bCov[0]);
3366 bRes[1] = TMath::Sqrt(bCov[2]);
3368 // -----------------------------------
3369 // How to get to a n-sigma cut?
3371 // The accumulated statistics from 0 to d is
3373 // -> Erf(d/Sqrt(2)) for a 1-dim gauss (d = n_sigma)
3374 // -> 1 - Exp(-d**2) for a 2-dim gauss (d*d = dx*dx + dy*dy != n_sigma)
3376 // It means that for a 2-dim gauss: n_sigma(d) = Sqrt(2)*ErfInv(1 - Exp((-x**2)/2)
3377 // Can this be expressed in a different way?
3379 if (bRes[0] == 0 || bRes[1] ==0)
3382 double d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
3384 // stupid rounding problem screws up everything:
3385 // if d is too big, TMath::Exp(...) gets 0, and TMath::ErfInverse(1) that should be infinite, gets 0 :(
3386 if (TMath::Exp(-d * d / 2) < 1e-10)
3390 d = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);
3394 //vector <TLorentzVector> AliAnalysisTaskGammaConversion::GetTLorentzVector(vector <AliESDtrack*> esdTrack){
3395 TClonesArray AliAnalysisTaskGammaConversion::GetTLorentzVector(TClonesArray *const esdTrack){
3396 //Return TLoresntz vector of track?
3397 // vector <TLorentzVector> tlVtrack(0);
3398 TClonesArray array("TLorentzVector",0);
3400 for(Int_t itrack=0; itrack < esdTrack->GetEntriesFast(); itrack++){
3402 //esdTrack[itrack]->GetConstrainedPxPyPz(p);
3403 ((AliESDtrack*)(esdTrack->At(itrack)))->GetConstrainedPxPyPz(p);
3404 TLorentzVector currentTrack;
3405 currentTrack.SetXYZM(p[0],p[1],p[2],fElectronMass);
3406 new((array)[array.GetEntriesFast()]) TLorentzVector(currentTrack);
3407 // tlVtrack.push_back(currentTrack);