]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSVertexerCosmics.cxx
Adding some further mother volumes to speed-up the overlap checking and particle...
[u/mrichter/AliRoot.git] / ITS / AliITSVertexerCosmics.cxx
index f238a4b71730871ebca9de1de5fcfea5c7458f8d..d118843a82e731fc99438bfee85fd048b2d3fad1 100644 (file)
  **************************************************************************/
 
 #include <TClonesArray.h>
+#include <TTree.h>
 #include "AliLog.h"
 #include "AliESDVertex.h"
-#include "AliRunLoader.h"
-#include "AliITSLoader.h"
 #include "AliITSgeomTGeo.h"
 #include "AliITSRecPoint.h"
 #include "AliITSReconstructor.h"
@@ -64,38 +63,33 @@ fMinDist2Vtxs(0)
   SetFirstLastModules(3,324,499);
   SetFirstLastModules(4,500,1247);
   SetFirstLastModules(5,1248,2197);
+  /*
   SetMaxVtxRadius(0,3.5);
   SetMaxVtxRadius(1,6.5);
   SetMaxVtxRadius(2,14.5);
   SetMaxVtxRadius(3,23.5);
   SetMaxVtxRadius(4,37.5);
   SetMaxVtxRadius(5,42.5);
-  /*
+  */  
   SetMaxVtxRadius(0,5.5);
   SetMaxVtxRadius(1,8.5);
   SetMaxVtxRadius(2,18.5);
   SetMaxVtxRadius(3,28.5);
   SetMaxVtxRadius(4,39.5);
   SetMaxVtxRadius(5,48.5);
-  */
+  
   SetMaxDistOnOuterLayer();
   SetMinDist2Vtxs();
 }
 //--------------------------------------------------------------------------
