]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSFindClustersV2.C
Correct the number of buspatches for station 1 & 2 and for R2 & R3 type slat (Christian)
[u/mrichter/AliRoot.git] / ITS / AliITSFindClustersV2.C
index 9521a59e4bc0dbe32d3e9a5cf6418d79dfa8a716..d9728602dd3411eda1219b828c0fac68e5159772 100644 (file)
  *           Origin: I.Belikov, CERN, Jouri.Belikov@cern.ch                 *
  ****************************************************************************/
 
-#ifndef __CINT__
-  #include <iostream.h>
+#if !defined(__CINT__) || defined(__MAKECINT__)
+  #include <Riostream.h>
 
   #include "AliRun.h"
+  #include "AliRunLoader.h"
+  #include "AliITSLoader.h"
   #include "AliITS.h"
   #include "AliITSgeom.h"
   #include "AliITSclustererV2.h"
 
-  #include "TFile.h"
+  #include "TTree.h"
   #include "TStopwatch.h"
 #endif
 
-Int_t AliITSFindClustersV2(Char_t SlowOrFast='s',Int_t eventn=1) {
+extern AliRun *gAlice;
+
+Int_t AliITSFindClustersV2(Int_t nev=5, Char_t SlowOrFast='s') {
 
    cerr<<"Looking for clusters...\n";
 
-   TFile *in=TFile::Open("galice.root");
-   if (!in->IsOpen()) {cerr<<"Can't open galice.root !\n"; return 2;}
-   if (!(gAlice=(AliRun*)in->Get("gAlice"))) {
-      cerr<<"Can't find gAlice !\n";
+   if (gAlice) {
+      delete gAlice->GetRunLoader();
+      delete gAlice; 
+      gAlice=0;
+   }
+   AliRunLoader *rl = AliRunLoader::Open("galice.root");
+   if (rl == 0x0) {
+      cerr<<"AliITSFindClustersV2.C : Can not open session RL=NULL"<< endl;
+      return 1;
+   }
+     
+   AliITSLoader *itsl = (AliITSLoader*)rl->GetLoader("ITSLoader");
+   if (itsl == 0x0) {
+      cerr<<"AliITSFindClustersV2.C : can not get ITS loader"<< endl;
       return 2;
    }
-   AliITS *ITS  = (AliITS*)gAlice->GetModule("ITS");
-   if (!ITS) { cerr<<"Can't find the ITS !\n"; return 3; }
 
+   rl->LoadKinematics();
+
+   Int_t retval = rl->LoadgAlice();
+   if (retval) {
+      cerr<<"AliITSFindClustersV2.C : LoadgAlice returned error"<< endl;
+      delete rl;
+      return 3;
+   }
+
+   gAlice=rl->GetAliRun();
+   AliITS *ITS  = (AliITS*)gAlice->GetModule("ITS");
+   if (!ITS) { cerr<<"Can't find the ITS !\n"; delete rl; return 3; }
    AliITSgeom *geom=ITS->GetITSgeom();
 
-   TFile *out=TFile::Open("AliITSclustersV2.root","new");
-   if (!out->IsOpen()) {
-      cerr<<"Delete old AliITSclustersV2.root !\n"; return 1;}
-   geom->Write();
+   itsl->LoadRecPoints("recreate");
+   if (SlowOrFast=='s') itsl->LoadDigits("read");
+   else itsl->LoadHits("read");
+   
+   if(SlowOrFast=='s'){
+     AliITSclustererV2 clusterer(geom);
 
-   TStopwatch timer;
-   AliITSclustererV2 clusterer(geom);
-   for (Int_t i=0; i<eventn; i++) {
+     TStopwatch timer;
+     if (nev>rl->GetNumberOfEvents()) nev=rl->GetNumberOfEvents();
+     for (Int_t i=0; i<nev; i++) {
        cerr<<"Processing event number: "<<i<<endl;
-       gAlice->GetEvent(i);
-       //ITS->MakeTreeC(); //To make the V1 cluster finders happy
-       clusterer.SetEvent(i);
-       if (SlowOrFast=='s') clusterer.Digits2Clusters(in,out);
-       else                 clusterer.Hits2Clusters(in,out);
+       rl->GetEvent(i);
+       
+       TTree *out=itsl->TreeR();
+       if (!out) {
+        itsl->MakeTree("R");
+        out=itsl->TreeR();
+       }
+       
+       TTree *in=itsl->TreeD();
+       if (!in) {
+        cerr<<"Can't get digits tree !\n";
+        return 4;
+       }
+       clusterer.Digits2Clusters(in,out);       
+       itsl->WriteRecPoints("OVERWRITE");
+       timer.Stop(); timer.Print();
+     }
+
+   } else{
+     
+     for(Int_t i=0;i<3;i++){
+       ITS->SetSimulationModel(i,new AliITSsimulationFastPoints());
+     }
+
+     TStopwatch timer;
+     for (Int_t i=0; i<nev; i++) {
+       rl->GetEvent(i);
+       if(itsl->TreeR()== 0x0) itsl->MakeTree("R");
+       TTree* in = (TTree*)itsl->TreeH();
+       TTree* out= (TTree*)itsl->TreeR();
+       timer.Start();
+       ITS->Hits2Clusters(in,out);
+       timer.Stop(); timer.Print();
+       itsl->WriteRecPoints("OVERWRITE");
+     }
    }
-   timer.Stop(); timer.Print();
 
-   delete gAlice; gAlice=0;
-   out->Close();
-   in->Close();
+   delete rl;
 
    return 0;
 }