]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG3/hfe/AliHFEpriVtx.cxx
Major update of the HFE package (comments inside the code
[u/mrichter/AliRoot.git] / PWG3 / hfe / AliHFEpriVtx.cxx
index 286881e9b39f864922d6956887fb28c5f720d49f..71870201581ad3f0c96a26cb88572b2431e12efd 100644 (file)
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
-/**************************************************************************
- *                                                                        *
- *  QA class of primary vertex study for Heavy Flavor electrons           *
- *                                                                        *
- * Authors:                                                               *
- *   MinJung Kweon <minjung@physi.uni-heidelberg.de>                      *
- *                                                                        *
- **************************************************************************/
+//
+// QA class of primary vertex study for Heavy Flavor electrons
+// this has functionality to reject electrons from primary vertex
+// and check primary vertex characteristics
+//  
+// Authors:
+//   MinJung Kweon <minjung@physi.uni-heidelberg.de>
+//
 
 
-#include <iostream>
 #include <TH2F.h>
-#include <TH3F.h>
-#include "TLorentzVector.h"
-#include <TNtuple.h>
 #include <TParticle.h>
 
 #include "AliESDEvent.h"
 #include <AliESDtrack.h>
-#include <AliStack.h>
+#include <AliMCEvent.h>
 
 #include <AliLog.h>
 #include <AliKFParticle.h>
@@ -45,13 +41,17 @@ ClassImp(AliHFEpriVtx)
 //_______________________________________________________________________________________________
 AliHFEpriVtx::AliHFEpriVtx():
         fESD1(0x0)
-        ,fStack(0x0)
+        ,fMCEvent(0x0)
         ,fNtrackswoPid(0)
         ,fHNtrackswoPid(0x0)
         ,fNESDprimVtxContributor(0x0)
         ,fNESDprimVtxIndices(0x0)
         ,fDiffDCAvsPt(0x0)
         ,fDiffDCAvsNt(0x0)
+        ,fNsectrk2prim(0)
+        ,fPVxRe(-999.)
+        ,fPVyRe(-999.)
+        ,fPVzRe(-999.)
 { 
         //
         // Default constructor
@@ -65,13 +65,17 @@ AliHFEpriVtx::AliHFEpriVtx():
 AliHFEpriVtx::AliHFEpriVtx(const AliHFEpriVtx &p):
          TObject(p)
         ,fESD1(0x0)
-        ,fStack(0x0)
+        ,fMCEvent(0x0)
         ,fNtrackswoPid(p.fNtrackswoPid)
         ,fHNtrackswoPid(0x0)
         ,fNESDprimVtxContributor(0x0)
         ,fNESDprimVtxIndices(0x0)
         ,fDiffDCAvsPt(0x0)
         ,fDiffDCAvsNt(0x0)
+        ,fNsectrk2prim(p.fNsectrk2prim)
+        ,fPVxRe(p.fPVxRe)
+        ,fPVyRe(p.fPVyRe)
+        ,fPVzRe(p.fPVzRe)
 {
         //
         // Copy constructor
@@ -141,9 +145,9 @@ void AliHFEpriVtx::CreateHistograms(TString hnopt)
            hname=hnopt+"nPrimVtxContributor_"+fkSourceLabel[isource];
            fPrimVtx[isource].fNprimVtxContributor = new TH1F(hname,hname,100,0,100);
            hname=hnopt+"PtElec_"+fkSourceLabel[isource];
-           fPrimVtx[isource].fPtElec = new TH1F(hname,hname,150,0,30);
+           fPrimVtx[isource].fPtElec = new TH1F(hname,hname,250,0,50);
            hname=hnopt+"PtElecContributor_"+fkSourceLabel[isource];
-           fPrimVtx[isource].fPtElecContributor = new TH1F(hname,hname,150,0,30);
+           fPrimVtx[isource].fPtElecContributor = new TH1F(hname,hname,250,0,50);
 
         }
 
@@ -154,7 +158,7 @@ void AliHFEpriVtx::CreateHistograms(TString hnopt)
         hname=hnopt+"nESDprimVtxIndices";
         fNESDprimVtxIndices= new TH1I(hname,hname,100,0,100);
         hname=hnopt+"diffDCAvsPt";
-        fDiffDCAvsPt = new TH2F(hname,hname,150,0,30,500,0,1);
+        fDiffDCAvsPt = new TH2F(hname,hname,250,0,50,500,0,1);
         hname=hnopt+"diffDCAvsNt";
         fDiffDCAvsNt = new TH2F(hname,hname,100,0,100,500,0,1);
 
@@ -191,14 +195,16 @@ void AliHFEpriVtx::FillNtracks()
 }
 
 //_______________________________________________________________________________________________
-Int_t AliHFEpriVtx::GetMCPID(AliESDtrack *track) 
+Int_t AliHFEpriVtx::GetMCPID(AliESDtrack const *track)
 {
         //
         // get MC pid
         //
 
-        Int_t label = TMath::Abs(track->GetLabel());
-        TParticle* mcpart = fStack->Particle(label);
+       AliMCParticle *mctrack = NULL;
+       if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(track->GetLabel()))))) return 0; 
+       TParticle *mcpart = mctrack->Particle();
+
         if ( !mcpart ) return 0;
         Int_t pdgCode = mcpart->GetPdgCode();
 
