]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSFindClustersV2.C
Splitting of the ITS libraries (M.Masera & E.Crescio)
[u/mrichter/AliRoot.git] / ITS / AliITSFindClustersV2.C
1 /****************************************************************************
2  *           Origin: I.Belikov, CERN, Jouri.Belikov@cern.ch                 *
3  ****************************************************************************/
4
5 #if !defined(__CINT__) || defined(__MAKECINT__)
6   #include <Riostream.h>
7
8   #include "AliRun.h"
9   #include "AliRunLoader.h"
10   #include "AliITSLoader.h"
11   #include "AliITS.h"
12   #include "AliITSgeom.h"
13   #include "AliITSclustererV2.h"
14
15   #include "TTree.h"
16   #include "TStopwatch.h"
17 #endif
18
19 extern AliRun *gAlice;
20
21 Int_t AliITSFindClustersV2(Int_t nev=5, Char_t SlowOrFast='s') {
22
23    cerr<<"Looking for clusters...\n";
24
25    if (gAlice) {
26       delete gAlice->GetRunLoader();
27       delete gAlice; 
28       gAlice=0;
29    }
30  
31    AliRunLoader *rl = AliRunLoader::Open("galice.root");
32    if (rl == 0x0) {
33       cerr<<"AliITSFindClustersV2.C : Can not open session RL=NULL"<< endl;
34       return 1;
35    }
36      
37    AliITSLoader *itsl = (AliITSLoader*)rl->GetLoader("ITSLoader");
38    if (itsl == 0x0) {
39       cerr<<"AliITSFindClustersV2.C : can not get ITS loader"<< endl;
40       return 2;
41    }
42
43    rl->LoadKinematics();
44
45    Int_t retval = rl->LoadgAlice();
46    if (retval) {
47       cerr<<"AliITSFindClustersV2.C : LoadgAlice returned error"<< endl;
48       delete rl;
49       return 3;
50    }
51
52    gAlice=rl->GetAliRun();
53    AliITS *ITS  = (AliITS*)gAlice->GetModule("ITS");
54    if (!ITS) { cerr<<"Can't find the ITS !\n"; delete rl; return 3; }
55    AliITSgeom *geom=ITS->GetITSgeom();
56
57    itsl->LoadRecPoints("recreate");
58    if (SlowOrFast=='s') itsl->LoadDigits("read");
59    else itsl->LoadHits("read");
60    
61    if(SlowOrFast=='s'){
62      AliITSclustererV2 clusterer(geom);
63
64      TStopwatch timer;
65      if (nev>rl->GetNumberOfEvents()) nev=rl->GetNumberOfEvents();
66      for (Int_t i=0; i<nev; i++) {
67        cerr<<"Processing event number: "<<i<<endl;
68        rl->GetEvent(i);
69        
70        TTree *out=itsl->TreeR();
71        if (!out) {
72          itsl->MakeTree("R");
73          out=itsl->TreeR();
74        }
75        
76        TTree *in=itsl->TreeD();
77        if (!in) {
78          cerr<<"Can't get digits tree !\n";
79          return 4;
80        }
81        clusterer.Digits2Clusters(in,out);       
82        itsl->WriteRecPoints("OVERWRITE");
83        timer.Stop(); timer.Print();
84      }
85
86    } else{
87      
88      for(Int_t i=0;i<3;i++){
89        ITS->SetSimulationModel(i,new AliITSsimulationFastPoints());
90      }
91
92      TStopwatch timer;
93      for (Int_t i=0; i<nev; i++) {
94        rl->GetEvent(i);
95        if(itsl->TreeR()== 0x0) itsl->MakeTree("R");
96        TTree* in = (TTree*)itsl->TreeH();
97        TTree* out= (TTree*)itsl->TreeR();
98        timer.Start();
99        ITS->Hits2Clusters(in,out);
100        timer.Stop(); timer.Print();
101        itsl->WriteRecPoints("OVERWRITE");
102      }
103    }
104
105    delete rl;
106
107    return 0;
108 }
109
110
111