]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCFindTracks.C
aa4449b3cc2a2825e99812e1b47c16525b753774
[u/mrichter/AliRoot.git] / TPC / AliTPCFindTracks.C
1 /****************************************************************************
2  *           Origin: I.Belikov, CERN, Jouri.Belikov@cern.ch                 *
3  ****************************************************************************/
4
5 #if !defined(__CINT__) || defined(__MAKECINT__)
6   #include <iostream.h>
7   #include "AliTPCParam.h"
8   #include "AliTPCtracker.h"
9   #include "AliRun.h"
10   #include "AliMagF.h"
11   #include "AliRunLoader.h"
12   #include "AliTPCLoader.h"
13
14   #include "TFile.h"
15   #include "TStopwatch.h"
16 #endif
17
18 extern AliRun *gAlice;
19
20 Int_t AliTPCFindTracks(Int_t nev=5) {
21
22    cerr<<"Looking for tracks...\n";
23
24    if (gAlice) {
25      delete gAlice->GetRunLoader();
26      delete gAlice;
27      gAlice = 0x0;
28    }
29
30    AliRunLoader *rl = AliRunLoader::Open("galice.root");
31    if (rl == 0x0) {
32       cerr<<"Can not open session"<<endl;
33       return 1;
34    }
35
36    AliTPCLoader *tpcl = (AliTPCLoader*)rl->GetLoader("TPCLoader");
37    if (tpcl == 0x0) {
38       cerr<<"Can not get TPC Loader"<<endl;
39       return 1;
40    }
41    
42    if (rl->LoadgAlice()) {
43       cerr<<"Error occured while loading gAlice"<<endl;
44       return 1;
45    }
46    AliKalmanTrack::SetConvConst(
47       1000/0.299792458/rl->GetAliRun()->Field()->SolenoidField()
48    );
49    rl->CdGAFile();
50    AliTPCParam *dig=(AliTPCParam *)gDirectory->Get("75x40_100x60_150x60");
51    if (!dig) { 
52         cerr<<"TPC parameters have not been found !\n";
53         return 1;
54    }
55
56    rl->UnloadgAlice();   
57
58    tpcl->LoadRecPoints("read");
59    tpcl->LoadTracks("recreate");
60
61    if (nev>rl->GetNumberOfEvents()) nev=rl->GetNumberOfEvents();
62     
63    TStopwatch timer;
64    Int_t rc=0;
65    AliTPCtracker tracker(dig);
66    for (Int_t i=0;i<nev;i++){
67      printf("Processing event %d\n",i);
68      rl->GetEvent(i);
69
70      TTree *in=tpcl->TreeR();
71      if (!in) {
72         cerr<<"Can't get clusters tree !\n";
73         return 4;
74      }
75
76      TTree *out=tpcl->TreeT();
77      if (!out) {
78         tpcl->MakeTree("T");
79         out=tpcl->TreeT();
80      }
81          
82      rc=tracker.Clusters2Tracks(in,out);
83
84      tpcl->WriteTracks("OVERWRITE");
85    }
86
87    timer.Stop(); timer.Print();
88  
89    delete dig; //Thanks to Mariana Bondila
90
91    delete rl;
92
93    return rc;
94 }