-AliESDVertex* AliITSVertexerCosmics::FindVertexForCurrentEvent(Int_t evnumber
+AliESDVertex* AliITSVertexerCosmics::FindVertexForCurrentEvent(TTree *itsClusterTree
 {
   // Defines the AliESDVertex for the current event
 
   fCurrentVertex = 0;
-  AliRunLoader *rl =AliRunLoader::GetRunLoader();
-  AliITSLoader* itsLoader = (AliITSLoader*)rl->GetLoader("ITSLoader");
-  itsLoader->LoadRecPoints();
-  rl->GetEvent(evnumber);
-
-  TTree *rpTree = itsLoader->TreeR();
 
   TClonesArray *recpoints=new TClonesArray("AliITSRecPoint",10000);
-  rpTree->SetBranchAddress("ITSRecPoints",&recpoints);
+  itsClusterTree->SetBranchAddress("ITSRecPoints",&recpoints);
 
   Int_t lay,lad,det; 
 
@@ -106,19 +100,21 @@ AliESDVertex* AliITSVertexerCosmics::FindVertexForCurrentEvent(Int_t evnumber)
   // Search for innermost layer with at least two clusters 
   // on two different modules
   Int_t ilayer=0,ilayer2=0;
-  while(ilayer<6) {
+  Int_t nHitModulesSPDinner=0;
+  while(ilayer<AliITSgeomTGeo::GetNLayers()) {
     if(AliITSReconstructor::GetRecoParam()->GetLayersToSkip(ilayer)) {
       ilayer++;
       continue;
     }
     Int_t nHitModules=0;
     for(Int_t imodule=fFirst[ilayer]; imodule<=fLast[ilayer]; imodule++) {
-      rpTree->GetEvent(imodule);
+      itsClusterTree->GetEvent(imodule);
       AliITSgeomTGeo::GetModuleId(imodule,lay,lad,det);
       lay -= 1;  // AliITSgeomTGeo gives layer from 1 to 6, we want 0 to 5
       if(lay!=ilayer) AliFatal("Layer mismatch!");
       if(recpoints->GetEntriesFast()>0) nHitModules++;
     }
+    if(ilayer==0) nHitModulesSPDinner=nHitModules;
     if(nHitModules>=2) break;
     ilayer++;
   }
@@ -129,12 +125,13 @@ AliESDVertex* AliITSVertexerCosmics::FindVertexForCurrentEvent(Int_t evnumber)
     ilayer2++;
   }
 
-  //if(ilayer==1 && ilayer2>5 && !AliITSReconstructor::GetRecoParam()->GetLayersToSkip(0)) {ilayer=0; ilayer2=1;}
+  // try tracklet on SPD2 and point on SPD1
+  if(ilayer==1 && !AliITSReconstructor::GetRecoParam()->GetLayersToSkip(0) &&
+     nHitModulesSPDinner>0) { ilayer=0; ilayer2=1; }
 
   if(ilayer>4 || ilayer2>5) {
     AliWarning("Not enough clusters");
     delete recpoints;
-    itsLoader->UnloadRecPoints();
     fCurrentVertex = new AliESDVertex(pos,err,"cosmics");
     fCurrentVertex->SetTitle("cosmics fake vertex (failed)");
     fCurrentVertex->SetNContributors(ncontributors);
@@ -163,7 +160,7 @@ AliESDVertex* AliITSVertexerCosmics::FindVertexForCurrentEvent(Int_t evnumber)
 
   // Collect clusters in the selected layer and the outer one
   for(Int_t imodule=fFirst[ilayer]; imodule<=fLast[ilayer2]; imodule++) {
-    rpTree->GetEvent(imodule);
+    itsClusterTree->GetEvent(imodule);
     AliITSgeomTGeo::GetModuleId(imodule,lay,lad,det);
     lay -= 1; // AliITSgeomTGeo gives layer from 1 to 6, we want 0 to 5
     nRecPoints=recpoints->GetEntriesFast();
@@ -199,7 +196,6 @@ AliESDVertex* AliITSVertexerCosmics::FindVertexForCurrentEvent(Int_t evnumber)
        //AliFatal("More than arrSize clusters per layer");
        AliWarning("Too many clusters per layer");
        delete recpoints;
-       itsLoader->UnloadRecPoints();
        fCurrentVertex = new AliESDVertex(pos,err,"cosmics");
        fCurrentVertex->SetTitle("cosmics fake vertex (failed)");
        fCurrentVertex->SetNContributors(ncontributors);
@@ -212,7 +208,7 @@ AliESDVertex* AliITSVertexerCosmics::FindVertexForCurrentEvent(Int_t evnumber)
   Int_t i1InnLay,i2InnLay,iOutLay;
 
   // build fake vertices
-  printf("Building tracklets on layer %d\n",ilayer);
+  //printf("Building tracklets on layer %d\n",ilayer);
 
   // InnLay - first cluster
   for(i1InnLay=0; i1InnLay<nclInnLayStored; i1InnLay++) { 
@@ -231,11 +227,12 @@ AliESDVertex* AliITSVertexerCosmics::FindVertexForCurrentEvent(Int_t evnumber)
        p3[0]=xclOutLay[iOutLay]; 
        p3[1]=yclOutLay[iOutLay]; 
        p3[2]=zclOutLay[iOutLay];
-       //printf(" %f\n",innLayline.GetDistFromPoint(p3));
+       //printf("(%f,%f) (%f,%f)     (%f,%f) %f\n",p1[0],p1[1],p2[0],p2[1],p3[0],p3[1],innLayline.GetDistFromPoint(p3));
        matchOutLayValue=innLayline.GetDistFromPoint(p3);
        distxyInnLay = (p1[0]-p2[0])*(p1[0]-p2[0])+(p1[1]-p2[1])*(p1[1]-p2[1]);
        if(matchOutLayValue<fMaxDistOnOuterLayer &&
           distxyInnLay>distxyInnLayBest) { 
+         //printf("found\n");
          distxyInnLayBest=distxyInnLay;
          i1InnLayBest=i1InnLay;
          i2InnLayBest=i2InnLay;
@@ -258,19 +255,9 @@ AliESDVertex* AliITSVertexerCosmics::FindVertexForCurrentEvent(Int_t evnumber)
       err[1]=TMath::Sqrt(0.25*(e2yclInnLay[i1InnLayBest]+e2yclInnLay[i2InnLayBest])); 
       err[2]=TMath::Sqrt(0.25*(e2zclInnLay[i1InnLayBest]+e2zclInnLay[i2InnLayBest]));
     }
-    /*
-    fCurrentVertex = new AliESDVertex(pos,err,"cosmics");
-    fCurrentVertex->SetTitle("cosmics fake vertex");
-    fCurrentVertex->SetNContributors(ncontributors);
-    delete recpoints;
-    itsLoader->UnloadRecPoints();
-    return fCurrentVertex;
-    */
-  }
 
-  /*
-  if(i1InnLayBest==-1 && i2InnLayBest==-1) {
-    // give a try exchanging InnLay and OutLay
+  } else { // give it a try exchanging InnLay and OutLay
+
     // OutLay - first cluster
     for(i1InnLay=0; i1InnLay<nclOutLayStored; i1InnLay++) { 
       p1[0]=xclOutLay[i1InnLay]; 
@@ -300,24 +287,23 @@ AliESDVertex* AliITSVertexerCosmics::FindVertexForCurrentEvent(Int_t evnumber)
        }
       } // OutLay - second cluster
     } // OutLay - first cluster
-  }
 
-  if(i1InnLayBest>-1 && i2InnLayBest>-1) { 
-    xvtx = 0.5*(xclOutLay[i1InnLayBest]+xclOutLay[i2InnLayBest]);
-    yvtx = 0.5*(yclOutLay[i1InnLayBest]+yclOutLay[i2InnLayBest]);
-    zvtx = 0.5*(zclOutLay[i1InnLayBest]+zclOutLay[i2InnLayBest]);
-    rvtx = TMath::Sqrt(xvtx*xvtx+yvtx*yvtx);
-    if(rvtx<fMaxVtxRadius[ilayer]) {
-      ncontributors = ilayer2;
-      pos[0] = xvtx;
-      pos[1] = yvtx;
-      pos[2] = zvtx;
-      err[0]=TMath::Sqrt(0.25*(e2xclOutLay[i1InnLayBest]+e2xclOutLay[i2InnLayBest])); 
-      err[1]=TMath::Sqrt(0.25*(e2yclOutLay[i1InnLayBest]+e2yclOutLay[i2InnLayBest])); 
-      err[2]=TMath::Sqrt(0.25*(e2zclOutLay[i1InnLayBest]+e2zclOutLay[i2InnLayBest]));
+    if(i1InnLayBest>-1 && i2InnLayBest>-1) { 
+      xvtx = 0.5*(xclOutLay[i1InnLayBest]+xclOutLay[i2InnLayBest]);
+      yvtx = 0.5*(yclOutLay[i1InnLayBest]+yclOutLay[i2InnLayBest]);
+      zvtx = 0.5*(zclOutLay[i1InnLayBest]+zclOutLay[i2InnLayBest]);
+      rvtx = TMath::Sqrt(xvtx*xvtx+yvtx*yvtx);
+      if(rvtx<fMaxVtxRadius[ilayer]) {
+       ncontributors = ilayer2;
+       pos[0] = xvtx;
+       pos[1] = yvtx;
+       pos[2] = zvtx;
+       err[0]=TMath::Sqrt(0.25*(e2xclOutLay[i1InnLayBest]+e2xclOutLay[i2InnLayBest])); 
+       err[1]=TMath::Sqrt(0.25*(e2yclOutLay[i1InnLayBest]+e2yclOutLay[i2InnLayBest])); 
+       err[2]=TMath::Sqrt(0.25*(e2zclOutLay[i1InnLayBest]+e2zclOutLay[i2InnLayBest]));
+      }
     }
-  }
-  */
+  } // give it a try exchanging InnLay and OutLay
 
   fCurrentVertex = new AliESDVertex(pos,err,"cosmics");
   fCurrentVertex->SetTitle("cosmics fake vertex");
@@ -325,26 +311,10 @@ AliESDVertex* AliITSVertexerCosmics::FindVertexForCurrentEvent(Int_t evnumber)
   //fCurrentVertex->Print();
 
   delete recpoints;
-  itsLoader->UnloadRecPoints();
 
   return fCurrentVertex;
 }  
-//-------------------------------------------------------------------------
-void AliITSVertexerCosmics::FindVertices()
-{
-  // computes the vertices of the events in the range FirstEvent - LastEvent
-  AliRunLoader *rl = AliRunLoader::GetRunLoader();
-  AliITSLoader* itsLoader =  (AliITSLoader*) rl->GetLoader("ITSLoader");
-  itsLoader->ReloadRecPoints();
-  for(Int_t i=fFirstEvent;i<=fLastEvent;i++){
-    //  printf("Processing event %d\n",i);
-    rl->GetEvent(i);
-    FindVertexForCurrentEvent(i);
-    if(fCurrentVertex){
-      WriteCurrentVertex();
-    }
-  }
-}
+
 //-------------------------------------------------------------------------
 void AliITSVertexerCosmics::PrintStatus() const 
 {