doxy: all TPC root converted
[u/mrichter/AliRoot.git] / TPC / AliTPCFindClusters.C
CommitLineData
3a4edebe 1/// \file AliTPCFindClusters.C
2///
3/// \author M.Ivanov marian.ivanov@cern.ch
4///
5/// macro to create array of clusters from TPC digits
6/// input files - galice.root
7/// digits.root - file with digits - usualy use link to galice.root
8/// - in splitted mode - neccesary to create link to proper file
9///
10/// output file - AliTPCclusters.root
11/// - to be used by AliTPCTrackFinderMI.C
12///
13/// Warning - if cluster file AliTPCclusters.root already exist - macro exit and don't produce anything
829455ad 14
15#ifndef __CINT__
16#include <iostream.h>
17#include "AliRun.h"
18#include "AliTPCv1.h"
19#include "AliTPCv2.h"
20#include "AliTPCParam.h"
21#include "AliTPCclusterer.h"
22#include "TFile.h"
23#include "TStopwatch.h"
24#include "TTree.h"
b9de75e1 25#endif
26
829455ad 27Int_t AliTPCFindClustersMI(Int_t n=1) {
28
88cb7938 29 AliRunLoader* rl = AliRunLoader::Open("galice.root");
c630aafd 30 if (rl == 0x0) {
88cb7938 31 cerr<<"Can not open session"<<endl;
32 return 1;
c630aafd 33 }
88cb7938 34
c630aafd 35 AliTPCLoader *tpcl = (AliTPCLoader*)rl->GetLoader("TPCLoader");
36 if (tpcl == 0x0) {
88cb7938 37 cerr<<"Can not get TPC Loader"<<endl;
38 return 1;
c630aafd 39 }
73042f01 40
829455ad 41 if (tpcl->LoadDigits()) {
42 cerr<<"Error occured while loading digits"<<endl;
43 return 1;
44 }
45
46 if (tpcl->LoadRecPoints("recreate")) {
47 cerr<<"Error occured while loading digits"<<endl;
48 return 1;
49 }
50
51 if (rl->LoadgAlice()) {
52 cerr<<"Error occured while l"<<endl;
53 return 1;
54 }
55
88cb7938 56 gAlice=rl->GetAliRun();
57 if (!gAlice) {
58 cerr<<"Can't get gAlice !\n";
59 return 1;
73042f01 60 }
61
829455ad 62 TDirectory *cwd = gDirectory;
63
73042f01 64 AliTPC *TPC = (AliTPC*)gAlice->GetDetector("TPC");
65 Int_t ver = TPC->IsVersion();
66 cerr<<"TPC version "<<ver<<" has been found !\n";
829455ad 67
88cb7938 68 rl->CdGAFile();
88cb7938 69
829455ad 70 AliTPCParam *dig=(AliTPCParam *)gDirectory->Get("75x40_100x60_150x60");
71 if (!dig) {cerr<<"TPC parameters have not been found !\n"; return 4;}
c630aafd 72
73042f01 73 TStopwatch timer;
74
829455ad 75 switch (ver) {
76 case 1:
73042f01 77 cerr<<"Making clusters...\n";
829455ad 78 {
79 AliTPCv1 &tpc=*((AliTPCv1*)TPC);
80 tpc.SetParam(dig); timer.Start(); cwd->cd();
81 for(Int_t i=0;i<n;i++){
88cb7938 82 printf("Processing event %d\n",i);
829455ad 83 gAlice->GetEvent(i);
84 tpc.Hits2Clusters(out,i);
85 }
73042f01 86 }
829455ad 87 break;
88 case 2:
89 cerr<<"Looking for clusters...\n";
90 {
91 // delete gAlice; gAlice=0;
92 AliTPCv2 tpc;
93 tpc.SetParam(dig); timer.Start(); cwd->cd();
94
95 n = rl->GetNumberOfEvents();
96 for (Int_t i=0;i<n;i++)
97 {
98 rl->GetEvent(i);
99 AliTPCclusterer clusterer(dig);
100
101 TTree * input = tpcl->TreeD();
102 if (input == 0x0)
103 {
104 cerr << "Can not get TreeD for event " << i <<endl;
105 continue;
106 }
107
108 TTree * output = tpcl->TreeR();
109 if (output == 0x0)
110 {
111 tpcl->MakeTree("R");
112 output = tpcl->TreeR();
113 if (output == 0x0)
114 {
115 cerr << "Problems with output tree (TreeR) for event " << i <<endl;
116 continue;
117 }
118 }
119
120 printf("Processing event %d\n",i);
121 clusterer.SetInput(input);
122 clusterer.SetOutput(output);
123 clusterer.Digits2Clusters();
124
125 tpcl->WriteRecPoints("OVERWRITE");
126 }
127 }
128 break;
129 default:
130 cerr<<"Invalid TPC version !\n";
131 return 5;
73042f01 132 }
829455ad 133
73042f01 134 timer.Stop(); timer.Print();
829455ad 135
136 delete rl;//cleans everything
c630aafd 137
73042f01 138 return 0;
139}