coverity fix
[u/mrichter/AliRoot.git] / TPC / AliTPCFindTracksMI.C
CommitLineData
1c53abe2 1/****************************************************************************
2 * Origin: I.Belikov, CERN, Jouri.Belikov@cern.ch *
3 ****************************************************************************/
4
927d593f 5#if !defined(__CINT__) || defined(__MAKECINT__)
6 #include <Riostream.h>
434772a9 7 #include "AliTPCParam.h"
8 #include "AliTPCtracker.h"
927d593f 9 #include "AliTPCtrackerMI.h"
10 #include "AliRun.h"
927d593f 11 #include "AliRunLoader.h"
12 #include "AliTPCLoader.h"
13 #include "AliESD.h"
434772a9 14 #include "TFile.h"
15 #include "TStopwatch.h"
1c53abe2 16#endif
17
927d593f 18extern AliRun *gAlice;
19
20
434772a9 21Int_t AliTPCFindTracksMI(Int_t N=-1) {
22
1c53abe2 23 cerr<<"Looking for tracks...\n";
1c53abe2 24
434772a9 25 if (gAlice)
26 {
33c3c91a 27 delete AliRunLoader::Instance();
434772a9 28 delete gAlice;
29 gAlice = 0x0;
30 }
31
927d593f 32 AliRunLoader *rl = AliRunLoader::Open("galice.root");
434772a9 33 if (rl == 0x0)
34 {
35 cerr<<"Can not open session"<<endl;
36 return 1;
37 }
927d593f 38 AliTPCLoader *tpcl = (AliTPCLoader*)rl->GetLoader("TPCLoader");
434772a9 39 if (tpcl == 0x0)
40 {
41 cerr<<"Can not get TPC Loader"<<endl;
42 return 1;
43 }
44
45 if (rl->LoadgAlice())
46 {
47 cerr<<"Error occured while l"<<endl;
48 return 1;
49 }
c84a5e9e 50 AliKalmanTrack::SetFieldMap(rl->GetAliRun()->Field());
434772a9 51
52 rl->CdGAFile();
53
927d593f 54 AliTPCParam *param=(AliTPCParam *)gDirectory->Get("75x40_100x60_150x60");
55 if (!param)
434772a9 56 {
927d593f 57 param=(AliTPCParam *)gDirectory->Get("75x40_100x60");
434772a9 58 if (!param)
59 {
60 cerr<<"TPC parameters have not been found !\n";
61 return 1;
62 }
63 else
64 {
65 cout<<"TPC 75x40_100x60 geometry found"<<endl;
66 }
67 }
68 else
69 {
70 cout<<"TPC 75x40_100x60_150x60 geometry found"<<endl;
71 }
1c53abe2 72
434772a9 73
74 tpcl->LoadTracks("recreate");
75
76 Int_t eventn;
77 if (N<=0)
78 {
79 eventn = rl->GetNumberOfEvents();
80 rl->UnloadHeader();
81 }
82 else
83 eventn = N;
84
1c53abe2 85 TStopwatch timer;
1c53abe2 86 Int_t rc=0;
434772a9 87 for (Int_t i=0;i<eventn;i++)
982aff31 88 {
89 rl->GetEvent(i);
434772a9 90 TTree * input = tpcl->TreeR();
91 if (input == 0x0)
92 {
93 tpcl->LoadRecPoints("read");
94 input = tpcl->TreeR();
95 if (input == 0x0)
96 {
97 cerr << "Problems with input tree (TreeR) for event " << i <<endl;
98 continue;
99 }
100 }
101 TTree * output = tpcl->TreeT();
102 if (output == 0x0)
103 {
104 tpcl->MakeTree("T");
105 output = tpcl->TreeT();
106 if (output == 0x0)
107 {
108 cerr << "Problems with output tree (TreeT) for event " << i <<endl;
109 continue;
110 }
111 }
112
113 printf("Processing event %d\n",i);
927d593f 114 AliTPCtrackerMI *tracker = new AliTPCtrackerMI(param);
115 tracker->SetIO();
116 tracker->LoadClusters();
434772a9 117 rc=tracker->Clusters2Tracks();
982aff31 118 tracker->WriteTracks(output);
927d593f 119 tracker->UnloadClusters();
982aff31 120 tpcl->WriteTracks("OVERWRITE");
927d593f 121 //output->GetDirectory()->cd();
122 //output->Write();
434772a9 123 delete tracker;
124 }
1c53abe2 125 timer.Stop(); timer.Print();
927d593f 126 rl->UnloadgAlice();
127
128 delete param;
434772a9 129 delete rl;
1c53abe2 130 return rc;
131}