bugs corrected
[u/mrichter/AliRoot.git] / PWG4 / PartCorr / AliAnalysisTaskGammaConversion.cxx
index ff6d6fd..f6edf1f 100644 (file)
@@ -124,6 +124,7 @@ AliAnalysisTaskGammaConversion::~AliAnalysisTaskGammaConversion()
 void AliAnalysisTaskGammaConversion::Init()\r
 {\r
   // Initialization\r
+  AliLog::SetGlobalLogLevel(AliLog::kError);\r
 }\r
 \r
 \r
@@ -216,10 +217,26 @@ void AliAnalysisTaskGammaConversion::ProcessMCData(){
          fHistograms->FillHistogram("MC_Gamma_Phi", tmpPhi);\r
 \r
          //adding the conversion points from all gammas with e+e- daughters\r
-         if(particle->GetNDaughters() == 2){\r
-           TParticle* daughter0 = (TParticle*)fStack->Particle(particle->GetFirstDaughter());\r
-           TParticle* daughter1 = (TParticle*)fStack->Particle(particle->GetLastDaughter());\r
+         if(particle->GetNDaughters() >= 2){\r
+           TParticle* daughter0 = NULL;\r
+           TParticle* daughter1 = NULL;\r
            \r
+           for(Int_t daughterIndex=particle->GetFirstDaughter();daughterIndex<=particle->GetLastDaughter();daughterIndex++){\r
+             TParticle *tmpDaughter = fStack->Particle(daughterIndex);\r
+             if(tmpDaughter->GetUniqueID() == 5){\r
+               if(tmpDaughter->GetPdgCode() == 11){\r
+                  daughter0 = tmpDaughter;\r
+               }\r
+               else if(tmpDaughter->GetPdgCode() == -11){\r
+                 daughter1 = tmpDaughter;\r
+               }\r
+             }\r
+           }\r
+\r
+           if(daughter0 == NULL || daughter1 == NULL){ // means we do not have two daughters from pair production\r
+             continue;\r
+           }\r
+\r
            if(daughter0->R()>fV0Reader->GetMaxRCut() || daughter1->R()>fV0Reader->GetMaxRCut()){\r
              continue;\r
            }\r
@@ -244,24 +261,24 @@ void AliAnalysisTaskGammaConversion::ProcessMCData(){
              fHistograms->FillHistogram(nameMCMappingR, particle->Eta());\r
              \r
              TString nameMCMappingPhiInR="";\r
-             nameMCMappingPhiInR.Form("MC_EP_Mapping_Phi_vs_R_R-%02d",rBin);\r
-             fHistograms->FillHistogram(nameMCMappingPhiInR, daughter0->R(), tmpPhi);\r
+             nameMCMappingPhiInR.Form("MC_EP_Mapping_Phi_R-%02d",rBin);\r
+             fHistograms->FillHistogram(nameMCMappingPhiInR, tmpPhi);\r
              //end mapping\r
 \r
              fHistograms->FillHistogram("MC_EP_R",daughter0->R());\r
              fHistograms->FillHistogram("MC_EP_ZR",daughter0->Vz(),daughter0->R());\r
              fHistograms->FillHistogram("MC_EP_XY",daughter0->Vx(),daughter0->Vy());\r
              fHistograms->FillHistogram("MC_EP_OpeningAngle",GetMCOpeningAngle(daughter0, daughter1));\r
-           }\r
-         }\r
-       }\r
+           }// end if((daughter0->GetPdgCode() == -11 && daughter1->GetPdgCode()) == 11 ||....... approx 20 lines above\r
+         }// end if(particle->GetNDaughters() >= 2){\r
+       } // end if( fStack->Particle(particle->GetMother(0))->GetPdgCode() != 22 )\r
        if( fStack->Particle(particle->GetMother(0))->GetPdgCode()==10441 ||//chic0 \r
            fStack->Particle(particle->GetMother(0))->GetPdgCode()==20443 ||//psi2S\r
            fStack->Particle(particle->GetMother(0))->GetPdgCode()==445  //chic2\r
-       ){ \r
+           ){ \r
          fMCGammaChic.push_back(particle);\r
-         }\r
-      }\r
+       }\r
+      }// end if(particle->GetMother(0)>-1)\r
       else{//means we have a primary particle\r
        fHistograms->FillHistogram("MC_DirectGamma_Energy",particle->Energy());\r
        fHistograms->FillHistogram("MC_DirectGamma_Pt", particle->Pt());\r
@@ -282,9 +299,8 @@ void AliAnalysisTaskGammaConversion::ProcessMCData(){
 \r
          }\r
        }\r
