]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG3/vertexingHF/AliAnalysisTaskSEBkgLikeSignJPSI.cxx
Fixes for bug #77230: PWG3 par files
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / AliAnalysisTaskSEBkgLikeSignJPSI.cxx
index c84193dec7ae6fcc84d0303fbce3a5572c5031ee..9e5dccb1729b7e2fbc79aa74b801c3e2a9d03389 100644 (file)
@@ -28,6 +28,8 @@
 #include <TList.h>
 #include <TH1F.h>
 
+#include "AliAnalysisManager.h"
+#include "AliAODHandler.h"
 #include "AliAODEvent.h"
 #include "AliAODVertex.h"
 #include "AliAODTrack.h"
@@ -204,30 +206,46 @@ void AliAnalysisTaskSEBkgLikeSignJPSI::UserExec(Option_t */*option*/)
   
   AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
 
-  // load heavy flavour vertices
-  TClonesArray *arrayVerticesHF =
-    (TClonesArray*)aod->GetList()->FindObject("VerticesHF");
-  if(!arrayVerticesHF) {
-    printf("AliAnalysisTaskSEBkgLikeSignJPSI::UserExec: VerticesHF branch not found!\n");
-    return;
+  TClonesArray *arrayJPSItoEle = 0;
+  TClonesArray *arrayLikeSign = 0;
+
+  if(!aod && AODEvent() && IsStandardAOD()) {
+    // In case there is an AOD handler writing a standard AOD, use the AOD 
+    // event in memory rather than the input (ESD) event.    
+    aod = dynamic_cast<AliAODEvent*> (AODEvent());
+    // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
+    // have to taken from the AOD event hold by the AliAODExtension
+    AliAODHandler* aodHandler = (AliAODHandler*) 
+      ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
+    if(aodHandler->GetExtensions()) {
+      AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
+      AliAODEvent *aodFromExt = ext->GetAOD();
+      // load Jpsi candidates   
+      arrayJPSItoEle=(TClonesArray*)aodFromExt->GetList()->FindObject("JPSItoEle");
+      // load like sign candidates
+      arrayLikeSign=(TClonesArray*)aodFromExt->GetList()->FindObject("LikeSign2Prong");
+    }
+  } else {
+    // load Jpsi candidates                                                   
+    arrayJPSItoEle=(TClonesArray*)aod->GetList()->FindObject("JPSItoEle");
+    // load like sign candidates
+    arrayLikeSign=(TClonesArray*)aod->GetList()->FindObject("LikeSign2Prong");
   }
 
-  // load JPSI->ee candidates                                                   
-  TClonesArray *arrayJPSItoEle =
-    (TClonesArray*)aod->GetList()->FindObject("JPSItoEle");
+
   if(!arrayJPSItoEle) {
     printf("AliAnalysisTaskSEBkgLikeSignJPSI::UserExec: JPSItoEle branch not found!\n");
     return;
   }
-
-  // load like sign candidates
-  TClonesArray *arrayLikeSign =
-    (TClonesArray*)aod->GetList()->FindObject("LikeSign2Prong");
   if(!arrayLikeSign) {
     printf("AliAnalysisTaskSEBkgLikeSignJPSI::UserExec: LikeSign2Prong branch not found!\n");
     return;
   }
 
+  // fix for temporary bug in ESDfilter 
+  // the AODs with null vertex pointer didn't pass the PhysSel
+  if(!aod->GetPrimaryVertex() || TMath::Abs(aod->GetMagneticField())<0.001) return;
+
   // AOD primary vertex
   AliAODVertex *vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
 
@@ -241,7 +259,7 @@ void AliAnalysisTaskSEBkgLikeSignJPSI::UserExec(Option_t */*option*/)
   // loop over Like sign candidates
   Int_t nPosPairs=0,nNegPairs=0;
   Int_t nLikeSign = arrayLikeSign->GetEntriesFast();
-  printf("+++\n+++Number of like sign pairs ---> %d \n+++\n", nLikeSign);
+  if(fDebug>1) printf("+++\n+++Number of like sign pairs ---> %d \n+++\n", nLikeSign);
 
   for(Int_t iLikeSign = 0; iLikeSign < nLikeSign; iLikeSign++) {
     AliAODRecoDecayHF2Prong *d = (AliAODRecoDecayHF2Prong*)arrayLikeSign->UncheckedAt(iLikeSign);
@@ -250,8 +268,9 @@ void AliAnalysisTaskSEBkgLikeSignJPSI::UserExec(Option_t */*option*/)
         d->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
         unsetvtx=kTRUE;
     }
-    Int_t okBtoJPSIls=0;
-    if(d->SelectBtoJPSI(fVHF->GetBtoJPSICuts(),okBtoJPSIls)) {
+    //Int_t okBtoJPSIls=0;
+    //if(d->SelectBtoJPSI(fVHF->GetBtoJPSICuts(),okBtoJPSIls)) {
+    if(d) {
        AliAODTrack *trk0 = (AliAODTrack*)d->GetDaughter(0);
        fHistMassLS->Fill(d->InvMassJPSIee());
        fHistCPtaLS->Fill(d->CosPointingAngle());
@@ -278,15 +297,15 @@ void AliAnalysisTaskSEBkgLikeSignJPSI::UserExec(Option_t */*option*/)
     if(unsetvtx) d->UnsetOwnPrimaryVtx();
   }
 
-  printf("------------ N. of positive pairs in Event ----- %d \n", nPosPairs);
-  printf("------------ N. of negative pairs in Event ----- %d \n", nNegPairs);
+  if(fDebug>1) printf("------------ N. of positive pairs in Event ----- %d \n", nPosPairs);
+  if(fDebug>1) printf("------------ N. of negative pairs in Event ----- %d \n", nNegPairs);
 
   fTotPosPairs += nPosPairs;
   fTotNegPairs += nNegPairs;
 
   // loop over JPSI candidates
   Int_t nBtoJpsiToEle = arrayJPSItoEle->GetEntriesFast();
-  printf("Number of like JPSI -> ee candidates ---> %d \n", nBtoJpsiToEle);
+  if(fDebug>1) printf("Number of like JPSI -> ee candidates ---> %d \n", nBtoJpsiToEle);
 
   for (Int_t iBtoJpsiToEle = 0; iBtoJpsiToEle < nBtoJpsiToEle; iBtoJpsiToEle++) {
     AliAODRecoDecayHF2Prong *d = (AliAODRecoDecayHF2Prong*)arrayJPSItoEle->UncheckedAt(iBtoJpsiToEle);
@@ -295,8 +314,9 @@ void AliAnalysisTaskSEBkgLikeSignJPSI::UserExec(Option_t */*option*/)
       d->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
       unsetvtx=kTRUE;
     }
-    Int_t okBtoJPSI=0;
-    if(d->SelectBtoJPSI(fVHF->GetBtoJPSICuts(),okBtoJPSI)) {
+    ///Int_t okBtoJPSI=0;
+    //if(d->SelectBtoJPSI(fVHF->GetBtoJPSICuts(),okBtoJPSI)) {
+    if(d) {
       fHistMassJPSI->Fill(d->InvMassJPSIee());
       fHistCtsJPSI->Fill(d->CosThetaStarJPSI());
       fHistd0d0JPSI->Fill(1e8*d->Prodd0d0());