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