-\r
-      }\r
-    }\r
+      }// end else\r
+    }// end if (particle->GetPdgCode()== 22){\r
     else if (TMath::Abs(particle->GetPdgCode())== 11){ // Means we have an electron or a positron\r
       if(particle->GetMother(0)>-1){ // means we have a mother\r
        if( fStack->Particle(particle->GetMother(0))->GetPdgCode()==22 ){ // Means we have a gamma mother\r
@@ -302,7 +318,7 @@ void AliAnalysisTaskGammaConversion::ProcessMCData(){
          }\r
        }\r
       }\r
-    }\r
+    } // end else if (TMath::Abs(particle->GetPdgCode())== 11)\r
     else if(particle->GetNDaughters() == 2){\r
 \r
       TParticle* daughter0 = (TParticle*)fStack->Particle(particle->GetFirstDaughter());\r
@@ -322,7 +338,7 @@ void AliAnalysisTaskGammaConversion::ProcessMCData(){
            fHistograms->FillHistogram("MC_Pi0_Secondaries_Energy", particle->Energy());\r
            fHistograms->FillHistogram("MC_Pi0_Secondaries_R", particle->R());\r
            fHistograms->FillHistogram("MC_Pi0_Secondaries_ZR", particle->Vz(),particle->R());\r
-           fHistograms->FillHistogram("MC_Pi0_Secondaries_OpeningAngle_Gamma", GetMCOpeningAngle(daughter0,daughter1));\r
+           fHistograms->FillHistogram("MC_Pi0_Secondaries_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));\r
            fHistograms->FillHistogram("MC_Pi0_Secondaries_XY", particle->Vx(),particle->Vy());//only fill from one daughter to avoid multiple filling\r
          }\r
          else{\r
@@ -333,7 +349,7 @@ void AliAnalysisTaskGammaConversion::ProcessMCData(){
            fHistograms->FillHistogram("MC_Pi0_Energy", particle->Energy());\r
            fHistograms->FillHistogram("MC_Pi0_R", particle->R());\r
            fHistograms->FillHistogram("MC_Pi0_ZR", particle->Vz(),particle->R());\r
-           fHistograms->FillHistogram("MC_Pi0_OpeningAngle_Gamma", GetMCOpeningAngle(daughter0,daughter1));\r
+           fHistograms->FillHistogram("MC_Pi0_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));\r
            fHistograms->FillHistogram("MC_Pi0_XY", particle->Vx(), particle->Vy());//only fill from one daughter to avoid multiple filling\r
          }\r
        }\r
@@ -345,7 +361,7 @@ void AliAnalysisTaskGammaConversion::ProcessMCData(){
          fHistograms->FillHistogram("MC_Eta_Energy", particle->Energy());\r
          fHistograms->FillHistogram("MC_Eta_R", particle->R());\r
          fHistograms->FillHistogram("MC_Eta_ZR", particle->Vz(),particle->R());\r
-         fHistograms->FillHistogram("MC_Eta_OpeningAngle_Gamma", GetMCOpeningAngle(daughter0,daughter1));\r
+         fHistograms->FillHistogram("MC_Eta_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));\r
          fHistograms->FillHistogram("MC_Eta_XY", particle->Vx(), particle->Vy());//only fill from one daughter to avoid multiple filling\r
        }\r
        \r
@@ -360,9 +376,9 @@ void AliAnalysisTaskGammaConversion::ProcessMCData(){
        fHistograms->FillHistogram("MC_Match_Gamma_Eta", particle->Eta());\r
        fHistograms->FillHistogram("MC_Match_Gamma_Phi",tmpPhi);\r
       }\r
-    }\r
-  }\r
-}\r
+    }// end else if(particle->GetNDaughters() == 2)\r
+  }// end for (Int_t iTracks = 0; iTracks < fStack->GetNtrack(); iTracks++)\r
+} // end ProcessMCData\r
 \r
 void AliAnalysisTaskGammaConversion::ProcessV0s(){\r
   // see header file for documentation\r
@@ -411,8 +427,8 @@ void AliAnalysisTaskGammaConversion::ProcessV0s(){
     fHistograms->FillHistogram(nameESDMappingR, fV0Reader->GetZ(), motherCandidateEta);  \r
 \r
     TString nameESDMappingPhiInR="";\r
-    nameESDMappingPhiInR.Form("ESD_EP_Mapping_Phi_vs_R_R-%02d",rBin);\r
-    fHistograms->FillHistogram(nameESDMappingPhiInR, fV0Reader->GetXYRadius(), fV0Reader->GetMotherCandidatePhi());\r
+    nameESDMappingPhiInR.Form("ESD_EP_Mapping_Phi_R-%02d",rBin);\r
+    fHistograms->FillHistogram(nameESDMappingPhiInR, fV0Reader->GetMotherCandidatePhi());\r
     // end mapping\r
     \r
     fKFReconstructedGammas.push_back(*fV0Reader->GetMotherCandidateKFCombination());\r
@@ -422,13 +438,13 @@ void AliAnalysisTaskGammaConversion::ProcessV0s(){
       if(fV0Reader->HasSameMCMother() == kFALSE){\r
        continue;\r
       }\r
-\r
\r
       TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();\r
       TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();\r
+\r
       if(negativeMC->GetPdgCode()!=11 || positiveMC->GetPdgCode()!=-11){\r
        continue;\r
       }\r
-\r
       if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){\r
        fHistograms->FillHistogram("ESD_Match_Gamma_XY", fV0Reader->GetX(),fV0Reader->GetY());\r
        fHistograms->FillHistogram("ESD_Match_Gamma_OpeningAngle", fV0Reader->GetOpeningAngle());\r
@@ -469,7 +485,7 @@ void AliAnalysisTaskGammaConversion::ProcessV0s(){
        if(fV0Reader->GetNegativeMCParticle()->R() != 0){\r
          resdR = ((fV0Reader->GetXYRadius() - fV0Reader->GetNegativeMCParticle()->R())/fV0Reader->GetNegativeMCParticle()->R())*100;\r
        }\r
-       fHistograms->FillHistogram("Resolutiond_R", fV0Reader->GetNegativeMCParticle()->R(), resdR);\r
+       fHistograms->FillHistogram("Resolution_dR", fV0Reader->GetNegativeMCParticle()->R(), resdR);\r
        fHistograms->FillHistogram("Resolution_MC_R", fV0Reader->GetNegativeMCParticle()->R());\r
        fHistograms->FillHistogram("Resolution_ESD_R", fV0Reader->GetXYRadius());\r
        fHistograms->FillHistogram("Resolution_dR_dPt", resdR, resdPt);\r
@@ -497,8 +513,7 @@ void AliAnalysisTaskGammaConversion::ProcessGammasForNeutralMesonAnalysis(){
       twoGammaCandidate->GetMass(massTwoGammaCandidate,widthTwoGammaCandidate);\r
       if(twoGammaCandidate->GetNDF()>0){\r
        chi2TwoGammaCandidate = twoGammaCandidate->GetChi2()/twoGammaCandidate->GetNDF();\r
-       //      if(chi2TwoGammaCandidate>0 && chi2TwoGammaCandidate<fChi2Cut){//TODO  find this out\r
-       if(chi2TwoGammaCandidate>0 && chi2TwoGammaCandidate<10000){//TODO  find this out see line above\r
+       if(chi2TwoGammaCandidate>0 && chi2TwoGammaCandidate<fV0Reader->GetChi2CutMeson()){\r
 \r
          TVector3 vectorTwoGammaCandidate(twoGammaCandidate->Px(),twoGammaCandidate->Py(),twoGammaCandidate->Pz());\r
 \r
@@ -510,7 +525,7 @@ void AliAnalysisTaskGammaConversion::ProcessGammasForNeutralMesonAnalysis(){
          \r
          Double_t radiusTwoGammaCandidate = TMath::Sqrt(tmpX*tmpX + tmpY*tmpY);\r
 \r
-         fHistograms->FillHistogram("ESD_TwoGammaCombination_OpeningAngleGamma", openingAngleTwoGammaCandidate);\r
+         fHistograms->FillHistogram("ESD_TwoGammaCombination_GammaDaughter_OpeningAngle", openingAngleTwoGammaCandidate);\r
          fHistograms->FillHistogram("ESD_TwoGammaCombination_Energy", twoGammaCandidate->GetE());\r
          fHistograms->FillHistogram("ESD_TwoGammaCombination_Pt", sqrt(twoGammaCandidate->GetPx()*twoGammaCandidate->GetPx()+twoGammaCandidate->GetPy()*twoGammaCandidate->GetPy()));\r
          fHistograms->FillHistogram("ESD_TwoGammaCombination_Eta", vectorTwoGammaCandidate.Eta());\r
@@ -518,14 +533,13 @@ void AliAnalysisTaskGammaConversion::ProcessGammasForNeutralMesonAnalysis(){
          fHistograms->FillHistogram("ESD_TwoGammaCombination_Mass", massTwoGammaCandidate);\r
          fHistograms->FillHistogram("ESD_TwoGammaCombination_R", radiusTwoGammaCandidate);\r
          fHistograms->FillHistogram("ESD_TwoGammaCombination_ZR", tmpY, radiusTwoGammaCandidate);\r
-         fHistograms->FillHistogram("ESD_TwoGammaCombination_XY", tmpX, tmpY);   \r
-         fHistograms->FillHistogram("InvMass_vs_Pt__Spectra",massTwoGammaCandidate ,sqrt(twoGammaCandidate->GetPx()*twoGammaCandidate->GetPx()+twoGammaCandidate->GetPy()*twoGammaCandidate->GetPy()));\r
+         fHistograms->FillHistogram("ESD_TwoGammaCombination_XY", tmpX, tmpY);\r
+         fHistograms->FillHistogram("InvMass_vs_Pt_Spectra",massTwoGammaCandidate ,sqrt(twoGammaCandidate->GetPx()*twoGammaCandidate->GetPx()+twoGammaCandidate->GetPy()*twoGammaCandidate->GetPy()));\r
        }\r
       }\r
       delete twoGammaCandidate;\r
     }\r
   }\r
-\r
 }\r
 \r
 void AliAnalysisTaskGammaConversion::CalculateBackground(){\r
@@ -546,8 +560,7 @@ void AliAnalysisTaskGammaConversion::CalculateBackground(){
       backgroundCandidate->GetMass(massBG,widthBG);\r
       if(backgroundCandidate->GetNDF()>0){\r
        chi2BG = backgroundCandidate->GetChi2()/backgroundCandidate->GetNDF();\r
-       //      if(chi2Pi0>0 && chi2Pi0<fChi2Cut){//TODO  find this out\r
-       if(chi2BG>0 && chi2BG<fV0Reader->GetChi2Cut()){//TODO  find this out see line above\r
+       if(chi2BG>0 && chi2BG<fV0Reader->GetChi2CutMeson()){\r
 \r
          TVector3 vectorBGCandidate(backgroundCandidate->Px(),backgroundCandidate->Py(),backgroundCandidate->Pz());\r
 \r
@@ -568,6 +581,7 @@ void AliAnalysisTaskGammaConversion::CalculateBackground(){
          fHistograms->FillHistogram("ESD_Background_R", radiusBG);\r
          fHistograms->FillHistogram("ESD_Background_ZR", tmpY, radiusBG);\r
          fHistograms->FillHistogram("ESD_Background_XY", tmpX, tmpY);\r
+         fHistograms->FillHistogram("Background_InvMass_vs_Pt_Spectra",massBG,sqrt(backgroundCandidate->GetPx()*backgroundCandidate->GetPx()+backgroundCandidate->GetPy()*backgroundCandidate->GetPy()));\r
        }\r
       }\r
       delete backgroundCandidate;   \r
@@ -593,7 +607,7 @@ void AliAnalysisTaskGammaConversion::UserCreateOutputObjects()
     fOutputContainer = new TList();\r
   }\r
   fHistograms->GetOutputContainer(fOutputContainer);\r
-  fOutputContainer->SetName(GetName()) ;  \r
+  fOutputContainer->SetName(GetName());\r
 }\r
 \r
 Double_t AliAnalysisTaskGammaConversion::GetMCOpeningAngle(TParticle* daughter0, TParticle* daughter1) const{\r
@@ -602,4 +616,3 @@ Double_t AliAnalysisTaskGammaConversion::GetMCOpeningAngle(TParticle* daughter0,
   TVector3 v3D1(daughter1->Px(),daughter1->Py(),daughter1->Pz());\r
   return v3D0.Angle(v3D1);\r
 }\r
-\r