]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSFindTracksV2.C
Implementing ESD functionality in the NewIO (Yu.Belikov)
[u/mrichter/AliRoot.git] / ITS / AliITSFindTracksV2.C
index 25723ccbb612923123bedbe85cc0d73424838550..6fc08504ef510b87267f3a88be9a68c66301febd 100644 (file)
-#ifndef __CINT__
+/****************************************************************************
+ *           Origin: I.Belikov, CERN, Jouri.Belikov@cern.ch                 *
+ ****************************************************************************/
+
+#if !defined(__CINT__) || defined(__MAKECINT__)
   #include "Riostream.h"
-  #include "TFile.h"
+
   #include "TStopwatch.h"
 
+  #include "AliRun.h"
+  #include "AliRunLoader.h"
+  #include "AliTPCLoader.h"
+  #include "AliITSLoader.h"
+  #include "AliITS.h"
   #include "AliITSgeom.h"
   #include "AliITStrackerV2.h"
 #endif
 
-Int_t AliITSFindTracksV2(Int_t nev=1) {  //number of events to process
+extern AliRun *gAlice;
+
+Int_t AliITSFindTracksV2(Int_t nev=5) {  //number of events to process
    cerr<<"Looking for tracks...\n";
    
-   if (gAlice) 
-    {
+   if (gAlice) {
       delete gAlice->GetRunLoader();
       delete gAlice; 
       gAlice=0;
-    }
+   }
  
-    AliRunLoader* rl = AliRunLoader::Open("galice.root");
-    if (rl == 0x0)
-     {
-      cerr<<"AliITSHits2DigitsDefault.C : Can not open session RL=NULL"
-           << endl;
-       return 3;
-     }
+   AliRunLoader* rl = AliRunLoader::Open("galice.root");
+   if (rl == 0x0) {
+      cerr<<"AliITSFindTracks.C : Can not open session RL=NULL"<< endl;
+      return 3;
+   }
      
-    Int_t retval = rl->LoadgAlice();
-    if (retval)
-     {
-       ::Error("AliITSHits2DigitsDefault.C","LoadgAlice returned error");
-       delete rl;
+   Int_t retval = rl->LoadgAlice();
+   if (retval) {
+      cerr<<"AliITSFindTracksV2.C : LoadgAlice returned error"<<endl;
+      delete rl;
        return 3;
-     }
-    retval = rl->LoadHeader();
-    if (retval)
-     {
-      ::Error("AliITSHits2DigitsDefault.C","LoadHeader returned error");
+   }
+   retval = rl->LoadHeader();
+   if (retval) {
+      cerr<<"AliITSFindTracksV2.C : LoadHeader returned error"<<endl;
       delete rl;
       return 3;
-     }
-    gAlice=rl->GetAliRun();
-   
-    
-    AliITSLoader* itsloader = (AliITSLoader*)rl->GetLoader("ITSLoader");
-    if (itsloader == 0x0)
-     {
-      ::Error("AliITSHits2DigitsDefault.C","can not get ITS loader");
+   }
+   gAlice=rl->GetAliRun();
+       
+   AliITSLoader* itsl = (AliITSLoader*)rl->GetLoader("ITSLoader");
+   if (itsl == 0x0) {
+      cerr<<"AliITSFindTracksV2.C : Can not get ITS loader"<<endl;
       return 4;
-     }
-
-    AliLoader* tpcloader = rl->GetLoader("TPCLoader");
-    if (tpcloader == 0x0)
-     {
-      cerr<<"AliITSHits2DigitsDefault.C : can not get TPC loader"
-           << endl;
-     }
+   }
 
-   rl->GetEvent(0);
+   AliTPCLoader* tpcl = (AliTPCLoader*)rl->GetLoader("TPCLoader");
+   if (tpcl == 0x0) {
+      cerr<<"AliITSFindTracksV2.C : can not get TPC loader"<<endl;
+      return 5;
+   }
 
-   itsloader->LoadTracks("recreate");
-   tpcloader->LoadTracks("read"); 
-   itsloader->LoadRawClusters("read");
-
-   AliITS* dITS = (AliITS*)gAlice->GetDetector("ITS");
-   if(!dITS)
-    {
-      ::Error("AliITSHits2DigitsDefault.C","Can not find ITS detector.");
+   AliITS *dITS = (AliITS*)gAlice->GetDetector("ITS");
+   if (!dITS) {
+      cerr<<"AliITSFindClusters.C : Can not find the ITS detector !"<<endl;
       return 6;
-    } // end if !fITS
-
+   }
    AliITSgeom *geom = dITS->GetITSgeom();
-   if(geom == 0x0)
-    {
-      ::Error("AliITSHits2DigitsDefault.C","Can not get geometry from ITS detector.");
-      return 6;
-    } // end if !GetITSgeom()
 
+   AliITStrackerV2 tracker(geom);
 
-   TStopwatch timer;
-   for (Int_t i = 0;i < rl->GetNumberOfEvents(); i++)
-    {
-      AliITStrackerV2* tracker = new AliITStrackerV2(geom,i);
-      Int_t rc=tracker->Clusters2Tracks();
-      if (rc) 
-       {
-         ::Error("AliITSHits2DigitsDefault.C",
-                 "AliITStrackerV2::Clusters2Tracks returned errror for event %d",i);
-         delete tracker;
-         break;
+   tpcl->LoadTracks("read"); 
+   itsl->LoadTracks("recreate");
+   itsl->LoadRecPoints("read");
+
+   TStopwatch timer; 
+   if (nev>rl->GetNumberOfEvents()) nev=rl->GetNumberOfEvents();
+   Int_t rc=0;
+   for (Int_t i=0; i<nev; i++) {
+       cerr<<"Processing event number: "<<i<<endl;
+       rl->GetEvent(i);
+
+       TTree *cTree=itsl->TreeR();
+       if (!cTree) {
+         cerr<<"AliITSFindTracksV2.C : Can't get the clusters tree !"<<endl;
+          return 4;
+       }
+       TTree *tpcTree=tpcl->TreeT();
+       if (!tpcTree) {
+         cerr<<"AliITSFindTracksV2.C : Can't get the TPC track tree !"<<endl;
+          return 4;
        }
-    }
+       TTree *itsTree=itsl->TreeT();
+       if (!itsTree) {
+          itsl->MakeTree("T");
+          itsTree=itsl->TreeT();
+       }
+
+       tracker.LoadClusters(cTree);
+       rc=tracker.Clusters2Tracks(tpcTree,itsTree);
+       tracker.UnloadClusters();
+
+       itsl->WriteTracks("OVERWRITE");
+   }
    timer.Stop(); timer.Print();
-   delete tracker;
+
    delete rl;
+
    return rc;
 }