Transition to NewIO
[u/mrichter/AliRoot.git] / TPC / AliTPCFindClusters.C
CommitLineData
c2b0eaa4 1/****************************************************************************
2 * Origin: I.Belikov, CERN, Jouri.Belikov@cern.ch *
3 ****************************************************************************/
4
b9de75e1 5#ifndef __CINT__
ddae8318 6 #include <Riostream.h>
b9de75e1 7 #include "AliRun.h"
8 #include "AliTPCv1.h"
9 #include "AliTPCv2.h"
10 #include "AliTPCParam.h"
11
12 #include "TFile.h"
13 #include "TStopwatch.h"
14#endif
15
88cb7938 16Int_t AliTPCFindClusters(Int_t N=-1)
17 {
18
19 if (gAlice)
20 {
21 delete gAlice->GetRunLoader();
22 delete gAlice;//if everything was OK here it is already NULL
23 gAlice = 0x0;
24 }
25
26 AliRunLoader* rl = AliRunLoader::Open("galice.root");
27 if (rl == 0x0)
28 {
29 cerr<<"Can not open session"<<endl;
30 return 1;
31 }
32
33 if (rl->LoadgAlice())
34 {
35 cerr<<"Error occured while l"<<endl;
36 return 1;
37 }
38 AliKalmanTrack::SetConvConst(1000/0.299792458/rl->GetAliRun()->Field()->SolenoidField());
39
40 tpcl = (AliTPCLoader*)rl->GetLoader("TPCLoader");
41 if (tpcl == 0x0)
42 {
43 cerr<<"Can not get TPC Loader"<<endl;
44 return 1;
45 }
73042f01 46
88cb7938 47 gAlice=rl->GetAliRun();
48 if (!gAlice) {
49 cerr<<"Can't get gAlice !\n";
50 return 1;
73042f01 51 }
52
73042f01 53 AliTPC *TPC = (AliTPC*)gAlice->GetDetector("TPC");
54 Int_t ver = TPC->IsVersion();
55 cerr<<"TPC version "<<ver<<" has been found !\n";
56
88cb7938 57 rl->CdGAFile();
58 AliTPCParam *dig=(AliTPCParam *)gDirectory->Get("75x40_100x60_150x60");
59 if (!dig)
60 {
61 dig=(AliTPCParam *)gDirectory->Get("75x40_100x60");
62 if (!param)
63 {
64 cerr<<"TPC parameters have not been found !\n";
65 return 1;
66 }
67 else
68 {
69 cout<<"TPC 75x40_100x60 geometry found"<<endl;
70 }
71 }
72 else
73 {
74 cout<<"TPC 75x40_100x60_150x60 geometry found"<<endl;
75 }
73042f01 76
88cb7938 77 Int_t n;
78 if (N<=0) n = rl->GetNumberOfEvents();
79 else n=N;
80
73042f01 81 TStopwatch timer;
82
83 switch (ver) {
84 case 1:
85 cerr<<"Making clusters...\n";
86 {
87 AliTPCv1 &tpc=*((AliTPCv1*)TPC);
afc42102 88 tpc.SetParam(dig); timer.Start(); cwd->cd();
88cb7938 89 tpc.SetLoader(tpcl);
90 tpcl->LoadHits("read");
91 tpcl->LoadRecPoints("recreate");
afc42102 92 for(Int_t i=0;i<n;i++){
93 printf("Processing event %d\n",i);
88cb7938 94 rl->GetEvent(i);
afc42102 95 tpc.Hits2Clusters(out,i);
96 }
73042f01 97 }
98 break;
99 case 2:
100 cerr<<"Looking for clusters...\n";
101 {
afc42102 102 // delete gAlice; gAlice=0;
88cb7938 103 AliTPCv2 * tpc = new AliTPCv2();
104 tpc->SetLoader(tpcl);
105 tpcl->LoadDigits("read");
106 tpcl->LoadRecPoints("recreate");
107
108 tpc->SetParam(dig); timer.Start();
109 for (Int_t i=0;i<n;i++)
110 {
111 printf("Processing event %d\n",i);
112 tpc->Digits2Clusters(i);
113 //AliTPCclusterer::Digits2Clusters(dig, out, i);
afc42102 114 }
88cb7938 115 delete tpc;
73042f01 116 }
117 break;
118 default:
119 cerr<<"Invalid TPC version !\n";
88cb7938 120 delete rl;
73042f01 121 return 5;
122 }
123
124 timer.Stop(); timer.Print();
125
88cb7938 126 delete rl;
73042f01 127 return 0;
128}