Changes due to the coding conventions
[u/mrichter/AliRoot.git] / TPC / AliTPCFindTracks.C
CommitLineData
88cb7938 1/****************************************************************************
2 * Origin: I.Belikov, CERN, Jouri.Belikov@cern.ch *
3 ****************************************************************************/
4
c630aafd 5#if !defined(__CINT__) || defined(__MAKECINT__)
88cb7938 6 #include <iostream.h>
7f6ddf58 7 #include "AliTPCParam.h"
b9de75e1 8 #include "AliTPCtracker.h"
9ca85d97 9 #include "AliTPCpidESD.h"
c630aafd 10 #include "AliRun.h"
11 #include "AliMagF.h"
12 #include "AliRunLoader.h"
13 #include "AliTPCLoader.h"
9ca85d97 14 #include "AliESDpid.h"
a62f4fcc 15 #include "AliESD.h"
b9de75e1 16
17 #include "TFile.h"
18 #include "TStopwatch.h"
19#endif
20
c630aafd 21extern AliRun *gAlice;
22
23Int_t AliTPCFindTracks(Int_t nev=5) {
88cb7938 24
73042f01 25 cerr<<"Looking for tracks...\n";
26
c630aafd 27 if (gAlice) {
88cb7938 28 delete gAlice->GetRunLoader();
29 delete gAlice;
30 gAlice = 0x0;
c630aafd 31 }
32
33 AliRunLoader *rl = AliRunLoader::Open("galice.root");
34 if (rl == 0x0) {
88cb7938 35 cerr<<"Can not open session"<<endl;
36 return 1;
c630aafd 37 }
38
39 AliTPCLoader *tpcl = (AliTPCLoader*)rl->GetLoader("TPCLoader");
40 if (tpcl == 0x0) {
88cb7938 41 cerr<<"Can not get TPC Loader"<<endl;
42 return 1;
c630aafd 43 }
88cb7938 44
c630aafd 45 if (rl->LoadgAlice()) {
46 cerr<<"Error occured while loading gAlice"<<endl;
88cb7938 47 return 1;
c630aafd 48 }
a62f4fcc 49
c630aafd 50 AliKalmanTrack::SetConvConst(
a62f4fcc 51 1000/0.299792458/rl->GetAliRun()->Field()->SolenoidField()
c630aafd 52 );
a62f4fcc 53
88cb7938 54 rl->CdGAFile();
55 AliTPCParam *dig=(AliTPCParam *)gDirectory->Get("75x40_100x60_150x60");
c630aafd 56 if (!dig) {
88cb7938 57 cerr<<"TPC parameters have not been found !\n";
58 return 1;
c630aafd 59 }
60
a62f4fcc 61 //rl->UnloadgAlice();
c630aafd 62
88cb7938 63 tpcl->LoadRecPoints("read");
73042f01 64
c630aafd 65 if (nev>rl->GetNumberOfEvents()) nev=rl->GetNumberOfEvents();
88cb7938 66
a62f4fcc 67 TFile *ef=TFile::Open("AliESDtpc.root","RECREATE");
68 if ((!ef)||(!ef->IsOpen())) {
69 cerr<<"Can't AliESDtpc.root !\n"; return 1;
70 }
73042f01 71 TStopwatch timer;
7f6ddf58 72 Int_t rc=0;
c630aafd 73 AliTPCtracker tracker(dig);
9ca85d97 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);
c630aafd 78 for (Int_t i=0;i<nev;i++){
afc42102 79 printf("Processing event %d\n",i);
a62f4fcc 80 AliESD *event=new AliESD();
c630aafd 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
a62f4fcc 89 tracker.LoadClusters(in);
90 rc=tracker.Clusters2Tracks(event);
9ca85d97 91 tpcPID.MakePID(event); // Preliminary PID
92 AliESDpid::MakePID(event); // for the ITS tracker
a62f4fcc 93 tracker.UnloadClusters();
94
9ca85d97 95 if (rc==0) {
a62f4fcc 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";
c630aafd 103 }
a62f4fcc 104 delete event;
afc42102 105 }
c630aafd 106
73042f01 107 timer.Stop(); timer.Print();
b9de75e1 108
a62f4fcc 109 ef->Close();
110
88cb7938 111 delete dig; //Thanks to Mariana Bondila
c630aafd 112
88cb7938 113 delete rl;
c630aafd 114
7f6ddf58 115 return rc;
73042f01 116}