removed iostream
[u/mrichter/AliRoot.git] / PHOS / AliPHOSClusterizerv2.cxx
CommitLineData
cbd576a6 1// --- ROOT system ---
2#include "TBenchmark.h"
3#include "TROOT.h"
4
5// --- Standard library ---
cbd576a6 6
7// --- AliRoot header files ---
8#include "AliPHOSClusterizerv2.h"
9#include "AliPHOSGetter.h"
10#include "TFolder.h"
11#include "AliPHOSEvalRecPoint.h"
12#include "AliPHOSRecCpvManager.h"
13#include "AliPHOSRecEmcManager.h"
14
15ClassImp(AliPHOSClusterizerv2)
16
17AliPHOSClusterizerv2::AliPHOSClusterizerv2() : AliPHOSClusterizerv1()
18{}
19
fbf811ec 20AliPHOSClusterizerv2::AliPHOSClusterizerv2(const char * headerFile, const char * name, const Bool_t toSplit):
21AliPHOSClusterizerv1(headerFile,name,toSplit)
cbd576a6 22{}
23
24void AliPHOSClusterizerv2::GetNumberOfClustersFound(int* numb) const
25{
26
27 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
28 numb[0] = gime->EmcRecPoints()->GetEntries();
29 numb[1] = gime->CpvRecPoints()->GetEntries();
30}
31
32void AliPHOSClusterizerv2::Exec(Option_t* option)
33{
34
35 if(strstr(option,"tim"))
36 gBenchmark->Start("PHOSClusterizer");
37
38 if(strstr(option,"print"))
39 Print("") ;
40
41 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
42
fbf811ec 43 TFolder* storage = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/RecData/RecPoints/PHOS"));
44 TFolder* wPoolF = storage->AddFolder("SmP","SmartRecPoints for PHOS");
45
cbd576a6 46 TObjArray* wPool = new TObjArray(400);
47 wPool->SetName("SmartPoints");
48 wPoolF->Add(wPool);
49 wPoolF->Add(this);
50
51 Int_t nevents = (Int_t) gAlice->TreeE()->GetEntries() ;
52 Int_t ievent ;
53
54 for(ievent = 0; ievent<nevents; ievent++) {
55
56 gAlice->GetEvent(ievent) ;
57 gAlice->SetEvent(ievent) ;
58
59 gime->Event(ievent,"D") ;
60// if(!ReadDigits(ievent)) //reads digits for event fEvent
61// continue;
62
21cd0c07 63 Info("Exec", "MakeClusters invoked..") ;
cbd576a6 64 MakeClusters() ;
21cd0c07 65 Info("Exec", "MakeClusters done.") ;
cbd576a6 66
67
68 //SmartRecPoints will communicate with wPool.
69
70 AliPHOSEvalRecPoint* rp=0;
71
72 // CPV reconstruction
73
74 AliPHOSRecCpvManager* recCpv = new AliPHOSRecCpvManager();
75 wPoolF->Add(recCpv);
76
c9eeb00e 77 Int_t iPoint; //loop variable
78
79 for(iPoint=0; iPoint<gime->CpvRecPoints()->GetEntriesFast(); iPoint++) {
cbd576a6 80 rp = new AliPHOSEvalRecPoint(iPoint,AliPHOSEvalRecPoint::cpv);
81 rp->MakeJob();
82 }
83
84 AliPHOSEvalRecPoint pt;
85 pt.UpdateWorkingPool();
86
87 TObjArray * cpvRecPoints = gime->CpvRecPoints() ;
88 Int_t nOldCpv = cpvRecPoints->GetEntries();
89 cpvRecPoints->Delete();
90 cpvRecPoints->Compress();
91
c9eeb00e 92 Int_t i; //loop variable
93
94 for(i=0; i<wPool->GetEntries(); i++)
cbd576a6 95 cpvRecPoints->Add(wPool->At(i));
96
97 wPool->Clear();
98 wPool->Compress();
99
100 wPoolF->Remove(recCpv);
101 delete recCpv;
102
21cd0c07 103 Info("Exec", " %d", gime->CpvRecPoints()->GetEntries() ) ;
104 Info("Exec", " %d cpvRecPoints", cpvRecPoints->GetEntries() ) ;
cbd576a6 105
106
107 // Now Emc reconstruction
108
109 AliPHOSRecEmcManager* recEmc = new AliPHOSRecEmcManager();
110 wPoolF->Add(recEmc);
111
c9eeb00e 112 for(iPoint=0; iPoint<gime->EmcRecPoints()->GetEntriesFast(); iPoint++) {
40b23f22 113 rp = new AliPHOSEvalRecPoint(iPoint,(Bool_t)AliPHOSEvalRecPoint::emc);
cbd576a6 114 rp->MakeJob();
115 }
116
117 pt.UpdateWorkingPool();
118
119 TObjArray * emcRecPoints = gime->EmcRecPoints() ;
120 Int_t nOldEmc = emcRecPoints->GetEntries();
121 emcRecPoints->Delete();
122 emcRecPoints->Compress();
123
c9eeb00e 124 for(i=0; i<wPool->GetEntries(); i++)
cbd576a6 125 emcRecPoints->Add(wPool->At(i));
126
127 wPool->Clear();
128 wPool->Compress();
129
130 wPoolF->Remove(recEmc);
131 delete recEmc;
132
21cd0c07 133 TString message ;
134 message = " %d OLD cpvRecPoints\n" ;
135 message += " %d\n" ;
136 message += " %d cpvRecPoints\n" ;
cbd576a6 137
21cd0c07 138 message += " %d OLD emcRecPoints " ;
139 message += " %d\n" ;
140 message += " %d emcRecPoints\n" ;
141
142 Info("Exec", message.Data(),
143 nOldCpv,
144 gime->CpvRecPoints()->GetEntries(),cpvRecPoints->GetEntries(),
145 nOldEmc,
146 gime->EmcRecPoints()->GetEntries(), emcRecPoints->GetEntries() ) ;
cbd576a6 147
148 WriteRecPoints(ievent);
149
150
151 } // loop over events
152
153 if(strstr(option,"tim")) {
154 gBenchmark->Stop("PHOSClusterizer");
21cd0c07 155 Info("Exec","took %f seconds for Clusterizing", gBenchmark->GetCpuTime("PHOSClusterizer") ) ;
cbd576a6 156 }
cbd576a6 157}
fbf811ec 158//---------------------------------------------------------------------------------
cbd576a6 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
cbd576a6 202 return rv ;
203
204}