]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCFindTracksMI.C
Updated version (M.Ivanov)
[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 "AliMagF.h"
12   #include "AliRunLoader.h"
13   #include "AliTPCLoader.h"
14   #include "AliESD.h"
15   #include "TFile.h"
16   #include "TStopwatch.h"
17 #endif
18
19 extern AliRun *gAlice;
20
21
22 Int_t AliTPCFindTracksMI(Int_t N=-1) {
23
24    cerr<<"Looking for tracks...\n";
25
26    if (gAlice)
27     {
28      delete gAlice->GetRunLoader();
29      delete gAlice;
30      gAlice = 0x0;
31     }
32     
33    AliRunLoader *rl = AliRunLoader::Open("galice.root");
34    if (rl == 0x0)
35     {
36       cerr<<"Can not open session"<<endl;
37       return 1;
38     }
39    AliTPCLoader *tpcl = (AliTPCLoader*)rl->GetLoader("TPCLoader");
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     }
51    AliKalmanTrack::SetConvConst(1000/0.299792458/rl->GetAliRun()->Field()->SolenoidField());
52    
53    rl->CdGAFile();
54    
55    AliTPCParam *param=(AliTPCParam *)gDirectory->Get("75x40_100x60_150x60");
56    if (!param) 
57     {
58      param=(AliTPCParam *)gDirectory->Get("75x40_100x60");
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     }
73
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     
86    TStopwatch timer;
87    Int_t rc=0;
88    for (Int_t i=0;i<eventn;i++)
89     { 
90       rl->GetEvent(i);
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);
115       AliTPCtrackerMI *tracker = new AliTPCtrackerMI(param);
116       tracker->SetIO();
117       tracker->LoadClusters();
118       rc=tracker->Clusters2Tracks();
119       tracker->WriteTracks(output);
120       tracker->UnloadClusters();
121       tpcl->WriteTracks("OVERWRITE");
122       //output->GetDirectory()->cd();
123       //output->Write();
124       delete tracker;
125     }
126    timer.Stop(); timer.Print();
127    rl->UnloadgAlice();
128    
129    delete param; 
130    delete rl;
131    return rc;
132 }