]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSFindTracksV2.C
cluster information
[u/mrichter/AliRoot.git] / ITS / AliITSFindTracksV2.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 "TStopwatch.h"
9
10   #include "AliRun.h"
11   #include "AliRunLoader.h"
12   #include "AliTPCLoader.h"
13   #include "AliITSLoader.h"
14   #include "AliITS.h"
15   #include "AliITSgeom.h"
16   #include "AliITStrackerV2.h"
17 #endif
18
19 extern AliRun *gAlice;
20
21 Int_t AliITSFindTracksV2(Int_t nev=5) {  //number of events to process
22    cerr<<"Looking for tracks...\n";
23    
24    if (gAlice) {
25       delete gAlice->GetRunLoader();
26       delete gAlice; 
27       gAlice=0;
28    }
29  
30    AliRunLoader* rl = AliRunLoader::Open("galice.root");
31    if (rl == 0x0) {
32       cerr<<"AliITSFindTracks.C : Can not open session RL=NULL"<< endl;
33       return 3;
34    }
35      
36    Int_t retval = rl->LoadgAlice();
37    if (retval) {
38       cerr<<"AliITSFindTracksV2.C : LoadgAlice returned error"<<endl;
39       delete rl;
40        return 3;
41    }
42    retval = rl->LoadHeader();
43    if (retval) {
44       cerr<<"AliITSFindTracksV2.C : LoadHeader returned error"<<endl;
45       delete rl;
46       return 3;
47    }
48    gAlice=rl->GetAliRun();
49        
50    AliITSLoader* itsl = (AliITSLoader*)rl->GetLoader("ITSLoader");
51    if (itsl == 0x0) {
52       cerr<<"AliITSFindTracksV2.C : Can not get ITS loader"<<endl;
53       return 4;
54    }
55
56    AliTPCLoader* tpcl = (AliTPCLoader*)rl->GetLoader("TPCLoader");
57    if (tpcl == 0x0) {
58       cerr<<"AliITSFindTracksV2.C : can not get TPC loader"<<endl;
59       return 5;
60    }
61
62    AliITS *dITS = (AliITS*)gAlice->GetDetector("ITS");
63    if (!dITS) {
64       cerr<<"AliITSFindClusters.C : Can not find the ITS detector !"<<endl;
65       return 6;
66    }
67    AliITSgeom *geom = dITS->GetITSgeom();
68
69    AliITStrackerV2 tracker(geom);
70
71    tpcl->LoadTracks("read"); 
72    itsl->LoadTracks("recreate");
73    itsl->LoadRecPoints("read");
74
75    TStopwatch timer; 
76    if (nev>rl->GetNumberOfEvents()) nev=rl->GetNumberOfEvents();
77    Int_t rc=0;
78    for (Int_t i=0; i<nev; i++) {
79        cerr<<"Processing event number: "<<i<<endl;
80        rl->GetEvent(i);
81
82        TTree *cTree=itsl->TreeR();
83        if (!cTree) {
84           cerr<<"AliITSFindTracksV2.C : Can't get the clusters tree !"<<endl;
85           return 4;
86        }
87        TTree *tpcTree=tpcl->TreeT();
88        if (!tpcTree) {
89           cerr<<"AliITSFindTracksV2.C : Can't get the TPC track tree !"<<endl;
90           return 4;
91        }
92        TTree *itsTree=itsl->TreeT();
93        if (!itsTree) {
94           itsl->MakeTree("T");
95           itsTree=itsl->TreeT();
96        }
97
98        tracker.LoadClusters(cTree);
99        rc=tracker.Clusters2Tracks(tpcTree,itsTree);
100        tracker.UnloadClusters();
101
102        itsl->WriteTracks("OVERWRITE");
103    }
104    timer.Stop(); timer.Print();
105
106    delete rl;
107
108    return rc;
109 }