Bug fix for aod
authorrbailhac <rbailhac@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 29 May 2012 15:59:57 +0000 (15:59 +0000)
committerrbailhac <rbailhac@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 29 May 2012 15:59:57 +0000 (15:59 +0000)
PWGHF/hfe/AliAnalysisTaskHFEFlow.cxx
PWGHF/hfe/AliAnalysisTaskHFEFlow.h
PWGHF/hfe/AliHFEextraCuts.cxx

index 0064890..410d5ef 100644 (file)
@@ -61,6 +61,7 @@
 #include "AliFlowVector.h"\r
 #include "AliFlowCommonConstants.h"\r
 #include "AliKFParticle.h"\r
+#include "AliKFVertex.h"\r
 \r
 #include "AliHFEcuts.h"\r
 #include "AliHFEpid.h"\r
@@ -102,12 +103,13 @@ AliAnalysisTaskHFEFlow::AliAnalysisTaskHFEFlow() :
   fUseMCReactionPlane(kFALSE),\r
   fMCPID(kFALSE),\r
   fNoPID(kFALSE),\r
-  fChi2OverNDFCut(999),\r
+  fChi2OverNDFCut(3.0),\r
   fMaxdca(3.0),\r
   fMaxopeningtheta(0.02),\r
   fMaxopeningphi(0.1),\r
   fMaxopening3D(0.1),\r
   fMaxInvmass(0.1),\r
+  fSetMassConstraint(kFALSE),\r
   fDebugLevel(0),\r
   fcutsRP(0),\r
   fcutsPOI(0),\r
@@ -193,12 +195,13 @@ AliAnalysisTaskHFEFlow:: AliAnalysisTaskHFEFlow(const char *name) :
   fUseMCReactionPlane(kFALSE),\r
   fMCPID(kFALSE),\r
   fNoPID(kFALSE),\r
-  fChi2OverNDFCut(999),\r
+  fChi2OverNDFCut(3.0),\r
   fMaxdca(3.0),\r
   fMaxopeningtheta(0.02),\r
   fMaxopeningphi(0.1),\r
   fMaxopening3D(0.1),\r
   fMaxInvmass(0.1),\r
+  fSetMassConstraint(kFALSE),\r
   fDebugLevel(0),\r
   fcutsRP(0),\r
   fcutsPOI(0),\r
