]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSFindClustersV2.C
Macro to plot pathlengths of back-to-back jets. (A. Dainese)
[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    AliITSclustererV2 clusterer(geom);
62
63    TStopwatch timer;
64    if (nev>rl->GetNumberOfEvents()) nev=rl->GetNumberOfEvents();
65    for (Int_t i=0; i<nev; i++) {
66        cerr<<"Processing event number: "<<i<<endl;
67        rl->GetEvent(i);
68
69        TTree *out=itsl->TreeR();
70        if (!out) {
71           itsl->MakeTree("R");
72           out=itsl->TreeR();
73        }
74
75        if (SlowOrFast=='s') {
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        } else {
83           TTree *in=itsl->TreeH();
84           if (!in) {
85             cerr<<"Can't get hits tree !\n";
86             return 5;
87           }
88           clusterer.Hits2Clusters(in,out);
89        }
90
91        itsl->WriteRecPoints("OVERWRITE");
92    }
93    timer.Stop(); timer.Print();
94
95    delete rl;
96
97    return 0;
98 }
99
100
101