Updated macro by J. Belikov
[u/mrichter/AliRoot.git] / TPC / AliTPCFindClusters.C
... / ...
CommitLineData
1/****************************************************************************
2 * Origin: I.Belikov, CERN, Jouri.Belikov@cern.ch *
3 ****************************************************************************/
4
5#ifndef __CINT__
6 #include <iostream.h>
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
16Int_t AliTPCFindClusters(Int_t n=1) {
17 TFile *out=TFile::Open("AliTPCclusters.root","new");
18 if (!out->IsOpen()) {cerr<<"Delete old AliTPCclusters.root !\n"; return 1;}
19 TFile *in=TFile::Open("rfio:galice.root");
20 if (!in->IsOpen()) {cerr<<"Can't open galice.root !\n"; return 2;}
21
22 if (!(gAlice=(AliRun*)in->Get("gAlice"))) {
23 cerr<<"gAlice have not been found on galice.root !\n";
24 return 3;
25 }
26
27 TDirectory *cwd = gDirectory;
28
29 AliTPC *TPC = (AliTPC*)gAlice->GetDetector("TPC");
30 Int_t ver = TPC->IsVersion();
31 cerr<<"TPC version "<<ver<<" has been found !\n";
32
33 AliTPCParam *dig=(AliTPCParam *)in->Get("75x40_100x60_150x60");
34 if (!dig) {cerr<<"TPC parameters have not been found !\n"; return 4;}
35
36 TStopwatch timer;
37
38 switch (ver) {
39 case 1:
40 cerr<<"Making clusters...\n";
41 {
42 AliTPCv1 &tpc=*((AliTPCv1*)TPC);
43 tpc.SetParam(dig); timer.Start(); cwd->cd();
44 for(Int_t i=0;i<n;i++){
45 printf("Processing event %d\n",i);
46 gAlice->GetEvent(i);
47 tpc.Hits2Clusters(out,i);
48 }
49 }
50 break;
51 case 2:
52 cerr<<"Looking for clusters...\n";
53 {
54 // delete gAlice; gAlice=0;
55 AliTPCv2 tpc;
56 tpc.SetParam(dig); timer.Start(); cwd->cd();
57 for (Int_t i=0;i<n;i++){
58 printf("Processing event %d\n",i);
59 tpc.Digits2Clusters(out,i);
60 // AliTPCclusterer::Digits2Clusters(dig, out, i);
61 }
62 }
63 break;
64 default:
65 cerr<<"Invalid TPC version !\n";
66 return 5;
67 }
68
69 timer.Stop(); timer.Print();
70
71 delete gAlice; gAlice=0;
72
73 out->Close();
74
75 in->Close();
76
77 return 0;
78}