]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSVertexerZ.cxx
Updated list of classes
[u/mrichter/AliRoot.git] / ITS / AliITSVertexerZ.cxx
index 8e236c93fe2b1d18ac0f9587d3d9b3df66cc1668..27fcad25bdc29b2a1a7f802dfde484e551cb7f38 100644 (file)
@@ -20,8 +20,8 @@
 #include<TTree.h>
 #include "AliESDVertex.h"
 #include "AliITSgeomTGeo.h"
-#include "AliITSDetTypeRec.h"
 #include "AliITSRecPoint.h"
+#include "AliITSRecPointContainer.h"
 #include "AliITSZPoint.h"
 
 /////////////////////////////////////////////////////////////////
@@ -106,7 +106,7 @@ AliITSVertexerZ::~AliITSVertexerZ() {
 void AliITSVertexerZ::ConfigIterations(Int_t noiter,Float_t *ptr){
   // configure the iterative procedure to gain efficiency for
   // pp events with very low multiplicity
-  Float_t defaults[5]={0.05,0.1,0.2,0.3,0.5};
+  Float_t defaults[5]={0.02,0.05,0.1,0.2,0.3};
   fMaxIter=noiter;
   if(noiter>5){
     Error("ConfigIterations","Maximum number of iterations is 5\n");
@@ -188,12 +188,7 @@ AliESDVertex* AliITSVertexerZ::FindVertexForCurrentEvent(TTree *itsClusterTree){
 void AliITSVertexerZ::VertexZFinder(TTree *itsClusterTree){
   // Defines the AliESDVertex for the current event
   fCurrentVertex = 0;
-  fIsPileup=kFALSE;
-  fNTrpuv=-2;     
-  fZpuv=-99999.;
-
-  TTree *tR = itsClusterTree;
-  fDetTypeRec->SetTreeAddressR(tR);
+  ResetVertex();
   TClonesArray *itsRec  = 0;
   // lc1 and gc1 are local and global coordinates for layer 1
   Float_t lc1[3]; for(Int_t ii=0; ii<3; ii++) lc1[ii]=0.;
@@ -201,27 +196,22 @@ void AliITSVertexerZ::VertexZFinder(TTree *itsClusterTree){
   // lc2 and gc2 are local and global coordinates for layer 2
   Float_t lc2[3]; for(Int_t ii=0; ii<3; ii++) lc2[ii]=0.;
   Float_t gc2[3]; for(Int_t ii=0; ii<3; ii++) gc2[ii]=0.;
-
-  itsRec = fDetTypeRec->RecPoints();
-  TBranch *branch;
-  branch = tR->GetBranch("ITSRecPoints");
+  AliITSRecPointContainer* rpcont=AliITSRecPointContainer::Instance();
+  itsRec=rpcont->FetchClusters(0,itsClusterTree);
+  if(!rpcont->IsSPDActive()){
+    AliWarning("Null pointer for RecPoints branch, vertex not calculated");
+    ResetHistograms();
+    fCurrentVertex = new AliESDVertex(0.,5.3,-2);
+    return;
+  }
 
   Int_t nrpL1 = 0;
   Int_t nrpL2 = 0;
+  nrpL1=rpcont->GetNClustersInLayerFast(1);
+  nrpL2=rpcont->GetNClustersInLayerFast(2);
 
-  // By default fFirstL1=0 and fLastL1=79
-  for(Int_t module= fFirstL1; module<=fLastL1;module++){
-    branch->GetEvent(module);
-    nrpL1+= itsRec->GetEntries();
-    fDetTypeRec->ResetRecPoints();
-  }
-  //By default fFirstL2=80 and fLastL2=239
-  for(Int_t module= fFirstL2; module<=fLastL2;module++){
-    branch->GetEvent(module);
-    nrpL2+= itsRec->GetEntries();
-    fDetTypeRec->ResetRecPoints();
-  }
   if(nrpL1 == 0 || nrpL2 == 0){
+    AliDebug(1,Form("No RecPoints in at least one SPD layer (%d %d)",nrpL1,nrpL2));
     ResetHistograms();
     fCurrentVertex = new AliESDVertex(0.,5.3,-2);
     return;
@@ -251,23 +241,10 @@ void AliITSVertexerZ::VertexZFinder(TTree *itsClusterTree){
   for(Int_t modul1= fFirstL1; modul1<=fLastL1;modul1++){   // Loop on modules of layer 1
     if(!fUseModule[modul1]) continue;
     UShort_t ladder=int(modul1/4)+1;  // ladders are numbered starting from 1
-    branch->GetEvent(modul1);
-    Int_t nrecp1 = itsRec->GetEntries();
-    static TClonesArray prpl1("AliITSRecPoint",nrecp1);
-    prpl1.SetOwner();
-    for(Int_t j=0;j<nrecp1;j++){
-      AliITSRecPoint *recp = (AliITSRecPoint*)itsRec->At(j);
-      new(prpl1[j])AliITSRecPoint(*recp);
-    }
-    fDetTypeRec->ResetRecPoints();
+    TClonesArray *prpl1=rpcont->UncheckedGetClusters(modul1);
+    Int_t nrecp1 = prpl1->GetEntries();
     for(Int_t j1=0;j1<nrecp1;j1++){
-      AliITSRecPoint *recp = (AliITSRecPoint*)prpl1.At(j1);
-      /*
-      lc1[0]=recp->GetDetLocalX();
-      lc1[2]=recp->GetDetLocalZ();
-      geom->LtoG(modul1,lc1,gc1);
-      // Global coordinates of this recpoints
-      */
+      AliITSRecPoint *recp = (AliITSRecPoint*)prpl1->At(j1);
       recp->GetGlobalXYZ(gc1);
       gc1[0]-=GetNominalPos()[0]; // Possible beam offset in the bending plane
       gc1[1]-=GetNominalPos()[1]; //   "               "
@@ -282,15 +259,10 @@ void AliITSVertexerZ::VertexZFinder(TTree *itsClusterTree){
          if(ladmod>AliITSgeomTGeo::GetNLadders(2)) ladmod=ladmod-AliITSgeomTGeo::GetNLadders(2);
          Int_t modul2=AliITSgeomTGeo::GetModuleIndex(2,ladmod,k+1);
          if(!fUseModule[modul2]) continue;
-         branch->GetEvent(modul2);
+         itsRec=rpcont->UncheckedGetClusters(modul2);
          Int_t nrecp2 = itsRec->GetEntries();
          for(Int_t j2=0;j2<nrecp2;j2++){
            recp = (AliITSRecPoint*)itsRec->At(j2);
-           /*
-           lc2[0]=recp->GetDetLocalX();
-           lc2[2]=recp->GetDetLocalZ();
-           geom->LtoG(modul2,lc2,gc2);
-           */
            recp->GetGlobalXYZ(gc2);
            gc2[0]-=GetNominalPos()[0];
            gc2[1]-=GetNominalPos()[1];
@@ -315,11 +287,9 @@ void AliITSVertexerZ::VertexZFinder(TTree *itsClusterTree){
              fZCombc->Fill(zr0);
            }
          }
-         fDetTypeRec->ResetRecPoints();
        }
       }
     }
-    prpl1.Clear(); 
   }
 
   points.Sort();
@@ -339,11 +309,12 @@ void AliITSVertexerZ::VertexZFinder(TTree *itsClusterTree){
   if(hc->GetBinContent(hc->GetMaximumBin())<3)hc->Rebin(4);
   Int_t binmin,binmax;
   Int_t nPeaks=GetPeakRegion(hc,binmin,binmax);   
-  if(nPeaks==2)AliWarning("2 peaks found");
+  if(nPeaks==2)AliDebug(2,"2 peaks found");
   Float_t zm =0.;
   Float_t ezm =0.;
   Float_t lim1 = hc->GetBinLowEdge(binmin);
   Float_t lim2 = hc->GetBinLowEdge(binmax)+hc->GetBinWidth(binmax);
+  Float_t widthSR=lim2-lim1;
 
   if(nPeaks ==1 && (lim2-lim1)<fWindowWidth){
     Float_t c=(lim1+lim2)/2.;
@@ -377,18 +348,31 @@ void AliITSVertexerZ::VertexZFinder(TTree *itsClusterTree){
     }
     niter++;
   } while(niter<10 && TMath::Abs((zm-lim1)-(lim2-zm))>fTolerance);
+  if(nPeaks==2) ezm=widthSR;
   fCurrentVertex = new AliESDVertex(zm,ezm,ncontr);
-  fCurrentVertex->SetTitle("vertexer: B");
+  fCurrentVertex->SetTitle("vertexer: Z");
+  fCurrentVertex->SetDispersion(fDiffPhiMax);
+  fNoVertices=1;
   points.Clear();
   if(ncontr>fMinTrackletsForPilup){ 
     Float_t secPeakPos;
     Int_t ncontr2=FindSecondPeak(fZCombc,binmin,binmax,secPeakPos);
     if(ncontr2>=fMinTrackletsForPilup){ 
       fIsPileup=kTRUE;
+      fNoVertices=2;
       fZpuv=secPeakPos;
       fNTrpuv=ncontr2;
+      AliESDVertex secondVert(secPeakPos,0.1,ncontr2);
+      fVertArray = new AliESDVertex[2];
+      fVertArray[0]=(*fCurrentVertex);
+      fVertArray[1]=secondVert;
     }
   }
+  if(fNoVertices==1){
+    fVertArray = new AliESDVertex[1];
+    fVertArray[0]=(*fCurrentVertex);     
+  }
+  
   ResetHistograms();
   return;
 }