]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCFindClusters.C
PWGPP-71 - Adding ncluster statistic to optional streamers. Print additional inform...
[u/mrichter/AliRoot.git] / TPC / AliTPCFindClusters.C
index 15267160720180111badbed3da0bde3c52f387c1..92e1e5fc784a638d0426127447b0404129fe1598 100644 (file)
@@ -1,83 +1,81 @@
 /****************************************************************************
- *           Origin: I.Belikov, CERN, Jouri.Belikov@cern.ch                 *
+ *           Origin: M.Ivanov marian.ivanov@cern.ch                         *
  ****************************************************************************/
 
-#ifndef __CINT__
-  #include <Riostream.h>
-  #include "AliRun.h"
-  #include "AliTPCv1.h"
-  #include "AliTPCv2.h"
-  #include "AliTPCParam.h"
+/*
+
+  macro to create array of clusters from TPC digits
+  input files - galice.root 
+                digits.root - file with digits - usualy use link to galice.root
+                           - in splitted mode - neccesary to create link to proper file
+                           
+   output file - AliTPCclusters.root
+               - to be used by AliTPCTrackFinderMI.C
+
+  Warning - if cluster file AliTPCclusters.root already exist - macro exit and don't produce anything
+              
+*/
 
-  #include "TFile.h"
-  #include "TStopwatch.h"
+
+#ifndef __CINT__
+#include <iostream.h>
+#include "AliRun.h"
+#include "AliTPCv1.h"
+#include "AliTPCv2.h"
+#include "AliTPCParam.h"
+#include "AliTPCclusterer.h"
+#include "TFile.h"
+#include "TStopwatch.h"
+#include "TTree.h"
 #endif
 
-Int_t AliTPCFindClusters(Int_t N=-1) 
- {
+Int_t AliTPCFindClustersMI(Int_t n=1) {
    
-   if (gAlice)
-    {
-      delete gAlice->GetRunLoader();
-      delete gAlice;//if everything was OK here it is already NULL
-      gAlice = 0x0;
-    }
-    
    AliRunLoader* rl = AliRunLoader::Open("galice.root");
-   if (rl == 0x0)
-    {
+   if (rl == 0x0) {
       cerr<<"Can not open session"<<endl;
       return 1;
-    }
-   
-   if (rl->LoadgAlice())
-    {
-      cerr<<"Error occured while l"<<endl;
-      return 1;
-    }
-   AliKalmanTrack::SetConvConst(1000/0.299792458/rl->GetAliRun()->Field()->SolenoidField());
+   }
    
-   tpcl = (AliTPCLoader*)rl->GetLoader("TPCLoader");
-   if (tpcl == 0x0)
-    {
+   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 (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;
+
    AliTPC *TPC = (AliTPC*)gAlice->GetDetector("TPC"); 
    Int_t ver = TPC->IsVersion(); 
    cerr<<"TPC version "<<ver<<" has been found !\n";
-
+   
    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;
-    }
+   if (!dig) {cerr<<"TPC parameters have not been found !\n"; return 4;}
 
-   Int_t n;
-   if (N<=0) n = rl->GetNumberOfEvents();
-   else n=N;
-   
    TStopwatch timer;
 
    switch (ver) {
@@ -86,43 +84,62 @@ Int_t AliTPCFindClusters(Int_t N=-1)
       {
        AliTPCv1 &tpc=*((AliTPCv1*)TPC);
        tpc.SetParam(dig); timer.Start(); cwd->cd(); 
-       tpc.SetLoader(tpcl);
-       tpcl->LoadHits("read");
-       tpcl->LoadRecPoints("recreate");
        for(Int_t i=0;i<n;i++){
          printf("Processing event %d\n",i);
-         rl->GetEvent(i);
+         gAlice->GetEvent(i);
          tpc.Hits2Clusters(out,i);
        } 
       }
       break;
    case 2:
-      cerr<<"Looking for clusters...\n";
-      {
-       // delete gAlice; gAlice=0;
-       AliTPCv2 * tpc = new AliTPCv2();
-       tpc->SetLoader(tpcl);
-       tpcl->LoadDigits("read");
-       tpcl->LoadRecPoints("recreate");
-
-       tpc->SetParam(dig); timer.Start();
+     cerr<<"Looking for clusters...\n";
+     {
+       // delete gAlice; gAlice=0;
+       AliTPCv2 tpc; 
+       tpc.SetParam(dig); timer.Start(); cwd->cd();  
+       
+       n = rl->GetNumberOfEvents();
        for (Int_t i=0;i<n;i++)
-        {
-         printf("Processing event %d\n",i);
-         tpc->Digits2Clusters(i);
-         //AliTPCclusterer::Digits2Clusters(dig, out, i);
+        { 
+          rl->GetEvent(i);
+          AliTPCclusterer 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");
        }
-       delete tpc;
-      }
-      break;
+     }
+     break;
    default:
-      cerr<<"Invalid TPC version !\n";
-      delete rl;
-      return 5;
+     cerr<<"Invalid TPC version !\n";
+     return 5;
    }
-
+   
    timer.Stop(); timer.Print();
+   
+   delete rl;//cleans everything
 
-   delete rl;
    return 0;
 }