1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: Ana Marin, Kathrin Koch, Kenneth Aamodt *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 ////////////////////////////////////////////////
17 //---------------------------------------------
18 // Class used to do analysis on conversion pairs
19 //---------------------------------------------
20 ////////////////////////////////////////////////
26 #include "AliAnalysisTaskGammaConversion.h"
29 #include "AliESDtrackCuts.h"
31 //#include "AliCFManager.h" // for CF
32 //#include "AliCFContainer.h" // for CF
33 #include "AliESDInputHandler.h"
34 #include "AliAnalysisManager.h"
35 #include "AliAODPWG4Particle.h"
36 #include "AliAODPWG4ParticleCorrelation.h"
37 #include "AliGammaConversionAODObject.h"
38 #include "AliAODConversionParticle.h"
39 #include "AliGammaConversionBGHandler.h"
40 #include "AliESDCaloCluster.h" // for combining PHOS and GammaConv
41 #include "AliKFVertex.h"
42 #include "AliGenPythiaEventHeader.h"
43 #include "AliGenDPMjetEventHeader.h"
44 #include "AliGenEventHeader.h"
45 #include <AliMCEventHandler.h>
47 #include "AliTriggerAnalysis.h"
48 #include "AliCentrality.h"
50 class AliESDTrackCuts;
58 class AliMCEventHandler;
59 class AliESDInputHandler;
60 class AliAnalysisManager;
67 ClassImp(AliAnalysisTaskGammaConversion)
70 AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion():
74 fMCTruth(NULL), // for CF
75 fGCMCEvent(NULL), // for CF
77 fOutputContainer(NULL),
78 fCFManager(0x0), // for CF
80 fTriggerCINT1B(kFALSE),
82 fDoNeutralMeson(kFALSE),
83 fDoOmegaMeson(kFALSE),
86 fRecalculateV0ForGamma(kFALSE),
87 fKFReconstructedGammasTClone(NULL),
88 fKFReconstructedPi0sTClone(NULL),
89 fKFRecalculatedGammasTClone(NULL),
90 fCurrentEventPosElectronTClone(NULL),
91 fCurrentEventNegElectronTClone(NULL),
92 fKFReconstructedGammasCutTClone(NULL),
93 fPreviousEventTLVNegElectronTClone(NULL),
94 fPreviousEventTLVPosElectronTClone(NULL),
99 fElectronRecalculatedv1(),
100 fElectronRecalculatedv2(),
108 fMinOpeningAngleGhostCut(0.),
110 fCalculateBackground(kFALSE),
111 fWriteNtuple(kFALSE),
113 fNeutralMesonNtuple(NULL),
114 fTotalNumberOfAddedNtupleEntries(0),
115 fChargedParticles(NULL),
116 fChargedParticlesId(),
118 fMinPtForGammaJet(1.),
119 fMinIsoConeSize(0.2),
121 fMinPtGamChargedCorr(0.5),
123 fLeadingChargedIndex(-1),
130 fAODBranchName("GammaConv"),
131 fOutputAODClassName("AliAODConversionParticle"),
134 fKFDeltaAODFileName(""),
135 fDoNeutralMesonV0MCCheck(kFALSE),
136 fUseTrackMultiplicityForBG(kTRUE),
137 fMoveParticleAccordingToVertex(kFALSE),
138 fApplyChi2Cut(kFALSE),
139 fNRandomEventsForBG(15),
140 fNDegreesPMBackground(15),
142 fCheckBGProbability(kTRUE),
143 fKFReconstructedGammasV0Index(),
144 fRemovePileUp(kFALSE),
145 fSelectV0AND(kFALSE),
146 fTriggerAnalysis(NULL),
149 fUseMultiplicityBin(0),
153 // Default constructor
155 /* Kenneth: the default constructor should not have any define input/output or the call to SetESDtrackCuts
156 // Common I/O in slot 0
157 DefineInput (0, TChain::Class());
158 DefineOutput(0, TTree::Class());
160 // Your private output
161 DefineOutput(1, TList::Class());
163 // Define standard ESD track cuts for Gamma-hadron correlation
168 AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion(const char* name):
169 AliAnalysisTaskSE(name),
172 fMCTruth(NULL), // for CF
173 fGCMCEvent(NULL), // for CF
175 fOutputContainer(0x0),
176 fCFManager(0x0), // for CF
178 fTriggerCINT1B(kFALSE),
180 fDoNeutralMeson(kFALSE),
181 fDoOmegaMeson(kFALSE),
184 fRecalculateV0ForGamma(kFALSE),
185 fKFReconstructedGammasTClone(NULL),
186 fKFReconstructedPi0sTClone(NULL),
187 fKFRecalculatedGammasTClone(NULL),
188 fCurrentEventPosElectronTClone(NULL),
189 fCurrentEventNegElectronTClone(NULL),
190 fKFReconstructedGammasCutTClone(NULL),
191 fPreviousEventTLVNegElectronTClone(NULL),
192 fPreviousEventTLVPosElectronTClone(NULL),
197 fElectronRecalculatedv1(),
198 fElectronRecalculatedv2(),
206 fMinOpeningAngleGhostCut(0.),
208 fCalculateBackground(kFALSE),
209 fWriteNtuple(kFALSE),
211 fNeutralMesonNtuple(NULL),
212 fTotalNumberOfAddedNtupleEntries(0),
213 fChargedParticles(NULL),
214 fChargedParticlesId(),
216 fMinPtForGammaJet(1.),
217 fMinIsoConeSize(0.2),
219 fMinPtGamChargedCorr(0.5),
221 fLeadingChargedIndex(-1),
228 fAODBranchName("GammaConv"),
229 fOutputAODClassName("AliAODConversionParticle"),
232 fKFDeltaAODFileName(""),
233 fDoNeutralMesonV0MCCheck(kFALSE),
234 fUseTrackMultiplicityForBG(kTRUE),
235 fMoveParticleAccordingToVertex(kFALSE),
236 fApplyChi2Cut(kFALSE),
237 fNRandomEventsForBG(15),
238 fNDegreesPMBackground(15),
240 fCheckBGProbability(kTRUE),
241 fKFReconstructedGammasV0Index(),
242 fRemovePileUp(kFALSE),
243 fSelectV0AND(kFALSE),
244 fTriggerAnalysis(NULL),
247 fUseMultiplicityBin(0),
251 // Common I/O in slot 0
252 DefineInput (0, TChain::Class());
253 DefineOutput(0, TTree::Class());
255 // Your private output
256 DefineOutput(1, TList::Class());
257 DefineOutput(2, AliCFContainer::Class()); // for CF
260 // Define standard ESD track cuts for Gamma-hadron correlation
265 AliAnalysisTaskGammaConversion::~AliAnalysisTaskGammaConversion()
267 // Remove all pointers
269 if(fOutputContainer){
270 fOutputContainer->Clear() ;
271 delete fOutputContainer ;
286 delete fEsdTrackCuts;
308 if(fTriggerAnalysis) {
309 delete fTriggerAnalysis;
316 void AliAnalysisTaskGammaConversion::Init()
319 // AliLog::SetGlobalLogLevel(AliLog::kError);
321 void AliAnalysisTaskGammaConversion::SetESDtrackCuts()
324 if (fEsdTrackCuts!=NULL){
325 delete fEsdTrackCuts;
327 fEsdTrackCuts = new AliESDtrackCuts("AliESDtrackCuts");
328 //standard cuts from:
329 //http://aliceinfo.cern.ch/alicvs/viewvc/PWG0/dNdEta/CreateCuts.C?revision=1.4&view=markup
331 // Cuts used up to 3rd of March
333 // fEsdTrackCuts->SetMinNClustersTPC(50);
334 // fEsdTrackCuts->SetMaxChi2PerClusterTPC(3.5);
335 // fEsdTrackCuts->SetRequireTPCRefit(kTRUE);
336 // fEsdTrackCuts->SetRequireITSRefit(kTRUE);
337 // fEsdTrackCuts->SetMaxNsigmaToVertex(3);
338 // fEsdTrackCuts->SetRequireSigmaToVertex(kTRUE);
340 //------- To be tested-----------
341 // Cuts used up to 26th of Agost
342 // Int_t minNClustersTPC = 70;
343 // Double_t maxChi2PerClusterTPC = 4.0;
344 // Double_t maxDCAtoVertexXY = 2.4; // cm
345 // Double_t maxDCAtoVertexZ = 3.2; // cm
346 // fEsdTrackCuts->SetRequireSigmaToVertex(kFALSE);
347 // fEsdTrackCuts->SetRequireTPCRefit(kTRUE);
348 // fEsdTrackCuts->SetRequireITSRefit(kTRUE);
349 // // fEsdTrackCuts->SetRequireTPCStandAlone(kTRUE);
350 // fEsdTrackCuts->SetAcceptKinkDaughters(kFALSE);
351 // fEsdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
352 // fEsdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
353 // fEsdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
354 // fEsdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
355 // fEsdTrackCuts->SetDCAToVertex2D(kTRUE);
356 // fEsdTrackCuts->SetEtaRange(-0.8, 0.8);
357 // fEsdTrackCuts->SetPtRange(0.15);
359 // fEsdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kFirst);
362 // Using standard function for setting Cuts
363 Bool_t selectPrimaries=kTRUE;
364 fEsdTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(selectPrimaries);
365 fEsdTrackCuts->SetMaxDCAToVertexZ(2);
366 fEsdTrackCuts->SetEtaRange(-0.8, 0.8);
367 fEsdTrackCuts->SetPtRange(0.15);
369 //----- From Jacek 10.03.03 ------------------/
370 // minNClustersTPC = 70;
371 // maxChi2PerClusterTPC = 4.0;
372 // maxDCAtoVertexXY = 2.4; // cm
373 // maxDCAtoVertexZ = 3.2; // cm
375 // esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
376 // esdTrackCuts->SetRequireTPCRefit(kFALSE);
377 // esdTrackCuts->SetRequireTPCStandAlone(kTRUE);
378 // esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
379 // esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
380 // esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
381 // esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
382 // esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
383 // esdTrackCuts->SetDCAToVertex2D(kTRUE);
387 // fEsdTrackCuts->SetAcceptKinkDaughters(kFALSE);
388 // fV0Reader->SetESDtrackCuts(fEsdTrackCuts);
391 void AliAnalysisTaskGammaConversion::UserExec(Option_t */*option*/)
393 // Execute analysis for current event
395 // Load the esdpid from the esdhandler if exists (tender was applied) otherwise set the Bethe Bloch parameters
396 Int_t eventQuality=-1;
398 AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
399 AliESDInputHandler *esdHandler=0x0;
400 if ( (esdHandler=dynamic_cast<AliESDInputHandler*>(man->GetInputEventHandler())) && esdHandler->GetESDpid() ){
401 AliV0Reader::SetESDpid(esdHandler->GetESDpid());
403 //load esd pid bethe bloch parameters depending on the existance of the MC handler
404 // yes: MC parameters
405 // no: data parameters
406 if (!AliV0Reader::GetESDpid()){
408 AliV0Reader::InitESDpid();
410 AliV0Reader::InitESDpid(1);
415 //Must set fForceAOD to true for the AOD to get filled. Should only be done when running independent chain / train.
417 if (!AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()) AliFatal("Cannot run ESD filter without an output event handler");
418 AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kTRUE);
421 if(fV0Reader == NULL){
422 // Write warning here cuts and so on are default if this ever happens
426 // To avoid crashes due to unzip errors. Sometimes the trees are not there.
428 AliMCEventHandler* mcHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
430 AliError("Could not retrive MC event handler!");
434 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
436 if (!mcHandler->InitOk() ){
438 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
441 if (!mcHandler->TreeK() ){
443 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
446 if (!mcHandler->TreeTR() ) {
448 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
453 fV0Reader->SetInputAndMCEvent(InputEvent(), MCEvent());
455 fV0Reader->Initialize();
456 fDoMCTruth = fV0Reader->GetDoMCTruth();
458 if(fAODGamma) fAODGamma->Delete();
459 if(fAODPi0) fAODPi0->Delete();
460 if(fAODOmega) fAODOmega->Delete();
462 if(fKFReconstructedGammasTClone == NULL){
463 fKFReconstructedGammasTClone = new TClonesArray("AliKFParticle",0);
465 if(fCurrentEventPosElectronTClone == NULL){
466 fCurrentEventPosElectronTClone = new TClonesArray("AliESDtrack",0);
468 if(fCurrentEventNegElectronTClone == NULL){
469 fCurrentEventNegElectronTClone = new TClonesArray("AliESDtrack",0);
471 if(fKFReconstructedGammasCutTClone == NULL){
472 fKFReconstructedGammasCutTClone = new TClonesArray("AliKFParticle",0);
474 if(fPreviousEventTLVNegElectronTClone == NULL){
475 fPreviousEventTLVNegElectronTClone = new TClonesArray("TLorentzVector",0);
477 if(fPreviousEventTLVPosElectronTClone == NULL){
478 fPreviousEventTLVPosElectronTClone = new TClonesArray("TLorentzVector",0);
480 if(fChargedParticles == NULL){
481 fChargedParticles = new TClonesArray("AliESDtrack",0);
484 if(fKFReconstructedPi0sTClone == NULL){
485 fKFReconstructedPi0sTClone = new TClonesArray("AliKFParticle",0);
488 if(fKFRecalculatedGammasTClone == NULL){
489 fKFRecalculatedGammasTClone = new TClonesArray("AliKFParticle",0);
492 if(fTriggerAnalysis== NULL){
493 fTriggerAnalysis = new AliTriggerAnalysis;
497 fKFReconstructedGammasTClone->Delete();
498 fCurrentEventPosElectronTClone->Delete();
499 fCurrentEventNegElectronTClone->Delete();
500 fKFReconstructedGammasCutTClone->Delete();
501 fPreviousEventTLVNegElectronTClone->Delete();
502 fPreviousEventTLVPosElectronTClone->Delete();
503 fKFReconstructedPi0sTClone->Delete();
504 fKFRecalculatedGammasTClone->Delete();
513 fElectronRecalculatedv1.clear();
514 fElectronRecalculatedv2.clear();
517 fChargedParticles->Delete();
519 fChargedParticlesId.clear();
521 fKFReconstructedGammasV0Index.clear();
523 //Clear the data in the v0Reader
524 // fV0Reader->UpdateEventByEventData();
526 //Take Only events with proper trigger
529 if(!fV0Reader->GetESDEvent()->IsTriggerClassFired("CINT1B-ABCE-NOPF-ALL")) return;
533 if(fV0Reader->CheckForPrimaryVertex() == kFALSE){
534 // cout<< "Event not taken"<< endl;
536 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
538 CheckMesonProcessTypeEventQuality(eventQuality);
540 return; // aborts if the primary vertex does not have contributors.
544 if(!fV0Reader->CheckForPrimaryVertexZ() ){
546 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
548 CheckMesonProcessTypeEventQuality(eventQuality);
553 if(fRemovePileUp && fV0Reader->GetESDEvent()->IsPileupFromSPD()) {
555 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
559 Bool_t v0A = fTriggerAnalysis->IsOfflineTriggerFired(fV0Reader->GetESDEvent(), AliTriggerAnalysis::kV0A);
560 Bool_t v0C = fTriggerAnalysis->IsOfflineTriggerFired(fV0Reader->GetESDEvent(), AliTriggerAnalysis::kV0C);
561 Bool_t v0AND = v0A && v0C;
563 if(fSelectV0AND && !v0AND){
565 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
567 CheckMesonProcessTypeEventQuality(eventQuality);
572 fMultiplicity = fEsdTrackCuts->CountAcceptedTracks(fV0Reader->GetESDEvent());
574 if( CalculateMultiplicityBin() != fUseMultiplicityBin){
576 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
580 if(fV0Reader->GetIsHeavyIon()){
581 if(fUseCentrality>0){
582 AliCentrality *esdCentrality = fV0Reader->GetESDEvent()->GetCentrality();
583 Int_t centralityC = -1;
585 if(fUseCentrality==1){
586 centralityC = esdCentrality->GetCentralityClass10("V0M");
587 if( centralityC != fUseCentralityBin ){
589 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
594 if(fUseCentrality==2){
595 centralityC = esdCentrality->GetCentralityClass10("CL1");
596 if( centralityC != fUseCentralityBin ){
598 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
605 fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
609 fHistograms->FillHistogram("ESD_NumberOfGoodESDTracks",fMultiplicity);
610 if (fV0Reader->GetNumberOfContributorsVtx()>=1){
611 fHistograms->FillHistogram("ESD_NumberOfGoodESDTracksVtx",fMultiplicity);
616 // Process the MC information
621 //Process the v0 information with no cuts
624 // Process the v0 information
630 FillAODWithConversionGammas() ;
634 // Process reconstructed gammas
635 if(fDoNeutralMeson == kTRUE){
636 ProcessGammasForNeutralMesonAnalysis();
640 if(fDoMCTruth == kTRUE){
643 //Process reconstructed gammas electrons for Chi_c Analysis
644 if(fDoChic == kTRUE){
645 ProcessGammaElectronsForChicAnalysis();
647 // Process reconstructed gammas for gamma Jet/hadron correlations
649 ProcessGammasForGammaJetAnalysis();
652 //calculate background if flag is set
653 if(fCalculateBackground){
654 CalculateBackground();
657 if(fDoNeutralMeson == kTRUE){
658 // ProcessConvPHOSGammasForNeutralMesonAnalysis();
659 if(fDoOmegaMeson == kTRUE){
660 ProcessGammasForOmegaMesonAnalysis();
664 //Clear the data in the v0Reader
665 fV0Reader->UpdateEventByEventData();
666 if(fRecalculateV0ForGamma==kTRUE){
667 RecalculateV0ForGamma();
669 PostData(1, fOutputContainer);
670 PostData(2, fCFManager->GetParticleContainer()); // for CF
674 // void AliAnalysisTaskGammaConversion::ConnectInputData(Option_t *option){
675 // // see header file for documentation
676 // // printf(" ConnectInputData %s\n", GetName());
678 // AliAnalysisTaskSE::ConnectInputData(option);
680 // if(fV0Reader == NULL){
681 // // Write warning here cuts and so on are default if this ever happens
683 // fV0Reader->Initialize();
684 // fDoMCTruth = fV0Reader->GetDoMCTruth();
687 void AliAnalysisTaskGammaConversion::CheckMesonProcessTypeEventQuality(Int_t evtQ){
688 // Check meson process type event quality
689 fStack= MCEvent()->Stack();
690 fGCMCEvent=MCEvent();
692 for (Int_t iTracks = 0; iTracks < fStack->GetNprimary(); iTracks++) {
693 TParticle* particle = (TParticle *)fStack->Particle(iTracks);
698 if(particle->GetPdgCode()!=111){ //Pi0
703 if(particle->Energy() - particle->Pz() == 0 || particle->Energy() + particle->Pz() == 0){
707 rapidity = 0.5*(TMath::Log((particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz())));
710 if(TMath::Abs(rapidity) > fV0Reader->GetRapidityMesonCut() ) continue;
713 switch(GetProcessType(fGCMCEvent)){
715 fHistograms->FillHistogram("MC_SD_EvtQ1_Pi0_Pt", particle->Pt());
718 fHistograms->FillHistogram("MC_DD_EvtQ1_Pi0_Pt", particle->Pt());
721 fHistograms->FillHistogram("MC_ND_EvtQ1_Pi0_Pt", particle->Pt());
724 AliError("Unknown Process");
728 switch(GetProcessType(fGCMCEvent)){
730 fHistograms->FillHistogram("MC_SD_EvtQ2_Pi0_Pt", particle->Pt());
733 fHistograms->FillHistogram("MC_DD_EvtQ2_Pi0_Pt", particle->Pt());
736 fHistograms->FillHistogram("MC_ND_EvtQ2_Pi0_Pt", particle->Pt());
739 AliError("Unknown Process");
744 switch(GetProcessType(fGCMCEvent)){
746 fHistograms->FillHistogram("MC_SD_EvtQ4_Pi0_Pt", particle->Pt());
749 fHistograms->FillHistogram("MC_DD_EvtQ4_Pi0_Pt", particle->Pt());
752 fHistograms->FillHistogram("MC_ND_EvtQ4_Pi0_Pt", particle->Pt());
755 AliError("Unknown Process");
760 switch(GetProcessType(fGCMCEvent)){
762 fHistograms->FillHistogram("MC_SD_EvtQ5_Pi0_Pt", particle->Pt());
765 fHistograms->FillHistogram("MC_DD_EvtQ5_Pi0_Pt", particle->Pt());
768 fHistograms->FillHistogram("MC_ND_EvtQ5_Pi0_Pt", particle->Pt());
771 AliError("Unknown Process");
779 void AliAnalysisTaskGammaConversion::ProcessMCData(){
780 // see header file for documentation
781 //InputEvent(), MCEvent());
783 fStack = fV0Reader->GetMCStack();
784 fMCTruth = fV0Reader->GetMCTruth(); // for CF
785 fGCMCEvent = fV0Reader->GetMCEvent(); // for CF
787 fStack= MCEvent()->Stack();
788 fGCMCEvent=MCEvent();
791 Double_t containerInput[3];
793 if(!fGCMCEvent) cout << "NO MC INFO FOUND" << endl;
794 fCFManager->SetEventInfo(fGCMCEvent);
799 if(fV0Reader->CheckForPrimaryVertex() == kFALSE){
800 return; // aborts if the primary vertex does not have contributors.
802 for (Int_t iTracks = 0; iTracks < fStack->GetNprimary(); iTracks++) {
803 // for (Int_t iTracks = 0; iTracks < fStack->GetNtrack(); iTracks++) {
804 TParticle* particle = (TParticle *)fStack->Particle(iTracks);
813 ///////////////////////Begin Chic Analysis/////////////////////////////
815 if(particle->GetPdgCode() == 443){//Is JPsi
816 if(particle->GetNDaughters()==2){
817 if(TMath::Abs(fStack->Particle(particle->GetFirstDaughter())->GetPdgCode()) == 11 &&
818 TMath::Abs(fStack->Particle(particle->GetLastDaughter())->GetPdgCode()) == 11){
820 TParticle* daug0 = fStack->Particle(particle->GetFirstDaughter());
821 TParticle* daug1 = fStack->Particle(particle->GetLastDaughter());
822 if(TMath::Abs(daug0->Eta()) < 0.9 && TMath::Abs(daug1->Eta()) < 0.9)
823 fHistograms->FillTable("Table_Electrons",3);//e+ e- from J/Psi inside acceptance
825 if( TMath::Abs(daug0->Eta()) < 0.9){
826 if(daug0->GetPdgCode() == -11)
827 fHistograms->FillTable("Table_Electrons",1);//e+ from J/Psi inside acceptance
829 fHistograms->FillTable("Table_Electrons",2);//e- from J/Psi inside acceptance
832 if(TMath::Abs(daug1->Eta()) < 0.9){
833 if(daug1->GetPdgCode() == -11)
834 fHistograms->FillTable("Table_Electrons",1);//e+ from J/Psi inside acceptance
836 fHistograms->FillTable("Table_Electrons",2);//e- from J/Psi inside acceptance
841 // const int CHI_C0 = 10441;
842 // const int CHI_C1 = 20443;
843 // const int CHI_C2 = 445
844 if(particle->GetPdgCode() == 22){//gamma from JPsi
845 if(particle->GetMother(0) > -1){
846 if(fStack->Particle(particle->GetMother(0))->GetPdgCode() == 10441 ||
847 fStack->Particle(particle->GetMother(0))->GetPdgCode() == 20443 ||
848 fStack->Particle(particle->GetMother(0))->GetPdgCode() == 445){
849 if(TMath::Abs(particle->Eta()) < 1.2)
850 fHistograms->FillTable("Table_Electrons",17);// gamma from chic inside accptance
854 if(particle->GetPdgCode() == 10441 || particle->GetPdgCode() == 20443 || particle->GetPdgCode() == 445){
855 if( particle->GetNDaughters() == 2){
856 TParticle* daug0 = fStack->Particle(particle->GetFirstDaughter());
857 TParticle* daug1 = fStack->Particle(particle->GetLastDaughter());
859 if( (daug0->GetPdgCode() == 443 || daug0->GetPdgCode() == 22) && (daug1->GetPdgCode() == 443 || daug1->GetPdgCode() == 22) ){
860 if( daug0->GetPdgCode() == 443){
861 TParticle* daugE0 = fStack->Particle(daug0->GetFirstDaughter());
862 TParticle* daugE1 = fStack->Particle(daug0->GetLastDaughter());
863 if( TMath::Abs(daug1->Eta()) < 1.2 && TMath::Abs(daugE0->Eta()) < 0.9 && TMath::Abs(daugE1->Eta()) < 0.9 )
864 fHistograms->FillTable("Table_Electrons",18);
867 else if (daug1->GetPdgCode() == 443){
868 TParticle* daugE0 = fStack->Particle(daug1->GetFirstDaughter());
869 TParticle* daugE1 = fStack->Particle(daug1->GetLastDaughter());
870 if( TMath::Abs(daug0->Eta()) < 1.2 && TMath::Abs(daugE0->Eta()) < 0.9 && TMath::Abs(daugE1->Eta()) < 0.9 )
871 fHistograms->FillTable("Table_Electrons",18);
878 /////////////////////End Chic Analysis////////////////////////////
881 // if(TMath::Abs(particle->Eta())> fV0Reader->GetEtaCut() ) continue;
883 if(particle->R()>fV0Reader->GetMaxRCut()) continue; // cuts on distance from collision point
885 Double_t tmpPhi=particle->Phi();
887 if(particle->Phi()> TMath::Pi()){
888 tmpPhi = particle->Phi()-(2*TMath::Pi());
892 if(particle->Energy() - particle->Pz() == 0 || particle->Energy() + particle->Pz() == 0){
896 rapidity = 0.5*(TMath::Log((particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz())));
901 if(iTracks<=fStack->GetNprimary() ){
902 if ( particle->GetPdgCode()== -211 || particle->GetPdgCode()== 211 ||
903 particle->GetPdgCode()== 2212 || particle->GetPdgCode()==-2212 ||
904 particle->GetPdgCode()== 321 || particle->GetPdgCode()==-321 ){
905 if(TMath::Abs(particle->Eta())> fV0Reader->GetEtaCut() ) continue;
906 fHistograms->FillHistogram("MC_PhysicalPrimaryCharged_Pt", particle->Pt());
913 if (particle->GetPdgCode() == 22){
914 if(TMath::Abs(particle->Eta())> fV0Reader->GetEtaCut() ) continue;
916 if(particle->GetMother(0) >-1 && fStack->Particle(particle->GetMother(0))->GetPdgCode() == 22){
917 continue; // no photon as mothers!
920 if(particle->GetMother(0) >= fStack->GetNprimary()){
921 continue; // the gamma has a mother, and it is not a primary particle
924 if(particle->GetMother(0) >-1){
925 fHistograms->FillHistogram("MC_DecayAllGamma_Pt", particle->Pt()); // All
926 switch(fStack->Particle(particle->GetMother(0))->GetPdgCode()){
928 fHistograms->FillHistogram("MC_DecayPi0Gamma_Pt", particle->Pt());
931 fHistograms->FillHistogram("MC_DecayRho0Gamma_Pt", particle->Pt());
934 fHistograms->FillHistogram("MC_DecayEtaGamma_Pt", particle->Pt());
937 fHistograms->FillHistogram("MC_DecayOmegaGamma_Pt", particle->Pt());
940 fHistograms->FillHistogram("MC_DecayK0sGamma_Pt", particle->Pt());
943 fHistograms->FillHistogram("MC_DecayEtapGamma_Pt", particle->Pt());
946 fHistograms->FillHistogram("MC_DecayPhiGamma_Pt", particle->Pt());
951 fHistograms->FillHistogram("MC_allGamma_Energy", particle->Energy());
952 fHistograms->FillHistogram("MC_allGamma_Pt", particle->Pt());
953 fHistograms->FillHistogram("MC_allGamma_Eta", particle->Eta());
954 fHistograms->FillHistogram("MC_allGamma_Phi", tmpPhi);
955 fHistograms->FillHistogram("MC_allGamma_Rapid", rapidity);
959 containerInput[0] = particle->Pt();
960 containerInput[1] = particle->Eta();
961 if(particle->GetMother(0) >=0){
962 containerInput[2] = fStack->Particle(particle->GetMother(0))->GetMass();
965 containerInput[2]=-1;
968 fCFManager->GetParticleContainer()->Fill(containerInput,kStepGenerated); // generated gamma
970 if(particle->GetMother(0) < 0 || //Phojet p+p -> Direct Photons have no mother
971 ((particle->GetMother(0) > -1) &&
972 (TMath::Abs(fStack->Particle(particle->GetMother(0))->GetPdgCode()) < 10)) //Pythia p+p -> Direct Photons have quarks as mother
974 fHistograms->FillHistogram("MC_allDirectGamma_Energy",particle->Energy());
975 fHistograms->FillHistogram("MC_allDirectGamma_Pt", particle->Pt());
976 fHistograms->FillHistogram("MC_allDirectGamma_Eta", particle->Eta());
977 fHistograms->FillHistogram("MC_allDirectGamma_Phi", tmpPhi);
978 fHistograms->FillHistogram("MC_allDirectGamma_Rapid", rapidity);
981 // looking for conversion (electron + positron from pairbuilding (= 5) )
982 TParticle* ePos = NULL;
983 TParticle* eNeg = NULL;
985 if(particle->GetNDaughters() >= 2){
986 for(Int_t daughterIndex=particle->GetFirstDaughter();daughterIndex<=particle->GetLastDaughter();daughterIndex++){
987 TParticle *tmpDaughter = fStack->Particle(daughterIndex);
988 if(tmpDaughter->GetUniqueID() == 5){
989 if(tmpDaughter->GetPdgCode() == 11){
992 else if(tmpDaughter->GetPdgCode() == -11){
1000 if(ePos == NULL || eNeg == NULL){ // means we do not have two daughters from pair production
1005 Double_t ePosPhi = ePos->Phi();
1006 if(ePos->Phi()> TMath::Pi()) ePosPhi = ePos->Phi()-(2*TMath::Pi());
1008 Double_t eNegPhi = eNeg->Phi();
1009 if(eNeg->Phi()> TMath::Pi()) eNegPhi = eNeg->Phi()-(2*TMath::Pi());
1012 if(ePos->Pt()<fV0Reader->GetPtCut() || eNeg->Pt()<fV0Reader->GetPtCut()){
1013 continue; // no reconstruction below the Pt cut
1016 if(TMath::Abs(ePos->Eta())> fV0Reader->GetEtaCut() || TMath::Abs(eNeg->Eta())> fV0Reader->GetEtaCut()){
1020 if(ePos->R()>fV0Reader->GetMaxRCut()){
1021 continue; // cuts on distance from collision point
1024 if(TMath::Abs(ePos->Vz()) > fV0Reader->GetMaxZCut()){
1025 continue; // outside material
1029 if((TMath::Abs(ePos->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue() > ePos->R()){
1030 continue; // line cut to exclude regions where we do not reconstruct
1036 fCFManager->GetParticleContainer()->Fill(containerInput,kStepReconstructable); // reconstructable gamma
1038 fHistograms->FillHistogram("MC_ConvGamma_Energy", particle->Energy());
1039 fHistograms->FillHistogram("MC_ConvGamma_Pt", particle->Pt());
1040 fHistograms->FillHistogram("MC_ConvGamma_Eta", particle->Eta());
1041 fHistograms->FillHistogram("MC_ConvGamma_Phi", tmpPhi);
1042 fHistograms->FillHistogram("MC_ConvGamma_Rapid", rapidity);
1043 fHistograms->FillHistogram("MC_ConvGamma_Pt_Eta", particle->Pt(),particle->Eta());
1045 fHistograms->FillHistogram("MC_E_Energy", eNeg->Energy());
1046 fHistograms->FillHistogram("MC_E_Pt", eNeg->Pt());
1047 fHistograms->FillHistogram("MC_E_Eta", eNeg->Eta());
1048 fHistograms->FillHistogram("MC_E_Phi", eNegPhi);
1050 fHistograms->FillHistogram("MC_P_Energy", ePos->Energy());
1051 fHistograms->FillHistogram("MC_P_Pt", ePos->Pt());
1052 fHistograms->FillHistogram("MC_P_Eta", ePos->Eta());
1053 fHistograms->FillHistogram("MC_P_Phi", ePosPhi);
1057 Int_t rBin = fHistograms->GetRBin(ePos->R());
1058 Int_t zBin = fHistograms->GetZBin(ePos->Vz());
1059 Int_t phiBin = fHistograms->GetPhiBin(particle->Phi());
1061 Double_t rITSTPCMin=50;
1062 Double_t rITSTPCMax=80;
1064 TVector3 vtxPos(ePos->Vx(),ePos->Vy(),ePos->Vz());
1066 TString nameMCMappingPhiR="";
1067 nameMCMappingPhiR.Form("MC_Conversion_Mapping_Phi%02d_R%02d",phiBin,rBin);
1068 // fHistograms->FillHistogram(nameMCMappingPhiR, ePos->Vz(), particle->Eta());
1070 TString nameMCMappingPhi="";
1071 nameMCMappingPhi.Form("MC_Conversion_Mapping_Phi%02d",phiBin);
1072 // fHistograms->FillHistogram(nameMCMappingPhi, particle->Eta());
1073 //fHistograms->FillHistogram(nameMCMappingPhi, ePos->Vz(), particle->Eta());
1075 TString nameMCMappingR="";
1076 nameMCMappingR.Form("MC_Conversion_Mapping_R%02d",rBin);
1077 // fHistograms->FillHistogram(nameMCMappingR, particle->Eta());
1078 //fHistograms->FillHistogram(nameMCMappingR,ePos->Vz(), particle->Eta());
1080 TString nameMCMappingPhiInR="";
1081 nameMCMappingPhiInR.Form("MC_Conversion_Mapping_Phi_in_R_%02d",rBin);
1082 // fHistograms->FillHistogram(nameMCMappingPhiInR, tmpPhi);
1083 fHistograms->FillHistogram(nameMCMappingPhiInR, vtxPos.Phi());
1085 TString nameMCMappingZInR="";
1086 nameMCMappingZInR.Form("MC_Conversion_Mapping_Z_in_R_%02d",rBin);
1087 fHistograms->FillHistogram(nameMCMappingZInR,ePos->Vz() );
1090 TString nameMCMappingPhiInZ="";
1091 nameMCMappingPhiInZ.Form("MC_Conversion_Mapping_Phi_in_Z_%02d",zBin);
1092 // fHistograms->FillHistogram(nameMCMappingPhiInR, tmpPhi);
1093 fHistograms->FillHistogram(nameMCMappingPhiInZ, vtxPos.Phi());
1097 TString nameMCMappingFMDPhiInZ="";
1098 nameMCMappingFMDPhiInZ.Form("MC_Conversion_Mapping_FMD_Phi_in_Z_%02d",zBin);
1099 fHistograms->FillHistogram(nameMCMappingFMDPhiInZ, vtxPos.Phi());
1102 if(ePos->R()>rITSTPCMin && ePos->R()<rITSTPCMax){
1103 TString nameMCMappingITSTPCPhiInZ="";
1104 nameMCMappingITSTPCPhiInZ.Form("MC_Conversion_Mapping_ITSTPC_Phi_in_Z_%02d",zBin);
1105 fHistograms->FillHistogram(nameMCMappingITSTPCPhiInZ, vtxPos.Phi());
1108 TString nameMCMappingRInZ="";
1109 nameMCMappingRInZ.Form("MC_Conversion_Mapping_R_in_Z_%02d",zBin);
1110 fHistograms->FillHistogram(nameMCMappingRInZ,ePos->R() );
1112 if(particle->Pt() > fLowPtMapping && particle->Pt()< fHighPtMapping){
1113 TString nameMCMappingMidPtPhiInR="";
1114 nameMCMappingMidPtPhiInR.Form("MC_Conversion_Mapping_MidPt_Phi_in_R_%02d",rBin);
1115 fHistograms->FillHistogram(nameMCMappingMidPtPhiInR, vtxPos.Phi());
1117 TString nameMCMappingMidPtZInR="";
1118 nameMCMappingMidPtZInR.Form("MC_Conversion_Mapping_MidPt_Z_in_R_%02d",rBin);
1119 fHistograms->FillHistogram(nameMCMappingMidPtZInR,ePos->Vz() );
1122 TString nameMCMappingMidPtPhiInZ="";
1123 nameMCMappingMidPtPhiInZ.Form("MC_Conversion_Mapping_MidPt_Phi_in_Z_%02d",zBin);
1124 fHistograms->FillHistogram(nameMCMappingMidPtPhiInZ, vtxPos.Phi());
1128 TString nameMCMappingMidPtFMDPhiInZ="";
1129 nameMCMappingMidPtFMDPhiInZ.Form("MC_Conversion_Mapping_MidPt_FMD_Phi_in_Z_%02d",zBin);
1130 fHistograms->FillHistogram(nameMCMappingMidPtFMDPhiInZ, vtxPos.Phi());
1134 TString nameMCMappingMidPtRInZ="";
1135 nameMCMappingMidPtRInZ.Form("MC_Conversion_Mapping_MidPt_R_in_Z_%02d",zBin);
1136 fHistograms->FillHistogram(nameMCMappingMidPtRInZ,ePos->R() );
1142 fHistograms->FillHistogram("MC_Conversion_R",ePos->R());
1143 fHistograms->FillHistogram("MC_Conversion_ZR",ePos->Vz(),ePos->R());
1144 fHistograms->FillHistogram("MC_Conversion_XY",ePos->Vx(),ePos->Vy());
1145 fHistograms->FillHistogram("MC_Conversion_OpeningAngle",GetMCOpeningAngle(ePos, eNeg));
1146 fHistograms->FillHistogram("MC_ConvGamma_E_AsymmetryP",particle->P(),eNeg->P()/particle->P());
1147 fHistograms->FillHistogram("MC_ConvGamma_P_AsymmetryP",particle->P(),ePos->P()/particle->P());
1150 if(particle->GetMother(0) < 0){ // no mother = direct gamma, still inside converted
1151 fHistograms->FillHistogram("MC_ConvDirectGamma_Energy",particle->Energy());
1152 fHistograms->FillHistogram("MC_ConvDirectGamma_Pt", particle->Pt());
1153 fHistograms->FillHistogram("MC_ConvDirectGamma_Eta", particle->Eta());
1154 fHistograms->FillHistogram("MC_ConvDirectGamma_Phi", tmpPhi);
1155 fHistograms->FillHistogram("MC_ConvDirectGamma_Rapid", rapidity);
1157 } // end direct gamma
1158 else{ // mother exits
1159 /* if( fStack->Particle(particle->GetMother(0))->GetPdgCode()==10441 ||//chic0
1160 fStack->Particle(particle->GetMother(0))->GetPdgCode()==20443 ||//psi2S
1161 fStack->Particle(particle->GetMother(0))->GetPdgCode()==445 //chic2
1163 fMCGammaChic.push_back(particle);
1166 } // end if mother exits
1167 } // end if particle is a photon
1171 // process motherparticles (2 gammas as daughters)
1172 // the motherparticle had already to pass the R and the eta cut, but no line cut.
1173 // the line cut is just valid for the conversions!
1175 // OWN primary Pi0 debug ////////////////////////////////////////////////////////////////////////////////////////////
1176 if (particle->GetPdgCode()==111){
1177 if( TMath::Abs(rapidity) < fV0Reader->GetRapidityMesonCut() ){
1178 fHistograms->FillHistogram("MC_Pi0_Pt_vs_Rapid_allDaughters", particle->Pt(),rapidity);
1181 // end OWN primary Pi0 debug ////////////////////////////////////////////////////////////////////////////////////////
1183 if(particle->GetNDaughters() == 2){
1185 TParticle* daughter0 = (TParticle*)fStack->Particle(particle->GetFirstDaughter());
1186 TParticle* daughter1 = (TParticle*)fStack->Particle(particle->GetLastDaughter());
1188 if(daughter0->GetPdgCode() != 22 || daughter1->GetPdgCode() != 22) continue; //check for gamma gamma daughters
1190 if(TMath::Abs(rapidity) > fV0Reader->GetRapidityMesonCut() ) continue;
1192 // Check the acceptance for both gammas
1193 Bool_t gammaEtaCut = kTRUE;
1194 if(TMath::Abs(daughter0->Eta()) > fV0Reader->GetEtaCut() || TMath::Abs(daughter1->Eta()) > fV0Reader->GetEtaCut() ) gammaEtaCut = kFALSE;
1195 Bool_t gammaRCut = kTRUE;
1196 if(daughter0->R() > fV0Reader->GetMaxRCut() || daughter1->R() > fV0Reader->GetMaxRCut() ) gammaRCut = kFALSE;
1200 // check for conversions now -> have to pass eta, R and line cut!
1201 Bool_t daughter0Electron = kFALSE;
1202 Bool_t daughter0Positron = kFALSE;
1203 Bool_t daughter1Electron = kFALSE;
1204 Bool_t daughter1Positron = kFALSE;
1206 if(daughter0->GetNDaughters() >= 2){ // first gamma
1207 for(Int_t TrackIndex=daughter0->GetFirstDaughter();TrackIndex<=daughter0->GetLastDaughter();TrackIndex++){
1208 TParticle *tmpDaughter = fStack->Particle(TrackIndex);
1209 if(tmpDaughter->GetUniqueID() == 5){
1210 if(tmpDaughter->GetPdgCode() == 11){
1211 if( TMath::Abs(tmpDaughter->Eta()) <= fV0Reader->GetEtaCut() ){
1212 if( ( TMath::Abs(tmpDaughter->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue() < tmpDaughter->R() ){
1213 if(tmpDaughter->R()< fV0Reader->GetMaxRCut()){
1214 daughter0Electron = kTRUE;
1220 else if(tmpDaughter->GetPdgCode() == -11){
1221 if( TMath::Abs(tmpDaughter->Eta()) <= fV0Reader->GetEtaCut() ){
1222 if( ( TMath::Abs(tmpDaughter->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue() < tmpDaughter->R() ){
1223 if(tmpDaughter->R()< fV0Reader->GetMaxRCut()){
1224 daughter0Positron = kTRUE;
1234 if(daughter1->GetNDaughters() >= 2){ // second gamma
1235 for(Int_t TrackIndex=daughter1->GetFirstDaughter();TrackIndex<=daughter1->GetLastDaughter();TrackIndex++){
1236 TParticle *tmpDaughter = fStack->Particle(TrackIndex);
1237 if(tmpDaughter->GetUniqueID() == 5){
1238 if(tmpDaughter->GetPdgCode() == 11){
1239 if( TMath::Abs(tmpDaughter->Eta()) <= fV0Reader->GetEtaCut() ){
1240 if( ( TMath::Abs(tmpDaughter->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue() < tmpDaughter->R() ){
1241 if(tmpDaughter->R()< fV0Reader->GetMaxRCut()){
1242 daughter1Electron = kTRUE;
1248 else if(tmpDaughter->GetPdgCode() == -11){
1249 if( TMath::Abs(tmpDaughter->Eta()) <= fV0Reader->GetEtaCut() ){
1250 if( ( TMath::Abs(tmpDaughter->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue() < tmpDaughter->R() ){
1251 if(tmpDaughter->R()< fV0Reader->GetMaxRCut()){
1252 daughter1Positron = kTRUE;
1264 if(particle->GetPdgCode()==111){ //Pi0
1265 if( iTracks >= fStack->GetNprimary()){
1266 fHistograms->FillHistogram("MC_Pi0_Secondaries_Eta", particle->Eta());
1267 fHistograms->FillHistogram("MC_Pi0_Secondaries_Rapid", rapidity);
1268 fHistograms->FillHistogram("MC_Pi0_Secondaries_Phi", tmpPhi);
1269 fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt", particle->Pt());
1270 fHistograms->FillHistogram("MC_Pi0_Secondaries_Energy", particle->Energy());
1271 fHistograms->FillHistogram("MC_Pi0_Secondaries_R", particle->R());
1272 fHistograms->FillHistogram("MC_Pi0_Secondaries_ZR", particle->Vz(),particle->R());
1273 fHistograms->FillHistogram("MC_Pi0_Secondaries_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));
1274 fHistograms->FillHistogram("MC_Pi0_Secondaries_XY", particle->Vx(),particle->Vy());//only fill from one daughter to avoid multiple filling
1276 if(gammaEtaCut && gammaRCut){
1277 //if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){
1278 fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt_Eta_withinAcceptance", particle->Pt(),particle->Eta());
1279 fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt_Rapid_withinAcceptance", particle->Pt(),rapidity);
1280 if(daughter0Electron && daughter0Positron && daughter1Electron && daughter1Positron){
1281 fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt_Eta_ConvGamma_withinAcceptance", particle->Pt(),particle->Eta());
1282 fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt_Rapid_ConvGamma_withinAcceptance", particle->Pt(),rapidity);
1287 fHistograms->FillHistogram("MC_Pi0_Eta", particle->Eta());
1288 fHistograms->FillHistogram("MC_Pi0_Rapid", rapidity);
1289 fHistograms->FillHistogram("MC_Pi0_Phi", tmpPhi);
1290 fHistograms->FillHistogram("MC_Pi0_Pt", particle->Pt());
1291 fHistograms->FillHistogram("MC_Pi0_Pt_vs_Rapid", particle->Pt(),rapidity);
1292 fHistograms->FillHistogram("MC_Pi0_Energy", particle->Energy());
1293 fHistograms->FillHistogram("MC_Pi0_R", particle->R());
1294 fHistograms->FillHistogram("MC_Pi0_ZR", particle->Vz(),particle->R());
1295 fHistograms->FillHistogram("MC_Pi0_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));
1296 fHistograms->FillHistogram("MC_Pi0_XY", particle->Vx(), particle->Vy());//only fill from one daughter to avoid multiple filling
1297 if(TMath::Abs(particle->Eta())<0.9)fHistograms->FillHistogram("MC_Pi0_Pt_Fiducial", particle->Pt());
1299 switch(GetProcessType(fGCMCEvent)){
1301 fHistograms->FillHistogram("MC_SD_EvtQ3_Pi0_Pt", particle->Pt());
1304 fHistograms->FillHistogram("MC_DD_EvtQ3_Pi0_Pt", particle->Pt());
1307 fHistograms->FillHistogram("MC_ND_EvtQ3_Pi0_Pt", particle->Pt());
1310 AliError("Unknown Process");
1313 if(gammaEtaCut && gammaRCut){
1314 // if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){
1315 fHistograms->FillHistogram("MC_Pi0_Pt_Eta_withinAcceptance", particle->Pt(),particle->Eta());
1316 fHistograms->FillHistogram("MC_Pi0_Pt_Rapid_withinAcceptance", particle->Pt(),rapidity);
1317 if(TMath::Abs(particle->Eta())<0.9)fHistograms->FillHistogram("MC_Pi0_Pt_withinAcceptance_Fiducial", particle->Pt());
1319 if(daughter0Electron && daughter0Positron && daughter1Electron && daughter1Positron){
1320 fHistograms->FillHistogram("MC_Pi0_Pt_Eta_ConvGamma_withinAcceptance", particle->Pt(),particle->Eta());
1321 fHistograms->FillHistogram("MC_Pi0_Pt_Rapid_ConvGamma_withinAcceptance", particle->Pt(),rapidity);
1322 fHistograms->FillHistogram("MC_Pi0_ZR_ConvGamma_withinAcceptance", particle->Vz(),particle->R());
1323 fHistograms->FillHistogram("MC_Pi0_ConvGamma_OpeningAngle_Pt", particle->Pt(),GetMCOpeningAngle(daughter0,daughter1));
1324 fHistograms->FillHistogram("MC_Pi0_ConvGamma_PtGamma_Pt", particle->Pt(),daughter0->Pt());
1325 fHistograms->FillHistogram("MC_Pi0_ConvGamma_PtGamma_Pt", particle->Pt(),daughter1->Pt());
1328 if((daughter0->Energy()+daughter1->Energy()) > 0.){
1329 alfa= TMath::Abs((daughter0->Energy()-daughter1->Energy())/(daughter0->Energy()+daughter1->Energy()));
1331 fHistograms->FillHistogram("MC_Pi0_alpha",alfa);
1332 if(TMath::Abs(particle->Eta())<0.9)fHistograms->FillHistogram("MC_Pi0_Pt_ConvGamma_withinAcceptance_Fiducial", particle->Pt());
1339 if(particle->GetPdgCode()==221){ //Eta
1340 fHistograms->FillHistogram("MC_Eta_Eta", particle->Eta());
1341 fHistograms->FillHistogram("MC_Eta_Rapid", rapidity);
1342 fHistograms->FillHistogram("MC_Eta_Phi",tmpPhi);
1343 fHistograms->FillHistogram("MC_Eta_Pt", particle->Pt());
1344 fHistograms->FillHistogram("MC_Eta_Pt_vs_Rapid", particle->Pt(),rapidity);
1345 fHistograms->FillHistogram("MC_Eta_Energy", particle->Energy());
1346 fHistograms->FillHistogram("MC_Eta_R", particle->R());
1347 fHistograms->FillHistogram("MC_Eta_ZR", particle->Vz(),particle->R());
1348 fHistograms->FillHistogram("MC_Eta_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));
1349 fHistograms->FillHistogram("MC_Eta_XY", particle->Vx(), particle->Vy());//only fill from one daughter to avoid multiple filling
1351 if(gammaEtaCut && gammaRCut){
1352 // if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){
1353 fHistograms->FillHistogram("MC_Eta_Pt_Eta_withinAcceptance", particle->Pt(),particle->Eta());
1354 fHistograms->FillHistogram("MC_Eta_Pt_Rapid_withinAcceptance", particle->Pt(),rapidity);
1355 if(daughter0Electron && daughter0Positron && daughter1Electron && daughter1Positron){
1356 fHistograms->FillHistogram("MC_Eta_Pt_Eta_ConvGamma_withinAcceptance", particle->Pt(),particle->Eta());
1357 fHistograms->FillHistogram("MC_Eta_Pt_Rapid_ConvGamma_withinAcceptance", particle->Pt(),rapidity);
1358 fHistograms->FillHistogram("MC_Eta_ZR_ConvGamma_withinAcceptance", particle->Vz(),particle->R());
1359 fHistograms->FillHistogram("MC_Eta_ConvGamma_OpeningAngle_Pt", particle->Pt(),GetMCOpeningAngle(daughter0,daughter1));
1360 fHistograms->FillHistogram("MC_Eta_ConvGamma_PtGamma_Pt", particle->Pt(),daughter0->Pt());
1361 fHistograms->FillHistogram("MC_Eta_ConvGamma_PtGamma_Pt", particle->Pt(),daughter1->Pt());
1364 if((daughter0->Energy()+daughter1->Energy()) > 0.){
1365 alfa= TMath::Abs((daughter0->Energy()-daughter1->Energy())/(daughter0->Energy()+daughter1->Energy()));
1367 fHistograms->FillHistogram("MC_Eta_alpha",alfa);
1375 // all motherparticles with 2 gammas as daughters
1376 fHistograms->FillHistogram("MC_Mother_R", particle->R());
1377 fHistograms->FillHistogram("MC_Mother_ZR", particle->Vz(),particle->R());
1378 fHistograms->FillHistogram("MC_Mother_XY", particle->Vx(),particle->Vy());
1379 fHistograms->FillHistogram("MC_Mother_Mass", particle->GetCalcMass());
1380 fHistograms->FillHistogram("MC_Mother_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));
1381 fHistograms->FillHistogram("MC_Mother_Energy", particle->Energy());
1382 fHistograms->FillHistogram("MC_Mother_Pt", particle->Pt());
1383 fHistograms->FillHistogram("MC_Mother_Eta", particle->Eta());
1384 fHistograms->FillHistogram("MC_Mother_Rapid", rapidity);
1385 fHistograms->FillHistogram("MC_Mother_Phi",tmpPhi);
1386 fHistograms->FillHistogram("MC_Mother_InvMass_vs_Pt",particle->GetMass(),particle->Pt());
1388 if(gammaEtaCut && gammaRCut){
1389 // if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){
1390 fHistograms->FillHistogram("MC_Mother_Pt_Eta_withinAcceptance", particle->Pt(),particle->Eta());
1391 fHistograms->FillHistogram("MC_Mother_Pt_Rapid_withinAcceptance", particle->Pt(),rapidity);
1392 fHistograms->FillHistogram("MC_Mother_InvMass_vs_Pt_withinAcceptance",particle->GetMass(),particle->Pt());
1393 if(daughter0Electron && daughter0Positron && daughter1Electron && daughter1Positron){
1394 fHistograms->FillHistogram("MC_Mother_Pt_Eta_ConvGamma_withinAcceptance", particle->Pt(),particle->Eta());
1395 fHistograms->FillHistogram("MC_Mother_Pt_Rapid_ConvGamma_withinAcceptance", particle->Pt(),rapidity);
1396 fHistograms->FillHistogram("MC_Mother_InvMass_vs_Pt_ConvGamma_withinAcceptance",particle->GetMass(),particle->Pt());
1401 } // end passed R and eta cut
1403 } // end if(particle->GetNDaughters() == 2)
1405 }// end for (Int_t iTracks = 0; iTracks < fStack->GetNtrack(); iTracks++)
1407 } // end ProcessMCData
1411 void AliAnalysisTaskGammaConversion::FillNtuple(){
1412 //Fills the ntuple with the different values
1414 if(fGammaNtuple == NULL){
1417 Int_t numberOfV0s = fV0Reader->GetNumberOfV0s();
1418 for(Int_t i=0;i<numberOfV0s;i++){
1419 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};
1420 AliESDv0 * cV0 = fV0Reader->GetV0(i);
1423 fV0Reader->GetPIDProbability(negPID,posPID);
1424 values[0]=cV0->GetOnFlyStatus();
1425 values[1]=fV0Reader->CheckForPrimaryVertex();
1428 values[4]=fV0Reader->GetX();
1429 values[5]=fV0Reader->GetY();
1430 values[6]=fV0Reader->GetZ();
1431 values[7]=fV0Reader->GetXYRadius();
1432 values[8]=fV0Reader->GetMotherCandidateNDF();
1433 values[9]=fV0Reader->GetMotherCandidateChi2();
1434 values[10]=fV0Reader->GetMotherCandidateEnergy();
1435 values[11]=fV0Reader->GetMotherCandidateEta();
1436 values[12]=fV0Reader->GetMotherCandidatePt();
1437 values[13]=fV0Reader->GetMotherCandidateMass();
1438 values[14]=fV0Reader->GetMotherCandidateWidth();
1439 // values[15]=fV0Reader->GetMotherMCParticle()->Pt(); MOVED TO THE END, HAS TO BE CALLED AFTER HasSameMother NB: still has the same entry in the array
1440 values[16]=fV0Reader->GetOpeningAngle();
1441 values[17]=fV0Reader->GetNegativeTrackEnergy();
1442 values[18]=fV0Reader->GetNegativeTrackPt();
1443 values[19]=fV0Reader->GetNegativeTrackEta();
1444 values[20]=fV0Reader->GetNegativeTrackPhi();
1445 values[21]=fV0Reader->GetPositiveTrackEnergy();
1446 values[22]=fV0Reader->GetPositiveTrackPt();
1447 values[23]=fV0Reader->GetPositiveTrackEta();
1448 values[24]=fV0Reader->GetPositiveTrackPhi();
1449 values[25]=fV0Reader->HasSameMCMother();
1450 if(values[25] != 0){
1451 values[26]=fV0Reader->GetMotherMCParticlePDGCode();
1452 values[15]=fV0Reader->GetMotherMCParticle()->Pt();
1454 fTotalNumberOfAddedNtupleEntries++;
1455 fGammaNtuple->Fill(values);
1457 fV0Reader->ResetV0IndexNumber();
1461 void AliAnalysisTaskGammaConversion::ProcessV0sNoCut(){
1462 // Process all the V0's without applying any cuts to it
1464 Int_t numberOfV0s = fV0Reader->GetNumberOfV0s();
1465 for(Int_t i=0;i<numberOfV0s;i++){
1466 /*AliESDv0 * cV0 = */fV0Reader->GetV0(i);
1468 if(fV0Reader->CheckForPrimaryVertex() == kFALSE){
1472 // if( !fV0Reader->GetV0(i)->GetOnFlyStatus()){
1473 if( !fV0Reader->CheckV0FinderStatus(i)){
1478 if( !((fV0Reader->GetNegativeESDTrack())->GetStatus() & AliESDtrack::kTPCrefit) ||
1479 !((fV0Reader->GetPositiveESDTrack())->GetStatus() & AliESDtrack::kTPCrefit) ){
1483 if( fV0Reader->GetNegativeESDTrack()->GetSign()== fV0Reader->GetPositiveESDTrack()->GetSign()){
1487 if( fV0Reader->GetNegativeESDTrack()->GetKinkIndex(0) > 0 ||
1488 fV0Reader->GetPositiveESDTrack()->GetKinkIndex(0) > 0) {
1491 if(TMath::Abs(fV0Reader->GetMotherCandidateEta())> fV0Reader->GetEtaCut()){
1494 if(TMath::Abs(fV0Reader->GetPositiveTrackEta())> fV0Reader->GetEtaCut()){
1497 if(TMath::Abs(fV0Reader->GetNegativeTrackEta())> fV0Reader->GetEtaCut()){
1500 if((TMath::Abs(fV0Reader->GetZ())*fV0Reader->GetLineCutZRSlope())-fV0Reader->GetLineCutZValue() > fV0Reader->GetXYRadius() ){ // cuts out regions where we do not reconstruct
1505 if(fV0Reader->HasSameMCMother() == kFALSE){
1509 TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
1510 TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
1512 if(TMath::Abs(negativeMC->GetPdgCode())!=11 || TMath::Abs(positiveMC->GetPdgCode())!=11){
1515 if(negativeMC->GetPdgCode() == positiveMC->GetPdgCode()){
1519 if(negativeMC->GetUniqueID() != 5 || positiveMC->GetUniqueID() !=5){ // id 5 is conversion
1523 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
1525 fHistograms->FillHistogram("ESD_NoCutConvGamma_Pt", fV0Reader->GetMotherCandidatePt());
1526 fHistograms->FillHistogram("ESD_NoCutConvGamma_Energy", fV0Reader->GetMotherCandidateEnergy());
1527 fHistograms->FillHistogram("ESD_NoCutConvGamma_Eta", fV0Reader->GetMotherCandidateEta());
1528 fHistograms->FillHistogram("ESD_NoCutConvGamma_Phi", fV0Reader->GetMotherCandidatePhi());
1529 fHistograms->FillHistogram("ESD_NoCutConvGamma_Mass", fV0Reader->GetMotherCandidateMass());
1530 fHistograms->FillHistogram("ESD_NoCutConvGamma_Width", fV0Reader->GetMotherCandidateWidth());
1531 fHistograms->FillHistogram("ESD_NoCutConvGamma_Chi2", fV0Reader->GetMotherCandidateChi2());
1532 fHistograms->FillHistogram("ESD_NoCutConvGamma_NDF", fV0Reader->GetMotherCandidateNDF());
1533 fHistograms->FillHistogram("ESD_NoCutConvGamma_Rapid", fV0Reader->GetMotherCandidateRapidity());
1534 fHistograms->FillHistogram("ESD_NoCutConvGamma_Pt_Eta", fV0Reader->GetMotherCandidatePt(),fV0Reader->GetMotherCandidateEta());
1536 fHistograms->FillHistogram("ESD_NoCutConvGamma_Pt_Chi2", fV0Reader->GetMotherCandidatePt(), fV0Reader->GetMotherCandidateChi2());
1537 fHistograms->FillHistogram("ESD_NoCutConvGamma_Eta_Chi2", fV0Reader->GetMotherCandidateEta(), fV0Reader->GetMotherCandidateChi2());
1539 fHistograms->FillHistogram("ESD_NoCutConversion_XY", fV0Reader->GetX(),fV0Reader->GetY());
1540 fHistograms->FillHistogram("ESD_NoCutConversion_R", fV0Reader->GetXYRadius());
1541 fHistograms->FillHistogram("ESD_NoCutConversion_ZR", fV0Reader->GetZ(),fV0Reader->GetXYRadius());
1542 fHistograms->FillHistogram("ESD_NoCutConversion_OpeningAngle", fV0Reader->GetOpeningAngle());
1543 fHistograms->FillHistogram("ESD_NoCutConvGamma_CosPointingAngle", fV0Reader->GetCosPointingAngle());
1544 fHistograms->FillHistogram("ESD_NoCutConvGamma_DcaDaughters", fV0Reader->GetDcaDaughters());
1545 fHistograms->FillHistogram("ESD_NoCutConvGamma_NormDcaDistDaughters", fV0Reader->GetNormDcaDistDaughters());
1546 fHistograms->FillHistogram("ESD_NoCutConvGamma_LikelihoodAP", fV0Reader->GetLikelihoodAP());
1548 fHistograms->FillHistogram("ESD_NoCutConvGamma_E_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetNegativeTrackP()/fV0Reader->GetMotherCandidateP());
1549 fHistograms->FillHistogram("ESD_NoCutConvGamma_P_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetPositiveTrackP()/fV0Reader->GetMotherCandidateP());
1550 fHistograms->FillHistogram("ESD_NoCutConvGamma_E_dEdxP",fV0Reader->GetNegativeTrackP(),fV0Reader->GetNegativeTrackTPCdEdx());
1551 fHistograms->FillHistogram("ESD_NoCutConvGamma_P_dEdxP",fV0Reader->GetPositiveTrackP(),fV0Reader->GetPositiveTrackTPCdEdx());
1553 //store MCTruth properties
1554 fHistograms->FillHistogram("ESD_NoCutConvGamma_MC_Pt_Eta", fV0Reader->GetMotherMCParticle()->Pt(),fV0Reader->GetMotherMCParticle()->Eta());
1555 fHistograms->FillHistogram("ESD_NoCutConversion_MC_ZR", negativeMC->Vz(),negativeMC->R());
1556 fHistograms->FillHistogram("ESD_NoCutConversion_MC_XY", negativeMC->Vx(),negativeMC->Vy());
1560 fV0Reader->ResetV0IndexNumber();
1563 void AliAnalysisTaskGammaConversion::ProcessV0s(){
1564 // see header file for documentation
1567 if(fWriteNtuple == kTRUE){
1571 Int_t nSurvivingV0s=0;
1572 fV0Reader->ResetNGoodV0s();
1573 while(fV0Reader->NextV0()){
1577 TVector3 vtxConv(fV0Reader->GetX(),fV0Reader->GetY(), fV0Reader->GetZ());
1579 //-------------------------- filling v0 information -------------------------------------
1580 fHistograms->FillHistogram("ESD_Conversion_R", fV0Reader->GetXYRadius());
1581 fHistograms->FillHistogram("ESD_Conversion_ZR", fV0Reader->GetZ(),fV0Reader->GetXYRadius());
1582 fHistograms->FillHistogram("ESD_Conversion_XY", fV0Reader->GetX(),fV0Reader->GetY());
1583 fHistograms->FillHistogram("ESD_Conversion_OpeningAngle", fV0Reader->GetOpeningAngle());
1585 // Specific histograms for beam pipe studies
1586 if( TMath::Abs(fV0Reader->GetZ()) < fV0Reader->GetLineCutZValue() ){
1587 fHistograms->FillHistogram("ESD_Conversion_XY_BeamPipe", fV0Reader->GetX(),fV0Reader->GetY());
1588 fHistograms->FillHistogram("ESD_Conversion_RPhi_BeamPipe", vtxConv.Phi(),fV0Reader->GetXYRadius());
1592 fHistograms->FillHistogram("ESD_E_Energy", fV0Reader->GetNegativeTrackEnergy());
1593 fHistograms->FillHistogram("ESD_E_Pt", fV0Reader->GetNegativeTrackPt());
1594 fHistograms->FillHistogram("ESD_E_Eta", fV0Reader->GetNegativeTrackEta());
1595 fHistograms->FillHistogram("ESD_E_Phi", fV0Reader->GetNegativeTrackPhi());
1596 fHistograms->FillHistogram("ESD_E_nTPCClusters", fV0Reader->GetNegativeTracknTPCClusters());
1597 fHistograms->FillHistogram("ESD_E_nITSClusters", fV0Reader->GetNegativeTracknITSClusters());
1598 Double_t eClsToF= 0;
1599 if(!fV0Reader->GetUseCorrectedTPCClsInfo()){
1600 if(fV0Reader->GetNegativeTracknTPCFClusters()!=0 ){
1601 eClsToF=(Double_t)fV0Reader->GetNegativeTracknTPCClusters()/(Double_t)fV0Reader->GetNegativeTracknTPCFClusters();
1604 eClsToF= fV0Reader->GetNegativeESDTrack()->GetTPCClusterInfo(2,0,fV0Reader->GetFirstTPCRow(fV0Reader->GetXYRadius()));
1606 fHistograms->FillHistogram("ESD_E_nTPCClustersToFP", fV0Reader->GetNegativeTrackP(),eClsToF );
1607 fHistograms->FillHistogram("ESD_E_nTPCClustersToFR", fV0Reader->GetXYRadius(),eClsToF );
1609 if(fV0Reader->GetNegativeTracknTPCClusters()!=0 ){
1610 fHistograms->FillHistogram("ESD_E_TPCchi2", fV0Reader->GetNegativeTrackTPCchi2()/(Double_t)fV0Reader->GetNegativeTracknTPCClusters());
1615 fHistograms->FillHistogram("ESD_P_Energy", fV0Reader->GetPositiveTrackEnergy());
1616 fHistograms->FillHistogram("ESD_P_Pt", fV0Reader->GetPositiveTrackPt());
1617 fHistograms->FillHistogram("ESD_P_Eta", fV0Reader->GetPositiveTrackEta());
1618 fHistograms->FillHistogram("ESD_P_Phi", fV0Reader->GetPositiveTrackPhi());
1619 fHistograms->FillHistogram("ESD_P_nTPCClusters", fV0Reader->GetPositiveTracknTPCClusters());
1620 fHistograms->FillHistogram("ESD_P_nITSClusters", fV0Reader->GetPositiveTracknITSClusters());
1621 Double_t pClsToF= 0;
1622 if(!fV0Reader->GetUseCorrectedTPCClsInfo()){
1623 if(fV0Reader->GetPositiveTracknTPCFClusters()!=0){
1624 pClsToF = (Double_t)fV0Reader->GetPositiveTracknTPCClusters()/(Double_t)fV0Reader->GetPositiveTracknTPCFClusters();
1627 pClsToF= fV0Reader->GetPositiveESDTrack()->GetTPCClusterInfo(2,0,fV0Reader->GetFirstTPCRow(fV0Reader->GetXYRadius()));
1630 fHistograms->FillHistogram("ESD_P_nTPCClustersToFP",fV0Reader->GetPositiveTrackP(), pClsToF);
1631 fHistograms->FillHistogram("ESD_P_nTPCClustersToFR",fV0Reader->GetXYRadius(), pClsToF);
1633 if(fV0Reader->GetPositiveTracknTPCClusters()!=0){
1634 fHistograms->FillHistogram("ESD_P_TPCchi2", fV0Reader->GetPositiveTrackTPCchi2()/(Double_t)fV0Reader->GetPositiveTracknTPCClusters());
1639 fHistograms->FillHistogram("ESD_ConvGamma_Energy", fV0Reader->GetMotherCandidateEnergy());
1640 fHistograms->FillHistogram("ESD_ConvGamma_Pt", fV0Reader->GetMotherCandidatePt());
1641 fHistograms->FillHistogram("ESD_ConvGamma_Eta", fV0Reader->GetMotherCandidateEta());
1642 fHistograms->FillHistogram("ESD_ConvGamma_Phi", fV0Reader->GetMotherCandidatePhi());
1643 fHistograms->FillHistogram("ESD_ConvGamma_Mass", fV0Reader->GetMotherCandidateMass());
1644 fHistograms->FillHistogram("ESD_ConvGamma_Width", fV0Reader->GetMotherCandidateWidth());
1645 fHistograms->FillHistogram("ESD_ConvGamma_Chi2", fV0Reader->GetMotherCandidateChi2());
1646 fHistograms->FillHistogram("ESD_ConvGamma_NDF", fV0Reader->GetMotherCandidateNDF());
1647 fHistograms->FillHistogram("ESD_ConvGamma_Rapid", fV0Reader->GetMotherCandidateRapidity());
1648 fHistograms->FillHistogram("ESD_ConvGamma_Pt_Eta", fV0Reader->GetMotherCandidatePt(),fV0Reader->GetMotherCandidateEta());
1650 fHistograms->FillHistogram("ESD_ConvGamma_Pt_Chi2", fV0Reader->GetMotherCandidatePt(), fV0Reader->GetMotherCandidateChi2());
1651 fHistograms->FillHistogram("ESD_ConvGamma_Eta_Chi2", fV0Reader->GetMotherCandidateEta(), fV0Reader->GetMotherCandidateChi2());
1653 fHistograms->FillHistogram("ESD_ConvGamma_CosPointingAngle", fV0Reader->GetCosPointingAngle());
1654 fHistograms->FillHistogram("ESD_ConvGamma_DcaDaughters", fV0Reader->GetDcaDaughters());
1655 fHistograms->FillHistogram("ESD_ConvGamma_NormDcaDistDaughters", fV0Reader->GetNormDcaDistDaughters());
1656 fHistograms->FillHistogram("ESD_ConvGamma_LikelihoodAP", fV0Reader->GetLikelihoodAP());
1658 fHistograms->FillHistogram("ESD_ConvGamma_E_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetNegativeTrackP()/fV0Reader->GetMotherCandidateP());
1659 fHistograms->FillHistogram("ESD_ConvGamma_P_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetPositiveTrackP()/fV0Reader->GetMotherCandidateP());
1660 fHistograms->FillHistogram("ESD_ConvGamma_E_dEdxP",fV0Reader->GetNegativeTrackP(),fV0Reader->GetNegativeTrackTPCdEdx());
1661 fHistograms->FillHistogram("ESD_ConvGamma_P_dEdxP",fV0Reader->GetPositiveTrackP(),fV0Reader->GetPositiveTrackTPCdEdx());
1665 fV0Reader->GetPIDProbability(negPID,posPID);
1666 fHistograms->FillHistogram("ESD_ConvGamma_E_EProbP",fV0Reader->GetNegativeTrackP(),negPID);
1667 fHistograms->FillHistogram("ESD_ConvGamma_P_EProbP",fV0Reader->GetPositiveTrackP(),posPID);
1669 Double_t negPIDmupi=0;
1670 Double_t posPIDmupi=0;
1671 fV0Reader->GetPIDProbabilityMuonPion(negPIDmupi,posPIDmupi);
1672 fHistograms->FillHistogram("ESD_ConvGamma_E_mupiProbP",fV0Reader->GetNegativeTrackP(),negPIDmupi);
1673 fHistograms->FillHistogram("ESD_ConvGamma_P_mupiProbP",fV0Reader->GetPositiveTrackP(),posPIDmupi);
1675 Double_t armenterosQtAlfa[2];
1676 fV0Reader->GetArmenterosQtAlfa(fV0Reader-> GetNegativeKFParticle(),
1677 fV0Reader-> GetPositiveKFParticle(),
1678 fV0Reader->GetMotherCandidateKFCombination(),
1681 fHistograms->FillHistogram("ESD_ConvGamma_alfa_qt",armenterosQtAlfa[1],armenterosQtAlfa[0]);
1685 Int_t rBin = fHistograms->GetRBin(fV0Reader->GetXYRadius());
1686 Int_t zBin = fHistograms->GetZBin(fV0Reader->GetZ());
1687 Int_t phiBin = fHistograms->GetPhiBin(fV0Reader->GetNegativeTrackPhi());
1689 Double_t rITSTPCMin=50;
1690 Double_t rITSTPCMax=80;
1693 // Double_t motherCandidateEta= fV0Reader->GetMotherCandidateEta();
1695 TString nameESDMappingPhiR="";
1696 nameESDMappingPhiR.Form("ESD_Conversion_Mapping_Phi%02d_R%02d",phiBin,rBin);
1697 //fHistograms->FillHistogram(nameESDMappingPhiR, fV0Reader->GetZ(), motherCandidateEta);
1699 TString nameESDMappingPhi="";
1700 nameESDMappingPhi.Form("ESD_Conversion_Mapping_Phi%02d",phiBin);
1701 //fHistograms->FillHistogram(nameESDMappingPhi, fV0Reader->GetZ(), motherCandidateEta);
1703 TString nameESDMappingR="";
1704 nameESDMappingR.Form("ESD_Conversion_Mapping_R%02d",rBin);
1705 //fHistograms->FillHistogram(nameESDMappingR, fV0Reader->GetZ(), motherCandidateEta);
1707 TString nameESDMappingPhiInR="";
1708 nameESDMappingPhiInR.Form("ESD_Conversion_Mapping_Phi_in_R_%02d",rBin);
1709 // fHistograms->FillHistogram(nameESDMappingPhiInR, fV0Reader->GetMotherCandidatePhi());
1710 fHistograms->FillHistogram(nameESDMappingPhiInR, vtxConv.Phi());
1712 TString nameESDMappingZInR="";
1713 nameESDMappingZInR.Form("ESD_Conversion_Mapping_Z_in_R_%02d",rBin);
1714 fHistograms->FillHistogram(nameESDMappingZInR, fV0Reader->GetZ());
1716 TString nameESDMappingPhiInZ="";
1717 nameESDMappingPhiInZ.Form("ESD_Conversion_Mapping_Phi_in_Z_%02d",zBin);
1718 // fHistograms->FillHistogram(nameESDMappingPhiInR, fV0Reader->GetMotherCandidatePhi());
1719 fHistograms->FillHistogram(nameESDMappingPhiInZ, vtxConv.Phi());
1721 if(fV0Reader->GetXYRadius()<rFMD){
1722 TString nameESDMappingFMDPhiInZ="";
1723 nameESDMappingFMDPhiInZ.Form("ESD_Conversion_Mapping_FMD_Phi_in_Z_%02d",zBin);
1724 fHistograms->FillHistogram(nameESDMappingFMDPhiInZ, vtxConv.Phi());
1727 if(fV0Reader->GetXYRadius()>rITSTPCMin && fV0Reader->GetXYRadius()<rITSTPCMax){
1728 TString nameESDMappingITSTPCPhiInZ="";
1729 nameESDMappingITSTPCPhiInZ.Form("ESD_Conversion_Mapping_ITSTPC_Phi_in_Z_%02d",zBin);
1730 fHistograms->FillHistogram(nameESDMappingITSTPCPhiInZ, vtxConv.Phi());
1733 TString nameESDMappingRInZ="";
1734 nameESDMappingRInZ.Form("ESD_Conversion_Mapping_R_in_Z_%02d",zBin);
1735 fHistograms->FillHistogram(nameESDMappingRInZ, fV0Reader->GetXYRadius());
1737 if(fV0Reader->GetMotherCandidatePt() > fLowPtMapping && fV0Reader->GetMotherCandidatePt()< fHighPtMapping){
1738 TString nameESDMappingMidPtPhiInR="";
1739 nameESDMappingMidPtPhiInR.Form("ESD_Conversion_Mapping_MidPt_Phi_in_R_%02d",rBin);
1740 fHistograms->FillHistogram(nameESDMappingMidPtPhiInR, vtxConv.Phi());
1742 TString nameESDMappingMidPtZInR="";
1743 nameESDMappingMidPtZInR.Form("ESD_Conversion_Mapping_MidPt_Z_in_R_%02d",rBin);
1744 fHistograms->FillHistogram(nameESDMappingMidPtZInR, fV0Reader->GetZ());
1746 TString nameESDMappingMidPtPhiInZ="";
1747 nameESDMappingMidPtPhiInZ.Form("ESD_Conversion_Mapping_MidPt_Phi_in_Z_%02d",zBin);
1748 fHistograms->FillHistogram(nameESDMappingMidPtPhiInZ, vtxConv.Phi());
1749 if(fV0Reader->GetXYRadius()<rFMD){
1750 TString nameESDMappingMidPtFMDPhiInZ="";
1751 nameESDMappingMidPtFMDPhiInZ.Form("ESD_Conversion_Mapping_MidPt_FMD_Phi_in_Z_%02d",zBin);
1752 fHistograms->FillHistogram(nameESDMappingMidPtFMDPhiInZ, vtxConv.Phi());
1756 TString nameESDMappingMidPtRInZ="";
1757 nameESDMappingMidPtRInZ.Form("ESD_Conversion_Mapping_MidPt_R_in_Z_%02d",zBin);
1758 fHistograms->FillHistogram(nameESDMappingMidPtRInZ, fV0Reader->GetXYRadius());
1765 new((*fKFReconstructedGammasTClone)[fKFReconstructedGammasTClone->GetEntriesFast()]) AliKFParticle(*fV0Reader->GetMotherCandidateKFCombination());
1766 fKFReconstructedGammasV0Index.push_back(fV0Reader->GetCurrentV0IndexNumber()-1);
1767 // fKFReconstructedGammas.push_back(*fV0Reader->GetMotherCandidateKFCombination());
1768 fElectronv1.push_back(fV0Reader->GetCurrentV0()->GetPindex());
1769 fElectronv2.push_back(fV0Reader->GetCurrentV0()->GetNindex());
1771 //----------------------------------- checking for "real" conversions (MC match) --------------------------------------
1773 TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
1774 TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
1776 if(fV0Reader->HasSameMCMother() == kFALSE){
1777 fHistograms->FillHistogram("ESD_TrueConvCombinatorial_R", fV0Reader->GetXYRadius());
1778 fHistograms->FillHistogram("ESD_TrueConvCombinatorial_Pt", fV0Reader->GetMotherCandidatePt());
1779 if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){
1780 fHistograms->FillHistogram("ESD_TrueConvCombinatorialElec_R", fV0Reader->GetXYRadius());
1781 fHistograms->FillHistogram("ESD_TrueConvCombinatorialElec_Pt", fV0Reader->GetMotherCandidatePt());
1785 // Moved up to check true electron background
1786 // TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
1787 // TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
1789 if(TMath::Abs(negativeMC->GetPdgCode())!=11 || TMath::Abs(positiveMC->GetPdgCode())!=11){
1790 fHistograms->FillHistogram("ESD_TrueConvHadronicBck_R", fV0Reader->GetXYRadius());
1791 fHistograms->FillHistogram("ESD_TrueConvHadronicBck_Pt", fV0Reader->GetMotherCandidatePt());
1795 if(negativeMC->GetPdgCode()==positiveMC->GetPdgCode()){
1799 UInt_t statusPos = fV0Reader->GetPositiveESDTrack()->GetStatus();
1800 UInt_t statusNeg = fV0Reader->GetNegativeESDTrack()->GetStatus();
1801 UChar_t itsPixelPos = fV0Reader->GetPositiveESDTrack()->GetITSClusterMap();
1802 UChar_t itsPixelNeg = fV0Reader->GetNegativeESDTrack()->GetITSClusterMap();
1804 // Using the UniqueID Phojet does not get the Dalitz right
1805 // if( (negativeMC->GetUniqueID() == 4 && positiveMC->GetUniqueID() ==4) ||
1806 // (negativeMC->GetUniqueID() == 0 && positiveMC->GetUniqueID() ==0) ){// fill r distribution for Dalitz decays
1807 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 111){ //pi0
1808 fHistograms->FillHistogram("ESD_TrueDalitzContamination_R", fV0Reader->GetXYRadius());
1809 fHistograms->FillHistogram("ESD_TrueConvDalitzPi0_R", fV0Reader->GetXYRadius());
1810 //--------Histos for HFE
1812 if(statusPos & AliESDtrack::kTOFpid){
1813 fHistograms->FillHistogram("ESD_TrueConvDalitzPi0_SinglePos_R", fV0Reader->GetXYRadius());
1814 if( TESTBIT(itsPixelPos, 0) ){
1815 fHistograms->FillHistogram("ESD_TrueConvDalitzPi0_SinglePos_kFirst_R", fV0Reader->GetXYRadius());
1818 if(statusNeg & AliESDtrack::kTOFpid){
1819 fHistograms->FillHistogram("ESD_TrueConvDalitzPi0_SingleNeg_R", fV0Reader->GetXYRadius());
1820 if( TESTBIT(itsPixelNeg, 0) ){
1821 fHistograms->FillHistogram("ESD_TrueConvDalitzPi0_SingleNeg_kFirst_R", fV0Reader->GetXYRadius());
1824 //--------------------------------------------------------
1827 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 221){ //eta
1828 fHistograms->FillHistogram("ESD_TrueConvDalitzEta_R", fV0Reader->GetXYRadius());
1833 if(negativeMC->GetUniqueID() != 5 || positiveMC->GetUniqueID() !=5){// check if the daughters come from a conversion
1837 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
1840 Double_t containerInput[3];
1841 containerInput[0] = fV0Reader->GetMotherCandidatePt();
1842 containerInput[1] = fV0Reader->GetMotherCandidateEta();
1843 containerInput[2] = fV0Reader->GetMotherCandidateMass();
1844 fCFManager->GetParticleContainer()->Fill(containerInput,kStepTrueGamma); // for CF
1847 fHistograms->FillHistogram("ESD_TrueConvGamma_Pt", fV0Reader->GetMotherCandidatePt());
1848 fHistograms->FillHistogram("ESD_TrueConvGamma_Energy", fV0Reader->GetMotherCandidateEnergy());
1849 fHistograms->FillHistogram("ESD_TrueConvGamma_Eta", fV0Reader->GetMotherCandidateEta());
1850 fHistograms->FillHistogram("ESD_TrueConvGamma_Phi", fV0Reader->GetMotherCandidatePhi());
1851 fHistograms->FillHistogram("ESD_TrueConvGamma_Mass", fV0Reader->GetMotherCandidateMass());
1852 fHistograms->FillHistogram("ESD_TrueConvGamma_Width", fV0Reader->GetMotherCandidateWidth());
1853 fHistograms->FillHistogram("ESD_TrueConvGamma_Chi2", fV0Reader->GetMotherCandidateChi2());
1854 fHistograms->FillHistogram("ESD_TrueConvGamma_NDF", fV0Reader->GetMotherCandidateNDF());
1855 fHistograms->FillHistogram("ESD_TrueConvGamma_Pt_Eta", fV0Reader->GetMotherCandidatePt(),fV0Reader->GetMotherCandidateEta());
1856 fHistograms->FillHistogram("ESD_TrueConvGamma_Rapid", fV0Reader->GetMotherCandidateRapidity());
1857 fHistograms->FillHistogram("ESD_TrueConvGamma_TrackLength", /*fV0Reader->GetNegativeTrackLength()*/fV0Reader->GetNegativeNTPCClusters());
1858 fHistograms->FillHistogram("ESD_TrueConvGamma_TrackLength", /*fV0Reader->GetPositiveTrackLength()*/fV0Reader->GetPositiveNTPCClusters());
1859 fHistograms->FillHistogram("ESD_TrueConvGamma_TrackLengthVSInvMass",/*fV0Reader->GetNegativeTrackLength()*/fV0Reader->GetNegativeNTPCClusters(),fV0Reader->GetMotherCandidateMass());
1860 fHistograms->FillHistogram("ESD_TrueConvGamma_TrackLengthVSInvMass",/*fV0Reader->GetPositiveTrackLength()*/fV0Reader->GetPositiveNTPCClusters(),fV0Reader->GetMotherCandidateMass());
1862 fHistograms->FillHistogram("ESD_TrueConvGamma_Pt_Chi2", fV0Reader->GetMotherCandidatePt(), fV0Reader->GetMotherCandidateChi2());
1863 fHistograms->FillHistogram("ESD_TrueConvGamma_Eta_Chi2", fV0Reader->GetMotherCandidateEta(), fV0Reader->GetMotherCandidateChi2());
1865 fHistograms->FillHistogram("ESD_TrueConversion_E_nTPCClustersToFR", fV0Reader->GetXYRadius(),eClsToF );
1866 fHistograms->FillHistogram("ESD_TrueConversion_P_nTPCClustersToFR",fV0Reader->GetXYRadius(), pClsToF);
1868 fHistograms->FillHistogram("ESD_TrueConversion_XY", fV0Reader->GetX(),fV0Reader->GetY());
1869 fHistograms->FillHistogram("ESD_TrueConversion_R", fV0Reader->GetXYRadius());
1870 fHistograms->FillHistogram("ESD_TrueConversion_ZR", fV0Reader->GetZ(),fV0Reader->GetXYRadius());
1871 fHistograms->FillHistogram("ESD_TrueConversion_OpeningAngle", fV0Reader->GetOpeningAngle());
1873 //----Histos for HFE--------------------------------------
1875 if(statusPos & AliESDtrack::kTOFpid){
1876 fHistograms->FillHistogram("ESD_TrueConversion_SinglePos_R", positiveMC->R(),fV0Reader->GetPositiveMCParticle()->Pt());
1877 if( TESTBIT(itsPixelPos, 0) ){
1878 fHistograms->FillHistogram("ESD_TrueConversion_SinglePos_kFirst_R", positiveMC->R(),fV0Reader->GetPositiveMCParticle()->Pt());
1881 if(statusNeg & AliESDtrack::kTOFpid){
1882 fHistograms->FillHistogram("ESD_TrueConversion_SingleNeg_R", negativeMC->R(),fV0Reader->GetNegativeMCParticle()->Pt());
1883 if( TESTBIT(itsPixelNeg, 0) ){
1884 fHistograms->FillHistogram("ESD_TrueConversion_SingleNeg_kFirst_R", negativeMC->R(),fV0Reader->GetNegativeMCParticle()->Pt());
1887 //--------------------------------------------------------
1889 fHistograms->FillHistogram("ESD_TrueConvGamma_CosPointingAngle", fV0Reader->GetCosPointingAngle());
1890 fHistograms->FillHistogram("ESD_TrueConvGamma_DcaDaughters", fV0Reader->GetDcaDaughters());
1891 fHistograms->FillHistogram("ESD_TrueConvGamma_NormDcaDistDaughters", fV0Reader->GetNormDcaDistDaughters());
1892 fHistograms->FillHistogram("ESD_TrueConvGamma_LikelihoodAP", fV0Reader->GetLikelihoodAP());
1893 if (fV0Reader->GetMotherCandidateP() != 0) {
1894 fHistograms->FillHistogram("ESD_TrueConvGamma_E_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetNegativeTrackP()/fV0Reader->GetMotherCandidateP());
1895 fHistograms->FillHistogram("ESD_TrueConvGamma_P_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetPositiveTrackP()/fV0Reader->GetMotherCandidateP());
1896 } else { cout << "Error::fV0Reader->GetNegativeTrackP() == 0 !!!" << endl; }
1898 fHistograms->FillHistogram("ESD_TrueConvGamma_E_dEdxP",fV0Reader->GetNegativeTrackP(),fV0Reader->GetNegativeTrackTPCdEdx());
1899 fHistograms->FillHistogram("ESD_TrueConvGamma_P_dEdxP",fV0Reader->GetPositiveTrackP(),fV0Reader->GetPositiveTrackTPCdEdx());
1900 fHistograms->FillHistogram("ESD_TrueConvGamma_alfa_qt",armenterosQtAlfa[1],armenterosQtAlfa[0]);
1904 //store MCTruth properties
1905 fHistograms->FillHistogram("ESD_TrueConvGamma_MC_Pt_Eta", fV0Reader->GetMotherMCParticle()->Pt(),fV0Reader->GetMotherMCParticle()->Eta());
1906 fHistograms->FillHistogram("ESD_TrueConversion_MC_ZR", negativeMC->Vz(),negativeMC->R());
1907 fHistograms->FillHistogram("ESD_TrueConversion_MC_XY", negativeMC->Vx(),negativeMC->Vy());
1910 Double_t mcpt = fV0Reader->GetMotherMCParticle()->Pt();
1911 Double_t esdpt = fV0Reader->GetMotherCandidatePt();
1912 Double_t resdPt = 0.;
1914 resdPt = ((esdpt - mcpt)/mcpt)*100.;
1917 cout<<"Pt of MC particle is negative, this will cause wrong calculation of resPt"<<endl;
1920 fHistograms->FillHistogram("Resolution_Gamma_dPt_Pt", mcpt, resdPt);
1921 fHistograms->FillHistogram("Resolution_MC_Pt", mcpt);
1922 fHistograms->FillHistogram("Resolution_ESD_Pt", esdpt);
1923 fHistograms->FillHistogram("Resolution_Gamma_dPt_Phi", fV0Reader->GetMotherCandidatePhi(), resdPt);
1925 Double_t resdZ = 0.;
1926 if(fV0Reader->GetNegativeMCParticle()->Vz() != 0){
1927 resdZ = ((fV0Reader->GetZ() -fV0Reader->GetNegativeMCParticle()->Vz())/fV0Reader->GetNegativeMCParticle()->Vz())*100.;
1929 Double_t resdZAbs = 0.;
1930 resdZAbs = (fV0Reader->GetZ() -fV0Reader->GetNegativeMCParticle()->Vz());
1932 fHistograms->FillHistogram("Resolution_dZAbs_VS_R", fV0Reader->GetNegativeMCParticle()->R(), resdZAbs);
1933 fHistograms->FillHistogram("Resolution_dZ", fV0Reader->GetNegativeMCParticle()->Vz(), resdZ);
1934 fHistograms->FillHistogram("Resolution_MC_Z", fV0Reader->GetNegativeMCParticle()->Vz());
1935 fHistograms->FillHistogram("Resolution_ESD_Z", fV0Reader->GetZ());
1937 // new for dPt_Pt-histograms for Electron and Positron
1938 Double_t mcEpt = fV0Reader->GetNegativeMCParticle()->Pt();
1939 Double_t resEdPt = 0.;
1941 resEdPt = ((fV0Reader->GetNegativeTrackPt()-mcEpt)/mcEpt)*100.;
1943 UInt_t statusN = fV0Reader->GetNegativeESDTrack()->GetStatus();
1944 // AliESDtrack * negTrk = fV0Reader->GetNegativeESDTrack();
1945 UInt_t kTRDoutN = (statusN & AliESDtrack::kTRDout);
1947 Int_t nITSclsE= fV0Reader->GetNegativeTracknITSClusters();
1948 // filling Resolution_Pt_dPt with respect to the Number of ITS clusters for Positrons
1950 case 0: // 0 ITS clusters
1951 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS0", mcEpt, resEdPt);
1953 case 1: // 1 ITS cluster
1954 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS1", mcEpt, resEdPt);
1956 case 2: // 2 ITS clusters
1957 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS2", mcEpt, resEdPt);
1959 case 3: // 3 ITS clusters
1960 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS3", mcEpt, resEdPt);
1962 case 4: // 4 ITS clusters
1963 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS4", mcEpt, resEdPt);
1965 case 5: // 5 ITS clusters
1966 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS5", mcEpt, resEdPt);
1968 case 6: // 6 ITS clusters
1969 fHistograms->FillHistogram("Resolution_E_dPt_Pt_ITS6", mcEpt, resEdPt);
1972 //Filling histograms with respect to Electron resolution
1973 fHistograms->FillHistogram("Resolution_E_dPt_Pt", mcEpt, resEdPt);
1974 fHistograms->FillHistogram("Resolution_E_dPt_Phi", fV0Reader->GetNegativeTrackPhi(), resEdPt);
1976 fHistograms->FillHistogram("Resolution_E_nTRDtracklets_ESDPt", fV0Reader->GetNegativeTrackPt(), fV0Reader->GetNegativeESDTrack()->GetTRDntracklets());
1977 fHistograms->FillHistogram("Resolution_E_nTRDtracklets_MCPt", mcEpt, fV0Reader->GetNegativeESDTrack()->GetTRDntracklets());
1978 fHistograms->FillHistogram("Resolution_E_nTRDclusters_ESDPt",fV0Reader->GetNegativeTrackPt(), fV0Reader->GetNegativeESDTrack()->GetTRDncls());
1979 fHistograms->FillHistogram("Resolution_E_nTRDclusters_MCPt",mcEpt, fV0Reader->GetNegativeESDTrack()->GetTRDncls());
1980 fHistograms->FillHistogram("Resolution_E_TRDsignal_ESDPt", fV0Reader->GetNegativeTrackPt(), fV0Reader->GetNegativeESDTrack()->GetTRDsignal());
1983 Double_t mcPpt = fV0Reader->GetPositiveMCParticle()->Pt();
1984 Double_t resPdPt = 0;
1986 resPdPt = ((fV0Reader->GetPositiveTrackPt()-mcPpt)/mcPpt)*100.;
1989 UInt_t statusP = fV0Reader->GetPositiveESDTrack()->GetStatus();
1990 // AliESDtrack * posTr= fV0Reader->GetPositiveESDTrack();
1991 UInt_t kTRDoutP = (statusP & AliESDtrack::kTRDout);
1993 Int_t nITSclsP = fV0Reader->GetPositiveTracknITSClusters();
1994 // filling Resolution_Pt_dPt with respect to the Number of ITS clusters for Positrons
1996 case 0: // 0 ITS clusters
1997 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS0", mcPpt, resPdPt);
1999 case 1: // 1 ITS cluster
2000 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS1", mcPpt, resPdPt);
2002 case 2: // 2 ITS clusters
2003 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS2", mcPpt, resPdPt);
2005 case 3: // 3 ITS clusters
2006 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS3", mcPpt, resPdPt);
2008 case 4: // 4 ITS clusters
2009 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS4", mcPpt, resPdPt);
2011 case 5: // 5 ITS clusters
2012 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS5", mcPpt, resPdPt);
2014 case 6: // 6 ITS clusters
2015 fHistograms->FillHistogram("Resolution_P_dPt_Pt_ITS6", mcPpt, resPdPt);
2018 //Filling histograms with respect to Positron resolution
2019 fHistograms->FillHistogram("Resolution_P_dPt_Pt", mcPpt, resPdPt);
2020 fHistograms->FillHistogram("Resolution_P_dPt_Phi", fV0Reader->GetPositiveTrackPhi(), resPdPt);
2022 fHistograms->FillHistogram("Resolution_P_nTRDtracklets_ESDPt", fV0Reader->GetPositiveTrackPt(), fV0Reader->GetPositiveESDTrack()->GetTRDntracklets());
2023 fHistograms->FillHistogram("Resolution_P_nTRDtracklets_MCPt", mcPpt, fV0Reader->GetPositiveESDTrack()->GetTRDntracklets());
2024 fHistograms->FillHistogram("Resolution_P_nTRDclusters_ESDPt",fV0Reader->GetPositiveTrackPt(), fV0Reader->GetPositiveESDTrack()->GetTRDncls());
2025 fHistograms->FillHistogram("Resolution_P_nTRDclusters_MCPt",mcPpt, fV0Reader->GetPositiveESDTrack()->GetTRDncls());
2026 fHistograms->FillHistogram("Resolution_P_TRDsignal_ESDPt", fV0Reader->GetPositiveTrackPt(), fV0Reader->GetPositiveESDTrack()->GetTRDsignal());
2030 Double_t resdR = 0.;
2031 if(fV0Reader->GetNegativeMCParticle()->R() != 0){
2032 resdR = ((fV0Reader->GetXYRadius() - fV0Reader->GetNegativeMCParticle()->R())/fV0Reader->GetNegativeMCParticle()->R())*100.;
2034 Double_t resdRAbs = 0.;
2035 resdRAbs = (fV0Reader->GetXYRadius() - fV0Reader->GetNegativeMCParticle()->R());
2037 fHistograms->FillHistogram("Resolution_dRAbs_VS_R", fV0Reader->GetNegativeMCParticle()->R(), resdRAbs);
2038 fHistograms->FillHistogram("Resolution_dR", fV0Reader->GetNegativeMCParticle()->R(), resdR);
2039 fHistograms->FillHistogram("Resolution_MC_R", fV0Reader->GetNegativeMCParticle()->R());
2040 fHistograms->FillHistogram("Resolution_ESD_R", fV0Reader->GetXYRadius());
2041 fHistograms->FillHistogram("Resolution_R_dPt", fV0Reader->GetNegativeMCParticle()->R(), resdPt);
2043 Double_t resdPhiAbs=0.;
2045 resdPhiAbs= (fV0Reader->GetMotherCandidatePhi()-fV0Reader->GetNegativeMCParticle()->Phi());
2046 fHistograms->FillHistogram("Resolution_dPhiAbs_VS_R", fV0Reader->GetNegativeMCParticle()->R(), resdPhiAbs);
2048 }//if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22)
2050 }//while(fV0Reader->NextV0)
2051 fHistograms->FillHistogram("ESD_NumberOfSurvivingV0s", nSurvivingV0s);
2052 fHistograms->FillHistogram("ESD_NumberOfV0s", fV0Reader->GetNumberOfV0s());
2053 fHistograms->FillHistogram("ESD_NumberOfContributorsVtx", fV0Reader->GetNumberOfContributorsVtx());
2055 fV0Reader->ResetV0IndexNumber();
2058 void AliAnalysisTaskGammaConversion::AddToAODBranch(TClonesArray * branch, AliAODPWG4Particle & particle) {
2059 //See header file for documentation
2061 Int_t i = branch->GetEntriesFast();
2062 if(! (fOutputAODClassName.Contains("Correlation")) ) {
2063 new((*branch)[i]) AliAODPWG4Particle(particle);
2065 new((*branch)[i]) AliAODPWG4ParticleCorrelation(particle);
2069 void AliAnalysisTaskGammaConversion::AddToAODBranch(TClonesArray * branch, AliGammaConversionAODObject & particle) {
2070 //See header file for documentation
2072 Int_t i = branch->GetEntriesFast();
2073 new((*branch)[i]) AliGammaConversionAODObject(particle);
2076 void AliAnalysisTaskGammaConversion::AddToAODBranch(TClonesArray * branch, AliAODConversionParticle & particle) {
2077 //See header file for documentation
2079 Int_t i = branch->GetEntriesFast();
2080 new((*branch)[i]) AliAODConversionParticle(particle);
2084 void AliAnalysisTaskGammaConversion::FillAODWithConversionGammas(){
2085 // Fill AOD with reconstructed Gamma
2087 for(Int_t gammaIndex=0;gammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();gammaIndex++){
2088 AliKFParticle * gammakf = dynamic_cast<AliKFParticle*>(fKFReconstructedGammasTClone->At(gammaIndex));
2090 if(fOutputAODClassName.Contains("AliAODPWG4Particle")) {
2091 AliAODPWG4Particle gamma = AliAODPWG4Particle(gammakf->Px(),gammakf->Py(),gammakf->Pz(), gammakf->E());
2092 //gamma.SetLabel(-1);//How to get the MC label of the reconstructed gamma?
2093 gamma.SetTrackLabel( fElectronv1[gammaIndex], fElectronv2[gammaIndex] ); //How to get the MC label of the 2 electrons that form the gamma?
2094 gamma.SetDetector("CTS"); //tag the gamma as reconstructed in the central barrel
2095 gamma.SetPdg(AliPID::kEleCon); //photon id
2096 gamma.SetTag(-1); //Here I usually put a flag saying that montecarlo says it is prompt, decay fragmentation photon, or hadrons or whatever
2097 //PH gamma.SetChi2(gammakf->Chi2());
2099 AddToAODBranch(fAODGamma, gamma);
2101 } else if(fOutputAODClassName.Contains("ConversionParticle")) {
2102 TLorentzVector momentum(gammakf->Px(),gammakf->Py(),gammakf->Pz(), gammakf->E());
2103 AliAODConversionParticle gamma = AliAODConversionParticle(momentum);
2104 //gamma.SetLabel(-1);//How to get the MC label of the reconstructed gamma?
2105 gamma.SetTrackLabels( fElectronv1[gammaIndex], fElectronv2[gammaIndex] ); //How to get the MC label of the 2 electrons that form the gamma?
2106 //gamma.SetPdg(AliPID::kEleCon); //photon id
2107 //gamma.SetTag(-1); //Here I usually put a flag saying that montecarlo says it is prompt, decay fragmentation photon, or hadrons or whatever
2108 //PH gamma.SetChi2(gammakf->Chi2());
2109 gamma.SetTrackLabels( fElectronv1[gammaIndex], fElectronv2[gammaIndex] );
2110 gamma.SetESDEvent(dynamic_cast<AliESDEvent*>(InputEvent()));
2111 AddToAODBranch(fAODGamma, gamma);
2116 AliGammaConversionAODObject gamma;
2117 gamma.SetPx(gammakf->GetPx());
2118 gamma.SetPy(gammakf->GetPy());
2119 gamma.SetPz(gammakf->GetPz());
2120 gamma.SetE(gammakf->GetE());
2121 gamma.SetLabel1(fElectronv1[gammaIndex]);
2122 gamma.SetLabel2(fElectronv2[gammaIndex]);
2123 gamma.SetChi2(gammakf->Chi2());
2124 gamma.SetE(gammakf->E());
2125 gamma.SetESDEvent(dynamic_cast<AliESDEvent*>(InputEvent()));
2126 AddToAODBranch(fAODGamma, gamma);
2131 void AliAnalysisTaskGammaConversion::ProcessGammasForOmegaMesonAnalysis(){
2132 // omega meson analysis pi0+gamma decay
2133 for(Int_t firstPi0Index=0;firstPi0Index<fKFReconstructedPi0sTClone->GetEntriesFast();firstPi0Index++){
2134 AliKFParticle * omegaCandidatePi0Daughter = (AliKFParticle *)fKFReconstructedPi0sTClone->At(firstPi0Index);
2135 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();firstGammaIndex++){
2137 AliKFParticle * omegaCandidateGammaDaughter = (AliKFParticle *)fKFReconstructedGammasTClone->At(firstGammaIndex);
2138 if(fGammav1[firstPi0Index]==firstGammaIndex || fGammav2[firstPi0Index]==firstGammaIndex){
2142 AliKFParticle omegaCandidate(*omegaCandidatePi0Daughter,*omegaCandidateGammaDaughter);
2143 Double_t massOmegaCandidate = 0.;
2144 Double_t widthOmegaCandidate = 0.;
2146 omegaCandidate.GetMass(massOmegaCandidate,widthOmegaCandidate);
2148 if ( massOmegaCandidate > 733 && massOmegaCandidate < 833 ) {
2149 //AddOmegaToAOD(&omegaCandidate, massOmegaCandidate, firstPi0Index, firstGammaIndex);
2152 fHistograms->FillHistogram("ESD_Omega_InvMass_vs_Pt",massOmegaCandidate ,omegaCandidate.GetPt());
2153 fHistograms->FillHistogram("ESD_Omega_InvMass",massOmegaCandidate);
2155 //delete omegaCandidate;
2157 }// end of omega reconstruction in pi0+gamma channel
2159 if(fDoJet == kTRUE){
2160 AliKFParticle* negPiKF=NULL;
2161 AliKFParticle* posPiKF=NULL;
2163 // look at the pi+pi+pi0 channel
2164 for(Int_t iCh=0;iCh<fChargedParticles->GetEntriesFast();iCh++){
2165 AliESDtrack* posTrack = (AliESDtrack*)(fChargedParticles->At(iCh));
2166 if (posTrack->GetSign()<0) continue;
2167 if(TMath::Abs(fV0Reader->GetESDpid()->NumberOfSigmasTPC(posTrack,AliPID::kPion))>2.) continue;
2168 if (posPiKF) delete posPiKF; posPiKF=NULL;
2169 posPiKF = new AliKFParticle( *(posTrack) ,211);
2171 for(Int_t jCh=0;jCh<fChargedParticles->GetEntriesFast();jCh++){
2172 AliESDtrack* negTrack = (AliESDtrack*)(fChargedParticles->At(jCh));
2173 if( negTrack->GetSign()>0) continue;
2174 if(TMath::Abs(fV0Reader->GetESDpid()->NumberOfSigmasTPC(negTrack,AliPID::kPion))>2.) continue;
2175 if (negPiKF) delete negPiKF; negPiKF=NULL;
2176 negPiKF = new AliKFParticle( *(negTrack) ,-211);
2177 AliKFParticle omegaCandidatePipPinPi0(*omegaCandidatePi0Daughter,*posPiKF,*negPiKF);
2178 Double_t massOmegaCandidatePipPinPi0 = 0.;
2179 Double_t widthOmegaCandidatePipPinPi0 = 0.;
2181 omegaCandidatePipPinPi0.GetMass(massOmegaCandidatePipPinPi0,widthOmegaCandidatePipPinPi0);
2183 if ( massOmegaCandidatePipPinPi0 > 733 && massOmegaCandidatePipPinPi0 < 833 ) {
2184 // AddOmegaToAOD(&omegaCandidatePipPinPi0, massOmegaCandidatePipPinPi0, -1, -1);
2187 fHistograms->FillHistogram("ESD_OmegaPipPinPi0_InvMass_vs_Pt",massOmegaCandidatePipPinPi0 ,omegaCandidatePipPinPi0.GetPt());
2188 fHistograms->FillHistogram("ESD_OmegaPipPinPi0_InvMass",massOmegaCandidatePipPinPi0);
2190 // delete omegaCandidatePipPinPi0;
2194 if (posPiKF) delete posPiKF; posPiKF=NULL; if (negPiKF) delete negPiKF; negPiKF=NULL;
2196 } // checking ig gammajet because in that case the chargedparticle list is created
2200 if(fCalculateBackground){
2202 AliGammaConversionBGHandler * bgHandler = fV0Reader->GetBGHandler();
2204 Int_t zbin= bgHandler->GetZBinIndex(fV0Reader->GetVertexZ());
2206 if(fUseTrackMultiplicityForBG == kTRUE){
2207 mbin = bgHandler->GetMultiplicityBinIndex(fV0Reader->CountESDTracks());
2210 mbin = bgHandler->GetMultiplicityBinIndex(fV0Reader->GetNGoodV0s());
2213 AliGammaConversionBGHandler::GammaConversionVertex *bgEventVertex = NULL;
2215 // Background calculation for the omega
2216 for(Int_t nEventsInBG=0;nEventsInBG <fV0Reader->GetNBGEvents();nEventsInBG++){
2217 AliGammaConversionKFVector * previousEventV0s = bgHandler->GetBGGoodV0s(zbin,mbin,nEventsInBG);
2219 if(fMoveParticleAccordingToVertex == kTRUE){
2220 bgEventVertex = bgHandler->GetBGEventVertex(zbin,mbin,nEventsInBG);
2222 for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
2223 AliKFParticle previousGoodV0 = (AliKFParticle)(*(previousEventV0s->at(iPrevious)));
2225 if(fMoveParticleAccordingToVertex == kTRUE){
2226 MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
2229 for(Int_t firstPi0Index=0;firstPi0Index<fKFReconstructedPi0sTClone->GetEntriesFast();firstPi0Index++){
2230 AliKFParticle * omegaCandidatePi0Daughter = (AliKFParticle *)fKFReconstructedPi0sTClone->At(firstPi0Index);
2231 AliKFParticle * omegaBckCandidate = new AliKFParticle(*omegaCandidatePi0Daughter,previousGoodV0);
2232 Double_t massOmegaBckCandidate = 0.;
2233 Double_t widthOmegaBckCandidate = 0.;
2235 omegaBckCandidate->GetMass(massOmegaBckCandidate,widthOmegaBckCandidate);
2238 fHistograms->FillHistogram("ESD_Omega_Bck_InvMass_vs_Pt",massOmegaBckCandidate ,omegaBckCandidate->GetPt());
2239 fHistograms->FillHistogram("ESD_Omega_Bck_InvMass",massOmegaBckCandidate);
2241 delete omegaBckCandidate;
2245 } // end of checking if background calculation is available
2249 void AliAnalysisTaskGammaConversion::AddOmegaToAOD(const AliKFParticle * const omegakf, Double_t mass, Int_t omegaDaughter, Int_t gammaDaughter) {
2250 //See header file for documentation
2251 AliGammaConversionAODObject omega;
2252 omega.SetPx(omegakf->GetPx());
2253 omega.SetPy(omegakf->GetPy());
2254 omega.SetPz(omegakf->GetPz());
2255 omega.SetChi2(omegakf->GetChi2());
2256 omega.SetE(omegakf->GetE());
2257 omega.SetIMass(mass);
2258 omega.SetLabel1(omegaDaughter);
2259 // //dynamic_cast<AliAODPWG4Particle*>(fAODBranch->At(daughter1))->SetTagged(kTRUE);
2260 omega.SetLabel2(gammaDaughter);
2261 AddToAODBranch(fAODOmega, omega);
2266 void AliAnalysisTaskGammaConversion::ProcessGammasForNeutralMesonAnalysis(){
2267 // see header file for documentation
2269 // for(UInt_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammas.size();firstGammaIndex++){
2270 // for(UInt_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fKFReconstructedGammas.size();secondGammaIndex++){
2272 fESDEvent = fV0Reader->GetESDEvent();
2274 if(fKFReconstructedGammasTClone->GetEntriesFast()>fV0Reader->GetNumberOfV0s()){
2275 cout<<"Warning, number of entries in the tclone is bigger than number of v0s"<<endl;
2278 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();firstGammaIndex++){
2279 for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();secondGammaIndex++){
2281 // AliKFParticle * twoGammaDecayCandidateDaughter0 = &fKFReconstructedGammas[firstGammaIndex];
2282 // AliKFParticle * twoGammaDecayCandidateDaughter1 = &fKFReconstructedGammas[secondGammaIndex];
2284 AliKFParticle * twoGammaDecayCandidateDaughter0 = (AliKFParticle *)fKFReconstructedGammasTClone->At(firstGammaIndex);
2285 AliKFParticle * twoGammaDecayCandidateDaughter1 = (AliKFParticle *)fKFReconstructedGammasTClone->At(secondGammaIndex);
2287 if(fElectronv1[firstGammaIndex]==fElectronv1[secondGammaIndex] || fElectronv1[firstGammaIndex]==fElectronv2[secondGammaIndex]){
2290 if(fElectronv2[firstGammaIndex]==fElectronv1[secondGammaIndex] || fElectronv2[firstGammaIndex]==fElectronv2[secondGammaIndex]){
2294 AliKFParticle *twoGammaCandidate = new AliKFParticle(*twoGammaDecayCandidateDaughter0,*twoGammaDecayCandidateDaughter1);
2296 Double_t massTwoGammaCandidate = 0.;
2297 Double_t widthTwoGammaCandidate = 0.;
2298 Double_t chi2TwoGammaCandidate =10000.;
2299 twoGammaCandidate->GetMass(massTwoGammaCandidate,widthTwoGammaCandidate);
2300 // if(twoGammaCandidate->GetNDF()>0){
2301 // chi2TwoGammaCandidate = twoGammaCandidate->GetChi2()/twoGammaCandidate->GetNDF();
2302 chi2TwoGammaCandidate = twoGammaCandidate->GetChi2();
2304 fHistograms->FillHistogram("ESD_Mother_Chi2",chi2TwoGammaCandidate);
2305 if((chi2TwoGammaCandidate>0 && chi2TwoGammaCandidate<fV0Reader->GetChi2CutMeson()) || fApplyChi2Cut == kFALSE){
2307 TVector3 momentumVectorTwoGammaCandidate(twoGammaCandidate->GetPx(),twoGammaCandidate->GetPy(),twoGammaCandidate->GetPz());
2308 TVector3 spaceVectorTwoGammaCandidate(twoGammaCandidate->GetX(),twoGammaCandidate->GetY(),twoGammaCandidate->GetZ());
2310 Double_t openingAngleTwoGammaCandidate = twoGammaDecayCandidateDaughter0->GetAngle(*twoGammaDecayCandidateDaughter1);
2312 if(twoGammaCandidate->GetE() - twoGammaCandidate->GetPz() <= 0 || twoGammaCandidate->GetE() + twoGammaCandidate->GetPz() <= 0){
2313 cout << "Error: |Pz| > E !!!! " << endl;
2317 rapidity = 0.5*(TMath::Log((twoGammaCandidate->GetE() +twoGammaCandidate->GetPz()) / (twoGammaCandidate->GetE()-twoGammaCandidate->GetPz())));
2320 if(TMath::Abs(rapidity) > fV0Reader->GetRapidityMesonCut()){
2321 delete twoGammaCandidate;
2322 continue; // rapidity cut
2327 if( (twoGammaDecayCandidateDaughter0->GetE()+twoGammaDecayCandidateDaughter1->GetE()) != 0){
2328 alfa=TMath::Abs((twoGammaDecayCandidateDaughter0->GetE()-twoGammaDecayCandidateDaughter1->GetE())
2329 /(twoGammaDecayCandidateDaughter0->GetE()+twoGammaDecayCandidateDaughter1->GetE()));
2332 if(openingAngleTwoGammaCandidate < fMinOpeningAngleGhostCut){
2333 delete twoGammaCandidate;
2334 continue; // minimum opening angle to avoid using ghosttracks
2337 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
2338 fHistograms->FillHistogram("ESD_Mother_GammaDaughter_OpeningAngle", openingAngleTwoGammaCandidate);
2339 fHistograms->FillHistogram("ESD_Mother_Energy", twoGammaCandidate->GetE());
2340 fHistograms->FillHistogram("ESD_Mother_Pt", momentumVectorTwoGammaCandidate.Pt());
2341 fHistograms->FillHistogram("ESD_Mother_Eta", momentumVectorTwoGammaCandidate.Eta());
2342 fHistograms->FillHistogram("ESD_Mother_Rapid", rapidity);
2343 fHistograms->FillHistogram("ESD_Mother_Phi", spaceVectorTwoGammaCandidate.Phi());
2344 fHistograms->FillHistogram("ESD_Mother_Mass", massTwoGammaCandidate);
2345 fHistograms->FillHistogram("ESD_Mother_alfa", alfa);
2346 if(massTwoGammaCandidate>0.1 && massTwoGammaCandidate<0.15){
2347 fHistograms->FillHistogram("ESD_Mother_alfa_Pi0", alfa);
2349 if(massTwoGammaCandidate>0.5 && massTwoGammaCandidate<0.57){
2350 fHistograms->FillHistogram("ESD_Mother_alfa_Eta", alfa);
2353 fHistograms->FillHistogram("ESD_Mother_R", spaceVectorTwoGammaCandidate.Pt()); // Pt in Space == R!!!
2354 fHistograms->FillHistogram("ESD_Mother_ZR", twoGammaCandidate->GetZ(), spaceVectorTwoGammaCandidate.Pt());
2355 fHistograms->FillHistogram("ESD_Mother_XY", twoGammaCandidate->GetX(), twoGammaCandidate->GetY());
2356 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2357 fHistograms->FillHistogram("ESD_Mother_InvMass",massTwoGammaCandidate);
2358 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt_alpha",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2361 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_E_alpha",massTwoGammaCandidate ,twoGammaCandidate->GetE());
2365 if(fCalculateBackground){
2366 /* Kenneth, just for testing*/
2367 AliGammaConversionBGHandler * bgHandlerTest = fV0Reader->GetBGHandler();
2369 Int_t zbin= bgHandlerTest->GetZBinIndex(fV0Reader->GetVertexZ());
2372 if(fUseTrackMultiplicityForBG == kTRUE){
2373 multKAA=fV0Reader->CountESDTracks();
2374 mbin = bgHandlerTest->GetMultiplicityBinIndex(fV0Reader->CountESDTracks());
2376 else{// means we use #v0s for multiplicity
2377 multKAA=fV0Reader->GetNGoodV0s();
2378 mbin = bgHandlerTest->GetMultiplicityBinIndex(fV0Reader->GetNGoodV0s());
2380 // cout<<"Filling bin number "<<zbin<<" and "<<mbin<<endl;
2381 // cout<<"Corresponding to z = "<<fV0Reader->GetVertexZ()<<" and m = "<<multKAA<<endl;
2382 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
2383 fHistograms->FillHistogram(Form("%d%dESD_Mother_InvMass",zbin,mbin),massTwoGammaCandidate);
2384 fHistograms->FillHistogram(Form("%d%dESD_Mother_InvMass_vs_Pt",zbin,mbin),massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2385 /* end Kenneth, just for testing*/
2386 fHistograms->FillHistogram(Form("%dESD_Mother_InvMass_vs_Pt",mbin),massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2389 /* if(fCalculateBackground){
2390 AliGammaConversionBGHandler * bgHandler = fV0Reader->GetBGHandler();
2391 Int_t mbin= bgHandler->GetMultiplicityBinIndex(fV0Reader->CountESDTracks());
2392 fHistograms->FillHistogram(Form("%dESD_Mother_InvMass_vs_Pt",mbin),massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2394 // if(fDoNeutralMesonV0MCCheck){
2396 //Kenneth: Checking the eta of the gamma to check the difference between 0.9 and 1.2
2397 Int_t indexKF1 = fKFReconstructedGammasV0Index.at(firstGammaIndex);
2398 if(indexKF1<fV0Reader->GetNumberOfV0s()){
2399 fV0Reader->GetV0(indexKF1);//updates to the correct v0
2400 Double_t eta1 = fV0Reader->GetMotherCandidateEta();
2401 Bool_t isRealPi0=kFALSE;
2402 Bool_t isRealEta=kFALSE;
2403 Int_t gamma1MotherLabel=-1;
2404 if(fV0Reader->HasSameMCMother() == kTRUE){
2405 //cout<<"This v0 is a real v0!!!!"<<endl;
2406 TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
2407 TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
2408 if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){
2409 if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){
2410 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
2411 gamma1MotherLabel=fV0Reader->GetMotherMCParticle()->GetFirstMother();
2414 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() ==111){
2415 gamma1MotherLabel=-111;
2417 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() ==221){
2418 gamma1MotherLabel=-221;
2422 Int_t indexKF2 = fKFReconstructedGammasV0Index.at(secondGammaIndex);
2423 if(indexKF1 == indexKF2){
2424 cout<<"index of the two KF particles are the same.... should not happen"<<endl;
2426 if(indexKF2<fV0Reader->GetNumberOfV0s()){
2427 fV0Reader->GetV0(indexKF2);
2428 Double_t eta2 = fV0Reader->GetMotherCandidateEta();
2429 Int_t gamma2MotherLabel=-1;
2430 if(fV0Reader->HasSameMCMother() == kTRUE){
2431 TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
2432 TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
2433 if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){
2434 if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){
2435 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
2436 gamma2MotherLabel=fV0Reader->GetMotherMCParticle()->GetFirstMother();
2439 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() ==111){
2440 gamma2MotherLabel=-111;
2442 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() ==221){
2443 gamma2MotherLabel=-221;
2448 if(gamma1MotherLabel>=0 && gamma1MotherLabel==gamma2MotherLabel){
2449 if(fV0Reader->CheckIfPi0IsMother(gamma1MotherLabel)){
2452 if(fV0Reader->CheckIfEtaIsMother(gamma1MotherLabel)){
2457 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
2458 if(TMath::Abs(eta1)>0.9 && TMath::Abs(eta2)>0.9){
2459 // fHistograms->FillHistogram("ESD_Mother_InvMass_1212",massTwoGammaCandidate);
2460 // fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt1212",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2461 if(isRealPi0 || isRealEta){
2462 fHistograms->FillHistogram("ESD_TruePi0_InvMass_1212",massTwoGammaCandidate);
2463 fHistograms->FillHistogram("ESD_TruePi0_OpeningAngle_1212",openingAngleTwoGammaCandidate);
2464 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt1212",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2465 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2466 fHistograms->FillHistogram("ESD_TruePi0_InvMass",massTwoGammaCandidate);
2467 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt_alpha",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2470 if(!isRealPi0 && !isRealEta){
2471 if(gamma1MotherLabel>-1 && gamma2MotherLabel>-1){
2472 fHistograms->FillHistogram("ESD_TrueBckGG_InvMass_vs_Pt",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2474 fHistograms->FillHistogram("ESD_TrueBckCont_InvMass_vs_Pt",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2476 if(gamma1MotherLabel==-111 || gamma2MotherLabel==-111 || gamma1MotherLabel==-221 || gamma2MotherLabel==-221){
2477 fHistograms->FillHistogram("ESD_TruePi0DalitzCont_InvMass_vs_Pt",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2482 else if(TMath::Abs(eta1)>0.9 || TMath::Abs(eta2)>0.9){
2483 // fHistograms->FillHistogram("ESD_Mother_InvMass_0912",massTwoGammaCandidate);
2484 // fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt0912",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2486 if(isRealPi0 || isRealEta){
2487 fHistograms->FillHistogram("ESD_TruePi0_InvMass_0912",massTwoGammaCandidate);
2488 fHistograms->FillHistogram("ESD_TruePi0_OpeningAngle_0912",openingAngleTwoGammaCandidate);
2489 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt0912",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2490 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2491 fHistograms->FillHistogram("ESD_TruePi0_InvMass",massTwoGammaCandidate);
2492 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt_alpha",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2494 if(!isRealPi0 && !isRealEta){
2495 if(gamma1MotherLabel>-1 && gamma2MotherLabel>-1){
2496 fHistograms->FillHistogram("ESD_TrueBckGG_InvMass_vs_Pt",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2498 fHistograms->FillHistogram("ESD_TrueBckCont_InvMass_vs_Pt",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2500 if(gamma1MotherLabel==-111 || gamma2MotherLabel==-111 || gamma1MotherLabel==-221 || gamma2MotherLabel==-221){
2501 fHistograms->FillHistogram("ESD_TruePi0DalitzCont_InvMass_vs_Pt",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2506 // fHistograms->FillHistogram("ESD_Mother_InvMass_0909",massTwoGammaCandidate);
2507 // fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt0909",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2508 if(isRealPi0 || isRealEta){
2509 fHistograms->FillHistogram("ESD_TruePi0_InvMass_0909",massTwoGammaCandidate);
2510 fHistograms->FillHistogram("ESD_TruePi0_OpeningAngle_0909",openingAngleTwoGammaCandidate);
2511 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt0909",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2512 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2513 fHistograms->FillHistogram("ESD_TruePi0_InvMass",massTwoGammaCandidate);
2514 fHistograms->FillHistogram("ESD_TruePi0_InvMass_vs_Pt_alpha",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2515 if(gamma1MotherLabel > fV0Reader->GetMCStack()->GetNprimary()){
2516 fHistograms->FillHistogram("ESD_TruePi0Sec_InvMass_vs_Pt",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2519 if(!isRealPi0 && !isRealEta){
2520 if(gamma1MotherLabel>-1 && gamma2MotherLabel>-1){
2521 fHistograms->FillHistogram("ESD_TrueBckGG_InvMass_vs_Pt",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2523 fHistograms->FillHistogram("ESD_TrueBckCont_InvMass_vs_Pt",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2525 if(gamma1MotherLabel==-111 || gamma2MotherLabel==-111 || gamma1MotherLabel==-221 || gamma2MotherLabel==-221 ){
2526 fHistograms->FillHistogram("ESD_TruePi0DalitzCont_InvMass_vs_Pt",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2534 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
2535 if ( TMath::Abs(twoGammaDecayCandidateDaughter0->GetEta())<0.9 && TMath::Abs(twoGammaDecayCandidateDaughter1->GetEta())<0.9 ){
2536 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt_Fiducial",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
2537 fHistograms->FillHistogram("ESD_Mother_InvMass_Fiducial",massTwoGammaCandidate);
2540 if(TMath::Abs(twoGammaDecayCandidateDaughter0->GetEta())>0.9 && TMath::Abs(twoGammaDecayCandidateDaughter1->GetEta())>0.9){
2541 fHistograms->FillHistogram("ESD_Mother_InvMass_1212",massTwoGammaCandidate);
2542 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt1212",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2544 else if(TMath::Abs(twoGammaDecayCandidateDaughter0->GetEta())>0.9 || TMath::Abs(twoGammaDecayCandidateDaughter1->GetEta())>0.9){
2545 fHistograms->FillHistogram("ESD_Mother_InvMass_0912",massTwoGammaCandidate);
2546 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt0912",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2549 fHistograms->FillHistogram("ESD_Mother_InvMass_0909",massTwoGammaCandidate);
2550 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt0909",massTwoGammaCandidate,momentumVectorTwoGammaCandidate.Pt());
2553 Double_t lowMassPi0=0.1;
2554 Double_t highMassPi0=0.15;
2555 if ( ( massTwoGammaCandidate > lowMassPi0) && (massTwoGammaCandidate < highMassPi0) ){
2556 new((*fKFReconstructedPi0sTClone)[fKFReconstructedPi0sTClone->GetEntriesFast()]) AliKFParticle(*twoGammaCandidate);
2557 fGammav1.push_back(firstGammaIndex);
2558 fGammav2.push_back(secondGammaIndex);
2559 if( fKFCreateAOD ) {
2560 AddPionToAOD(twoGammaCandidate, massTwoGammaCandidate, firstGammaIndex, secondGammaIndex);
2566 delete twoGammaCandidate;
2571 void AliAnalysisTaskGammaConversion::AddPionToAOD(AliKFParticle * pionkf, Double_t mass, Int_t daughter1, Int_t daughter2) {
2572 //See header file for documentation
2573 if(fOutputAODClassName.Contains("AODObject")) {
2574 AliGammaConversionAODObject pion;
2575 pion.SetPx(pionkf->GetPx());
2576 pion.SetPy(pionkf->GetPy());
2577 pion.SetPz(pionkf->GetPz());
2578 pion.SetChi2(pionkf->GetChi2());
2579 pion.SetE(pionkf->GetE());
2580 pion.SetIMass(mass);
2581 pion.SetLabel1(daughter1);
2582 pion.SetLabel2(daughter2);
2583 AddToAODBranch(fAODPi0, pion);
2585 TLorentzVector momentum(pionkf->Px(),pionkf->Py(),pionkf->Pz(), pionkf->E());
2586 AliAODConversionParticle pion = AliAODConversionParticle(momentum);
2587 pion.SetTrackLabels( daughter1, daughter2 );
2588 pion.SetChi2(pionkf->GetChi2());
2589 AddToAODBranch(fAODPi0, pion);
2596 void AliAnalysisTaskGammaConversion::ProcessConvPHOSGammasForNeutralMesonAnalysis(){
2598 // see header file for documentation
2599 // Analyse Pi0 with one photon from Phos and 1 photon from conversions
2604 vtx[0] = fV0Reader->GetPrimaryVertex()->GetX();
2605 vtx[1] = fV0Reader->GetPrimaryVertex()->GetY();
2606 vtx[2] = fV0Reader->GetPrimaryVertex()->GetZ();
2609 // Loop over all CaloClusters and consider only the PHOS ones:
2610 AliESDCaloCluster *clu;
2611 TLorentzVector pPHOS;
2612 TLorentzVector gammaPHOS;
2613 TLorentzVector gammaGammaConv;
2614 TLorentzVector pi0GammaConvPHOS;
2615 TLorentzVector gammaGammaConvBck;
2616 TLorentzVector pi0GammaConvPHOSBck;
2619 for (Int_t i=0; i<fV0Reader->GetESDEvent()->GetNumberOfCaloClusters(); i++) {
2620 clu = fV0Reader->GetESDEvent()->GetCaloCluster(i);
2621 if ( !clu->IsPHOS() || clu->E()<0.1 ) continue;
2622 clu ->GetMomentum(pPHOS ,vtx);
2623 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();firstGammaIndex++){
2624 AliKFParticle * twoGammaDecayCandidateDaughter0 = (AliKFParticle *)fKFReconstructedGammasTClone->At(firstGammaIndex);
2625 gammaGammaConv.SetXYZM(twoGammaDecayCandidateDaughter0->Px(),twoGammaDecayCandidateDaughter0->Py(),twoGammaDecayCandidateDaughter0->Pz(),0.);
2626 gammaPHOS.SetXYZM(pPHOS.Px(),pPHOS.Py(),pPHOS.Pz(),0.);
2627 pi0GammaConvPHOS=gammaGammaConv+gammaPHOS;
2628 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvPHOS",pi0GammaConvPHOS.M());
2629 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt_GammaConvPHOS",pi0GammaConvPHOS.M(),pi0GammaConvPHOS.Pt());
2631 TVector3 v3D0(twoGammaDecayCandidateDaughter0->Px(),twoGammaDecayCandidateDaughter0->Py(),twoGammaDecayCandidateDaughter0->Pz());
2632 TVector3 v3D1(gammaPHOS.Px(),gammaPHOS.Py(),gammaPHOS.Pz());
2633 Double_t opanConvPHOS= v3D0.Angle(v3D1);
2634 if ( opanConvPHOS < 0.35){
2635 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvPHOS_OpanLow",pi0GammaConvPHOS.M());
2637 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvPHOS_OpanHigh",pi0GammaConvPHOS.M());
2642 // Now the LorentVector pPHOS is obtained and can be paired with the converted proton
2644 //==== End of the PHOS cluster selection ============
2645 TLorentzVector pEMCAL;
2646 TLorentzVector gammaEMCAL;
2647 TLorentzVector pi0GammaConvEMCAL;
2648 TLorentzVector pi0GammaConvEMCALBck;
2650 for (Int_t i=0; i<fV0Reader->GetESDEvent()->GetNumberOfCaloClusters(); i++) {
2651 clu = fV0Reader->GetESDEvent()->GetCaloCluster(i);
2652 if ( !clu->IsEMCAL() || clu->E()<0.1 ) continue;
2653 if (clu->GetNCells() <= 1) continue;
2654 if ( clu->GetTOF()*1e9 < 550 || clu->GetTOF()*1e9 > 750) continue;
2656 clu ->GetMomentum(pEMCAL ,vtx);
2657 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();firstGammaIndex++){
2658 AliKFParticle * twoGammaDecayCandidateDaughter0 = (AliKFParticle *)fKFReconstructedGammasTClone->At(firstGammaIndex);
2659 gammaGammaConv.SetXYZM(twoGammaDecayCandidateDaughter0->Px(),
2660 twoGammaDecayCandidateDaughter0->Py(),
2661 twoGammaDecayCandidateDaughter0->Pz(),0.);
2662 gammaEMCAL.SetXYZM(pEMCAL.Px(),pEMCAL.Py(),pEMCAL.Pz(),0.);
2663 pi0GammaConvEMCAL=gammaGammaConv+gammaEMCAL;
2664 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvEMCAL",pi0GammaConvEMCAL.M());
2665 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt_GammaConvEMCAL",pi0GammaConvEMCAL.M(),pi0GammaConvEMCAL.Pt());
2666 TVector3 v3D0(twoGammaDecayCandidateDaughter0->Px(),
2667 twoGammaDecayCandidateDaughter0->Py(),
2668 twoGammaDecayCandidateDaughter0->Pz());
2669 TVector3 v3D1(gammaEMCAL.Px(),gammaEMCAL.Py(),gammaEMCAL.Pz());
2672 Double_t opanConvEMCAL= v3D0.Angle(v3D1);
2673 if ( opanConvEMCAL < 0.35){
2674 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvEMCAL_OpanLow",pi0GammaConvEMCAL.M());
2676 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvEMCAL_OpanHigh",pi0GammaConvEMCAL.M());
2680 if(fCalculateBackground){
2681 for(Int_t nEventsInBG=0;nEventsInBG <fV0Reader->GetNBGEvents();nEventsInBG++){
2682 AliGammaConversionKFVector * previousEventV0s = fV0Reader->GetBGGoodV0s(nEventsInBG);
2683 for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
2684 AliKFParticle previousGoodV0 = (AliKFParticle)(*(previousEventV0s->at(iPrevious)));
2685 gammaGammaConvBck.SetXYZM(previousGoodV0.Px(),
2686 previousGoodV0.Py(),
2687 previousGoodV0.Pz(),0.);
2688 pi0GammaConvEMCALBck=gammaGammaConvBck+gammaEMCAL;
2689 fHistograms->FillHistogram("ESD_Mother_InvMass_GammaConvEMCAL_Bck",pi0GammaConvEMCALBck.M());
2690 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt_GammaConvEMCAL_Bck",pi0GammaConvEMCALBck.M(),
2691 pi0GammaConvEMCALBck.Pt());
2695 // Now the LorentVector pEMCAL is obtained and can be paired with the converted proton
2696 } // end of checking if background photons are available
2698 //==== End of the PHOS cluster selection ============
2703 void AliAnalysisTaskGammaConversion::MoveParticleAccordingToVertex(AliKFParticle * particle,const AliGammaConversionBGHandler::GammaConversionVertex *vertex){
2704 //see header file for documentation
2706 Double_t dx = vertex->fX - fESDEvent->GetPrimaryVertex()->GetX();
2707 Double_t dy = vertex->fY - fESDEvent->GetPrimaryVertex()->GetY();
2708 Double_t dz = vertex->fZ - fESDEvent->GetPrimaryVertex()->GetZ();
2710 // cout<<"dx, dy, dz: ["<<dx<<","<<dy<<","<<dz<<"]"<<endl;
2711 particle->X() = particle->GetX() - dx;
2712 particle->Y() = particle->GetY() - dy;
2713 particle->Z() = particle->GetZ() - dz;
2716 void AliAnalysisTaskGammaConversion::RotateKFParticle(AliKFParticle * kfParticle,Double_t angle){
2717 // Rotate the kf particle
2718 Double_t c = cos(angle);
2719 Double_t s = sin(angle);
2722 for( Int_t i=0; i<7; i++ ){
2723 for( Int_t j=0; j<7; j++){
2727 for( int i=0; i<7; i++ ){
2730 mA[0][0] = c; mA[0][1] = s;
2731 mA[1][0] = -s; mA[1][1] = c;
2732 mA[3][3] = c; mA[3][4] = s;
2733 mA[4][3] = -s; mA[4][4] = c;
2738 for( Int_t i=0; i<7; i++ ){
2740 for( Int_t k=0; k<7; k++){
2741 mAp[i]+=mA[i][k] * kfParticle->GetParameter(k);
2745 for( Int_t i=0; i<7; i++){
2746 kfParticle->Parameter(i) = mAp[i];
2749 for( Int_t i=0; i<7; i++ ){
2750 for( Int_t j=0; j<7; j++ ){
2752 for( Int_t k=0; k<7; k++ ){
2753 mAC[i][j]+= mA[i][k] * kfParticle->GetCovariance(k,j);
2758 for( Int_t i=0; i<7; i++ ){
2759 for( Int_t j=0; j<=i; j++ ){
2761 for( Int_t k=0; k<7; k++){
2762 xx+= mAC[i][k]*mA[j][k];
2764 kfParticle->Covariance(i,j) = xx;
2770 void AliAnalysisTaskGammaConversion::CalculateBackground(){
2771 // see header file for documentation
2774 TClonesArray * currentEventV0s = fV0Reader->GetCurrentEventGoodV0s();
2776 AliGammaConversionBGHandler * bgHandler = fV0Reader->GetBGHandler();
2778 Int_t zbin= bgHandler->GetZBinIndex(fV0Reader->GetVertexZ());
2780 if(fUseTrackMultiplicityForBG == kTRUE){
2781 mbin = bgHandler->GetMultiplicityBinIndex(fV0Reader->CountESDTracks());
2784 mbin = bgHandler->GetMultiplicityBinIndex(fV0Reader->GetNGoodV0s());
2787 if(fDoRotation == kTRUE){
2788 TRandom3 *random = new TRandom3();
2789 for(Int_t iCurrent=0;iCurrent<currentEventV0s->GetEntriesFast();iCurrent++){
2790 AliKFParticle currentEventGoodV0 = *(AliKFParticle *)(currentEventV0s->At(iCurrent));
2791 for(Int_t iCurrent2=iCurrent+1;iCurrent2<currentEventV0s->GetEntriesFast();iCurrent2++){
2792 for(Int_t nRandom=0;nRandom<fNRandomEventsForBG;nRandom++){
2794 AliKFParticle currentEventGoodV02 = *(AliKFParticle *)(currentEventV0s->At(iCurrent2));
2796 if(fCheckBGProbability == kTRUE){
2797 Double_t massBGprob =0.;
2798 Double_t widthBGprob = 0.;
2799 AliKFParticle *backgroundCandidateProb = new AliKFParticle(currentEventGoodV0,currentEventGoodV02);
2800 backgroundCandidateProb->GetMass(massBGprob,widthBGprob);
2801 if(massBGprob>0.1 && massBGprob<0.14){
2802 if(random->Rndm()>bgHandler->GetBGProb(zbin,mbin)){
2803 delete backgroundCandidateProb;
2807 delete backgroundCandidateProb;
2810 Double_t nRadiansPM = fNDegreesPMBackground*TMath::Pi()/180;
2812 Double_t rotationValue = random->Rndm()*2*nRadiansPM + TMath::Pi()-nRadiansPM;
2814 RotateKFParticle(¤tEventGoodV02,rotationValue);
2816 AliKFParticle *backgroundCandidate = new AliKFParticle(currentEventGoodV0,currentEventGoodV02);
2818 Double_t massBG =0.;
2819 Double_t widthBG = 0.;
2820 Double_t chi2BG =10000.;
2821 backgroundCandidate->GetMass(massBG,widthBG);
2823 // if(backgroundCandidate->GetNDF()>0){
2824 chi2BG = backgroundCandidate->GetChi2();
2825 if((chi2BG>0 && chi2BG<fV0Reader->GetChi2CutMeson()) || fApplyChi2Cut == kFALSE){
2827 TVector3 momentumVectorbackgroundCandidate(backgroundCandidate->GetPx(),backgroundCandidate->GetPy(),backgroundCandidate->GetPz());
2828 TVector3 spaceVectorbackgroundCandidate(backgroundCandidate->GetX(),backgroundCandidate->GetY(),backgroundCandidate->GetZ());
2830 Double_t openingAngleBG = currentEventGoodV0.GetAngle(currentEventGoodV02);
2833 if(backgroundCandidate->GetE() - backgroundCandidate->GetPz() == 0 || backgroundCandidate->GetE() + backgroundCandidate->GetPz() == 0) rapidity=0;
2834 else rapidity = 0.5*(TMath::Log((backgroundCandidate->GetE() +backgroundCandidate->GetPz()) / (backgroundCandidate->GetE()-backgroundCandidate->GetPz())));
2836 if(TMath::Abs(rapidity) > fV0Reader->GetRapidityMesonCut() ){
2837 delete backgroundCandidate;
2838 continue; // rapidity cut
2843 if( (currentEventGoodV0.GetE()+currentEventGoodV02.GetE()) != 0){
2844 alfa=TMath::Abs((currentEventGoodV0.GetE()-currentEventGoodV02.GetE())
2845 /(currentEventGoodV0.GetE()+currentEventGoodV02.GetE()));
2849 if(openingAngleBG < fMinOpeningAngleGhostCut ){
2850 delete backgroundCandidate;
2851 continue; // minimum opening angle to avoid using ghosttracks
2855 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
2856 fHistograms->FillHistogram("ESD_Background_GammaDaughter_OpeningAngle", openingAngleBG);
2857 fHistograms->FillHistogram("ESD_Background_Energy", backgroundCandidate->GetE());
2858 fHistograms->FillHistogram("ESD_Background_Pt", momentumVectorbackgroundCandidate.Pt());
2859 fHistograms->FillHistogram("ESD_Background_Eta", momentumVectorbackgroundCandidate.Eta());
2860 fHistograms->FillHistogram("ESD_Background_Rapidity", rapidity);
2861 fHistograms->FillHistogram("ESD_Background_Phi", spaceVectorbackgroundCandidate.Phi());
2862 fHistograms->FillHistogram("ESD_Background_Mass", massBG);
2863 fHistograms->FillHistogram("ESD_Background_R", spaceVectorbackgroundCandidate.Pt()); // Pt in Space == R!!!!
2864 fHistograms->FillHistogram("ESD_Background_ZR", backgroundCandidate->GetZ(), spaceVectorbackgroundCandidate.Pt());
2865 fHistograms->FillHistogram("ESD_Background_XY", backgroundCandidate->GetX(), backgroundCandidate->GetY());
2866 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt",massBG,momentumVectorbackgroundCandidate.Pt());
2867 fHistograms->FillHistogram("ESD_Background_InvMass",massBG);
2868 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt_alpha",massBG,momentumVectorbackgroundCandidate.Pt());
2870 if(massBG>0.1 && massBG<0.15){
2871 fHistograms->FillHistogram("ESD_Background_alfa_Pi0", alfa);
2873 if(massBG>0.5 && massBG<0.57){
2874 fHistograms->FillHistogram("ESD_Background_alfa_Eta", alfa);
2877 if ( TMath::Abs(currentEventGoodV0.GetEta())<0.9 && TMath::Abs(currentEventGoodV02.GetEta())<0.9 ){
2878 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt_Fiducial",massBG,momentumVectorbackgroundCandidate.Pt());
2879 fHistograms->FillHistogram("ESD_Background_InvMass_Fiducial",massBG);
2882 fHistograms->FillHistogram(Form("%d%dESD_Background_GammaDaughter_OpeningAngle",zbin,mbin), openingAngleBG);
2883 fHistograms->FillHistogram(Form("%d%dESD_Background_Energy",zbin,mbin), backgroundCandidate->GetE());
2884 fHistograms->FillHistogram(Form("%d%dESD_Background_Pt",zbin,mbin), momentumVectorbackgroundCandidate.Pt());
2885 fHistograms->FillHistogram(Form("%d%dESD_Background_Eta",zbin,mbin), momentumVectorbackgroundCandidate.Eta());
2886 fHistograms->FillHistogram(Form("%d%dESD_Background_Rapidity",zbin,mbin), rapidity);
2887 fHistograms->FillHistogram(Form("%d%dESD_Background_Phi",zbin,mbin), spaceVectorbackgroundCandidate.Phi());
2888 fHistograms->FillHistogram(Form("%d%dESD_Background_Mass",zbin,mbin), massBG);
2889 fHistograms->FillHistogram(Form("%d%dESD_Background_R",zbin,mbin), spaceVectorbackgroundCandidate.Pt()); // Pt in Space == R!!!!
2890 fHistograms->FillHistogram(Form("%d%dESD_Background_ZR",zbin,mbin), backgroundCandidate->GetZ(), spaceVectorbackgroundCandidate.Pt());
2891 fHistograms->FillHistogram(Form("%d%dESD_Background_XY",zbin,mbin), backgroundCandidate->GetX(), backgroundCandidate->GetY());
2892 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_vs_Pt",zbin,mbin),massBG,momentumVectorbackgroundCandidate.Pt());
2893 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass",zbin,mbin),massBG);
2895 if ( TMath::Abs(currentEventGoodV0.GetEta())<0.9 && TMath::Abs(currentEventGoodV02.GetEta())<0.9 ){
2896 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_vs_Pt_Fiducial",zbin,mbin),massBG,momentumVectorbackgroundCandidate.Pt());
2897 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_Fiducial",zbin,mbin),massBG);
2901 fHistograms->FillHistogram("ESD_Background_InvMass_vs_E_alpha",massBG ,backgroundCandidate->GetE());
2906 delete backgroundCandidate;
2912 else{ // means no rotation
2913 AliGammaConversionBGHandler::GammaConversionVertex *bgEventVertex = NULL;
2915 if(fUseTrackMultiplicityForBG){
2916 // cout<<"Using charged track multiplicity for background calculation"<<endl;
2917 for(Int_t nEventsInBG=0;nEventsInBG <fV0Reader->GetNBGEvents();nEventsInBG++){
2919 AliGammaConversionKFVector * previousEventV0s = bgHandler->GetBGGoodV0s(zbin,mbin,nEventsInBG);//fV0Reader->GetBGGoodV0s(nEventsInBG);
2921 if(fMoveParticleAccordingToVertex == kTRUE){
2922 bgEventVertex = bgHandler->GetBGEventVertex(zbin,mbin,nEventsInBG);
2925 for(Int_t iCurrent=0;iCurrent<currentEventV0s->GetEntriesFast();iCurrent++){
2926 AliKFParticle currentEventGoodV0 = *(AliKFParticle *)(currentEventV0s->At(iCurrent));
2927 for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
2928 AliKFParticle previousGoodV0 = (AliKFParticle)(*(previousEventV0s->at(iPrevious)));
2929 AliKFParticle previousGoodV0test = (AliKFParticle)(*(previousEventV0s->at(iPrevious)));
2931 //cout<<"Primary Vertex event: ["<<fESDEvent->GetPrimaryVertex()->GetX()<<","<<fESDEvent->GetPrimaryVertex()->GetY()<<","<<fESDEvent->GetPrimaryVertex()->GetZ()<<"]"<<endl;
2932 //cout<<"BG prim Vertex event: ["<<bgEventVertex->fX<<","<<bgEventVertex->fY<<","<<bgEventVertex->fZ<<"]"<<endl;
2934 //cout<<"XYZ of particle before transport: ["<<previousGoodV0.X()<<","<<previousGoodV0.Y()<<","<<previousGoodV0.Z()<<"]"<<endl;
2935 if(fMoveParticleAccordingToVertex == kTRUE){
2936 MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
2938 //cout<<"XYZ of particle after transport: ["<<previousGoodV0.X()<<","<<previousGoodV0.Y()<<","<<previousGoodV0.Z()<<"]"<<endl;
2940 AliKFParticle *backgroundCandidate = new AliKFParticle(currentEventGoodV0,previousGoodV0);
2942 Double_t massBG =0.;
2943 Double_t widthBG = 0.;
2944 Double_t chi2BG =10000.;
2945 backgroundCandidate->GetMass(massBG,widthBG);
2946 // if(backgroundCandidate->GetNDF()>0){
2947 // chi2BG = backgroundCandidate->GetChi2()/backgroundCandidate->GetNDF();
2948 chi2BG = backgroundCandidate->GetChi2();
2949 if((chi2BG>0 && chi2BG<fV0Reader->GetChi2CutMeson()) || fApplyChi2Cut == kFALSE){
2951 TVector3 momentumVectorbackgroundCandidate(backgroundCandidate->GetPx(),backgroundCandidate->GetPy(),backgroundCandidate->GetPz());
2952 TVector3 spaceVectorbackgroundCandidate(backgroundCandidate->GetX(),backgroundCandidate->GetY(),backgroundCandidate->GetZ());
2954 Double_t openingAngleBG = currentEventGoodV0.GetAngle(previousGoodV0);
2958 if(backgroundCandidate->GetE() - backgroundCandidate->GetPz() <= 0 || backgroundCandidate->GetE() + backgroundCandidate->GetPz() <= 0){
2959 cout << "Error: |Pz| > E !!!! " << endl;
2962 rapidity = 0.5*(TMath::Log((backgroundCandidate->GetE() +backgroundCandidate->GetPz()) / (backgroundCandidate->GetE()-backgroundCandidate->GetPz())));
2964 if(TMath::Abs(rapidity) > fV0Reader->GetRapidityMesonCut() ){
2965 delete backgroundCandidate;
2966 continue; // rapidity cut
2971 if( (currentEventGoodV0.GetE()+previousGoodV0.GetE()) != 0){
2972 alfa=TMath::Abs((currentEventGoodV0.GetE()-previousGoodV0.GetE())
2973 /(currentEventGoodV0.GetE()+previousGoodV0.GetE()));
2977 if(openingAngleBG < fMinOpeningAngleGhostCut ){
2978 delete backgroundCandidate;
2979 continue; // minimum opening angle to avoid using ghosttracks
2983 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
2984 fHistograms->FillHistogram("ESD_Background_GammaDaughter_OpeningAngle", openingAngleBG);
2985 fHistograms->FillHistogram("ESD_Background_Energy", backgroundCandidate->GetE());
2986 fHistograms->FillHistogram("ESD_Background_Pt", momentumVectorbackgroundCandidate.Pt());
2987 fHistograms->FillHistogram("ESD_Background_Eta", momentumVectorbackgroundCandidate.Eta());
2988 fHistograms->FillHistogram("ESD_Background_Rapidity", rapidity);
2989 fHistograms->FillHistogram("ESD_Background_Phi", spaceVectorbackgroundCandidate.Phi());
2990 fHistograms->FillHistogram("ESD_Background_Mass", massBG);
2991 fHistograms->FillHistogram("ESD_Background_R", spaceVectorbackgroundCandidate.Pt()); // Pt in Space == R!!!!
2992 fHistograms->FillHistogram("ESD_Background_ZR", backgroundCandidate->GetZ(), spaceVectorbackgroundCandidate.Pt());
2993 fHistograms->FillHistogram("ESD_Background_XY", backgroundCandidate->GetX(), backgroundCandidate->GetY());
2994 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt",massBG,momentumVectorbackgroundCandidate.Pt());
2995 fHistograms->FillHistogram("ESD_Background_InvMass",massBG);
2996 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt_alpha",massBG,momentumVectorbackgroundCandidate.Pt());
2998 if(massBG>0.1 && massBG<0.15){
2999 fHistograms->FillHistogram("ESD_Background_alfa_Pi0", alfa);
3001 if(massBG>0.5 && massBG<0.57){
3002 fHistograms->FillHistogram("ESD_Background_alfa_Eta", alfa);
3005 if ( TMath::Abs(currentEventGoodV0.GetEta())<0.9 && TMath::Abs(previousGoodV0.GetEta())<0.9 ){
3006 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt_Fiducial",massBG,momentumVectorbackgroundCandidate.Pt());
3007 fHistograms->FillHistogram("ESD_Background_InvMass_Fiducial",massBG);
3011 fHistograms->FillHistogram(Form("%d%dESD_Background_GammaDaughter_OpeningAngle",zbin,mbin), openingAngleBG);
3012 fHistograms->FillHistogram(Form("%d%dESD_Background_Energy",zbin,mbin), backgroundCandidate->GetE());
3013 fHistograms->FillHistogram(Form("%d%dESD_Background_Pt",zbin,mbin), momentumVectorbackgroundCandidate.Pt());
3014 fHistograms->FillHistogram(Form("%d%dESD_Background_Eta",zbin,mbin), momentumVectorbackgroundCandidate.Eta());
3015 fHistograms->FillHistogram(Form("%d%dESD_Background_Rapidity",zbin,mbin), rapidity);
3016 fHistograms->FillHistogram(Form("%d%dESD_Background_Phi",zbin,mbin), spaceVectorbackgroundCandidate.Phi());
3017 fHistograms->FillHistogram(Form("%d%dESD_Background_Mass",zbin,mbin), massBG);
3018 fHistograms->FillHistogram(Form("%d%dESD_Background_R",zbin,mbin), spaceVectorbackgroundCandidate.Pt()); // Pt in Space == R!!!!
3019 fHistograms->FillHistogram(Form("%d%dESD_Background_ZR",zbin,mbin), backgroundCandidate->GetZ(), spaceVectorbackgroundCandidate.Pt());
3020 fHistograms->FillHistogram(Form("%d%dESD_Background_XY",zbin,mbin), backgroundCandidate->GetX(), backgroundCandidate->GetY());
3021 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_vs_Pt",zbin,mbin),massBG,momentumVectorbackgroundCandidate.Pt());
3022 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass",zbin,mbin),massBG);
3024 if ( TMath::Abs(currentEventGoodV0.GetEta())<0.9 && TMath::Abs(previousGoodV0.GetEta())<0.9 ){
3025 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_vs_Pt_Fiducial",zbin,mbin),massBG,momentumVectorbackgroundCandidate.Pt());
3026 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_Fiducial",zbin,mbin),massBG);
3031 fHistograms->FillHistogram("ESD_Background_InvMass_vs_E_alpha",massBG ,backgroundCandidate->GetE());
3035 delete backgroundCandidate;
3040 else{ // means using #V0s for multiplicity
3042 // cout<<"Using the v0 multiplicity to calculate background"<<endl;
3044 fHistograms->FillHistogram("ESD_Background_z_m",zbin,mbin);
3045 fHistograms->FillHistogram("ESD_Mother_multpilicityVSv0s",fV0Reader->CountESDTracks(),fV0Reader->GetNumberOfV0s());
3047 for(Int_t nEventsInBG=0;nEventsInBG <fV0Reader->GetNBGEvents();nEventsInBG++){
3048 AliGammaConversionKFVector * previousEventV0s = bgHandler->GetBGGoodV0s(zbin,mbin,nEventsInBG);// fV0Reader->GetBGGoodV0s(nEventsInBG);
3049 if(previousEventV0s){
3051 if(fMoveParticleAccordingToVertex == kTRUE){
3052 bgEventVertex = bgHandler->GetBGEventVertex(zbin,mbin,nEventsInBG);
3055 for(Int_t iCurrent=0;iCurrent<currentEventV0s->GetEntriesFast();iCurrent++){
3056 AliKFParticle currentEventGoodV0 = *(AliKFParticle *)(currentEventV0s->At(iCurrent));
3057 for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
3058 AliKFParticle previousGoodV0 = (AliKFParticle)(*(previousEventV0s->at(iPrevious)));
3060 if(fMoveParticleAccordingToVertex == kTRUE){
3061 MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
3064 AliKFParticle *backgroundCandidate = new AliKFParticle(currentEventGoodV0,previousGoodV0);
3065 Double_t massBG =0.;
3066 Double_t widthBG = 0.;
3067 Double_t chi2BG =10000.;
3068 backgroundCandidate->GetMass(massBG,widthBG);
3069 /* if(backgroundCandidate->GetNDF()>0){
3070 chi2BG = backgroundCandidate->GetChi2()/backgroundCandidate->GetNDF();
3071 {//remember to remove
3072 TVector3 momentumVectorbackgroundCandidate(backgroundCandidate->GetPx(),backgroundCandidate->GetPy(),backgroundCandidate->GetPz());
3073 TVector3 spaceVectorbackgroundCandidate(backgroundCandidate->GetX(),backgroundCandidate->GetY(),backgroundCandidate->GetZ());
3075 Double_t openingAngleBG = currentEventGoodV0.GetAngle(previousGoodV0);
3076 fHistograms->FillHistogram("ESD_Background_GammaDaughter_OpeningAngle_nochi2", openingAngleBG);
3079 chi2BG = backgroundCandidate->GetChi2();
3080 if((chi2BG>0 && chi2BG<fV0Reader->GetChi2CutMeson()) || fApplyChi2Cut == kFALSE){
3081 TVector3 momentumVectorbackgroundCandidate(backgroundCandidate->GetPx(),backgroundCandidate->GetPy(),backgroundCandidate->GetPz());
3082 TVector3 spaceVectorbackgroundCandidate(backgroundCandidate->GetX(),backgroundCandidate->GetY(),backgroundCandidate->GetZ());
3084 Double_t openingAngleBG = currentEventGoodV0.GetAngle(previousGoodV0);
3087 if(backgroundCandidate->GetE() - backgroundCandidate->GetPz() == 0 || backgroundCandidate->GetE() + backgroundCandidate->GetPz() == 0) rapidity=0;
3088 else rapidity = 0.5*(TMath::Log((backgroundCandidate->GetE() +backgroundCandidate->GetPz()) / (backgroundCandidate->GetE()-backgroundCandidate->GetPz())));
3090 if(TMath::Abs(rapidity) > fV0Reader->GetRapidityMesonCut() ){
3091 delete backgroundCandidate;
3092 continue; // rapidity cut
3097 if( (currentEventGoodV0.GetE()+previousGoodV0.GetE()) != 0){
3098 alfa=TMath::Abs((currentEventGoodV0.GetE()-previousGoodV0.GetE())
3099 /(currentEventGoodV0.GetE()+previousGoodV0.GetE()));
3103 if(openingAngleBG < fMinOpeningAngleGhostCut ){
3104 delete backgroundCandidate;
3105 continue; // minimum opening angle to avoid using ghosttracks
3108 if(alfa>fV0Reader->GetAlphaMinCutMeson() && alfa<fV0Reader->GetAlphaCutMeson()){
3109 fHistograms->FillHistogram("ESD_Background_GammaDaughter_OpeningAngle", openingAngleBG);
3110 fHistograms->FillHistogram("ESD_Background_Energy", backgroundCandidate->GetE());
3111 fHistograms->FillHistogram("ESD_Background_Pt", momentumVectorbackgroundCandidate.Pt());
3112 fHistograms->FillHistogram("ESD_Background_Eta", momentumVectorbackgroundCandidate.Eta());
3113 fHistograms->FillHistogram("ESD_Background_Rapidity", rapidity);
3114 fHistograms->FillHistogram("ESD_Background_Phi", spaceVectorbackgroundCandidate.Phi());
3115 fHistograms->FillHistogram("ESD_Background_Mass", massBG);
3116 fHistograms->FillHistogram("ESD_Background_R", spaceVectorbackgroundCandidate.Pt()); // Pt in Space == R!!!!
3117 fHistograms->FillHistogram("ESD_Background_ZR", backgroundCandidate->GetZ(), spaceVectorbackgroundCandidate.Pt());
3118 fHistograms->FillHistogram("ESD_Background_XY", backgroundCandidate->GetX(), backgroundCandidate->GetY());
3119 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt",massBG,momentumVectorbackgroundCandidate.Pt());
3120 fHistograms->FillHistogram("ESD_Background_InvMass",massBG);
3123 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt_alpha",massBG,momentumVectorbackgroundCandidate.Pt());
3125 if(massBG>0.1 && massBG<0.15){
3126 fHistograms->FillHistogram("ESD_Background_alfa_Pi0", alfa);
3128 if(massBG>0.5 && massBG<0.57){
3129 fHistograms->FillHistogram("ESD_Background_alfa_Eta", alfa);
3132 if ( TMath::Abs(currentEventGoodV0.GetEta())<0.9 && TMath::Abs(previousGoodV0.GetEta())<0.9 ){
3133 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt_Fiducial",massBG,momentumVectorbackgroundCandidate.Pt());
3134 fHistograms->FillHistogram("ESD_Background_InvMass_Fiducial",massBG);
3137 if(massBG>0.5 && massBG<0.6){
3138 fHistograms->FillHistogram("ESD_Background_alfa_pt0506",momentumVectorbackgroundCandidate.Pt(),alfa);
3140 if(massBG>0.3 && massBG<0.4){
3141 fHistograms->FillHistogram("ESD_Background_alfa_pt0304",momentumVectorbackgroundCandidate.Pt(),alfa);
3145 fHistograms->FillHistogram(Form("%d%dESD_Background_GammaDaughter_OpeningAngle",zbin,mbin), openingAngleBG);
3146 fHistograms->FillHistogram(Form("%d%dESD_Background_Energy",zbin,mbin), backgroundCandidate->GetE());
3147 fHistograms->FillHistogram(Form("%d%dESD_Background_Pt",zbin,mbin), momentumVectorbackgroundCandidate.Pt());
3148 fHistograms->FillHistogram(Form("%d%dESD_Background_Eta",zbin,mbin), momentumVectorbackgroundCandidate.Eta());
3149 fHistograms->FillHistogram(Form("%d%dESD_Background_Rapidity",zbin,mbin), rapidity);
3150 fHistograms->FillHistogram(Form("%d%dESD_Background_Phi",zbin,mbin), spaceVectorbackgroundCandidate.Phi());
3151 fHistograms->FillHistogram(Form("%d%dESD_Background_Mass",zbin,mbin), massBG);
3152 fHistograms->FillHistogram(Form("%d%dESD_Background_R",zbin,mbin), spaceVectorbackgroundCandidate.Pt()); // Pt in Space == R!!!!
3153 fHistograms->FillHistogram(Form("%d%dESD_Background_ZR",zbin,mbin), backgroundCandidate->GetZ(), spaceVectorbackgroundCandidate.Pt());
3154 fHistograms->FillHistogram(Form("%d%dESD_Background_XY",zbin,mbin), backgroundCandidate->GetX(), backgroundCandidate->GetY());
3155 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_vs_Pt",zbin,mbin),massBG,momentumVectorbackgroundCandidate.Pt());
3156 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass",zbin,mbin),massBG);
3158 if ( TMath::Abs(currentEventGoodV0.GetEta())<0.9 && TMath::Abs(previousGoodV0.GetEta())<0.9 ){
3159 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_vs_Pt_Fiducial",zbin,mbin),massBG,momentumVectorbackgroundCandidate.Pt());
3160 fHistograms->FillHistogram(Form("%d%dESD_Background_InvMass_Fiducial",zbin,mbin),massBG);
3165 fHistograms->FillHistogram("ESD_Background_InvMass_vs_E_alpha",massBG ,backgroundCandidate->GetE());
3169 delete backgroundCandidate;
3174 } // end else (means use #v0s as multiplicity)
3175 } // end no rotation
3179 void AliAnalysisTaskGammaConversion::ProcessGammasForGammaJetAnalysis(){
3180 //ProcessGammasForGammaJetAnalysis
3182 Double_t distIsoMin;
3184 CreateListOfChargedParticles();
3187 // for(UInt_t gammaIndex=0;gammaIndex<fKFReconstructedGammas.size();gammaIndex++){
3188 for(Int_t gammaIndex=0;gammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();gammaIndex++){
3189 AliKFParticle * currentGamma = (AliKFParticle*)fKFReconstructedGammasTClone->At(gammaIndex);
3190 TVector3 momentumVectorCurrentGamma(currentGamma->GetPx(),currentGamma->GetPy(),currentGamma->GetPz());
3192 if( momentumVectorCurrentGamma.Pt()> fMinPtForGammaJet){
3193 distIsoMin=GetMinimumDistanceToCharge(gammaIndex);
3195 if (distIsoMin > fMinIsoConeSize && fLeadingChargedIndex>=0){
3196 CalculateJetCone(gammaIndex);
3202 //____________________________________________________________________
3203 Bool_t AliAnalysisTaskGammaConversion::IsGoodImpPar(const AliESDtrack *const track)
3206 // check whether particle has good DCAr(Pt) impact
3207 // parameter. Only for TPC+ITS tracks (7*sigma cut)
3208 // Origin: Andrea Dainese
3211 Float_t d0z0[2],covd0z0[3];
3212 track->GetImpactParameters(d0z0,covd0z0);
3213 Float_t sigma= 0.0050+0.0060/TMath::Power(track->Pt(),0.9);
3214 Float_t d0max = 7.*sigma;
3215 if(TMath::Abs(d0z0[0]) < d0max) return kTRUE;
3221 void AliAnalysisTaskGammaConversion::CreateListOfChargedParticles(){
3222 // CreateListOfChargedParticles
3224 fESDEvent = fV0Reader->GetESDEvent();
3225 Int_t numberOfESDTracks=0;
3226 for(Int_t iTracks = 0; iTracks < fESDEvent->GetNumberOfTracks(); iTracks++){
3227 AliESDtrack* curTrack = fESDEvent->GetTrack(iTracks);
3232 // Not needed if Standard function used.
3233 // if(!IsGoodImpPar(curTrack)){
3237 if(fEsdTrackCuts->AcceptTrack(curTrack) ){
3238 new((*fChargedParticles)[fChargedParticles->GetEntriesFast()]) AliESDtrack(*curTrack);
3239 // fChargedParticles.push_back(curTrack);
3240 fChargedParticlesId.push_back(iTracks);
3241 numberOfESDTracks++;
3244 // Moved to UserExec using CountAcceptedTracks function. runjet is not needed by default
3245 // fHistograms->FillHistogram("ESD_NumberOfGoodESDTracks",numberOfESDTracks);
3246 // cout<<"esdtracks::"<< numberOfESDTracks<<endl;
3247 // if (fV0Reader->GetNumberOfContributorsVtx()>=1){
3248 // fHistograms->FillHistogram("ESD_NumberOfGoodESDTracksVtx",numberOfESDTracks);
3251 void AliAnalysisTaskGammaConversion::RecalculateV0ForGamma(){
3252 //recalculates v0 for gamma
3254 Double_t massE=0.00051099892;
3255 TLorentzVector curElecPos;
3256 TLorentzVector curElecNeg;
3257 TLorentzVector curGamma;
3259 TLorentzVector curGammaAt;
3260 TLorentzVector curElecPosAt;
3261 TLorentzVector curElecNegAt;
3262 AliKFVertex primVtxGamma(*(fESDEvent->GetPrimaryVertex()));
3263 AliKFVertex primVtxImprovedGamma = primVtxGamma;
3265 const AliESDVertex *vtxT3D=fESDEvent->GetPrimaryVertex();
3267 Double_t xPrimaryVertex=vtxT3D->GetXv();
3268 Double_t yPrimaryVertex=vtxT3D->GetYv();
3269 Double_t zPrimaryVertex=vtxT3D->GetZv();
3270 // Float_t primvertex[3]={xPrimaryVertex,yPrimaryVertex,zPrimaryVertex};
3272 Float_t nsigmaTPCtrackPos;
3273 Float_t nsigmaTPCtrackNeg;
3274 Float_t nsigmaTPCtrackPosToPion;
3275 Float_t nsigmaTPCtrackNegToPion;
3276 AliKFParticle* negKF=NULL;
3277 AliKFParticle* posKF=NULL;
3279 for(Int_t iTracks = 0; iTracks < fESDEvent->GetNumberOfTracks(); iTracks++){
3280 AliESDtrack* posTrack = fESDEvent->GetTrack(iTracks);
3284 if (posKF) delete posKF; posKF=NULL;
3285 if(posTrack->GetSign()<0) continue;
3286 if(!(posTrack->GetStatus() & AliESDtrack::kTPCrefit))continue;
3287 if(posTrack->GetKinkIndex(0)>0 ) continue;
3288 if(posTrack->GetNcls(1)<50)continue;
3290 // posTrack->GetConstrainedPxPyPz(momPos);
3291 posTrack->GetPxPyPz(momPos);
3292 AliESDtrack *ptrk=fESDEvent->GetTrack(iTracks);
3293 curElecPos.SetXYZM(momPos[0],momPos[1],momPos[2],massE);
3294 if(TMath::Abs(curElecPos.Eta())<0.9) continue;
3295 posKF = new AliKFParticle( *(posTrack),-11);
3297 nsigmaTPCtrackPos = fV0Reader->GetESDpid()->NumberOfSigmasTPC(posTrack,AliPID::kElectron);
3298 nsigmaTPCtrackPosToPion = fV0Reader->GetESDpid()->NumberOfSigmasTPC(posTrack,AliPID::kPion);
3300 if ( nsigmaTPCtrackPos>5.|| nsigmaTPCtrackPos<-2.){
3304 if(pow((momPos[0]*momPos[0]+momPos[1]*momPos[1]+momPos[2]*momPos[2]),0.5)>0.5 && nsigmaTPCtrackPosToPion<1){
3310 for(Int_t jTracks = 0; jTracks < fESDEvent->GetNumberOfTracks(); jTracks++){
3311 AliESDtrack* negTrack = fESDEvent->GetTrack(jTracks);
3315 if (negKF) delete negKF; negKF=NULL;
3316 if(negTrack->GetSign()>0) continue;
3317 if(!(negTrack->GetStatus() & AliESDtrack::kTPCrefit))continue;
3318 if(negTrack->GetKinkIndex(0)>0 ) continue;
3319 if(negTrack->GetNcls(1)<50)continue;
3321 // negTrack->GetConstrainedPxPyPz(momNeg);
3322 negTrack->GetPxPyPz(momNeg);
3324 nsigmaTPCtrackNeg = fV0Reader->GetESDpid()->NumberOfSigmasTPC(negTrack,AliPID::kElectron);
3325 nsigmaTPCtrackNegToPion = fV0Reader->GetESDpid()->NumberOfSigmasTPC(negTrack,AliPID::kPion);
3326 if ( nsigmaTPCtrackNeg>5. || nsigmaTPCtrackNeg<-2.){
3329 if(pow((momNeg[0]*momNeg[0]+momNeg[1]*momNeg[1]+momNeg[2]*momNeg[2]),0.5)>0.5 && nsigmaTPCtrackNegToPion<1){
3332 AliESDtrack *ntrk=fESDEvent->GetTrack(jTracks);
3333 curElecNeg.SetXYZM(momNeg[0],momNeg[1],momNeg[2],massE);
3334 if(TMath::Abs(curElecNeg.Eta())<0.9) continue;
3335 negKF = new AliKFParticle( *(negTrack) ,11);
3337 Double_t b=fESDEvent->GetMagneticField();
3338 Double_t xn, xp, dca=ntrk->GetDCA(ptrk,b,xn,xp);
3339 AliExternalTrackParam nt(*ntrk), pt(*ptrk);
3340 nt.PropagateTo(xn,b); pt.PropagateTo(xp,b);
3343 //--- Like in ITSV0Finder
3344 AliExternalTrackParam ntAt0(*ntrk), ptAt0(*ptrk);
3345 Double_t xxP,yyP,alphaP;
3348 // if (!ptAt0.GetGlobalXYZat(ptAt0->GetX(),xxP,yyP,zzP)) continue;
3349 if (!ptAt0.GetXYZAt(ptAt0.GetX(),b,rP)) continue;
3352 alphaP = TMath::ATan2(yyP,xxP);
3355 ptAt0.Propagate(alphaP,0,b);
3356 Float_t ptfacP = (1.+100.*TMath::Abs(ptAt0.GetC(b)));
3358 // Double_t distP = ptAt0.GetY();
3359 Double_t normP = ptfacP*TMath::Sqrt(ptAt0.GetSigmaY2());
3360 Double_t normdist0P = TMath::Abs(ptAt0.GetY()/normP);
3361 Double_t normdist1P = TMath::Abs((ptAt0.GetZ()-zPrimaryVertex)/(ptfacP*TMath::Sqrt(ptAt0.GetSigmaZ2())));
3362 Double_t normdistP = TMath::Sqrt(normdist0P*normdist0P+normdist1P*normdist1P);
3365 Double_t xxN,yyN,alphaN;
3367 // if (!ntAt0.GetGlobalXYZat(ntAt0->GetX(),xxN,yyN,zzN)) continue;
3368 if (!ntAt0.GetXYZAt(ntAt0.GetX(),b,rN)) continue;
3372 alphaN = TMath::ATan2(yyN,xxN);
3374 ntAt0.Propagate(alphaN,0,b);
3376 Float_t ptfacN = (1.+100.*TMath::Abs(ntAt0.GetC(b)));
3377 // Double_t distN = ntAt0.GetY();
3378 Double_t normN = ptfacN*TMath::Sqrt(ntAt0.GetSigmaY2());
3379 Double_t normdist0N = TMath::Abs(ntAt0.GetY()/normN);
3380 Double_t normdist1N = TMath::Abs((ntAt0.GetZ()-zPrimaryVertex)/(ptfacN*TMath::Sqrt(ntAt0.GetSigmaZ2())));
3381 Double_t normdistN = TMath::Sqrt(normdist0N*normdist0N+normdist1N*normdist1N);
3383 //-----------------------------
3385 Double_t momNegAt[3];
3386 nt.GetPxPyPz(momNegAt);
3387 curElecNegAt.SetXYZM(momNegAt[0],momNegAt[1],momNegAt[2],massE);
3389 Double_t momPosAt[3];
3390 pt.GetPxPyPz(momPosAt);
3391 curElecPosAt.SetXYZM(momPosAt[0],momPosAt[1],momPosAt[2],massE);
3396 // Double_t dneg= negTrack->GetD(xPrimaryVertex,yPrimaryVertex,b);
3397 // Double_t dpos= posTrack->GetD(xPrimaryVertex,yPrimaryVertex,b);
3398 AliESDv0 vertex(nt,jTracks,pt,iTracks);
3401 Float_t cpa=vertex.GetV0CosineOfPointingAngle(xPrimaryVertex,yPrimaryVertex,zPrimaryVertex);
3405 // cout<< "v0Rr::"<< v0Rr<<endl;
3406 // if (pvertex.GetRr()<0.5){
3409 // cout<<"vertex.GetChi2V0()"<<vertex.GetChi2V0()<<endl;
3410 if(cpa<0.9)continue;
3411 // if (vertex.GetChi2V0() > 30) continue;
3412 // cout<<"xp+xn::"<<xp<<" "<<xn<<endl;
3413 if ((xn+xp) < 0.4) continue;
3414 if (TMath::Abs(ntrk->GetD(xPrimaryVertex,yPrimaryVertex,b))<0.05)
3415 if (TMath::Abs(ptrk->GetD(xPrimaryVertex,yPrimaryVertex,b))<0.05) continue;
3417 //cout<<"pass"<<endl;
3419 AliKFParticle v0GammaC;
3422 v0GammaC.SetMassConstraint(0,0.001);
3423 primVtxImprovedGamma+=v0GammaC;
3424 v0GammaC.SetProductionVertex(primVtxImprovedGamma);
3427 curGamma=curElecNeg+curElecPos;
3428 curGammaAt=curElecNegAt+curElecPosAt;
3430 // invariant mass versus pt of K0short
3432 Double_t chi2V0GammaC=100000.;
3433 if( v0GammaC.GetNDF() != 0) {
3434 chi2V0GammaC = v0GammaC.GetChi2()/v0GammaC.GetNDF();
3436 cout<< "ERROR::v0K0C.GetNDF()" << endl;
3439 if(chi2V0GammaC<200 &&chi2V0GammaC>0 ){
3440 if(fHistograms != NULL){
3441 fHistograms->FillHistogram("ESD_RecalculateV0_InvMass",v0GammaC.GetMass());
3442 fHistograms->FillHistogram("ESD_RecalculateV0_Pt",v0GammaC.GetPt());
3443 fHistograms->FillHistogram("ESD_RecalculateV0_E_dEdxP",curElecNegAt.P(),negTrack->GetTPCsignal());
3444 fHistograms->FillHistogram("ESD_RecalculateV0_P_dEdxP",curElecPosAt.P(),posTrack->GetTPCsignal());
3445 fHistograms->FillHistogram("ESD_RecalculateV0_cpa",cpa);
3446 fHistograms->FillHistogram("ESD_RecalculateV0_dca",dca);
3447 fHistograms->FillHistogram("ESD_RecalculateV0_normdistP",normdistP);
3448 fHistograms->FillHistogram("ESD_RecalculateV0_normdistN",normdistN);
3450 new((*fKFRecalculatedGammasTClone)[fKFRecalculatedGammasTClone->GetEntriesFast()]) AliKFParticle(v0GammaC);
3451 fElectronRecalculatedv1.push_back(iTracks);
3452 fElectronRecalculatedv2.push_back(jTracks);
3458 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFRecalculatedGammasTClone->GetEntriesFast();firstGammaIndex++){
3459 for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fKFRecalculatedGammasTClone->GetEntriesFast();secondGammaIndex++){
3460 AliKFParticle * twoGammaDecayCandidateDaughter0 = (AliKFParticle *)fKFRecalculatedGammasTClone->At(firstGammaIndex);
3461 AliKFParticle * twoGammaDecayCandidateDaughter1 = (AliKFParticle *)fKFRecalculatedGammasTClone->At(secondGammaIndex);
3463 if(fElectronRecalculatedv1[firstGammaIndex]==fElectronRecalculatedv1[secondGammaIndex]){
3466 if( fElectronRecalculatedv2[firstGammaIndex]==fElectronRecalculatedv2[secondGammaIndex]){
3470 AliKFParticle twoGammaCandidate(*twoGammaDecayCandidateDaughter0,*twoGammaDecayCandidateDaughter1);
3471 fHistograms->FillHistogram("ESD_RecalculateGG_InvMass",twoGammaCandidate.GetMass());
3472 fHistograms->FillHistogram("ESD_RecalculateGG_InvMass_vs_Pt",twoGammaCandidate.GetMass(),twoGammaCandidate.GetPt());
3476 void AliAnalysisTaskGammaConversion::CalculateJetCone(Int_t gammaIndex){
3480 Double_t coneSize=0.3;
3483 // AliKFParticle * currentGamma = &fKFReconstructedGammas[gammaIndex];
3484 AliKFParticle * currentGamma = (AliKFParticle*)fKFReconstructedGammasTClone->At(gammaIndex);
3486 TVector3 momentumVectorCurrentGamma(currentGamma->GetPx(),currentGamma->GetPy(),currentGamma->GetPz());
3488 AliESDtrack* leadingCharged = (AliESDtrack*)(fChargedParticles->At(fLeadingChargedIndex));
3490 Double_t momLeadingCharged[3];
3491 leadingCharged->GetConstrainedPxPyPz(momLeadingCharged);
3493 TVector3 momentumVectorLeadingCharged(momLeadingCharged[0],momLeadingCharged[1],momLeadingCharged[2]);
3495 Double_t phi1=momentumVectorLeadingCharged.Phi();
3496 Double_t eta1=momentumVectorLeadingCharged.Eta();
3497 Double_t phi3=momentumVectorCurrentGamma.Phi();
3499 for(Int_t iCh=0;iCh<fChargedParticles->GetEntriesFast();iCh++){
3500 AliESDtrack* curTrack = (AliESDtrack*)(fChargedParticles->At(iCh));
3501 Int_t chId = fChargedParticlesId[iCh];
3502 if(fLeadingChargedIndex==chId || fLeadingChargedIndex==chId) continue;
3504 curTrack->GetConstrainedPxPyPz(mom);
3505 TVector3 momentumVectorChargedParticle(mom[0],mom[1],mom[2]);
3506 Double_t phi2=momentumVectorChargedParticle.Phi();
3507 Double_t eta2=momentumVectorChargedParticle.Eta();
3511 if( TMath::Abs(phi2 - phi1) <= ( TMath::TwoPi()-coneSize) ){
3512 cone = TMath::Sqrt( TMath::Power((eta2-eta1),2)+ TMath::Power((phi2-phi1),2) );
3514 if( (phi2 - phi1)> TMath::TwoPi()-coneSize ){
3515 cone = TMath::Sqrt( TMath::Power((eta2-eta1),2)+ TMath::Power((phi2-TMath::TwoPi()-phi1),2) );
3517 if( (phi2 - phi1)< -(TMath::TwoPi()-coneSize) ){
3518 cone = TMath::Sqrt( TMath::Power((eta2-eta1),2)+ TMath::Power((phi2+TMath::TwoPi()-phi1),2) );
3522 if(cone <coneSize&& momentumVectorChargedParticle.Pt()>fMinPtJetCone ){
3523 ptJet+= momentumVectorChargedParticle.Pt();
3524 Double_t ffzHdrGam = momentumVectorChargedParticle.Pt()/momentumVectorCurrentGamma.Pt();
3525 Double_t imbalanceHdrGam=-momentumVectorChargedParticle.Dot(momentumVectorCurrentGamma)/momentumVectorCurrentGamma.Mag2();
3526 fHistograms->FillHistogram("ESD_FFzHdrGam",ffzHdrGam);
3527 fHistograms->FillHistogram("ESD_ImbalanceHdrGam",imbalanceHdrGam);
3531 Double_t dphiHdrGam=phi3-phi2;
3532 if ( dphiHdrGam < (-TMath::PiOver2())){
3533 dphiHdrGam+=(TMath::TwoPi());
3536 if ( dphiHdrGam > (3.*TMath::PiOver2()) ){
3537 dphiHdrGam-=(TMath::TwoPi());
3540 if (momentumVectorChargedParticle.Pt()>fMinPtGamChargedCorr){
3541 fHistograms->FillHistogram("ESD_dphiHdrGamIsolated",dphiHdrGam);
3548 Double_t AliAnalysisTaskGammaConversion::GetMinimumDistanceToCharge(Int_t indexHighestPtGamma){
3549 // GetMinimumDistanceToCharge
3551 Double_t fIsoMin=100.;
3552 Double_t ptLeadingCharged=-1.;
3554 fLeadingChargedIndex=-1;
3556 AliKFParticle * gammaHighestPt = (AliKFParticle*)fKFReconstructedGammasTClone->At(indexHighestPtGamma);
3557 TVector3 momentumVectorgammaHighestPt(gammaHighestPt->GetPx(),gammaHighestPt->GetPy(),gammaHighestPt->GetPz());
3559 Double_t phi1=momentumVectorgammaHighestPt.Phi();
3560 Double_t eta1=momentumVectorgammaHighestPt.Eta();
3562 for(Int_t iCh=0;iCh<fChargedParticles->GetEntriesFast();iCh++){
3563 AliESDtrack* curTrack = (AliESDtrack*)(fChargedParticles->At(iCh));
3564 Int_t chId = fChargedParticlesId[iCh];
3565 if(fElectronv1[indexHighestPtGamma]==chId || fElectronv2[indexHighestPtGamma]==chId) continue;
3567 curTrack->GetConstrainedPxPyPz(mom);
3568 TVector3 momentumVectorChargedParticle(mom[0],mom[1],mom[2]);
3569 Double_t phi2=momentumVectorChargedParticle.Phi();
3570 Double_t eta2=momentumVectorChargedParticle.Eta();
3571 Double_t iso=pow( (pow( (eta1-eta2),2)+ pow((phi1-phi2),2)),0.5 );
3573 if(momentumVectorChargedParticle.Pt()>fMinPtIsoCone ){
3579 Double_t dphiHdrGam=phi1-phi2;
3580 if ( dphiHdrGam < (-TMath::PiOver2())){
3581 dphiHdrGam+=(TMath::TwoPi());
3584 if ( dphiHdrGam > (3.*TMath::PiOver2()) ){
3585 dphiHdrGam-=(TMath::TwoPi());
3587 if (momentumVectorChargedParticle.Pt()>fMinPtGamChargedCorr){
3588 fHistograms->FillHistogram("ESD_dphiHdrGam",dphiHdrGam);
3591 if (dphiHdrGam>0.9*TMath::Pi() && dphiHdrGam<1.1*TMath::Pi()){
3592 if (momentumVectorChargedParticle.Pt()> ptLeadingCharged && momentumVectorChargedParticle.Pt()>0.1*momentumVectorgammaHighestPt.Pt()){
3593 ptLeadingCharged=momentumVectorChargedParticle.Pt();
3594 fLeadingChargedIndex=iCh;
3599 fHistograms->FillHistogram("ESD_MinimumIsoDistance",fIsoMin);
3604 Int_t AliAnalysisTaskGammaConversion::GetIndexHighestPtGamma(){
3605 //GetIndexHighestPtGamma
3607 Int_t indexHighestPtGamma=-1;
3609 fGammaPtHighest = -100.;
3611 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();firstGammaIndex++){
3612 AliKFParticle * gammaHighestPtCandidate = (AliKFParticle*)fKFReconstructedGammasTClone->At(firstGammaIndex);
3613 TVector3 momentumVectorgammaHighestPtCandidate(gammaHighestPtCandidate->GetPx(),gammaHighestPtCandidate->GetPy(),gammaHighestPtCandidate->GetPz());
3614 if (momentumVectorgammaHighestPtCandidate.Pt() > fGammaPtHighest){
3615 fGammaPtHighest=momentumVectorgammaHighestPtCandidate.Pt();
3616 //gammaHighestPt = gammaHighestPtCandidate;
3617 indexHighestPtGamma=firstGammaIndex;
3621 return indexHighestPtGamma;
3626 void AliAnalysisTaskGammaConversion::Terminate(Option_t */*option*/)
3628 // Terminate analysis
3630 AliDebug(1,"Do nothing in Terminate");
3633 void AliAnalysisTaskGammaConversion::UserCreateOutputObjects()
3639 if(!fAODGamma) fAODGamma = new TClonesArray(fOutputAODClassName.Data(), 0);
3640 else fAODGamma->Delete();
3641 fAODGamma->SetName(Form("%s_gamma", fAODBranchName.Data()));
3643 if(!fAODPi0) fAODPi0 = new TClonesArray(fOutputAODClassName.Data(), 0);
3644 else fAODPi0->Delete();
3645 fAODPi0->SetName(Form("%s_Pi0", fAODBranchName.Data()));
3647 if(!fAODOmega) fAODOmega = new TClonesArray(fOutputAODClassName.Data(), 0);
3648 else fAODOmega->Delete();
3649 fAODOmega->SetName(Form("%s_Omega", fAODBranchName.Data()));
3651 //If delta AOD file name set, add in separate file. Else add in standard aod file.
3652 if(GetDeltaAODFileName().Length() > 0) {
3653 AddAODBranch("TClonesArray", &fAODGamma, GetDeltaAODFileName().Data());
3654 AddAODBranch("TClonesArray", &fAODPi0, GetDeltaAODFileName().Data());
3655 AddAODBranch("TClonesArray", &fAODOmega, GetDeltaAODFileName().Data());
3656 AliAnalysisManager::GetAnalysisManager()->RegisterExtraFile(GetDeltaAODFileName().Data());
3658 AddAODBranch("TClonesArray", &fAODGamma);
3659 AddAODBranch("TClonesArray", &fAODPi0);
3660 AddAODBranch("TClonesArray", &fAODOmega);
3664 // Create the output container
3665 if(fOutputContainer != NULL){
3666 delete fOutputContainer;
3667 fOutputContainer = NULL;
3669 if(fOutputContainer == NULL){
3670 fOutputContainer = new TList();
3671 fOutputContainer->SetOwner(kTRUE);
3674 //Adding the histograms to the output container
3675 fHistograms->GetOutputContainer(fOutputContainer);
3679 if(fGammaNtuple == NULL){
3680 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);
3682 if(fNeutralMesonNtuple == NULL){
3683 fNeutralMesonNtuple = new TNtuple("NeutralMesonNtuple","NeutralMesonNtuple","test");
3685 TList * ntupleTList = new TList();
3686 ntupleTList->SetOwner(kTRUE);
3687 ntupleTList->SetName("Ntuple");
3688 ntupleTList->Add((TNtuple*)fGammaNtuple);
3689 fOutputContainer->Add(ntupleTList);
3692 fOutputContainer->SetName(GetName());
3695 Double_t AliAnalysisTaskGammaConversion::GetMCOpeningAngle(const TParticle* const daughter0, const TParticle* const daughter1) const{
3697 TVector3 v3D0(daughter0->Px(),daughter0->Py(),daughter0->Pz());
3698 TVector3 v3D1(daughter1->Px(),daughter1->Py(),daughter1->Pz());
3699 return v3D0.Angle(v3D1);
3702 void AliAnalysisTaskGammaConversion::CheckV0Efficiency(){
3703 // see header file for documentation
3705 vector<Int_t> indexOfGammaParticle;
3707 fStack = fV0Reader->GetMCStack();
3709 if(fV0Reader->CheckForPrimaryVertex() == kFALSE){
3710 return; // aborts if the primary vertex does not have contributors.
3713 for (Int_t iTracks = 0; iTracks < fStack->GetNprimary(); iTracks++) {
3714 TParticle* particle = (TParticle *)fStack->Particle(iTracks);
3715 if(particle->GetPdgCode()==22){ //Gamma
3716 if(particle->GetNDaughters() >= 2){
3717 TParticle* electron=NULL;
3718 TParticle* positron=NULL;
3719 for(Int_t daughterIndex=particle->GetFirstDaughter();daughterIndex<=particle->GetLastDaughter();daughterIndex++){
3720 TParticle *tmpDaughter = fStack->Particle(daughterIndex);
3721 if(tmpDaughter->GetUniqueID() == 5){
3722 if(tmpDaughter->GetPdgCode() == 11){
3723 electron = tmpDaughter;
3725 else if(tmpDaughter->GetPdgCode() == -11){
3726 positron = tmpDaughter;
3730 if(electron!=NULL && positron!=0){
3731 if(electron->R()<160){
3732 indexOfGammaParticle.push_back(iTracks);
3739 Int_t nFoundGammas=0;
3740 Int_t nNotFoundGammas=0;
3742 Int_t numberOfV0s = fV0Reader->GetNumberOfV0s();
3743 for(Int_t i=0;i<numberOfV0s;i++){
3744 fV0Reader->GetV0(i);
3746 if(fV0Reader->HasSameMCMother() == kFALSE){
3750 TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
3751 TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
3753 if(TMath::Abs(negativeMC->GetPdgCode())!=11 || TMath::Abs(positiveMC->GetPdgCode())!=11){
3756 if(negativeMC->GetPdgCode()==positiveMC->GetPdgCode()){
3760 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
3761 //TParticle * v0Gamma = fV0Reader->GetMotherMCParticle();
3762 for(UInt_t mcIndex=0;mcIndex<indexOfGammaParticle.size();mcIndex++){
3763 if(negativeMC->GetFirstMother()==indexOfGammaParticle[mcIndex]){
3775 void AliAnalysisTaskGammaConversion::ProcessGammaElectronsForChicAnalysis(){
3776 // see header file for documantation
3778 fESDEvent = fV0Reader->GetESDEvent();
3781 TClonesArray * vESDeNegTemp = new TClonesArray("AliESDtrack",0);
3782 TClonesArray * vESDePosTemp = new TClonesArray("AliESDtrack",0);
3783 TClonesArray * vESDxNegTemp = new TClonesArray("AliESDtrack",0);
3784 TClonesArray * vESDxPosTemp = new TClonesArray("AliESDtrack",0);
3785 TClonesArray * vESDeNegNoJPsi = new TClonesArray("AliESDtrack",0);
3786 TClonesArray * vESDePosNoJPsi = new TClonesArray("AliESDtrack",0);
3789 vector <AliESDtrack*> vESDeNegTemp(0);
3790 vector <AliESDtrack*> vESDePosTemp(0);
3791 vector <AliESDtrack*> vESDxNegTemp(0);
3792 vector <AliESDtrack*> vESDxPosTemp(0);
3793 vector <AliESDtrack*> vESDeNegNoJPsi(0);
3794 vector <AliESDtrack*> vESDePosNoJPsi(0);
3798 fHistograms->FillTable("Table_Electrons",0);//Count number of Events
3800 for(Int_t iTracks = 0; iTracks < fESDEvent->GetNumberOfTracks(); iTracks++){
3801 AliESDtrack* curTrack = fESDEvent->GetTrack(iTracks);
3804 //print warning here
3808 double p[3];if(!curTrack->GetConstrainedPxPyPz(p))continue;
3809 double r[3];curTrack->GetConstrainedXYZ(r);
3813 fHistograms->FillTable("Table_Electrons",4);//Count number of ESD tracks
3815 Bool_t flagKink = kTRUE;
3816 Bool_t flagTPCrefit = kTRUE;
3817 Bool_t flagTRDrefit = kTRUE;
3818 Bool_t flagITSrefit = kTRUE;
3819 Bool_t flagTRDout = kTRUE;
3820 Bool_t flagVertex = kTRUE;
3823 //Cuts ---------------------------------------------------------------
3825 if(curTrack->GetKinkIndex(0) > 0){
3826 fHistograms->FillHistogram("Table_Electrons",5);//Count kink
3830 ULong_t trkStatus = curTrack->GetStatus();
3832 ULong_t tpcRefit = (trkStatus & AliESDtrack::kTPCrefit);
3835 fHistograms->FillHistogram("Table_Electrons",9);//Count not TPCrefit
3836 flagTPCrefit = kFALSE;
3839 ULong_t itsRefit = (trkStatus & AliESDtrack::kITSrefit);
3841 fHistograms->FillHistogram("Table_Electrons",10);//Count not ITSrefit
3842 flagITSrefit = kFALSE;
3845 ULong_t trdRefit = (trkStatus & AliESDtrack::kTRDrefit);
3848 fHistograms->FillHistogram("Table_Electrons",8); //Count not TRDrefit
3849 flagTRDrefit = kFALSE;
3852 ULong_t trdOut = (trkStatus & AliESDtrack::kTRDout);
3855 fHistograms->FillHistogram("Table_Electrons",7); //Count not TRDout
3856 flagTRDout = kFALSE;
3859 double nsigmaToVxt = GetSigmaToVertex(curTrack);
3861 if(nsigmaToVxt > 3){
3862 fHistograms->FillHistogram("Table_Electrons",6); //Count Tracks with number of sigmas > 3
3863 flagVertex = kFALSE;
3866 if(! (flagKink && flagTPCrefit && flagITSrefit && flagTRDrefit && flagTRDout && flagVertex ) ) continue;
3867 fHistograms->FillHistogram("Table_Electrons",11);//Count Tracks passed Cuts
3871 GetPID(curTrack, pid, weight);
3874 fHistograms->FillHistogram("Table_Electrons",12); //Count Tracks with pid != 0
3878 fHistograms->FillHistogram("Table_Electrons",13); //Count Tracks with pid != 0
3886 TLorentzVector curElec;
3887 curElec.SetXYZM(p[0],p[1],p[2],fElectronMass);
3891 Int_t labelMC = TMath::Abs(curTrack->GetLabel());
3892 TParticle* curParticle = fStack->Particle(labelMC);
3893 if(curTrack->GetSign() > 0){
3895 fHistograms->FillHistogram("MC_ElectronPosNegPt",curParticle->Pt());
3896 fHistograms->FillHistogram("MC_ElectronPosNegEta",curParticle->Eta());
3899 fHistograms->FillHistogram("MC_ElectronPosNegPt",curParticle->Pt());
3900 fHistograms->FillHistogram("MC_ElectronPosNegEta",curParticle->Eta());
3906 if(curTrack->GetSign() > 0){
3908 // vESDxPosTemp.push_back(curTrack);
3909 new((*vESDxPosTemp)[vESDxPosTemp->GetEntriesFast()]) AliESDtrack(*curTrack);
3913 fHistograms->FillHistogram("ESD_ElectronPosNegPt",curElec.Pt());
3914 fHistograms->FillHistogram("ESD_ElectronPosPt",curElec.Pt());
3915 // fHistograms->FillHistogram("MC_ElectronPosNegPt",curParticle->Pt());
3916 fHistograms->FillHistogram("ESD_ElectronPosNegEta",curElec.Eta());
3917 // fHistograms->FillHistogram("MC_ElectronPosNegEta",curParticle->Eta());
3918 // vESDePosTemp.push_back(curTrack);
3919 new((*vESDePosTemp)[vESDePosTemp->GetEntriesFast()]) AliESDtrack(*curTrack);
3926 new((*vESDxNegTemp)[vESDxNegTemp->GetEntriesFast()]) AliESDtrack(*curTrack);
3930 fHistograms->FillHistogram("ESD_ElectronPosNegPt",curElec.Pt());
3931 fHistograms->FillHistogram("ESD_ElectronNegPt",curElec.Pt());
3932 fHistograms->FillHistogram("ESD_ElectronPosNegEta",curElec.Eta());
3933 new((*vESDeNegTemp)[vESDeNegTemp->GetEntriesFast()]) AliESDtrack(*curTrack);
3942 Bool_t ePosJPsi = kFALSE;
3943 Bool_t eNegJPsi = kFALSE;
3944 Bool_t ePosPi0 = kFALSE;
3945 Bool_t eNegPi0 = kFALSE;
3947 UInt_t iePosJPsi=0,ieNegJPsi=0,iePosPi0=0,ieNegPi0=0;
3949 for(Int_t iNeg=0; iNeg < vESDeNegTemp->GetEntriesFast(); iNeg++){
3950 if(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDeNegTemp->At(iNeg)))->GetLabel()))->GetPdgCode() == 11)
3951 if(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDeNegTemp->At(iNeg)))->GetLabel()))->GetMother(0) > -1){
3952 Int_t labelMother = fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDeNegTemp->At(iNeg)))->GetLabel()))->GetMother(0);
3953 TParticle* partMother = fStack ->Particle(labelMother);
3954 if (partMother->GetPdgCode() == 111){
3958 if(partMother->GetPdgCode() == 443){ //Mother JPsi
3959 fHistograms->FillTable("Table_Electrons",14);
3964 // vESDeNegNoJPsi.push_back(vESDeNegTemp[iNeg]);
3965 new((*vESDeNegNoJPsi)[vESDeNegNoJPsi->GetEntriesFast()]) AliESDtrack(*(AliESDtrack*)(vESDeNegTemp->At(iNeg)));
3966 // cout<<"ESD No Positivo JPsi "<<endl;
3972 for(Int_t iPos=0; iPos < vESDePosTemp->GetEntriesFast(); iPos++){
3973 if(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDePosTemp->At(iPos)))->GetLabel()))->GetPdgCode() == -11)
3974 if(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDePosTemp->At(iPos)))->GetLabel()))->GetMother(0) > -1){
3975 Int_t labelMother = fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDePosTemp->At(iPos)))->GetLabel()))->GetMother(0);
3976 TParticle* partMother = fStack ->Particle(labelMother);
3977 if (partMother->GetPdgCode() == 111){
3981 if(partMother->GetPdgCode() == 443){ //Mother JPsi
3982 fHistograms->FillTable("Table_Electrons",15);
3987 // vESDePosNoJPsi.push_back(vESDePosTemp[iPos]);
3988 new((*vESDePosNoJPsi)[vESDePosNoJPsi->GetEntriesFast()]) AliESDtrack(*(AliESDtrack*)(vESDePosTemp->At(iPos)));
3989 // cout<<"ESD No Negativo JPsi "<<endl;
3995 if( eNegJPsi && ePosJPsi ){
3996 TVector3 tempeNegV,tempePosV;
3997 tempeNegV.SetXYZ(((AliESDtrack*)(vESDeNegTemp->At(ieNegJPsi)))->Px(),((AliESDtrack*)(vESDeNegTemp->At(ieNegJPsi)))->Py(),((AliESDtrack*)(vESDeNegTemp->At(ieNegJPsi)))->Pz());
3998 tempePosV.SetXYZ(((AliESDtrack*)(vESDePosTemp->At(iePosJPsi)))->Px(),((AliESDtrack*)(vESDePosTemp->At(iePosJPsi)))->Py(),((AliESDtrack*)(vESDePosTemp->At(iePosJPsi)))->Pz());
3999 fHistograms->FillTable("Table_Electrons",16);
4000 fHistograms->FillHistogram("ESD_ElectronPosNegJPsiAngle",tempeNegV.Angle(tempePosV));
4001 fHistograms->FillHistogram("MC_ElectronPosNegJPsiAngle",GetMCOpeningAngle(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDeNegTemp->At(ieNegJPsi)))->GetLabel())),
4002 fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDePosTemp->At(iePosJPsi)))->GetLabel()))));
4005 if( eNegPi0 && ePosPi0 ){
4006 TVector3 tempeNegV,tempePosV;
4007 tempeNegV.SetXYZ(((AliESDtrack*)(vESDeNegTemp->At(ieNegPi0)))->Px(),((AliESDtrack*)(vESDeNegTemp->At(ieNegPi0)))->Py(),((AliESDtrack*)(vESDeNegTemp->At(ieNegPi0)))->Pz());
4008 tempePosV.SetXYZ(((AliESDtrack*)(vESDePosTemp->At(iePosPi0)))->Px(),((AliESDtrack*)(vESDePosTemp->At(iePosPi0)))->Py(),((AliESDtrack*)(vESDePosTemp->At(iePosPi0)))->Pz());
4009 fHistograms->FillHistogram("ESD_ElectronPosNegPi0Angle",tempeNegV.Angle(tempePosV));
4010 fHistograms->FillHistogram("MC_ElectronPosNegPi0Angle",GetMCOpeningAngle(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDeNegTemp->At(ieNegPi0)))->GetLabel())),
4011 fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDePosTemp->At(iePosPi0)))->GetLabel()))));
4015 FillAngle("ESD_eNegePosAngleBeforeCut",GetTLorentzVector(vESDeNegTemp),GetTLorentzVector(vESDePosTemp));
4017 CleanWithAngleCuts(*vESDeNegTemp,*vESDePosTemp,*fKFReconstructedGammasTClone);
4019 // vector <TLorentzVector> vCurrentTLVeNeg = GetTLorentzVector(fCurrentEventNegElectron);
4020 // vector <TLorentzVector> vCurrentTLVePos = GetTLorentzVector(fCurrentEventPosElectron);
4022 TClonesArray vCurrentTLVeNeg = GetTLorentzVector(fCurrentEventNegElectronTClone);
4023 TClonesArray vCurrentTLVePos = GetTLorentzVector(fCurrentEventPosElectronTClone);
4026 FillAngle("ESD_eNegePosAngleAfterCut",vCurrentTLVeNeg,vCurrentTLVePos);
4031 //FillAngle("ESD_eNegePosAngleAfterCut",CurrentTLVeNeg,CurrentTLVePos);
4034 FillElectronInvMass("ESD_InvMass_ePluseMinus",vCurrentTLVeNeg,vCurrentTLVePos);
4035 FillElectronInvMass("ESD_InvMass_xPlusxMinus",GetTLorentzVector(vESDxNegTemp),GetTLorentzVector(vESDxPosTemp));
4039 FillGammaElectronInvMass("ESD_InvMass_GammaePluseMinusChiC","ESD_InvMass_GammaePluseMinusChiCDiff",*fKFReconstructedGammasCutTClone,vCurrentTLVeNeg,vCurrentTLVePos);
4041 FillGammaElectronInvMass("ESD_InvMass_GammaePluseMinusPi0","ESD_InvMass_GammaePluseMinusPi0Diff",
4042 *fKFReconstructedGammasCutTClone,vCurrentTLVeNeg,vCurrentTLVePos);
4047 ElectronBackground("ESD_ENegBackground",vCurrentTLVeNeg);
4048 ElectronBackground("ESD_EPosBackground",vCurrentTLVePos);
4049 ElectronBackground("ESD_EPosENegBackground",vCurrentTLVeNeg);
4050 ElectronBackground("ESD_EPosENegBackground",vCurrentTLVePos);
4052 // Like Sign e+e- no JPsi
4053 ElectronBackground("ESD_EPosENegNoJPsiBG",GetTLorentzVector(vESDeNegNoJPsi));
4054 ElectronBackground("ESD_EPosENegNoJPsiBG",GetTLorentzVector(vESDePosNoJPsi));
4058 if( fCurrentEventPosElectronTClone->GetEntriesFast() > 0 && fCurrentEventNegElectronTClone->GetEntriesFast() > 0 && fKFReconstructedGammasCutTClone->GetEntriesFast() > 0 ){
4059 FillGammaElectronInvMass("ESD_EPosENegGammaBackgroundMX","ESD_EPosENegGammaBackgroundMXDiff",
4060 *fKFReconstructedGammasCutTClone,*fPreviousEventTLVNegElectronTClone,*fPreviousEventTLVPosElectronTClone);
4061 *fPreviousEventTLVNegElectronTClone = vCurrentTLVeNeg;
4062 *fPreviousEventTLVPosElectronTClone = vCurrentTLVePos;
4069 vtx[0]=0;vtx[1]=0;vtx[2]=0;
4070 for(UInt_t i=0;i<fKFReconstructedGammasChic.size();i++){
4072 // if(fMCGammaChicTempCut[i]->GetMother(0) < 0) continue;
4076 Int_t tempLabel = fStack->Particle(fMCGammaChicTempCut[i]->GetMother(0))->GetPdgCode();
4077 // cout<<" Label Pedro Gonzalez " <<tempLabel <<endl;
4079 // cout<<" Label Distance"<<fKFReconstructedGammasChic[i].GetDistanceFromVertex(vtx)<<endl;
4081 if( tempLabel == 10441 || tempLabel == 20443 || tempLabel == 445 )
4083 fHistograms->FillHistogram("ESD_PhotonsMomentum",fKFReconstructedGammasChic[i].GetMomentum());
4092 vESDeNegTemp->Delete();
4093 vESDePosTemp->Delete();
4094 vESDxNegTemp->Delete();
4095 vESDxPosTemp->Delete();
4096 vESDeNegNoJPsi->Delete();
4097 vESDePosNoJPsi->Delete();
4099 delete vESDeNegTemp;
4100 delete vESDePosTemp;
4101 delete vESDxNegTemp;
4102 delete vESDxPosTemp;
4103 delete vESDeNegNoJPsi;
4104 delete vESDePosNoJPsi;
4108 void AliAnalysisTaskGammaConversion::FillAngle(TString histoName,vector <TLorentzVector> tlVeNeg, vector <TLorentzVector> tlVePos){
4109 //see header file for documentation
4110 for( UInt_t iNeg=0; iNeg < tlVeNeg.size(); iNeg++){
4111 for (UInt_t iPos=0; iPos < tlVePos.size(); iPos++){
4112 fHistograms->FillHistogram(histoName.Data(),tlVeNeg[iNeg].Vect().Angle(tlVePos[iPos].Vect()));
4117 void AliAnalysisTaskGammaConversion::FillAngle(TString histoName,TClonesArray const tlVeNeg, TClonesArray const tlVePos){
4118 //see header file for documentation
4119 for( Int_t iNeg=0; iNeg < tlVeNeg.GetEntriesFast(); iNeg++){
4120 for (Int_t iPos=0; iPos < tlVePos.GetEntriesFast(); iPos++){
4121 fHistograms->FillHistogram(histoName.Data(),((TLorentzVector*)(tlVeNeg.At(iNeg)))->Vect().Angle(((TLorentzVector*)(tlVePos.At(iPos)))->Vect()));
4125 void AliAnalysisTaskGammaConversion::FillElectronInvMass(TString histoName, TClonesArray const eNeg, TClonesArray const ePos){
4126 //see header file for documentation
4127 for( Int_t n=0; n < eNeg.GetEntriesFast(); n++){
4128 TLorentzVector en = (*(TLorentzVector*)(eNeg.At(n)));
4129 for (Int_t p=0; p < ePos.GetEntriesFast(); p++){
4130 TLorentzVector ep = (*(TLorentzVector*)(ePos.At(p)));
4131 TLorentzVector np = ep + en;
4132 fHistograms->FillHistogram(histoName.Data(),np.M());
4137 void AliAnalysisTaskGammaConversion::FillGammaElectronInvMass(TString histoMass,TString histoDiff,TClonesArray const fKFGammas,
4138 TClonesArray const tlVeNeg,TClonesArray const tlVePos)
4140 //see header file for documentation
4142 for( Int_t iNeg=0; iNeg < tlVeNeg.GetEntriesFast(); iNeg++ ){
4144 for (Int_t iPos=0; iPos < tlVePos.GetEntriesFast(); iPos++){
4146 TLorentzVector xy = *((TLorentzVector *)(tlVePos.At(iPos))) + *((TLorentzVector *)(tlVeNeg.At(iNeg)));
4148 for (Int_t iGam=0; iGam < fKFGammas.GetEntriesFast(); iGam++){
4150 // AliKFParticle * gammaCandidate = &fKFGammas[iGam];
4151 AliKFParticle * gammaCandidate = (AliKFParticle *)(fKFGammas.At(iGam));
4154 g.SetXYZM(gammaCandidate->GetPx(),gammaCandidate->GetPy(),gammaCandidate->GetPz(),fGammaMass);
4155 TLorentzVector xyg = xy + g;
4156 fHistograms->FillHistogram(histoMass.Data(),xyg.M());
4157 fHistograms->FillHistogram(histoDiff.Data(),(xyg.M()-xy.M()));
4163 void AliAnalysisTaskGammaConversion::ElectronBackground(TString hBg, TClonesArray e)
4165 // see header file for documentation
4166 for(Int_t i=0; i < e.GetEntriesFast(); i++)
4168 for (Int_t j=i+1; j < e.GetEntriesFast(); j++)
4170 TLorentzVector ee = (*(TLorentzVector*)(e.At(i))) + (*(TLorentzVector*)(e.At(j)));
4172 fHistograms->FillHistogram(hBg.Data(),ee.M());
4178 void AliAnalysisTaskGammaConversion::CleanWithAngleCuts(TClonesArray const negativeElectrons,
4179 TClonesArray const positiveElectrons,
4180 TClonesArray const gammas){
4181 // see header file for documentation
4183 UInt_t sizeN = negativeElectrons.GetEntriesFast();
4184 UInt_t sizeP = positiveElectrons.GetEntriesFast();
4185 UInt_t sizeG = gammas.GetEntriesFast();
4189 vector <Bool_t> xNegBand(sizeN);
4190 vector <Bool_t> xPosBand(sizeP);
4191 vector <Bool_t> gammaBand(sizeG);
4194 for(UInt_t iNeg=0; iNeg < sizeN; iNeg++) xNegBand[iNeg]=kTRUE;
4195 for(UInt_t iPos=0; iPos < sizeP; iPos++) xPosBand[iPos]=kTRUE;
4196 for(UInt_t iGam=0; iGam < sizeG; iGam++) gammaBand[iGam]=kTRUE;
4199 for(UInt_t iPos=0; iPos < sizeP; iPos++){
4202 ((AliESDtrack*)(positiveElectrons.At(iPos)))->GetConstrainedPxPyPz(aP);
4204 TVector3 ePosV(aP[0],aP[1],aP[2]);
4206 for(UInt_t iNeg=0; iNeg < sizeN; iNeg++){
4209 ((AliESDtrack*)(negativeElectrons.At(iNeg)))->GetConstrainedPxPyPz(aN);
4210 TVector3 eNegV(aN[0],aN[1],aN[2]);
4212 if(ePosV.Angle(eNegV) < 0.05){ //e+e- from gamma
4213 xPosBand[iPos]=kFALSE;
4214 xNegBand[iNeg]=kFALSE;
4217 for(UInt_t iGam=0; iGam < sizeG; iGam++){
4218 AliKFParticle* gammaCandidate = (AliKFParticle*)gammas.At(iGam);
4219 TVector3 gammaCandidateVector(gammaCandidate->Px(),gammaCandidate->Py(),gammaCandidate->Pz());
4220 if(ePosV.Angle(gammaCandidateVector) < 0.05 || eNegV.Angle(gammaCandidateVector) < 0.05)
4221 gammaBand[iGam]=kFALSE;
4229 for(UInt_t iPos=0; iPos < sizeP; iPos++){
4231 new((*fCurrentEventPosElectronTClone)[fCurrentEventPosElectronTClone->GetEntriesFast()]) AliESDtrack((*(AliESDtrack*)(positiveElectrons.At(iPos))));
4232 // fCurrentEventPosElectron.push_back(positiveElectrons[iPos]);
4235 for(UInt_t iNeg=0;iNeg < sizeN; iNeg++){
4237 new((*fCurrentEventNegElectronTClone)[fCurrentEventNegElectronTClone->GetEntriesFast()]) AliESDtrack((*(AliESDtrack*)(negativeElectrons.At(iNeg))));
4238 // fCurrentEventNegElectron.push_back(negativeElectrons[iNeg]);
4241 for(UInt_t iGam=0; iGam < sizeG; iGam++){
4242 if(gammaBand[iGam]){
4243 new((*fKFReconstructedGammasCutTClone)[fKFReconstructedGammasCutTClone->GetEntriesFast()]) AliKFParticle((*(AliKFParticle*)(gammas.At(iGam))));
4244 //fKFReconstructedGammasCut.push_back(*(AliKFParticle*)gammas->At(iGam));
4250 void AliAnalysisTaskGammaConversion::GetPID(const AliESDtrack *track, Stat_t &pid, Stat_t &weight)
4252 // see header file for documentation
4257 double wpartbayes[5];
4259 //get probability of the diffenrent particle types
4260 track->GetESDpid(wpart);
4262 // Tentative particle type "concentrations"
4263 double c[5]={0.01, 0.01, 0.85, 0.10, 0.05};
4267 for (int i = 0; i < 5; i++)
4269 rcc+=(c[i] * wpart[i]);
4274 for (int i=0; i<5; i++) {
4275 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)
4276 wpartbayes[i] = c[i] * wpart[i] / rcc;
4284 //find most probable particle in ESD pid
4285 //0:Electron - 1:Muon - 2:Pion - 3:Kaon - 4:Proton
4286 for (int i = 0; i < 5; i++)
4288 if (wpartbayes[i] > max)
4291 max = wpartbayes[i];
4298 double AliAnalysisTaskGammaConversion::GetSigmaToVertex(const AliESDtrack* t)
4300 // Calculates the number of sigma to the vertex.
4305 t->GetImpactParameters(b,bCov);
4306 if (bCov[0]<=0 || bCov[2]<=0) {
4307 AliDebug(1, "Estimated b resolution lower or equal zero!");
4308 bCov[0]=0; bCov[2]=0;
4310 bRes[0] = TMath::Sqrt(bCov[0]);
4311 bRes[1] = TMath::Sqrt(bCov[2]);
4313 // -----------------------------------
4314 // How to get to a n-sigma cut?
4316 // The accumulated statistics from 0 to d is
4318 // -> Erf(d/Sqrt(2)) for a 1-dim gauss (d = n_sigma)
4319 // -> 1 - Exp(-d**2) for a 2-dim gauss (d*d = dx*dx + dy*dy != n_sigma)
4321 // It means that for a 2-dim gauss: n_sigma(d) = Sqrt(2)*ErfInv(1 - Exp((-x**2)/2)
4322 // Can this be expressed in a different way?
4324 if (bRes[0] == 0 || bRes[1] ==0)
4327 double d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
4329 // stupid rounding problem screws up everything:
4330 // if d is too big, TMath::Exp(...) gets 0, and TMath::ErfInverse(1) that should be infinite, gets 0 :(
4331 if (TMath::Exp(-d * d / 2) < 1e-10)
4335 d = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);
4339 //vector <TLorentzVector> AliAnalysisTaskGammaConversion::GetTLorentzVector(vector <AliESDtrack*> esdTrack){
4340 TClonesArray AliAnalysisTaskGammaConversion::GetTLorentzVector(TClonesArray *const esdTrack){
4341 //Return TLoresntz vector of track?
4342 // vector <TLorentzVector> tlVtrack(0);
4343 TClonesArray array("TLorentzVector",0);
4345 for(Int_t itrack=0; itrack < esdTrack->GetEntriesFast(); itrack++){
4347 //esdTrack[itrack]->GetConstrainedPxPyPz(p);
4348 ((AliESDtrack*)(esdTrack->At(itrack)))->GetConstrainedPxPyPz(p);
4349 TLorentzVector currentTrack;
4350 currentTrack.SetXYZM(p[0],p[1],p[2],fElectronMass);
4351 new((array)[array.GetEntriesFast()]) TLorentzVector(currentTrack);
4352 // tlVtrack.push_back(currentTrack);
4359 Int_t AliAnalysisTaskGammaConversion::GetProcessType(const AliMCEvent * mcEvt) {
4361 // Determine if the event was generated with pythia or phojet and return the process type
4363 // Check if mcEvt is fine
4365 AliFatal("NULL mc event");
4368 // Determine if it was a pythia or phojet header, and return the correct process type
4369 AliGenPythiaEventHeader * headPy = 0;
4370 AliGenDPMjetEventHeader * headPho = 0;
4371 AliGenEventHeader * htmp = mcEvt->GenEventHeader();
4373 AliFatal("Cannot Get MC Header!!");
4375 if( TString(htmp->IsA()->GetName()) == "AliGenPythiaEventHeader") {
4376 headPy = (AliGenPythiaEventHeader*) htmp;
4377 } else if (TString(htmp->IsA()->GetName()) == "AliGenDPMjetEventHeader") {
4378 headPho = (AliGenDPMjetEventHeader*) htmp;
4380 AliError("Unknown header");
4383 // Determine process type
4385 if(headPy->ProcessType() == 92 || headPy->ProcessType() == 93) {
4386 // single difractive
4388 } else if (headPy->ProcessType() == 94) {
4389 // double diffractive
4392 else if(headPy->ProcessType() != 92 && headPy->ProcessType() != 93 && headPy->ProcessType() != 94) {
4396 } else if (headPho) {
4397 if(headPho->ProcessType() == 5 || headPho->ProcessType() == 6 ) {
4398 // single difractive
4400 } else if (headPho->ProcessType() == 7) {
4401 // double diffractive
4403 } else if(headPho->ProcessType() != 5 && headPho->ProcessType() != 6 && headPho->ProcessType() != 7 ) {
4410 // no process type found?
4411 AliError(Form("Unknown header: %s", htmp->IsA()->GetName()));
4412 return kProcUnknown;
4416 Int_t AliAnalysisTaskGammaConversion::CalculateMultiplicityBin(){
4417 // Get Centrality bin
4419 Int_t multiplicity = 0;
4421 if ( fUseMultiplicity == 1 ) {
4423 if (fMultiplicity>= 0 && fMultiplicity<= 5) multiplicity=1;
4424 if (fMultiplicity>= 6 && fMultiplicity<= 9) multiplicity=2;
4425 if (fMultiplicity>=10 && fMultiplicity<=14) multiplicity=3;
4426 if (fMultiplicity>=15 && fMultiplicity<=22) multiplicity=4;
4427 if (fMultiplicity>=23 ) multiplicity=5;
4430 return multiplicity;