Cosmetic changes, and a new function AliL3Hough::ProcessPatchIter.
[u/mrichter/AliRoot.git] / PHOS / AliPHOSClusterizerv2.cxx
CommitLineData
cbd576a6 1// --- ROOT system ---
2#include "TBenchmark.h"
3#include "TROOT.h"
4
5// --- Standard library ---
6#include <iostream.h>
7#include <iomanip.h>
8
9// --- AliRoot header files ---
10#include "AliPHOSClusterizerv2.h"
11#include "AliPHOSGetter.h"
12#include "TFolder.h"
13#include "AliPHOSEvalRecPoint.h"
14#include "AliPHOSRecCpvManager.h"
15#include "AliPHOSRecEmcManager.h"
16
17ClassImp(AliPHOSClusterizerv2)
18
19AliPHOSClusterizerv2::AliPHOSClusterizerv2() : AliPHOSClusterizerv1()
20{}
21
22AliPHOSClusterizerv2::AliPHOSClusterizerv2(const char* File, const char* name):
23 AliPHOSClusterizerv1(File,name)
24{}
25
26void AliPHOSClusterizerv2::GetNumberOfClustersFound(int* numb) const
27{
28
29 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
30 numb[0] = gime->EmcRecPoints()->GetEntries();
31 numb[1] = gime->CpvRecPoints()->GetEntries();
32}
33
34void AliPHOSClusterizerv2::Exec(Option_t* option)
35{
36
37 if(strstr(option,"tim"))
38 gBenchmark->Start("PHOSClusterizer");
39
40 if(strstr(option,"print"))
41 Print("") ;
42
43 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
44
45 TFolder* aliceF = (TFolder*)gROOT->FindObjectAny("YSAlice");
46 TFolder* storage = (TFolder*)aliceF->FindObject("WhiteBoard/RecPoints/PHOS");
47 TFolder* wPoolF = storage->AddFolder("SmP","SmartRecPoints for PHOS");
48
49 TObjArray* wPool = new TObjArray(400);
50 wPool->SetName("SmartPoints");
51 wPoolF->Add(wPool);
52 wPoolF->Add(this);
53
54 Int_t nevents = (Int_t) gAlice->TreeE()->GetEntries() ;
55 Int_t ievent ;
56
57 for(ievent = 0; ievent<nevents; ievent++) {
58
59 gAlice->GetEvent(ievent) ;
60 gAlice->SetEvent(ievent) ;
61
62 gime->Event(ievent,"D") ;
63// if(!ReadDigits(ievent)) //reads digits for event fEvent
64// continue;
65
66 cout<<" MakeClusters invoked..";
67 MakeClusters() ;
68 cout<<" done."<<endl;
69
70
71 //SmartRecPoints will communicate with wPool.
72
73 AliPHOSEvalRecPoint* rp=0;
74
75 // CPV reconstruction
76
77 AliPHOSRecCpvManager* recCpv = new AliPHOSRecCpvManager();
78 wPoolF->Add(recCpv);
79
c9eeb00e 80 Int_t iPoint; //loop variable
81
82 for(iPoint=0; iPoint<gime->CpvRecPoints()->GetEntriesFast(); iPoint++) {
cbd576a6 83 rp = new AliPHOSEvalRecPoint(iPoint,AliPHOSEvalRecPoint::cpv);
84 rp->MakeJob();
85 }
86
87 AliPHOSEvalRecPoint pt;
88 pt.UpdateWorkingPool();
89
90 TObjArray * cpvRecPoints = gime->CpvRecPoints() ;
91 Int_t nOldCpv = cpvRecPoints->GetEntries();
92 cpvRecPoints->Delete();
93 cpvRecPoints->Compress();
94
c9eeb00e 95 Int_t i; //loop variable
96
97 for(i=0; i<wPool->GetEntries(); i++)
cbd576a6 98 cpvRecPoints->Add(wPool->At(i));
99
100 wPool->Clear();
101 wPool->Compress();
102
103 wPoolF->Remove(recCpv);
104 delete recCpv;
105
106 cout<<" "<<gime->CpvRecPoints()->GetEntries()<<endl;
107 cout<<" "<<cpvRecPoints->GetEntries()<<" cpvRecPoints."<<endl<<endl;
108
109
110 // Now Emc reconstruction
111
112 AliPHOSRecEmcManager* recEmc = new AliPHOSRecEmcManager();
113 wPoolF->Add(recEmc);
114
c9eeb00e 115 for(iPoint=0; iPoint<gime->EmcRecPoints()->GetEntriesFast(); iPoint++) {
40b23f22 116 rp = new AliPHOSEvalRecPoint(iPoint,(Bool_t)AliPHOSEvalRecPoint::emc);
cbd576a6 117 rp->MakeJob();
118 }
119
120 pt.UpdateWorkingPool();
121
122 TObjArray * emcRecPoints = gime->EmcRecPoints() ;
123 Int_t nOldEmc = emcRecPoints->GetEntries();
124 emcRecPoints->Delete();
125 emcRecPoints->Compress();
126
c9eeb00e 127 for(i=0; i<wPool->GetEntries(); i++)
cbd576a6 128 emcRecPoints->Add(wPool->At(i));
129
130 wPool->Clear();
131 wPool->Compress();
132
133 wPoolF->Remove(recEmc);
134 delete recEmc;
135
136 cout<<" "<<nOldCpv<<" OLD cpvRecPoints."<<endl;
137 cout<<" "<<gime->CpvRecPoints()->GetEntries()<<endl;
138 cout<<" "<<cpvRecPoints->GetEntries()<<" cpvRecPoints."<<endl<<endl;
139
140 cout<<" "<<nOldEmc<<" OLD emcRecPoints."<<endl;
141 cout<<" "<<gime->EmcRecPoints()->GetEntries()<<endl;
142 cout<<" "<<emcRecPoints->GetEntries()<<" emcRecPoints."<<endl<<endl;
143
144 WriteRecPoints(ievent);
145
146
147 } // loop over events
148
149 if(strstr(option,"tim")) {
150 gBenchmark->Stop("PHOSClusterizer");
151 cout << "AliPHOSClusterizer:" << endl ;
152 cout << " took " << gBenchmark->GetCpuTime("PHOSClusterizer") << " seconds for Clusterizing " << endl;
153 cout << endl ;
154
155 }
156
157}
158
159Int_t AliPHOSClusterizerv2::AreNeighbours(AliPHOSDigit* d1, AliPHOSDigit* d2) const
160{
161 // Points are neighbours if they have common edge.
162 // Points with common vertex are NOT neighbours.
163 // This treatment of neighbourship is the part of
164 // IHEP algorithm of clusterization.
165
166 // Gives the neighbourness of two digits = 0 are not neighbour but continue searching
167 // = 1 are neighbour
168 // = 2 are not neighbour but do not continue searching
169 // The order of d1 and d2 is important: first (d1) should be a digit already in a cluster
170 // which is compared to a digit (d2) not yet in a cluster
171
172 const AliPHOSGeometry * geom = AliPHOSGetter::GetInstance()->PHOSGeometry();
173
174 Int_t rv = 0 ;
175
176 Int_t relid1[4] ;
177 geom->AbsToRelNumbering(d1->GetId(), relid1) ;
178
179 Int_t relid2[4] ;
180 geom->AbsToRelNumbering(d2->GetId(), relid2) ;
181
182 if ( (relid1[0] == relid2[0]) && (relid1[1]==relid2[1]) ) { // inside the same PHOS module and the same PPSD Module
183 Int_t rowdiff = TMath::Abs( relid1[2] - relid2[2] ) ;
184 Int_t coldiff = TMath::Abs( relid1[3] - relid2[3] ) ;
185
186 if ( ( (coldiff < 1) && (rowdiff <= 1) ) || ( ( coldiff <= 1 ) && ( rowdiff < 1 ) ) ){
187 rv = 1 ;
188 }
189 else {
190 if((relid2[2] > relid1[2]) && (relid2[3] > relid1[3]+1))
191 rv = 2; // Difference in row numbers is too large to look further
192 }
193
194 }
195 else {
196
197 if( (relid1[0] < relid2[0]) || (relid1[1] < relid2[1]) )
198 rv=2 ;
199
200 }
201
202// //Do NOT clusterize upper PPSD // YVK 30.09.2001
203// if( IsInPpsd(d1) && IsInPpsd(d2) &&
204// relid1[1] > 0 &&
205// relid1[1] < geom->GetNumberOfPadsPhi()*geom->GetNumberOfPadsPhi() ) rv = 2 ;
206
207 return rv ;
208
209}