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