]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCFindTracksMI.C
Coverity fix
[u/mrichter/AliRoot.git] / TPC / AliTPCFindTracksMI.C
1 /****************************************************************************
2  *           Origin: I.Belikov, CERN, Jouri.Belikov@cern.ch                 *
3  ****************************************************************************/
4
5 #if !defined(__CINT__) || defined(__MAKECINT__)
6   #include <Riostream.h>
7   #include "AliTPCParam.h"
8   #include "AliTPCtracker.h"
9   #include "AliTPCtrackerMI.h"
10   #include "AliRun.h"
11   #include "AliRunLoader.h"
12   #include "AliTPCLoader.h"
13   #include "AliESD.h"
14   #include "TFile.h"
15   #include "TStopwatch.h"
16 #endif
17
18 extern AliRun *gAlice;
19
20
21 Int_t AliTPCFindTracksMI(Int_t N=-1) {
22
23    cerr<<"Looking for tracks...\n";
24
25    if (gAlice)
26     {
27      delete AliRunLoader::Instance();
28      delete gAlice;
29      gAlice = 0x0;
30     }
31     
32    AliRunLoader *rl = AliRunLoader::Open("galice.root");
33    if (rl == 0x0)
34     {
35       cerr<<"Can not open session"<<endl;
36       return 1;
37     }
38    AliTPCLoader *tpcl = (AliTPCLoader*)rl->GetLoader("TPCLoader");
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     }
50    AliKalmanTrack::SetFieldMap(rl->GetAliRun()->Field());
51    
52    rl->CdGAFile();
53    
54    AliTPCParam *param=(AliTPCParam *)gDirectory->Get("75x40_100x60_150x60");
55    if (!param) 
56     {
57      param=(AliTPCParam *)gDirectory->Get("75x40_100x60");
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     }
72
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     
85    TStopwatch timer;
86    Int_t rc=0;
87    for (Int_t i=0;i<eventn;i++)
88     { 
89       rl->GetEvent(i);
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);
114       AliTPCtrackerMI *tracker = new AliTPCtrackerMI(param);
115       tracker->SetIO();
116       tracker->LoadClusters();
117       rc=tracker->Clusters2Tracks();
118       tracker->WriteTracks(output);
119       tracker->UnloadClusters();
120       tpcl->WriteTracks("OVERWRITE");
121       //output->GetDirectory()->cd();
122       //output->Write();
123       delete tracker;
124     }
125    timer.Stop(); timer.Print();
126    rl->UnloadgAlice();
127    
128    delete param; 
129    delete rl;
130    return rc;
131 }