]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSVertexerPPZ.cxx
readers updated (mini header -> data header)
[u/mrichter/AliRoot.git] / ITS / AliITSVertexerPPZ.cxx
index 6c7eb9f6c25e7cd60d91a439832fcc1f2fe13c9d..cea187a3c1a410a005fe89484d72a52d942a1cbb 100644 (file)
@@ -24,6 +24,7 @@
 #include "AliRun.h"
 #include "AliITS.h"
 #include "AliITSgeom.h"
+#include "AliITSLoader.h"
 #include "AliITSRecPoint.h"
 /////////////////////////////////////////////////////////////////////////
 //                                                                     //
@@ -53,9 +54,8 @@ AliITSVertexerPPZ::AliITSVertexerPPZ():AliITSVertexer() {
   SetWindow(0);
 }
 
-AliITSVertexerPPZ::AliITSVertexerPPZ(TFile *infile, TFile *outfile, Float_t x0, Float_t y0):AliITSVertexer(infile,outfile) {
+AliITSVertexerPPZ::AliITSVertexerPPZ(TString fn, Float_t x0, Float_t y0):AliITSVertexer(fn) {
   // Standard constructor
-  if(!fInFile)Fatal("AliITSVertexerPPZ","No inputfile has been defined!");
   SetDiffPhiMax();
   fX0 = x0;
   fY0 = y0;
@@ -95,7 +95,7 @@ void  AliITSVertexerPPZ::EvalZ(TH1F *hist,Int_t sepa, Int_t ncoinc, TArrayF *zva
   if(NbinNotZero==1){
     fZFound = curz;
     fZsig=0;
-    fCurrentVertex = new AliITSVertex(fZFound,fZsig,NbinNotZero);
+    fCurrentVertex = new AliESDVertex(fZFound,fZsig,NbinNotZero);
     return;
   }
   Float_t errsq = totst2/(N-1)-totst*totst/N/(N-1);
@@ -154,7 +154,7 @@ void  AliITSVertexerPPZ::EvalZ(TH1F *hist,Int_t sepa, Int_t ncoinc, TArrayF *zva
   if(N<1){fZFound=-110; fZsig=-110; return;}
   if(N==1){
     fZsig = 0;
-    fCurrentVertex = new AliITSVertex(fZFound,fZsig,N);
+    fCurrentVertex = new AliESDVertex(fZFound,fZsig,N);
     return;
   }
   errsq = (fZsig/(N-1)-fZFound*fZFound/N/(N-1))/N;
@@ -171,20 +171,17 @@ void  AliITSVertexerPPZ::EvalZ(TH1F *hist,Int_t sepa, Int_t ncoinc, TArrayF *zva
   fZFound*=fZsig;
   fZsig = TMath::Sqrt(fZsig);
   */
-  fCurrentVertex = new AliITSVertex(fZFound,fZsig,N);
+  fCurrentVertex = new AliESDVertex(fZFound,fZsig,N);
 }
 
 //______________________________________________________________________
-AliITSVertex* AliITSVertexerPPZ::FindVertexForCurrentEvent(Int_t evnumber){
-  // Defines the AliITSVertex for the current event
+AliESDVertex* AliITSVertexerPPZ::FindVertexForCurrentEvent(Int_t evnumber){
+  // Defines the AliESDVertex for the current event
   fCurrentVertex = 0;
   fZFound = -999;
   fZsig = -999;
-  if(!gAlice)gAlice = (AliRun*)fInFile->Get("gAlice");
-  if(!gAlice){
-    Error("FindVertexForCurrentEvent","The AliRun object is not available - nothing done");
-    return fCurrentVertex;
-  }
+  AliRunLoader *rl =AliRunLoader::GetRunLoader();
+  AliITSLoader* ITSloader =  (AliITSLoader*) rl->GetLoader("ITSLoader");
   if(!fITS)  {
     fITS = (AliITS*)gAlice->GetModule("ITS");
     if(!fITS) {
@@ -192,29 +189,37 @@ AliITSVertex* AliITSVertexerPPZ::FindVertexForCurrentEvent(Int_t evnumber){
       return fCurrentVertex;
     }
   }
+  fITS->SetTreeAddress();
   AliITSgeom *geom = fITS->GetITSgeom();
   if(!geom) {
     Error("FindVertexForCurrentEvent","ITS geometry is not defined");
     return fCurrentVertex;
   }
-  TTree *TR=0;
-  TClonesArray *ITSrec  = 0;
+  TTree *tR=0;
+  TClonesArray *itsRec  = 0;
   Float_t lc[3]; for(Int_t ii=0; ii<3; ii++) lc[ii]=0.;
   Float_t gc[3]; for(Int_t ii=0; ii<3; ii++) gc[ii]=0.;
   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.;
 
-  TR = gAlice->TreeR();
-  if(!TR){
+  tR = ITSloader->TreeR();
+  if(!tR){
     Error("FindVertexForCurrentEvent","TreeR not found");
     return fCurrentVertex;
   }
-  ITSrec  = fITS->RecPoints();  // uses slow points or fast points if slow are
+  itsRec  = fITS->RecPoints();  // uses slow points or fast points if slow are
   // missing
-  TBranch *branch = TR->GetBranch("ITSRecPoints");
-  if(!branch){ 
-    branch = TR->GetBranch("ITSRecPointsF");
-    //   Warning("FindVertexForCurrentEvent","Using Fast points");
+  TClonesArray dummy("AliITSclusterV2",10000), *clusters=&dummy;
+  TBranch *branch;
+  if(fUseV2Clusters){
+    branch = tR->GetBranch("Clusters");
+    branch->SetAddress(&clusters);
+  }
+  else {
+    branch = tR->GetBranch("ITSRecPoints");
+    if(!branch){ 
+      branch = tR->GetBranch("ITSRecPointsF");
+    }
   }
   if(!branch){
    Error("FindVertexForCurrentEvent","branch for ITS rec points not found");
@@ -226,9 +231,12 @@ AliITSVertex* AliITSVertexerPPZ::FindVertexForCurrentEvent(Int_t evnumber){
   Int_t firipixe=0;
   for(Int_t module= fFirstL1; module<=fLastL1;module++){
     branch->GetEvent(module);
-    Int_t nrecp1 = ITSrec->GetEntries();
+    if(fUseV2Clusters){
+      Clusters2RecPoints(clusters,module,itsRec);
+    }
+    Int_t nrecp1 = itsRec->GetEntries();
     for(Int_t i=0; i<nrecp1;i++){
-      AliITSRecPoint *current = (AliITSRecPoint*)ITSrec->At(i);
+      AliITSRecPoint *current = (AliITSRecPoint*)itsRec->At(i);
       lc[0]=current->GetX();
       lc[2]=current->GetZ();
       geom->LtoG(module,lc,gc);
@@ -265,9 +273,12 @@ AliITSVertex* AliITSVertexerPPZ::FindVertexForCurrentEvent(Int_t evnumber){
   for(Int_t module= fFirstL1; module<=fLastL1;module++){
     if(fDebug>0)cout<<"processing module   "<<module<<"                  \r";
     branch->GetEvent(module);
-    Int_t nrecp1 = ITSrec->GetEntries();
+    if(fUseV2Clusters){
+      Clusters2RecPoints(clusters,module,itsRec);
+    }
+    Int_t nrecp1 = itsRec->GetEntries();
     TObjArray *poiL1 = new TObjArray(nrecp1);
-    for(Int_t i=0; i<nrecp1;i++)poiL1->AddAt(ITSrec->At(i),i);
+    for(Int_t i=0; i<nrecp1;i++)poiL1->AddAt(itsRec->At(i),i);
     fITS->ResetRecPoints();
     for(Int_t i=0; i<nrecp1;i++){
       AliITSRecPoint *current = (AliITSRecPoint*)poiL1->At(i);
@@ -282,9 +293,12 @@ AliITSVertex* AliITSVertexerPPZ::FindVertexForCurrentEvent(Int_t evnumber){
       if(fDebug>1)cout<<"module "<<module<<" "<<gc[0]<<" "<<gc[1]<<" "<<gc[2]<<" "<<phi1<<"     \n";
       for(Int_t modul2=fFirstL2; modul2<=fLastL2; modul2++){
        branch->GetEvent(modul2);
-       Int_t nrecp2 = ITSrec->GetEntries();
+       if(fUseV2Clusters){
+         Clusters2RecPoints(clusters,modul2,itsRec);
+       }
+       Int_t nrecp2 = itsRec->GetEntries();
        for(Int_t j=0; j<nrecp2;j++){
-         AliITSRecPoint *recp = (AliITSRecPoint*)ITSrec->At(j);
+         AliITSRecPoint *recp = (AliITSRecPoint*)itsRec->At(j);
          lc2[0]=recp->GetX();
          lc2[2]=recp->GetZ();
          geom->LtoG(modul2,lc2,gc2);
@@ -330,7 +344,7 @@ AliITSVertex* AliITSVertexerPPZ::FindVertexForCurrentEvent(Int_t evnumber){
   if(fCurrentVertex){
     char name[30];
     sprintf(name,"Vertex_%d",evnumber);
-    fCurrentVertex->SetName(name);
+    //    fCurrentVertex->SetName(name);
     fCurrentVertex->SetTitle("vertexer: PPZ");
   }
   return fCurrentVertex;
@@ -339,19 +353,12 @@ AliITSVertex* AliITSVertexerPPZ::FindVertexForCurrentEvent(Int_t evnumber){
 //______________________________________________________________________
 void AliITSVertexerPPZ::FindVertices(){
   // computes the vertices of the events in the range FirstEvent - LastEvent
-  if(!fOutFile){
-    Error("FindVertices","The output file is not available - nothing done");
-    return;
-  }
-  if(!gAlice)gAlice = (AliRun*)fInFile->Get("gAlice");
-  if(!gAlice){
-    Error("FindVertices","The AliRun object is not available - nothing done");
-    return;
-  }
-  TDirectory *curdir = gDirectory;
-  fInFile->cd();
+  AliRunLoader *rl = AliRunLoader::GetRunLoader();
+  AliITSLoader* ITSloader =  (AliITSLoader*) rl->GetLoader("ITSLoader");
+  ITSloader->ReloadRecPoints();
   for(Int_t i=fFirstEvent;i<=fLastEvent;i++){
-    gAlice->GetEvent(i);
+    cout<<"Processing event "<<i<<endl;
+    rl->GetEvent(i);
     FindVertexForCurrentEvent(i);
     if(fCurrentVertex){
       WriteCurrentVertex();
@@ -363,7 +370,6 @@ void AliITSVertexerPPZ::FindVertices(){
       }
     }
   }
-  curdir->cd();
 }
 
 //________________________________________________________
@@ -378,10 +384,6 @@ void AliITSVertexerPPZ::PrintStatus() const {
   cout <<" Window for Z search: "<<fWindow<<endl;
   cout <<" Current Z "<<fZFound<<"; Z sig "<<fZsig<<endl;
   cout <<" Debug flag: "<<fDebug<<endl;
-  if(fInFile)cout <<" The input file is open\n";
-  if(!fInFile)cout <<"The input file is not open\n";
-  if(fOutFile)cout <<"The output file is open\n";
-  if(!fOutFile)cout <<"The output file is not open\n";
   cout<<"First event to be processed "<<fFirstEvent;
   cout<<"\n Last event to be processed "<<fLastEvent<<endl;
 }