Memory leak corrected
[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
80 for(Int_t iPoint=0; iPoint<gime->CpvRecPoints()->GetEntriesFast(); iPoint++) {
81 rp = new AliPHOSEvalRecPoint(iPoint,AliPHOSEvalRecPoint::cpv);
82 rp->MakeJob();
83 }
84
85 AliPHOSEvalRecPoint pt;
86 pt.UpdateWorkingPool();
87
88 TObjArray * cpvRecPoints = gime->CpvRecPoints() ;
89 Int_t nOldCpv = cpvRecPoints->GetEntries();
90 cpvRecPoints->Delete();
91 cpvRecPoints->Compress();
92
93 for(Int_t i=0; i<wPool->GetEntries(); i++)
94 cpvRecPoints->Add(wPool->At(i));
95
96 wPool->Clear();
97 wPool->Compress();
98
99 wPoolF->Remove(recCpv);
100 delete recCpv;
101
102 cout<<" "<<gime->CpvRecPoints()->GetEntries()<<endl;
103 cout<<" "<<cpvRecPoints->GetEntries()<<" cpvRecPoints."<<endl<<endl;
104
105
106 // Now Emc reconstruction
107
108 AliPHOSRecEmcManager* recEmc = new AliPHOSRecEmcManager();
109 wPoolF->Add(recEmc);
110
111 for(Int_t iPoint=0; iPoint<gime->EmcRecPoints()->GetEntriesFast(); iPoint++) {
112 rp = new AliPHOSEvalRecPoint(iPoint,AliPHOSEvalRecPoint::emc);
113 rp->MakeJob();
114 }
115
116 pt.UpdateWorkingPool();
117
118 TObjArray * emcRecPoints = gime->EmcRecPoints() ;
119 Int_t nOldEmc = emcRecPoints->GetEntries();
120 emcRecPoints->Delete();
121 emcRecPoints->Compress();
122
123 for(Int_t i=0; i<wPool->GetEntries(); i++)
124 emcRecPoints->Add(wPool->At(i));
125
126 wPool->Clear();
127 wPool->Compress();
128
129 wPoolF->Remove(recEmc);
130 delete recEmc;
131
132 cout<<" "<<nOldCpv<<" OLD cpvRecPoints."<<endl;
133 cout<<" "<<gime->CpvRecPoints()->GetEntries()<<endl;
134 cout<<" "<<cpvRecPoints->GetEntries()<<" cpvRecPoints."<<endl<<endl;
135
136 cout<<" "<<nOldEmc<<" OLD emcRecPoints."<<endl;
137 cout<<" "<<gime->EmcRecPoints()->GetEntries()<<endl;
138 cout<<" "<<emcRecPoints->GetEntries()<<" emcRecPoints."<<endl<<endl;
139
140 WriteRecPoints(ievent);
141
142
143 } // loop over events
144
145 if(strstr(option,"tim")) {
146 gBenchmark->Stop("PHOSClusterizer");
147 cout << "AliPHOSClusterizer:" << endl ;
148 cout << " took " << gBenchmark->GetCpuTime("PHOSClusterizer") << " seconds for Clusterizing " << endl;
149 cout << endl ;
150
151 }
152
153}
154
155Int_t AliPHOSClusterizerv2::AreNeighbours(AliPHOSDigit* d1, AliPHOSDigit* d2) const
156{
157 // Points are neighbours if they have common edge.
158 // Points with common vertex are NOT neighbours.
159 // This treatment of neighbourship is the part of
160 // IHEP algorithm of clusterization.
161
162 // Gives the neighbourness of two digits = 0 are not neighbour but continue searching
163 // = 1 are neighbour
164 // = 2 are not neighbour but do not continue searching
165 // The order of d1 and d2 is important: first (d1) should be a digit already in a cluster
166 // which is compared to a digit (d2) not yet in a cluster
167
168 const AliPHOSGeometry * geom = AliPHOSGetter::GetInstance()->PHOSGeometry();
169
170 Int_t rv = 0 ;
171
172 Int_t relid1[4] ;
173 geom->AbsToRelNumbering(d1->GetId(), relid1) ;
174
175 Int_t relid2[4] ;
176 geom->AbsToRelNumbering(d2->GetId(), relid2) ;
177
178 if ( (relid1[0] == relid2[0]) && (relid1[1]==relid2[1]) ) { // inside the same PHOS module and the same PPSD Module
179 Int_t rowdiff = TMath::Abs( relid1[2] - relid2[2] ) ;
180 Int_t coldiff = TMath::Abs( relid1[3] - relid2[3] ) ;
181
182 if ( ( (coldiff < 1) && (rowdiff <= 1) ) || ( ( coldiff <= 1 ) && ( rowdiff < 1 ) ) ){
183 rv = 1 ;
184 }
185 else {
186 if((relid2[2] > relid1[2]) && (relid2[3] > relid1[3]+1))
187 rv = 2; // Difference in row numbers is too large to look further
188 }
189
190 }
191 else {
192
193 if( (relid1[0] < relid2[0]) || (relid1[1] < relid2[1]) )
194 rv=2 ;
195
196 }
197
198// //Do NOT clusterize upper PPSD // YVK 30.09.2001
199// if( IsInPpsd(d1) && IsInPpsd(d2) &&
200// relid1[1] > 0 &&
201// relid1[1] < geom->GetNumberOfPadsPhi()*geom->GetNumberOfPadsPhi() ) rv = 2 ;
202
203 return rv ;
204
205}