]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSFindTracksV2.C
Removing GetDebug and SetDebug from AliRun and AliModule. Using AliLog for the messages
[u/mrichter/AliRoot.git] / ITS / AliITSFindTracksV2.C
index 25723ccbb612923123bedbe85cc0d73424838550..43d3d7dca3abf353b81f9ef97ece73bc722ab0d3 100644 (file)
-#ifndef __CINT__
+/****************************************************************************
+ *           Origin: I.Belikov, CERN, Jouri.Belikov@cern.ch                 *
+ ****************************************************************************/
+
+#if !defined(__CINT__) || defined(__MAKECINT__)
   #include "Riostream.h"
-  #include "TFile.h"
+  #include "TKey.h"
   #include "TStopwatch.h"
 
+  #include "AliRun.h"
+  #include "AliMagF.h"
+  #include "AliRunLoader.h"
+  #include "AliTPCLoader.h"
+  #include "AliITSLoader.h"
+  #include "AliITS.h"
   #include "AliITSgeom.h"
   #include "AliITStrackerV2.h"
+  #include "AliESD.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;
-       return 3;
-     }
-    retval = rl->LoadHeader();
-    if (retval)
-     {
-      ::Error("AliITSHits2DigitsDefault.C","LoadHeader returned error");
+   AliITSLoader* itsl = (AliITSLoader*)rl->GetLoader("ITSLoader");
+   if (itsl == 0x0) {
+      cerr<<"AliITSFindTracksV2.C : Can not get ITS loader"<<endl;
+      return 4;
+   }
+
+   if (rl->LoadgAlice()) {
+      cerr<<"AliITSFindTracksV2.C : LoadgAlice 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");
-      return 4;
-     }
+   }
 
-    AliLoader* tpcloader = rl->GetLoader("TPCLoader");
-    if (tpcloader == 0x0)
-     {
-      cerr<<"AliITSHits2DigitsDefault.C : can not get TPC loader"
-           << endl;
-     }
+   AliKalmanTrack::SetConvConst(
+      1000/0.299792458/rl->GetAliRun()->Field()->SolenoidField()
+   );
+       
+   AliITS *dITS = (AliITS*)rl->GetAliRun()->GetDetector("ITS");
+   if (!dITS) {
+      cerr<<"AliITSFindClusters.C : Can not find the ITS detector !"<<endl;
+      return 6;
+   }
+   AliITSgeom *geom = dITS->GetITSgeom();
 
-   rl->GetEvent(0);
+   AliITStrackerV2 tracker(geom);
 
-   itsloader->LoadTracks("recreate");
-   tpcloader->LoadTracks("read"); 
-   itsloader->LoadRawClusters("read");
+   itsl->LoadRecPoints("read");
 
-   AliITS* dITS = (AliITS*)gAlice->GetDetector("ITS");
-   if(!dITS)
-    {
-      ::Error("AliITSHits2DigitsDefault.C","Can not find ITS detector.");
-      return 6;
-    } // end if !fITS
+   if (nev>rl->GetNumberOfEvents()) nev=rl->GetNumberOfEvents();
+   Int_t rc=0;
 
-   AliITSgeom *geom = dITS->GetITSgeom();
-   if(geom == 0x0)
-    {
-      ::Error("AliITSHits2DigitsDefault.C","Can not get geometry from ITS detector.");
-      return 6;
-    } // end if !GetITSgeom()
+   TFile *itsf=TFile::Open("AliESDits.root","RECREATE");
+   if ((!itsf)||(!itsf->IsOpen())) {
+      cerr<<"Can't AliESDits.root !\n"; return 1;
+   }
+   TFile *tpcf=TFile::Open("AliESDtpc.root");
+   if ((!tpcf)||(!tpcf->IsOpen())) {
+      cerr<<"Can't AliESDtpc.root !\n"; return 1;
+   }
+   TKey *key=0;
+   TIter next(tpcf->GetListOfKeys());
+   TStopwatch timer; 
+   for (Int_t i=0; i<nev; i++) {
+       tpcf->cd();
+       if ((key=(TKey*)next())==0) break;
+       cerr<<"Processing event number: "<<i<<endl;
+       AliESD *event=(AliESD*)key->ReadObj();
 
+       rl->GetEvent(i);
 
-   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;
+       TTree *cTree=itsl->TreeR();
+       if (!cTree) {
+         cerr<<"AliITSFindTracksV2.C : Can't get the clusters tree !"<<endl;
+          return 4;
        }
-    }
+
+       tracker.LoadClusters(cTree);
+       rc=tracker.Clusters2Tracks(event);
+       tracker.UnloadClusters();
+
+       if (rc==0) {
+          Char_t ename[100]; 
+          sprintf(ename,"%d",i);
+          itsf->cd();
+          if (!event->Write(ename)) rc++;
+       } 
+       if (rc) {
+          cerr<<"Something bad happened...\n";
+       }
+       delete event;
+   }
    timer.Stop(); timer.Print();
-   delete tracker;
+
+   tpcf->Close();
+   itsf->Close();
+
    delete rl;
+
    return rc;
 }