@@ -230,8 +236,15 @@ void AliHFEpriVtx::CountPriVxtElecContributor(AliESDtrack *ESDelectron, Int_t so
         // get track id of our selected electron
         Int_t elecTrkID = ESDelectron->GetID();
 
-        Int_t label = TMath::Abs(ESDelectron->GetLabel());
-        TParticle* mcpart = fStack->Particle(label);
+       AliMCParticle *mctrack = NULL;
+       if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(ESDelectron->GetLabel()))))) return; 
+       TParticle *mcpart = mctrack->Particle();
+
+
+        if(!mcpart){
+          AliDebug(1, "no mc particle, return\n");
+          return;
+        }
 
         AliKFParticle::SetField(fESD1->GetMagneticField());
         AliKFParticle kfElectron(*ESDelectron,11);
@@ -286,3 +299,117 @@ void AliHFEpriVtx::FillNprimVtxContributor() const
         }
 
 }
+
+//_______________________________________________________________________________________________
+Double_t AliHFEpriVtx::GetDistanceFromRecalVertexXY(AliESDtrack * const ESDelectron) 
+{
+        //
+        // return recalculated DCA after removing input track from the primary vertex
+        //
+
+        // get track id of our selected electron
+        Int_t elecTrkID = ESDelectron->GetID();
+
+        AliKFParticle::SetField(fESD1->GetMagneticField());
+        AliKFParticle kfElectron(*ESDelectron,11);
+        // prepare kfprimary vertex
+        AliKFVertex kfESDprimary;
+
+        // Reconstructed Primary Vertex (with ESD tracks)
+        const AliESDVertex *primvtx = fESD1->GetPrimaryVertex();
+        Int_t n=primvtx->GetNIndices();
+
+        if (n>0 && primvtx->GetStatus()){
+
+                kfESDprimary = AliKFVertex(*primvtx);
+                UShort_t *priIndex = primvtx->GetIndices();
+
+                for (Int_t i=0;i<n;i++){
+
+                        Int_t idx = Int_t(priIndex[i]);
+                        if (idx == elecTrkID){
+                                kfESDprimary -= kfElectron;
+                                Double_t dcaAFrmElec = kfElectron.GetDistanceFromVertexXY(kfESDprimary);
+
+                                return dcaAFrmElec;
+                        }
+                } 
+        }  
+             return -1;
+
+}
+
+void AliHFEpriVtx::RecalcPrimvtx(Int_t nkftrk, const Int_t * const trkid, const AliKFParticle * const kftrk)
+{
+        //
+        // recalculate primary vertex after removing the input track
+        //
+
+        const AliESDVertex *primvtx = fESD1->GetPrimaryVertex();
+
+        AliKFVertex kfESDprimary;
+        Int_t n = primvtx->GetNIndices();
+        fNsectrk2prim = 0;
+        fPVxRe = -999.;
+        fPVyRe = -999.;
+        fPVyRe = -999.;
+
+        if (n>0 && primvtx->GetStatus()){
+          kfESDprimary = AliKFVertex(*primvtx);
+          UShort_t *priIndex = primvtx->GetIndices();
+          for (Int_t j=0; j<nkftrk; j++){
+            for (Int_t i=0;i<n;i++){
+              Int_t idx = Int_t(priIndex[i]);
+              if (idx == trkid[j]){
+                kfESDprimary -= kftrk[j];
+                fNsectrk2prim++;
+              }
+            }
+          }
+        }
+
+        fPVxRe = kfESDprimary.GetX();
+        fPVyRe = kfESDprimary.GetY();
+        fPVzRe = kfESDprimary.GetZ();
+
+}
+
+
+//_______________________________________________________________________________________________
+void AliHFEpriVtx::RecalcPrimvtx(AliESDtrack * const ESDelectron)
+{
+        //
+        // recalculate primary vertex after removing the input track
+        //
+
+        // get track id of our selected electron
+        Int_t elecTrkID = ESDelectron->GetID();
+
+        AliKFParticle::SetField(fESD1->GetMagneticField());
+        AliKFParticle kfElectron(*ESDelectron,11);
+
+        const AliESDVertex *primvtx = fESD1->GetPrimaryVertex();
+
+        AliKFVertex kfESDprimary;
+        Int_t n = primvtx->GetNIndices();
+        fPVxRe = -999.;
+        fPVyRe = -999.;
+        fPVyRe = -999.;
+        
+        if (n>0 && primvtx->GetStatus()){
+          kfESDprimary = AliKFVertex(*primvtx);
+          UShort_t *priIndex = primvtx->GetIndices();
+          for (Int_t i=0;i<n;i++){
+            Int_t idx = Int_t(priIndex[i]);
+            if (idx == elecTrkID){
+              kfESDprimary -= kfElectron;
+            }
+          }
+        }     
+        
+        fPVxRe = kfESDprimary.GetX();
+        fPVyRe = kfESDprimary.GetY();
+        fPVzRe = kfESDprimary.GetZ();
+
+}