Working version (P.Skowronski)
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 19 Aug 2003 15:10:30 +0000 (15:10 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 19 Aug 2003 15:10:30 +0000 (15:10 +0000)
TPC/AliTPCFindClustersMI.C
TPC/AliTPCFindTracksMI.C

index aaeb046..281bc05 100644 (file)
 #endif
 
 Int_t AliTPCFindClustersMI(Int_t n=1) {
-   TFile *out=TFile::Open("AliTPCclusters.root","new");
-   if (!out->IsOpen()) {cerr<<"Delete old AliTPCclusters.root !\n"; return 1;}
-   TFile *in=TFile::Open("rfio:galice.root");
-   if (!in->IsOpen()) {cerr<<"Can't open galice.root !\n"; return 2;}
-
-   TFile *ind=TFile::Open("rfio:digits.root");
-   if (!ind->IsOpen()) {cerr<<"Can't open digits file !\n"; return 2;}
+   
+   AliRunLoader* rl = AliRunLoader::Open("rfio:./galice.root");
+   if (rl == 0x0) {
+      cerr<<"Can not open session"<<endl;
+      return 1;
+   }
+   
+   AliTPCLoader *tpcl = (AliTPCLoader*)rl->GetLoader("TPCLoader");
+   if (tpcl == 0x0) {
+      cerr<<"Can not get TPC Loader"<<endl;
+      return 1;
+   }
 
+   if (tpcl->LoadDigits()) {
+      cerr<<"Error occured while loading digits"<<endl;
+      return 1;
+   }
 
-   if (!(gAlice=(AliRun*)in->Get("gAlice"))) {
-     cerr<<"gAlice have not been found on galice.root !\n";
-     return 3;
+   if (tpcl->LoadRecPoints("recreate")) {
+      cerr<<"Error occured while loading digits"<<endl;
+      return 1;
+   }
+   
+   if (rl->LoadgAlice()) {
+      cerr<<"Error occured while l"<<endl;
+      return 1;
+   }
+   
+   gAlice=rl->GetAliRun();
+   if (!gAlice) {
+      cerr<<"Can't get gAlice !\n";
+      return 1;
    }
 
    TDirectory *cwd = gDirectory;
@@ -50,8 +70,10 @@ Int_t AliTPCFindClustersMI(Int_t n=1) {
    AliTPC *TPC = (AliTPC*)gAlice->GetDetector("TPC"); 
    Int_t ver = TPC->IsVersion(); 
    cerr<<"TPC version "<<ver<<" has been found !\n";
-
-   AliTPCParam *dig=(AliTPCParam *)in->Get("75x40_100x60_150x60");
+   
+   rl->CdGAFile();
+   
+   AliTPCParam *dig=(AliTPCParam *)gDirectory->Get("75x40_100x60_150x60");
    if (!dig) {cerr<<"TPC parameters have not been found !\n"; return 4;}
 
    TStopwatch timer;
@@ -76,23 +98,37 @@ Int_t AliTPCFindClustersMI(Int_t n=1) {
        AliTPCv2 tpc; 
        tpc.SetParam(dig); timer.Start(); cwd->cd();  
        
-       
-       for (Int_t i=0;i<n;i++){ 
-        AliTPCclustererMI clusterer;
-        char dname[100];
-        char cname[100];
-        sprintf(dname,"TreeD_75x40_100x60_150x60_%d",i);
-        sprintf(cname,"TreeC_TPC_%d",i);
-        TTree * input = (TTree*)ind->Get(dname);
-        out->cd();
-        TTree * output = new TTree(cname,cname); 
-        
-        printf("Processing event %d\n",i); 
-        clusterer.SetInput(input);
-        clusterer.SetOutput(output);
-        clusterer.Digits2Clusters(dig, i);
-         //tpc.Digits2Clusters(out,i);
-        //      AliTPCclusterer::Digits2Clusters(dig, out, i);
+       n = rl->GetNumberOfEvents();
+       for (Int_t i=0;i<n;i++)
+        { 
+          rl->GetEvent(i);
+          AliTPCclustererMI clusterer(dig);
+          
+          TTree * input = tpcl->TreeD();
+          if (input == 0x0)
+           {
+             cerr << "Can not get TreeD for event " << i <<endl;
+             continue;
+           }
+          
+          TTree * output = tpcl->TreeR();
+          if (output == 0x0)
+           {
+             tpcl->MakeTree("R");
+             output = tpcl->TreeR();
+             if (output == 0x0)
+              {
+                cerr << "Problems with output tree (TreeR) for event " << i <<endl;
+                continue;
+              }
+           }
+
+          printf("Processing event %d\n",i); 
+          clusterer.SetInput(input);
+          clusterer.SetOutput(output);
+          clusterer.Digits2Clusters();
+          
+          tpcl->WriteRecPoints("OVERWRITE");
        }
      }
      break;
@@ -103,11 +139,7 @@ Int_t AliTPCFindClustersMI(Int_t n=1) {
    
    timer.Stop(); timer.Print();
    
-   delete gAlice; gAlice=0;
-
-   out->Close();
-
-   in->Close();
+   delete rl;//cleans everything
 
    return 0;
 }
index 7e3acc0..e0b19a1 100644 (file)
  ****************************************************************************/
 
 #ifndef __CINT__
-#include <iostream.h>
-#include "AliTPCParam.h"
-#include "AliTPCtrackerMI.h"
-#include "TFile.h"
-#include "TStopwatch.h"
-#include "AliRun.h"
-#include "AliMagF.h"
+  #include <iostream.h>
+  #include "AliTPCParam.h"
+  #include "AliTPCtracker.h"
+
+  #include "TFile.h"
+  #include "TStopwatch.h"
 #endif
 
-Int_t AliTPCFindTracks(Int_t eventn=1) { 
+Int_t AliTPCFindTracksMI(Int_t N=-1) {
+
    cerr<<"Looking for tracks...\n";
-   TFile f("galice.root");
-   gAlice = (AliRun*)f.Get("gAlice");
-   AliKalmanTrack::SetConvConst(1000/0.299792458/gAlice->Field()->SolenoidField());
-   TFile *out=TFile::Open("AliTPCtracks.root","new");
-   if (!out->IsOpen()) {cerr<<"Delete old AliTPCtracks.root !\n"; return 1;}
 
-   TFile *in=TFile::Open("AliTPCclusters.root");
-   if (!in->IsOpen()) {cerr<<"Can't open AliTPCclusters.root !\n"; return 2;}
+   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->UnloadgAlice();
+   
+   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;
+    }
 
-   AliTPCParam *par=(AliTPCParam*)in->Get("75x40_100x60_150x60");
-   if (!par) {cerr<<"Can't get TPC parameters !\n"; return 3;}
+   
+   tpcl->LoadTracks("recreate");
+
+   Int_t eventn;
+   if (N<=0) 
+    {
+     eventn = rl->GetNumberOfEvents();
+     rl->UnloadHeader();
+    }
+   else
+    eventn = N;
+    
    TStopwatch timer;
-  
    Int_t rc=0;
-   for (Int_t i=0;i<eventn;i++){
-     printf("Processing event %d\n",i);
-     AliTPCtrackerMI *tracker = new AliTPCtrackerMI(par,i);
-     //delete tracker; 
-     //tracker = new AliTPCtrackerMI(par,i);
-     //Double_t xyz[]={0.,0.,0.}; tracker->SetVertex(xyz); //primary vertex
-     rc=tracker->Clusters2Tracks(0,out);
-     delete tracker;
-   }
+   for (Int_t i=0;i<eventn;i++)
+    {
+      TTree * input = tpcl->TreeR();
+      if (input == 0x0)
+       {
+         tpcl->LoadRecPoints("read");
+         input = tpcl->TreeR();
+         if (input == 0x0)
+          {
+            cerr << "Problems with input tree (TreeR) for event " << i <<endl;
+            continue;
+          }
+       }
+      TTree * output = tpcl->TreeT();
+      if (output == 0x0)
+       {
+         tpcl->MakeTree("T");
+         output = tpcl->TreeT();
+         if (output == 0x0)
+          {
+            cerr << "Problems with output tree (TreeT) for event " << i <<endl;
+            continue;
+          }
+       }
+
+      printf("Processing event %d\n",i);
+      AliTPCtrackerMI *tracker = new AliTPCtrackerMI(dig);
+      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;
 }