]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSFindTracksV2.C
New geometry: SDD, cables and update on V11 (L. Gaudichet)
[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   #include "TKey.h"
8   #include "TStopwatch.h"
9
10   #include "AliRun.h"
11   #include "AliMagF.h"
12   #include "AliRunLoader.h"
13   #include "AliTPCLoader.h"
14   #include "AliITSLoader.h"
15   #include "AliITS.h"
16   #include "AliITSgeom.h"
17   #include "AliITStrackerV2.h"
18   #include "AliESD.h"
19 #endif
20
21 extern AliRun *gAlice;
22
23 Int_t AliITSFindTracksV2(Int_t nev=5) {  //number of events to process
24    cerr<<"Looking for tracks...\n";
25    
26    if (gAlice) {
27       delete gAlice->GetRunLoader();
28       delete gAlice; 
29       gAlice=0;
30    }
31  
32    AliRunLoader* rl = AliRunLoader::Open("galice.root");
33    if (rl == 0x0) {
34       cerr<<"AliITSFindTracks.C : Can not open session RL=NULL"<< endl;
35       return 3;
36    }
37      
38    AliITSLoader* itsl = (AliITSLoader*)rl->GetLoader("ITSLoader");
39    if (itsl == 0x0) {
40       cerr<<"AliITSFindTracksV2.C : Can not get ITS loader"<<endl;
41       return 4;
42    }
43
44    if (rl->LoadgAlice()) {
45       cerr<<"AliITSFindTracksV2.C : LoadgAlice returned error"<<endl;
46       delete rl;
47       return 3;
48    }
49
50    AliKalmanTrack::SetConvConst(
51       1000/0.299792458/rl->GetAliRun()->Field()->SolenoidField()
52    );
53        
54    AliITS *dITS = (AliITS*)rl->GetAliRun()->GetDetector("ITS");
55    if (!dITS) {
56       cerr<<"AliITSFindClusters.C : Can not find the ITS detector !"<<endl;
57       return 6;
58    }
59    AliITSgeom *geom = dITS->GetITSgeom();
60
61    AliITStrackerV2 tracker(geom);
62
63    itsl->LoadRecPoints("read");
64
65    if (nev>rl->GetNumberOfEvents()) nev=rl->GetNumberOfEvents();
66    Int_t rc=0;
67
68    TFile *itsf=TFile::Open("AliESDits.root","RECREATE");
69    if ((!itsf)||(!itsf->IsOpen())) {
70       cerr<<"Can't AliESDits.root !\n"; return 1;
71    }
72    TFile *tpcf=TFile::Open("AliESDtpc.root");
73    if ((!tpcf)||(!tpcf->IsOpen())) {
74       cerr<<"Can't AliESDtpc.root !\n"; return 1;
75    }
76    TKey *key=0;
77    TIter next(tpcf->GetListOfKeys());
78    TStopwatch timer; 
79    for (Int_t i=0; i<nev; i++) {
80        tpcf->cd();
81        if ((key=(TKey*)next())==0) break;
82        cerr<<"Processing event number: "<<i<<endl;
83        AliESD *event=(AliESD*)key->ReadObj();
84
85        rl->GetEvent(i);
86
87        TTree *cTree=itsl->TreeR();
88        if (!cTree) {
89           cerr<<"AliITSFindTracksV2.C : Can't get the clusters tree !"<<endl;
90           return 4;
91        }
92
93        tracker.LoadClusters(cTree);
94        rc=tracker.Clusters2Tracks(event);
95        tracker.UnloadClusters();
96
97        if (rc==0) {
98           Char_t ename[100]; 
99           sprintf(ename,"%d",i);
100           itsf->cd();
101           if (!event->Write(ename)) rc++;
102        } 
103        if (rc) {
104           cerr<<"Something bad happened...\n";
105        }
106        delete event;
107    }
108    timer.Stop(); timer.Print();
109
110    tpcf->Close();
111    itsf->Close();
112
113    delete rl;
114
115    return rc;
116 }