Transition to NewIO
[u/mrichter/AliRoot.git] / TPC / AliTPCFindTracks.C
index 604a439..3c67d7e 100644 (file)
@@ -1,5 +1,9 @@
+/****************************************************************************
+ *           Origin: I.Belikov, CERN, Jouri.Belikov@cern.ch                 *
+ ****************************************************************************/
+
 #ifndef __CINT__
-  #include <Riostream.h>
+  #include <iostream.h>
   #include "AliTPCParam.h"
   #include "AliTPCtracker.h"
 
   #include "TStopwatch.h"
 #endif
 
-Int_t AliTPCFindTracks(Int_t eventn=1) { 
+Int_t AliTPCFindTracks(Int_t N=-1) {
+
    cerr<<"Looking for tracks...\n";
 
-   TFile *out=TFile::Open("AliTPCtracks.root","new");
-   if (!out->IsOpen()) {cerr<<"Delete old AliTPCtracks.root !\n"; return 1;}
+   if (gAlice)
+    {
+     delete gAlice->GetRunLoader();
+     delete gAlice;
+     gAlice = 0x0;
+    }
+    
+   rl = AliRunLoader::Open("galice.root");
+   if (rl == 0x0)
+    {
+      cerr<<"Can not open session"<<endl;
+      return 1;
+    }
+   tpcl = (AliTPCLoader*)rl->GetLoader("TPCLoader");
+   if (tpcl == 0x0)
+    {
+      cerr<<"Can not get TPC Loader"<<endl;
+      return 1;
+    }
+   
+   if (rl->LoadgAlice())
+    {
+      cerr<<"Error occured while l"<<endl;
+      return 1;
+    }
+   AliKalmanTrack::SetConvConst(1000/0.299792458/rl->GetAliRun()->Field()->SolenoidField());
+   rl->CdGAFile();
+   AliTPCParam *dig=(AliTPCParam *)gDirectory->Get("75x40_100x60_150x60");
+   if (!dig) 
+    {
+     dig=(AliTPCParam *)gDirectory->Get("75x40_100x60");
+     if (!param) 
+      {
+        cerr<<"TPC parameters have not been found !\n";
+        return 1;
+      }
+     else
+      {
+        cout<<"TPC 75x40_100x60 geometry found"<<endl;
+      }
+    }
+   else
+    {
+      cout<<"TPC 75x40_100x60_150x60  geometry found"<<endl;
+    }
 
-   TFile *in=TFile::Open("AliTPCclusters.root");
-   if (!in->IsOpen()) {cerr<<"Can't open AliTPCclusters.root !\n"; return 2;}
+   rl->UnloadgAlice()   
+   
+   tpcl->LoadRecPoints("read");
+   tpcl->LoadTracks("recreate");
 
-   AliTPCParam *par=(AliTPCParam*)in->Get("75x40_100x60_150x60");
-   if (!par) {cerr<<"Can't get TPC parameters !\n"; return 3;}
+   Int_t eventn;
+   if (N<=0) 
+    {
+     eventn = rl->GetNumberOfEvents();
+     rl->UnloadHeader();
+    }
+   else
+    eventn = N;
+    
    TStopwatch timer;
-
    Int_t rc=0;
-   AliTPCtracker tracker(par);
    for (Int_t i=0;i<eventn;i++){
      printf("Processing event %d\n",i);
-     tracker.SetEventNumber(i);
-     //Double_t xyz[]={0.,0.,0.}; tracker.SetVertex(xyz); //primary vertex
-     rc=tracker.Clusters2Tracks(0,out);
+     AliTPCtracker *tracker = new AliTPCtracker(dig,i);
+     rc=tracker->Clusters2Tracks();
+     delete tracker;
    }
    timer.Stop(); timer.Print();
  
-   delete par; //Thanks to Mariana Bondila
-
-   in->Close();
-   out->Close();
-
+   delete dig; //Thanks to Mariana Bondila
+   delete rl;
    return rc;
 }