]>
Commit | Line | Data |
---|---|---|
1 | /**************************************************************************** | |
2 | * Origin: I.Belikov, CERN, Jouri.Belikov@cern.ch * | |
3 | ****************************************************************************/ | |
4 | ||
5 | #if !defined(__CINT__) || defined(__MAKECINT__) | |
6 | #include <Riostream.h> | |
7 | ||
8 | #include "AliRun.h" | |
9 | #include "AliRunLoader.h" | |
10 | #include "AliTPCLoader.h" | |
11 | #include "AliTPCv1.h" | |
12 | #include "AliTPCParam.h" | |
13 | #include "AliTPCclusterer.h" | |
14 | ||
15 | #include "TTree.h" | |
16 | #include "TStopwatch.h" | |
17 | #endif | |
18 | ||
19 | extern AliRun *gAlice; | |
20 | ||
21 | Int_t AliTPCFindClusters(Int_t nev=5) { | |
22 | ||
23 | if (gAlice) { | |
24 | delete gAlice->GetRunLoader(); | |
25 | delete gAlice;//if everything was OK here it is already NULL | |
26 | gAlice = 0x0; | |
27 | } | |
28 | ||
29 | AliRunLoader* rl = AliRunLoader::Open("galice.root"); | |
30 | if (rl == 0x0) { | |
31 | cerr<<"Can not open session"<<endl; | |
32 | return 1; | |
33 | } | |
34 | ||
35 | if (rl->LoadgAlice()) { | |
36 | cerr<<"Error occured while l"<<endl; | |
37 | return 1; | |
38 | } | |
39 | ||
40 | AliTPCLoader *tpcl = (AliTPCLoader*)rl->GetLoader("TPCLoader"); | |
41 | if (tpcl == 0x0) { | |
42 | cerr<<"Can not get TPC Loader"<<endl; | |
43 | return 1; | |
44 | } | |
45 | ||
46 | gAlice=rl->GetAliRun(); | |
47 | if (!gAlice) { | |
48 | cerr<<"Can't get gAlice !\n"; | |
49 | return 1; | |
50 | } | |
51 | ||
52 | AliTPC *TPC = (AliTPC*)gAlice->GetDetector("TPC"); | |
53 | Int_t ver = TPC->IsVersion(); | |
54 | cerr<<"TPC version "<<ver<<" has been found !\n"; | |
55 | ||
56 | rl->CdGAFile(); | |
57 | AliTPCParam *dig=(AliTPCParam *)gDirectory->Get("75x40_100x60_150x60"); | |
58 | if (!dig) { | |
59 | cerr<<"TPC parameters have not been found !\n"; | |
60 | return 1; | |
61 | } | |
62 | ||
63 | if (nev>rl->GetNumberOfEvents()) nev=rl->GetNumberOfEvents(); | |
64 | ||
65 | tpcl->LoadRecPoints("recreate"); | |
66 | if (ver==1) tpcl->LoadHits("read"); | |
67 | else tpcl->LoadDigits("read"); | |
68 | ||
69 | TStopwatch timer; | |
70 | ||
71 | if (ver==1) { | |
72 | cerr<<"Making clusters...\n"; | |
73 | AliTPCv1 &tpc=*((AliTPCv1*)TPC); | |
74 | tpc.SetParam(dig); | |
75 | tpc.SetLoader(tpcl); | |
76 | rl->LoadKinematics(); | |
77 | timer.Start(); | |
78 | for(Int_t i=0;i<nev;i++) { | |
79 | printf("Processing event %d\n",i); | |
80 | rl->GetEvent(i); | |
81 | tpc.Hits2Clusters(i); | |
82 | } | |
83 | } else if (ver==2) { | |
84 | cerr<<"Looking for clusters...\n"; | |
85 | AliTPCclusterer *dummy=new AliTPCclusterer(dig), &clusterer=*dummy; | |
86 | timer.Start(); | |
87 | for (Int_t i=0;i<nev;i++) { | |
88 | printf("Processing event %d\n",i); | |
89 | rl->GetEvent(i); | |
90 | ||
91 | TTree *out=tpcl->TreeR(); | |
92 | if (!out) { | |
93 | tpcl->MakeTree("R"); | |
94 | out=tpcl->TreeR(); | |
95 | } | |
96 | TTree *in=tpcl->TreeD(); | |
97 | if (!in) { | |
98 | cerr<<"Can't get digits tree !\n"; | |
99 | return 4; | |
100 | } | |
101 | ||
102 | clusterer.Digits2Clusters(in,out); | |
103 | ||
104 | tpcl->WriteRecPoints("OVERWRITE"); | |
105 | } | |
106 | delete dummy; | |
107 | delete dig; | |
108 | } else { | |
109 | cerr<<"Invalid TPC version !\n"; | |
110 | delete rl; | |
111 | return 5; | |
112 | } | |
113 | ||
114 | timer.Stop(); timer.Print(); | |
115 | ||
116 | delete rl; | |
117 | ||
118 | return 0; | |
119 | } |