]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCFindTracks.C
Coding conventions for AliITSdigitXXX classes and AliITSTrackerV1
[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   #include "AliESD.h"
14
15   #include "TFile.h"
16   #include "TStopwatch.h"
17 #endif
18
19 extern AliRun *gAlice;
20
21 Int_t AliTPCFindTracks(Int_t nev=5) {
22
23    cerr<<"Looking for tracks...\n";
24
25    if (gAlice) {
26      delete gAlice->GetRunLoader();
27      delete gAlice;
28      gAlice = 0x0;
29    }
30
31    AliRunLoader *rl = AliRunLoader::Open("galice.root");
32    if (rl == 0x0) {
33       cerr<<"Can not open session"<<endl;
34       return 1;
35    }
36
37    AliTPCLoader *tpcl = (AliTPCLoader*)rl->GetLoader("TPCLoader");
38    if (tpcl == 0x0) {
39       cerr<<"Can not get TPC Loader"<<endl;
40       return 1;
41    }
42    
43    if (rl->LoadgAlice()) {
44       cerr<<"Error occured while loading gAlice"<<endl;
45       return 1;
46    }
47
48    AliKalmanTrack::SetConvConst(
49      1000/0.299792458/rl->GetAliRun()->Field()->SolenoidField()
50    );
51
52    rl->CdGAFile();
53    AliTPCParam *dig=(AliTPCParam *)gDirectory->Get("75x40_100x60_150x60");
54    if (!dig) { 
55         cerr<<"TPC parameters have not been found !\n";
56         return 1;
57    }
58
59    //rl->UnloadgAlice();   
60
61    tpcl->LoadRecPoints("read");
62
63    if (nev>rl->GetNumberOfEvents()) nev=rl->GetNumberOfEvents();
64     
65    TFile *ef=TFile::Open("AliESDtpc.root","RECREATE");
66    if ((!ef)||(!ef->IsOpen())) {
67       cerr<<"Can't AliESDtpc.root !\n"; return 1;
68    }
69    TStopwatch timer;
70    Int_t rc=0;
71    AliTPCtracker tracker(dig);
72    for (Int_t i=0;i<nev;i++){
73      printf("Processing event %d\n",i);
74      AliESD *event=new AliESD(); 
75      rl->GetEvent(i);
76
77      TTree *in=tpcl->TreeR();
78      if (!in) {
79         cerr<<"Can't get clusters tree !\n";
80         return 4;
81      }
82
83      tracker.LoadClusters(in);
84      rc=tracker.Clusters2Tracks(event);
85      tracker.UnloadClusters();
86
87     if (rc==0) {
88         Char_t ename[100]; 
89         sprintf(ename,"%d",i);
90         ef->cd();
91         if (!event->Write(ename)) rc++;
92      } 
93      if (rc) {
94         cerr<<"Something bad happened...\n";
95      }
96      delete event;
97    }
98
99    timer.Stop(); timer.Print();
100  
101    ef->Close();
102
103    delete dig; //Thanks to Mariana Bondila
104
105    delete rl;
106
107    return rc;
108 }