@@ -309,6 +312,7 @@ AliAnalysisTaskHFEFlow::AliAnalysisTaskHFEFlow(const AliAnalysisTaskHFEFlow &ref
   fMaxopeningphi(ref.fMaxopeningphi),\r
   fMaxopening3D(ref.fMaxopening3D),\r
   fMaxInvmass(ref.fMaxInvmass),\r
+  fSetMassConstraint(ref.fSetMassConstraint),\r
   fDebugLevel(ref.fDebugLevel),\r
   fcutsRP(NULL),\r
   fcutsPOI(NULL),\r
@@ -411,6 +415,7 @@ void AliAnalysisTaskHFEFlow::Copy(TObject &o) const {
   target.fMaxopeningphi = fMaxopeningphi;\r
   target.fMaxopening3D = fMaxopening3D;\r
   target.fMaxInvmass = fMaxInvmass;\r
+  target.fSetMassConstraint =  fSetMassConstraint;\r
   target.fAlgorithmMA = fAlgorithmMA;\r
   target.fCounterPoolBackground = fCounterPoolBackground;\r
   target.fDebugLevel = fDebugLevel;\r
@@ -622,9 +627,9 @@ void AliAnalysisTaskHFEFlow::UserCreateOutputObjects()
   Double_t binLimCharge[nBinsCharge+1];\r
   for(Int_t i=0; i<=nBinsCharge; i++) binLimCharge[i]=(Double_t)minCharge + (maxCharge-minCharge)/nBinsCharge*(Double_t)i ;\r
 \r
-  Int_t nBinsSource = 8;\r
+  Int_t nBinsSource = 10;\r
   Double_t minSource = 0.;\r
-  Double_t maxSource = 8.;\r
+  Double_t maxSource = 10.;\r
   Double_t binLimSource[nBinsSource+1];\r
   for(Int_t i=0; i<=nBinsSource; i++) binLimSource[i]=(Double_t)minSource + (maxSource-minSource)/nBinsSource*(Double_t)i ;\r
 \r
@@ -1782,6 +1787,9 @@ Int_t AliAnalysisTaskHFEFlow::LookAtNonHFE(Int_t iTrack1, AliVTrack *track1, Ali
 \r
   //Magnetic Field\r
   Double_t bfield = vEvent->GetMagneticField();\r
+\r
+  // Get Primary vertex\r
+  const AliVVertex *pVtx = vEvent->GetPrimaryVertex();\r
   \r
   for(Int_t idex = 0; idex < fCounterPoolBackground; idex++) \r
     {\r
@@ -1804,18 +1812,20 @@ Int_t AliAnalysisTaskHFEFlow::LookAtNonHFE(Int_t iTrack1, AliVTrack *track1, Ali
        Int_t source2 = 0;\r
        Int_t indexmother2 = -1;\r
        source2 = FindMother(TMath::Abs(track2->GetLabel()),mcEvent, indexmother2);\r
-       if((indexmother2 == indexmother) && (source == source2)) {\r
-         if(source == kElectronfromconversion) {\r
-           valueangle[2] = kElectronfromconversionboth;\r
-           valuensparseDeltaPhiMaps[4] = kElectronfromconversionboth;\r
-         }\r
-         if(source == kElectronfrompi0) {\r
-           valueangle[2] = kElectronfrompi0both;\r
-           valuensparseDeltaPhiMaps[4] = kElectronfrompi0both;\r
-         }\r
-         if(source == kElectronfrometa) {\r
-           valueangle[2] = kElectronfrometaboth;\r
-           valuensparseDeltaPhiMaps[4] = kElectronfrometaboth;\r
+       if(source2 >=0 ) {\r
+         if((indexmother2 == indexmother) && (source == source2)) {\r
+           if(source == kElectronfromconversion) {\r
+             valueangle[2] = kElectronfromconversionboth;\r
+             valuensparseDeltaPhiMaps[4] = kElectronfromconversionboth;\r
+           }\r
+           if(source == kElectronfrompi0) {\r
+             valueangle[2] = kElectronfrompi0both;\r
+             valuensparseDeltaPhiMaps[4] = kElectronfrompi0both;\r
+           }\r
+           if(source == kElectronfrometa) {\r
+             valueangle[2] = kElectronfrometaboth;\r
+             valuensparseDeltaPhiMaps[4] = kElectronfrometaboth;\r
+           }\r
          }\r
        }\r
       }\r
@@ -1916,25 +1926,36 @@ Int_t AliAnalysisTaskHFEFlow::LookAtNonHFE(Int_t iTrack1, AliVTrack *track1, Ali
          if(fCharge1>0) fPDGtrack1 = -11;\r
          if(fCharge2>0) fPDGtrack2 = -11;\r
          \r
-         AliKFParticle fKFtrack1(*track1, fPDGtrack1);\r
-         AliKFParticle fKFtrack2(*track2, fPDGtrack2);\r
-         AliKFParticle fRecoGamma(fKFtrack1, fKFtrack2);\r
+         AliKFParticle ktrack1(*track1, fPDGtrack1);\r
+         AliKFParticle ktrack2(*track2, fPDGtrack2);\r
+         AliKFParticle recoGamma(ktrack1, ktrack2);\r
          \r
          //Reconstruction Cuts\r
-         if(fRecoGamma.GetNDF()<1) continue;\r
-         Double_t chi2OverNDF = fRecoGamma.GetChi2()/fRecoGamma.GetNDF();\r
+         if(recoGamma.GetNDF()<1) continue;\r
+         Double_t chi2OverNDF = recoGamma.GetChi2()/recoGamma.GetNDF();\r
          if(TMath::Sqrt(TMath::Abs(chi2OverNDF))>fChi2OverNDFCut) continue;\r
          \r
+         // if set mass constraint\r
+         if(fSetMassConstraint && pVtx) {\r
+           AliKFVertex primV(*pVtx);\r
+           primV += recoGamma;\r
+           recoGamma.SetProductionVertex(primV);\r
+           recoGamma.SetMassConstraint(0,0.0001);\r
+         }    \r
+\r
          //Invariant Mass\r
          Double_t imass; \r
          Double_t width;\r
-         fRecoGamma.GetMass(imass,width);\r
+         recoGamma.GetMass(imass,width);\r
          \r
          //Opening Angle (Total Angle)\r
-         Double_t angle = fKFtrack1.GetAngle(fKFtrack2);\r
+         Double_t angle = ktrack1.GetAngle(ktrack2);\r
          valueangle[0] = angle;\r
          if((fCharge1*fCharge2)>0.0) fSameSignAngle->Fill(&valueangle[0]);\r
-         else fOppSignAngle->Fill(&valueangle[0]);       \r
+         else fOppSignAngle->Fill(&valueangle[0]);\r
+\r
+         // Cut\r
+         if(angle > fMaxopening3D) continue;     \r
 \r
          // Invmass\r
          valuensparseDeltaPhiMaps[3] = imass;\r
@@ -1950,7 +1971,7 @@ Int_t AliAnalysisTaskHFEFlow::LookAtNonHFE(Int_t iTrack1, AliVTrack *track1, Ali
        \r
        }\r
     }\r
-\r
+  \r
   if(oppositetaggedphotonic && sametaggedphotonic){\r
     taggedphotonic = 6;\r
   }\r
@@ -1974,6 +1995,12 @@ Int_t AliAnalysisTaskHFEFlow::FindMother(Int_t tr, AliMCEvent *mcEvent, Int_t &i
   //\r
 \r
   if(!mcEvent) return 0;\r
+\r
+  Int_t pdg = CheckPdg(tr,mcEvent);\r
+  if(TMath::Abs(pdg)!= 11) {\r
+    indexmother = -1;\r
+    return kNoElectron;\r
+  }\r
   \r
   indexmother = IsMotherGamma(tr,mcEvent);\r
   if(indexmother > 0) return kElectronfromconversion;\r
@@ -1991,6 +2018,35 @@ Int_t AliAnalysisTaskHFEFlow::FindMother(Int_t tr, AliMCEvent *mcEvent, Int_t &i
 \r
 }\r
 //____________________________________________________________________________________________________________\r
+Int_t AliAnalysisTaskHFEFlow::CheckPdg(Int_t tr, AliMCEvent* mcEvent) {\r
+\r
+  //\r
+  // Return the pdg of the particle\r
+  //\r
+\r
+  Int_t pdgcode = -1;\r
+\r
+  if(tr < 0) return pdgcode;\r
+  AliVParticle *mctrack = mcEvent->GetTrack(tr);\r
\r
+  \r
+  if(mctrack->IsA() == AliMCParticle::Class()) {\r
+    AliMCParticle *mctrackesd = NULL;\r
+    if(!(mctrackesd = dynamic_cast<AliMCParticle *>(mcEvent->GetTrack(TMath::Abs(tr))))) return pdgcode;\r
+    pdgcode = mctrackesd->PdgCode();\r
+  }\r
+\r
+  if(mctrack->IsA() == AliAODMCParticle::Class()) {\r
+    AliAODMCParticle *mctrackaod = NULL;\r
+    if(!(mctrackaod = dynamic_cast<AliAODMCParticle *>(mcEvent->GetTrack(TMath::Abs(tr))))) return pdgcode;\r
+    pdgcode = mctrackaod->GetPdgCode();\r
+  }\r
+  \r
+  return pdgcode;\r
+\r
\r
+}\r
+//____________________________________________________________________________________________________________\r
 Int_t AliAnalysisTaskHFEFlow::IsMotherGamma(Int_t tr, AliMCEvent* mcEvent) {\r
 \r
   //\r
index 61f67f4..e7e5b63 100644 (file)
@@ -58,7 +58,8 @@ public:
     kElectronfromB = 5,\r
     kElectronfrometa = 6,\r
     kElectronfrometaboth = 7,\r
-    kElectronfromother = 8\r
+    kElectronfromother = 8,\r
+    kNoElectron = 9\r
   } FlowSource_t;\r
   \r
   typedef enum{\r
@@ -127,6 +128,7 @@ public:
   void  SetMaxopeningtheta(Double_t maxOpeningtheta) { fMaxopeningtheta = maxOpeningtheta; };\r
   void  SetMaxopeningphi(Double_t maxOpeningphi) { fMaxopeningphi = maxOpeningphi; };\r
   void  SetAlgorithmMA(Bool_t algorithmMA) { fAlgorithmMA = algorithmMA; };\r
+  void  SetMassConstraint(Bool_t massConstraint) { fSetMassConstraint = massConstraint; };\r
 \r
   Int_t    LookAtNonHFE(Int_t iTrack1, AliVTrack *track1, AliVEvent *fESD, AliMCEvent *mcEvent,Int_t binct,Double_t deltaphi,Int_t source,Int_t indexmother);\r
   \r
@@ -169,6 +171,7 @@ private:
   Double_t  fMaxopeningphi;    // Limit opening angle in phi\r
   Double_t  fMaxopening3D;     // Limit opening 3D\r
   Double_t  fMaxInvmass;       // Limit invariant mass\r
+  Bool_t    fSetMassConstraint; // Set mass constraint\r
   \r
 \r
   Int_t     fDebugLevel; // Debug Level  \r
@@ -262,6 +265,7 @@ private:
   THnSparseF *fSameSignAngle;        // ! Opening Angles\r
 \r
   Int_t FindMother(Int_t tr, AliMCEvent *mcEvent, Int_t &indexmother);\r
+  Int_t CheckPdg(Int_t tr, AliMCEvent* mcEvent);\r
   Int_t IsMotherGamma(Int_t tr, AliMCEvent* mcEvent);\r
   Int_t IsMotherPi0(Int_t tr, AliMCEvent* mcEvent);\r
   Int_t IsMotherC(Int_t tr, AliMCEvent* mcEvent);\r
index 17fda31..84d67d5 100644 (file)
@@ -199,7 +199,8 @@ Bool_t AliHFEextraCuts::CheckRecCuts(AliVTrack *track){
   ULong64_t survivedCut = 0;   // Bitmap for cuts which are passed by the track, later to be compared with fRequirements
   if(IsQAOn()) FillQAhistosRec(track, kBeforeCuts);
   // Apply cuts
-  Float_t impactR, impactZ;
+  Float_t impactR = -999.;
+  Float_t impactZ = -999.;
   Double_t hfeimpactR, hfeimpactnsigmaR;
   Double_t hfeimpactRcut, hfeimpactnsigmaRcut;
   Double_t maximpactRcut; 
@@ -727,7 +728,7 @@ void AliHFEextraCuts::GetImpactParameters(AliVTrack *track, Float_t &radial, Flo
       if(xyz[0]==-999. || xyz[1]==-999. ||  xyz[2]==-999.){
        if(!fEvent) {
          z = xyz[2];
-         radial = TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]+xyz[1]);
+         radial = TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]);
          //printf("No event\n");
        }
        else {
@@ -746,7 +747,7 @@ void AliHFEextraCuts::GetImpactParameters(AliVTrack *track, Float_t &radial, Flo
       }
       else {
        z = xyz[2];
-       radial = TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]+xyz[1]);
+       radial = TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]);
       }
     }
   }