+ Int_t gamma0MCLabel = -1;
+ Int_t gamma0MotherLabel = -1;
+ if(!positiveMC||!negativeMC)
+ return;
+
+ if(positiveMC->GetMother()>-1&&(negativeMC->GetMother() == positiveMC->GetMother())){
+ gamma0MCLabel = positiveMC->GetMother();
+ }
+
+ if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
+ // Daughters Gamma 0
+ AliAODMCParticle * gammaMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MCLabel));
+ if(abs(negativeMC->GetPdgCode())==11 && abs(positiveMC->GetPdgCode())==11){ // Electrons ...
+ if(((positiveMC->GetMCProcessCode())) == 5 && ((negativeMC->GetMCProcessCode())) == 5){ // ... From Conversion ... // STILL A BUG IN ALIROOT >>8 HAS TPO BE REMOVED AFTER FIX
+ if(gammaMC0->GetPdgCode() == 22){ // ... with Gamma Mother
+ gamma0MotherLabel=gammaMC0->GetMother();
+ }
+ }
+ if(gammaMC0->GetPdgCode() ==111){ // Conversion but Pi0 Mother
+ gamma0MotherLabel=-111;
+ }
+ if(gammaMC0->GetPdgCode() ==221){ // Conversion but Eta Mother
+ gamma0MotherLabel=-221;
+ }
+ }
+ }
+ positiveMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate1->GetMCLabelPositive()));
+ negativeMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate1->GetMCLabelNegative()));
+
+ Int_t gamma1MCLabel = -1;
+ Int_t gamma1MotherLabel = -1;
+ if(!positiveMC||!negativeMC)
+ return;
+
+ if(positiveMC->GetMother()>-1&&(negativeMC->GetMother() == positiveMC->GetMother())){
+ gamma1MCLabel = positiveMC->GetMother();
+ }
+ if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
+ // Daughters Gamma 1
+ AliAODMCParticle * gammaMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MCLabel));
+ if(abs(negativeMC->GetPdgCode())==11 && abs(positiveMC->GetPdgCode())==11){ // Electrons ...
+ if(((positiveMC->GetMCProcessCode())) == 5 && ((negativeMC->GetMCProcessCode())) == 5){ // ... From Conversion ... // STILL A BUG IN ALIROOT >>8 HAS TPO BE REMOVED AFTER FIX
+ if(gammaMC1->GetPdgCode() == 22){ // ... with Gamma Mother
+ gamma1MotherLabel=gammaMC1->GetMother();
+ }
+ }
+ if(gammaMC1->GetPdgCode() ==111){ // Conversion but Pi0 Mother
+ gamma1MotherLabel=-111;
+ }
+ if(gammaMC1->GetPdgCode() ==221){ // Conversion but Eta Mother
+ gamma1MotherLabel=-221;
+ }
+ }
+ }
+ if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
+ if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == 111){
+ isTruePi0=kTRUE;
+ }
+ if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == 221){
+ isTrueEta=kTRUE;
+ }
+ }
+ if(isTruePi0 || isTrueEta){// True Pion or Eta
+ hESDTrueMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+
+ if(!(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MotherLabel))->IsPrimary())){ // Secondary Meson
+ Int_t secMotherLabel = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->GetMother();
+ Float_t weightedSec= 1;
+ if(((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(secMotherLabel, 0x0, fInputEvent) && static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==310){
+ weightedSec= ((AliConversionCuts*)fCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),secMotherLabel, 0x0, fInputEvent)/2.; //invariant mass is additive thus the weight for the daughters has to be devide by two for the K0s at a certain pt
+ //cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
+ }
+ hESDTrueSecondaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
+
+ if (secMotherLabel >-1){
+ if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==310){
+ hESDTrueSecondaryMotherFromK0sInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
+ if (fDoMesonQA)hESDTrueK0sWithPi0DaughterMCPt[fiCut]
+ ->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
+ }
+ if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==221){
+ hESDTrueSecondaryMotherFromEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
+ if (fDoMesonQA)hESDTrueEtaWithPi0DaughterMCPt[fiCut]
+ ->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
+ }
+ }
+ }else{ // Only primary pi0 for efficiency calculation
+ Float_t weighted= 1;
+ if(((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(gamma1MotherLabel, 0x0, fInputEvent)){
+ if (static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt()>0.005){
+ weighted= ((AliConversionCuts*)fCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),gamma1MotherLabel, 0x0, fInputEvent);
+ // cout << "rec \t " <<gamma1MotherLabel << "\t" << weighted << endl;
+ }
+ }
+ hESDTruePrimaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
+
+ if (fDoMesonQA){
+ Double_t sparesFill[3] = {Pi0Candidate->M(),Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift()};
+ sESDTruePrimaryMotherInvMassPtY[fiCut]->Fill(sparesFill,1);
+ if(isTruePi0){ // Only primary pi0 for resolution
+ hESDTruePrimaryPi0MCPtResolPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),
+ (Pi0Candidate->Pt()-static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt())/static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),weighted);
+ }
+ if (isTrueEta){ // Only primary eta for resolution
+ hESDTruePrimaryEtaMCPtResolPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),
+ (Pi0Candidate->Pt()-static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt())/static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),weighted);
+ }
+ }
+ }
+ }
+ else if(!isTruePi0 && !isTrueEta && fDoMesonQA){ // Background
+ if(gamma0MotherLabel>-1 && gamma1MotherLabel>-1){ // Both Tracks are Photons and have a mother but not Pi0 or Eta
+ hESDTrueBckGGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+ } else { // No photon or without mother
+ hESDTrueBckContInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+ }
+ if((gamma0MotherLabel==-111 || gamma1MotherLabel==-111 || gamma0MotherLabel==-221 || gamma1MotherLabel==-221) ){
+ // Dalitz
+ hESDTrueMotherDalitzInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+ }
+ }
+}