Added TRef to the primary vertex of the AOD event. Allows to retrieve it automaticall...
authordainese <dainese@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 21 Jul 2009 22:28:44 +0000 (22:28 +0000)
committerdainese <dainese@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 21 Jul 2009 22:28:44 +0000 (22:28 +0000)
PWG3/vertexingHF/AliAODRecoDecayHF.cxx
PWG3/vertexingHF/AliAODRecoDecayHF.h
PWG3/vertexingHF/AliAnalysisVertexingHF.cxx

index 335d0187b0d43031bf53c4ed4be7b69da0ab43ee..f00ded99bbf25782d9ed5dc8af9c7e7dc8faff0e 100644 (file)
@@ -31,6 +31,7 @@ ClassImp(AliAODRecoDecayHF)
 AliAODRecoDecayHF::AliAODRecoDecayHF() :
   AliAODRecoDecay(),
   fOwnPrimaryVtx(0x0),
+  fEventPrimaryVtx(),
   fd0err(0x0), 
   fProngID(0x0) 
 {
@@ -44,6 +45,7 @@ AliAODRecoDecayHF::AliAODRecoDecayHF(AliAODVertex *vtx2,Int_t nprongs,Short_t ch
                                     Double_t *d0,Double_t *d0err) :
   AliAODRecoDecay(vtx2,nprongs,charge,px,py,pz,d0),
   fOwnPrimaryVtx(0x0),
+  fEventPrimaryVtx(),
   fd0err(0x0),
   fProngID(0x0) 
 {
@@ -58,6 +60,7 @@ AliAODRecoDecayHF::AliAODRecoDecayHF(AliAODVertex *vtx2,Int_t nprongs,Short_t ch
                                     Double_t *d0,Double_t *d0err) :
   AliAODRecoDecay(vtx2,nprongs,charge,d0),
   fOwnPrimaryVtx(0x0),
+  fEventPrimaryVtx(),
   fd0err(0x0),
   fProngID(0x0) 
 {
@@ -74,6 +77,7 @@ AliAODRecoDecayHF::AliAODRecoDecayHF(Double_t vtx1[3],Double_t vtx2[3],
                                     Double_t *d0) :
   AliAODRecoDecay(0x0,nprongs,charge,px,py,pz,d0),
   fOwnPrimaryVtx(0x0),
+  fEventPrimaryVtx(),
   fd0err(0x0),
   fProngID(0x0) 
 {
@@ -91,6 +95,7 @@ AliAODRecoDecayHF::AliAODRecoDecayHF(Double_t vtx1[3],Double_t vtx2[3],
 AliAODRecoDecayHF::AliAODRecoDecayHF(const AliAODRecoDecayHF &source) :
   AliAODRecoDecay(source),
   fOwnPrimaryVtx(0x0),
+  fEventPrimaryVtx(source.fEventPrimaryVtx),
   fd0err(0x0),
   fProngID(0x0)
 {
@@ -118,6 +123,8 @@ AliAODRecoDecayHF &AliAODRecoDecayHF::operator=(const AliAODRecoDecayHF &source)
 
   AliAODRecoDecay::operator=(source);
 
+  fEventPrimaryVtx = source.fEventPrimaryVtx;
+
   if(source.GetOwnPrimaryVtx()) fOwnPrimaryVtx = new AliAODVertex(*(source.GetOwnPrimaryVtx()));
 
   if(source.GetNProngs()>0) {
index 9fbedf28cad7ce30dbd2bce12dea6fe02416cdb3..dc5181e1d02a858bfe6686898119e2fbdecfad91 100644 (file)
@@ -9,6 +9,7 @@
 // Author: A.Dainese, andrea.dainese@lnl.infn.it
 //***********************************************************
 
+#include <TRef.h>
 #include "AliAODRecoDecay.h"
 
 class AliAODRecoDecayHF : public AliAODRecoDecay {
@@ -31,39 +32,42 @@ class AliAODRecoDecayHF : public AliAODRecoDecay {
    
 
   // primary vertex
-  void SetOwnPrimaryVtx(const AliAODVertex *vtx2) { UnsetOwnPrimaryVtx(); fOwnPrimaryVtx = new AliAODVertex(*vtx2);}
+  void SetPrimaryVtxRef(TObject *vtx) { fEventPrimaryVtx = vtx; }
+  AliAODVertex* GetPrimaryVtxRef() const { return (AliAODVertex*)(fEventPrimaryVtx.GetObject()); }
+  void SetOwnPrimaryVtx(const AliAODVertex *vtx) { UnsetOwnPrimaryVtx(); fOwnPrimaryVtx = new AliAODVertex(*vtx);}
   void CheckOwnPrimaryVtx() const 
     {if(!fOwnPrimaryVtx) printf("fOwnPrimaryVtx not set"); return;}
   AliAODVertex* GetOwnPrimaryVtx() const {return fOwnPrimaryVtx;}
   void GetOwnPrimaryVtx(Double_t vtx[3]) const 
     {CheckOwnPrimaryVtx();fOwnPrimaryVtx->GetPosition(vtx);}
   void UnsetOwnPrimaryVtx() {if(fOwnPrimaryVtx) {delete fOwnPrimaryVtx; fOwnPrimaryVtx=0;} return;}
+  AliAODVertex* GetPrimaryVtx() const { return (GetOwnPrimaryVtx() ? GetOwnPrimaryVtx() : GetPrimaryVtxRef()); }
 
   // kinematics & topology
   Double_t DecayLength() const 
-    {CheckOwnPrimaryVtx();return AliAODRecoDecay::DecayLength(fOwnPrimaryVtx);}
+    { return AliAODRecoDecay::DecayLength(GetPrimaryVtx());}
   Double_t DecayLengthError() const 
-    {CheckOwnPrimaryVtx();return AliAODRecoDecay::DecayLengthError(fOwnPrimaryVtx);}
+    { return AliAODRecoDecay::DecayLengthError(GetPrimaryVtx());}
   Double_t NormalizedDecayLength() const 
-    {CheckOwnPrimaryVtx();return AliAODRecoDecay::NormalizedDecayLength(fOwnPrimaryVtx);}
+    { return AliAODRecoDecay::NormalizedDecayLength(GetPrimaryVtx());}
   Double_t DecayLengthXY() const 
-    {CheckOwnPrimaryVtx();return AliAODRecoDecay::DecayLengthXY(fOwnPrimaryVtx);}
+    { return AliAODRecoDecay::DecayLengthXY(GetPrimaryVtx());}
   Double_t DecayLengthXYError() const 
-    {CheckOwnPrimaryVtx();return AliAODRecoDecay::DecayLengthXYError(fOwnPrimaryVtx);}
+    { return AliAODRecoDecay::DecayLengthXYError(GetPrimaryVtx());}
   Double_t NormalizedDecayLengthXY() const 
-    {CheckOwnPrimaryVtx();return AliAODRecoDecay::NormalizedDecayLengthXY(fOwnPrimaryVtx);}
+    { return AliAODRecoDecay::NormalizedDecayLengthXY(GetPrimaryVtx());}
   Double_t Ct(UInt_t pdg) const 
-    {CheckOwnPrimaryVtx();return AliAODRecoDecay::Ct(pdg,fOwnPrimaryVtx);}
+    { return AliAODRecoDecay::Ct(pdg,GetPrimaryVtx());}
   Double_t CosPointingAngle() const 
-    {CheckOwnPrimaryVtx();return AliAODRecoDecay::CosPointingAngle(fOwnPrimaryVtx);}
+    { return AliAODRecoDecay::CosPointingAngle(GetPrimaryVtx());}
   Double_t CosPointingAngleXY() const 
-    {CheckOwnPrimaryVtx();return AliAODRecoDecay::CosPointingAngleXY(fOwnPrimaryVtx);}
+    { return AliAODRecoDecay::CosPointingAngleXY(GetPrimaryVtx());}
   Double_t ImpParXY() const 
-    {CheckOwnPrimaryVtx();return AliAODRecoDecay::ImpParXY(fOwnPrimaryVtx);}
+    { return AliAODRecoDecay::ImpParXY(GetPrimaryVtx());}
   Double_t QtProngFlightLine(Int_t ip) const 
-    {CheckOwnPrimaryVtx();return AliAODRecoDecay::QtProngFlightLine(ip,fOwnPrimaryVtx);}
+    { return AliAODRecoDecay::QtProngFlightLine(ip,GetPrimaryVtx());}
   Double_t QlProngFlightLine(Int_t ip) const 
-    {CheckOwnPrimaryVtx();return AliAODRecoDecay::QlProngFlightLine(ip,fOwnPrimaryVtx);}
+    { return AliAODRecoDecay::QlProngFlightLine(ip,GetPrimaryVtx());}
 
   // prongs
   Double_t Getd0errProng(Int_t ip) const {return fd0err[ip];}
@@ -78,10 +82,11 @@ class AliAODRecoDecayHF : public AliAODRecoDecay {
  protected:
 
   AliAODVertex *fOwnPrimaryVtx; // primary vertex for this candidate
+  TRef          fEventPrimaryVtx; // ref to primary vertex of the event
   Double_t     *fd0err;  //[fNProngs] error on prongs rphi impact param [cm]
   UShort_t     *fProngID;  //[fNProngs] track ID of daughters
 
-  ClassDef(AliAODRecoDecayHF,2)  // base class for AOD reconstructed 
+  ClassDef(AliAODRecoDecayHF,3)  // base class for AOD reconstructed 
                                  // heavy-flavour decays
 };
 
index c27cc5e04fd20d055bc920be672d32661b3b01e4..7129007c0adeb8db6cd63c2b3cdc5145cadc7d77 100644 (file)
@@ -390,16 +390,19 @@ void AliAnalysisVertexingHF::FindCandidates(AliVEvent *event,
              rd = new(aodD0toKpiRef[iD0toKpi++])AliAODRecoDecayHF2Prong(*io2Prong);
              rd->SetSecondaryVtx(v2Prong);
              v2Prong->SetParent(rd);
+             if(fInputAOD) rd->SetPrimaryVtxRef((AliAODVertex*)event->GetPrimaryVertex());
            }
            if(okJPSI) {
              rd = new(aodJPSItoEleRef[iJPSItoEle++])AliAODRecoDecayHF2Prong(*io2Prong);
              rd->SetSecondaryVtx(v2Prong);
              if(!okD0) v2Prong->SetParent(rd); // it cannot have two mothers ...
+             if(fInputAOD) rd->SetPrimaryVtxRef((AliAODVertex*)event->GetPrimaryVertex());
            }
          } else { // isLikeSign2Prong
            rd = new(aodLikeSign2ProngRef[iLikeSign2Prong++])AliAODRecoDecayHF2Prong(*io2Prong);
            rd->SetSecondaryVtx(v2Prong);
            v2Prong->SetParent(rd);
+           if(fInputAOD) rd->SetPrimaryVtxRef((AliAODVertex*)event->GetPrimaryVertex());
          }
        }
        // D* candidates
@@ -466,6 +469,7 @@ void AliAnalysisVertexingHF::FindCandidates(AliVEvent *event,
                rd = new(aodD0toKpiRef[iD0toKpi++])AliAODRecoDecayHF2Prong(*io2Prong);
                rd->SetSecondaryVtx(v2Prong);
                v2Prong->SetParent(rd);
+               if(fInputAOD) rd->SetPrimaryVtxRef((AliAODVertex*)event->GetPrimaryVertex());
                okD0=kTRUE; // this is done to add it only once
              }
              // add the vertex and the cascade to the AOD
@@ -479,6 +483,7 @@ void AliAnalysisVertexingHF::FindCandidates(AliVEvent *event,
              rc = new(aodDstarRef[iDstar++])AliAODRecoCascadeHF(*ioCascade);
              rc->SetSecondaryVtx(vCasc);
              vCasc->SetParent(rc);
+             if(fInputAOD) rc->SetPrimaryVtxRef((AliAODVertex*)event->GetPrimaryVertex());
            }
            twoTrackArrayCasc->Clear();
            trackPi=0; 
@@ -571,6 +576,7 @@ void AliAnalysisVertexingHF::FindCandidates(AliVEvent *event,
              rd = new(aodLikeSign3ProngRef[iLikeSign3Prong++])AliAODRecoDecayHF3Prong(*io3Prong);
              rd->SetSecondaryVtx(v3Prong);
              v3Prong->SetParent(rd);
+             if(fInputAOD) rd->SetPrimaryVtxRef((AliAODVertex*)event->GetPrimaryVertex());
            }
          }
          if(io3Prong) {delete io3Prong; io3Prong=NULL;} 
@@ -633,6 +639,7 @@ void AliAnalysisVertexingHF::FindCandidates(AliVEvent *event,
              rd = new(aodCharm4ProngRef[i4Prong++])AliAODRecoDecayHF4Prong(*io4Prong);
              rd->SetSecondaryVtx(v4Prong);
              v4Prong->SetParent(rd);
+             if(fInputAOD) rd->SetPrimaryVtxRef((AliAODVertex*)event->GetPrimaryVertex());
            }
 
            if(io4Prong) {delete io4Prong; io4Prong=NULL;} 
@@ -717,6 +724,7 @@ void AliAnalysisVertexingHF::FindCandidates(AliVEvent *event,
              rd = new(aodLikeSign3ProngRef[iLikeSign3Prong++])AliAODRecoDecayHF3Prong(*io3Prong);
              rd->SetSecondaryVtx(v3Prong);
              v3Prong->SetParent(rd);
+             if(fInputAOD) rd->SetPrimaryVtxRef((AliAODVertex*)event->GetPrimaryVertex());
            }
          }
          if(io3Prong) {delete io3Prong; io3Prong=NULL;}